How to make an object with its own sprite draw an additional sprite on top of itself I'm making character select buttons for a Game Maker Studio 2 game, hoping to do so by just having a single object I can edit on an individual basis to change which character it represents. I also want the button itself to display the sprite of the character it's meant to represent like an image overlaying the button's own sprite. I can't seem to get a clear, direct answer on how this is done. To sum up Character select button is an object with its own assigned sprite. Each individual button object holds (a reference to) a corresponding character object the player may select by clicking that specific button. Button object should be able to check the sprite of the character object it references, and draw it on top of its own sprite without replacing it entirely. If anyone can help show me how to do that last part or barring that, perhaps point me toward a better way to achieve a similar effect, it would be appreciated.


Make a laser beam effect with Ogre and a BillboardChain http www.lpi.usra.edu lunar missions apollo apollo 15 images laser beam lg.gif I want to be able to such an effect, but I don't really know how the BillboardChain class works or how I can use it, examples for this class seems to be rare.


Can I make a mirror with Unity Free? If I understand correctly, render textures are a feature of Unity Pro, and that is the best way to create mirrors, TV screens, and so forth. If I am wrong, please tell me. What I would like to know is if there is another, probably less convenient, way to create a mirror with the free version of Unity. If I need to write a custom script, I would appreciate a basic outline of how to write it. Even better, if you know of a free script package that does this, please tell me.


Is there a way to easily make 3d models and textures for people with no prior experience? I want to make a game, but I need assets. I am wondering if I should make them by myself even though I never made any textures or 3d models before. Are there technologies that allow you to easily make them? What would you recommend me to do?


LightMap not working properly I've made a chips bag model for my game http imgur.com JcumRF4 And I textured it like this http imgur.com wpyeACZ and I googled on how to make lightmaps all of them say "Smart UV project" but when I do that, texture on my model gets broken, so thats why I dont want to use smart uv project Is there another way?, it has to be.


Would it be possible to edit character models of a PS1 game, to be played on an emulator? There are some abandoned PS1 oldies out there that I would love to see revamped with improved assets. I have some skills with some some modelling programs, so I was wondering if it would be possible to rip some models with or without their textures so that I could try to update them, and experience them on an emulator. Is this possible? Even if the edited copies cannot be reinserted into the game, would it still be possible to rip the models out so that I could edit them?


How to shade a texture two different colors? To give an example of what I'm asking about, I'll use Saints Row 3 since I've been playing that lately. In that game you can customize your looks and your car's appearance a lot. Your coat can have a primary color and a trim color. Your car can have a primary color and a stripe color, etc. Is there just a single coat texture that is being shaded two different colors somehow or are they overlaying a transparent second texture for the trim stripes that gets shaded differently? If it's just one texture I'd like to know how it's done. If it's two different textures it seems like it's a waste of space. The second texture would be the same size as the first one but mostly transparent if you just wanted to lay it on top of the first one. Or are they just carefully positioning a second, smaller texture so that it aligns properly with the first one?


Why is my texture displaying incorrect colours using dx11? I am trying to load my data from a binary file (ppm) and create a texture using this data. It is important that I learn to do it this way as I am eventually going to be packing all of my textures into a single binary file and then index them so creating the texture with pure binary data is something that I need to be able to do. It seems that the texture is drawing correctly, but the colours are incorrect. I saved my image as .ppm just for this test application. Here is the code to load my data ppm ppm ppm.read(std string("textureppm.ppm")) just to ensure the data is correct uint32 t val ppm.pixels 0 unsigned char r (val amp 0xFF000000) gt gt 24 unsigned char g (val amp 0x00FF0000) gt gt 16 unsigned char b (val amp 0x0000FF00) gt gt 8 unsigned char a (val amp 0x000000FF) ID3D11ShaderResourceView texSRV nullptr D3D11 SUBRESOURCE DATA initData amp ppm.pixels, ppm.width sizeof(uint32 t), 0 D3D11 TEXTURE2D DESC desc desc.Width ppm.width desc.Height ppm.height desc.MipLevels 1 desc.ArraySize 1 desc.Format DXGI FORMAT R8G8B8A8 UNORM desc.SampleDesc.Count 1 desc.Usage D3D11 USAGE IMMUTABLE desc.BindFlags D3D11 BIND SHADER RESOURCE ID3D11Texture2D tex HRESULT hr getDevice() gt CreateTexture2D( amp desc, amp initData, amp tex) if (SUCCEEDED(hr)) D3D11 SHADER RESOURCE VIEW DESC SRVDesc SRVDesc.Format DXGI FORMAT R8G8B8A8 UNORM SRVDesc.ViewDimension D3D11 SRV DIMENSION TEXTURE2D SRVDesc.Texture2D.MipLevels 1 hr getDevice() gt CreateShaderResourceView(tex, amp SRVDesc, amp texSRV) if (FAILED(hr)) throw 0 else setTexture(texSRV) I have packed each byte into a uint32 t as it seems that is the format that is required DXGI FORMAT R8G8B8A8 UNORM Here is the packing uint32 t ppm CreateRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) uint32 t value 0 int r2 (r amp 0xff) lt lt 24 int g2 (g amp 0xff) lt lt 16 int b2 (b amp 0xff) lt lt 8 int a2 (a amp 0xff) value r2 g2 b2 a2 return value This code produces the following texture When the original texture is Does anyone know what I am doing wrong?


FPS drop after moved from Textures to TextureAtlas in LibGDX I've started using LibGDX some time ago and I was making a test project to get used to this library. I've created some images and added them to the assets folder and loaded each image as a Texture using the AssetManager. Everything was working fine and I had 60 FPS. I wanted to work in a more efficient way so I packed all my images into an atlas using the TexturePacker tool. I loaded the atlas using the AssetManager again and started using TextureRegions instead of Textures. After this change I've started to notice sudden drops in FPS from 60 to 50 and even 30 once. I've tried to change the pixel format to RGBA4444, I've made sure that the min and mag filter were both seth to Nearest, but still I see those annoying frame drops. I'm not doing anything heavy in the game itself, it's currently some actors in a stage. I got some MoveActions and Animation, but nothing special yet. Does anyone have a clue what can cause the FPS drop? Thanks


Confusion on HLSL Samplers. Can I Set Samplers Inside Functions? I'm trying to create a system where I can instance a quad to the screen, however I've run into a problem. Like I said, I'm trying to instance the quad, so I'm trying to use the same geometry several times, and I'm trying to do it in one draw call. The issue is, I want some quads to use different textures, but I can't figure out how to get the data into a sampler so I can use it in the pixel shader. I figured that since we can simply pass in the 4 bytes of our IDirect3DTexture9 to set the global texture, I can do so when passing in my dynamic buffer. (Which also stores each objects world matrix and UV data) Now that I'm sending the data, I can't figure how to get it into the sampler, and I really want to assume that it's simply not possible. Is there any way I could achieve this?


Why is the texture all wrong on my model? Why is this happening? If possible I'd like to know what this particular problem is called. The model is a simple cube made in blender and exported with normals and MTL. Texture is the cube unwrapped with crate image on each side. Are the UV coordinates wrong?


What is the difference between a Sprite and a Texture? I have an assignment due for University, and my task is to discuss textures used within video games, and how they have evolved. My main question is, what is the fundamental difference between using a sprite, or using other texture methods? Having done a little research myself, I seem to be inclined that Sprites store images in a single file, and can be used for animations etc.. and were commonly used with older video games, generally using sprites as all of their game visuals. Now, with modern games, sprites I believe tend to be less used as technology advances and other textures are available such as bump mapping. Although sprites are still used today to accommodate features such as a health bar or long distance textures. But what are the main advantages of using textures, over sprites?


does cocos2d cache texture automatically I know if we want the textures cached we can use the sharedtexture manager to cache them, but since this is on mobile platform , why don't cocos2d x just do this for all texture loads ? when creating sprites with images, are these textures cached as well ?


How to make a texture appear the same way in a cube? My problem seems so simple, that before asking the question here I did a search on google and this site https forums.unrealengine.com development discussion content creation 33665 applying and manipulating textures on actors https www.youtube.com watch?v p6O4AgSwTmQ Trouble applying a texture to a cube How to produce a texture to represent a vector field Why do I get a blank material in Unreal Engine 4? How to create smoke that spreads outward in all directions? But nothing seemed to be related to my problem. I imported this image.png I created a material and added the image to it But I did not get the expected result in the game (I wish this yellow line were under that pink arrow that I drew) Innocently I thought the solution was obvious, so I added another image.png and added it to the material To my surprise, the result was worse, the yellow line did not even appear I realized this happens because the floor of my game is a "stretched" cube, so the image I added is appearing correctly on one of its faces, not just the one I want. I'd like to know how to make it look the same on all faces, or some value that I can change so that it appears correctly on the face I want. EDIT 1 (attempt using rotator) I put the input time to see if any value would be compatible with what I want, but none is. I tried with both texture images, but both presented the same behavior See that spinning looks like the shaft rotates around the top left of the floor. For some moments the yellow line will disappear.


Where does the roughness map go? So I used Quixel, and created a great item. I want to view it in Unity with all the maps the problem however is I have 5 maps but only know how to insert 4. Diffuse Normal AO Specular Roughness I don't see a slot for roughness (AKA gloss).


Is it possible to look up a texel from a texture in GLES2 GLSL framgent shader without using sampler? Is there some way I can directly access texture memory from fragment shader in GLES2 GLSL? I don't need the sampler to be involved since I am just using it as a look up table.


How to read BC4 texture in GLSL? I'm supposed to receive a texture in BC4 format. In OpenGL, i guess this format is called GL COMPRESSED RED RGTC1. The texture is not really a "texture", more like a data to handle at fragment shader. Usually, to get colors from a texture within a fragment shader, i do uniform sampler2D TextureUnit void main() vec4 TexColor texture2D(TextureUnit, vec2(gl TexCoord 0 )) (...) the result of which is obviously a v4, for RGBA. But now, i'm supposed to receive a single float from the read. I'm struggling to understand how this is achieved. Should i still use a texture sampler, and expect the value to be in a specific position (for example, within TexColor.r ?), or should i use something else ?


How can I create random noise that is seamless across modular game assets? Does anyone know how I can create a texture for a modular tile, such that when the tiles are arranged, random weathering effects such as scratches will be continuous across seams? An example photo below shows the ideal result. The scratches are continuous between different tiles. Is creating weathering effects like this possible using any procedural software?


3ds max "thread stiching" plugin for cloths or furniture i m trying to find a plugin or way to add 3D thread stiching to a mesh. It would be perfect if you could creat thread stiches along edges in "editpoly" mode. I know that you can somehow do this in Z Brush with customized alpha brushes but in my opinion its a bit complicated. I could also imagine alining a editable spline along a mesh edge. Important for me would be that this "unknown tool" would also add the displacement on the canvas and the stiches so i can use "render to texture" to give seems realistic look. Thisway you could always creat perfect stiches with realistic looking displacement like in the picture below without to much affort. http www.esunroof.com contrast stitch.jpg http t1.gstatic.com images?q tbn ANd9GcQplgCvhur ynthz15Qdaqpv1QRwkG4K6sjhVjDqzzxm6OaY9Bt would be awesome if you know a way to do this, Thanks a lot lot )


