I’m confused about the description of the intersection between ray and quad. It says:
u,v is the intersection point in terms of the quad plane
http://javadoc.jmonkeyengine.org/com/jme3/math/Ray.html
My method so far is:
/**
* Calculates intersection between an arena and a ray from the client
*
* @param ray the ray from the client camera mouse click, into the
* worldspace
* @param arena the arena the client is playing in
* @return Vec3d holding the point of intersection
*
*/
public Vec3d getCollisionCoords(Ray ray, ArenaId arena) {
/**
* For different arenas, we use different Z-offsets. Our planes are in
* the x,y-plane using different z's for different arenas
*/
int zOffset = this.arenaOffsetMap.get(arena.getArenaId());
//Construct topleft, topright and bottomleft of quad
Vector3f quadCoordBottomLeft = new Vector3f(-100, -100, zOffset);
Vector3f quadCoordTopRight = new Vector3f(100, 100, zOffset);
Vector3f quadCoordTopLeft = new Vector3f(-100, 100, zOffset);
//initiate vec3f to store collision info (t,u,v)
/**
* t: distance from origin to collision u,v: is the intersection point
* in terms of the quad plane
*/
Vector3f collisionLoc = new Vector3f();
/**
* TODO: Use correct intersect method
*/
Boolean intersects = ray.intersectWherePlanarQuad(quadCoordTopLeft, quadCoordTopRight, quadCoordBottomLeft, collisionLoc);
if (intersects) {
/**
* Return correct Vec3d
*/
return new Vec3d(collisionLoc.y, collisionLoc.z, zOffset);
} else {
return null;
}
}
But I dont understand the u,v-coordinates. If my plane is 200 wu in width and height centered on 0,0 - how do I use the u,v-coordinates to figure out where, in world space, my ray intersected the plane?
Kind regards,
Asser