static void KeyboardCallback(unsigned char key, int x, int y)
{
	static Random random;
	int sceneIndex = random.rand()&1;

	switch (key)
	{
	case 27:	exit(0); break;
	case ' ':			CreateCube(sceneIndex, NxVec3(0.0f, 20.0f, 0.0f), 1+(rand()&3)); break;
	case 's':			CreateStack(sceneIndex, 10); break;
	case 'b':			CreateStack(sceneIndex, 30); break;
	case 't':			CreateTower(sceneIndex, 30); break;
	case 'x':			gShadows = !gShadows; break;
	case 'p':			gPause = !gPause; break;
	case 101: case '8':	Eye += Dir * 2.0f; break;
	case 103: case '2':	Eye -= Dir * 2.0f; break;
	case 100: case '4':	Eye -= N * 2.0f; break;
	case 102: case '6':	Eye += N * 2.0f; break;
	case 'w':
		{
		NxVec3 t = Eye;
		NxVec3 Vel = Dir;
		Vel.normalize();
		Vel*=200.0f;
		CreateCube(sceneIndex, t, 8, &Vel);
		}
		break;
	}
}
void RenderScene() 
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer
	glLoadIdentity();									// Reset The matrix
	
		// 	  Position      View	   Up Vector
	gluLookAt(0, 0, 6,     0, 0, 0,     0, 1, 0);		// This determines where the camera's position and view is

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

	// Only 4 lines of code where changed in this function.  First, we added
	// another cube, but this one is half the size as the original.  Second, we
	// added the glEnable()/glDisable() and glBlendFunc() functions.  More explained below.

	glRotatef(rotX, 1.0f, 0.0f, 0.0f);					// Rotate the cubes around the X-axis
	glRotatef(rotY, 0.0f, 1.0f, 0.0f);					// Rotate the cubes around the Y-axis	
	glRotatef(rotZ, 0.0f, 0.0f, 1.0f);					// Rotate the cubes around the Z-axis

	// This will be the smaller cube inside of the bigger cube.  You notice we
	// pass in 255 as the color value at the end.  That basically just creates the
	// colors in the opposite position as the other cube so it looks a bit better.

	CreateCube(-0.5f, -0.5f, -0.5f, 1, 255);			// Create the smaller cube inside the bigger one

	// This turns blending on.  Anything drawn after this will be transparent.

	glEnable(GL_BLEND);									// Turn on blending

	// This actually chooses the blending mode we want.  Without this, nothing would happen.
	// Basically, the first parameter specifies how the red, green, blue, 
	// and alpha source-blending factors are calculated.  The next parameter specifies how
	// the red, green, blue, and alpha destination-blending factors are calculated.  We chose
	// a ONE to ONE ratio basically.  There is a equation for each of the (R, G, B, A) values.
	// In a later tutorial we will examine some other flags that we could pass in, like GL_SRC_COLOR.
	// Look in MSDN for further explanations on each of these flags.

	glBlendFunc(GL_ONE, GL_ONE);						// Make our transparency a 1:1 ratio

	CreateCube(-1, -1, -1, 2, 0);						// This creates our larger transparent cube

	// The last step is to disable blending.  This assures that nothing else will
	// be blended from here on.  This finishes the scope of our blending.

	glDisable(GL_BLEND);								// Disable blending from here on out

	rotX += 0.3f;										// Increase the X rotation
	rotY += 0.3f;										// Increase the Y rotation
	rotZ += 0.8f;										// Increase the Z rotation

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

	SwapBuffers(g_hDC);									// Swap the backbuffer to the foreground
}
Пример #3
0
void Initialize (int argc, char *argv[])
{
  GLenum GlewInitResult;
  TempString = (char *) malloc (512 + strlen(WINDOW_TITLE_PREFIX));
  InitWindow (argc, argv);
  glewExperimental = GL_TRUE;
  GlewInitResult = glewInit();
  if (GLEW_OK != GlewInitResult) {
    fprintf (stderr,
	     "ERROR: %s\n",
	     glewGetErrorString (GlewInitResult) );
    exit (EXIT_FAILURE);
  }
  fprintf (stdout, "INFO: OpengGL Vertion: %s\n", glGetString (GL_VERSION));
  glGetError ();

  glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
  
  glEnable (GL_DEPTH_TEST);
  glDepthFunc (GL_LESS);
  ExitOnGLError ("ERROR: Could not set OpenGL depth testing options");
  
  glEnable (GL_CULL_FACE);
  glCullFace (GL_BACK);
  glFrontFace (GL_CCW);
  ExitOnGLError ("ERROR: Could not set OpenGL culling options");
  
  ModelMatrix = IDENTITY_MATRIX;
  ProjectionMatrix = IDENTITY_MATRIX;
  ViewMatrix = IDENTITY_MATRIX;
  TranslateMatrix (&ViewMatrix, 0, 0, -2);

  CreateCube ();
}
Пример #4
0
HRESULT InitD3D( HWND hWnd )
{
	// Create the D3D object, which is needed to create the D3DDevice.
	if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
	{
		MessageBoxA(NULL, "Create D3D9 object failed!", "Error", 0) ;
		return E_FAIL;
	}

	D3DPRESENT_PARAMETERS d3dpp; 
	ZeroMemory( &d3dpp, sizeof(d3dpp) );

	d3dpp.Windowed = TRUE; // use window mode, not full screen
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;

	// Create device
	if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
		D3DCREATE_SOFTWARE_VERTEXPROCESSING,
		&d3dpp, &g_pd3dDevice ) ) )
	{
		MessageBoxA(NULL, "Create D3D9 device failed!", "Error", 0) ;
		return E_FAIL;
	}

	// Create Cube
	CreateCube();

	// Build effect
	BuildEffect();

	return S_OK;
}
Пример #5
0
BOOL BBXParser::LoadFile( LPWSTR _FileName )
{
	Cleanup();

//	//CDebugConsole::GetInstance()->Messagef( L"BBXParser\n" );
//	//CDebugConsole::GetInstance()->Message( _FileName );
//	//CDebugConsole::GetInstance()->Messagef( L"\n" );

	FILE*	fp;
	fp = _wfopen( _FileName, L"rt" );
	TCHAR	sLine[ 1024 ];

	ReadLineFromFile( fp, sLine );
	if( !CheckFile( fp, sLine ) )
		return FALSE;

	while( !feof( fp ) )
	{
		ReadLineFromFile( fp, sLine );

		GetNumBoundBox( sLine );

		BeginBoundBoxList( fp, sLine );
	}

	//	렌더링 될 충돌박스를 만든다
	CreateCube( m_iNumBoundBox, m_pData );

	fclose( fp );

	return TRUE;
}
Пример #6
0
void CreateCubeFromEye(int size)
{
	NxVec3 t = g_CameraPos;
	NxVec3 vel = g_CameraForward;
	vel.normalize();
	vel*=200.0f;
	CreateCube(t, size, &vel);
}
Пример #7
0
void PhysX::CreateCubeFromEye(float cubeSize)
{
	NxVec3 t = m_Eye;
	NxVec3 vel = m_Dir;
	vel.normalize();
	vel*=200.0f;
	CreateCube(t, cubeSize, DENSITY, &vel);
}
Пример #8
0
bool InitNx()
{
	// Initialize PhysicsSDK
	NxPhysicsSDKDesc desc;
	gMyPhysX.initPhysX(desc);

	if(isPhysXHardwarePresent())
		printf("PhysX Hardware is available in your system!\n");
	// Create a scene
	NxSceneDesc sceneDesc;
	sceneDesc.gravity				= gDefaultGravity;

	gMyPhysX.createDefaultScene(sceneDesc);

	// Create ground plane
	NxPlaneShapeDesc PlaneDesc;
	PlaneDesc.group = 2;
	NxActorDesc ActorDesc;
	ActorDesc.shapes.pushBack(&PlaneDesc);
	gMyPhysX.getScene()->createActor(ActorDesc);

	NxMaterial * defaultMaterial = gMyPhysX.getScene()->getMaterialFromIndex(0); 
	defaultMaterial->setRestitution(0.0f);
	defaultMaterial->setStaticFriction(0.5f);
	defaultMaterial->setDynamicFriction(0.5f);

	// Create trigger

	NxVec3 zeroV(0,0,0);

	CreateTrigger(NxVec3(0,10,0), 10);
	CreateTrigger(NxVec3(-40,10,0), 10, &zeroV, false);
	CreateCube(NxVec3(-40,10,40), 10, NULL, false, true);
	CreateCube(NxVec3(-40,10,80), 10, NULL, true, false);

	//This creates a kinematic actor with a trigger, note that kinematic
	//triggers get interactions with static objects, thus this trigger
	//(which is placed directly above the ground) will directly get an
	//enter event for the ground plane (and change it's color). 
	CreateTrigger(NxVec3(40,10,0), 10, NULL, true);
	//You can try to move it up just a little bit, and you will see 
	//that it will no longer intersect the ground plane.
	//CreateTrigger(NxVec3(40,11,0), 10, NULL, true);

	return true;
}
void RendererBase::loadScene()
{
	m_camera->setPosDir(glm::vec3(0.0f, 5.0f, 0.0f), glm::vec2(TO_RADIANS(175.0f), 0.0f));


	ModelObject *ground = new ModelObject(&m_modelCube);
	ground->scale(glm::vec3(200.0f, 1.0f, 200.0f));
	ground->pos(glm::vec3(0.0f, 0.0f, 0.0f));

	m_modelObjects.push_back(ground);

	int index = 0;
	for (int x = 0; x < 8; x++) {
		for (int y = 0; y < 8; y++) {
			LightPoint *lp = new LightPoint;
			lp->position = glm::vec3(-10.0f + (x*  12 ), 5.0f, -20.0f + (y*  12 ));

			ModelObject *teapot = new ModelObject(&m_modelTeapot);
			teapot->scale(glm::vec3(20.0f, 20.0f, 20.0f));
			teapot->pos(glm::vec3(lp->position.x-1.0f,
								  0.5f,
								  lp->position.z));

			m_pointLights.push_back(lp);

			m_modelObjects.push_back(teapot);
		}
	}
	
	// Textures
	m_textureGround.load("Ground_SmoothRocks_1k_d.tga", 16);
	m_textureGround.setTextTile(50.0f);
	m_textureGround.setKd(glm::vec3(1.0f));
	m_textureGround.setShininess(100.0f);
	m_textureGround.setSpec(0.1f);

	m_textureTeapot.load("Metal_WallPanel_1k_d.tga", 16);
	m_textureTeapot.setTextTile(4.0f);
	m_textureTeapot.setKd(glm::vec3(1.0f));
	m_textureTeapot.setShininess(100.0f);
	m_textureTeapot.setSpec(2.7f);

	
	m_textureColorTerrain.setKd(glm::vec3(0.0f, 0.0f, 1.0f));
	m_textureColorTerrain.setShininess(100.0f);
	m_textureColorTerrain.setSpec(2.7f);

	std::vector<glm::vec3> verticesList;
	std::vector<glm::vec3> normalsList;
	std::vector<glm::vec2> tcList;
	std::vector<GLushort> indices;

	CreateCube(1, verticesList, normalsList, tcList, indices);
	m_terrainCube.fillVertecies(verticesList, normalsList, tcList, indices);

	m_terrainCube.pos(glm::vec3(0.0f, 1.0f, 0.0f));
	m_terrainCube.scale(glm::vec3(4.0f));
}
Пример #10
0
static void KeyboardCallback(unsigned char key, int x, int y)
	{
	switch (key)
		{
		case 27:	exit(0); break;
		case '1':			CreateCube(NxVec3(-40.0f, 60.0f, -18.0f)); break;
		case '2':			CreateCube(NxVec3(0.0f, 60.0f, -18.0f)); break;
		case '3':			CreateCube(NxVec3(40.0f, 60.0f, -18.0f)); break;

		case '4':			CreateCube(NxVec3(-40.0f, 60.0f, 40.0f)); break;
		case '5':			CreateCube(NxVec3(0.0f, 60.0f, 40.0f)); break;
		case '6':			CreateCube(NxVec3(40.0f, 60.0f, 40.0f)); break;

		case 'p':			gPause = !gPause; break;
		case 101: 			Eye += Dir * 2.0f; break;
		case 103: 			Eye -= Dir * 2.0f; break;
		case 100: 			Eye -= N * 2.0f; break;
		case 102: 			Eye += N * 2.0f; break;
		case 'w':
			{
			NxVec3 t = Eye;
			NxVec3 Vel = Dir;
			Vel.normalize();
			Vel*=100.0f;
			CreateCube(t, &Vel);
			}
			break;
		}
	
	}