libgdx texture edge blending problem I have two completely white bitmaps here They're there, trust me. When I put one on top of the other and scale them down with TextureFilter.Linear I get this How do I get rid of the dark pixels?


Reversing plane projection texture mapping algorithm I found this algorithm in some old codebase, it takes two triangles from a mesh ABC and PMN, where ABC is the triangle that will be rendered and PMN is an extra triangle that is only used to generate the UV coordinate for ABC and is not rendered. I am trying to create a reverse algorithm to calculate the PMN triangle positions based on UV coordinates of a triangle and ABC positions of the same triangle. Vector3f A stored in mesh data Vector3f B stored in mesh data Vector3f C stored in mesh data Vector3f P stored in mesh data Vector3f M stored in mesh data Vector3f N stored in mesh data Vector3f PM M.sub(P, new Vector3f()) Vector3f PN N.sub(P, new Vector3f()) Vector3f PA A.sub(P, new Vector3f()) Vector3f PB B.sub(P, new Vector3f()) Vector3f PC C.sub(P, new Vector3f()) Vector3f PMxPN PM.cross(PN, new Vector3f()) Calculate the U coordinates Vector3f U PN.cross(PMxPN, new Vector3f()) float Mu 1.0F U.dot(PM) float Ua U.dot(PA) Mu 1st U coordinate (for vertex A) float Ub U.dot(PB) Mu 2nd U coordinate (for vertex B) float Uc U.dot(PC) Mu 3rd U coordinate (for vertex C) Calculate the V coordinates Vector3f V PM.cross(PMxPN, new Vector3f()) float Mv 1 V.dot(PN) float Va V.dot(PA) Mv 1st V coordinate (for vertex A) float Vb V.dot(PB) Mv 2nd V coordinate (for vertex B) float Vc V.dot(PC) Mv 3rd V coordinate (for vertex C) Formatted LaTex represention of the same algorithm vec PM vec M vec P vec PN vec N vec P vec PA vec A vec P vec PB vec B vec P vec PC vec C vec P vec PMPN vec PM times vec PN vec U vec PN times vec PMPN Mu frac 1 vec U cdot vec PM Ua vec U cdot vec PA times Mu Ub vec U cdot vec PB times Mu Uc vec U cdot vec PC times Mu vec V vec PM times vec PMPN Mv frac 1 vec V cdot vec PN Va vec V cdot vec PA times Mv Vb vec V cdot vec PB times Mv Vc vec V cdot vec PC times Mv


Replicating no. of sprites without letting the app to slow down and crash Is it possible that if I'm making a a simple drag n drop game, does making a new sprite via constructor with texture as a parameter makes the game slower and depletes more memory until it crashes or does making a new texture via constructor cause the memory to go slow? I'm on a revision for the new drag n drop puzzle game where the only goal is to stack the most no. of objects as you can before it falls off the platform. Is it a good idea to create another sprite with texture as a parameter every time a player drag n drop another object? Here's the start of the dry run looked like and I set it to debug mode so that the platform is completely block the pit to test the replication test. Afterwards, when it reaches from hundreds to thousands, this will be like this and the game gets slower. When the game crashes, here's the result via Logcat 12 11 16 38 53.953 E AudioTrack(25701) AudioFlinger could not create track, status 22 12 11 16 38 53.953 E SoundPool(25701) Error creating AudioTrack 12 11 16 38 53.993 D dalvikvm(25701) GC EXPLICIT freed 947K, 14 free 14414K 16672K, paused 2ms 4ms, total 96ms 12 11 16 39 16.363 E AudioTrack(25701) AudioFlinger could not create track, status 22 12 11 16 39 16.363 E SoundPool(25701) Error creating AudioTrack 12 11 16 39 16.433 D dalvikvm(25701) GC FOR ALLOC freed 2120K, 15 free 14418K 16848K, paused 47ms, total 47ms By the way, I'm using BodyEditor library for Box2D program and rendering, a physics engine.


Triangle Texture Packing Problem I'm trying to create a texture atlas where each triangle face is laid separately from each other (i.e. it is not typical mesh parameterization). In order to do this, I would have to pack the triangles into a 2D texture image. Can someone suggest a good algorithm to do this efficiently, both timely and spatially?


