Exemple #1
0
void buildGraph()
{
	
	SceneObject* ball = new SceneObject("OBJs/SphereFull.txt", ballRadius, program);
	SceneObject* ball2 = new SceneObject("OBJs/smoothSphere.obj", ballRadius, program);
	SceneObject* ball3 = new SceneObject("OBJs/smoothSphere.obj", ballRadius, program);
	gmtl::Vec3f floorDimensions = gmtl::Vec3f(150.0f, 5.0f, 150.0f);
	SceneObject* floor = new SceneObject("OBJs/cube.obj", floorDimensions, program);
	gmtl::Matrix44f initialTranslation;
	gmtl::Quatf initialRotation;

		
	//Ball 1
	ball->type = BALL;
	ball->parent = NULL; 
	ball->children.clear();

	initialTranslation = gmtl::makeTrans<gmtl::Matrix44f>(gmtl::Vec3f(0.0f, floorDimensions[1] + ballDiameter+1.0f, 100.0f));
	initialTranslation.setState(gmtl::Matrix44f::TRANS);
	ball->AddTranslation(initialTranslation);
	ball->SetTexture(LoadTexture("textures/Berry_Diffuse.ppm"));
	//ball->velocity = ZERO_VECTOR;
	ball->acceleration = ZERO_VECTOR;

	sceneGraph.push_back(ball);

	//Ball 2
	ball2->type = BALL;
	ball2->parent = NULL;
	ball2->children.clear();

	initialTranslation = gmtl::makeTrans<gmtl::Matrix44f>(gmtl::Vec3f(75.0f, floorDimensions[1] + ballDiameter + 1.0f, 100.0f));
	initialTranslation.setState(gmtl::Matrix44f::TRANS);
	ball2->AddTranslation(initialTranslation);
	ball2->SetTexture(LoadTexture("textures/earth.ppm"));
	//ball->velocity = ZERO_VECTOR;
	ball2->acceleration = ZERO_VECTOR;

	sceneGraph.push_back(ball2);
	
	//Floor
	floor->type = FLOOR;
	floor->parent = NULL;
	floor->children.clear();
	initialTranslation = gmtl::makeTrans<gmtl::Matrix44f>(gmtl::Vec3f(0.0f,floorDimensions[1],0.0f));
	initialTranslation.setState(gmtl::Matrix44f::TRANS);
	floor->AddTranslation(initialTranslation);
	floor->SetTexture(LoadTexture("textures/carpet.ppm"));

	sceneGraph.push_back(floor);

	for (int i = 0; i < 4; ++i)
	{
		sceneGraph.push_back(AddWall(i, floorDimensions));
	}

	buildTable(floorDimensions);

}
Exemple #2
0
// TODO Generalize this.
SceneObject* AddWall(int i, gmtl::Vec3f floorDimensions)
{
	SceneObject* wall = new SceneObject();
	float wallHeight = 50.0f;
	switch (i)
	{
		case 0:
			wall = new SceneObject("OBJs/cube.obj", floorDimensions[0] + (ballDiameter*2), wallHeight, ballDiameter, program);
			wall->AddTranslation(gmtl::Vec3f(0.0f, wallHeight, floorDimensions[2] + ballDiameter));
			wall->type = BACK_WALL;
			break;

		case 1:
			wall = new SceneObject("OBJs/cube.obj", floorDimensions[0] + (ballDiameter * 2), wallHeight, ballDiameter, program);
			wall->AddTranslation(gmtl::Vec3f(0.0f, wallHeight, -floorDimensions[2]  - ballDiameter));
			wall->type = FRONT_WALL;
			break;

		case 2:
			wall = new SceneObject("OBJs/cube.obj", ballDiameter, wallHeight, floorDimensions[2], program);
			wall->AddTranslation(gmtl::Vec3f(floorDimensions[0] + ballDiameter, wallHeight, 0.0f));
			wall->type = RIGHT_WALL;
			break;

		case 3:
			wall = new SceneObject("OBJs/cube.obj", ballDiameter, wallHeight, floorDimensions[2], program);
			wall->AddTranslation(gmtl::Vec3f(-floorDimensions[0] - ballDiameter, wallHeight, 0.0f));
			wall->type = LEFT_WALL;
			break;
	}

	wall->parent = NULL;
	wall->children.clear();
	wall->SetTexture(LoadTexture("textures/dirt.ppm"));
	wall->mass = FLT_MAX;
	return wall;
}
Exemple #3
0
void buildTable(gmtl::Vec3f floorDimensions)
{
	float legHeight = 20.0f,
		legY = (floorDimensions[1] * 2.0f) + legHeight, //Y
		tableWidth = 25.0f,  //X
		tableLength = 25.0f; //Z

	SceneObject* tableTop = new SceneObject("OBJs/cube.obj", tableWidth, floorDimensions[1], tableLength, program);
	tableTop->AddTranslation(gmtl::Vec3f(0.0f, legY+floorDimensions[1]+legHeight, 0.0f));
	tableTop->type = TABLETOP;
	tableTop->parent = NULL;
	tableTop->SetTexture(LoadTexture("textures/dirt.ppm"));
	tableTop->children.clear();

	sceneGraph.push_back(tableTop);

	SceneObject* brleg = new SceneObject("OBJs/cylinder.obj", ballRadius, legHeight, program);
	brleg->AddTranslation(gmtl::Vec3f(tableWidth - ballRadius, legY, -(tableWidth - ballRadius)));
	brleg->type = LEG;
	brleg->parent = NULL;
	brleg->SetTexture(LoadTexture("textures/dirt.ppm"));
	brleg->children.clear();
	brleg->mass = FLT_MAX;
	brleg->velocity = ZERO_VECTOR;

	sceneGraph.push_back(brleg);

	SceneObject* blleg = new SceneObject("OBJs/cylinder.obj", ballRadius, legHeight, program);
	blleg->AddTranslation(gmtl::Vec3f(-(tableWidth - ballRadius), legY, -(tableWidth - ballRadius)));
	blleg->type = LEG;
	blleg->parent = NULL;
	blleg->SetTexture(LoadTexture("textures/dirt.ppm"));
	blleg->children.clear();
	blleg->mass = FLT_MAX;
	blleg->velocity = ZERO_VECTOR;

	sceneGraph.push_back(blleg);

	SceneObject* frleg = new SceneObject("OBJs/cylinder.obj", ballRadius, legHeight, program);
	frleg->AddTranslation(gmtl::Vec3f(tableWidth - ballRadius, legY, tableWidth - ballRadius));
	frleg->type = LEG;
	frleg->parent = NULL;
	frleg->SetTexture(LoadTexture("textures/dirt.ppm"));
	frleg->children.clear();
	frleg->mass = FLT_MAX;
	frleg->velocity = ZERO_VECTOR;

	attractLeg = frleg;
	sceneGraph.push_back(frleg);	

	SceneObject* flleg = new SceneObject("OBJs/cylinder.obj", ballRadius, legHeight, program);
	flleg->AddTranslation(gmtl::Vec3f(-(tableWidth - ballRadius), legY, tableWidth - ballRadius));
	flleg->type = LEG;
	flleg->parent = NULL;
	flleg->SetTexture(LoadTexture("textures/dirt.ppm"));
	flleg->children.clear();
	flleg->mass = FLT_MAX;
	flleg->velocity = ZERO_VECTOR;

	sceneGraph.push_back(flleg);


}