Recover a plane

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
joe70
Gnoblar
Posts: 9
Joined: Thu Apr 05, 2018 5:57 pm
x 1

Recover a plane

Post by joe70 »

Hi, friends. I'm trying to recover a plane create with the next code

Code: Select all

Plane plane1(Vector3::UNIT_Y, 0);
MeshManager::getSingleton().createPlane("plane1",
	ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane1,
	200,200,1,1,true,1,10,10,Vector3::UNIT_Z);

SceneNode* node3 = _sceneManager->createSceneNode("ground");
Entity* groundEnt = _sceneManager->createEntity("planeEnt", "plane1");
I've recovered the entity using _scm (sceneManager)

Code: Select all

 
 SceneNode* _nodeplane = _scm->getSceneNode("ground");
  _planent = static_cast <Entity *> (_nodeplane->getAttachedObject("planeEnt"));
 
I'm looking for the plane with ChildObjectListIterator and ChildObjectList, also I've tryed

Code: Select all

_camera2->enableReflection(static_cast <Plane &>(_planent->getMovableType()()));
_camera2->enableCustomNearClipPlane(static_cast <Plane &>(_planent->getMesh()));
How you can see, i'm trying to do a mirror effect. I need the plane for get it.

Can you help me?

Thanks
User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 449
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 156

Re: Recover a plane

Post by sercero »

Hello, they are diffrent kind of planes
joe70 wrote: Wed Jul 08, 2020 9:18 pm

Code: Select all

Plane plane1(Vector3::UNIT_Y, 0);
MeshManager::getSingleton().createPlane("plane1",
	ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane1,
	200,200,1,1,true,1,10,10,Vector3::UNIT_Z);
That plane is a mesh created by the mesh manager to use in an entity.
https://ogrecave.github.io/ogre/api/lat ... nager.html
https://ogrecave.github.io/ogre/api/lat ... ntity.html
_camera2->enableReflection(static_cast <Plane &>(_planent->getMovableType()()));
_camera2->enableCustomNearClipPlane(static_cast <Plane &>(_planent->getMesh()));
[/code]
The plane you need here is a plane of a different kind, see here:
https://ogrecave.github.io/ogre/api/lat ... ustum.html
https://ogrecave.github.io/ogre/api/lat ... plane.html

If you need these planes to have the same characteristics I think hat you will have to save the parameters somewhere, perhaps you should create an abstract plane and use that as a parameter for the mesh.
joe70
Gnoblar
Posts: 9
Joined: Thu Apr 05, 2018 5:57 pm
x 1

Re: Recover a plane

Post by joe70 »

Thanks for the reply, sercero, but I need to recover "plane1". i haven't explained clearly the question, i think

First I've created a graph scene
SceneNode* node3 = _sceneManager->createSceneNode("ground");
Entity* groundEnt = _sceneManager->createEntity("planeEnt", "plane1");
node3->attachObject(groundEnt);
_sceneManager->getRootSceneNode()->addChild(node3);
Also, I call to MyFrameListener function sending _sceneManager

Code: Select all

_framelistener = new MyFrameListener(window, _sceneManager, _overlayManager);
MyFramelistener summarized declaration

Code: Select all

class MyFrameListener : public FrameListener {
private:
   SceneManager* _scm;
  SceneNode* _node;
  SceneNode* _nodeplane;
  Entity* _planent;
  int nmat;

public:
  MyFrameListener(RenderWindow* win, SceneManager* scm, OverlayManager* om);
  ~MyFrameListener();
  bool frameStarted(const FrameEvent& evt);  
};
MyFrameListener Constructor

Code: Select all

MyFrameListener::MyFrameListener(Ogre::RenderWindow* win, 
				 Ogre::SceneManager* scm,
				 Ogre::OverlayManager *om) {
....  
 _scm=scm; _overlayManager = om;
  nmat = 1;  // Inicialmente utilizamos el material 1
....

  _nodeplane = _scm->getSceneNode("ground");
  _planent = static_cast <Entity *> (_nodeplane->getAttachedObject("planeEnt"));
}
I've recoverded the nodescene and the entity (_nodeplane and _planent), now The answer is How can I recover "plane1" like an plane object from _planent?

Thanks again,
User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 449
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 156

Re: Recover a plane

Post by sercero »

Hello,

It was clear what you were saying, now I understand.

I don't think that you can recover that plane (plane1), because it is being used as a parameter to create a plane mesh.

It is very unlikely that the parameter is being saved somewhere.

If you can't or wont create a global variable to save the plane, then you have another alternative which is to use the UserObjectBindings::setUserAny() function.

This function would allow you to save the plane as a user object whitin the entity or the scene node.

I can only point you to the API, since I have not used this feature yet, but I stumbled upon it recently and I am planning to use it in the future.
https://www.ogre3d.org/docs/api/1.8/cla ... ings.html

From my understanding you would have to use it like this:

Code: Select all

Plane* plane1 = new Plane(Vector3::UNIT_Y, 0);
...
Entity* groundEnt = _sceneManager->createEntity("planeEnt", "plane1");
groundEnt->setUserAny(plane1);
And then, later in the code:

Code: Select all

 _planent = static_cast <Entity*> (_nodeplane->getAttachedObject("planeEnt"));
Plane* plane1 = static_cast <Plane*> (_planent->getUserAny();
I had to modify your code so that now the plane is not an automatic variable.

Now the problem is that since the object now resides in the heap you have to delete it.

I don't know of any managers that give you planes, so you have to take care of the object lifecycle.
joe70
Gnoblar
Posts: 9
Joined: Thu Apr 05, 2018 5:57 pm
x 1

Re: Recover a plane

Post by joe70 »

Thanks Sercero, you solve my problem. Thank you very much.
Post Reply