Archived

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

Game Design and DirectX question

This topic is 6128 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Ok, let''s say I have a flying saucer that''s in local cordinates. I want to make it spin so I create a matrix that makes something rotate around the y axis using y is up. I make a matrix that trnsforms it to world space. And also make a matrix that makes it translate. I multiply the matrixes in left to right order in the same order I created them above. Do I understand the matrix thing correctly? If so... Now I apply the combined matrix to each vertex of the flying saucer? If so... Now it''s in world space, if I want to make it spin some more, like say everytime before I render it I want it to spin some more, then I have to put it back in local cordinates to make it spin around it''s local y axis and not the y axis of the world space. Seems a little awkward. I''m guessing I''m not understanding something. Also, to get to the DirectX part of it, I''m doing the DirectX tutorials and I see where I give directX a matrix to put it into world space, but in order to do collision detection I have to know where my own object is in world space. So is better to just transform the stuff my self and then give the vertxes to directX and somehow tell it that they all that''s left is to transform to the viewport??? I thought I understood the game design thing until I really got into directx. I don''t understand why directX deals with rotation matrixes, I figured it would just take my triangles and display them, and deal with the lights and stuff, I kinda thought all the matrix stuff would be of my own doing and be left to the physics engine. Thanks in advance for any help, comments, and critism.

Share on other sites
be careful with your order of applying the matrices. if you translate first, and then rotate, the saucer would orbit the y axis instead of rotating.

Share on other sites
I understand that, so once my saucer is in world space, and my game loop runs around again and I go to update my saucer, I have to spin it some more, but it''s in world space now so I can''t spin it!

Share on other sites
DirectX uses the world world, camera, view and projection
matrixes ''cause 3d hardware typically has a set of inline
multipliers. This allows you to plug in matrixes for each
step of the transformation from 3d to 2d. (This is called
the transformation pipeline) Its much faster than building
a composite matrix for every frame of your game since typically
every object you render is gonna have its own world matrix.
To change the world matrix you just plug the values for
your matrix into the pipeline and the hardware multiplies
everything in the right order.

Now as for your rotation and scaling remember that your object
(if you do it right) always stays in a local coord system.
When directx applies the transformation pipeline to each of
your vertices it doesn''t change your vertices. (and of course
you can turn the transformation pipeline off and do it yourself
look at the Flexible Vertex Format for info on how to do that)

So every frame of animation you just rebuild your world matrix
and plug it into the hardware. Just do the same thing you did
to render your object in the last frame.

Share on other sites
That''s reasonable, but how do I do collision detection if my objects are all in their own local coords?

I''m not trying to be difficult, I just want to have a clear idea of what I''m working towards before I dive to deep into the technicalities.

Thanks to both of you for your replies so far.

Share on other sites
I have on my web site the source code of my little game, StarShooter. Take a look at the CShip class first. You should get answers to most of your questions, matrixes, translations, rotations, and collisions.

http://www.lafaqmfc.com/starshooter.htm

the version posted there is a little old, has major memory leaks and a slew of bugs, but the 3D math is right.

Laurent

Share on other sites
quote:
Original post by Anonymous Poster
I have on my web site the source code of my little game, StarShooter. Take a look at the CShip class first. You should get answers to most of your questions, matrixes, translations, rotations, and collisions.

http://www.lafaqmfc.com/starshooter.htm

the version posted there is a little old, has major memory leaks and a slew of bugs, but the 3D math is right.

Laurent

Would you mind if you post an explanation of how your code work? I mean, your offer to help is great but some people may not have enough time to sift through your code.

Share on other sites
that''s a little to much for me to take in, I''m still playing with triangles and stuff. I''m just trying to grasp the concepts.

Share on other sites
every frame your gonna build your objects world matrix.
You''re gonna want to keep a copy of this matrix stored
with the object. (Not only for collision detection but
say your doing a flock of birds you''ll want all the
birds to fly around 1 object. To accomplish this you
just combine each objects world matrix with the world
matrix for the object you want it to follow...ie you
always want to keep the objects world matrix around)

Anyways, say you want to do collision detection by
way of bounding boxes. (Eight points that form a box
around your object) Well to do collision detection
you just multiply all those points by the world matrix
for your object. (You''ll probably want to keep 2 sets
of points, one local coords, and 2 transformed coords)
and then compare it to all the other objects bounding
boxes (after you do the same to them)

Thats a quick and dirty way but there are probably more
efficient ways to do it.

Share on other sites
cool, that sounds good to me, thanks everyone for your help, it''s clear now, until I try to actually try to implement the concepts on my own

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 14
• Forum Statistics

• Total Topics
633322
• Total Posts
3011360
• Who's Online (See full list)

There are no registered users currently online

×

Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!