Unity 5 Textures look strange in Deferred Rendering I've created an exterior terrain scene in Unity 5 which features lots of trees and grass but some textures look awful and I'm wondering why. Please see the attached image This texture problem is especially obvious at night (I'm using Time of Day unity asset for Day Night cycle) but also during day light it doesn't look good. The tree bark looks like plastic and also the ground textures are too bright and lack contrast. Stone texture on the other hand look perfectly fine. Can somebody point me into the right direction of what I'm doing wrong here with my lighting and rendering?


Accessing and changing texture data in SlimDX How can I access and change texture data in SlimDX? I have a Texture2D and a Texture3D and I need to be able to go in and change either a single or group of pixels.


How do I use transparent textures in panda3d? I need to map a partially transparent texture on a flat quad with panda3d. With the quad as a canvas I'd like to create something like sprites positioned in the 3d coordinate system. I wanted to render a tree. As you can see the color values of the trees border have been stretched over the texture. How can I change the texture mode to include the alpha channel ? I just don't know how to get hold of the right settings. A link to the right manpage would be perfect. If you need more information about the setup you might want to look at my other question How do I use setFilmSize in panda3d to achieve the correct view?


How can I find the right UV coordinates for interpolating a bezier curve? I'll let this picture do the talking. I'm trying to create a mesh from a bezier curve and then add a texture to it. The problem here is that the interpolation points along the curve do not increase linearly, so points farther from the control point (near the endpoints) stretch and those in the bend contract, causing the texture to be uneven across the curve, which can be problematic when using a pattern like stripes on a road. How can I determine how far along the curve the vertices actually are so I can give a proper UV coordinate? EDIT Allow me to clarify that I'm not talking about the trapezoidal distortion of the roads. That I know is normal and I'm not concerned about. I've updated the image to show more clearly where my concerns are. Interpolating over the curve I get 10 segments, but each of these 10 segments is not spaced at an equal point along the curve, so I have to account for this in assigning UV data to vertices or else the road texture will stretch shrink depending on how far apart vertices are at that particular part of the curve.


Why is it when I render a basic cube, my editor's grid changes too? I have one HLSL file for DirectX11 that only has input layout for color and position. Then another HLSL file for the simple cube that has position, normal and textures. What I noticed is when I render the simple cube the grid also changes and doesn't remain pure white color. They have different pixelshaders, vertexshaders, constant buffers and different inputlayout descriptions. Would anyone like to chip in and help get this resolved? This has been puzzling for a day!


minecraft mapping from tibia OTBM file I am new to minecraft modding but i program for a living and it looks quite simple to get around. I have this fantasy and a quick internet search shows im not the only one. For those of you who do not know tibia is an MMORPG first released in 1997. It is a 2d tile based game and i would like to see it in 3D. since it is a tile based game it fits nicely with the minecraft architecture. Tibia is a close sourced game but there is TibiaOT which is developed by the community and the map file format is OTBM (open tibia binary map). This is a set of 15 2D grids where each grid represents a floor or the height of the grid, the file comes with two more files with monster spawns and default item locations like chests. There is a tibia texture pack for minecraft called "Tibian texture pack", so we got the materials covered. all in all we have the following a native tibia map and a minecraft texture pack people have been building tibia maps manually for years now, it seems stupid because we have a binary file for the real map. what we need is a way to map the OTBM file to a minecraft map. i am looking for tools and any other tips a on how to digest the files into a minecraft map file. an explanation of minecraft map file format would also be very helpful.


Multiple colored textures vs Color Overlay Let's say we're using DirectX 9 10 11. In our game we have a character wearing armor. The armor has 50 different color variations. So, if armor is red, the first method would load the red texture from file. The second method would display the 1 base texture, with a red overlay. Code wise the overlay armor would just contain an extra flag that would specify color. Is it faster more efficient to load different textures in? Or, is it faster more efficient to color the texture on the fly? I'm not aware if there is some huge overhead for dropping a tint over a texture...


reading from texture2d resource in directx11 Hi i am trying to read data in resource, which i used to do well without any problems. but suddenly it is not working. first i made immutable resource that has data in it, which is XMFLOAT4(1,1,1,1) here. next i made staging resource for reading. lastly, i called map unmap to read and store data into outputArr. (all HRESULT checked already) int WIDTH 10, HEIGHT 2 ID3D11Texture2D resource create texture D3D11 TEXTURE2D DESC texDesc texDesc.BindFlags D3D11 BIND SHADER RESOURCE texDesc.Usage D3D11 USAGE IMMUTABLE texDesc.Format DXGI FORMAT R32G32B32A32 FLOAT texDesc.Width WIDTH texDesc.Height HEIGHT texDesc.CPUAccessFlags 0 texDesc.ArraySize 1 texDesc.MipLevels 1 texDesc.SampleDesc.Count 1 texDesc.SampleDesc.Quality 0 texDesc.MiscFlags 0 XMFLOAT4 initValues new XMFLOAT4 WIDTH HEIGHT for (int i 0 i lt WIDTH HEIGHT i) initValues i XMFLOAT4(1,1,1,1) D3D11 SUBRESOURCE DATA data data.pSysMem initValues data.SysMemPitch sizeof(XMFLOAT4) WIDTH data.SysMemSlicePitch 0 device gt CreateTexture2D( amp texDesc, amp data, amp resource) ID3D11Texture2D staging create texture for reading D3D11 TEXTURE2D DESC stgDesc stgDesc.BindFlags 0 stgDesc.Usage D3D11 USAGE STAGING stgDesc.Format DXGI FORMAT R32G32B32A32 FLOAT stgDesc.Width WIDTH stgDesc.Height HEIGHT stgDesc.CPUAccessFlags D3D11 CPU ACCESS READ stgDesc.ArraySize 1 stgDesc.MipLevels 1 stgDesc.SampleDesc.Count 1 stgDesc.SampleDesc.Quality 0 stgDesc.MiscFlags 0 device gt CreateTexture2D( amp stgDesc, nullptr, amp staging) XMFLOAT4 outputArr new XMFLOAT4 WIDTH HEIGHT READ dContext gt CopyResource(staging, resource) D3D11 MAPPED SUBRESOURCE mappedResource ZeroMemory( amp mappedResource, sizeof(D3D11 MAPPED SUBRESOURCE)) dContext gt Map(staging, 0, D3D11 MAP READ, 0, amp mappedResource) outputArr reinterpret cast lt XMFLOAT4 gt (mappedResource.pData) std vector lt XMFLOAT4 gt testV for (int y 0 y lt HEIGHT y) for (int x 0 x lt WIDTH x) int idx y WIDTH x testV.push back(outputArr idx ) dContext gt Unmap(staging, 0) and it turns out, only when WIDTH is multiple of 16(HEIGHT doesn't seem to be matter here), it copies the data well into ALL element of array, otherwise it fill out just 0 into array until next 16 element. For example, if width height is 10 2, first 10 elements of outputArr will have proper data and next 6 elements have just 0, and next another 10 elements with data, and 6 elements with 0, so on. i haven't had any problem on dealing with resources. and struggle still. just my humble assumption is that there might be specific alignment in number of width of resource that i miss. Or silly mistake in my process. Hope anyone can find something from this question. thanks


Ogre3d 2.1 How to apply texture on mesh? I have searched forums and tried to read the Ogre 2.1 samples, but I still have no clue how to apply texture on mesh ( Here what I've done so far. I use Easy Ogre Exporter to export the scene (actually I just need the model and texture). I got the following files modelRoot.mesh modelRoot.skeleton model.material model.tga Note I also use OgreMeshTool d.exe to upgrade the mesh from v1 to v2. I render this model into Ogre In the file resources2.cfg Essential Zip .. Data DebugPack.zip I add the model files (4 files I got from Easy Ogre Exporter at step 1 above) into DebugPack.zip file. And I use this code to add the model into the Ogre scene void MeshHelper CreateMesh(Ogre String szFileName, Ogre Vector3 scale) Bring the mesh to scene m meshItem m sceneManager gt createItem(szFileName, Ogre ResourceGroupManager AUTODETECT RESOURCE GROUP NAME, Ogre SCENE DYNAMIC) m meshSceneNode m sceneManager gt getRootSceneNode(Ogre SCENE DYNAMIC) gt createChildSceneNode(Ogre SCENE DYNAMIC) m meshSceneNode gt attachObject(m meshItem) if (nullptr ! scale) m meshSceneNode gt scale(scale gt x, scale gt y, scale gt z) ... meshHelper.CreateMesh("modelRoot.mesh", amp meshScale) But I can only render the model without texture ( Please help me to apply these texture into my model model.material model.tga Thanks for reading )


How to make a texture not stretch? I have made two textures in Photoshop. I applied one of the textures to the sides (one to each side, in the Unity editor) and the other one to the top and bottom sides. However when I extend the object the texture gets stretched which I don't want. Is there any way to prevent this? The object is a cube. I don't want the texture to get stretched if I make the cube larger and I don't want the texture to get shrunk if I were to make the quad smaller. This is what I don't want as a result


Why are textures always square powers of two? What if they aren't? Why are the resolution of textures in games always a power of two (128x128, 256x256, 512x512, 1024x1024, etc.)? Wouldn't it be smart to save on the game's file size and make the texture exactly fit the UV unwrapped model? What would happen if there was a texture that was not a power of two? Would it be incorrect to have a texture be something like 256x512, or 512x1024? Or would this cause the problems that non power of two textures may cause?


Why texture coordinate of flat surface reflection is calculated like this in fragment shader? The whole project is here https developer.apple.com library mac samplecode GLEssentials Introduction Intro.html The rendering flow is like this Render the character upside down to a texture. Render the character normally. Render the flat reflection surface below the character using the texture from step 1. I don't understand the texture coordinate calculation in the fragment shader, specifically the block marked with ??? below precision highp float Color of tint to apply (blue) const vec4 tintColor vec4(0.0, 0.0, 1.0, 1.0) Amount of tint to apply const float tintFactor 0.2 varying vec3 varNormal varying vec3 varEyeDir uniform sampler2D diffuseTexture void main (void) Compute reflection vector vec3 reflectDir reflect(varEyeDir, varNormal) Compute altitude and azimuth angles vec2 texcoord texcoord.t normalize(reflectDir).y ??????????????????????????????????????????????? reflectDir.y 0.0 Why clear reflectDir.y? texcoord.s normalize(reflectDir).x 0.5 Why times 0.5? Translate index values into proper range if (reflectDir.z gt 0.0) texcoord (texcoord 1.0) 0.5 else texcoord.t (texcoord.t 1.0) 0.5 texcoord.s ( texcoord.s) 0.5 1.0 Why translation of s is like this, different from t? ??????????????????????????????????????????????? Do a lookup into the environment map. vec4 texColor texture2D(diffuseTexture, texcoord) Add some blue tint to the image so it looks more like a mirror or glass gl FragColor mix(texColor, tintColor, tintFactor) Thanks in advance to anyone who can demystify this for me!


pre rendering light on texture based on bump map Using a gray scale bump map and N sources of colored light, what is the algorithm to render the light on the textured surface, assuming I have the angle(s) and distance of each light source? (I am pre rendering in software). I have the part where it renders light based on the position and angle of light source. My question is twofold How do I decide on an RGB color based on multiple different light sources? Is it simply additive by nature? What do I do about cases where the angle is not a sufficient way to determine intensity? For instance when there is a deep caveat in the surface and a higher elevated area is blocking the light to that lower shaded area? How do you handle something like that?


Making a radial gradient visual range I am currently working on a project in p5JS. So lets say i've got a texture and top of it, i've got a radial gradient that is overlapping on the texture. I want to make this like a cool vision range effect in 2D. I believe you can imagine this stitation. So how am i able to start this thing? Should i use another framework to do this?


Best way to load multiple TextureRegion from multiple bitmaps in AndEngine I've seen a lot of examples of AndEngine usage where some bitmaps are mapped into some TextureRegions and loaded into an Atlas. But what if I have a lot of bitmaps, where each bitmap is a sprite sheet, with several sprites for a given entity? How can I extract multiple texture regions from each bitmap and load all that into a single Atlas?


Monogame Texture anti aliasing result in transparent edges This is a follow up question on a previous issue I faced with a game I'm trying to make. It's in a 2D isometric perspective and the levels are created from individual tiles. A simple 3x3 map can be seen here The tiles are individually added to the sprite batch, and (at least, this is what I think is happening) each one get anti aliased on their edges, resulting in a small blur which creates the thin edges that you can see in the picture. To make matters worse, I actually want to provide a bit more complex tiles in my game than what is displayed above. For example, I want to be able to show roads. To do so, I wanted to layer multiple sprites on top of each other, resulting in the picture below I think you can see where I'm going here. The same problem that I described with the aliasing is now occuring aroud each texture. So sad. I know I can use Point sampling to make the textures align pixel perfect, but even though this does work, the (relatively) high resolution textures really do not seem fit for such a setting I mean, these edges simply need to be anti aliased. So, my question to you all is Is there a way to stitch my tiles (and tile pieces) together in a way so that anti aliasing does not ruin it with those annoying edges, while still being able to produce a nicely anti aliased result? I hope there is, and that someone here can show me how ) Thanks, Rutger Edit 1 Changed the title to be more representative to the problem (I hope?)


Spherical fractal noise generator in shader I have a growing sphere in space, and I thought of having a procedural generated texture over it. Since it is growing, I thought a fractal would be a great choice, because more details would be visible the larger the sphere get (and I could mess with some parameter over time to have it animated). A quick Mandelbrot implementation in GLSL showed it would be too expensive to have it in the devices I am targeting also, I don't know how to map a cool looking fractal over complex plane onto a sphere without distortions (I expect the players to fly around this sphere in every direction, so there should be no "glued" edges or collapsed points), neither I have the background to devise project a fractal over the spherical surface myself (probably was done before, but I could not find). So weighting the requisites of the procedural texture Fast to run, for low end mobile GPU Over a spherical surface domain Growing in details with growing in size Possible to animate (BONUS) Cool looking (of course) then I thought it might be impossible within the constraints. But since I am no expert in this fractal thing, I thought I could ask it here first before scraping out the idea. Maybe it is really not a fractal I need, and there is some other kind of noise with growing details I could use. Do you know of such noise generation procedure? Do you know of any noise generator with uniform distribution over spherical sufaces, or any fractals whose domain is a sphere? Can you suggest any alternatives for my situation?


Should the content pipeline tools be embedded in the engine? How minimal should a games engine be? How much of the content pipeline should be embedded in the engine? Some use cases where the super engine might be useful When loading user content, the user isn't required to package up his textures, the engine will do it at load time. A script requests a font at a much larger size than was pre generated, the engine could parse the ttf file ad build a new texture atlas. Halo forge. None of this is free of course. This requires your content pipeline tools to written in C . Support libraries you use in the pipeline need to be compiled for use on the device. It requires the content generation to be not buggy. And it generally makes your engine larger and unwieldy. What are some other pros and cons? Do the pros outweigh the cons? Some specific questions Should engine be capable of loading various image formats? A TGA only loader is pretty easy to hand code. What about audio formats? Is it feasible to only support loading wav files? What about ambient music files which are often huge. Should the engine be capable of dynamic TTF parsing and atlas generation? Texture packing.


How to print Depth to a Texture2D and then read it in the next pass on a shader in DirectX11 I'm programming a two pass effect in DirectX 11 (SharpDX). It's supposed to write the depth to a texture in the first pass and then use that texture to extract data on the second one in the pixel shader. What I get is a white screen, with nothing but the interface and I don't know why nothing is being printed. What could be the problem? I would say I should get at least something from the Depth Texture. This is how I'm setting the depth texture values this.depthBuffer new Texture2D(device, new Texture2DDescription() Format Format.R32 Typeless, ArraySize 1, MipLevels 1, Width (int)host.ActualWidth, Height (int)host.ActualHeight, SampleDescription new SampleDescription(1, 0), Usage ResourceUsage.Default, BindFlags BindFlags.DepthStencil BindFlags.ShaderResource, CpuAccessFlags CpuAccessFlags.None, OptionFlags ResourceOptionFlags.None, ) this.depthBufferShaderResourceView new ShaderResourceView(this.device, this.depthBuffer, new ShaderResourceViewDescription() Format Format.R32 Float, Dimension ShaderResourceViewDimension.Texture2D, Texture2D new ShaderResourceViewDescription.Texture2DResource() MipLevels 1, MostDetailedMip 0, ) var depthStencilDesc new DepthStencilStateDescription() DepthComparison Comparison.LessEqual, DepthWriteMask global SharpDX.Direct3D11.DepthWriteMask.All, IsDepthEnabled true, And here is how I sample the depth in the .fx file int3 posTex int3(input.p.xy, 0) float depthPixel DepthTexture.Load(posTex) float4 color float4(depthPixel, depthPixel , depthPixel, 1.0f ) return color And here the way I'm now setting the Depth Buffer stencil view as a Render Target in 2 passes. In the first I try to set the depthstencilview as a target. In the second pass I'm trying to set teh depth texture as a shader resource to read from it. this.device.ImmediateContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(this.vertexBuffer, LinesVertex.SizeInBytes, 0)) PASS 0 this.device.ImmediateContext.OutputMerger.SetTargets(depthBufferStencilView) this.device.ImmediateContext.ClearDepthStencilView(this.depthBufferStencilView, DepthStencilClearFlags.Depth DepthStencilClearFlags.Stencil, 1.0f, 0) this.technique.GetPassByIndex(0).Apply(this.device.ImmediateContext) this.device.ImmediateContext.DrawIndexed(this.geometry.Indices.Length, 0, 0) PASS 1 this.device.ImmediateContext.OutputMerger.ResetTargets() unbinding the depthStencilView this.device.ImmediateContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(this.vertexBuffer, LinesVertex.SizeInBytes, 0)) this.depthStencilShaderResourceVariable effect.GetVariableByName("DepthTexture").AsShaderResource() this.depthStencilShaderResourceVariable.SetResource(this.depthBufferShaderResourceView) this.technique.GetPassByIndex(1).Apply(this.device.ImmediateContext) this.device.ImmediateContext.DrawIndexed(this.geometry.Indices.Length, 0, 0) Finally, this is how I set the two passes in the .fx file technique11 RenderMyTechnique pass P0 SetDepthStencilState( DSSDepthLessEqual, 0 ) SetVertexShader ( CompileShader( vs 4 0, VShader() ) ) SetHullShader ( NULL ) SetDomainShader ( NULL ) SetGeometryShader ( NULL ) SetPixelShader ( NULL ) pass P1 SetDepthStencilState( DSSDepthLessEqual, 0 ) SetVertexShader ( CompileShader( vs 4 0, VShader() ) ) SetHullShader ( NULL ) SetDomainShader ( NULL ) SetGeometryShader ( CompileShader( gs 4 0, GShader() ) ) SetPixelShader ( CompileShader( ps 4 0, PShader() ) )


How do I generate mipmap .png and model .obj files for LibGDX? I'm playing a bit with LibGDX (OpenGL ES 2.0 wrapper for Android). I found some sample code which used prepared files to load models and mipmap textures for them, e.g., at https github.com libgdx libgdx blob master demos invaders gdx invaders src com badlogic gdxinvaders RendererGL20.java it reads .obj file for the model and RGB565 format .png file to apply a mipmapped texture to it. What is the best easiest way for me to create these files? I understand .obj files are generated by a bunch of tools (I installed Blender, Wings3D and Kerkythea so far), but which ones will be the most user friendly for someone unfamiliar with 3D modelling? But more importantly, how do I produce a .png file with the mipmapped texture? The .png I looked at ( https github.com libgdx libgdx blob master demos invaders gdx invaders data ship.png ) seems to include different textures for each of the faces, probably created with some tool. I browsed through the menus for the 3 tools I have installed but didn't find an option to export such a .png file. What am I missing?


LibGDX render sprites in tiled map format ( convert texture to sprite ) I am creating a game in which till now I have used textures to create A 2D tiled game. I have created a matrix which converts the touch co ordinates into a array index number and according to that index number, a specific tile gets selected. The problem is that I want to emulate the same behaviour for sprites instead of textures. But I get stuck on what could possibly be given as the co ordinates for the sprite position? I want to just use Sprites instead of using textures as Sprites are easier to animate. No matter which values I give, the screen remains white and sometimes a different tile's texture gets rendered at a different position. What am I doing wrong? Function returns the position of tile touched int getPos(int screenX, int screenY) x screenX (int)xSize y screenY (int)ySize y Squares Y 1 y int result y Squares X x return result Previous Render function public void render(float delta) batch.begin() Tile current initial layout if(current.topLink ! null) for (int Pos 0 Pos lt Squares X Pos ) for (int ypos 0 ypos lt Squares Y ypos ) batch.draw(bg texture, Pos xSize, ypos ySize, xSize, ySize) if(current! null) batch.draw(current.getTexture(), Pos xSize, ypos ySize, xSize, ySize) current current.topLink if(Gdx.input.justTouched()) if(win false) int x Gdx.input.getX() int y Gdx.input.getY() touchDown(getPos(x, y)) else System.out.print(" nLevel Completed !! " utils.level) game.dispose() batch.end() New Render Function public void render() batch.begin() Tile current initial layout if(current.topLink ! null) for (int Pos 0 Pos lt Squares X Pos ) for (int ypos 0 ypos lt Squares Y ypos ) batch.draw(bg texture, Pos xSize, ypos ySize, xSize, ySize) if(current! null) spriteBatch.begin() texture current.getTexture() sprite new Sprite(texture,(int)xSize,(int)ySize) sprite.setPosition(Pos xSize, ypos ySize) batch.draw(current.getTexture(), Pos xSize, ypos ySize, xSize, ySize) sprite.draw(spriteBatch) current current.topLink spriteBatch.end() if(Gdx.input.justTouched()) if(win false) int x Gdx.input.getX() int y Gdx.input.getY() touchDown(getPos(x, y)) else System.out.print(" nGame WON for Level " utils.level) game.dispose() batch.end()


How to make part of the Texture not to be scaled.? I am new to LibGdx, i was doing one example for my learning and struck with this question, i had searched in google but i am not able to find the answer for this. 1) How to make part of the Texture not to be scaled. as you can see in the image i am reducing the height of bottom pipes so that the top pipe scale is reduced to fit the height given but i want the top part of the pipe not to be scaled. in this example whole pipe is one texture, for fixing this problem i thought to split the top and body to separate texture and set height for only body but i thought there should be some other solution so that only i had put this question here.


