Esempio n. 1
0
CC3Vector CC3BillboardBoundingBoxArea::getLocationOfRayIntesection( const CC3Ray& localRay )
{
	if (m_shouldIgnoreRayIntersection) 
		return CC3Vector::kCC3VectorNull;

	// Get the location where the ray intersects the plane of the billboard,
	// which is the Z=0 plane, and ensure that the ray is not parallel to that plane.
	CC3Plane bbPlane = CC3Plane::plane(CC3Vector::kCC3VectorUnitZPositive, CC3Vector::kCC3VectorZero);
	CC3Vector4 pLoc4 = CC3RayIntersectionWithPlane(localRay, bbPlane);
	if ( pLoc4.isNull() ) 
		return CC3Vector::kCC3VectorNull;
	
	// Convert the location to a 2D point on the Z=0 plane, and check
	// if that point is inside the rectangular bounds of the billboard.
	bool intersects = getBillboardBoundingRect().containsPoint( ccp(pLoc4.x, pLoc4.y) );

	// Return the 3D puncture location, or null if the ray did not intersect the boundary rectangle
	return intersects ? pLoc4.cc3Vector() : CC3Vector::kCC3VectorNull;
}
Esempio n. 2
0
CC3Vector4 CC3Camera::unprojectPoint( const CCPoint& cc2Point, const CC3Plane& plane )
{
    return CC3RayIntersectionWithPlane( unprojectPoint( cc2Point ), plane );
}