Jump to content
  • Advertisement

Archived

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

Nodger

Some Newbie questions

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

Since I am a newbie, I would to pick the brains of you guys a bit on questions regarding DirectX, here goes: 1. What is an index buffer? 2. If I want to make a cube using triangle strips, I will need 3 strips? right? 3. Can pixel shaders be used to "darken" part of a specific triangle? is this easy? 4. Can vertices be translated while in the vertex buffer? 5. For instance, if I have 2 meshes in the vertex buffer, and I want to move them closer to each other, can I do this without touching the vertex buffer? sorry if these questions are a little vague, but Im just trying to get a general "feel" as to how this whole 3D thing works. I probably should stop, My doctor says I have the wrists of an 80-year old

Share this post


Link to post
Share on other sites
Advertisement
1) An index buffer will attatch indices to your vertex buffer. Example: say you want to render a quad (square). Without an index buffer, you have to define six vertices (forget the fact you could also use a triangle strip/list):
v1 v4-v5
| \ \ |
v3-v2 v6
With an index buffer, you would only need to define the unique vertices:
v1-v2
| \ |
v3-v4
You would fill the index buffer with:
1, 2, 4, 1, 4, 3
ie, 1,2,4 are the vertices of the first triangle, 1,4,3 are the vertices of the second triangle.

2) I wouldn''t try making a cube out of triangle strips. Just use a vertex buffer with the 8 unique vertices and then an index buffer (similar to the example above).

3) I don''t know much about pixel shaders and vertex shaders cause they don''t seem to like me.

4) Yes. You do something like this:
D3DXMATRIX World;
D3DXMatrixTransformY(&World, 45.0f);
device->SetTransform(D3DTS_WORLD, &World);
//render vertices

to rotate a mesh/model 45 degrees. There are other functions for translating, rotating, and scaling (see SDK)

5) I wouldn''t recommend putting two different meshes into one vertex buffer. I would make two different vertex buffers and transform each individually.

Share this post


Link to post
Share on other sites
ok so what you are saying is you can have a few different vertex buffers? like one for every object on the screen? this seems to be getting more confusing.

Share this post


Link to post
Share on other sites
quote:
Original post by langguy
5) I wouldn't recommend putting two different meshes into one vertex buffer. I would make two different vertex buffers and transform each individually.
You can do this and quite easily. If you know the beginning of the mesh's vertices in the array you can set the index buffer offset to that and render as many vertices as the object has.

[edited by - Raloth on August 17, 2003 5:39:56 PM]

Share this post


Link to post
Share on other sites
1. answered already

2. no only one strip, generaly each object will have it''s own vertex buffer, (or mesh) and only one per object.

3. duno, havn''t goten into shadows yet, you can darken part of an object by giving it no light though, (if you enable lighting)

4. use the world transform, you setup the world transform to say where, what angle, and what size an object is. generaly each object will have it''s own world transform

5. see 2 & 4 don''t put 2 meshs in a vertex buffer if your useing a mesh DirectX handels the vertices for you, see the mesh tutorial.

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!