Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

trianglelist from mesh

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 zeppeldep   Members   

104
Like
0Likes
Like

Posted 19 May 2013 - 05:52 AM

There is probably reference to code to do this action already, please point me in the right direction

 

I am trying to draw triangles from a mesh in directx x file

The directx x file is exported from blender .. I have not taken care of the mirrored part yet

 

the code I am trying (very badly put together by me) only draws every other triangle, what have I missed?

I am using .. C#, sharpdx and assimp net

 

ASI.Scene model = importer.ImportFile(fileName,
ASI.PostProcessPreset.TargetRealTimeMaximumQuality);

var vertices = new VertexBuffer(device, 
Utilities.SizeOf() * 2 * model.Meshes[0].VertexCount, Usage.WriteOnly,
VertexFormat.None, Pool.Managed);

Vector4[] VSet = new Vector4[model.Meshes[0].VertexCount * 2];

foreach (ASI.Mesh AMesh in model.Meshes)
{
 int i2 = -1;
 for(int i1 = 0; i1 < AMesh.VertexCount * 2; i1++)
 {
    i2++;
    VSet[i1] = new Vector4(AMesh.Vertices[i2][0], AMesh.Vertices[i2][1], AMesh.Vertices[ i2][2], 1.0f);
    i1++;
    VSet[i1] = new Vector4(AMesh.Normals[i2][0], AMesh.Normals[i2][1], AMesh.Normals[i2] [2], 1.0f);
 }
break;
}
vertices.Lock(0, 0, LockFlags.None).WriteRange(VSet); 

 

then draw with:

 

device.DrawPrimitives(PrimitiveType.TriangleList, 0, model.Meshes[0].VertexCount / 3);

 

 

Attached Files



#2 unbird   Members   

8307
Like
0Likes
Like

Posted 19 May 2013 - 06:18 AM

That mesh has quads. Use Assimp.PostProcessSteps.Triangulate.

 

Edit: Hmmm, that preset does include the triangulate flag already. I think you should iterate over the faces, not the vertices directly. Even better: use an index buffer and DrawIndexedPrimitive.


Edited by unbird, 19 May 2013 - 06:53 AM.


#3 zeppeldep   Members   

104
Like
0Likes
Like

Posted 21 May 2013 - 09:05 AM

oops! sorry now I see .. I am just throwing the vertices at the renderer without providing a the usage of each vertex in the faces .. doh!

*blush*

Thx unbird ... thx for putting me back on track and not calling me stooopid ...



#4 unbird   Members   

8307
Like
0Likes
Like

Posted 21 May 2013 - 10:30 AM

laugh.png. Well that would violate both netiquette and forum rules. I also don't think there are stupid questions per se: We all started "from zero" somewhere you know. One can ask stupidly though - or lazily.

Also: My own experience with assimp is no more than a couple of weeks, so I might well miss something here. I recommend playing around with the assimp_view.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.