Esempio n. 1
0
//========================================================================================
//	geCamera_ConvertWorldSpaceToCameraSpace
//	Converts a worldspace Xform to a cameraspace xform
//========================================================================================
GENESISAPI geBoolean GENESISCC geCamera_ConvertWorldSpaceToCameraSpace(const geXForm3d *WXForm, geXForm3d *CXForm)
{
	// The rotation portion is just the transpose of the model xform
	CXForm->AX = WXForm->AX;
	CXForm->AY = WXForm->BX;
	CXForm->AZ = WXForm->CX;

	CXForm->BX = WXForm->AY;
	CXForm->BY = WXForm->BY;
	CXForm->BZ = WXForm->CY;

	CXForm->CX = WXForm->AZ;
	CXForm->CY = WXForm->BZ;
	CXForm->CZ = WXForm->CZ;

	CXForm->Translation = WXForm->Translation;

	geVec3d_Inverse(&CXForm->Translation);

	// Rotate the translation in the new camera matrix
	geXForm3d_Rotate(CXForm, &CXForm->Translation, &CXForm->Translation);

	return GE_TRUE;
}
Esempio n. 2
0
//====================================================================================
//	FinishLeafSides
//====================================================================================
geBoolean FinishLeafSides(GBSP_Node *Node)
{
	geVec3d		Mins, Maxs;
	GBSP_Plane	Plane;
	int32		Axis, i, Dir;

	if (!GetLeafBBoxFromPortals(Node, &Mins, &Maxs))
	{
		GHook.Error("FinishLeafSides:  Could not get leaf portal BBox.\n");
		return GE_FALSE;
	}
	
	if (CNumLeafSides < 4)
		GHook.Printf("*WARNING*  FinishLeafSides:  Incomplete leaf volume.\n");

	// Add any bevel planes to the sides so we can expand them for axial box collisions
	else for (Axis=0 ; Axis <3 ; Axis++)
	{
		for (Dir=-1 ; Dir <= 1 ; Dir+=2)
		{
			// See if the plane is allready in the sides
			for (i=0; i< CNumLeafSides; i++)
			{
				Plane = Planes[LPlaneNumbers[i]];
				if (LPlaneSides[i])
				{
					geVec3d_Inverse(&Plane.Normal);
					Plane.Dist = -Plane.Dist;
				}

				if (VectorToSUB(Plane.Normal, Axis) == (geFloat)Dir)
					break;
			}

			if (i >= CNumLeafSides)
			{	
				// Add a new axial aligned side

				geVec3d_Clear(&Plane.Normal);

				VectorToSUB(Plane.Normal, Axis) = (geFloat)Dir;
				
				// get the mins/maxs from the gbsp brush
				if (Dir == 1)
					Plane.Dist = VectorToSUB(Maxs, Axis);
				else
					Plane.Dist = -VectorToSUB(Mins, Axis);
				
				LPlaneNumbers[i] = FindPlane(&Plane, &LPlaneSides[i]);

				if (LPlaneNumbers[i] == -1)
				{
					GHook.Error("FinishLeafSides:  Could not create the plane.\n");
					return GE_FALSE;
				}

				CNumLeafSides++;
				
				NumLeafBevels++;
			}
		}
	}		
	
	Node->FirstSide = NumLeafSides;
	Node->NumSides = CNumLeafSides;
	
	for (i=0; i< CNumLeafSides; i++)
	{
		if (NumLeafSides >= MAX_LEAF_SIDES)
		{
			GHook.Error("FinishLeafSides:  Max Leaf Sides.\n");
			return GE_FALSE;
		}
		
		LeafSides[NumLeafSides].PlaneNum = LPlaneNumbers[i];
		LeafSides[NumLeafSides].PlaneSide = LPlaneSides[i];

		NumLeafSides++;
	}

	return GE_TRUE;
}