Jump to content
  • Advertisement

Archived

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

NeoInferno

Vertex Buffer...

This topic is 5793 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 read some D3D Tutorials,where a vertex buffer is used.There the vertices of one cube are stored in the vertex buffer,then the stream source is set and so on... If i render more than one cube,for example a more complex 3D Scene,have i to use more vertext buffer,or have i to store all of my vertices used in this one vertex buffer? greez,Neo (Please use simple english,i am just a silly german *g*)

Share this post


Link to post
Share on other sites
Advertisement
You can use several buffers as well as use one.
If your cubes are static you can put them into one buffer, set their World Matrix and then call drawprim for every cube.
You could as well have only one cube in the buffer that is transformed and rendered.

Share this post


Link to post
Share on other sites
How many vertices or cubes or whatever can i store into one vertex buffer?
I want wo make a small 3D Engine with Visual Basic...
I think i''ll make one vertex buffer for each kind of geometry (cube,sphere,...).Then I make for each of them arrays...
Would that work?

Share this post


Link to post
Share on other sites
You should try to have as few VBs as possible. You can put all your geometry into one VB if you want, and set the world matrix according to where the object should be drawn.

Steve
DirectX Programmer
Soon to be the new Bill Gates

Share this post


Link to post
Share on other sites
Does one matrix only change the position of ONE geometric figure?Need i to set each matrix new,after one thing is drawn?
...i hope i''ll learn that as soon as possible

Share this post


Link to post
Share on other sites
Yes, you set up the VB once.
A VB defines an object with its own coordinates, usually around (0,0,0) It's then transformed to world coordinates with a world matrix. You can draw the same VB many times.

Fill the VB in the initialization function.
Then when drawing you set up the projection and viewpoint matrices.
Then in a loop, you set the world matrix, draw it, set the world matrix to something else, draw again, etc.
Then you will have different cubes on the screen.




[edited by - Fidelio_ on September 1, 2002 6:24:29 AM]

Share this post


Link to post
Share on other sites
Ok thanks
But another problem:
I wanted to draw a simple plain..i used 4 vertices and triangletrip @DrawPrimitive.
But only a triangle was drawn...whats wrong there?Probably i have the wrong "Primitive Count" @DrawPrimitive.Whats this PrimitiveCount? The Number of the vertices,the triangles or what else?
Or i use wrong coordinates.How does the coordinate-system in D3D look like?

1
^
|
|
|
0---->1

Or:

0----->1
|
|
|
1

Thanks 4 answer

Share this post


Link to post
Share on other sites
A trianglestrip has the problem that the first triangle is clockwise, but the second one is counterclockwise. If you don''t specify a normal it is facing away from the camera and not drawn. And yes I think you should specify 2 as the last parameter. Try it with a triangle list and 6 points.

You can have several vertex buffers, but it''s best if there are as many as possible triangles in one buffer. But if you use an object a few times, put that in a vertex buffer.

Share this post


Link to post
Share on other sites
Yes thank u very much
And whats the coordinate system like?Is the Point (0;0) Up/Left or Down/Left...i am not sure about that.
...its a pitty that all good forums and tutorials are in english.For me as a german its often not easy to understand

Share this post


Link to post
Share on other sites
quote:
...its a pitty that all good forums and tutorials are in english.For me as a german its often not easy to understand


Ummm, I don''t remeber the site, but I know that there is a site which has dx8 tutorials in german, actually I''ve already found a few of them, although I don''t know if they are any good ...

How big can you VBuffer be? Well, that you must specify when you create your vertex buffer. So if you want you can make a big vertex buffer or a collection of vertex buffers (although I wouldn''t recommend creating too many, by too many I mean several dozen or a few hundred, as every time you switch vertex buffer there is a small overhead while the card/dx changes it''s source and that might cut a bit down on your speed if you''re changing between 50 buffers every frame). A good rule would be to make enough buffers for your different types of FVF and then for each FVF you''d distinguish between geometry that you have to load every frame and geometry you only need to load once in the game (normally most geometry is of this type, one model which is then altered with the world matrix, trees, cars, buildings, etc) and make a different buffer for both types, ofcourse if you fell like it you can make more buffers. Then you''d have all your objects defined by a struct which keeps the world transformation matrix, start index (if your also using an index buffer) or start vert and the number of tris that defines your geometry. The main reason to keep a buffer with static geometry is to avoid loading the geometry every frame, when you actually don''t need to as it doesn''t change over many frames, if it even changes.

From here on, when you start rendering, for every object, you change the world matrix and render the relevant tris.

quote:
Does one matrix only change the position of ONE geometric figure?Need i to set each matrix new,after one thing is drawn?


Umm, the matrix transformation is applied to all the verts that are called by drawprimitive, transforming all of them to a new space... basically all this tech talk just means that it''s picking up the verts which you defined on one (central) (zyz)axis and moves them to another (xyz)axis. Think of a translation, all the verts where on some axis, using a cube the coordinates will be something like (1,1,1),(1,-1,1),(-1,1,1),(-1,-1,1),(1,1,-1) and so on, when you apply the translation all the verts are moved in some direction and now their coordinates are now specified on a different axis (if we move it with this vector(1,0,0) we get these coordinates (2,1,1),(2,-1,1),(0,1,1),(0,-1,1),(2,1,-1) ) it''s exactly the same geometry just on a different axis with which it has only different coordinates (maybe the best way to think of it is to totally distinguish all axises and when you apply a transformation, all that your doing is making a copy that geometry to a certain spot on another space difined by a different axis, trust me, with an image this is self-expalanatory with words it''s a bit harder...). A rotation uses exactly the same principal, but in this case the axis vectors are being rotated, so it is harder to visualize and understand without an image.

So for sometinh like a forest, all you do is set a world matrix for one of the trees, render the tree (sending all the relevant tris to DX8 with drawprimitve), change the world matrix for another tree, , render the tree (sending all the relevant tris to DX8 with drawprimitve), change the world matrix for another tree,, render the tree (sending all the relevant tris to DX8 with drawprimitve), change the world matrix for another tree...
So it severly simplifies work, as you can reuse the same geometry over and over and all you need to do is change a matrix. Another big advantage is that you don''t need to create all the geometry for every spot in space (for a scene with 5 to 10 cubes floating around you don''t need to make each one, you just make one and render it 5 to 10 times).

As for the direction, I''m not sure, my recomendation, try it out and if it''s wrong just switch it around.
If your not seeing tris, then try switch off backface culling (it''s one of the renderstates), if all your tris are now visible now then you need to fix your vertex order to satisfy one of the winding orders.

Oh and primitive count is how many tris you want to render, don''t use the number verts you want to render (as this value should be higher then number of tris to be rendered) or you''ll get one of those interesting DX8 errors...

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!