コード例 #1
0
ファイル: PlaneModel.cpp プロジェクト: ruttyj/GraphicsAhoy
void PlaneModel::MakeRudder(){
	


	//########################################################################################

	//Rudder
	GroupModel* rudder = new GroupModel();
	vec3 rudderSize = vec3(0.07f,1.15f, 1.0f);
	vec3 rudderColor = vec3(1,0,0);
	if(1){//Right
		GroupModel* group = new GroupModel();
			CubeModel* model = new CubeModel(rudderColor);
			model->SetPosition(vec3(0.0f,0.5f,-2.0f));
			model->SetRotation(vec3(1.0f,0.0f,0.0f), -30.0f);	
			model->SetScaling(rudderSize);
		group->AddChild(model);
		group->SetRotation(vec3(0,0,1), 45.0f);
		rudder->AddChild(group);
	}
	if(1){//Left
		GroupModel* group = new GroupModel();
			CubeModel* model = new CubeModel(rudderColor);
			model->SetPosition(vec3(0.0f,0.5f,-2.0f));
			model->SetRotation(vec3(1.0f,0.0f,0.0f), -30.0f);	
			model->SetScaling(rudderSize);
		group->AddChild(model);
		group->SetRotation(vec3(0,0,1), -45.0f);
		rudder->AddChild(group);
	}
	rudder->SetRotation(vec3(0.0f,0.0f,1.0f), 0.0f);
	AddChild("rudder",rudder);
	//*////////////////////////////////////////////////////
	//$#%^$#$^Y$T#%^&%$#W$^&$#%^&%$#%^&&%^$#$%^&%%$#$$^%#$%
	//Model Testing :: Transforms on multiple layers
	


	//########################################################################################
}
コード例 #2
0
ファイル: CubeModel.cpp プロジェクト: tanjil/COMP371
void CubeModel::handleBeginContact(q3Box * box){
	if (mBreakable){
		
		std::cout << "Breakable model contact" << std::endl;
		
		// Queue this object's removal
		World::GetInstance()->RemoveModel(this);

		// break into 8 evenly sized pieces
		vec3 size = mScaling / 2.0f;
		vec3 pos = size / 2.0f;
		for (int x = 0; x < 2; ++x){
			for (int y = 0; y < 2; ++y){
				for (int z = 0; z < 2; ++z){
					CubeModel *shard = new CubeModel();
					shard->SetPosition(mPosition +
						glm::vec3(
							pos.x * (x ? 1 : -1),
							pos.y * (y ? 1 : -1),
							pos.z * (z ? 1 : -1)
						));
					shard->SetScaling(size);
					shard->SetPhysicsType(Dynamic);
					shard->SetBreakable(false);

					auto body = new q3BodyDef(shard->GetBodyDef());
					auto box = new q3BoxDef(shard->GetBoxDef());

					auto transform = mBody->GetTransform();
					transform.position = { 0, 0, 0 };

					box->Set(transform, g2q(size));

					World::GetInstance()->AddModel(shard, body, box);
				}
			}
		}

	}
}
コード例 #3
0
VehicleModel::VehicleModel()
{
	angularSpeedXAxis = 900.0f;
	angularSpeedYAxis = 720.0f;
	
	// @TODO 5 - Layout your vehicle in a hierarchy
	CubeModel * mBody = new CubeModel(this);
	CubeModel * mFront = new CubeModel(mBody);
	CubeModel * mTail = new CubeModel(mBody);
	CubeModel * mTailWing = new CubeModel(mTail);
	CubeModel * mShaft = new CubeModel(mBody);
	CubeModel * mBlade1 = new CubeModel(mShaft);
	CubeModel * mBlade2 = new CubeModel(mShaft);
	CubeModel * mTailBlade1 = new CubeModel(mTailWing);
	CubeModel * mTailBlade2 = new CubeModel(mTailWing);

	// Body
	container.push_back(mBody);

    // Front
    mFront->SetPosition(glm::vec3(0.0f, -0.25f, 0.75f));
    mFront->SetScaling(glm::vec3(1.0f, 0.5f, 0.75f));
    container.push_back(mFront);

    // Tail
    mTail->SetPosition(glm::vec3(0.0f, -0.0f, -1.4f));
    mTail->SetScaling(glm::vec3(0.25f, 0.5f, 1.9f));
    container.push_back(mTail);

    // Tail Wing
    mTailWing->SetPosition(glm::vec3(0.0f, 0.25f, -0.7f));
    mTailWing->SetScaling(glm::vec3(1.0f, 1.5f, 0.4f));
    container.push_back(mTailWing);

    // Shaft
    mShaft->SetPosition(glm::vec3(0.0f, 0.55f, 0.0f));
    mShaft->SetScaling(glm::vec3(0.1f, 0.5f, 0.1f));
    container.push_back(mShaft);

    // Blade1
    mBlade1->SetPosition(glm::vec3(0.0f, 0.5f, 0.0f));
    mBlade1->SetScaling(glm::vec3(35.0f, 0.1f, 1.0f));
    container.push_back(mBlade1);
    rotatingYAxis.push_back(mBlade1);

    // Blade2
    mBlade2->SetPosition(glm::vec3(0.0f, 0.5f, 0.0f));
    mBlade2->SetScaling(glm::vec3(1.0f, 0.1f, 35.0f));
    container.push_back(mBlade2);
    rotatingYAxis.push_back(mBlade2);

    // TailBlade1
    mTailBlade1->SetPosition(glm::vec3(0.65f, 0.35f, -0.35f));
    mTailBlade1->SetScaling(glm::vec3(0.2f, 2.25f, 0.15f));
    container.push_back(mTailBlade1);
    rotatingXAxis.push_back(mTailBlade1);

    // TailBlade2
    mTailBlade2->SetPosition(glm::vec3(0.65f, 0.35f, -0.35f));
    mTailBlade2->SetScaling(glm::vec3(0.2f, 0.15f, 2.25f));
    container.push_back(mTailBlade2);
    rotatingXAxis.push_back(mTailBlade2);
}