*
Login | forgot password | register | register with OpenID Click here to register with OpenID
X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

(what is OpenID?)

Forums

45 Posts in 15 Topics by 16 members

Jump to:

General Discussion

If this is your first visit, you will need to register before you can post. However, you can browse all messages below.

Imaginary Game Engine » Forums » General Discussion » Correct way of setting arrays for triangle mesh
Page: 1 go to end Reply
Author Topic: Correct way of setting arrays for triangle mesh 461 views
  • CyberVillain
    CyberVillain's avatar
    Community Member
    2 posts

    Correct way of setting arrays for triangle mesh

    Hi.
    I've written a parser for .x directx files that will create a NxVec3 array of vertices and a uint32 array size of (x, 3) of indicies.

    But the properties only takes pointers, whats the correct way of settings these two properties?

    Best Regards, Anders

  • CyberVillain
    CyberVillain's avatar
    Community Member
    2 posts

    Re: Correct way of setting arrays for triangle mesh

    This is my code, coocked returns false, and it crashes on last line

     
    NxTriangleMesh mesh = sdk.createTriangleMesh(stream);
     
    private NxActor CreateActorFromFile(string filename)
    {
    MeshManager meshManager = new MeshManager();
    NxActor actor = null;
    NxVec3[] vertices;
    int[,] indices;
     
    meshManager.GetMesh(filename, out vertices, out indices);
     
    // create stream
    NxStream stream = new NxStream();
    NxTriangleMeshDesc meshDesc = new NxTriangleMeshDesc();
    // go unsafe
    unsafe
    {
    // fix pointers
    fixed (int* pIndices = indices)
    fixed (NxVec3* pVertices = vertices)
    {
    // assign pointers
    meshDesc.triangles = new IntPtr((void*)pIndices);
    meshDesc.points = new IntPtr((void*)pVertices);
     
    meshDesc.pointStrideBytes = (uint)sizeof(NxVec3);
     
    meshDesc.numVertices = (uint)vertices.Length;
    meshDesc.numTriangles = (uint)indices.Length / 3;
    meshDesc.triangleStrideBytes = 3 * sizeof(int);
    meshDesc.flags = 0;
    meshDesc.heightFieldVerticalAxis = NxHeightFieldAxis.NX_Z;
    meshDesc.heightFieldVerticalExtent = -1000.0f;
     
    // create mesh
    NxCookingInterface cooking = PhysXLoader.NxGetCookingLib(PhysXLoader.NX_PHYSICS_SDK_VERSION);
    bool cooked = cooking.NxCookTriangleMesh(meshDesc, stream);
    }
    }
     
    NxTriangleMesh mesh = sdk.createTriangleMesh(stream);
     
     
     
    return actor;
    }
     

    Last edited: 1 February 2009 at 9:21pm

  • SeaEagle1
    SeaEagle1's avatar
    Administrator
    16 posts

    Re: Correct way of setting arrays for triangle mesh

    I haven't done much with mesh cooking myself so far, but a few things I can come up with are:

    • Do you initialise the cooking sdk?
    • What does meshDesc.isValid() return?
    • NxStream is, afaik, just an abstract class which need an implementation.

    Last edited: 1 February 2009 at 9:39pm

    461 views
go to top Reply

Currently Online:

There is nobody online.

Welcome to our latest member: jfreie