# Tagged Questions

A 2D array of numbers, symbols or expressions, arranged in rows and columns. Each row must have the same number of columns. The numbers, symbols or expressions themselves are called elements or entries.

210 views

### XNA matrix order problem

I want a matrix that scales first and then rotates. I tried the code below, but it didn't work. zRotation, yRotation and xRotation are rotations that shouldn't be affected by the origin. allrot should ...
615 views

### Shear transformation in the projection matrix?

I am trying to understand what the shear transformation (l+r/r-l & b+t/t-b) is actually doing in the projection matrix? The only thing I got till now is headache :) Can you please help?
540 views

### Creating a 2D perspective in 3D game

I'm new to XNA and 3D game development in general. I'm creating a puzzle game kind of similar to tetris, built with blocks. I decided to build the game in 3D since I can do some cool animations and ...
1k views

### How to do directional per fragment lighting in world space?

I am attempting to create a GLSL shader for simple, per-fragment directional light. So far, after following many tutorials, I have continually ran into the issue: my light is specified in world ...
535 views

### Matrix multiplication - Scene Graphs

I wrote a MatrixStack class in C# to use in a SceneGraph. So, to get the world matrix for an object I am suposed to use: WorldMatrix = ParentWorld * LocalTransform But, in fact, it only works as ...
229 views

### Common way to store model transformations

I ask myself what's the best way to store the transformations in a model class. What I came up with is to store the translation and scaling in a Vector3 and the rotation in a Matrix4. On each update (...
285 views

### Matrix transforms in XNA

