Jump to content

[SOLVED] How to load mesh in ObjectMesh?


photo

Recommended Posts

I used static_cast<ObjectMesh*>(ObjectMesh::createNode(Node::OBJECT_MESH)) to create a ObjectMesh.

 

but I didn't found any function to load mesh,except the constructor: ObjectMesh::ObjectMesh(const char *name).

 

It is means if I used Node::createNode to create a Node,I can NOT use the constructor's param;

 

so,how to load mesh???

 

Thank you.

Link to comment

Use ObjectMesh constructor:

ObjectMesh *mesh = new ObjectMesh(name);

Node::createNode() function is used for world loading and deserializing only.

I don't recommend to use engine internal functions.

Link to comment

Use ObjectMesh constructor:

ObjectMesh *mesh = new ObjectMesh(name);

Node::createNode() function is used for world loading and deserializing only.

I don't recommend to use engine internal functions.

 

It will is take a new problem,I creating a game tool under Qt.

Unigine source overloaded "new" in global space, It's didn't work with Qt.

 

So I closed USE_MEMORY define.

 

so,If I use "new Object",I will take a memory problem.

 

If I use Node::createNode function,this problem is not exist.

 

many days ago,I found this solution in this formus.So,I learn to use Node::createNode.

Link to comment

Try in-place new constructor:

void *ptr = Memory::allocate(sizeof(ObjectMesh));
ObjectMesh *mesh = new(ptr) ObjectMesh(name);

And manual destructor:

mesh->~ObjectMesh();
Memory::deallocate(mesh);

Link to comment

Try in-place new constructor:

void *ptr = Memory::allocate(sizeof(ObjectMesh));
ObjectMesh *mesh = new(ptr) ObjectMesh(name);

And manual destructor:

mesh->~ObjectMesh();
Memory::deallocate(mesh);

Thank you very much,I will try it.

Link to comment
×
×
  • Create New...