Пример #11
0
	MeshUtil::MeshUtil()
	{
		m_MeshMap.emplace("quad_mesh", CreateQuad("quad_mesh", Vector4(-1.0f, -1.0f, 0.0f), Vector4(1.0f, 1.0f, 0.0f)));
		m_MeshMap.emplace("cube_mesh", CreateCube("cube_mesh", Vector4(-1.0f), Vector4(1.0f)));
		m_MeshMap.emplace("ico_sphere_mesh", CreateIcoSphere("ico_sphere_mesh", 1.0f, 2));
		m_MeshMap.emplace("sphere_mesh", CreateSphere("sphere_mesh", 1.0f, 20, 20));
		m_MeshMap.emplace("cylinder_mesh", CreateCylinder("cylinder_mesh", 1.0f, 1.0f, 1.0f, 4, 10));
		m_MeshMap.emplace("cone_mesh", CreateCylinder("cone_mesh", 0.0f, 1.0f, 1.0f, 4, 10));
	}
Пример #12
0
int Game_Init(void *parms)
{
	// this function is where you do all the initialization 
	// for your game

	renderer = Renderer();
	renderer.initialize(main_window_handle, WINDOW_WIDTH, WINDOW_HEIGHT);

	renderer.createZBuffer();

	open_light = 1;

	// 设置光源
	ambient_light.state = LIGHTV1_STATE_ON;
	ambient_light.attr = LIGHTV1_ATTR_AMBIENT;
	ambient_light.c_ambient = ColourValue::Gray;
	ambient_light.c_diffuse = ColourValue::ZERO;
	
	directional_light.state = LIGHTV1_STATE_ON;
	directional_light.attr = LIGHTV1_ATTR_DIRECTIONAL;
	directional_light.c_ambient = ColourValue::ZERO;
	directional_light.c_diffuse = ColourValue::Gray; //ColourValue(1.0f, 1.0f, 0.0f);
	directional_light.dir = Vector4(0, 2, -2, 1);


	//CreatePlane(g_Obj, Vector4(0, 0, 5, 1));
	
	CreateCube(g_Obj, Vector4(0, 0, 5, 1), "../Texture/struct_rotation1.bmp");
	CreateCube(g_Obj_c, Vector4(4, 0, 5, 1));
	CreateCube(g_Obj_s, Vector4(-4, 0, 5, 1));

	// 设置相机
	camera.CameraCreate(CAMERA_TYPE_ELUER, Vector4(0, 0, 0, 1), Vector3::zero, Vector4(0, 0, 0, 1), Vector4(0, 0, 1, 1), 0, 1, 50, 120, WINDOW_WIDTH, WINDOW_HEIGHT);
	//camera.CameraCreate(CAMERA_TYPE_ELUER, Vector4(0.1f, 3.5f, 4.f, 1.0f), Vector3(40, 0, 0) , Vector4(0, 0, 0, 1), Vector4(0, 0, 1, 1), 0, 5, 50, 90, WINDOW_WIDTH, WINDOW_HEIGHT);
	//camera.CameraCreate(CAMERA_TYPE_UVN, Vector4(5, 0, 6, 1), Vector3::zero, Vector4(0, 0, 5, 1), Vector4(0, 0, 1, 1), 0, 5, 50, 90, WINDOW_WIDTH, WINDOW_HEIGHT);
	
	camera.CameraUpdateMatrix();
	camera.BuildProjectMatrix();
	camera.BuildScreenMatrix();

	// return success
	return(1);

} // end Game_Init
Пример #13
0
CubeRobot::CubeRobot(void)	{	
	if(!cube) {
		CreateCube();
	}
	SetMesh(cube);

	//Make the body
	SceneNode*body = new SceneNode(cube,Vector4(1,0,0,1));
	body->SetModelScale(Vector3(10,15,5));
	body->SetTransform(Matrix4::Translation(Vector3(0,35,0)));
	AddChild(body);

	//Add the head
	head = new SceneNode(cube,Vector4(0,1,0,1));
	head->SetModelScale(Vector3(5,5,5));
	head->SetTransform(Matrix4::Translation(Vector3(0,30,0)));
	body->AddChild(head);

	//Add the left arm
	leftArm = new SceneNode(cube,Vector4(0,0,1,1));
	leftArm->SetModelScale(Vector3(3,-18,3));
	leftArm->SetTransform(Matrix4::Translation(Vector3(-12,30,-1)));
	body->AddChild(leftArm);

	//Add the right arm
	rightArm = new SceneNode(cube,Vector4(0,0,1,1));
	rightArm->SetModelScale(Vector3(3,-18,3));
	rightArm->SetTransform(Matrix4::Translation(Vector3(12,30,-1)));
	body->AddChild(rightArm);

	//Add the left leg
	leftLeg = new SceneNode(cube,Vector4(0,0,1,1));
	leftLeg->SetModelScale(Vector3(3,-17.5,3));
	leftLeg->SetTransform(Matrix4::Translation(Vector3(-8,0,0)));
	body->AddChild(leftLeg);

	//Finally the right leg!
	rightLeg = new SceneNode(cube,Vector4(0,0,1,1));
	rightLeg->SetModelScale(Vector3(3,-17.5,3));
	rightLeg->SetTransform(Matrix4::Translation(Vector3(8,0,0)));
	body->AddChild(rightLeg);

	//Giant CubeRobot!
	//transform = Matrix4::Scale(Vector3(10,10,10));

	//The Scene Management Tutorial introduces these, as cheap culling tests
	body->SetBoundingRadius(15.0f);
	head->SetBoundingRadius(5.0f);

	leftArm->SetBoundingRadius(18.0f);
	rightArm->SetBoundingRadius(18.0f);

	leftLeg->SetBoundingRadius(18.0f);
	rightLeg->SetBoundingRadius(18.0f);
}
Пример #14
0
void CreateCubeFromEye(int size,osg::Camera *camera)
{
	osg::Vec3 eye,center,up;
	camera->getViewMatrixAsLookAt(eye,center,up);
	NxVec3 t(eye.x(),eye.y(),eye.z());
	NxVec3 vel(center.x()-eye.x(),center.y()-eye.y(),center.z()-eye.z());
	vel.normalize();
	vel*=500.0f;

	camera->addChild(CreateCube(t, size,5, &vel));
	//return CreateCube(t, size, &vel);
}
Пример #15
0
void PhysX::CreateTower(int cubeCount, float cubeSize)
{
	//const float cubeSize = 2.0f;
	const float spacing = 0.01f;
	NxVec3 pos(0.0f, cubeSize, 0.0f);
	while(cubeCount)
	{
		CreateCube(pos, (int)cubeSize);
		pos.y += (cubeSize * 2.0f + spacing);
		cubeCount--;
	}
}
static void CreateTower(int sceneIndex, int size)
{
	float CubeSize = 2.0f;
	float Spacing = 0.01f;
	NxVec3 Pos(0.0f, CubeSize, 0.0f);
	while(size)
	{
		CreateCube(sceneIndex, Pos, (int)CubeSize);
		Pos.y += (CubeSize * 2.0f + Spacing);
		size--;
	}
}
Пример #17
0
/*
    Function: Main entry point ( Application main )

    Flow:
        - Init GLUT
        - Setup Window Buffers ( Double render buffer as well as support
            for Alpha, and Depth buffer)
        - Setup Window Width, Height, X, Y Position
        - Create Window with title
        - Setup Lighting
        - Set callback to display function for rendering
        - Set callback to reshape function for changing the size of the viewport
        - Set callback to keyPressed and keyUp to handle keyboard input
        - Tell GLUT to enter main loop
            E.g
                while( running ) {
                    doApplicationStuff();
                }
    End State:
        Creation and running of an application as well as closing and
        releasing all resources used by the application
*/
int main(int argc, char **argv)
{
    int windowWidth     = 500;
    int windowHeight    = 500;
    int windowXPos      = 100;
    int windowYPos      = 100;

    // Initialize GLUT with command line input
    glutInit(&argc, argv);

    // Set up a basic buffer (only single buffered for now)
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);

	glutGameModeString("1440x900:32@60");
	glutEnterGameMode();

    // Set width ,height, X Pos and Y pos of window
    //glutInitWindowSize(windowWidth, windowHeight);
    //glutInitWindowPosition(windowXPos, windowYPos);

    // Create window with title
    //glutCreateWindow("Basic Window with lighting!");

    // Clear keyboard state
    initKeyboardState();

    // Setup lighting
    initLighting();

	 // Initiate object lists
	 CreateCube();

    // Setup Idle and Display to both use the 'display' function,
    // set the reshape event to use the 'reshape' funciton
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutReshapeFunc(reshape);

    // Set keyboard callback function to handle key pressing and releasing
    glutKeyboardFunc(keyPressed);
    glutKeyboardUpFunc(keyUp);
    glutSpecialFunc(keySpecialPressed);
    glutSpecialUpFunc(keySpecialUp);
    
    // Run the main loop which will handle closing of the application
	 glutMainLoop();

    // Free the texture
    FreeTexture( texture );
}
Пример #18
0
void TW_CALL SetScale(const void *value, void *clientData)
{
	//Pointer auf gesetzten Typ casten (der Typ der bei TwAddVarCB angegeben wurde)
	const unsigned int* uintptr = static_cast<const unsigned int*>(value);

	//Setzen der Variable auf neuen Wert
	scale = *uintptr;

	//Hier kann nun der Aufruf gemacht werden um die Geometrie mit neuem Scalefaktor zu erzeugen
	//CreateCone(0.0f, 0.0f, -100.0f);
	CreateCube(-75.0f, 0.0f, 0.0f);
	CreateCylinder(0.0f, 125.0f, 0.0f);
	CreateSphere(100.0f, 0.0f, 0.0f);

	RenderScene();
}
static void CreateStack(int sceneIndex, int size)
{
	float CubeSize = 2.0f;
	float Spacing = 0.0001f;
	NxVec3 Pos(0.0f, CubeSize, 0.0f);
	float Offset = -size * (CubeSize * 2.0f + Spacing) * 0.5f;
	while(size)
	{
		for(int i=0;i<size;i++)
		{
			Pos.x = Offset + float(i) * (CubeSize * 2.0f + Spacing);
			CreateCube(sceneIndex, Pos, (int)CubeSize);
		}
		Offset += CubeSize;
		Pos.y += (CubeSize * 2.0f + Spacing);
		size--;
	}
}
Пример #20
0
//Splash screen
void Splash() {
	ResetTimer(); //we're going to use it for random seed
	//Setup a world with a tank and a pyramid in specific places
	CloseGraphics();
	OpenGraphics();

	Point3d centre;
	world=CreateNewWorld();

	//A tank pointing straight at us
	centre=CreatePoint(0.0,0.0,45.0);
	obj=CreateTank(GREEN, centre, 4.5);
	RotateObjectYAxis(&obj, 2.0 * PI / 360.0 * 195);
	AddObjectToWorld(&world, obj);

	//A yellow pyramid behind the tank and to the right
	centre=CreatePoint(10.0, 0.0, 70.0);
	obj=CreatePyramid(YELLOW, centre, 5.0);
	RotateObjectYAxis(&obj, 3.0*PI/5.0);
	AddObjectToWorld(&world, obj);

	//A blue cube behind the tank and to the left
	centre=CreatePoint(-10.0, 0.0, 60.0);
	obj=CreateCube(BLUE, centre, 5.0);
	RotateObjectYAxis(&obj, 195.0*PI/180.0);
	AddObjectToWorld(&world,obj);

	//Draw world, add splash graphics, prompt to start
	cameraPos=CreatePoint(0.0,5.0,0.0);
	cameraAngle=CreatePoint(0.0,0.0,0.0);
	DrawWorld(&world, cameraPos, cameraAngle);
	SetTextColor(GREEN);
	DrawText(5,25, "by RorschachUK");

	SetTextColor(CYAN);
	DrawText(5,100, "Help");
	DrawText(110,100,"Start");
	DrawImage(logoImage, 5,5,RGBColor(253,255,252,0));
	DrawImage(signatureImage, 135,24,BLACK);

	Show();
	Sleep(100);
	mode=0;
}
Пример #21
0
void CreateStack(int size)
{
	const float cubeSize = 2.0f;
	const float spacing = -2.0f*gPhysicsSDK->getParameter(NX_SKIN_WIDTH);
	NxVec3 pos(0.0f, cubeSize, 0.0f);
	float offset = -size * (cubeSize * 2.0f + spacing) * 0.5f;
	while(size)
	{
		for(int i=0;i<size;i++)
		{
			pos.x = offset + (float)i * (cubeSize * 2.0f + spacing);
			CreateCube(pos, (int)cubeSize);
		}

		offset += cubeSize;
		pos.y += (cubeSize * 2.0f + spacing);
		size--;
	}
}
Пример #22
0
// Initialisierung des Rendering Kontextes
void SetupRC() {
	// Schwarzer Hintergrund
	glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
	// In Uhrzeigerrichtung zeigende Polygone sind die Vorderseiten.
	// Dies ist umgekehrt als bei der Default-Einstellung weil wir Triangle_Fans benützen
	glFrontFace(GL_CW);

	//initialisiert die standard shader
	shaderManager.InitializeStockShaders();
	transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix);

	//erzeuge die geometrie
	CreateCone(0, 0, 0);
	CreateCube(0, 0, 0);
	CreateCylinder(0, 0, 0);
	CreateSphere(0, 0, 0);

	InitGUI();
}
Пример #23
0
PxSolidObject * PxObjectFactory::GetObject(const PxRuntimeObject & ro)
{
    switch(ro.Type)
    {
    case rtoCube:
        return CreateCube(ro);
    case rtoFlag:
        return CreateFlag(ro);
    case rtoFountain:
        return CreateFountain(ro);
    case rtoSteps:
        return CreateSteps(ro);
    case rtoHoarding:
        return CreateHoarding(ro);
    case rtoModel:
        return CreateModel(ro);
    }
    return nullptr;
}
Пример #24
0
void PhysX::CreateStack(int cubeCount, float n_cubeSize)
{
	const float cubeSize = n_cubeSize/2.0f;
	const float spacing = -2.0f*m_pPhysicsSDK->getParameter(NX_SKIN_WIDTH);
	NxVec3 pos(0.0f, cubeSize, 0.0f);

	float offset = -cubeCount * (cubeSize * 2.0f + spacing) * 0.5f;
	while(cubeCount)
	{
		for(int i=0;i<cubeCount;i++)
		{
			pos.x = offset + (float)i * (cubeSize * 2.0f + spacing);
			CreateCube(pos, (int)cubeSize);
		}

		offset += cubeSize;
		pos.y += (cubeSize * 2.0f + spacing);
		cubeCount--;
	}
}
Пример #25
0
void TW_CALL SetTesselation(const void *value, void *clientData)
{
	//Pointer auf gesetzten Typ casten (der Typ der bei TwAddVarCB angegeben wurde)
	const unsigned int* uintptr = static_cast<const unsigned int*>(value);

	//Setzen der Variablen auf neuen Wert
	tess = *uintptr;
	tesselation = pow(2, tess);
	arraySize = 2 * tesselation + 2;
	doubleArraySize = 2 * arraySize;
	sphereArraySize = (tesselation*(arraySize - 1) + 1) * 2;

	//Hier kann nun der Aufruf gemacht werden um die Geometrie mit neuem Tesselierungsfaktor zu erzeugen
	//CreateCone(0.0f, 0.0f, -100.0f);
	CreateCube(-75.0f, 0.0f, 0.0f);
	CreateCylinder(0.0f, 125.0f, 0.0f);
	CreateSphere(100.0f, 0.0f, 0.0f);

	RenderScene();
}
Пример #26
0
HRESULT InitD3D( HWND hWnd )
{
	// Create the D3D object, which is needed to create the D3DDevice.
	if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
	{
		MessageBoxA(NULL, "Create D3D9 object failed!", "Error", 0) ;
		return E_FAIL;
	}

	D3DPRESENT_PARAMETERS d3dpp; 
	ZeroMemory( &d3dpp, sizeof(d3dpp) );

	d3dpp.Windowed = TRUE; // use window mode, not full screen
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
	d3dpp.EnableAutoDepthStencil = TRUE ;
	d3dpp.AutoDepthStencilFormat = D3DFMT_D16 ;

	// Create device
	if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
		D3DCREATE_SOFTWARE_VERTEXPROCESSING,
		&d3dpp, &g_pd3dDevice ) ) )
	{
		MessageBoxA(NULL, "Create D3D9 device failed!", "Error", 0) ;
		return E_FAIL;
	}

	// Enable z-buffer
	g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE) ;

	// Set cull mode
	g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE) ;

	// Disable light
	g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE) ;

	// Create cube
	CreateCube() ;

	return S_OK;
}
Пример #27
0
osg::Group* CreateStack(int size)
{
	osg::Group* stack = new osg::Group;

	const float cubeSize = 2.0f;
	const float spacing = -2.0f*gMyPhysX.getPhysXSDK()->getParameter(NX_SKIN_WIDTH);
	NxVec3 pos(0.0f, 0.0f, cubeSize+50.0);
	float offset = -size * (cubeSize * 2.0f + spacing) * 0.5f;
	while(size)
	{
		for(int i=0;i<size;i++)
		{
			pos.x = offset + (float)i * (cubeSize * 2.0f + spacing);
			stack->addChild(CreateCube(pos, (int)cubeSize));
		}

		offset += cubeSize;
		pos.z += (cubeSize * 2.0f + spacing);
		size--;
	}
	//printf("Create Stack Success!\n");
	return stack;
}
Пример #28
0
//Setup world
void InitialiseWorld() {
	world=CreateNewWorld();
	Point3d centre;
	//Camera starting point - raised 5cm off ground.
	cameraPos=CreatePoint(0.0,5.0,0.0);
	cameraAngle=CreatePoint(0.0,0.0,0.0);
	baselinePos=cameraPos;
	arrowRefAngle=0;

	//The tank
	tank=CreateTank(GREEN, CreatePoint(0,0,0), 4.5);
	tankObjectIndex=AddObjectToWorld(&world, tank);
	PlaceTank(cameraPos, cameraAngle);

	//Populate with a few shapes
	int i;
	for (i=0; i<4; i++) {
		//Random blue cubes
		centre=CreatePoint(Random(-100.0, 100.0),0.0,Random(-100.0, 100.0));
		obj=CreateCube(BLUE, centre, 4.0);
		RotateObjectYAxis(&obj, Random(0.0, 2 * PI));
		AddObjectToWorld(&world,obj);

		//Random yellow pyramids
		centre=CreatePoint(Random(-100.0, 100.0),0.0,Random(-100.0, 100.0));
		obj=CreatePyramid(YELLOW, centre, 4.0);
		RotateObjectYAxis(&obj, Random(0.0, 2 * PI));
		AddObjectToWorld(&world,obj);

		//Random red barrels
		centre=CreatePoint(Random(-100.0, 100.0),0.0,Random(-100.0, 100.0));
		obj=CreateCylinder(RED,centre, 4.0);
		RotateObjectYAxis(&obj, Random(0.0, 2 * PI));
		AddObjectToWorld(&world,obj);
	}
}
Пример #29
0
void CreateShapes(SimpleTree& _rRoot)
{
	Matrix44 prismRectangleCube0Transformation;
	setTranslation(prismRectangleCube0Transformation, Vector3(85.0f, 5.0f, 20.0f));
	CreatePrismRectangleCube(_rRoot, prismRectangleCube0Transformation);

	Matrix44 prismRectangleCube1Transformation;
	rotate(prismRectangleCube1Transformation, Math::PI / 2.0f, Vector4(0.0f, 1.0f, 0.0f, 1.0f));
	setTranslation(prismRectangleCube1Transformation, Vector3(20.0f, 5.0f, -85.0f));
	CreatePrismRectangleCube(_rRoot, prismRectangleCube1Transformation);

	Matrix44 prismRectangle0Transformation;
	setTranslation(prismRectangle0Transformation, Vector3(-90.0f, 5.0f, -20.0f));
	CreatePrismRectangle(_rRoot, prismRectangle0Transformation);

	Matrix44 prismRectangle1Transformation;
	rotate(prismRectangle1Transformation, Math::PI / 2.0f, Vector4(0.0f, 1.0f, 0.0f, 1.0f));
	setTranslation(prismRectangle1Transformation, Vector3(-20.0f, 5.0f, 90.0f));
	CreatePrismRectangle(_rRoot, prismRectangle1Transformation);

	Matrix44 cubeTransformation;
	setTranslation(cubeTransformation, Vector3(0.0f, 5.0f, 0.0f));
	CreateCube(_rRoot, cubeTransformation);
}
Пример #30
0
void getkey(unsigned char key,int x,int y)
{
	static int drawMode = 0;
	switch(key)
	{
	case 27:		
		exit(0);
		break;
	case '0':
		ResetNx();
		break;
	case '1':
		CreateCube(NxVec3(0,40,0),3);
		break;
	case '2':
		CreateCubeFromEye(2);
		break;
	case '3':
		CreateStack(10);
		break;
	case 'p':
	case 'P':
		gPauseSimulation = !gPauseSimulation;
		break;
	case 'h':
	case 'H':
		g_DisplayHelp = !g_DisplayHelp;
		break;
	case 'f':
	case 'F':
		FullScreen();
		break;
	case 't':
	case 'T':
		drawMode = ++drawMode % 3;
		if(drawMode == 0)        // fill mode
		{
			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
			glEnable(GL_DEPTH_TEST);
			glEnable(GL_CULL_FACE);
		}
		else if(drawMode == 1)  // wireframe mode
		{
			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
			glDisable(GL_DEPTH_TEST);
			glDisable(GL_CULL_FACE);
		}
		else                    // point mode
		{
			glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
			glDisable(GL_DEPTH_TEST);
			glDisable(GL_CULL_FACE);
		}
		break;
	case ' ':
		g_CameraPos = NxVec3(0.0f, 20.0f, 80.0f);
		g_CameraForward = NxVec3(0.0f,0.0f,-1.0f);
		g_fovy =90.0f;
		break;
	default:
		break;
	}
	glutPostRedisplay();
	glCheckError("getkey");
}