void PlaneModel::MakePropeller(){ //######################################################################################## //-------------------------------------------------- //* Front Propeller if(true){ GroupModel* propeller = new GroupModel(); float bladeLength = 0.6f; int blades = 8; for(int i=0; i<blades;i++){ GroupModel* blade = new GroupModel(); SphereModel* sphere = new SphereModel(); sphere->SetScaling(vec3(bladeLength, 0.06f, 0.1f)); sphere->SetPosition(vec3(bladeLength/2, 0.0f, 0.0f)); sphere->SetRotation(vec3(1.0f, 0.0f, 0.0f), 45.0f); blade->AddChild(sphere); blade->SetRotation(vec3(0.0f,0.0f,2.0f), i*(360.0f/blades)); propeller->AddChild(blade); } propeller->SetPosition(vec3(0.0f,0.0f,2.5f)); propeller->SetRotation(vec3(0.0f,0.0f,1.0f), 0.0f); propeller->SetRotationSpeed(5.0f*180.0f); AddChild("propeller", propeller); } //*/ }
void PlaneModel::MakeBody(){ //######################################################################################## if(1){//body SphereModel* model = new SphereModel(color); model->SetScaling(vec3(0.8f, 0.5f, 2.5f)); model->SetPosition(vec3(0.0f, 0.0f, 0.0f)); //model->SetRotation(vec3(0.0f, 1.0f, 0.0f), 45.0f); AddChild("body", model); } //######################################################################################## if(1){//cockpit GroupModel* group = new GroupModel(); if(1){ //glass float col = mBlack; SphereModel* model = new SphereModel(vec3(col,col,col)); model->SetScaling(vec3(0.5f, 0.4f, 1.7f)); model->SetPosition(vec3(0.0f, 0.3f, 0.0f)); //model->SetRotation(vec3(0.0f, 1.0f, 0.0f), 45.0f); group->AddChild("glass", model); } if(1){ //back SphereModel* model = new SphereModel(color); model->SetScaling(vec3(0.5f, 0.4f, 2.0f)); model->SetPosition(vec3(0.0f, 0.3f, -0.4f)); //model->SetRotation(vec3(0.0f, 1.0f, 0.0f), 45.0f); group->AddChild("back",model); } AddChild("cockpit", group); group->mRotationAngleX = -5.0f; } }
void World::LoadScene(const char * scene_path) { // Using case-insensitive strings and streams for easier parsing ci_ifstream input; input.open(scene_path, ios::in); // Invalid file if(input.fail() ) { fprintf(stderr, "Error loading file: %s\n", scene_path); getchar(); exit(-1); } ci_string item; while( std::getline( input, item, '[' ) ) { ci_istringstream iss( item ); ci_string result; if( std::getline( iss, result, ']') ) { if( result == "cube" ) { // Box attributes CubeModel* cube = new CubeModel(); cube->Load(iss); mModel.push_back(cube); } else if( result == "sphere" ) { SphereModel* sphere = new SphereModel(); sphere->Load(iss); mModel.push_back(sphere); } else if( result == "path" ) { Path* path = new Path(); path->Load(iss); mPath.push_back(path); } else if( result == "spline" ) { BSpline* path = new BSpline(); path->Load(iss); mSpline.push_back(path); } else if ( result.empty() == false && result[0] == '#') { // this is a comment line } else { fprintf(stderr, "Error loading scene file... !"); getchar(); exit(-1); } } } input.close(); // Set PATH vertex buffers for (vector<Path*>::iterator it = mPath.begin(); it < mPath.end(); ++it) { // Draw model (*it)->CreateVertexBuffer(); } // Set B-SPLINE vertex buffers for (vector<BSpline*>::iterator it = mSpline.begin(); it < mSpline.end(); ++it) { // Draw model (*it)->CreateVertexBuffer(); } //LOAD DAT OBJ MODEL YO vector<OBJModel*> pokemon = PokemonGenerator::GeneratePokemon(); for (int i = 0; i < pokemon.size(); i++) mModel.push_back(pokemon[i]); srand(20); OBJModel* grass = new OBJModel("../Models/Grass_02.obj"); for (int i = 0; i < 50; i++){ OBJModel* newgrass = new OBJModel(*grass); newgrass->SetPosition(vec3(rand() % 150 - 75, 0, rand() % 150 - 75)); newgrass->SetScaling(vec3(1, 1, 1)); mModel.push_back(newgrass); } // DAYTIME - default groundDay = new SkyboxModel("../Models/cube.obj"); groundDay->SetSwitch(true); groundDay->SetPosition(vec3(0, -2.5, 0)); groundDay->SetScaling(vec3(150, 5, 150)); mModel.push_back(groundDay); skyboxDay = new SkyboxModel("../Models/ds.obj"); skyboxDay->SetSwitch(true); skyboxDay->SetPosition(vec3(0, 60, 0)); skyboxDay->SetScaling(vec3(80, 80, 80)); mModel.push_back(skyboxDay); // NIGHTTIME groundNight = new SkyboxModel("../Models/cube2.obj"); groundNight->SetSwitch(false); groundNight->SetPosition(vec3(0, -2.5, 0)); groundNight->SetScaling(vec3(150, 5, 150)); mModel.push_back(groundNight); skyboxNight = new SkyboxModel("../Models/ns.obj"); skyboxNight->SetSwitch(false); skyboxNight->SetPosition(vec3(0, 60, 0)); skyboxNight->SetScaling(vec3(80, 80, 80)); mModel.push_back(skyboxNight); LoadCameras(); }
void World::LoadScene(const char * scene_path) { // Using case-insensitive strings and streams for easier parsing ci_ifstream input; input.open(scene_path, ios::in); // Invalid file if(input.fail() ) { fprintf(stderr, "Error loading file: %s\n", scene_path); getchar(); exit(-1); } ci_string item; while( std::getline( input, item, '[' ) ) { ci_istringstream iss( item ); ci_string result; if( std::getline( iss, result, ']') ) { if( result == "cube" ) { // Box attributes CubeModel* cube = new CubeModel(); cube->Load(iss); mModel.push_back(cube); } else if( result == "tank" ) { // Box attributes tank = new TankModel(); tank->Load(iss); mModel.push_back(tank); mCamera.at(0)->setTarget(tank); mCamera.at(1)->setTarget(tank); } else if (result == "alien") { // Box attributes AlienModel* alien = new AlienModel(); Missile* mis = new Missile(tank); AlienCubeModel* pos = new AlienCubeModel(); pos->SetMissile(mis); pos->Load(iss); alien->Load(iss); mModel.push_back(mis); mModel.push_back(pos); mModel.push_back(alien); } else if( result == "vehicle" ) { // Box attributes VehicleModel* vehicle = new VehicleModel(); vehicle->Load(iss); mModel.push_back(vehicle); } else if( result == "sphere" ) { SphereModel* sphere = new SphereModel(); sphere->Load(iss); mModel.push_back(sphere); } else if( result == "light" ) { LightModel* light = new LightModel(); light->Load(iss); mLightModels.push_back(light); } else if( result == "sun" ) { SunModel* sun = new SunModel(); sun->Load(iss); mModel.push_back(sun); LightModel* light = new LightModel(sun); light->Load(iss); mLightModels.push_back(light); } else if( result == "moon" ) { MoonModel* moon = new MoonModel(); moon->Load(iss); mModel.push_back(moon); } else if( result == "bspline" ) { BSpline* bSpline = new BSpline(); bSpline->Load(iss); mBSplineModels.push_back(bSpline); } else if (result == "textured_cube") { TexturedCube* texturedCube = new TexturedCube(); texturedCube->Load(iss); mModel.push_back(texturedCube); } else if (result == "triangle") { TriangleModel* triangle = new TriangleModel(); triangle->Load(iss); mModel.push_back(triangle); } else if (result == "particleEmitter") { ParticleEmitter* particleEmitter = new ParticleEmitter(vec4(1.0f, 0.0f, 0.0f, 0.0f), vec4(1.0f, 0.0f, 0.0f, 0.0f)); particleEmitter->Load(iss); mModel.push_back(particleEmitter); mParticleEmitterModels.push_back(particleEmitter); particleEmitter->SetLightSource(mLightModels.back()); particleEmitter->GenerateParticles(); } else if (result == "cubesm") { CubeModelSM* cubesm = new CubeModelSM(); cubesm->Load(iss); mModel.push_back(cubesm); } else if ( result.empty() == false && result[0] == '#') { // this is a comment line } else { fprintf(stderr, "Error loading scene file... !"); getchar(); exit(-1); } } } input.close(); for (vector<Model*>::iterator it = mModel.begin(); it < mModel.end(); ++it) { // Temporary for single light source (*it)->SetLightSource(mLightModels.back()); } }
void World::LoadScene(const char * scene_path) { // Using case-insensitive strings and streams for easier parsing ci_ifstream input; input.open(scene_path, ios::in); // Invalid file if (input.fail()) { fprintf(stderr, "Error loading file: %s\n", scene_path); getchar(); exit(-1); } ci_string item; while (std::getline(input, item, '[')) { ci_istringstream iss(item); ci_string result; if (std::getline(iss, result, ']')) { if (result == "player") { // Box attributes PlayerModel* player = new PlayerModel(); player->Load(iss); mModel.push_back(player); mPlayerModel = player; } else if (result == "discoball") { // Box attributes Discoball* discoBallz = new Discoball(); discoBallz->Load(iss); mModel.push_back(discoBallz); } else if (result == "bunnny") { // Box attributes BunnyModel* bunny = new BunnyModel(); bunny->Load(iss); mModel.push_back(bunny); } else if (result == "barrel") { // Box attributes BarrelModel* barrel = new BarrelModel(); barrel->Load(iss); mModel.push_back(barrel); } else if (result == "cube") { // Box attributes CubeModel* cube = new CubeModel(); cube->Load(iss); mModel.push_back(cube); } else if (result == "sphere") { SphereModel* sphere = new SphereModel(); sphere->Load(iss); mModel.push_back(sphere); } else if (result == "animationkey") { AnimationKey* key = new AnimationKey(); key->Load(iss); mAnimationKey.push_back(key); } else if (result == "animation") { Animation* anim = new Animation(); anim->Load(iss); mAnimation.push_back(anim); } else if (result.empty() == false && result[0] == '#') { // this is a comment line } else { fprintf(stderr, "Error loading scene file... !"); getchar(); exit(-1); } } } input.close(); if (DRAW_ANIM_PATH) { for (vector<Animation*>::iterator it = mAnimation.begin(); it < mAnimation.end(); ++it) { (*it)->CreateVertexBuffer(); } } }
void World::LoadScene(const char * scene_path) { // Using case-insensitive strings and streams for easier parsing ci_ifstream input; input.open(scene_path, ios::in); // Invalid file if (input.fail()) { fprintf(stderr, "Error loading file: %s\n", scene_path); getchar(); exit(-1); } ci_string item; while (std::getline(input, item, '[')) { ci_istringstream iss(item); ci_string result; if (std::getline(iss, result, ']')) { if (result == "cube") { CubeModel* cube = new CubeModel(); cube->Load(iss); mModel.push_back(cube); } else if (result == "sphere") { #if defined(PLATFORM_OSX) int sphereTextureID = TextureLoader::LoadTexture("Textures/moonTexture.jpg"); #else int sphereTextureID = TextureLoader::LoadTexture("../Assets/Textures/moonTexture.jpg"); #endif SphereModel* moon = new SphereModel(sphereTextureID, vec3(10.0f, 10.0f, 10.0f)); moon->Load(iss); mModel.push_back(moon); } else if (result == "animationkey") { AnimationKey* key = new AnimationKey(); key->Load(iss); mAnimationKey.push_back(key); } else if (result == "animation") { Animation* anim = new Animation(); anim->Load(iss); mAnimation.push_back(anim); } else if (result.empty() == false && result[0] == '#') { // this is a comment line } else { fprintf(stderr, "Error loading scene file... !"); getchar(); exit(-1); } } } input.close(); // Set Animation vertex buffers for (vector<Animation*>::iterator it = mAnimation.begin(); it < mAnimation.end(); ++it) { // Draw model (*it)->CreateVertexBuffer(); } }
void PlaneModel::MakeWings(){ //######################################################################################## //wing GroupModel* wing = new GroupModel(); SphereModel* wingbase = new SphereModel(); wingbase->SetScaling(vec3(4.0f, 0.1f, 0.5f)); wingbase->SetPosition(vec3(0.0f, 0.0f, 0.0f)); //sphere->SetRotation(vec3(0.0f, 1.0f, 0.0f), 45.0f); wing->AddChild("wing_base", wingbase); AddChild("wing", wing); //Flaps --------------------------------------------------------------------------------- float flapWidth = 0.45f;// z width of flap float flapLen = 2.0f;// 3.4 full wing float wingAng = 6; // rotate to fit wing float zOffset = -0.2;//-0.2; float xOffset = 1.78f;//2.3f; vec3 flapColor = vec3(0.4f, 0,0); //Left Flap ----------------------------------------------------------------------------- if(1){ GroupModel* wingside = new GroupModel(); //wingside->AddChild(new CubeModel(vec3(0,0,1), vec3(0.2f))); //marker if(1){ Model* m = new CubeModel(flapColor); //flap->AddChild(new CubeModel(vec3(1), vec3(0.2f))); //marker m->SetPosition(vec3(1.60f,-0.025,-0.42f)); m->SetScaling(vec3(1.2f,0.05f, flapWidth)); wingside->AddChild(m); } GroupModel* flap = new GroupModel(); //flaps cube Model* m = new CubeModel(flapColor); //flap->AddChild(new CubeModel(vec3(1), vec3(0.2f))); //marker m->SetPosition(vec3(0,-0.025,-flapWidth/2)); m->SetScaling(vec3(flapLen,0.05f, flapWidth)); flap->SetRotation(vec3(1,0,0), 0); // angle of flap flap->SetPosition(vec3(0,0,zOffset)); //flap->SetRotationSpeed(60); flap->AddChild("flap", m); wingside->SetRotation(vec3(0,1,0), -wingAng); wingside->SetPosition(vec3(xOffset,0,0)); wingside->AddChild("flap",flap); wing->AddChild("left", wingside); } //Right Flap ----------------------------------------------------------------------------- if(1){ GroupModel* wingside = new GroupModel(); //wingside->AddChild(new CubeModel(vec3(0,0,1), vec3(0.2f))); //marker if(1){ Model* m = new CubeModel(flapColor); //flap->AddChild(new CubeModel(vec3(1), vec3(0.2f))); //marker m->SetPosition(vec3(-1.60f,-0.025,-0.42f)); m->SetScaling(vec3(1.2f,0.05f, flapWidth)); wingside->AddChild(m); } GroupModel* flap = new GroupModel(); //flaps cube Model* m = new CubeModel(flapColor); //flap->AddChild(new CubeModel(vec3(1), vec3(0.2f))); //marker m->SetPosition(vec3(0,-0.025,-flapWidth/2)); m->SetScaling(vec3(flapLen,0.05f, flapWidth)); flap->SetRotation(vec3(1,0,0), 0); // angle of flap flap->SetPosition(vec3(0,0,zOffset)); //flap->SetRotationSpeed(60); flap->AddChild("flap", m); wingside->SetRotation(vec3(0,1,0), wingAng); wingside->SetPosition(vec3(-xOffset,0,0)); wingside->AddChild("flap",flap); wing->AddChild("right", wingside); } //######################################################################################## }