d3d11 black texture when manually creating from image (Rust) I am trying to create a ID3D11Texture2D from a RgbaImage loaded from a .jpg. The below code produces no errors. However, the texture is black when it is actually rendered. I know the standard way to load textures is through the DirectXTex library, but I was having issues linking with it and can't find any premade Rust bindings. Should the below code settings work to create a working ID3D11Texture2D? Is there a way to view the contents of a ID3D11Texture2D in order to debug? Are there DirectXTex bindings for Rust? fn load resource from file(device amp Device, path amp Path) gt error Result lt Texture gt unsafe let image Reader open(path)?.decode()?.to rgba() let mut sample desc dxgitype DXGI SAMPLE DESC default() sample desc.Count 1 sample desc.Quality 0 let mut desc d3d11 D3D11 TEXTURE2D DESC default() desc.Width image.width() desc.Height image.height() desc.MipLevels 1 desc.ArraySize 1 desc.Format dxgiformat DXGI FORMAT R8G8B8A8 UINT desc.Usage d3d11 D3D11 USAGE DEFAULT desc.SampleDesc sample desc desc.BindFlags d3d11 D3D11 BIND SHADER RESOURCE desc.CPUAccessFlags 0 desc.MiscFlags 0 let mut data d3d11 D3D11 SUBRESOURCE DATA default() data.SysMemPitch (image.sample layout().width stride mem size of lt Rgba lt u8 gt gt ()) as u32 let buffer Vec lt u8 gt image.into raw() data.pSysMem buffer.as ptr() as const data.SysMemSlicePitch buffer.len() as u32 let mut texture ptr null mut() device.as ref().CreateTexture2D( amp desc, amp data, amp mut texture, ).result()? let texture NonNull new(texture).ok or(null ptr err!())? drop(buffer) let mut resource view ptr null mut() device.as ref().CreateShaderResourceView( amp texture.as ref() as const d3d11 ID3D11Resource as mut , ptr null(), amp mut resource view, ).result()? let resource view NonNull new(resource view).ok or(null ptr err!())? Ok( Texture(Arc new(TextureInner texture, resource view, )))


Rendering Texture Quad to Screen or FBO (OpenGL ES) I need to render the texture on the iOS device's screen or a render to texture frame buffer object. But it does not show any texture. It's all black. (I am loading texture with image myself for testing purpose) Load texture data UIImage image UIImage imageNamed "textureImage.png" GLuint width FRAME WIDTH GLuint height FRAME HEIGHT Create context void imageData malloc(height width 4) CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB() CGContextRef context CGBitmapContextCreate(imageData, width, height, 8, 4 width, colorSpace, kCGImageAlphaPremultipliedLast kCGBitmapByteOrder32Big) CGColorSpaceRelease(colorSpace) Prepare image CGContextClearRect(context, CGRectMake(0, 0, width, height)) CGContextDrawImage(context, CGRectMake(0, 0, width, height), image.CGImage) glGenTextures(1, amp texture) glBindTexture(GL TEXTURE 2D, texture) glTexParameteri(GL TEXTURE 2D, GL TEXTURE MIN FILTER, GL NEAREST) glTexImage2D(GL TEXTURE 2D, 0, GL RGBA, width, height, 0, GL RGBA, GL UNSIGNED BYTE, imageData) glTexParameterf(GL TEXTURE 2D, GL TEXTURE WRAP S, GL CLAMP TO EDGE) glTexParameterf(GL TEXTURE 2D, GL TEXTURE WRAP T, GL CLAMP TO EDGE) Simple Texture Quad drawing code mentioned here Bind Texture, Bind render to texture FBO and then draw the quad const float quadPositions 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0 const float quadTexcoords 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0 stop using VBO glBindBuffer(GL ARRAY BUFFER, 0) setup buffer offsets glVertexAttribPointer(ATTRIB VERTEX, 3, GL FLOAT, GL FALSE, 3 sizeof(float), quadPositions) glVertexAttribPointer(ATTRIB TEXCOORD0, 2, GL FLOAT, GL FALSE, 2 sizeof(float), quadTexcoords) ensure the proper arrays are enabled glEnableVertexAttribArray(ATTRIB VERTEX) glEnableVertexAttribArray(ATTRIB TEXCOORD0) Bind Texture and render to texture FBO. glBindTexture(GL TEXTURE 2D, GLid) Actually wanted to render it to render to texture FBO, but now testing directly on default FBO. glBindFramebuffer(GL FRAMEBUFFER, textureFBO pixelBuffernum ) draw glDrawArrays(GL TRIANGLES, 0, 2 3) What am I doing wrong in this code? P.S. I'm not familiar with shaders yet, so it is difficult for me to make use of them right now.


How AAA games use this texture in the tone mapping shader? I found that Battlefield 3 as well as Saint's Row the Third use this texture in their final tone mapping stage. Can anyone share a link to an article about how this texture is used? UPDATE As there are hardly any examples of Color Grading implementation on the net, I will post my quick and dirty sample for XNA 4.0. This does nothing but builds the default 2d colormap from scratch on GPU, copies it's contents into a 3d texture on CPU and performs the actual color correction with the shader code from the article provided in the answer. XNA 4.0 Color Correction Sample If you want to know what you can do with this, look here http the witness.net news 2012 08 fun with in engine color grading In short the author explains there, how you can basically make a screenshot of your normal in game image with the default color grading palette on top, perform screenshot color correction in photoshop, cut and copy the deformed color correction palette into the engine and have that color correction applied for every in game scene automatically.


Capturing small details in textures without making a huge map Ex. Nuts and bolts on a cabinet. Said items are tiny relative to the cabinet, and on a texture map looks like an indistinguishable dot. Is it worth it to separate these tiny details into a mesh of their own? Obvious cons are increasing poly count and draw calls, disregarding how much of an increase that would be. Is there a generally accepted way of going about this?


