Horde3D
http://horde3d.org/forums/

problem using h3dGetCastRayResult
http://horde3d.org/forums/viewtopic.php?f=2&t=1691
Page 1 of 1

Author:  imranhabib [ 06.07.2012, 17:35 ]
Post subject:  problem using h3dGetCastRayResult

Hello I was stuck on this problem last year and left it because i couldn't proceed.
And now again i am supposed to continue with the same problem.

If I describe my problem in simple words it would be that. i am using

Code:
h3dGetCastRayResult(i, &Intersection_Node, &distance, &intersection))

I am returned with handle of the object in the variable "Intersection_Node" now i want to use this handle for calculating the transformation of the object [e.g wall] using this variable [i.e. Intersection_Node] but the code gives me exception.. I use following function for calculating transformation
Code:
GameEngine::getEntityTransformation(Intersection_Node);

If I use handle to an object obtained by another way and use it in the function. GameEngine::getEntityTransformation(handle) then it calculates me the transformation and it works properly but I have problem calculating the transformation only when I am using the handle obtained through the function h3dGetCastRayResult().
I want to use this h3dGetCastRayResult() function to get the 10 objects close to me in a range and then by this function GameEngine::getEntityTransformation(Intersection_Node); i want to calculate transformation of thos objects through their handles [i.e Intersection_Node].
I have no luck with it and now I want to solve it some how I will appreciate any one's solution.

Thank you

Author:  Irdis [ 06.07.2012, 18:44 ]
Post subject:  Re: problem using h3dGetCastRayResult

Hello imran.
I do not use the gameengine, but it seems that you are trying to use handles, obtained from horde, in gameengine. This will not work because gameengine uses its own handles for entities.

Here is some pseudo code that might help you solve the problem:
Code:

...

GameEntity someGameEngineEntity = getValidEntityFromSomewhere();

H3DNode hordeNode = someGameEngineEntity.entitySceneGraphID();

int numberOfCollisions = h3dCastRay( hordeNode, ..., ..., ...);

H3DNode Intersection_Node = 0;
float distance = 0; float intersection = 0;

for ( unsigned int i = 0; i < numberOfCollisions; ++i )
{
      bool res =  h3dGetCastRayResult(i, &Intersection_Node, &distance, &intersection));
      if ( res )
      {
            unsigned int gameEngineEntity = GameEngine::sceneGraphEntityID( Intersection_Node );
           
            float *nodeTransform = GameEngine::getEntityTransformation( gameEngineEntity );
      }
}



Should be something like that...

Author:  imranhabib [ 16.07.2012, 04:10 ]
Post subject:  Re: problem using h3dGetCastRayResult

Irdis wrote:
Hello imran.
I do not use the gameengine, but it seems that you are trying to use handles, obtained from horde, in gameengine. This will not work because gameengine uses its own handles for entities.

Here is some pseudo code that might help you solve the problem:....
....
Should be something like that...


Hello Irdis Thanks for replying and i am sorry that i am writing this late.i saw ur message earlier but i got my official computer on friday
so had to fix it first and today when i used the function that you suggested me i.e
Code:
unsigned int gameEngineEntity = GameEngine::sceneGraphEntityID(Intersection_Node);

then i came accross the following problem.

if i only print the value "gameEngineEntity" then i m getting 0 as printed in the value.
i am getting correct hordeIds in Intersection Node and even if I print Intersection_Node .... I get specific ID .. which is correct

why it converts the Intersection_Node to
"gameEngineEntity" as 0 (zero)

can you suggest something?

Author:  Volker [ 16.07.2012, 05:58 ]
Post subject:  Re: problem using h3dGetCastRayResult

I guess that the entity is bound to the model while the h3dGetCastRayResult returns an ID of a mesh being a child of this model. So maybe you have to get the model of the mesh returned by h3dGetCastRayResult using h3dGetNodeParent and h3dGetNodeType and try to call GameEngine::sceneGraphEntityID on the model's Horde3D id.

But as I don't know on which Horde3D node you have attached a GameEngine attachment, this is only speculation.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/