Archived

This topic is now archived and is closed to further replies.

D8575777

Matrix Questions

Recommended Posts

Hi, I am trying to get started in 3D, I use c# alot and having been messing with the pointsprites direct3d example. I haven''t been changing the pointsprites, they just look cool and the example has a ground which gives me some perspective, they add some excitment. I am trying just to get a feel for the 3d functions but matrix''s aren''t like anything i worked with in sql windows apps. My questions: I looked everywhere and can''t find a reference that tell what the matrix values corespond too, M31-34 yawl pitch and roll, or is it all relative to the matrix.identity? Say I''m just using a 3d font mesh that says "Doug Sucks" (My friend is doug he will think it''s funny), it sits on the origin where the pointsprites are(device.Transform.View = viewMatrix, this works), how can i easily move it up off the ground a little and out in any direction? once i figure that out i can experiment and see what other stuff i can do but i am stuck right now. i try and do random commands to see the effect but they then i can''t see my 3dmeshfont, ie: objecttwo = viewMatrix; objecttwo.Scale(1.0f,1.0f,1.0f); device.Transform.View = objecttwo ; which i assumed would make it bigger but it is just gone now. Any help or a link that show how to use the matrix(); to control where things go. Thanks, D

Share this post


Link to post
Share on other sites
The mayrix can me used in many ways, but you have to know where and how... for example camera matricies are created by special functions and take up the view and projection slots in the transformations.

What your trying to do would go into the world slot as would anything else that modifies objects in your worldspace, and be sure to multiply it with the current one if something is already there vis matrix.multiply(...)

Just look into some of the samples or take a look at the great tutorial at www.directx4vb.com

Good Luck

Share this post


Link to post
Share on other sites
Hey thanks, that did the trick, sorta, i have moved past my stoppage, using this:

Matrix tmpMatrix = new Matrix();
tmpMatrix.Translate(-10.0f,0.0f,0.0f);
objecttwo.Multiply(tmpMatrix);

device.Transform.View = objecttwo ;

i only have two matrixes to set objecttwo too, view and orientation, i think I need to get out of this example and start my own code. How do I an initial matrix that I can keep refering to set locations of things? Matrix.Indentity?

Share this post


Link to post
Share on other sites
I''ve gotten way past that last problem and learned tons about matrices. I''m stuck again, I am going for a 3rd person view, i think I am very close, if I just changed the world matrix the character stays in front of me as long i don''t do an yaw rotation. so I tried to modify the view of the character by using the LookAtLH, this fixes my yaw problem but now i have a pitch problem, when i look up the character goes up. how do I remove the pitch? Here is my matrix setup for the character:


Matrix matWorld = Matrix.Translation( -objectCenterA.X,-objectCenterA.Y,-objectCenterA.Z );

tMatrix2 = new Matrix();
tMatrix2.Scale(0.03125f,0.03125f,0.03125f);
Matrix PosMatrix = Matrix.Invert(viewMatrix);

tMatrix2.Multiply(Matrix.Translation(PosMatrix.M41+5.0f,1.0f,PosMatrix.M43+5.0f));

matWorld.Multiply(tMatrix2);

device.Transform.World = matWorld;


float pangle = 90.0f;
float distance = 2.0f;
float rideheight = 1.0f;
Matrix tM = Matrix.LookAtLH(new Vector3((-(float)Math.Cos(Math.PI/pangle)*distance + position.X), rideheight, (-(float)Math.Sin(pangle)*distance + position.Z)),new Vector3(position.X,position.Y, position.Z), new Vector3(0.0f, 1.0f, 0.0f));

Matrix.Invert(tM);

device.Transform.View = tM;



I believe there is something fundamental wrong here(you telling me to use the world matrix in my first post help immensely) I think this problem is along the same line should I be using the transform.world or view here?

Share this post


Link to post
Share on other sites