Skip to main content
9 votes
Accepted

lookAt with orthographic camera (gl-matrix)

When I use the identity view matrix, I can see my model, but when I use LookAt, it is not visible. How can I see my model using ...
Jimmy's user avatar
  • 9,059
7 votes
Accepted

How to mirror/reflect/flip a 4D transformation matrix

To get a transformation matrix equivalent to the one you have, but reflected across a major axis you can compose it (multiply it by) a reflection matrix. That is, if you have your input matrix M and ...
Theraot's user avatar
  • 28.3k
7 votes
Accepted

Finding islands from array

This is a standard computer science problem called connected component search. You can solve it in time linear in the number of cells using iterated depth-first / breadth-first search or a flood fill ...
DMGregory's user avatar
  • 141k
6 votes
Accepted

How to convert a 4x4 matrix transformation to another coordinate system?

This is as easy as writing your old coordinates in terms of the new ones. We want +x to map to +x (1, 0, 0) We want +y to map to +z (0, 0, 1) We want +z to map to -y (0, -1, 0) We want the fourth, ...
DMGregory's user avatar
  • 141k
5 votes

How does glm::lookAt produce a View Matrix?

Alright so upon looking into it further, here's how glm::lookAt produces a View Matrix: Make a row-major ordered 4x4 Translation Matrix by negating the camera position, c: ...
Ian's user avatar
  • 71
4 votes
Accepted

Why do these DirectXMath functions seem like they return column-major matrics?

You posted a column-major version of the translation matrix for (1,1,-1): 1.0 0.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 0.0 1.0 -1.0 0.0 0.0 0.0 1.0 ...
Chuck Walbourn's user avatar
4 votes

From 3d rotation, snap to nearest 90 directions

For anyone in the future looking for a solution to this using Unity/C#, here is an implementation I made based on Steve's answer: ...
Callum Ferguson's user avatar
4 votes
Accepted

Normal Matrix in plain English

You need to use a different matrix to transform your normal vectors when your model's transformation might include non-uniform scale. When we stretch a shape along, say, just the y axis, the y ...
DMGregory's user avatar
  • 141k
4 votes
Accepted

Difference between World matrix and Model matrix?

The names "world matrix" and "model matrix" are just terminology, and are not 100% standardised, so depending which source you read you may see them being used to refer to a number ...
Maximus Minimus's user avatar
4 votes
Accepted

How do I create a localtoworldmatrix and worldtolocalmatrix in Godot?

In Godot a Transform3D has no concept of local or world. They are transformations between spaces, and what those spaces are depend on how you use them. For a ...
Theraot's user avatar
  • 28.3k
3 votes
Accepted

How to Convert a Z Up Matrix to a Y Up Matrix?

Anything you'd do would effectively be a rotation. That's the matrix to apply to your other matrix: [1 0 0 0] [0 0 -1 0] [0 1 0 0] [0 0 0 1] Alternatively: <...
Stephane Hockenhull's user avatar
3 votes
Accepted

3d isometric projection matrix?

You should try having a separate camera and projection matrix, since isometric projection is just ortographic with a very specific camera placement. If you are using a modern matrix library (you ...
Bálint's user avatar
  • 15.1k
3 votes

Should calculations be done on the CPU or GPU?

A few rules of thumb around this, if the calculation only needs to be done once and applies to the entire object, then you will get best bang for buck calculating it prior to loading onto the GPU. IF ...
ErnieDingo's user avatar
  • 1,190
3 votes
Accepted

Should 3D transformations be represented by a 4x4 matrix or a 3x4 matrix?

Since 3D transformations are represented by 4x4 homogeneous matrices Correction: Might be represented by 4x4 matrices ;) Now I can see how this would be a great optimization at first as it increases ...
wychmaster's user avatar
3 votes
Accepted

