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


HLSL An array of textures and sampler states The shader must switch between multiple textures depending on the Alpha value of the original texture for each pixel. Now this would word fine if I didn't have to worry about SamplerStates. I have created my array of textures and can select a texture based on the Alpha value of the pixel. But how do I create an Array of SamplerStates and link it to my array of textures? I attempted to treat the SamplerState as a function by adding the (int i) but that didn't work. Also I can't use Texture.Sample since this is shader model 2.0. shader model 2.0 (DX9) texture subTextures 255 SamplerState MeshTextureSampler(int i) Texture (subTextures i ) float4 SampleCompoundTexture(float2 texCoord, float4 diffuse) float4 SelectedColor SAMPLE TEXTURE(Texture, texCoord) int i SelectedColor.a texture SelectedTx subTextures i return tex2D(MeshTextureSampler(i), texCoord) diffuse


projected textures not appear on the "back" of the mesh as well? I want to create blood wounds on my character's bodies by using projected textures. I've watched some commentaries on games like Left 4 Dead and they say they use projected textures for the blood. But the way projected textures work is that if you project a texture on a rigged character, say his chest, it will also appear on his back. So what's the trick? How to get projected textures appear only on one "side" of the mesh? I use the Panda3D game engine, if that will help.


Opengles 2.0 multi Textures fade out one by one I have multi textures, A was drawed on top of B, B was on top of C ...., ( like Picture 1) .I want to fade out A first, then B will appear and fade out either... But when A fade out, background color appeared on top of B, ( like Picture 1 )? Why? What should I do? I have enable Blend like this glClearColor(0, 104.0 255.0, 55.0 255.0, 1.0) glClear(GL COLOR BUFFER BIT GL DEPTH BUFFER BIT) glEnable(GL DEPTH TEST) glEnable(GL BLEND) glBlendFunc(GL ONE, GL ONE MINUS SRC ALPHA) and Fragment shader "void main(void) 2 n" "gl FragColor texture2D(Texture, TexCoordOut) n" "gl FragColor alpha n" " n" Picture 1 background color is green, A and B are both rectangle, A is on top of B Picure 2 When I fade out A, the result like this I aso try to use glBlendFunc(GL SRC ALPHA, GL ONE MINUS SRC ALPHA) but it doesn't work either. Update 1 shader const GLchar vertex shader source attribute vec4 Position uniform mat4 Projection uniform mat4 Modelview varying vec4 DestinationColor attribute vec2 TexCoordIn New varying vec2 TexCoordOut New void main(void) gl Position Projection Modelview Position TexCoordOut TexCoordIn New " const GLchar fragment shader source uniform highp float alpha uniform sampler2D Texture New varying highp vec2 TexCoordOut New void main(void) 2 gl FragColor texture2D(Texture, TexCoordOut) "gl FragColor.a alpha


Tools for assembling textures into DDS files There are plenty of tools for making images. I'm not looking for one of those I have many tools for creating an image. I've got tools for compressing images, generating mipmaps, and even for poking at their basic data format. My issue is with texture assembly. DDS files support cubemaps, array textures, and even cubemap arrays. But I don't know of a tool that can pack a series of images into a cubemap or the like. What tools are available for doing this kind of thing?


How to change texture from pvr.ccz in Cocos2d? I'm using .pvr.ccz file that texturePacker application created for me , I created a Sprite that it's image choosed from this file(.pvr.ccz) like below CCSprite mySprite CCSprite createWithSpriteFrameName("first.png") But how can I change it's texture using .pvr.ccz file? I knew below solution for changing texture of a sprite, but it works when second.png file is normal PNG file and is not compressed in a.pvr.ccz file. mySprite gt setTexture(CCTextureCache sharedTextureCache() gt addImage("second.png"))


How to get the "(human) Face" position from Webcam Texture I am searching a way to recalculate the current Position of the Face in "Virtual World Position" From a Webcam Texture. I was thinking about a way to solve this via taking the Average Pupillary distance (which is 60mm). And... With this number I somehow need to get a actual position ... somehow... of the... Face... (The Center) I dont know how exactly though. Any Ideas?


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.


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.


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.


How can I pack repeated textures into one texture efficiently? I have an obj mesh with some textures, several of them are repeated(uvs are not within 0,1 ). I'd like to merge all those textures into one texture and transform the uvs of obj.


Why are examples of game textures often represented on a sphere model? I have recently started working with Unity and was looking for textures for the background (castle walls and such pieces) on a game that I am thinking about eventually building. I noticed that the textures are often represented as ball shaped, such as for example in this sample image here For example, why are the texture patterns not shown as simply flat squares? I guess there is a reason behind this that has to do with mapping to 3d surfaces but I was not sure so I wanted to check here. Why are textures often represented in spherical shapes in examples and previews?


Displaying 2 textures on the same surface? I'm messing around with XNA in a very simple Minecraft esque world I'm making and I'm wondering how I can do the "breaking the block" visuals in XNA. If you're unfamiliar with the game, you begin interacting with the cube and based one what tool you're using, the block will take X amount of time to break. There's about 10 different stages of cracking that the cube will display before the cube breaks. I'm curious about how to display those 10 stages of cracking on top of the original skin of the block. I know the game works using a Sprite sheet to color the blocks. This sprite sheet does not include every possible design at every possible stage of breaking the block, each stage is a different sprite with some transparency. In short, how can I quickly and efficiently overlay a texture on a surface that already has a texture? Do I have to combine them? If so, how?


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?)


Computing uv coordinates on a sphere approximated from an octahedron Right now I'm texturing the octahedron with the formular from wikipedia(Finding UV on a sphere) UV Coordinates Wikipedia That unfortunately leads to heavy distortion right at the beginning, which of course leads to a lot of distortion when splitting up the triangles when approximating it to a sphere. The upper and lower triangles are okay, the left and right ones are distorted. Now I'm looking for different formulars to calculate the uv's. Are there any other easy formulars? Or would another approach be much more complicated?


Avoid double compression of resources I am using .pngs for my textures and am using a virtual file system in a .zip file for my game project. This means my textures are compressed and decompressed twice. What are the solutions to this double compression problem? One solution I've heard about is to use .tgas for textures, but it seems ages ago, since I've heard that. Another solution is to implement decompression on the GPU and, since that is fast, forget about the overhead.


Best Practices for Texturing Large Objects Kind of a 3D graphics newbie here. This is the biggest prop I've ever tried to texture, and I'm kind of stumped. How do you get a decent resolution on large meshes like this without exporting enormous maps? Texture atlases? Tiling textures? And what's the best way to set up the UVs, if so?


Converting DDS textures to TGA I have a model which has textures in DDS format, but my game takes textures in TGA format. How can I convert the textures from DDS to TGA?


So, I need to create varied animal textures for my game. How would I go about doing that? For example, one of the creatures planned is an isopod like animal. Would I need to get pictures of real animals and adjust them to my needs?


