ogre-next crrate entity from ManualObject

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
User avatar
jordiperezarti
Kobold
Posts: 32
Joined: Sun Sep 01, 2024 7:50 pm

ogre-next crrate entity from ManualObject

Post by jordiperezarti »

I am creating a floor plane:

Ogre::ManualObject* man = this->sceneManager->createManualObject();
man->begin("Examples/floor");
....
man->end();

Code: Select all

v1::MeshPtr planeMeshPtr = man->convertToMesh("floor_meshptr");
v1::Entity *planeEntity = sceneManager->createEntity(planeMeshPtr);

planeEntity->getMesh()->buildTangentVectors();
this->sceneManager->getRootSceneNode()->createChildSceneNode()->attachObject(planeEntity);

When compiling fails, appears some errors in the OgreSharedPtr.h

Someone has tried this before?

rpgplayerrobin
Gnoll
Posts: 676
Joined: Wed Mar 18, 2009 3:03 am
x 379

Re: ogre-next crrate entity from ManualObject

Post by rpgplayerrobin »

It can be a number of different things that can cause this I think.

You must supply your full code in order to know for sure though, but if you do not supply to manual object what is needed to calculate tangents, it is impossible to do the calculations, which may make it crash even (last time I checked).

I think you need position, UV and normal per vertex in order to be able to generate tangents.
If you have all those 3 per vertex and it still fails, try to also add a Vector3::ZERO for tangents per vertex as well, as creating them later might just replace the ones you added.

But I would suggest you to build Ogre from source in order to be able to debug these kind of crashes, because in that case it would most likely show what caused it to crash in more detail.

User avatar
jordiperezarti
Kobold
Posts: 32
Joined: Sun Sep 01, 2024 7:50 pm

Re: ogre-next crrate entity from ManualObject

Post by jordiperezarti »

Ogre::ManualObject* man = this->sceneManager->createManualObject();
man->begin("Examples/floor");

Code: Select all

man->position(-200, 0, 200);
man->normal(0, 1, 0);
man->textureCoord(0, 0);

man->position(-200, 0, -200);
man->normal(0, 1, 0);
man->textureCoord(0, 1);

man->position(200, 0, -200);
man->normal(0, 1, 0);
man->textureCoord(1, 1);

man->position(200, 0, 200);
man->normal(0, 1, 0);
man->textureCoord(1, 0);

man->quad(0, 1, 2, 3);
man->end();
man->setCastShadows(false);

MeshPtr     planeMeshPtr = man->convertToMesh("floor_meshptr");

v1::MeshPtr v1PlaneMeshPtr;
v1PlaneMeshPtr->importV2(planeMeshPtr.get());

v1::Entity *planeEntity = sceneManager->createEntity(v1PlaneMeshPtr);

Seems that i need to convert from Mesh to v1:Mesh,
here is crashing at:

Code: Select all

v1PlaneMeshPtr->importV2(planeMeshPtr.get());

because the pointer is not allocated yet.
But how do i allocate the v1PlaneMeshPtr? which is the constructor or how i get a new instance?