Why loading 250mb of compressed texture data spills Out of memory error on Windows I am making SDL2 OpenGL 2D game for Windows with a lot of pre rendered sprites. When testing on my laptop I got SDL Surface creation failed out of memory error during loading assets. Windows' Application Manager on other machine shows that my game in stress uses less then 170 mb of ram memory and MSI Afterburner shows that vram usage for entire system is below 800 mb. My laptop has 8 gb of RAM and 2048 mb of vram (GeForce 840 M). I am obviously doing something terribly wrong, but I don't know wheres my ram usage counting technique is wrong, or maybe for some reasons I have less memory then available on system, or something completely else is happening. But I don't know where to search for. I will gladly post some code if I need to, but I don't know which parts will be useful in diagnosing the problem. One more thing, I am using GL COMPRESSED RGBA ARB for all textures Edited It's not exactly the same situation as what's described here. I've already measured vram usage, and numbers are way below available count, yet still I get out of memory error. So, the question is "How measure properly vram usage", not "How measure vram usage", as in other question. I am not a native English speaker, so maybe there is some cloud in my title I will gladly accept correction for title Edited I reckon the image load procedure might be useful here, since it is heavily related to issue. Game Texture Game Asset GetTex(const UString amp path) Texture ret assetsTex path if (ret) return ret const UString amp absolutePath GetAbsolutePath(path) SDL Surface surface IMG Load(absolutePath.GetCStr()) if (!surface) ERR( U("Failed to load surface 1 "), UString FromA(IMG GetError())) Here's my problem! int bpp surface gt format gt BytesPerPixel UInt8 pixels (UInt8 )surface gt pixels if (bpp ! 3 amp amp bpp ! 4) WARN( U("Texture ' 1 ' is not 24 bpp or 32 bpp! Aborting load..."), path) SDL FreeSurface(surface) return nullptr GLuint tex glGenTextures(1, amp tex) glBindTexture(GL TEXTURE 2D, tex) if (bpp 3) glTexImage2D(GL TEXTURE 2D, 0, GL COMPRESSED RGBA ARB, surface gt w, surface gt h, 0, GL RGB, GL UNSIGNED BYTE, pixels) else if (bpp 4) glTexImage2D(GL TEXTURE 2D, 0, GL COMPRESSED RGBA ARB, surface gt w, surface gt h, 0, GL RGBA, GL UNSIGNED BYTE, pixels) glTexParameteri(GL TEXTURE 2D, GL TEXTURE MIN FILTER, GL LINEAR) glTexParameteri(GL TEXTURE 2D, GL TEXTURE MAG FILTER, GL LINEAR) glTexParameteri(GL TEXTURE 2D, GL TEXTURE WRAP S, GL CLAMP TO EDGE) glTexParameteri(GL TEXTURE 2D, GL TEXTURE WRAP T, GL CLAMP TO EDGE) ret new Texture(tex, surface gt w, surface gt h) SDL FreeSurface(surface) assetsTex path ret return ret Edited I moved from SDL Image to stb image for image load, but I still got out of memory error message Edited I've installed VS Studio 2015 on my laptop and found out Task Manager shows application eats up 650 mb in the moment of Out of memory casted GetProcessMemoryInfo returns PeakWorkingSetSize 720 mb and WorkingSetSize 650 mb as well But Visual 2015 UI (Debug Diagnostic, memory usage) shows that application actually consumed 1.7 gb. Even if this is true and both former are not, there is still plenty of room for allocations (application is 32 bit, there are 8 gb of on board memory, not counting page file) I tried to convert png tga and load them up, to check if png uncompressing is eating memory, but the result was exactly the same, the same Out of memory error Out of memory is spit in png load function which has nothing to do with OpenGL and GPU at all. I am retagging and retitleing the post


OpenGL ES 2.0. Sprite Sheet Animation I've found a bunch of tutorials on how to make this work on Open GL 1 amp 1.1 but I can't find it for 2.0. I would work it out by loading the texture and use a matrix on the vertex shader to move through the sprite sheet. I'm looking for the most efficient way to do it. I've read that when you do the thing I'm proposing you are constantly changing the VBO's and that that is not good. Edit Been doing some research myself. Came upon this two Updating Texture and referring to the one before PBO's. I can't use PBO's since i'm using ES version of OpenGL so I suppose the best way is to make FBO's but, what I still don't get, is if I should create a Sprite atlas batch and make a FBO loadtexture for each frame of if I should load every frame into the buffer and change just de texture directions.


Is it possible to use unnormalized texture coordinates from a GLES2 GLSL fragment shader? I want to look up a texel from my GLES2 GLSL fragment shader using un normalized texture coordinates (0 w, 0 h instead of 0 1, 0 1). The reason is that this texture is used as a look up table and I get precision problems with normalized coordinates. I see that GL TEXTURE RECTANGLE is not supported wihtout extensions and neither is texelFetch(), so I have ruled out those options. Thanks!


How to pass arguments with BungeeCord Bukkit plugin messaging I am trying to send a plugin message from Bukkit, to BungeeCord, but can not figure out how to send arguments. Here is the code from the Bukkit plugin, which sends the message ByteArrayDataOutput out ByteStreams.newDataOutput() out.writeUTF("BungeeCord") out.writeUTF("Argument") If you don't care about the player Player player Iterables.getFirst(Bukkit.getOnlinePlayers(), null) Else, specify them Player plr Bukkit.getPlayerExact("spacegeek224") plr.sendPluginMessage(p, "BungeeCord", out.toByteArray()) Here is the code in the main class of my BungeeCord plugin Override public void onEnable() this.getProxy() ProxyServer.getInstance().getPluginManager().registerListener(this, new ChannelListener()) this.getProxy() ProxyServer.getInstance().registerChannel("Return") And finally, here is the code for the ChannelListener package net.spacegeek224.metro.util import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream import java.io.DataInputStream import java.io.DataOutputStream import java.io.IOException import net.md 5.bungee.api.ProxyServer import net.md 5.bungee.api.chat.BaseComponent import net.md 5.bungee.api.chat.ComponentBuilder import net.md 5.bungee.api.config.ServerInfo import net.md 5.bungee.api.event.PluginMessageEvent import net.md 5.bungee.api.plugin.Listener import net.md 5.bungee.event.EventHandler public class ChannelListener implements Listener EventHandler public void onPluginMessage(PluginMessageEvent e) if (e.getTag().equalsIgnoreCase("BungeeCord")) DataInputStream in new DataInputStream(new ByteArrayInputStream(e.getData())) try String channel in.readUTF() channel we delivered if(channel.equals("BungeeCord")) ProxyServer.getInstance().broadcast(new ComponentBuilder(e.getReceiver().toString()).create()) else ProxyServer.getInstance().broadcast(new ComponentBuilder(e.getReceiver().toString() " " channel).create()) catch (IOException e1) e1.printStackTrace() public void sendToBukkit(String channel, String message, ServerInfo server) ByteArrayOutputStream stream new ByteArrayOutputStream() DataOutputStream out new DataOutputStream(stream) try out.writeUTF(channel) out.writeUTF(message) catch (IOException e) e.printStackTrace() server.sendData("Return", stream.toByteArray()) I have tried many things, including Google, and looking at what other methods are available, but have come up with nothing.


Minecraft Forge 1.8 Custom Recipe Manager, need help sorry for asking this question. Some of you will probably find it very easy but I just can't figure out how to do it. I want to write a custom Recipe Manager. It has to check the recipes. Therefor I create an ArrayList lt Item gt recipes new ArrayList() The Item Array store 4 items(3 inputs and one output) Item items Item1, Item2, Item3, Item4 I want to get a function that does this I give it a Item and it gives me an ArrayList containing all the Item s containing that Item as the 0th index and a Boolean that is true when there is any Item containing the Item. Then I give (if needed to another function) an second Item. It returns me a new ArrayList containing all of the previous Item s that containe the Item and a Boolean similiar to 1 but for the 1th index. Analog to 2. (I think you get what I mean). The 3 points have to be handled in another method call. Thank you very much in advance Nova


How do I fix a "missing mcp.cfg" error? I am trying to use mod coder pack (MCP) to create mods of my own. I have downloaded MCP 9.4 version from www.modcoderpack.com. The error that I have encountered is that when I try to run a file called decompile.sh in the mac terminal, the terminal responds with an error ERROR root !! Missing mcp.cfg. I have checked my MCP folder and made sure that it contained the file mcp.cfg. The file is in my folder. I am currently running on a Macbook Pro with MacOS Mojave Version 10.14.4.


How to remove jitter from motion input? I am writing a Minecraft mod that supports input from the Razer Hydra. It is a pair of motion controllers (one for each hand) that provide incredibly accurate position and rotation information. For the purpose of this question, rotating the right controller on the Y axis cause the player's character to look left or right (yaw), and rotating on the X axis makes the player look up and down (pitch). The input from the controller is mapped directly to the character's heading. If the controller is rotated 30 degrees left, the character turns 30 degrees to the left. The problem is that the input "jitters". If I try to hold the controller perfectly still, the character's heading moves erratically within a very small cone (maybe 1 degree). This is probably due to my shaky hands, as the controller's data is seemingly exact. I tried filtering input by averaging data from the last X frames, but this makes input seem buttery. My question is How can I filter the rotational data to remove jitter without loosing precision?