Alpha blending is too smooth I got the exercise to create a color map from a heightfield and given normals with alpha blending. Therefore I have to blend 4 textures (deep flat, deep steep, high flat, high steep) depending on the height and slope. First I'm calculating the 3 alpha values (lowest layer is fully opaque, does not need to be blended gras texture) slope 1.0f normal.z at current pixel void calcAlphas(float height, float slope, float amp alpha1, float amp alpha2, float amp alpha3) alpha1 (1 height) slope low steep gt dirt texture alpha2 height high flat gt pebbles texture alpha3 height slope high steep gt rock texture After that I'm getting the color at the current pixel of all four textures and calculating the final color 3 3 3 (1 3) (2 2 1 2 (1 1 1 1 0)) The result looks pretty good but it's very smooth. To compare my result I got a pattern how it should be. Orignal My own color map


How to read a color of a pixel from texture (cocos2d js)? How to read a color of a pixel at x,y from a texture (in cocos2d js)?


What would be theoretical the perfect texture size? I am more a newbie considering game development but I am dealing very often with optimization of games for work and because I am interested in it. So as far as I know higher texture size need less draw calls if you make serveral objects share the same texture but it takes up more VRAM. Also you have to consider how acuit you want to have your textures. But the more I thought about the topic I thought there would be a theoretical perfect texture size, correct me if I am wrong. Thought experimet Considering you always want the same acuity of your game and you have 4 objects that take the exact same amount of UV space but have different textures. Then there would be a perfect spot between texture size and number of objects that share the same texture considering your goal is best performance. In this case there would be 4 possibilities 1 texture where all objects share the same one 2 texture for two of the objects 3 texures where it would be a mix of those above or 4 textures where every object have their own If performance is your main goal then there would be only one variable to change depending on how acuit you want your game, the acuity, wouldnt it? Hope you understood my thoughts


Distortion of color space in UDK (material editor) Question Using UDK's material editor, I wish to use a texture as a two dimensional array of values for mathematical computations (basically, the color components of each pixel in the texture alter the behavior of some transformations applied to another texture). I want to retain rather precise color values for my mathematical operations to keep their meaning, but in my experiments I noticed a heavy distortion of the color space dark colors are darker than they should be, and light colors are lighter than they should. Additional information This effect is best shown by the following material, which takes a simple linear gradient texture, and applies a rounding operation on the colors If the colors were correctly preserved, the preview on the left should have 10 bands of equal length (a black band, a 10 gray band, a 20 gray band etc. with each band being 10 of the width of the image), however the black band is huge, the next (10 gray) one rather large, and the bands get smaller and smaller as they get lighter. In this example, I take the red channel of the image, but taking the other channels gives similar results The red and blue channels are identical, and the distortion is slightly different with the green channel, and taking the combination of these logically produces small bands of purple and green between any two bands. I guess this is a compression issue with the original texure, but I don't know which parameters I should change so the colors are preserved when I use the texture in the material editor. Above is the texture I used, created with The Gimp. The colors are correct, it is a linear gradient the color of the pixels in column 0 is (0,0,0), the pixels in the column 255 are (255,255,255) and I manually checked at many points in the image that the pixels in the column x are (x,x,x)). Above are the properties for this texture. Nothing special here, just the defaults. Specifically, the Adjust Brightness Curve and Adjust RGB Curve properties are set to 1.0 (by default), which seems correct since they are the power to which the HSV and RGB curves must be elevated. The distortion I observed looks a lot like if the values were raised to a given power.


Need to know the origin and coordinates for 2d texture and 2d 3d vertices in webgl Long story short, I know my coordinates are off and I believe my indices might be off. I'm trying to render a simple 2d rectangle with a texture in webgl here's the code I have for the vbo ibo rectVertices.vertices new Float32Array( 0.5, 0.5, Vertice 1, bottom left 0.0, 0.0, UV 1 0.5, 0.5, Vertice 2, top left 0.0, 1.0, UV 2 0.5, 0.5, Vertice 3, top right 1.0, 1.0, UV 3 0.5, 0.5, Vertice 4, bottom right 1.0, 0.0, UV 4 ) rectVertices.indices new Int16Array( 0,1,2,2,0,3 ) I'm assuming the vertices go like this ( 0.5, 0.5) ( 0.5, 0.5) ( 0.5, 0.5) ( 0.5, 0.5) with the origin in the middle and the texture coordinates go like this ( 0.0, 1.0) ( 1.0, 1.0) ( 0.0, 0.0) ( 1.0, 0.0) so as you can see I'm all messed up. I'm also using gl.pixelStorei(gl.UNPACK FLIP Y WEBGL, true) Here's the output of the program the texture I'm using is this So, I guess I need to know the origins, but the triangle strip looks way off. I am doing this as well create VBO and IBO vbo gl.createBuffer() gl.bindBuffer(gl.ARRAY BUFFER, vbo) gl.bufferData(gl.ARRAY BUFFER, triangleVertices.vertices, gl.STATIC DRAW) ibo gl.createBuffer() gl.bindBuffer(gl.ELEMENT ARRAY BUFFER, ibo) gl.bufferData(gl.ELEMENT ARRAY BUFFER, triangleVertices.indices, gl.STATIC DRAW) and gl.bindBuffer(gl.ARRAY BUFFER, vbo) gl.bindBuffer(gl.ELEMENT ARRAY BUFFER, ibo) gl.vertexAttribPointer(vertexAttribute ,2, gl.FLOAT, false,FLOAT 2,FLOAT 0) position gl.vertexAttribPointer(textureAttribute,2, gl.FLOAT ,false,FLOAT 2,FLOAT 2) texture gl.enableVertexAttribArray(vertexAttribute) gl.enableVertexAttribArray(textureAttribute) gl.drawElements(gl.TRIANGLE STRIP, 6, gl.UNSIGNED SHORT, 0) It almost seems as though the Vertices and the UV coordinates are getting mixed up.


How are minimaps rendered for open worlds? When I've created minimaps for smaller to medium levels before I would use a large texture mapped to a plane for the minimap and world map. The minimap world map camera would then view this texture from a top down view. For larger, open world style environments though I'm facing a performance vs fidelity issue. For example, a large environment requires a large texture to fit everything in, but at the same time the texture also needs to be a high enough resolution for when the player decides to zoom in onto a specific point in the map. I can make the map high resolution with enough detail up close but this creates quite a large texture size. Or I can make a lower res map which is more efficient but it becomes blurry pixelated when zooming in. Is this just a balance that I have to play with, or is there a better way to handle this? For example, creating a simple 3d mesh whose shape would act as the map. Or instead of using a texture using a vector graphic. How is this usually done?


How to texture voxel terrain without triplanar texturing? How can a voxel terrain (marching cubes) be textured without triplanar mapping ? The goal being to have more artistic freedom. I think, I could unwrap the mesh while extracting the isosurface then use projective painting. But I do not know how to handle terrain modifications without breaking the texture. I also guess that virtual texturing could help here. Links for these matters would be appreciated.


