Jump to content
  • Advertisement


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


Figuring out depth buffers...

This topic is 6019 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 all, I am learning DirectX programming after years spent in 3D effects and simulations. At a certain point you just have to know how it all works under the hood. The problem is that curiosity always leads to more questions. So here it is: If I define one cube object (or any other model for that matter)can I then re-use that object many times in a scene? For instance: let''s say that I want the cube to represent cars on a road. Can each vehicle reference the same cube and transform it as needed and then render it to the target and depth buffer surfaces without problems? It looks like it''s possible from what I''ve read in the reference material so far. Is this an idea that is worth pursuing? Are there any good examples out there if it is in fact a valid way of approaching multi-object scenes? Thanks 3CM

Share this post

Link to post
Share on other sites
If you''re using object oriented programming, you can create a class. One of the would contain a display model function that referenced the cube,car,dragon or whatever, and any associate animations. Then within your main program you simply create instances of that object.

class car
// your constructors/destructors

int displayModel();
void setLocation(int , int, int);
int get_coordinate_X();
int get_coordinate_Y();
int get_coordinate_Z();
// your object''s location

float locationx;
float locationy;
float locationz;

// create instances

car mustang;
car corvette;

// Display Models


Anyway, the above is a ROUGH representation of reusing the same "model" in multiple objects.

Hope it helps.

"Why must we always come up with incredibly philosophic signatures?"

Share this post

Link to post
Share on other sites
I compare it to that Return of the Jedi scene with all the TIE Fighters flying behind the Millenium Falcon towards the Death Star. They are all the same TIE Fighter model. It is done this way, naturally, to reduce the amount of work needed to create the models before they can film them in front of a bluescreen and then add them to the scene.

3D rendering works the same way. You can have 1000 cubes in your scene, but use the exact same model to render each of them, translating and rotating to a different location each time. Once rendered, the API doesn't need the data piped into it for drawing, so rotating and translating after a given render doesn't destroy what you've drawn before. You can reuse that same data as needed for all renderings. Good that it works that way, too. It would be a shame to have to generate 1000 models of cubes in memory.

In my own designs, I would create a cube model and contain it in an object. In the linked list that houses my game objects, each would have a reference the cube model object for purposes of rendering. Each node in the linked list also has a position and orientation that I would use to transform to the correct place before I render the model referenced.

[edited by - Waverider on June 25, 2002 1:21:19 PM]

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!