Jump to content
  • Advertisement
Sign in to follow this  
nuclear123

More help with render class design

This topic is 2505 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

I have a question about my renderer class. I decided to store my primitives that i draw inside of a vector to be the container of primitives i create! My question is the following.

1.) How do i perform the updating of matrices for EACH primitive? Will i make the matrices needed and add them as members to my renderer class and update them before drawing of primitives?


2.) If i do above this leads to one problem. What if i have a primitive that is specified in object space instead of world space. How do i SPECIFICALLY alter/change how this object's matrices are updated vs all the other primitives in my list. I'm not sure how to handle this problem


this is the outline for my render class
Class Render
{
public:
createline()
createbox()
drawscene()

private:
vector lines;
vector points
vector boxes;

}

Share this post


Link to post
Share on other sites
Advertisement
primitives should always be specified in object space. You just use transformation matrices to describe their world space position, size, and orientation.

Are you saying that each primitive is it's own object? and has it's own world space matrix? Are you making a 3d modeling program? if you are, I wouldn't use matrices for each primitive. Instead, have an array of vertices (probably only need an array of 3d floats for the positions), and just change the vertex positions whenever you want to move them around. Then update your vertex buffer with the new vertex array.

Share this post


Link to post
Share on other sites

primitives should always be specified in object space. You just use transformation matrices to describe their world space position, size, and orientation.


Primitives are always in object space, but object space for a primitive can be the same as world space. If you have a large amount of static geometry compared to dynamic geometry, you can save a decent amount of time by not setting a few constants and not multiplying by the world matrix in the shader. You can also pre-process the geometry to massage it into the best size vertex / index buffers - combine a large amount of meshes with few vertices into one mesh to save on draw calls, or split up a large mesh into smaller meshes to be able to cull some of them.

2.) If i do above this leads to one problem. What if i have a primitive that is specified in object space instead of world space. How do i SPECIFICALLY alter/change how this object's matrices are updated vs all the other primitives in my list. I'm not sure how to handle this problem
[/quote]

Have a "scene" (whatever stores your objects) differentiate between static and dynamic geometry - or in this case geometry already in world space. This is really helpful for other stuff as well. The static geometry can be in a really optimized quadtree or whatever for culling, and you don't ever have to worry about having to change it as dynamic objects move around. Meanwhile the dynamic objects can be in something more like an ABT or if there are relatively few of them, you can just not frustum cull and submit all of them for drawing.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!