Gradient Banding in Unity Android In an Android game, I have a gradient background that changes color over time. This was achieved by creating a 1x2 pixel texture in code, and stretching it over a large quad with bilinear filtering. This all works fine in the editor, but as soon as it is viewed on an Android device, the banding is ridiculously noticeable and annoying. Since this texture is generated in code, I cannot set the compression to "truecolor" like most other post suggest, nor can I tick the "Generate Mipmap" option. Here is how the gradient look on the phone Code to generate gradient (stripped of unimportant stuff) Texture2D gradient MeshRenderer render Color HSV1, HSV2 Color primaryColor, secondaryColor render GetComponent lt MeshRenderer gt () Update() HSV1.x 0.01F Time.deltaTime HSV2.x HSV1.x if (HSV1.x gt 1) HSV1.x HSV1.x 1 if (HSV2.x gt 1) HSV2.x HSV2.x 1 primaryColor Color.HSVToRGB(HSV1.r, HSV1.g, HSV1.b HSVdifferece) secondaryColor Color.HSVToRGB(HSV2.r, HSV1.g HSVdifferece, HSV1.b HSVdifferece) gradient.SetPixel(0, 0, primaryColor) gradient.SetPixel(0, 1, secondaryColor) gradient.filterMode FilterMode.Bilinear gradient.Apply() render.material.SetTexture(" MainTex", rainbow) The color banding is really obvious and annoying. How can I fix this?


How to create a texture2d from an array of pixels in DirectX11 I currently have a ray casting camera that holds an array of pixel colors (XMFLOAT4 color) that is 1024x768. I am trying to create a Texture2D in DirectX11 that is also 1024x768 and simply copy over the pixels to the texture. I then want to apply the texture to a fullscreen quad to essentially display what geometry my rays are intersecting with. D3D11 TEXTURE2D DESC textureDesc 0 textureDesc.Width 1024 textureDesc.Height 768 textureDesc.MipLevels 1 textureDesc.ArraySize 1 textureDesc.Format DXGI FORMAT R32G32B32A32 FLOAT textureDesc.SampleDesc.Count 1 textureDesc.SampleDesc.Quality 0 textureDesc.Usage D3D11 USAGE DEFAULT ID3D11Texture2D fullScreenTexture nullptr ThrowIfFailed(mGame gt Direct3DDevice() gt CreateTexture2D( amp textureDesc, nullptr, amp fullScreenTexture), "ID3D11Device CreateTexture2D() failed.") Assuming I have XMFLOAT4 pixels 1024 768 Filled in appropriately with colors. I'm not sure where how I would take my pixel data and apply it to the texture. Any help would be greatly appreciated.


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?


texture size of characters and geosets I am a 3D artist, not a game developer but I am interested in dabbling none the less. Would anybody know the texture sizes currently used for games like WOW or Guild Wars 2? Don't worry, I'm not trying to make a massive game that takes teams of hundreds, I'm simply interested in the efficiency of MMO type games. From what I can find on the net, it's roughly 512k x 512k textures for the base character although its surprisingly hard to find the information and I don't have the games installed anymore to see if I can check. And... If anybody can explain Geo sets to a noob like me that would be great. My general understanding is that the model is separated into pieces such as head, hands, legs etc then the model with textures swapped some how to show new models and textures for say a new pair of gloves. Many thanks.


What is it called when you combine textures for an object I am trying to gain a better understanding for modeling and texturing for Unreal 4 and Blender. Now my question is What is the process result called when packing textures into one image as shown below?


Which gaming engine can be used for pixel manipulation? Here is the gist of where I am going with this. I work for a printer company and basically all of our input files(or output files for virtual printers) are bitmap files. We currently have a tool built in java over 10 years ago that works, but chokes on our high end 1600x1600 files. So I was thinking, why not utilize a game engine's built in ability to utilize the power of a gpu? I am thinking all I would have to do is create a 1600x1600 plane, feed it the image file and draw the scene. I figure this is the easy part. However, the hard part is reaching into the image for example and clicking the mouse on a particular pixel. Getting RGB data, converting to CYMK, making changes, converting back into RGB and then redrawing the scene. Not only that but pulling the modified texture out of memory and saving it back into a bitmap. Is this even possible? I haven't used a game engine since college and that was opengl 2.0. Just figured this looked like a good place to ask. Thanks.


Grainy texture from distance I am using SharpDX, a C wrapper over DirectX 11 to render terrain. While I am able to render terrain correctly, I noticed that moving around creates a lot of visual noise and makes the texture of the ground very grainy. I have attached a picture of how the texture looks on the terrain. (Make sure to make full screen for clarity) Here is the dirt texture I am using Here is the dirt texture normal map I thought I set up the mip maps appropriately in this code (note that filename is just the path to the terrain bitmap I showed above) public bool Initialize(SharpDX.Direct3D11.Device device, string fileName) try using (var texture LoadFromFile(device, new SharpDX.WIC.ImagingFactory(), fileName)) ShaderResourceViewDescription srvDesc new ShaderResourceViewDescription() Format texture.Description.Format, Dimension SharpDX.Direct3D.ShaderResourceViewDimension.Texture2D, srvDesc.Texture2D.MostDetailedMip 0 srvDesc.Texture2D.MipLevels 1 TextureResource new ShaderResourceView(device, texture, srvDesc) device.ImmediateContext.GenerateMips(TextureResource) TextureResource ShaderResourceView.FromFile(device, fileName) return true catch return false public Texture2D LoadFromFile(SharpDX.Direct3D11.Device device, ImagingFactory factory, string fileName) using (var bs LoadBitmap(factory, fileName)) return CreateTexture2DFromBitmapSource(device, bs) public BitmapSource LoadBitmap(ImagingFactory factory, string filename) var bitmapDecoder new SharpDX.WIC.BitmapDecoder( factory, filename, SharpDX.WIC.DecodeOptions.CacheOnDemand ) var result new SharpDX.WIC.FormatConverter(factory) result.Initialize( bitmapDecoder.GetFrame(0), SharpDX.WIC.PixelFormat.Format32bppPRGBA, SharpDX.WIC.BitmapDitherType.None, null, 0.0, SharpDX.WIC.BitmapPaletteType.Custom) return result public Texture2D CreateTexture2DFromBitmapSource(SharpDX.Direct3D11.Device device, BitmapSource bitmapSource) Allocate DataStream to receive the WIC image pixels int stride bitmapSource.Size.Width 4 using (var buffer new SharpDX.DataStream(bitmapSource.Size.Height stride, true, true)) Copy the content of the WIC to the buffer bitmapSource.CopyPixels(stride, buffer) return new SharpDX.Direct3D11.Texture2D(device, new SharpDX.Direct3D11.Texture2DDescription() Width bitmapSource.Size.Width, Height bitmapSource.Size.Height, ArraySize 1, BindFlags SharpDX.Direct3D11.BindFlags.ShaderResource BindFlags.RenderTarget, Usage SharpDX.Direct3D11.ResourceUsage.Default, CpuAccessFlags SharpDX.Direct3D11.CpuAccessFlags.None, Format SharpDX.DXGI.Format.R8G8B8A8 UNorm, MipLevels 1, OptionFlags ResourceOptionFlags.GenerateMipMaps, ResourceOptionFlags.GenerateMipMap SampleDescription new SharpDX.DXGI.SampleDescription(1, 0), , new SharpDX.DataRectangle(buffer.DataPointer, stride)) Here is my samplerstate code SamplerStateDescription samplerDesc new SamplerStateDescription() Filter Filter.MinMagMipLinear, AddressU TextureAddressMode.Clamp, AddressV TextureAddressMode.Clamp, AddressW TextureAddressMode.Clamp, MipLodBias 0, MaximumAnisotropy 1, ComparisonFunction Comparison.Always, BorderColor new Color4(0, 0, 0, 0), Black Border. MinimumLod 0, MaximumLod float.MaxValue SamplerState new SamplerState(device, samplerDesc) Is there anything wrong here?


