Jump to content
  • Advertisement

Archived

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

Sphet

HOW: Managing Objects in 3D

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I''m finally trying to move from all 2D programming to 3D programming. I''m currently using Direct3D with all of the helper libraries. This seems like a sensible step since I just want to become familiar with 3D concepts. My question is this: In my world I have a number of objects. They can be oriented in a variety of ways, but they are all instances of the same object. Obviously I have the object vertice list, and for every instance of the object I point to the same vertice list. The vertices are centered around the origin. If I want to move an instance of that object from the origin, I create a translation matrix and modify the vertices. Of course I have to modify a copy of the source vertices. I was wondering if someone could just run through the basics of how this information is organized and managed. Specifically: 1. What information is stored in the original object? 2. What information is stored in the instance of an object? 3. When is the transformation performed, every frame? 4. Are the transformed vertices saved or deleted each frame? 5. Is the transformation matrix saved? Any other points that may be important would be appreciated as this is my first stab at all of this. Sphet

Share this post


Link to post
Share on other sites
Advertisement
You can start like this:
"original objects" hold vertex and index data, as you wrote. Instances just point to them.

Instances have their transformation matrices (one for each seperately controllable object component, e.g. one for a simple plane, 2 or 3 for a plane with flaps etc.)

The transformation is performed in every frame, you apply the matrices (in correct order) to your vertices, this will transform from model space to world space. So what your engine has to call is a kind of Animate() and then Render() function of all your objects. Note that your moving objects have model space vertices ("untransformed") while your static ground data can right be stored transformed.

Sophisticated engines extent this concept in various ways, e.g. they collect all primitives to be rendered from ground and all models and sort them by material to minimize render state changes etc. rather than rendering each object seperately. I would suggest not to think that complicated at the beginning, just make your engine in a simple form and extent it step-wise.

Other things your objects should know are how to animate themselves (physics), how to sound, and helper data for e.g. collision detection (sphere or bounding boxes).

There are two main aspects that you have to solve when a basic engine is running: firstly to render just the things that are visible (keywords octree, quadtree, BSP etc) that has great impact on how to arrange your data structures, and secondly collision detection.

My advice is to keep things simple at the beginning and come back to them when you have some experience with the 3D stuff.

There some good books around to start, as well as good links to complete source code and helpful class libraries (e.g. glvelocity).

- thomas

Share this post


Link to post
Share on other sites
Renus,

Thank you for your reply.

These are some good points and I will start thinking about the sorting and object occlusion soon. I think I can get it sorted out.

A question that I've come up with now, is that Direct 3D has a function to set the world matrix. The documentation suggests I don't call this too often since it resets a bunch of values internally. Does that mean I should be transforming my vertices MYSELF instead of just building a world matrix and setting that within D3D?

Edited by - Sphet on September 7, 2001 5:13:58 PM

Share this post


Link to post
Share on other sites
No, you should use it! It is not expensive at all. Roughly estimated you will call it once before ground rendering and depending on your engine before rendering each model. T&L optimized engines call it much more often since they render material-wise and hence need to tell DX the world space matrix frequently. This is cheaper than doing some render state changes or vertex buffer reload etc.

- thomas

Share this post


Link to post
Share on other sites
I must correct my last statement: according to other posts one really should not set the world matrix too often. E.g. for particle engines that blow hundreds of single or double triangles at different positions it is recommended to transform the primitives on your own. Nevertheless for meshes it is ok to use the world matrix set since it occurs not as frequently as for particles.

Since I have no profiling by now I don''t know about the set world matrix delay, would be interesting to know the overhead and any dependencies to the underlying hardware.

- thomas

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

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!