NewtonCollision* dCollisionCompoundNodeInfo::CreateNewtonCollision (NewtonWorld* const world, dScene* const scene, dScene::dTreeNode* const myNode) const
{
	dAssert (IsType (dCollisionCompoundNodeInfo::GetRttiType()));

	// get the collision node	
	int collisionID = GetShapeId ();
	
	NewtonCollision* const collision = NewtonCreateCompoundCollision(world, collisionID); 
	NewtonCompoundCollisionBeginAddRemove(collision);

	// create space to load all sub shapes
	for (void* link = scene->GetFirstChildLink(myNode); link; link = scene->GetNextChildLink (myNode, link)) {
		dScene::dTreeNode* childNode = scene->GetNodeFromLink(link);
		dNodeInfo* info = scene->GetInfoFromNode(childNode);
		if (info->IsType (dCollisionNodeInfo::GetRttiType())) {
			dCollisionNodeInfo* collInfo = (dCollisionNodeInfo*) scene->GetInfoFromNode(childNode);
			NewtonCollision* const convex = collInfo->CreateNewtonCollision (world, scene, childNode);
			if (convex) {
				NewtonCompoundCollisionAddSubCollision(collision, convex);
				NewtonDestroyCollision(convex);
			}
		}
	}
	NewtonCompoundCollisionEndAddRemove(collision);
	
	return collision;

}
NewtonCollision* dCollisionConeNodeInfo::CreateNewtonCollision (NewtonWorld* const world, dScene* const scene, dScene::dTreeNode* const myNode) const
{
	dAssert (IsType (dCollisionConeNodeInfo::GetRttiType()));

	// get the collision node	
	int collisionID = GetShapeId ();
	const dMatrix& offsetMatrix = GetTransform ();
	
	// create a newton collision shape from the node.
	return NewtonCreateCone(world, m_radius, m_height, collisionID, &offsetMatrix[0][0]);
}
Exemplo n.º 3
0
NewtonCollision* dCollisionBoxNodeInfo::CreateNewtonCollision (NewtonWorld* const world, dScene* const scene, dScene::dTreeNode* const myNode) const
{
	_ASSERTE (IsType (dCollisionBoxNodeInfo::GetRttiType()));

	// get the collision node	
	int collisionID = GetShapeId ();
	const dMatrix& offsetMatrix = GetTransform ();
	
	// create a newton collision shape from the node.
	return NewtonCreateBox(world, m_size.m_x, m_size.m_y, m_size.m_z, collisionID, &offsetMatrix[0][0]);
}