Creating a large ground texture for mobile Does anyone has any insight on creating texturing a large mesh that will be used for a mobile game's level map? Specifically, I was wondering how games like Vainglory achieve this. I am familiar with the idea of splat maps, however this is where my knowledge of the subject ends... Is the use of splats on mobile a good solution? Should the mesh be broken down into small sections which are UV'd and textured separately? Neither of these things?


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 to calculate a projection of 360 equirectangular slides? My goal is to have a light source inside of a transparent sphere that has an equirectangular texture to act as a 360 slide. I want to get the projection on arbitrary objects as a texture image on these objects in high resolution. This will happen on a webserver. So my input should be the equirectangular and the object and optionally position of the light source and my output should be texture files of each flat surface of the arbitrary object. What algorithms can I use to make this as simple, quick and fast in action as possible?


What are the texture coordinates for a tetrahedron EDIT This is the WebGL code for initializing the tetrahedron points. You may want to skip to the second code block, because you may be able to answer without this. Making a tetrahedron with equal sides Using rotation matrices to determine the points 120 degrees var q Math.PI 2.0 4.0 3.0 Transformation matrix for X axis rotation var rotationArrayX 1.0, 0.0, 0.0, 0.0, 0.0, Math.cos(q), Math.sin(q), 0.0, 0.0, Math.sin(q), Math.cos(q), 0.0, 0.0, 0.0, 0.0, 1.0 var rotationMatrixX mat4.create(rotationArrayX) var d vec3.create(new Array(0.0, 1.0, 0.0)) Topmost point var a vec3.create() mat4.multiplyVec3(rotationMatrixX, d, a) Now we have the top most point and the first point of the base After rotating the vector A with 120 degrees two times, we have the 3 base points 120 degrees q q Transformation matrix for Y axis rotation var rotationArrayY Math.cos(q), 0.0, Math.sin(q), 0.0, 0.0, 1.0, 0.0, 0.0, Math.sin(q), 0.0, Math.cos(q), 0.0, 0.0, 0.0, 0.0, 1.0 var rotationMatrixY mat4.create(rotationArrayY) Calculating points B and C var b vec3.create() mat4.multiplyVec3(rotationMatrixY, a, b) var c vec3.create() mat4.multiplyVec3(rotationMatrixY, b, c) The remaining point is the top point var vertices new Array() bottom vertices.push(a) vertices.push(b) vertices.push(c) front vertices.push(b) vertices.push(c) vertices.push(d) right vertices.push(c) vertices.push(a) vertices.push(d) left vertices.push(a) vertices.push(b) vertices.push(d) How should I imagine texturing these triangles? Is this a valid set of texture coordinates? var textureCoords bottom 0.5, 1.0, 0.0, 0.0, 1.0, 0.0, front 0.5, 1.0, 0.0, 0.0, 1.0, 0.0, right 0.5, 1.0, 0.0, 0.0, 1.0, 0.0, left 0.5, 1.0, 0.0, 0.0, 1.0, 0.0, I based this on http www.codeguru.com forum showpost.php?p 1542703 amp postcount 2 (0.5,1) Texture Image (0,0) (1,0) Thanks in advance!


DirectX9 texture flashing or disappearing I am learning DirectX 9 and I have these test models in my scene and this weird texture flashing happens. If you look at the bottom of the picture you will see a blue area, that is supposed to be filled with the ground texture I have. So every time I move my camera the ground texture flashes very quickly and parts of it disappear lots of times a second. I know it's not a problem with my video card. What could cause this?


GLSL pack floats into an RGBA texture I want to compose conventional triangle based models and particles with a ray traced scene at a reasonable frame rate. webGL does not let you write the gl FragDepth in the fragment shader. You cannot have multiple render targets, but you can render to an RGBA texture and then use that texture as input to another draw op. So I can render my ray traced scene and store the depth as input to the next stage. This is obviously far from ideal, but workable. I'd love to be wrong about this, and this is gathered from trial and error rather than any definitive source please correct any flawed assumptions How can you pack unpack a float and, ideally, some flag bits and such, into an RGBA texture efficiently in a GLSL fragment shader?


SDL2 Textures bleeding 1px border around tile maps SDL RenderCopyEx taking integer arguments https forums.libsdl.org viewtopic.php?t 9486 This post gives a good indication of my question. Basically if you set SDL2 logicalScale or otherwise and render textures at native window resolution they appear fine. However, with tile maps if you resize the window in anyway, you get a bleed where an integer rounding issue creates a 1px border around certain tiles. Is my only option to create a 1px border around all my images to stop this bleed rounding error? Or a semi transparent border with the main color. What are my options? Is this solved in any of the latest SDL2.X.Y ? EDIT A simpler method I have used is reducing my images from 64x64px to 62x62px in SDL2 (not the actual sprite) and using it's own sprite as a 1px border, and using Render Scaling to scale up that 1px, which stops bleed. It reduces the quality on background images ever so slightly, but it requires no tweaking of any code or sprites... but again wondering if there's a more elegant solution.


What does the max texture unit mean? My graphics card is a UHD 620 from intel and it says that it has 24 texture units (as far as I know). Using SDL2 creating and loading 25 texture works fine, so am I not understanding what the max texture unit actually means? If I were to launch a program that uses more than 24 texture units would it crash if I tried to draw them all at the same time or would it just be really slow having to cycle between then in the shader program?


How Would You Animate a 3d Characters Face (With Textures) So I'd like to do a low poly style of modeling, and one of the corners I'd like to cut is on head geometry. Specifically, making the details of the face a texture (like a Mii or a character in Animal Crossing for example). How would you go about accomplishing animating the face? Getting it onto the model in the first place? I'm using Unreal Engine to learn and working on my 3d modeling skills at the same time, so knowing a general workflow would give me some structure to work with.


Substance Painter Jagged edges when painting normals I am painting normals on a normal layer using the Textures tab to make bumps and crevices. But the effect is so jagged. How can I fix this? INB Texture Set is already on 4K so it's not a quality issue.


How do I convert a horizontal, panoramic skymap texture into a "dome" version of itself? How do I convert the following skymap image into a "dome" version like the one below? I'm looking towards making use of Adobe Photoshop for the task at hand. However, I'm at a loss on what tools I'm going to use and how I will go about it. So, how do I convert a horizontal, panoramic skymap texture into a "dome" version of itself?


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 )


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?


