Jump to content

getIntersectionNodes not works with NODE_REFERENCE type


photo

Recommended Posts

I use function getIntersectionNodes, to get objects ahead the player:

mat4 projection = ortho(-0.05f, 0.05f, -0.05f, 0.05f, 0.5f, 6.0f);

int nodeList[0];

int count = engine.world.getIntersectionNodes(projection, actor.getModelview(), -1, nodeList);

I use "slim projection" cause I need determine all objects ahead player's cursor, so I use this "selection corridor", cause all different getIntersection functions give my only the first intersected object (is it any more simple way to determine nodes on vector, not on projection area? Like engine.world.getIntersection but that return all nodes via start-end vectors)

 

So I use getIntersectionNodes to get all nodes that ahead the player, it's work, but I get all nodes all types, I need get only NodeReference, so I use:

int count = engine.world.getIntersectionNodes(projection, actor.getModelview(), 2, nodeList);
// or
int count = engine.world.getIntersectionNodes(projection, actor.getModelview(), NODE_REFERENCE, nodeList);

Both this variant not give any nodes, what is it can be?

Link to comment

Another question is, how to get surface, that was intersected?

I get list of nodes, that was be intersected, then I find node that I need, and then I need know, what surface was intersected.

I used next:

LOG("nodeMatrix.getNumSurfaces() = " + nodeMatrix.getNumSurfaces());

for (int j = 0; j < nodeMatrix.getNumSurfaces(); j++)
{
int surfaceIntersectionResult[0];
int result = nodeMatrix.getIntersection(actorPos, actorFeelerPos, j, surfaceIntersectionResult);

LOG("nodeMatrix.getIntersectionMask(j) = " + nodeMatrix.getIntersectionMask(j));
LOG("nodeMatrix.getIntersection(j) = " + nodeMatrix.getIntersection(j));
LOG("result = " + result + ", surface = " + j);

if (result)
{
	vec3 intersectionNormal = intersectionResult[1];	// normal of the intersection point (vec3)

	LOG("result = " + result + ", surface = " + j + ", normal = " + string(intersectionNormal));
}
}

and have next result:

16:01:13 ----
16:01:13 nodeMatrix.getNumSurfaces() = 7
16:01:13 nodeMatrix.getIntersectionMask(j) = 1
16:01:13 nodeMatrix.getIntersection(j) = 1
16:01:13 result = 0, surface = 0
16:01:13 nodeMatrix.getIntersectionMask(j) = 1
16:01:13 nodeMatrix.getIntersection(j) = 1
16:01:13 result = 0, surface = 1
16:01:13 nodeMatrix.getIntersectionMask(j) = 1
16:01:13 nodeMatrix.getIntersection(j) = 1
16:01:13 result = 0, surface = 2
16:01:13 nodeMatrix.getIntersectionMask(j) = 1
16:01:13 nodeMatrix.getIntersection(j) = 1
16:01:13 result = 0, surface = 3
16:01:13 nodeMatrix.getIntersectionMask(j) = 1
16:01:13 nodeMatrix.getIntersection(j) = 1
16:01:13 result = 0, surface = 4
16:01:13 nodeMatrix.getIntersectionMask(j) = 1
16:01:13 nodeMatrix.getIntersection(j) = 1
16:01:13 result = 0, surface = 5
16:01:13 nodeMatrix.getIntersectionMask(j) = 1
16:01:13 nodeMatrix.getIntersection(j) = 1
16:01:13 result = 0, surface = 6
16:01:13 mouseOverObject

So I have not surface intersection, what can be wrong? For what to surface set intersection mask, we not use it in getIntersection() function

Link to comment

is it any more simple way to determine nodes on vector, not on projection area?

 

engine.world.getIntersection() can be used for getting all nodes including their intersection surface data on vector between p0 and p1 simply by adding nearest node intersection of iteration N to exclude array for iteration N+1 until no more intersection can be found. Due to your short test distance performance shouldn't be a problem.

 

Something like the following (untested) code outlines the general approach

 

....
Node            node;
Node            nodes[];
int             result[];
Unigine::Vector results;

do
{
  node = engine.world.getIntersection( p0, p1, mask, nodes, result );

  if( node != 0 )
  {
      nodes.append(node);
      results.append(result);
  }
}
while( node != 0 )

.....

Link to comment
×
×
  • Create New...