예제 #1
0
	void CameraFreeView (int iID, float move, float ystep, float xturn, float yturn)
	{
		if (!camera.ACTIVE) return;
		// Tastatur Steuerung
		if (dbUpKey()==1)			{	camera.UPDATE=true;	dbMoveCamera(    iID, move);		}
		if (dbDownKey()==1)		{	camera.UPDATE=true;	dbMoveCamera(    iID, -move);									}
		if (dbLeftKey()==1)		{	camera.UPDATE=true;	dbYRotateCamera( iID, dbWrapValue(camera.b-yturn));	}
		if (dbRightKey()==1)		{	camera.UPDATE=true;	dbYRotateCamera( iID, dbWrapValue(camera.b+yturn));	}
		if (dbScanCode()==201)  {	camera.UPDATE=true;	dbXRotateCamera( iID, dbWrapValue(camera.a+xturn));	}
		if (dbScanCode()==209) 	{	camera.UPDATE=true;	dbXRotateCamera( iID, dbWrapValue(camera.a-xturn));	}
		if (dbShiftKey()==1) 	{	camera.UPDATE=true;	dbPositionCamera(iID, camera.x,camera.y+ystep,camera.z);}
		if (dbControlKey()==1) 	{	camera.UPDATE=true;	dbPositionCamera(iID, camera.x,camera.y-ystep,camera.z);}

		// Maus Steuerung
		if ( mouse.c == 2)
		{

		if ( mouse.mx != 0.0f)	{	camera.UPDATE=true;	dbYRotateCamera(iID,dbCurveAngle(dbWrapValue(camera.b+mouse.mx),camera.b,2.5f));	}
		if ( mouse.my != 0.0f)	{	camera.UPDATE=true;	dbXRotateCamera(iID,dbCurveAngle(dbWrapValue(camera.a+mouse.my),camera.a,2.5f));	}
		if ( mouse.mz != 0.0f)	{	camera.UPDATE=true;	dbMoveCamera(iID,mouse.mz);}
		}
	}