How to create a texture2d from an array of pixels in DirectX11 I currently have a ray casting camera that holds an array of pixel colors (XMFLOAT4 color) that is 1024x768. I am trying to create a Texture2D in DirectX11 that is also 1024x768 and simply copy over the pixels to the texture. I then want to apply the texture to a fullscreen quad to essentially display what geometry my rays are intersecting with. D3D11 TEXTURE2D DESC textureDesc 0 textureDesc.Width 1024 textureDesc.Height 768 textureDesc.MipLevels 1 textureDesc.ArraySize 1 textureDesc.Format DXGI FORMAT R32G32B32A32 FLOAT textureDesc.SampleDesc.Count 1 textureDesc.SampleDesc.Quality 0 textureDesc.Usage D3D11 USAGE DEFAULT ID3D11Texture2D fullScreenTexture nullptr ThrowIfFailed(mGame gt Direct3DDevice() gt CreateTexture2D( amp textureDesc, nullptr, amp fullScreenTexture), "ID3D11Device CreateTexture2D() failed.") Assuming I have XMFLOAT4 pixels 1024 768 Filled in appropriately with colors. I'm not sure where how I would take my pixel data and apply it to the texture. Any help would be greatly appreciated.


Difference between texture.Load and texture.Sample(PointSampler,..) in HLSL Dx Conceptually, I understand the difference between load and sample but I want to know if essentially point sampling and load do the same thing when it comes to selecting a texture value (ignoring an out of bound situation).


Streaming webcam via websocket performance issues (Code included) I finally figured out, how I can stream my webcam, but I'm getting not the best performance. In low resolutions it's working fine, but as soon as I turn the resolution up, the performance gets worse. I think Unity can't handle the decoding in that quality and speed so that the game is getting slowed down. Here is my Code Texture2D screenshot new Texture2D(Screen.width, Screen.height, TextureFormat.ARGB32, false) screenshot.ReadPixels(new Rect(0,0,Screen.width,Screen.height),0,0) screenshot.Apply() ws.Send(System.Convert.ToBase64String(screenshot.EncodeToJPG(quality))) Hopefully there is something to improve.


What is it called when you combine textures for an object I am trying to gain a better understanding for modeling and texturing for Unreal 4 and Blender. Now my question is What is the process result called when packing textures into one image as shown below?


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


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.


Implement spherical mapping for texture coordinates I am using a texture of a world map and I am trying to put that image on a sphere made up of many triangles. Each triangle has points a,b,c with their own (x,y,z) coordinates. I am trying to use the coordinate system conversions formula from Wikipedia. This is my world to spherical coordinates function function worldToSpherical(p) const r Math.sqrt(Math.pow(p 0 ,2) Math.pow(p 1 ,2) Math.pow(p 2 ,2)) const u Math.atan2(p 1 ,p 0 ) const i Math.atan2(Math.sqrt(Math.pow(p 0 ,2) Math.pow(p 1 ,2)),p 2 ) const s r Math.sin(i) Math.cos(u) const t r Math.sin(i) Math.sin(u) return s, t But this is what my output looks like It seems to be wrapping around twice. Am I using the wrong formula, or using it wrong?


Any reason not to combine an AO Map and Cavity Map into one texture? If an Ambient Occlusion Map is for mapping shadows based on closeness of neighboring geometry, and a Cavity Map is for mapping smaller shadows based on angle or distance, then is there any reason not to mix these into one unified shadow map? It seems desirable to do so for saving a game from having to load extra textures, but I ask in case I'm overlooking something. This article gives an overview of the differences between the two types of maps, but it never mentions combining them. This made me wonder if there was some reason to keep them as separate images. Thanks in advance for any insight.


How to texture a VBO? I'm not sure which way is the best way to do this for my purposes. My purposes being having a textured (with an image) cube. Also, I've been following a blend of tutorials, so I'm not sure which way is the most right and what I'm doing wrong (currently I haven't had the texture fit right). Do I use glDrawArrays or glDrawElements? For pointers, do I say gl.glVertexPointer(3, GL.GL FLOAT, 0, vertices) and gl.glTexCoordPointer(2, GL.GL FLOAT, 0, textureData) or gl.glVertexPointer(3, GL.GL FLOAT, 0, 0) and gl.glTexCoordPointer(2, GL.GL FLOAT, 0, 0) When do I bind unbind the buffers? (gl.glBindBuffer(GL.GL ARRAY BUFFER, VBOVertices) gl.glBindBuffer(GL.GL ARRAY BUFFER, vboTextureCoordHandle) ) Before I establish the pointers or not in my drawing method at all? Do I need to specify the UV coordinates Texture Coordinates in the shader? If I'm getting a weirdly stretched texture, does that mean my fragment shader and setting the uniforms is working correctly? Thank you! I can supply more code, but I think I just need more information on the basics.


How do I get an instance of KX PolygonMaterial in Blender? I've got a question concerning using Python in Blender's Game Engine. Before I start I want to state that I'm trying to change the color of an object in Blender's game engine. To do this, I'm attempting to find a way to update the texture of the object (I basically want two or three states, red, (yellow), green). What I'm doing right now is scene GameLogic.getCurrentScene() pingMeter scene.objects 'Ping Meter' mesh pingMeter.meshes materials mesh 0 .materials material materials 0 However, when I do print(material. class . name ) it outputs KX BlenderMaterial. Shouldn't I be getting KX PolygonMaterial if I'm running the Blender Game Engine? Is there anyway to change color or texture with KX BlenderMaterial because I can't find anything in the documentation. Can I get an instance of KX PolygonMaterial out of the code above? ...or should I just take a different approach all together? Thanks! EDIT I'm using Blender 2.65 which uses Python 3 in case anyone is wondering.


Creating single texture for all materials in substance painter with ID map. ID map doesn't bake properly I am trying to create single texture for multiple materials in substance painter according to this tutorial. https www.youtube.com watch?v HMP2xpGHimY I have two models made in Blender. One with several materials(for generating ID map), another with one material. Mesh for ID map Main mesh Both are totally identical from geometry and scale standpoint. Generating ID map settings(it is a mobile game so I use only Unlit texture and don't require other maps and channels except for BaseColor) Painting the model with masks created with ID map and actual problem. Id map Model's materials in Blender (everything is great here) How can I handle this issue?


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?


