Jump to content


(DirextX) Retrieving faces from Mesh.FromFile object


1 reply to this topic

#1 sune

    New Member

  • Members
  • Pip
  • 2 posts

Posted 15 December 2005 - 11:06 AM

Hi,

I´m using the Mesh class in my application, since it affords me some nice features at no cost :)
However i need to do some calculations on the vertices and therefore I need to pull them out of the Mesh object. I use simple Lock functions on the objects Index- and Vertexbuffer and using a for-loop I run through the indexbuffer using the values to take out vertices of vertexbuffer (3 indices per triangle). This straightforward method works splendidly on the standard Mesh.Box, Mesh.Sphere etc. but when I try to use it on a Mesh.FromFile object it fails. The vertices seem fine, but the indices are wrong. Anyone know why this is ? When I do my reading I assume that the only primitive in the buffer is Triangles, could that be my problem ?

#2 ikk

    Member

  • Members
  • PipPip
  • 87 posts

Posted 16 December 2005 - 01:53 PM

Where did u get Mesh.FromFile object-method?. afaik in Direct X mesh object doesnt have FromFile method.
while reading data from files, problem there may occur bcos structures/classes boundary in your code may be diffrent than in files u read from.
alligment is specified either by /Zp commandline switch or by #pragma pack preprocessor directive, ie.
#pragma pack(1) //causes boundary of structures to be 1 byte
in example above boundary is set to 1 byte, but if it'd be set to 4 then every structure
size is rounded up to 4 bytes.
therefore when reading data from file indexing may be incorrect.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users