So in my most recent 2D game I draw objects like so. _spriteBatch.Draw(_sprite, Center(), null, Color.White, _rotation, new Vector2(_sprite.Width / 2, _sprite.Height / 2), _scale, SpriteEffects....
2k views

### What is the difference between a modelview-projection matrix and world-view-projection matrix?

So basically I wrote a shader a long time ago that uses all World and WVP matrices. Now I am working in an engine that will only give me access to ModelView, MVP, and model to world space matrices. ...
878 views

### Is this Rotation Matrix correct?

I'm having heavly troubles with setting up a View Matrix and a Projection Matrix. It simply doesnt work. So I think my problem is related to my rotationMatrix function. I'm using this tutorial to ...
191 views

### Manual GLU.gluUnproject

Before I used GLU.gluUnproject to calculate my picking ray in my OpenGL game. Recently I switched to my own calculated matrices, and now I can forget the gluUnproject. How can I calculate the picking ...
268 views

### Optimising skeletal animation

I am implementing a skeleton system for my latest game. I am using my own linear algebra classes which already have some optimisations, such as separate transformPoint and transformVector functions ...
10k views

### OpenGL - Understanding the relationship between Model, View and World Matrix

I am having a bit of trouble understanding how these matrixes work and how to set them up in relation to one another to get a proper system running. In my understanding the Model Matrix is the matrix ...
235 views

### OpenGL Calculate Matrices

Im trying to switch from the glTranslate etc to my own Matrices, but for some reason it does not work. Here are my 2 functions to create the view- and projection matrix: public Matrix4f getViewMatrix(...
475 views

### Sharp DX Identity Matrix, Matrix.Forward vector pointing at negative Z

I'm trying to take a steady grip on Sharp DX. Already done some work like translating, scaling and rotating objects. Now i have to calculate the rotation matrix using only direction vector and ...
105 views

### What values to construct “Projection Matrix” from?

I am curious to what standard values I should use to create a camera's projection matrix, as well as if certain measurements need to be taken if I want to represent a very small world or a very big ...
138 views

### Getting Rotation Values From A Rotation Matrix

I'm trying to get rotation values along the x, y and z axis from a matrix that can include rotation, translation and scale data. Currently I have this function to return the y rotational value: float ...
827 views

### Rotating and Translating a Node in Horde3D with Matrices and Quaternions

I have been trying to learn how to use the Horde3D rendering engine for the past couple of days, and so far I have managed to learn a decent amount and integrate Bullet Physics with it as well. My ...
147 views

### XNA Camera Positioning All Wrong

I've been working in 3DSMax for years now and decided to give XNA 4.0 a try. I've got the majority of it working, however the camera is being a pain to me and I can't discern what's gone wrong. I ...
190 views

### What kind of projection is ScreenX=X/Z, ScreenY=Y/Z?

I have an existing class which transforms 3D vectors and projects them on a 2D plane (Camera). The code is all written in C without help from an external library. To project a single vector (X,Y,Z) ...
826 views

### Negative scale in Matrix 4x4

After some rotations and to from quaternion conversions I get negative scale from Matrix 4x4, is it possible? I need that scale to draw sprite on screen so I get sprite flipped, how to deal with this ...
438 views

### Java Tetris - Matrix Rotations

I'm building Tetris in Java and am trying to use linear algebra to rotate a piece composed of 4 tiles. My friend was explaining the way to do it is: He said: "To clarify, you do need to rotate ...
2k views

### Tetris - Rotations using Linear Algebra (Rotation Matrices)

I'm making Tetris in Java and am at the point of rotations... Originally I was hardcoding each rotation: if (direction.equals("right")) { if (shape.equals("Bar")) { if (...
592 views

### Translating Viewmatrix is inverted, why?

So I've defined a Projectionmatrix, Viewmatrix and a Modelmatrix using OpenGL (LWJGL). But when I translate my Viewmatrix to +X it moves my object to the right (hence my camera is moving to the left),...
177 views

### Transform translation relative to world space

What is common algorithm for translating a transform matrix relative to world space axis? E.g. Matrix M is representing some local space. When I want to translate M relative to it's own local axis, I ...
218 views

### Camera not strafing (GLSL)

I use this code in my GLSL vertex shader, where v_position is the vertex position: gl_Position = v_position * u_camera; and set u_camera as follows: meshShader.setUniformMatrix("u_camera", camera....
151 views

### transformations of matrices

I'm in the process of reading up on 3d matrices and trying to following this powerpoint and had a few questions as to how to exactly determine the type of transformation from a matrix. If I have a ...
364 views

### Box2D OpenGL debug renderer convert box2d coordinates to world space

I made an OpenGL 3.x renderer for Box2D's debug draw (b2Draw base class). Unfortunately I've tried for a while now to convert the box2D units, which are meters to my internal units which are pixels. I ...
371 views

### Directional light and matrix issues

I'm trying to implement basic directional lightning in OpenGL 3.3 by emulating the logic shown in this guide: http://www.arcsynthesis.org/gltut/Illumination/Tutorial%2009.html I do not understand ...
121 views

### Rotate Points with Object in world space

I posted this in the original stack overflow then realized that a game-dev specific one exists. I am working on personal project that requires me to have 4 points surrounding an object (1 at each of ...
872 views

### World space and model space the dummies version [closed]

I'm by no means a 3d programmer but have recently taken it upon myself to build a Voxel based game and I'm having a little trouble understanding some of the concepts around matrices (what with my ...
1k views

### Rotating plane to be parallel to given normal via change of basis

I have two planes and their respective normals. I would like to rotate the second plane, planeB, so that it is parallel to the first, planeA. To do this, I am using a change of basis to rotate each ...
543 views

### Accumulating rotations for camera

It seems there are three ways to store a camera's rotation: in angles, view matrix or quaternion. I was using euler angles since when I used a matrix it had a tendency to accumulate rounding errors ...
225 views

### Proper approach to handle transformation matrix and extract its components

Basically I have a Transformation component object with following structure(pseudo): TransformComponent{ Vec3 position; Vec3 rotation; //in euler angles Vec3 scale; Mat4 worldMatrix; //...
656 views

### Ways to “invert Z-axis” in shader-based core-profile OpenGL?

In my hobbyist shader-based (non-FFP) GL (3.2+ core) "engine", everything in world-space and model-space is by design "left-handed" (and to stay that way), so X-axis goes from -1 ("left") to 1 ("right"...
420 views

### How can I create a 2D camera with upscaling and translation?

I've computed a Viewport that is fair in size (a proper aspect ratio to the given device) and then I calculate my ScaleMatrix like so: scaleMatrix = Matrix.CreateScale( (float) ...
6k views

### What matrix operations do I perform to translate then rotate then translate then rotate?

In an android game I want to draw a running leg. To output the thigh I do something like: // legCX,legCY is the location on screen about which the leg rotates. Matrix m = new Matrix(); m....
4k views

### Mapping 3D object coordinates to 2D screen coordinates with perspective projection

Sort of following on from where this person was in their topic: Matrix for 2D perspective What I have at the moment is a transformation matrix that's defined as follows: http://pastebin.com/GM6BhP0R -...
2k views

### How can you extract orientation from a transformation matrix?

I have a 4x4 transformation matrix M, and I want to find out the shape of a sphere when transformed by M. (Sphere is at the origin and has radius 1.) I know I can find the center by just multiplying ...
64 views

### Assigning bone transform in every draw a good idea?

In my Draw method, I am doing the following: thisMesh.CopyAbsoluteBoneTransformsTo(transforms); Is this a good idea? Or should I do this once at the constructor level?
670 views

### 2D Matrix Transformation (with a Player and Ground)

I have a simple game that I'm trying to do for learning purposes, but Matrices are a bit hard, especially in DirectX. I currently have a tilesystem that renders tiles at the screen and a character ...
1k views

### All of my matrix functions not working? OpenGL ES 2.0

I am trying to make a projection matrix scaling the screen and making a coordination system. For some reason I don't think any of my matrix calling is working... the 3 function I am using are Matrix....
2k views

### Rotating 3d plane to XY plane

I have a triangle in 3d space and would like to create a grid over the triangle, such as in the image below. The purpose of this is to store information about each block of the grid. In order to ...
581 views

### Stacking Drawing Matrix for SpriteBatch in XNA

I'm trying to make a 2D engine for XNA with SpriteBatch. My object unit is Entity, which can include other Entities as its children. However, when drawing them, the rotation and scaling stacking do ...
635 views

### Handling Origin/Anchor Points in a Scene Graph

I'm trying to implement a simple scene graph on iOS using GLKit but handling origin/anchor points is giving me fits. The requirements are pretty straightforward: There is a graph of nodes each with ...
201 views

### How do I implement a physics gun?

I'm currently trying to implement a physics gun for my game. What I want is for the entity to stay in the same position on the screen no matter how I wiggle the camera about, what is the correct way ...
231 views

### Is my idea of how to use matrices to layer 2D on top of 3D correct?

I'm new to using matrices, so I'd like some input on whether I've understood the use of them in the context described in the title. Right now I have a small Direct3D 11-based game engine which ...
87 views

### Transform a Screen Delta

I have a delta in screen coordinates that I want to transform to a 3d delta in world space. The delta is in this case a movement across the (x,y) coordinates in screen space on the near projection ...
937 views

### Matrix Rotation with three Angles

I want to rotate a form with three given angles fo each of the three axis. But the GLM rotation function takes only one angle and a vector as arguments. How can I convert between both formats?