Basic terrain shader without using external texture I have this (Right now I have the height map in a x x size 2D array and a 1D vector too.) What I am trying to achieve is something like this Without using any textures, only plain colors. So basically smooth transitions and some shadow (using shaders). My vertex shader looks like this version 330 layout (location 0) in vec3 Position layout (location 1) in vec3 Normal layout (location 2) in vec3 Color out vec3 fragmentNormal out vec4 ex color,pos out vec3 N out vec3 v void main () pos vec4(Position,1) ex color vec4(Color,1) fragmentNormal Normal v vec3(gl ModelViewMatrix pos) N normalize(gl NormalMatrix Normal) gl Position gl ModelViewProjectionMatrix vec4(Position,1) I have normals for all the vertices. Color is set simply in the c code based on height. Here is the fragment shader in vec3 N in vec3 v in vec4 ex color void main(void) vec3 L normalize(gl LightSource 0 .position.xyz v) vec4 Idiff gl FrontLightProduct 0 .diffuse max(dot(N,L), 0.0) Idiff clamp(Idiff, 0.0, 1.0) gl FragColor Idiff ex color So I guess my problem is what formula should I use to mix the colors. I think I don't need to set the colors in the c code but in the shaders. Update Here is the wireframe of the terrain. Update2 Based on Babis' answer the result is So the gradient is not quot projected quot onto the surface as I would like to do. What could cause this? Maybe my qustion wasn't clear.


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?


Interact with texture flat surface (Unity) I don't know exactly how to put this into words, so googling did nothing really for me. Imagine a bowling game. On the oldern bowling lanes there was only a scheme of the pins above the lane, lighting up all the pins that are still standing, while the ones that already fell, were not lit anymore. How can I achieve this in Unity? Is there any way to do this, without having to make something stupid like creating hundreds of textures, with all the possible combinations and swap them out? I'm still very new to Unity, so I'd love to know the best approach to something like this. Thank you very much in advance


Finding texture coordinates for plane I am creating a 3D ray tracer and want to add textured planes. My planes are stored using a position vector and a normal vector. I want to use a square texture and map it repetitively onto the plane. How do I figure out a transformation from points (3D vectors) on the plane and points (2D vectors) on a texture? Once I know how to do this transformation, I don't think making it repetitive will be hard, as we can just apply modulo arithmetic. I thought I could make a basis on the plane by calculating a vector B1 perpendicular to the normal, and then another one, B2, perpendicular to the normal and B1. But once I have these two vectors, I still don't know how to express the point (which is the argument for the function below) in this basis. Vector3 position, normal Bitmap texture public override Vector3 GetColor(Vector3 point) int u ? int v ? return texture.GetPixel(u, v)


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 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.


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.


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.


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 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 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.


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'?


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?


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 to get an AbstractClientPlayer for all players? I'm working on an minecraft forge mod (1.8.8). I have en custom (ownable) entity and want to set its texture to the texture of its owner, because it's a mini version of the owner. I found out that i can get the texture of players with AbstractClientPlayer getLocationSkin(), but i can't figure out how to access either EntityOtherPlayerMP or EntityPlayerSP, which implement AbstractClientPlayer, in my custom renderer. Is there a way to get all AbstractClientPlayer, regardless of SP or MP? I can access the GameProfile and i have the EntityPlayer of the owner.


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.


