# uglybdavis

Member

151

1065 Excellent

• Rank
Member
1. ## Vector4 W Component

Thanks guys! That pretty much answers all my questions!
2. ## Vector4 W Component

I'm working on a Vector4 class, and am having a hard time figuring out what to do with the W Component.   To my understanding if W is 0, the vector is treated as a vector when being multiplied by a matrix. That is, it will not be translated, only rotated and scaled. If the W is 1, the vector is treated as a point when being multiplied by a matrix. That is, it will be translated, rotated and scaled!   So, what vector operations does W take part in exactly? I assume not length.... It would be odd if W took part in the Length operation as the vector (2, 2, 2, 0) and the point (2, 2, 2, 1) would have different results.   On that same note, it does not make sense (to me) to include W in the dot product calculation either.    So, should i just ignore W for these operations: Addition, Subtraction, Scalar Multiplication, Dot Product, Cross Product, Length and Projection?   But then what happens when a Vector with a W of 0 and a Vector with a W of 1 are added? Point + Vector = Point makes sense in my head. But Vector + Point = ? That doesn't really make much sense...   Does this make sense to anyone else? How do you handle the W component of a Vector4?
3. ## Confused about row major matrix and pre multiplication

Thank you!   That has answered all of my questions. Thanks again, you have no idea how helpful that all was!
4. ## Confused about row major matrix and pre multiplication

That's very helpful.    If i understand what you said correctly, if two matrices (A and B) together; to find element 2,3 of the resulting matrix   Row major multiplication: take the dot product row 2 of matrix A and column 3 of matrix B   Column major multiplication: take the dot product of column 2 of matrix A, and row 3 of matrix B   ----------------------------------------   So, last question (i hope). Does the above mean that the formula for matrix product (For matrices F & G):   This will always take dot product the i-th row and j-th column of the two matrices, the only difference being that row major = FG, while column major = GF   OR, do the subscripts get a different meaning? Like in row major it's the i-th row and j-th column, where with column major it's the j-th row and i-th column?
5. ## Confused about row major matrix and pre multiplication

I see, thank you for clearing that up.    If i understand correctly, the transpose is a result of treating the vector as a column vector; hence the matrix is never actually transposed. Is that correct?   I have one more question regarding pre / post multiplication. I always assumed that the whole row v column order was what determined if pre or post multiplication is used (Due largely to my understanding of linear algebra being based on the differences in OpenGL & Direct X).    Now that i'm trying to build some more solid mathematical foundations i find my old understanding very chalenged.   If we have Matrix T (a translation matrix that translates by 10, 20 and 30)  and matrix S (A scale matrix that is a uniform scale of two)   And we want to concatinate the transformation so that the matrix translates first, and scales second we must calculate it as S x T. This is assuming the same multiplication method as in the first post. I think because we scaled first then translated this is using post multiplication?   If correct, how come post multiplying two row major matrices works in math but Direct 3D uses pre-multiplication? Is this due to some implicit like the vector X matrix multiplication? Am i missing something trivial in my mental model of how this works?   Or perhaps is my pre / post terminology wrong when it comes to multiplying matrices?
6. ## Confused about row major matrix and pre multiplication

I'm hoping someone could clear up a bit of matrix confusion i'm having. The breakdown might be because of my understanding of math or direct x but here goes.   As i understand Direct3D is often using a left handed coordinate system, row major matrices and row vectors with pre multiplication.   pre multiplication meaning that the vector being multiplied goes before the matrix. IE: transformedVector = vector * matrix;   Now as far as i understand given matrices A * B, to calculate the matrix product of element 2, 3 you take the dot product of the second row of A and 3rd column of B. This means that A and B's inner dimensions must match, and their outer dimensions will be the size of the resulting matrix.   With the above rules in mind given a row vector (4, 1) and a transformation matrix (4, 4) the only way to get a row vector as the result is to use post multiplication. That is transformedVector = matrix * vector.   So, given this information how on earth does DirectX use pre multiplication? Do they not follow the row / column rules of the dot product and in effect transpose the vector or matrix?   Context: HLSL, Direct 3D 9: https://msdn.microsoft.com/en-us/library/windows/desktop/bb944006(v=vs.85).aspx float4 VertexShader_Tutorial_1(float4 inPos : POSITION ) : POSITION { return mul(inPos, WorldViewProj ); };
7. ## Unity Game Engine for Linux

