Jump to content

[SOLVED] Search ObjectMesh in scene


photo

Recommended Posts

Posted

Hi all,

 

I need build a widget windows to search target ObjectMesh and highlight it in scene,

 

I referenced at sample selection_00:

 

------------------------

 

 

 

void update_scene() {

 

Object object = NULL;

 

while(1) {

 

Vec3 p0,p1;

Unigine::getPlayerMouseDirection(p0,p1);

 

int ret[0];

Object o = engine.world.getIntersection(p0,p1,~0,ret);

 

---------------------

 

 

I need a sample how to set data to specific ObjectMesh instead of getPlayerMouseDirection. Because my code doesn't work....

 

Anyone has any suggestion?

 

Thanks a lot...

Posted

Your code don't work because you use while without wait, you can remove while and put this into update function it will ba called on every frame.

Posted

Your code seems incomplete with an unclosed while loop, so I would drop that. To access ObjectMesh specific functions use;

 

Vec3 p0,p1;
Unigine::getPlayerMouseDirection(p0,p1);
int ret[0];
Object o = engine.world.getIntersection(p0,p1,~0,ret);
if(o != NULL)
{
if(o.getType() == NODE_OBJECT_MESH)
{
   	ObjectMesh objM = node_cast(o);
   	//Do something with objM
}
}

Posted

Ohhh, I just paste part of code first 6 lines from sample code lib for explain.

 

Issue has been solved by using getNode().

 

Thanks all.

×
×
  • Create New...