How do you create multiple blocks with minecraft addons? I've seen a question like this and I followed the directions they gave (Adding a blocks folder into behavior pack etc.), but I can't seem to get a result, it could be because I want to make 2 blocks (slime cyan and slime purple), OR it could also be because they weren't doing the right version because they said to add the component quot Register To Creative Menu quot and on bridge it doesn't even suggest that component (I know I said bridge but I'm not looking for a bridge tutorial). I just want to create 2 new blocks for Minecraft bedrock with only add ons, no special modding app, could anyone help me with this? I'm on Windows 10 edition. I'm using Minecraft Bedrock 1.16


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


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.


Where do I store (or how do I refer to) textures for custom blocks? I'm making my first foray into Minecraft modding on Ubuntu using Minecraft Forge. I'm finding it a little hard to get started as many of the tutorials seem to refer to older versions of Minecraft (e.g. that use the BaseMod base class, which now appears to be deprecated). I've created a simple block type package net.minecraft.block import net.minecraft.block. import net.minecraft.block.material. public class RolyBlock extends Block public RolyBlock(int par1, Material par2Material) super(par1, par2Material) and added the following static initialiser to the Block class public static final Block rolyBlock new RolyBlock(174, Material.rock) .setHardness(1.5F) .setResistance(10) .setStepSound(soundStoneFootstep) .setUnlocalizedName("rolyBlock") .setCreativeTab(CreativeTabs.tabBlock) .setTextureName("roly block") I created a 256x256 PNG file called roly block and placed it in Forge's MCP folder, in the same location as the other textures. However, when I start Minecraft (v. 1.6.5) via Eclipse, it is unable to locate the texture 2014 03 14 11 38 34 SEVERE Minecraft Client Using missing texture, unable to load minecraft textures blocks roly block.png I suspect this is because I put the texture in the directory forge mcp temp src minecraft assets minecraft textures (where I found the other textures) where this temp folder is presumably a decompiled version of the Minecraft 1.6.5 .jar file. I can't actually remember how I ended up with this folder, though. My question is how do I add a new texture to my Eclipse mod development environment? Must I rebuild a .jar each time, and if so how? Or can I have Minecraft load textures from a directory? (I'm a complete Minecraft newbie, so there are many things about the configuration dev environment for Minecraft that are confusing me. For example if I run recompile.py from Forge's MCP folder, I get a swathe of errors relating to IconRegister not being found.)


How do I make a Minecraft recipe that costs XP? I want to program a Minecraft client mod or server plugin that adds a recipe for making a Bottle o' Enchanting with the following ingredients 1 glass bottle 1 lvl of experience 1 Bottle o' Enchanting One possible implementation that I have thought of is to execute the command xp 1L player, but I am unsure how to invoke that command from my Java code. Is there a better way? How would you go about adding an experience requiring recipe to Minecraft?


Unity Particle System How to rotate particle effect? My Particle System creates a "puff" of smoke. When I rotate the particle system it doesn't rotate the effect, just the way the particle is shot. What I want to do is when I shoot a wall have it "puff" horizontal not vertical. And vertical when hitting floor. I want it to follow the normals of the surface I am raycasting to. My problem is that the texture doesn't turn with it's parent rotation. Do I need to write my own Custom Simulation Space to be able to rotate the effect? Assigning the transform of the parent does nothing. Prefab structure Particle Settings


Pygame surface rotation, rect rotation or sprite rotation? i seem to have a conceptual misunderstanding of the surface and rect object in pygame. I currently observe these objects this way Surface Just the loaded image rect the 'hard' representation of the ingame object (sprite). Used for simplifying object moment and collision detection sprite rect and surface grouped together What i want to do is rotate my sprite. The only available method i found for rotation is pygame.transform.rotate. How do i rotate the rectangle, or even better, the whole sprite? Below is the image of how i visualize this problem.


Rotate can I rotate an object to a target angle using Euler Angles? How do I rotate an object from its current angle to the desired angle in increments on 1 axis? The problem is the wraparound at 360 degrees What I have so far (Note pseudocode) double MaxSpeed 5 double CurrentAngle 170 double DesiredAngle 40 double Distance DesiredAngle CurrentAngle How do I calculate this value considering angle wraparound? CurrentAngle Mathd.clamp(Distance, MaxSpeed, MaxSpeed) Caps the rotation speed


Rotate final image with projection matrix I'm trying to use space in my shadow (depth) maps in a more efficient way. If I could freely rotate the final image I get with projection matrix I could save a lot of pixels, but I don't know if it is possible to do so. Is it?


How can obtain the relative orientation between two quaternions? How do I obtain the relative orientation given two orientations (represented by quaternions q0 and q1)?


Transform.forward having problems after rotation I have this script, void Update () float pitch, yaw, roll pitch Input.GetAxis ("Mouse Y") yaw Input.GetAxis ("Mouse X") roll Input.GetAxis ("Roll") transform.Rotate ( pitch, yaw, roll) if (Input.GetKey (KeyCode.W)) Rigid.AddRelativeForce (transform.forward 50) else if (Input.GetKey (KeyCode.S)) Rigid.AddRelativeForce ( transform.forward 50) else if (Input.GetKey (KeyCode.D)) Rigid.AddRelativeForce (transform.right 50) else if (Input.GetKey (KeyCode.A)) Rigid.AddRelativeForce ( transform.right 50) else Rigid.velocity Vector3.zero if (Input.GetKey (KeyCode.Space)) transform.rotation Quaternion.Euler (Vector3.zero) Rigid.velocity Vector3.zero Rigid.angularVelocity Vector3.zero My "Roll" is defined as 'q' and 'e' keys. "Rigid" is rigidbody object. I simply want to implement 6DoF on this cube, the pitch, yaw and roll works fine , but when it comes to movement it behaves in very unusual way after the object is rotated, I tried moving by using localPosition still no result. I also used relative torque for rotation but it resulted in worse, that is why rotation is controlled by transform.rotation not torque. I suppose I am not handling gimbal lock or something? Or am I doing it completely wrong?


Rotation in 3D space using Quaternion System Configuration I have two simulation systems (which I am going to call Sim A and Sim B) where I am going to spawn an entity created in Sim A inside Sim B. Expected outcome The entity created in Sim A appears in Sim B in the right position with the correct orientation. System Input The position of the entity created in Sim A received in Lat Long Alt format (it assumes WGS 84 spheroid) and the orientation in Euler angles. The Euler angles would help me to transform an entity from its world coordinate system to entity coordinate system by applying the Euler angles in the order of heading, pitch and yaw. Below is how it is documented. " The order of rotation is first, rotate about z by the angle psi (), then about the new y (y') by angle theta (T), then about the newest x (x'') by the angle phi (I). The positive direction of rotation about an axis is defined as clockwise when viewed toward the positive direction along the axis of rotation." However, in Sim B this rotation is defined in Quaternion and it assumes a perfect sphere for the world (not WGS 84). As a result, I have to convert Euler to Quaternion before sending the information to Sim B. I have achieved this by applying ZYX conversion (page A 11) given in here 2 . Challenge When I pass the position and orientation of an entity created in Sim A to Sim B ( Sim B uses ECEF system, so I do another conversion to go from LLA to ECEF), it appears in the correct LLA position but its orientation is incorrect (shown in the figure.). This can be fixed by adding some value to the pitch and roll but it is not mathematically sound. Also, these values might change (haven't tried) if you spawn the entity in a different location of the earth due to its shape. So, I would like to know the right way of correcting this issue (i.e. how to make the entity to stand upright). Assume that I can get the Up, Front and Right vector of the entity when it is spawned in Sim B.


CW CCW Rotation of a Vector Considering that I have a vector A, and after an arbitrary rotation I get vector B. I want to use this rotation operation in others vectors as well, but I'm having problems in doing that. My idea do that is to calculate the perpendicular vector C of the plane AB (by calculating AxB). This vector C is the axis that I'll need to rotate. To discover the angle I used the dot product between A and B, the acos of the dot product will return the lowest angle between A and B, the angle ang. The rotation I need to do is then rotate ang around the C axis. The problem is that I dont know if this rotation is a CW or CCW rotation, since the cos of the dot product does not give me information of the sign of the angle. There's a tip discover that in 2D ( A.x B.y A.y B.x) that you can use to discover if the vector A is at left right of vector B. But I dont know how to do this in 3D space. Can anyone help me?


Projectile Rotation During Flight (Tank Game) I have a tank firing projectiles into the air. I want the projectiles to be rotated relative to their position along their flight path. See the diagram I drew in the image below. At any given point I know the x and y of the projectile, z represents initial velocity, theta is also known.


From 3d rotation, snap to nearest 90 directions I have a 4x4 transformation matrix, made only from successive rotations and translations, and I'd like to "snap" my object to the "nearest" of the 24 orthogonal (multiples of 90 degree) rotations. I'm not sure how to think of the problem. Round each element of the upper 3x3 matrix to 1, 0, and 1 (cutting at .707)? I am pretty sure that would be too good to be true. Another possibility would be to convert to axis and rotation or quaternion, but would that make it simpler somehow? I'm not fluent in those manipulations. Any guidance most welcome!


Godot 3.0 Constant 2D Angular Velocity I am making a Top Down shooter in Godot 3.0 on Linux. I would like to have my character rotate to face the mouse pointer at a constant speed, and have rotation speed power ups that allow the player turn faster. So far, this is done by having a Position2D object called "Center" share the same position (but not be a child of) the player (below just called "Sprite"). The center always looks to the mouse, and the Sprite rotates with linear interpolation to eventually reach the same rotation as the "Center". The weight of linear interpolation is calculated by dividing the difference in rotation (in radians) by an arbitrary constant speed. Problem The speed of rotation increases as rotation occurs, or more specifically, the time it takes to reach the same rotation (a rotational difference of zero) becomes shorter over time. I have the following code extends Sprite onready var center get parent().get node("Center") var current time 0 var total time 0 var start rot 0 var end rot 0 func process(delta) center.look at(get global mouse position()) var amt 0 var theta abs(self.rotation center.rotation) var speed 0.05 total time theta speed start rot get rotation() end rot center.rotation if not total time 0 amt current time total time current time delta amt clamp(amt,0,1) var rot lerp(start rot,end rot,amt) center.rotation fmod(rot,(PI 2)) set rotation(fmod(rot,(PI 2))) get parent().get node("Control rotation").text str(int(self.rotation degrees)) get parent().get node("Control theta").text str(theta) get parent().get node("Control time").text str(total time) What am I doing wrong?


2 Parts Object Material displays at 90degrees Material Mask will not rotate with object? Hi I have a 2 part issue. Part 1 I have a planet in Unreal, in the object editor it is aligned properly and the material displays correctly but in the game even with the rotation set to 0 it displays as being flipped 90 degrees to one side? Why is this happening and how do I make it display correctly? Part 2 The material for the planet has a mask on it to make it display day and night. However, when I attempt to manually rotate the object everything BUT the mask rotates which screws everything up. Why does the mask not rotate and how do I make it rotate with the rest for manual manipulation?


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).


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)


