fill vertex buffer

Started by
8 comments, last by initial_y 22 years, 1 month ago
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...
汇编语言不会编
Advertisement
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...
汇编语言不会编
How did you get the vertex data from the .x file? Did you use the ID3DXPMesh? And use D3DX to load it?

Cocyen
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.
---visit #directxdev on afternet <- not just for directx, despite the name
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...
汇编语言不会编
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.
/* Bullmax */-------------Reality has many forms : good and evil, black and white, yin and yang.
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?
---visit #directxdev on afternet <- not just for directx, despite the name
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...
汇编语言不会编
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..
Of course it uses index buffer, but it draws lists of triangles.
---visit #directxdev on afternet <- not just for directx, despite the name

This topic is closed to new replies.

Advertisement