Esempio n. 1
0
void ObjectMan::UpdateObjectsWithInput()
{
	Geometry* car = GetInstance()->objectMap[CAR];
	float z = InputMan::GetMovementBackward() - InputMan::GetMovementForward();
	float x = InputMan::GetMovementRight() - InputMan::GetMovementLeft();
	bool accel = InputMan::GetAccel();
	car->Translate(accel * x * TRANSLATE_SCALE, 0.0, accel * z * TRANSLATE_SCALE);
}
Esempio n. 2
0
void ObjectMan::LoadObjects()
{
	ifstream enlistments(ENLISTMENTS);
	
	if(!enlistments.is_open())
	{
		cout << "Bad models.enlistments file:" << endl
			<< "\tMake sure you have a models.enlistments file in your models "
			<< "directory that contains the names of each object. Leave off the "
			<< "file extension. Textures should have the same name." << endl;
		return;
	}

	cout << "Loading Objects:" << endl;

	while(enlistments.good())
	{
		string line;
		getline(enlistments, line);

		if (line.find("#") == 0 || line.empty())
		{
			// Comment or empty line in enlistments - skip over it
			continue;
		}

		string obj_id;
		string filename;
		float tx, ty, tz, rx, ry, rz, sx, sy, sz;
		string parent_id;

		istringstream iss(line);
		iss >> obj_id;
		iss >> filename;
		iss >> tx;
		iss >> ty;
		iss >> tz;
		iss >> rx;
		iss >> ry;
		iss >> rz;
		iss >> sx;
		iss >> sy;
		iss >> sz;
		iss >> parent_id;

		bool collidable = false;
		if (filename.find("::") != string::npos)
		{
			collidable = true;
			filename = filename.substr(0, filename.find("::"));
		}

		Geometry* obj = LoadObject(obj_id, filename, collidable, parent_id);

		cout << "\t\tTransformations...";

		obj->Translate(tx, ty, tz);
		obj->Rotate(rx, ry, rz);
		obj->Scale(sx, sy, sz);

		cout << "DONE." << endl;

		LoadTexture(obj_id, filename);
	}

	cout << "Loading Complete." << endl << endl;
}