Fps independent rotation I'm trying in my game to have camera rotation speed idependent of fps. For keyboard it works without problems but not for mouse movoment. At 60 fps it works good but at 200 for example rotation is to slow. mouse dif is difference since last frame in pixels. Maybe thats a problem too, bigger screen resolution will rotate faster then smaller. My code const float rot speed u.GetRotationSpeed() returns 5.f float val 0 if(allow input ALLOW INPUT allow input ALLOW MOUSE) val float(mouse dif.x) 200 if(val gt rot speed dt) val rot speed dt else if(val lt rot speed dt) val rot speed dt u.rot val How can I make it fps independent?


Quaternion rotations transforms from global to local space I am trying to solve this problem and getting no where, could really use some assistance. Rotation is defined as X (rotate left right), Y(rotate up down), Z(roll) Coordinates are X Forward backward, Y Left right, Z up down I have two objects in simulated space, both have galactic coordinates (XYZ) and a quaternion representing their rotation. ObjectA Coordinates 0.593 0 0 (directly ahead of ObjB) RotationQuat w 0, x 1, y 0, z 0 (Rotated 180 yaw, facing backwards) ObjectB Coordinates 0 0 0 RotationQuat w 1, x 0, y 0, z 0 (No rotation, facing towards ObjA) Given the above information, how do I translate ObjA's location into ObjB's local space? If ObjA fires at ObjB (or vise versa), I need to calculate which side will be hit. Forward, Aft, Port, Starboard, Ventral or Dorsal. My project is written entirely in C. Actually this is an old project, created by someone else that I am converting to using quaternions due to gimbal lock. Any advice?


Reconstruct Quaternion from 48 bit rotation data I'm trying to reverse an animation file from a commercial multiplayer game, whose format was recently updated. The problem lies within joint rotation information, which changed from a 128bit format to a 48 bit format. The old format actually was using a quaternion representation with 32 bit floats for each component (32 4 128 bit) The new format was probably added for quantization purposes (serving better multiplayer performance). I played around trying to apply an euler angle representation (3 x 16 bit integers or 3 x 16 bit half floats) but i failed miserably so I think it should be still a quaternion representation of some sort. I have located a model which has not changed at all structurally but obviously the model files have been updated to the newest format. So I do have the byte data, I know the correct rotation angles (again from game data) that correspond to those values as well as the quaternion values from the old version of the files. New Format Bytes Rotation(deg) X,Y,Z Quaternion 41 ED 3F ED 41 6D 0, 90.0, 89.99 0.5, 0.5, 0.5, 0.5 85 F7 2C A0 85 77 59.64, 90, 0 0.3516, 0.61347, 0.351634, 0.61347 AE CE FF BF FF 3F 180, 0, 18.54 0.98 0.16 0 0 40 ED BE 92 BE 12 0, 90,90 0.5, 0.5, 0.5, 0.5 DE 40 DA 42 CA 3C 1.017, 3.633, 4.091 0.009633918, 0.03154902, 0.03542599, 0.9988277 I'm currently searching the web for quaternion quantization techniques and I'm experimenting with different stuff, so if I find anything I'll make sure to update. Thanks in advance


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


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.


THREE.JS why is the rotation only applied on the last axis used? my function function rotateAroundWorldAxis2(object, radians1, radians2) object.rotWorldMatrix.makeRotationX(radians1).makeRotationZ(radians2) object.rotWorldMatrix old code for Three.JS pre r54 rotWorldMatrix.multiply(object.matrix) new code for Three.JS r55 object.rotWorldMatrix.multiply(object.matrix) pre multiply object.matrix.copy( object.rotWorldMatrix ) old code for Three.js pre r49 object.rotation.getRotationFromMatrix(object.matrix, object.scale) old code for Three.js pre r59 object.rotation.setEulerFromRotationMatrix(object.matrix) code for r59 object.rotation.setFromRotationMatrix(object.matrix) my object was initialized like this object.rotWorldMatrix new THREE.Matrix4()


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 convert relative position of child to parent into an absolute position? I am modifying a game that stores object positions with a 3d vector x, y, z and rotation as a 3d vector with degree angles x, y, z . I want to place an object in relation to a parent object accounting for its rotation. I do not have access to the game code, so I have to provide a position of the child as an absolute position. For example, I would like to place a child object at a relative position 50, 0, 100 50 units along the x axis and 100 units up the z axis from the parent's position. Assuming the parent object is currently at position 0, 0, 0 with rotation 0, 0, 0 the resulting absolute position for the child object would be simply 50, 0, 100 . But, if the parent has a position of 0, 0, 0 and a rotation of 0, 0, 90 , the child's absolute position would be 0, 50, 100 . What would be the transformation function that, given the absolute parent position, parent rotation, and relative child position, outputs the absolute position of the child (taking into account all three axes of rotation)?


Transform inertia tensor using quaternion I have inertia tensor T in body coordinates and quaternion q for the body. I know I can transform T to world coordinate by converting quaternion to rotation matrix R and then use the relation (R T R T). However this seems unnecessarily expensive and unwieldy (especially if you are doing this often). So my question is How do I transform inertia tensor from body to world coordinate directly using quaternion and without having to generate rotation matrix from quaternion?


UE4 Event Tick and getting Forward Vector I'm trying to make a game where my character rotates towards cursor (that works). He can choose between a few weapons (also works). One of the weapons works like a machine gun. My idea was to make a simple solution with Event tick gt gate (opened by pulling LBM and closed by releasing it) gt gate (closed after firing and opened after some delay) gt spawning projectile which leads to a sequence that closes opens the second gate. It doesn't work perfectly. The projectile spawns with the right scale and location, but the rotation is always pointing straight forward. If the exactly same blueprint is attached to anything else (straight up to the LMB pull or a timer), it works perfectly. However, doing the LMB pull defeats the whole purpose, as it's not a machine gun any more, and timer... is less then perfect I believe. I liked my solution using gates but it just doesn't want to work. For example, this bit works with no problem (even though the spawning and rotation code is literally copy pasted) Does anyone have an idea on how to fix this?


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


How to expand the limit of screen mouse access for FPS side rotation I started coding in Godot and i have a working FPS controller but the problem is that when i move my mouse sideways , it cannot move my sight beyinid that side of my screen , in other words the movement of my charecter is limited by the size of my screen , how to prevent this Rotation code func input(event) if event is InputEventMouseMotion head.rotate y(deg2rad(event.relative.x mouseSensitivity)) camera.rotate x(deg2rad(event.relative.y mouseSensitivity))


XNA Rotating a Rectangle? I am in the process of making a giant shooter game and I have got to the point where I needed to use rectangles to detect bullets and giants hitting the player. I did that however, if you look at this image It shows the giant and the players rectangle, as you can see they are not rotating with the player, any idea how to fix this? Also yes I know they are no the same size as the sprites, that is because I set the size as they were to big before. Thanks for any help )


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.


Find out which way to rotate based on current rotation and final rotation I have one object that I want to rotate to a certain angle with 'smooth' rotation. I looked up on how to solve that and I came up with this enter image description here But how do I know in what way to rotate, positive or negative? According the the picture on ex. 1, I need to rotate positively because it is the closest way for me to rotate. And on the second it is the negative way. But how do I know this? I've tried several solutions but I can't seem to find anything that is correct.


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