Invert parent transform (doesn't work for combination of rotation and scale)

A 4x4 homogeneous matrix can represent any affine transformation. That is, any combination of: Translation by any offset Rotation around any axis by any angle Scale along multiple arbitrary axes by ...
DMGregory's user avatar
  • 141k
2 votes

Problem Rendering a Wireframe Cube and Grid with DirectX 11

D3D11_INPUT_ELEMENT_DESC inputElementDesc[] = { {"POSITION",0,DXGI_FORMAT_R32G32_FLOAT,0,0,D3D11_INPUT_PER_VERTEX_DATA,0} }; You need to change the format to ...
Jordan Calderwood's user avatar
2 votes

TRS Matrix between 2 points

The question hardly makes sense for points, since, if I'm not mistaken, there are infinitely many matrices that would fit. If you mean 'objects' rather than 'points', then the answer simple: You ...
HolyBlackCat's user avatar
  • 2,054
2 votes

Is clipping done before or after projection?

The projection matrix describes the mapping from 3D points of a scene, to 2D points of the viewport. It transforms from eye space to the clip space, and the coordinates in the clip space are ...
Rabbid76's user avatar
  • 321
2 votes
Accepted

Why does a translation matrix need an extra row?

If you're doing all your transformation with a single matrix, and you don't need to do any other computation with that matrix or the output vectors, then you're right, you don't need the extra row. ...
DMGregory's user avatar
  • 141k
2 votes

Display object at different position

Yes, you have several options here: Use Graphics.DrawMesh (or one of its variants) to manually submit a drawing call, without a renderer component at all. You can provide your own position & ...
DMGregory's user avatar
  • 141k
2 votes

How do Axis-Aligned Bounding Boxes update with rotations?

Given an original axis-aligned bounding box and a transformation matrix, you can compute a new axis-aligned bounding box from the extents of the original box, transformed by the matrix, like so: <...
DMGregory's user avatar
  • 141k
2 votes
Accepted

What exactly does XMMatrixPerspective{L,R}H do?

The DirectXMath library is all inline so you can look directly at the source. For example, here is the C version of XMMatrixPerspectiveLH: ...
Chuck Walbourn's user avatar
2 votes
Accepted

Translate operation is rotating?

Your matrix is row major, so you should transpose it in order to get behaviour you expect, since OpenGL memory layout is more column-major friendly, because translation is located in the memory at the ...
Ocelot's user avatar
  • 1,433
2 votes
Accepted

Which is a better way for moving 3d objects in OpenGL?

Mix of the both: move object for game logic, move the origin/camera (modify modelview matrix) for drawing. As you said, recalculating the vertex buffer every frame is not going to be efficient, to ...
crueltear's user avatar
  • 371
2 votes
Accepted

matrices and nesting hierarchy with game objects

Inheritance of transformation is the main reason we like to use transformation hierarchies in game scenes. If I want to move a car, it's convenient that I can simply move the body/root of the car, ...
DMGregory's user avatar
  • 141k
2 votes
Accepted

Scaling a rotated child with parent-child transforms

After some experiments, I figured this out, and as was noticed in the comments to my question it was not to do with my matrix multiplication order, but rather something else entirely. After ...
DavidColson's user avatar
2 votes
Accepted

What is the signifigance of the Dot Product in World to Local Transformations?

This is a vector projection. Dotting a vector like AgentPosition with a unit direction vector like AgentHeading or ...
DMGregory's user avatar
  • 141k
2 votes

Rotate Object in world space - Raytracing

As mentioned in the comments, rotation in 3 dimensions has 3 degrees of freedom (you can think of them like yaw, pitch, and roll), but a unit vector in 3 dimensions has only 2 degrees of freedom (...
DMGregory's user avatar
  • 141k
2 votes
Accepted

Random 100x100 map using all levels from 1 to 100

To ensure all castles 1-100 are present, simply shuffle an array containing all the numbers 1-100. You can either do this once when you first generate the map and then hold onto it, or you can use a ...
Cloudy's user avatar
  • 1,154

Only top scored, non community-wiki answers of a minimum length are eligible