예제 #2
0
void DarkSDK ( void )
{
	// entry point for the application

	//dbSetDir ( "media\\" );

	// initial application set up
	dbSyncOn         ( );				// turn sync on
	dbSyncRate       ( 0 );			// set sync rate to 60
	dbBackdropOn    ( );				// switch backdrop off - no need to clear screen
	dbSetCameraRange ( 0.5f, 30000 );	// set the camera range

	PhysStart ( );

	
		// floor
	dbMakeObjectBox			 ( 1, 100, 1, 100 );
	dbPositionObject		 ( 1, 0, 0, 0 );
	dbColorObject			 ( 1, dbRgb ( 100, 0, 0 ) );
	PhysCreateStaticRigidBodyMesh ( 1 );
	

	/*
	dbLoadObject ( "bin1.x", 2 );
	//dbPositionObject ( 2, 0, 1 + dbObjectCollisionCenterY ( 2 ), 0 );
	dbPositionObject ( 2, 0, 0, 0 );
	//dbOffsetLimb ( 2, 0, dbObjectCollisionCenterX ( 2 ) * -1, dbObjectCollisionCenterY ( 2 ) * -1, dbObjectCollisionCenterZ ( 2 ) * -1 );
	PhysCreateRigidBodyBox ( 2 );

	dbMakeObjectCube ( 3, 5 );
	dbPositionObject ( 3, 20, 10, 0 );
	PhysCreateRigidBodyBox ( 3 );
	*/



	const NxReal height = 0.3;
	const NxReal width = 2;
	const NxReal length = 4;

	

	//dbMakeObjectBox ( 5, length*0.65, height*0.85, width*0.65 );
	dbMakeObjectBox ( 5, 3.5,3,4);
	dbPositionObject ( 5, 3.5,4,0 );

	dbMakeObjectSphere ( 10, 0.8 );
	dbMakeObjectSphere ( 11, 0.8 );
	dbMakeObjectSphere ( 12, 0.8 );
	dbMakeObjectSphere ( 13, 0.8 );

	CreateTruck ( );

	//dbLoadObject ( "corsa.x", 5 );
	//dbPositionObject ( 5, 0, 1, 0 );

	/*
	InitCar ( );
	car = CreateCar(NxVec3(0,5,0));
	*/

	

	dbPositionCamera ( 0, 20, -30 );


	
//	PhysCreateRigidBodyBox ( 10 );
	
	// loop round until escape key is pressed
	while ( LoopSDK ( ) )
	{
		if ( dbEscapeKey ( ) )
			return;

		if ( dbSpaceKey ( ) )
			PhysSetVelocity ( 10, 0, 20, 0 );

		UpdateTruck ( );

		//if ( dbSpaceKey ( ) )
		//	PhysSetVelocity ( 3, -20, 0, 0 );

		/*
		{
			bool bKey = false;

			if ( dbKeyState ( 17 ) == 1 )
			{
				gMotorForce = gMaxMotorPower;
				bKey = true;
			}

			if ( dbKeyState ( 31 ) == 1 )
			{
				gMotorForce = -gMaxMotorPower;
				bKey = true;
			}

			if ( dbKeyState ( 32 ) )
			{
				if (gSteeringValue > (-1.0f + gSteeringDelta))
					gSteeringValue -= gSteeringDelta;

				bKey = true;
			}

			if ( dbKeyState ( 30 ) )
			{
				if (gSteeringValue < (1.0f - gSteeringDelta))
					gSteeringValue += gSteeringDelta;

				bKey = true;
			}

			if ( !bKey )
			{
				gMotorForce = 0.0f;
				gSteeringValue = 0.0f;
			}

		}

		TickCar ( );
		*/
		

		// show the frame rate and handle user input
		showFPS   ( );
		userInput ( );

		PhysRun ( );
		PhysUpdate ( );

		// render everything
		dbSync ( );
	}
}
예제 #3
0
	void CameraCylinder (int iID,float move, float ystep, float yturn)
	{
		if (!camera.ACTIVE) return;

		//Left
		if (dbLeftKey()==1)		
		{	
			camera.b=dbWrapValue(camera.b+yturn);
			float distXZ=dbSQRT(camera.x*camera.x+camera.z*camera.z);
			camera.x=dbNewXValue(camera.point.x,camera.b,-distXZ);
			camera.z=dbNewZValue(camera.point.z,camera.b,-distXZ);
			dbPositionCamera(iID,camera.x,camera.y,camera.z);
			dbPointCamera(iID,camera.point.x,camera.point.y,camera.point.z);
			camera.UPDATE=true;
		}
		//Right
		if (dbRightKey()==1)		
		{
			camera.b=dbWrapValue(camera.b-yturn);	
			float distXZ=dbSQRT(camera.x*camera.x+camera.z*camera.z);
			camera.x=dbNewXValue(camera.point.x,camera.b,-distXZ);
			camera.z=dbNewZValue(camera.point.z,camera.b,-distXZ);
			dbPositionCamera(iID,camera.x,camera.y,camera.z);
			dbPointCamera(iID,camera.point.x,camera.point.y,camera.point.z);
			camera.UPDATE=true;
		}
		//Shift
		if (dbShiftKey()==1)		
		{	
			camera.y += ystep;
			dbPositionCamera(iID,camera.x,camera.y,camera.z);
			dbPointCamera(iID,camera.point.x,camera.point.y,camera.point.z);
			camera.a=dbCameraAngleX(iID);
			camera.UPDATE=true;
		}
		//Strg
		if (dbControlKey()==1)	
		{	
			if (camera.y>=ystep)
			{
			camera.y -= ystep;
			dbPositionCamera(iID,camera.x,camera.y,camera.z);
			dbPointCamera(iID,camera.point.x,camera.point.y,camera.point.z);
			camera.a=dbCameraAngleX(iID);
			camera.UPDATE=true;
			}
		}
		//Up
		if (dbUpKey()==1)	
		{	
			dbMoveCamera(iID,move);
			camera.x=dbCameraPositionX(iID);
			camera.y=dbCameraPositionY(iID);
			camera.z=dbCameraPositionZ(iID);
			camera.UPDATE=true;
		}
		//Down
		if (dbDownKey()==1)
		{	
			dbMoveCamera(iID,-move);
			camera.x=dbCameraPositionX(iID);
			camera.y=dbCameraPositionY(iID);
			camera.z=dbCameraPositionZ(iID);
			camera.UPDATE=true;
		}
		//Mouse
		if (mouse.c==2)
		{
		if ( mouse.mx != 0.0f)	{	dbYRotateCamera(iID,dbCurveAngle(dbWrapValue(dbCameraAngleY(iID)+mouse.mx),dbCameraAngleY(iID),2.5f));	}
		if ( mouse.my != 0.0f)	{	dbXRotateCamera(iID,dbCurveAngle(dbWrapValue(dbCameraAngleX(iID)+mouse.my),dbCameraAngleX(iID),2.5f));	}
		if ( mouse.mz != 0.0f)	{	dbMoveCamera(iID,mouse.mz);}
		}	
	}