How can I mod Minecraft 1.7.9? I've looked up a lot of tutorials on YouTube and all of them only work for versions of Minecraft prior to 1.7.9. I first got a Minecraft Coder Pack (MCP) off of this website, but then realized that only decompiles Minecraft 1.6.4. Then I found a more recent MCP (that's not on the website for some reason) and it is version 9.03, downloaded here. This decompiles Minecraft version 1.7.2 (when I followed this video's instructions, I run the decompile.bat file and it says Json file not found in C Users mike AppData Roaming .minecraft versions 1.7.2 1.7.2.json). Basically I can't decompile Minecraft 1.7.9, but I can decompile older versions. However, I don't have any older versions downloaded onto my computer. I have only 1.7.9. Then I tried using Forge, but realized that most videos were using versions of Minecraft prior to 1.6.4, meaning they use the bin folder that does not exist anymore. Even after trying to figure that out as well, the decompiling would never work. I tried to do what this video did, but couldn't replicate it. Then I finally looked at this video about using Forge and I could replicate it, but this didn't decompile Minecraft. It just set up a workspace in Eclipse that I'm not sure how to use. TL DR I can decompile Minecraft 1.6.4 and 1.7.2 but I can't decompile version 1.7.9. Should I download an older version of Minecraft, wait for an MCP for 1.7.9, or something else? Is there something I'm missing, where I actually can decompile and mod Minecraft 1.7.9?


How do you make Minecraft mods? I'm new to making minecraft mods and I'm wondering what I need to do to get started.


How can I use IntelliJ to make Minecraft mods? I'm starting out creating Minecraft mods with my son. I've seen one YouTube tutorial which sets up project with Eclipse. Since I don't like Eclipse much, I ask how would I setup IntelliJ or Android Studio(if feasible) to develop Minecraft mods? My son specifically want to create roller coaster mods.


No MODS button in Windows Minecraft when selecting Forge profile I have installed a Minecraft launcher in Windows that supports Minecraft 1.14. I have installed Forge 1.14.4 forge 28.0.13. I have created the mods folder and placed a mod jar in it which is Xaeros Minimap 1.17.4 Forge 1.14.4. I have selected the Forge profile in the launcher. When running the launcher, I have to remove JVM option XX CMSIncrementalMode in order to run it (also when running the regular profile). I have Java 11 installed. But after launching, there is no MOD button in the menu. What could be the problem?


How do I use the Minecraft Coder Pack on Linux I downloaded the Minecraft coder pack to mod the game and decompile it, but how do I use it on Linux. Some sources seem to give specific directions, but they are not clear and they involve executing the .bat files. My Ubuntu does not recognize .bat file. How do I decompile a class file from changing a Minecraft version jar file to a zip and unzipping it? How do I decompile one of those class files using Minecraft coder pack? I have been wondering what at least some of the Minecraft source code looks like.


How can I mod a Minecraft slime to be about the size of a full block? I want to make the slime's size roughly the size of a full block, I have tried some values but I'm not sure if any of those I tried fit the idea I have. What would you recommend for the size of the slime which roughly matches or matches a block's size?


Minecraft Forge Look for Entities in a Certain Location The title mostly explains it. I have a tile entity that is called Energizer. I want this energizer to check to see if there is an EntityItem on top of it and if so, consume it and create energy. The only problem is, I can't figure out how to check for (and receive) an EntityItem in a certain location (on top of it). I considered using a method that searches for nearby entities and then seeing if they were instanceof EntityItem, but I can't even find a method to do that.


How do I add a custom mob to Minecraft? Basically decided to make my own mob, I have Created my mob's entity class Created my mobs model class Drawn the model Added the function call for addMapping within the EntityList class I'm stuck on what to do next. I've tried finding the code that deals with passive animal spawning in the world, however I can't seem to find it. Help greatly appreciated.


Minecraft Optifine where is the zoom class? I'm working on a mod where I want to have a zoom feature like Optifine. To start out, I want to try messing around with the zoom in the actual Optifine mod. There are a lot of .class files, and I don't want to decompile all of them one by one, so if anyone knows which one(s) have the zoom that would be super helpful.


Is there a way to drain durability from an item instead of a sword, for instance? I am modding Minecraft 1.8 using Eclipse with Forge, and I just wondered, is there a way to drain durability from a battery, for instance, instead of a piece of armor when hit. I have tried things like getting an item from the player's inventory and attempting to reduce its durability, so that would be a possibility, however, I was unable to find a way to do so?


How can I teleport seamlessly, without using interpolation? I've been implementing Bukkit plugin for creating toggleable in game warping areas that will teleport any catched entity to other similar area. I was going to implement concept of non Euclidean maze using this plugin, but, unfortunately, I've discovered that doing Entity.teleport() causes client to interpolate movement while teleporting, so player slides towards target like Enderman and receives screen updates, so for a split second all underground stuff is visible. While for "just teleport me where I want" usage this is just fine, it ruins whole idea of seamless teleporting, as player can clearly see when transfer happened even without need to look at debug screen. Is there possibility to somehow disable interpolating while teleporting without modifying client, or maybe prevent client from updating screen while it's being teleported?


How to make blocks like "redstone" working in a minecraft like game when the chunks are not loaded I'm working on a 2D minecraft like game, I use chunks to save my world and each chunk has 128 128 blocks in it. And infinite chunks can create an infinite world. Memory should never be infinite and only several chunks near the character are shown on the screen and loaded into memory. How can I handle logic based blocks like red stone signals when they are in chunks far away and so not loaded in memory?


No files in .net.minecraft So, I've been trying to make a minecraft 1.11.2 client for minecraft. Thing is, the mcp src minecraft folder is empty, without any net files. The only error I had while decompiling was missing lwjgl 2.9.4, which does not exist. I have everything ready, but those files are missing, and thus I cannot code anything on my client(I am only using allowed mods.) This is a massive project I am taking for my favorite server, and I would like some help. Can anyone be kind and tell me how to fix this? I have installed Optifine files for my client, and seems to have got about half of the files that I need. What I need What I have As you can see, I am missing a lot of packages and have errors in most of them.


how to ADD a NEW entity item effect to Minecraft Java In Minecraft Java, I am creating many resource packs by myself (no studio or external resource) so, I want to ADD a new file entity element items etc. to the game to not replace an old item because EVERY item effect entity has SOME use in the game. In conclusion how I can ADD not replace a file in the game and give it custom physical and mental properties?


How can I check if player is an operator in Forge? In Minecraft Forge, I would like to know if there is any way to find out if a player currently has vanilla "OP" "Operator" status. I can't find a method that does this on the EntityPlayer Class. I'd like something like EntityPlayer player (EntityPlayer)sender if (player.getOpStatus) do some stuff


What are names like "net.minecraft.blocks" called? I'm trying to find these types of names for certain Minecraft blocks to add them to a block whitelist for one of my mods. Is there an actual name for these? If not, how would I go about finding a list of or searching for them?


Source code of Minecraft servers? Is there any way to get the source code of Minecraft servers? I tried decompiling but I get very obfuscated arguments, classes, and methods. If the answer is no, how did services like Bukkit and Spigot create their 'servers'?


Minecraft Mod making (MCreator) Redstone Result Event I am currently using a Mod making Tool called "MCreator" made by Pylo. I am currently making a Block Element and creating an event when The block is right clicked by a Prismarine Shard, then The block will power redstone. I did this by doing the following Event On block rightclicked Condition itemInPlayersHand Items.prismarine shard Event parameters (Redstone Power State of power) true I also checked "Can provide power?" In Advanced properties The problem is that when I test the mod in a client environment and click the block, it will not power any redstone around it. I tried to change when the event happens to Print a text and when I tested and clicked on it with a prismarine shard, it printed the text to the console. So is there something wrong with the Redstone Power event result or am I doing something wrong. Thanks in Advanced, Bryan


How to setup for live player observer pair w voice chat in Minecraft I'm trying to build a setup for educational use of Minecraft One person plays Minecraft, another person watches live online with the least lag latency possible, and the pair can talk over high quality voice chat. What is the best setup to allow this? Scenario A 1) Write a mod that allows a watcher to be a passive spectator through their copy of Minecraft? The watcher would see exactly what the player sees. Would this be the fastest and clearest picture? Is it a trivial mod to write? 2) Connect together over Hamachi? Can that be dead easy to set up? 3) Use a voice chat in the game itself? Scenario B 1) Use a streaming video technology. (Twitch? Google Hangouts? Something else?) 2) Third party voice chat like Skype. (Or just Google Hangouts?) My fear here is lag, low quality video, bandwidth. Scenario C ? Thanks very much for any help )


Why Minecraft has such a terrible backward compatibility? For every release of Minecraft, even a minor release, is almost guaranteed to break some plugins or mod. Why is this so? I am asking this so that we could avoid the same architecture problem as Minecraft. I mean, why can't the upgrades also support previous version of minecraft? Minecraft requires an EXACT version number match in order to connect. I am pretty sure the protocol can be designed so that clients should ignore unsupported commands. For example, if there is new block introduced and the client doesn't understand it, they can just fall back to default dummy block so that players can still play but start seeing dummy wireframe block or so. Once they start seeing too much of wireframe blocks they know they should upgrade.


How do I add a method to a class without editing the source file? I am trying to add a method to a Minecraft source file, but I have to figure out how to do it without actually editing the source files, as it would be illegal to redistribute Minecraft's source files with the mod I am creating. I need to add the method setInPortalZub() to the EntityPlayer class located in net.minecraft.entity.player. I am using the MCP Minecaft Forge API. I have tried creating an EntityPlayer instance, but I'm not exactly sure how to make this work.


How much more do I have to learn? So I started learning java sometime ago and now I am understanding packages. My main goal is to do minecraft modding. Can someone with modding experience please tell me how hard(or easy) minecraft modding is? And how much time will it take for me to get to a level when I can start modding?


Where do I write code in my minecraft modding environment? So this is probably a stupid question but I'm just beginning so I hope someone can help. I set up my whole modding environment in eclipse but the problem is that I don't know where to start writing code that will be run while playing the game. I'm used to there being a run method that will constantly loop and run the code within that method but there doesn't seem to be such a thing. I tried putting stuff in my main class under the init event handler but that just crashed my game. I was just testing stuff out and tried putting this code in the init area which caused the game to crash when I tried running the client Entity player Minecraft.getMinecraft().player if(player.posX gt 100.0) player.posX 12.0


Why aren't ModLoader's decompiled files showing up? I want to start making a Minecraft 1.6.4 mod, but have this trouble with ModLoader I've run the decompile.bat batch file, but when opening the eclipse folder, the bin folder is empty. The batch file ran fine with no errors, and src minecraft net minecraft contains many decompiled java files, but no modloader files like BaseMod.java. If I open this folder with Eclipse, the package explorer menu stays empty. What's happening here?


Minecraft Forge modding 1.8 instance changing tool armor material color I am developing a minecraft mod in forge, and I need to find a way to create tools and armor where individual instances of items would have different tool material properties, armor material properties, and hues in how they are displayed. If you can offer help for any of those things, or for how to achieve these dynamic properties in general, I would be very appreciative.


Minecraft Bedrock behaviors drop items for player owner? I'm making a simple behavior pack for Minecraft's Bedrock Edition for my own experimenting the aim is to get tamed wolves to play fetch. The behavior pack is valid and loading, as it sort of works, but the part that isn't working is what I've been banging my head against for hours. As per the tutorial on the official wiki, I've copied entities wolf.json and entities player.json from the vanilla behavior pack to my pack and added to them, borrowing cues from the villager's behavior file and referring to the reference for BE's entity components. I've also modified the priorities of the tamed wolf's behaviors so picking up items (i.e. sticks) and sharing them are a higher priority than following the owner or breeding. wolf.json "minecraft entity" "format version" "1.2.0", "component groups" ... "minecraft wolf tame" ... "minecraft behavior.pickup items" "priority" 7, "max dist" 16, "speed multiplier" 1.5, "track target" true , "minecraft inventory" "inventory size" 1, "private" true , "minecraft shareables" "items" "item" "minecraft stick", "want amount" 1, "surplus amount" 1 , "minecraft behavior.share items" "priority" 6, "max dist" 16, "speed multiplier" 2, "goal radius" 2.0, "entity types" "filters" "test" "is owner", "subject" "other" , "must see" true ... player.json "minecraft entity" "format version" "1.2.0", "components" ... "minecraft shareables" "items" "item" "minecraft stick", "want amount" 2304, "surplus amount" 2304 Currently, a tamed wolf will run over to pick up a dropped stick within 16 blocks of it, but after that it simply resumes following me (its owner) and never drops shares its sticks. I've messed with the want amount and surplus amount of the sticks for both the player and wolf, but with absolutely no results.


What can I do about a "missing mcp.cfg" error? I am trying to use MCP. After trying to run decompile.sh, I manually ran decompile.py, getting the error "ERROR root !! Missing mcp.cfg !!" I tried to copy the variables from mcp.cfg into the files which reference them, but I still got the error. How can I fix this?


Minecraft Players Held Item Type How can I check if a players held item is of a specific item type for example an axe. (can be iron axe, gold axe, wooden axe, etc.)? Or do I have to do multiple if statements to have this done? EventHandler(priority EventPriority.HIGH) public void onInteract(PlayerInteractEvent event) Player p event.getPlayer() ItemStack heldItem p.getInventory().getItemInMainHand() if(heldItem.getType() Material.DIAMOND AXE) I dont want to do multiple if statements for multiple type of Axes ... other if statement for Material.WOODEN AXE etc.


How minecraft manages interactable blocks (Chest)? I am wondering, how does minecraft handle blocks like chest? I guess normal blocks are ids in simple array, but how does it store and references blocks with special behaviour?


How do I use the Minecraft Coder Pack on Linux I downloaded the Minecraft coder pack to mod the game and decompile it, but how do I use it on Linux. Some sources seem to give specific directions, but they are not clear and they involve executing the .bat files. My Ubuntu does not recognize .bat file. How do I decompile a class file from changing a Minecraft version jar file to a zip and unzipping it? How do I decompile one of those class files using Minecraft coder pack? I have been wondering what at least some of the Minecraft source code looks like.


Is there a way to create a cellular automaton mod for Minecraft? I basically want to create a mod for Minecraft that does the following if(a sand block is next to lava block) change the sand block to a glass block Is it possible to create a mod like this without editing multiple Java classes?


How do I modify the health of an entity after it has been created? Is there any way to add or remove health after an entity has been created? For example, I'd like to have a mob regenerate "hearts" when some event happens.


How can I read a portion of one Minecraft world file and write it into another? I'm looking to read block data from one Minecraft world and write the data into certain places in another. I have a Minecraft world, let's say "TemplateWorld", and a 2D list of Point objects. I'm developing an application that should use the x and y values of these Points as x and z reference coordinates from which to read constant sized areas of blocks from the TemplateWorld. It should then write these blocks into another Minecraft world at constant y coordinates, with x amp z coordinates determined based on each Point's index in the 2D list. The issue is that, while I've found a decent amount of information online regarding Minecraft world formats, I haven't found what I really need more of a breakdown by hex address of where what everything is. For example, I could have the TemplateWorld actually be a .schematic file rather than a world I just need to be able to read the bytes of the file, know that the actual block data starts always at a certain address (or after a certain instance of FF, etc.), and how it's stored. Once I know that, it's easy as pie to just read the bytes and store them.


Minecraft Forge setTextureName method not working I am attempting to make an item using the latest version of Forge. For some reason, the setTextureName method gives me an error that says The method setTextureName(String) is undefined for the type ItemKey I have been trying to fix this for a while, and notice that when I remove the quotation marks from the colon the error for setTextureName disappears, but I get an error on the colon that says Syntax error on token " ", delete this token an error on the sign that says The operator is undefined for the argument type(s) String and finally an error on "key" that says The method setTextureName(String) is undefined for the type ItemKey This is my first time trying to make an item, so help would be greatly appreciated. EDIT I just figured out that if I change MODID to modid in the setTextureName method I stop getting an error message for setTextureName but instead get an error for modid saying that modid cannot be resolved or is not a field package com.arti.artismod import net.minecraft.item.Item import net.minecraft.creativetab.CreativeTabs public class ItemKey extends Item private String name "key" public ItemKey() setUnlocalizedName(ArtisMod.MODID " " "key") setTextureName(ArtisMod.MODID " " "key") setCreativeTab(CreativeTabs.tabMisc)


Pygame's rotation methods have crippling issues, but is it me or Python's pygame? http www.youtube.com watch?v lNJFxvR6ex8 amp feature youtu.be On rotate and rotozoom, can't find fixes on these on the internet, anywhere. Basically, the video is showing 4 things in this order 1. A ring image being rotated with .rotate. 2. A simple image being rotated with .rotate. 3. The ring rotated with .rotozoom. 4. The simple circle rotated with .rotozoom. The difference In 1 and 2, the images do not have that slight quiver movement, but are reduced in quality. It might be difficult to tell with the video quality, but the ring image is slightly pixelated blurred. In 3 and 4, the images are of equal better than 1 amp 2 quality when rotated with rotozoom, but they have this VERY SLIGHT but noticeable wobble about them. This is VERY noticable with test 3, where I put my mouse next to the circle outline, and you can see it move. ANY and all help will be greatly appreciated, AND this will help many people for a long time, i'm sure. Here are images of the differences in picture quality of rotate vs rotozoom http s189.beta.photobucket.com user ECSit library PyGame 20and 20Python


How to set object's node's absolute rotation correctly? Usually when I want to rotate an object node in my Ogre scene I call the node's rotate() method. That rotates the node locally relative to it's current rotation. So for example, when I start with 0 rotation, then rotate twice for 5 degrees about one axis, then after the second call the object is rotated by 10 degrees in total. Now I need to set the absolute rotation of the node object directly, regardless of its current rotation. Thus, say I don't know the objects current rotation, I need to set it say to 45 degrees on the X axis. Something like setRotation(). I know there is a setOrientation() method in the SceneNode class, which expects a quaternion object. I also know that I can get the current orientation quaternion. What I don't know how can I use change this current orientation quaternion to set the new absolute rotation of the node? PS Crosspost at http www.ogre3d.org forums viewtopic.php?f 2 amp t 77710


3d rotation of a Gunner unit to shoot the target I'm developing a scenario to shoot incoming targets by a specific gunner unit, however I'm confused to actual logic of shooting an object with a gun. I'm working in 3D environment. I'v target's position vector i.e x,y,z and its rotation vector x,y,z,angle , and also Gun's position vector i.e x,y,z and its rotation vector x,y,z,angle . The gun has two components, i.e a TopDondur and a set of Barrels, both components have the rotation along y axis, i.e only angel of rotation vector 0 1 0 angle is required to move the Gunner Unit to the target. What rotataions shuould give the Gunner unit to rotate both TopDondur and Barrels, i.e TopDondur rotates to the target and Barrels are to move up down with respect to that target.


Converting 3 axis vectors to a rotation matrix I am trying to get a rotation matrix (in 3dsmax) from 3 vectors that form an axis (all 3 vectors are aligned by 90 degrees each other) Somewhere I read that I could build a rotation matrix just by inserting in every row one vector at a time (source http renderdan.blogspot.cz 2006 05 rotation matrix from axis vectors.html) So, I built a matrix with these example vectors x axis 0.194624, 0.23715, 0.951778 y axis 0.773012,0.634392,0 z axis 0.6038, 0.735735,0.306788 But for some reason, if I try to convert this matrix to eulerangles, I receive this rotation (eulerAngles 47.7284 6.12831 36.8263) ... which is totally wrong, and doesn't align to my 3 vectors at all. I know that rotation is quite difficult to understand, may someone shed some light? )


Get 3D quad rotation matrix from points I have 4 3D points which represent a even quad in space. (So 3 points are sufficient) I need to get all the individual transformations (translation, rotation, dimensions) so that I can build that quad in my CSS 3D engine. So the default normal vector for a quad is 0, 0, 1 . What I have so far 4 points p0, p1, p2, p3 normal normal cross(p1 p0, p2 p0) axis and angle axis cross( 0, 0, 1 , normal) angle arccos(dot( 0, 0, 1 , normal)) rotation matrix rotationMatrix matrix4.fromAxisAngle(axis, angle) width and height width sqrt((p2.x p1.x) 2, (p2.y p1.y) 2, (p2.z p1.z) 2) height sqrt((p1.x p0.x) 2, (p1.y p0.y) 2, (p1.z p0.z) 2) translation x (p0.x p1.x p2.x p3.x) 4 y (p0.y p1.y p2.y p3.y) 4 z (p0.z p1.z p2.z p3.z) 4 It almost works, but some rotations are wrong or more specifically one rotation axis is missing. This is logical because the rotation is only build from the normal. So how can I get the full rotation? Here you see that the top and bottom quads are just rotated around the x axis but the y axis rotation is missing


Rotating and pitching a turret I am new to game development and I was trying to build a turret model, and control it through lua script in shiva3d. I can rotate it around the y axis which is no problem, but when it comes to pitching, I am not sure how to do that in a way which is independent of the Y rotation, for example, in the default position, rotating with a positive value around X aims upwards, which is what I expect. when I rotate it by 180 degrees around Y, the positive rotation around X aims downwards towards the ground instead of upwards. on the other hand, if I rotate by 90 degrees, the turret rotates around it self as if its rolling... I am not sure what to look for in order to understand how rotation in a 3d world should happen, so any pointers on that would be much appreciated


Error in plane transformation I have a bunch of coplanar points, who sit on plane P. I want to translate the plane to Q with the points upon. Here is what I do I take three points from P, say a, b, c. Their centroid is denoted by c(a,b,c). I pick the local origin as O c(a,b,c) and local XYZ as x normalize(Oa) v normalize(Ob) z x.crossProduct(v) y x.crossProduct(z) I apply the same method to their global coordinates on Q, which are d, e, f. O c(d,e,f) x normalize(Od) v normalize(Oe) z x .crossProduct(v ) y x .crossproduct(z ) Then, I use the transformation matrix as follows Matrix input x,y,z Matrix output x ,y ,z Matrix T output.multiply(input.transpose()) After this step, I multiply the coordinates of a point p that sit in plane P with matrix T. Of course, before that, I take the vector difference p O. The result should be the transformed point minus target origin (q O ). Hence, for each p in P, I transform p to its place in Q, which is denoted by q using the following computation q T.multiply(p.subtract(O)).add(O ) But what I get is, the reflection of the points through an imaginary (I don't know which) axis. Am I missing some step? Is there a wrong computation?


How can I keep the clicked point under the mouse when rotating? (GLM) I have a spherical mesh of radius 1, centered at (0,0,0) in world coordinates. I want to rotate the sphere so that the clicked point remains under the mouse at all times. However, I cannot find an algorithm that does this. The clicked point always drifts away from the mouse. My current algorithm does the following Cast a ray to a sphere of radius 1. Find intersection point in world coordinates (Pa). After the mouse is moved, cast another ray and find a new intersection point. (Pb) since both those 3D points are on a sphere of radius one, centered at the origin, they should have length 1 but just in case I normalize them both. Find the rotation axis by doing Pa x Pb. Normalize the resulting axis axis glm cross(Pa,Pb) axis glm normalize(axis) Find the angle by doing arccosine on the dot product float angle glm acos(glm dot(Pa,Pb)) Build a rotation matrix from the axis and angle mat4 rotation glm rotate(glm degrees(angle),axis) lt This was the mistake glm degrees is not needed Multiply the existing model matrix by that calculated matrix modelMatrix rotation modelMatrix The rotations are correct but the clicked point does not stay under the mouse (I am checking by drawing a black square point on the sphere texture when the drag starts). If I click and drag to the right, the initially clicked point drifts to the left (lags).


How to eliminate roll rotation? Let's say I have Rotation(0, 0, 180) pitch, yaw, roll . How to do it that I would have Rotation(180, 180, 0) which is exactly the same?


How do I create a rocket projectile that is "dropped", then accelerates toward the enemy? I'm making an Asteroids like game. I've successfully implemented linear bullets. Now I want to add some rocket styled bullets, with a certain flight path The rockets should be "dropped" back first, then accelerate towards the enemy. I'm having difficulty making this work when the shooter is rotated. To visualize what I mean Bullets have a lifeTime which increases every frame.


How to map absolute Joystick position to object rotation? In my (Ogre) 3d scene I have an object that should be rotated locally based on Joystick input. I have a Joystick with min max values of 32767, 32767 on both X and Y axes. When the Joystick is in its origin position, the object should not be rotated. When the user moves the Joystick, the object in the 3d scene should follow this movement (or better orientation) up to a max. of 45 degrees on both axes. Or in other words when the user moves the Joystick e.g. fully to the left, the object's orientation in the 3d scene should be set to 45 degrees on the according axis. Being new to 3d programming I searched on the Internet on how to achieve this. I think to understand that I want to use Quaternions for this task. I found some examples and tutorials on how to use Quaternions for rotating objects. What I don't understand though is how I can map from the Joystick's current absolute axes positions to the absolute, local rotation of an object. I see that I could use the rotate() method of the object's node to set its rotation, but I understand that this rotates the object relatively to it's current position. But instead I want to map from the Joystick's absolute position to the absolute orientation rotation of the object in the scene. Any advice how I should approach this?


from normal to rotation matrix (i'm on OPENGL) i have a mesh O (object) and a mesh T (terrain). i know a single triangle in T and i want to orient O to be aligned to that triangle (torate O to align to T in that point). i have only the normal in the triangle. how can i achive the roation matrix? i have thought this algorithm pseudocode float normal2rotation(Vector3D normal) angleX Vector3D.angleBetween(normal, Vecto3D.Axis3D.X) angleY Vector3D.angleBetween(normal, Vecto3D.Axis3D.Y) angleZ Vector3D.angleBetween(normal, Vecto3D.Axis3D.Z) float result angleX, angleY, angleZ return result but it does not give me the desired result.


What is an efficient way to get a look at direction from either a quaternion or a transformation matrix? So, I have an object in my custom engine (C ), with a column major transform in world space. I'm using a package that takes a look at direction as an input. What's the most efficient way to get a look at direction from this transform? Do I extract the rotation matrix? Do I try to extract a quaternion?


How do I determine the forward right direction when I have the "up" vector? Unity I am trying to fix a gameobject for e.g. a cube (which i am using as a sensor) on my character. I need the cube to rotate (with orientation control from the inspector I have a public quaternion rotation variable set). I have identified 3 vertices using ray cast to fix my sensor onto the character. I already have determined the normal of these vertices which will be the "up" direction of the cube. I am wondering how I can determine the forward right vector to use in the LookRotation() function. I need to basically be able to rotate the cube ON the character even as the character moves on animation. This is my code, and as of now there is no rotation happening. I'm sure I am missing something and would really appreciate help. I really hope this is enough explanation. using System.Collections using System.Collections.Generic using UnityEngine public class orientation MonoBehaviour importing from Vertex Finder Script to use InterpolatedNormalInWorldSpace value private VertexFinder script public Transform target to edit orientation of sensor in Unity Inspector public Quaternion rotation edit Start is called before the first frame update void Start() script GetComponent lt VertexFinder gt () Quaternion TurretLookRotation(Vector3 approximateForward, Vector3 exactUp) Quaternion rotateZToUp Quaternion.LookRotation(exactUp, approximateForward) Quaternion rotateYToZ Quaternion.Euler(90f, 0f, 0f) return rotateZToUp rotateYToZ Update is called once per frame void Update() Vector3 relativePos target.position transform.position aligning axes of sensor to z axis and y axis respectively Quaternion rotation1 TurretLookRotation(relativePos, script.interpolatedNormalInWorldSpace) setting rotation of sensor to values entered in Inspector with respect to the above aligned axes transform.rotation rotation1 rotation edit


Increasing the rotation angle on a quaternion makes the rotation stop at a certain angle I'm using the following code to change the rotation of an object Quaternion rot getRotation() setRotation(make quaternion axis angle(rot.v,rotationSpeed dt) rot) This code works as expected until a certain angle where it suddenly stops. Why does it stop?


Quaternion rotation is inverse of what I expect I'm trying to learn quaternions and decided to implement my own quaternion class. To test it I made a couple vertex shaders, one that gets a model matrix (calculated from the quaternion) and another that gets the rotation quaternion directly and rotates vertices in shader. I then feed these a quaternion that rotates around the Y axis t 10000 radians (t time) const rotation Quat.fromAxisAngle(new Vec3( 0, 1, 0 ), t 10000) The result surprises me because my model is rotating counter clockwise but I expected it to rotate clockwise, since the angle is increasing (checked it, quat's xyz increase with time). Rotation around the X or Z axes is also backwards. All translations as well as matrix rotations work as expected in my coordinate system. I suspect my formulas are wrong, and probably assume Z is forward. If I transpose my model matrix (or post multiply with it) it rotates as expected, which suggests it's a handedness problem. Where are my formulas wrong and how can I understand the math behind this? Details My matrices are column major in memory (to match GLSL's mat4). My coordinate system is X right, Y up, Z forward. My code Quaternion from axis angle function fromAxisAngle(axis Vec3, angle number, dest new Quat()) Quat angle 0.5 const sin Math.sin(angle) dest.x axis.x sin dest.y axis.y sin dest.z axis.z sin dest.w Math.cos(angle) return dest Note I noticed if I negate this quaternion's x, y and z, everthing works as expected. Is this the root cause? I thought quaternions didn't have handedness! Since this is actually just inverting the quaternion (and thus its rotation) I'm afraid I'm just patching over the root cause. I don't want to patch the issue, I want to fix my math! Matrix from quaternion toMat4(dest new Mat4()) Mat4 const x, y, z, w this const x2 x x const y2 y y const z2 z z const xx x x2 const xy x y2 const xz x z2 const yy y y2 const yz y z2 const zz z z2 const wx w x2 const wy w y2 const wz w z2 Notice matrix is column major Source https en.wikipedia.org wiki Quaternions and spatial rotation Quaternion derived rotation matrix dest.init( 1 (yy zz), xy wz, xz wy, 0, xy wz, 1 (xx zz), yz wx, 0, xz wy, yz wx, 1 (xx yy), 0, 0, 0, 0, 1, ) return dest Matrix vertex shader precision mediump float attribute vec3 aVertexPosition attribute vec2 aVertexUV uniform mat4 uModelMatrix uniform mat4 uViewMatrix uniform mat4 uProjectionMatrix varying vec2 vUV void main(void) vUV aVertexUV gl Position uProjectionMatrix uViewMatrix uModelMatrix vec4(aVertexPosition.xyz, 1.0) Quaternion vertex shader precision mediump float attribute vec3 aVertexPosition attribute vec2 aVertexUV struct Transform float scale vec3 translation vec4 rotation uniform Transform uModel uniform Transform uView uniform mat4 uProjection varying vec2 vUV Source https twistedpairdevelopment.wordpress.com 2013 02 11 rotating a vector by a quaternion in glsl vec3 rotateVector(vec4 quat, vec3 vec) return vec 2.0 cross(cross(vec, quat.xyz) quat.w vec, quat.xyz) void main(void) vUV aVertexUV vec3 world rotateVector(uModel.rotation, aVertexPosition uModel.scale) uModel.translation vec3 view rotateVector(uView.rotation, world uView.scale) uView.translation gl Position uProjection vec4(view, 1.0)


Does gimbal lock occur only when a combination of local and world rotation axis are used? In all the explanations I've seen of gimbal lock, they always refer to the fact that when performing a series of rotations on all axes, it is possible that one rotation might end up aligning an axis with another which causes us to lose a degree of freedom. This never made sense to me since a rotation around e.g. the LOCAL RIGHT axis will rotation the whole LOCAL BASIS, no alignment happens. The only explanation I've seen that made sense was this one by DMGregory where it clearly explains that gimbal lock occurs when we e.g. change the yaw using the local basis and the pitch using a world basis. My question is Is that the only scenario where gimbal lock occurs or am I missing something? I also thought that quaternions help avoid gimbal lock but again, I'm missing something here because it seems to occur regardless of the rotation representation method (euler quaternion).


Rotating the playing field. (MonoGame) My maths isn't as good as it should be, I need to pick up some reference books on Trig. Could someone give me an idea of the maths if I wanted to revolve many sprites around a central point? It's a 2D system in MonoGame. I'm going to try to describe the scenario, I can't think of anything quite like it to reference. Imagine a game screen, you are looking down on the world, with my character in the middle, my character sprite will never change, but if I turn left or right I want everything else to rotate around the central point. Of course every sprite will have to be moved, and also rotate to account for the spin. Can someone point me in the right direction? Thanks.


AABB of rotated sprite? Say I have a sprite. Its AABB is easy to find since I know the width and height. Say I rotate it 45 degrees, I don't think the AABB would be big enough to cover it, so I need a new AABB. How can I calculate the bounding rectangle of a rotated rectangle (given a center point, an angle, and its width and height)? Note that OpenGL does the rotation so I do not have access to the vertex information. What I'm trying to do is get AABBs so I can do 2D culling for rendering. Thanks


Rotate around an axis function for euler angles representation For a 3d game i need a function to rotate an euler representation around an arbitary axis by an angle. For example an object is rotated with euler angles (0,90,0). Now the object should be rotated by 100 degrees around the axis (0,1,0). The resulting angle will be (0,190,0) using rotation order YXZ. In this case I can add the angle to the euler value of the axis, however for an arbitary axis this will not work. Problem with Quaternions amp Rotation matrices With these representations the resulting rotations will always be smaller that 180 for each axis. I need the rotation to be lerped afterwards for example from (0,0,0) to (0,720,0). Basically I am searching for a way to display euler angles like most of the 3D editors. When you rotate an object around any arbitary axis rotation might be larger than 360 in the editor, like (420,720,15).


How to find optimal perpendicular axis of rotation vector to draw arrows? I am drawing lines on the screen. Each line has a point (x,y,z) and a direction (u,v,w). I want to draw arrow heads on these lines, like two lines that start from (x,y,z) and leave at a 15 degree angle. I know how to draw these arrow head lines. I do this by rotating (u,v,w) by 15 degrees on some axis of rotation which is perpendicular to (u,v,w). The problem is the axis of rotation I am using is not making all my graphs look good. Basically I'm given a unit vector (u,v,w). If w 1, then u and v are 0 and I just use (1,0,0) which is a unit vector and perpendicular to (u,v,w). If that is not the case, then I use (v, u, 0) which is not a unit vector but is perpendicular. Then I normalize it. The norm won't be 0, since w lt 1 which means u 2 v 2 ! 0. This gives ok results. But some tests, the arrow head lines look a bit messed up, or not even looking like a 15 degree angle from the main line. Does anyone know a good way to find a good perpendicular unit vector to (u,v,w) so the results will always look good? Thanks