@phantom I totally forgot UE4 is on linux now!   @alnite It's just in blender. You're gonna have to do some googling. Tough as phantom pointed out, UE4 man! Should be super quick to prototype with blueprints.
8. ## Unity Game Engine for Linux

Game Editor Blender Game Engine Godot C4
9. ## OpenGL Row v Column Majors

I'm a bit confused. I keep reading the following: OpenGL uses a right-handed coordinate system, column-major matrices, column vectors, and post-multiplication.   Yet the in memory layout of an OpenGL matrix is: x.x x.y x.z 0 y.x y.y y.z 0 z.x z.y z.z 0 p.x p.y p.z 1 Or x.x x.y x.z 0 y.x y.y y.z 0 z.x z.y z.z 0 p.x p.y p.z 1 Which is a row major layout!   I'm trying to roll my own math library, looking at glm for guidance, matrices are indexed as mat[row][col] which would seem to only further strengthen that OpenGL is indeed using row matrices.   It sounds like the matrix notation used in the OpenGL docs (and blue book) does not describe the in memory layout of the matrices. Which begs the question, does this mean i should be pre-multiplying matrices, or do i need to account for the in-memory layout when doing matrix multiplications and keep post-multiply?   again, turning to glm for help, if i want to translate a model to 1, 2, 3 and then scale it up by 2 i need to do post multiplication: glm::mat4 mat = glm::translate(glm::vec3(1.0f, 2.0f, 3.0f)) * glm::scale(glm::vec3(2.0f, 2.0f, 2.0f)); Results in: 2, 0, 0, 0,  0, 2, 0, 0,  0, 0, 2, 0,  1, 2, 3, 1 But, if the matrix has a row layout, shouldn't that multiplication be in reverse?   So confused.....
10. ## C++ multiplatform engine/framework/library?

Gameplay3D: http://gameplay3d.org/   Cross platform C++ gem!
11. ## Good C (not C++) math library?

Seeing how the glm source is available, why not copy-pasta the features you need? I've done this in the past and ended up with a small managable library of math code.
12. ## noob question - dark basic

It sounds like you're kind of a beginner, so welcome to the wonderful world of code!   For you, i'm going to go ahead and say the merits of a language should be gauged by the amount of information available targeting it rather than the complexity of learning it. Say you want to write some pathfinding code (Pretty important for an RTS game), i'm going to go out on a dime and say you can find more / better resources about pathfinding utilizing C# or Javascript than you could using any flavor of basic. Also keep in mind you are not interested in learning EVERY feature of C# or LUA, just the small subset that targets what you are trying to do.   Even simple projects are complicated to code, there is a lot of hidden complexity. I would suggest using a pre-made engine as you are not trying to showcase your code writing skills. There are a few good options for you, the two prominent ones are Unreal 4 (Blueprints), and Unity3D. I haven't used blueprints myself, but from what i gather so far it's super simple artist friendly visual coding. With Unity you will most likely have to learn C#, but there are a LOT of references online for this. Just take a look at the Packt Pub books. And the 2D unity tutorials / resources are just growing larger and larger.   Anyway, best of luck!
13. ## Script language implementation in C#

http://msdn.microsoft.com/en-us/library/hbxc2t98(v=vs.84).aspx
14. ## Dissecting idTech4

Dissecting a production engine is never a fun learning experience. In production, things make it into code that shouldn't. That's just life.   How about starting with a more modern engine, that was made specifically to learn from:  https://github.com/blackberry/GamePlay   There is an older GDC video about it, but i lost the link.
15. ## Visual Studio 2013 _tmain ?

Thank you! That is the exact info i needed!!