コード例 #1
0
void init()
{

	glClearColor(1.0,1.0,1.0,0.0);						//sets the clear colour to yellow
					//glClear(GL_COLOR_BUFFER_BIT) in the display function//will clear the buffer to this colour.

	// Shaders
	if(!myShader.load("BasicView", "glslfiles/basicTransformations.vert", "glslfiles/basicTransformations.frag"))
	{
		cout << "failed to load shader" << endl;
	}							
	if (!cubeShader.load("BasicView", "glslfiles/cubeShader.vert", "glslfiles/cubeShader.frag"))
	{
		cout << "failed to load shader" << endl;
	}
	cubeOne.setDim(15);
	cubeOne.constructGeometry(&cubeShader);
	worldCube.setDim(1000);
	worldCube.constructGeometry(&cubeShader);

	glEnable(GL_TEXTURE_2D);

	
	copter.loadModel(myShader);
	prop.loadModel(myShader);
	world.loadModel(myShader);
	ground.loadModel(myShader);
	houseOne.loadModel(myShader, "TestModels/dododododhouse2.obj", glm::vec3(50, 44, 50), 
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 0);
	houseTwo.loadModel(myShader, "TestModels/pyramidhouse2.obj", glm::vec3(-1250, 44, 1000),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 0);
	houseThree.loadModel(myShader, "TestModels/pyramidhouse2.obj", glm::vec3(-500, 44, -500),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 0);
	houseFour.loadModel(myShader, "TestModels/pyramidhouse2.obj", glm::vec3(1200, 44, 1200),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 0);
	houseFive.loadModel(myShader, "TestModels/dododododhouse2.obj", glm::vec3(50, 44, -1150),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 0);
	houseSix.loadModel(myShader, "TestModels/dododododhouse2.obj", glm::vec3(-900, 44, -500),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 0);
	treeOne.loadModel(myShader, "TestModels/tree.obj", glm::vec3(250, 20, 250),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50);
	treeTwo.loadModel(myShader, "TestModels/tree.obj", glm::vec3(350, 20, 250),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50);
	treeThree.loadModel(myShader, "TestModels/tree.obj", glm::vec3(300, 20, 250),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50);
	treeFour.loadModel(myShader, "TestModels/tree.obj", glm::vec3(0, 20, 750),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50);
	treeFive.loadModel(myShader, "TestModels/tree.obj", glm::vec3(200, 20, 180),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50);
	treeOne.loadModel(myShader, "TestModels/tree.obj", glm::vec3(-900, 20, 580),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50);
	treeTwo.loadModel(myShader, "TestModels/tree.obj", glm::vec3(1040, 20, 1050),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50);
	treeThree.loadModel(myShader, "TestModels/tree.obj", glm::vec3(-1260, 20, -250),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50);
	treeFour.loadModel(myShader, "TestModels/tree.obj", glm::vec3(1270, 20, 250),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50);
	treeFive.loadModel(myShader, "TestModels/tree.obj", glm::vec3(-230, 20, 250),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50);
	leafOne.loadModel(myShader, "TestModels/leaf.obj", glm::vec3(150, -10, 580),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50);
	leafTwo.loadModel(myShader, "TestModels/leaf.obj", glm::vec3(170, -10, 530),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50);
	leafThree.loadModel(myShader, "TestModels/leaf.obj", glm::vec3(150, -10, 550),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50);
	leafFour.loadModel(myShader, "TestModels/leaf.obj", glm::vec3(150, -10, 510),
		glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50);
	
	houses.push_back(houseOne);
	houses.push_back(houseTwo);
	houses.push_back(houseThree);
	houses.push_back(houseFour);
	houses.push_back(houseFive);
	houses.push_back(houseSix);
	trees.push_back(treeOne);
	trees.push_back(treeTwo);
	trees.push_back(treeThree);
	trees.push_back(treeFour);
	trees.push_back(treeFive);
	trees.push_back(treeSix);
	trees.push_back(treeSeven);
	trees.push_back(treeEight);
	trees.push_back(treeNine);
	trees.push_back(treeTen);
	leafs.push_back(leafOne);
	leafs.push_back(leafTwo);
	leafs.push_back(leafThree);
	leafs.push_back(leafFour);
	glEnable(GL_DEPTH_TEST);

	
}
コード例 #2
0
ファイル: handle.cpp プロジェクト: ppearson/ImaginePartial
void Handle::initAxisHandleObjects()
{
	// assumes none of them have been created yet

	Handle::pObjectXTranslateHandleLine = new Cylinder(1.0f, 0.03f, 6, 1);
	Handle::pObjectYTranslateHandleLine = new Cylinder(1.0f, 0.03f, 6, 1);
	Handle::pObjectZTranslateHandleLine = new Cylinder(1.0f, 0.03f, 6, 1);

	Handle::pObjectXTranslateHandleHead = new Cone(0.2f, 0.07f, 8);
	Handle::pObjectYTranslateHandleHead = new Cone(0.2f, 0.07f, 8);
	Handle::pObjectZTranslateHandleHead = new Cone(0.2f, 0.07f, 8);

	Cylinder *pX = Handle::pObjectXTranslateHandleLine;
	Cylinder *pY = Handle::pObjectYTranslateHandleLine;
	Cylinder *pZ = Handle::pObjectZTranslateHandleLine;

	pX->setObjectID(eXTranslate);
	pX->setPosition(Point(0.6f, 0.0f, 0.0f));
	pX->rotate(0.0f, 0.0f, 90.0f);
	pX->constructGeometry();

	pY->setObjectID(eYTranslate);
	pY->setPosition(Point(0.0f, 0.6f, 0.0f));
	pY->constructGeometry();

	pZ->setObjectID(eZTranslate);
	pZ->setPosition(Point(0.0f, 0.0f, 0.6f));
	pZ->rotate(-90.0f, 0.0f, 0.0f);
	pZ->constructGeometry();

	Cone *pXHead = Handle::pObjectXTranslateHandleHead;
	Cone *pYHead = Handle::pObjectYTranslateHandleHead;
	Cone *pZHead = Handle::pObjectZTranslateHandleHead;

	pXHead->setObjectID(eXTranslate);
	pXHead->setPosition(Point(1.1f, 0.0f, 0.0f));
	pXHead->rotate(0.0f, 0.0f, -90.0f);
	pXHead->constructGeometry();

	pYHead->setObjectID(eYTranslate);
	pYHead->setPosition(Point(0.0f, 1.1f, 0.0f));
	pYHead->constructGeometry();

	pZHead->setObjectID(eZTranslate);
	pZHead->setPosition(Point(0.0f, 0.0f, 1.1f));
	pZHead->rotate(90.0f, 0.0f, 0.0f);
	pZHead->constructGeometry();

	/// object rotate

	Torus* pXRotate = new Torus(kObjectRotateHandleThickness, kObjectRotateHandleRadius, kObjectRotateHandleSegments, kObjectRotateHandleSides);
	Torus* pYRotate = new Torus(kObjectRotateHandleThickness, kObjectRotateHandleRadius, kObjectRotateHandleSegments, kObjectRotateHandleSides);
	Torus* pZRotate = new Torus(kObjectRotateHandleThickness, kObjectRotateHandleRadius, kObjectRotateHandleSegments, kObjectRotateHandleSides);

	Handle::pObjectXRotateHandleLoop = pXRotate;
	Handle::pObjectYRotateHandleLoop = pYRotate;
	Handle::pObjectZRotateHandleLoop = pZRotate;

	pXRotate->setObjectID(eXRotate);
	pXRotate->rotate(0.0f, 0.0f, -90.0f);
	pXRotate->constructGeometry();

	pYRotate->setObjectID(eYRotate);
	pYRotate->rotate(0.0f, 0.0f, 0.0f);
	pYRotate->constructGeometry();

	pZRotate->setObjectID(eZRotate);
	pZRotate->rotate(90.0f, 0.0f, 0.0f);
	pZRotate->constructGeometry();

	/// face

	Handle::pFaceNormalTranslateHandleLine = new Cylinder(1.0f, 0.03f, 6, 1);
	Handle::pFaceNormalTranslateHandleHead = new Cone(0.2f, 0.07f, 8);
	Handle::pFaceExtrude = new Cube(0.05f);

	Cylinder* pFaceNormalLine = Handle::pFaceNormalTranslateHandleLine;
	pFaceNormalLine->setObjectID(eFaceNormalTranslate);
	pFaceNormalLine->setPosition(Point(0.0f, 0.6f, 0.0f));
	pFaceNormalLine->constructGeometry();

	Cone* pFaceNormalHead = Handle::pFaceNormalTranslateHandleHead;
	pFaceNormalHead->setObjectID(eFaceNormalTranslate);
	pFaceNormalHead->setPosition(Point(0.0f, 1.1f, 0.0f));
	pFaceNormalHead->constructGeometry();

	Cube* pFaceExtrude = Handle::pFaceExtrude;
	pFaceExtrude->setObjectID(eFaceExtrude);
	pFaceExtrude->setPosition(Point(0.0f, 1.4f, 0.0f));
	pFaceExtrude->constructGeometry();

	Handle::pFaceTranslateXLine = new Cylinder(1.0f, 0.03f, 6, 1);
	Handle::pFaceTranslateYLine = new Cylinder(1.0f, 0.03f, 6, 1);

	Cylinder* pFaceTranslateXLine = Handle::pFaceTranslateXLine;
	pFaceTranslateXLine->setObjectID(eFaceTranslateX);
	pFaceTranslateXLine->setRotation(Vector(0.0f, 0.0f, -90.0f));
	pFaceTranslateXLine->setPosition(Point(0.6f, 0.0f, 0.0f));
	pFaceTranslateXLine->constructGeometry();

	Cylinder* pFaceTranslateYLine = Handle::pFaceTranslateYLine;
	pFaceTranslateYLine->setObjectID(eFaceTranslateY);
	pFaceTranslateYLine->setRotation(Vector(90.0f, 0.0f, 0.0f));
	pFaceTranslateYLine->setPosition(Point(0.0f, 0.0f, 0.6f));
	pFaceTranslateYLine->constructGeometry();

	Handle::pFaceTranslateXHead = new Cone(0.2f, 0.07f, 8);
	Handle::pFaceTranslateYHead = new Cone(0.2f, 0.07f, 8);

	Cone* pFaceTranslateXHead = Handle::pFaceTranslateXHead;
	pFaceTranslateXHead->setObjectID(eFaceTranslateX);
	pFaceTranslateXHead->setRotation(Vector(0.0f, 0.0f, -90.0f));
	pFaceTranslateXHead->setPosition(Point(1.1f, 0.0f, 0.0f));
	pFaceTranslateXHead->constructGeometry();

	Cone* pFaceTranslateYHead = Handle::pFaceTranslateYHead;
	pFaceTranslateYHead->setObjectID(eFaceTranslateY);
	pFaceTranslateYHead->setRotation(Vector(90.0f, 0.0f, 0.0f));
	pFaceTranslateYHead->setPosition(Point(0.0f, 0.0f, 1.1f));
	pFaceTranslateYHead->constructGeometry();

	//

	Handle::pFaceScaleX = new Cube(0.05f);
	Handle::pFaceScaleY = new Cube(0.05f);
	Handle::pFaceScaleUniform = new Cube(0.05f);
	Cube* pFaceScaleX = Handle::pFaceScaleX;
	pFaceScaleX->setObjectID(eFaceScaleX);
	pFaceScaleX->setPosition(Point(1.4f, 0.0f, 0.0f));
	pFaceScaleX->setRotation(Vector(-90.0f, 0.0f, 0.0f));
	pFaceScaleX->constructGeometry();

	Cube* pFaceScaleY = Handle::pFaceScaleY;
	pFaceScaleY->setObjectID(eFaceScaleY);
	pFaceScaleY->setPosition(Point(0.0f, 0.0f, 1.4f));
	pFaceScaleY->constructGeometry();

	Cube* pFaceScaleUniform = Handle::pFaceScaleUniform;
	pFaceScaleUniform->setObjectID(eFaceScaleUniform);
	pFaceScaleUniform->setPosition(Point(1.4f, 0.0f, 1.4f));
	pFaceScaleUniform->constructGeometry();
}