Archived

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

initial_y

fill vertex buffer

Recommended Posts

I got the vertex data of a x file.As I know draw Triangle Strips are faster than Triangle Lists.But the vertex buffer''s data must use the correct order to arrange in term of direct3d''s rule.But data of x file didn''t the correct order and I can''t find the rule about it. I can only draw a mesh use Triangle Lists with the DrawPrimitive() method or have the better methods? goddess just one...

Share this post


Link to post
Share on other sites
don''t laugh at me...

Now I got the vertex data from an x file.What can I do next?

use DrawPrimitive() or DrawIndexedPrimitive() or just use DrawSubset() even the Procedural Shaders of my self?

goddess just one...

Share this post


Link to post
Share on other sites
It''s true that triangle strips are faster than triangle lists. But I think drawing 100 triangles in a list with one call is faster than issuing 10 calls to draw 10 triangles in strips.

DrawPrimitive supports all primitives from D3DPRIMITIVETYPE.

The way to go about repeating vertices is to use index buffers. You define each vertex only once, and then use indices to refer to it as much as you want. The advantage is that indices take only 2 or 4 bytes, depending on index buffer format. See SetIndices and DrawIndexedPrimitive in SDK help.

If you loaded X file using D3DXLoadMeshFromX, then you can call DrawDubset to draw it. Just remember to set materials and textures, if they are present in X file.

Or, you can use Get{Vertex|Index}Buffer functions to get those and use DrawIndexedPrimitive to draw them. But unless you are doing something with the vertices/indices, DrawSubset requires less code. If you want to draw the mesh yourself, you also must take care of attributes (see [Un]LockAttributeBuffer). No reason to make life complicated for yourself.

Share this post


Link to post
Share on other sites
I don''t want to use any of the D3DX sets and just want to use the D3D sets.So I load all data of x file myself.In fact I have not go in the knowledge of indexbuffer...It seems indexbuffer will help me much.
I also have another question about the DrawSubset() method and who can tell me how it work in deed?It draw a polygon base on trangle lists, strips or other method?

goddess just one...

Share this post


Link to post
Share on other sites
You should use D3DX... well I think so, because they contain optimized functions to do from simple to complicated tasks. If you know how and when to use it, you will only benefit from it.



/* Bullmax */
-------------
Reality has many forms : good and evil, black and white, ying and yang.

Share this post


Link to post
Share on other sites
DrawSubset uses triangle lists because they work on any data.

Is there any reason why you don''t want to use D3DX to load meshes for you?

Share this post


Link to post
Share on other sites
Because I want to control vertex buffer...
Working with skinned mesh is my cause. I can''t know the specific data format in the buffer if use D3DX I think.If I use D3DX then I don''t know the hierarchy of the file...

goddess just one...

Share this post


Link to post
Share on other sites
IndirectX: why are you so sure that drawsubset uses triangle lists??
i think it uses indexbuffer. At least there is a function(ID3DXBaseMesh::GetIndexBuffer) for getting a pointer to the index buffer, and a function to get the vertex buffer associated with it (ID3DXBaseMesh::GetVertexBuffer).
and if you look at the format of X files, you can notice that there is a list of indices for each object..

Share this post


Link to post
Share on other sites