コード例 #1
0
ファイル: main.cpp プロジェクト: jolin1337/opgl-Test-Projects
int init_resources(void) {
	try{
		player.moveLeft(9);
		player.moveForward(7);
		player.rotateX(-M_PI*3/4);
		player.rotateY(M_PI/12);
		player.addForce(gravity*-1);

		player.loadObj("crazy.o");
		cube.loadObj("cube.o");
		cube2.loadObj("cube.o");

		setupBuffers(player);
		setupBuffers(cube);
		setupBuffers(cube2);

		addObjectToShader(&cube);
		addObjectToShader(&cube2);
		bool c1 = cube.loadShaders(vertexShaderFileName, fragmentShaderFileName),
			 c2 = cube2.loadShaders(vertexShaderFileName, fragmentShaderFileName);
		Vector3 pos = cube2.getPosition()+ Vector3(0.5f, 3.5f, 1.5f);
		cube2.setPosition(pos);
		//cube2.setRotation(Vector3(30*M_PI/180, 0, 40*M_PI/180));
		return c1 * c2;
	}catch(int i){
		return 0;
	}
}
コード例 #2
0
ファイル: main.cpp プロジェクト: jolin1337/opgl-Test-Projects
int init_resources(void) {
	try{
		player.moveLeft(9);
		player.moveForward(7);
		player.rotateX(-M_PI*3/4);
		player.rotateY(M_PI/12);
		player.addForce(gravity*-1);

		player.loadObj("crazy.o");
		cube.loadObj("cube.o");
		cube2.loadObj("cube.o");

		setupBuffers(player);
		setupBuffers(cube);
		setupBuffers(cube2);

		addObjectToShader(&cube);
		addObjectToShader(&cube2);
		bool c1 = cube.loadShaders(vertexShaderFileName, fragmentShaderFileName),
			 c2 = cube2.loadShaders(vertexShaderFileName, fragmentShaderFileName),
			 c3 = 1;

		for(int i=0; i< BALLS; i++){
			balls[i].loadObj("crazy.o");
			balls[i].setScale(Vector3(0.25f,0.25f,0.25f));
			setupBuffers(balls[i]);
			addObjectToShader(&(balls[i]));
			c3 *= balls[i].loadShaders(vertexShaderFileName, fragmentShaderFileName);

			balls[i].addVelocity(Vector3(m_rand()-0.5f, m_rand()-0.5f, m_rand()-0.5f).normalize().mult(60.0));
		}
		GLfloat scale_grid = ((GLfloat)DETAIL_GRID*2.0f)/((GLfloat)BOUNDARY);
		for(int i=0; i< DETAIL_GRID; i++){
			for(int j = 0;j < DETAIL_GRID; j++){
				grid[i].loadObj("cube.o");

				grid[i].setScale(Vector3(scale_grid, scale_grid, scale_grid));
				setupBuffers(grid[i]);
				addObjectToShader(&(grid[i]));
				c3 *= grid[i].loadShaders(vertexShaderFileName, fragmentShaderFileName);


				grid[i].setPosition(Vector3(i*scale_grid, j*scale_grid, k*scale_grid - DETAIL_GRID-2.0f));
				/*if(i%6 == 0)
					grid[i].setPosition(Vector3(DETAIL_GRID + 1.0f, (i-3)*scale_grid-DETAIL_GRID, (i-3)*scale_grid-DETAIL_GRID));
				else if(i%6 == 1)
					grid[i].setPosition(Vector3((i-2)*scale_grid-DETAIL_GRID, DETAIL_GRID + 1.0f, (i-2)*scale_grid-DETAIL_GRID));
				else if(i%6 == 2)
					grid[i].setPosition(Vector3((i-1)*scale_grid-DETAIL_GRID, (i-1)*scale_grid-DETAIL_GRID, DETAIL_GRID + 1.0f));
				else if(i%6 == 3)
					grid[i].setPosition(Vector3(-DETAIL_GRID - 1.0f , i*scale_grid-DETAIL_GRID, i*scale_grid-DETAIL_GRID));
				else if(i%6 == 4)
					grid[i].setPosition(Vector3((i+1)*scale_grid-DETAIL_GRID, -DETAIL_GRID - 1.0f, (i+1)*scale_grid-DETAIL_GRID));
				else if(i%6 == 5)
					grid[i].setPosition(Vector3((i+2)*scale_grid-DETAIL_GRID, (i+2)*scale_grid-DETAIL_GRID, -DETAIL_GRID - 1.0f));*/
			}
		}
		Vector3 pos = cube2.getPosition()+ Vector3(0.5f, 3.5f, 1.5f);
		cube2.setPosition(pos);
		//cube2.setRotation(Vector3(30*M_PI/180, 0, 40*M_PI/180));
		return c1 * c2 * c3;
	}catch(int i){
		return 0;
	}
}