CVector4f FileIO::getVector4f() { float r,g,b,a; r = getFloat(); g = getFloat(); b = getFloat(); a = getFloat(); return CVector4f(r,g,b,a); }
void CShader::SetParamMatrix(SShaderActiveParam& sParam, const CMatrix* pMatrix, uint32 nElemCnt) { assert(sParam.m_nRegPerElem > 1); nElemCnt = min(nElemCnt, sParam.m_nElemCnt); CVector4f* pDes = (CVector4f*)&sParam.m_strBuffer[0]; for (uint32 i = 0; i < nElemCnt; i ++) for (uint32 j = 0; j < sParam.m_nRegPerElem; j ++) *pDes ++ = CVector4f(pMatrix->C[0][j], pMatrix->C[1][j], pMatrix->C[2][j], pMatrix->C[3][j]); }
//------------------------------------------------------------------------------ CEnvMapWaterEffect::CEnvMapWaterEffect() { m_pEnvironmentMap = NULL; m_pWaveNormalMap[0] = NULL; m_pWaveNormalMap[1] = NULL; SetEffectID(CWaterMgr::EffectTypeToID(CWaterMgr::EnvironmentMapping)); CGraphic::GetInst()->CreateTexture(PATH_ALIAS_RES.c_str(), "tile/scenewater/sky.dds",&m_pEnvironmentMap); CGraphic::GetInst()->CreateTexture(PATH_ALIAS_RES.c_str(), "tile/scenewater/wave0.dds",&m_pWaveNormalMap[0]); CGraphic::GetInst()->CreateTexture(PATH_ALIAS_RES.c_str(), "tile/scenewater/wave1.dds",&m_pWaveNormalMap[1]); m_WaveSpeed[0] = CVector2f(0.0225f, 0.015f); m_WaveSpeed[1] = CVector2f(-0.0125f, 0.02f); m_WaveOffset = CVector4f(0,0,0,0); }
// // Update // void Game::update(float delay) { int i; #ifndef CONSOLE dotAnim += delay * 720; while (dotAnim >= 360) dotAnim -= 360; #endif if (voting.votingInProgress) { if (voting.update(delay)) { if (isServerGame) { //--- Voting complete, check the result // In order to the vote to pass, more than // 50% of ALL the players should have voted YES. /*voting.nbActivePlayers = 0; for (int i=0;i<MAX_PLAYER;++i) { if ( (players[i]) && (players[i]->teamID != PLAYER_TEAM_AUTO_ASSIGN) && (players[i]->teamID != PLAYER_TEAM_AUTO_ASSIGN) ) ++voting.nbActivePlayers; }*/ net_svcl_vote_result voteResult; voteResult.passed = (voting.votingResults[0] > (int)voting.activePlayersID.size() / 2); bb_serverSend((char*)(&voteResult), sizeof(net_svcl_vote_result), NET_SVCL_VOTE_RESULT); if (voteResult.passed) { //--- Vote passed!!! console->sendCommand(voting.votingWhat); } else { //--- Vote failed... } } } } if (roundState == GAME_PLAYING) { // On update les players for (int i=0;i<MAX_PLAYER;++i) { if (players[i]) { players[i]->update(delay); if (players[i]->incShot > 0) { players[i]->incShot--; if (players[i]->incShot%3 == 0) { // On test premièrement si on touche un autre joueur! Player * hitPlayer = 0; CVector3f p3 = players[i]->p2; for (int j=0;j<MAX_PLAYER;j++) { if (players[j]) { if (j != i) { #ifdef _PRO_ if (players[j]->status == PLAYER_STATUS_ALIVE && (players[j]->teamID != players[i]->teamID || gameType == GAME_TYPE_DM || gameType == GAME_TYPE_SND || gameVar.sv_friendlyFire || gameVar.sv_reflectedDamage)) #else if (players[j]->status == PLAYER_STATUS_ALIVE && (players[j]->teamID != players[i]->teamID || gameType == GAME_TYPE_DM || gameVar.sv_friendlyFire)) #endif { // Ray to sphere test if (segmentToSphere(players[i]->p1, p3, players[j]->currentCF.position, .35f)) { hitPlayer = players[j]; p3 = players[i]->p2; // Full length // On décrémente sa vie hitPlayer->hitSV(gameVar.weapons[WEAPON_PHOTON_RIFLE], players[i], gameVar.weapons[WEAPON_PHOTON_RIFLE]->damage / 2.0f); } } } } } } } //--- Update les guns if (players[i]->weapon) { if (players[i]->weapon->weaponID == WEAPON_SMG) { if (!gameVar.sv_enableSMG) { players[i]->switchWeapon(SelectToAvailableWeapon(), true); } } if (players[i]->weapon->weaponID == WEAPON_SHOTGUN) { if (!gameVar.sv_enableShotgun) { players[i]->switchWeapon(SelectToAvailableWeapon(), true); } } if (players[i]->weapon->weaponID == WEAPON_SNIPER) { if (!gameVar.sv_enableSniper/* || map->size[0] * map->size[1] <= 512*/) { players[i]->switchWeapon(SelectToAvailableWeapon(), true); } } if (players[i]->weapon->weaponID == WEAPON_DUAL_MACHINE_GUN) { if (!gameVar.sv_enableDualMachineGun) { players[i]->switchWeapon(SelectToAvailableWeapon(), true); } } if (players[i]->weapon->weaponID == WEAPON_CHAIN_GUN) { if (!gameVar.sv_enableChainGun) { players[i]->switchWeapon(SelectToAvailableWeapon(), true); } } if (players[i]->weapon->weaponID == WEAPON_BAZOOKA) { if (!gameVar.sv_enableBazooka) { players[i]->switchWeapon(SelectToAvailableWeapon(), true); } } if (players[i]->weapon->weaponID == WEAPON_PHOTON_RIFLE) { if (!gameVar.sv_enablePhotonRifle) { players[i]->switchWeapon(SelectToAvailableWeapon(), true); } } if (players[i]->weapon->weaponID == WEAPON_FLAME_THROWER) { if (!gameVar.sv_enableFlameThrower) { players[i]->switchWeapon(SelectToAvailableWeapon(), true); } } } //--- Update les melee if (players[i]->meleeWeapon) { if (!gameVar.sv_enableSecondary) { players[i]->switchMeleeWeapon(SelectToAvailableMeleeWeapon(), true); } else { if (players[i]->meleeWeapon->weaponID == WEAPON_KNIVES) { if (!gameVar.sv_enableKnives) { players[i]->switchMeleeWeapon(SelectToAvailableMeleeWeapon(), true); } } if (players[i]->meleeWeapon->weaponID == WEAPON_NUCLEAR) { if (!gameVar.sv_enableNuclear) { players[i]->switchMeleeWeapon(SelectToAvailableMeleeWeapon(), true); } } if (players[i]->meleeWeapon->weaponID == WEAPON_SHIELD) { if (!gameVar.sv_enableShield) { players[i]->switchMeleeWeapon(SelectToAvailableMeleeWeapon(), true); } } #ifdef _PRO_ if (players[i]->meleeWeapon->weaponID == WEAPON_MINIBOT) { if (!gameVar.sv_enableMinibot) { players[i]->switchMeleeWeapon(SelectToAvailableMeleeWeapon(), true); } } #endif } } } } } #ifdef _PRO_ //--- Perform bot collisions with walls if (isServerGame) { for (int i=0;i<MAX_PLAYER;++i) { if (players[i]) { if (players[i]->status == PLAYER_STATUS_ALIVE) { if (players[i]->minibot) { if (map) map->performCollision(players[i]->minibot->lastCF, players[i]->minibot->currentCF, .15f); map->collisionClip(players[i]->minibot->currentCF, .15f); } } } } } #endif // Si on tiens tab, on montre les stats #ifndef CONSOLE if (!console->isActive() && dkiGetState(gameVar.k_showScore) || roundState != GAME_PLAYING) { showStats = true; } else { showStats = false; } for (i=0;i<(int)nikeFlashes.size();++i) { nikeFlashes[i]->update(delay); if (nikeFlashes[i]->life <= 0) { delete nikeFlashes[i]; nikeFlashes.erase(nikeFlashes.begin() + i); --i; } } if (thisPlayer && roundState == GAME_PLAYING) { if (thisPlayer->teamID == PLAYER_TEAM_SPECTATOR && !console->isActive() && !writting && !showMenu && !(menuManager.root && menuManager.root->visible)) { // On est spectateur, alors on peut se déplacer comme on veut dans la map // Pour l'instant les flèches (a,s,w,d, pomal temp) if (dkiGetState(gameVar.k_moveRight)) { map->camLookAt[0] += 10 * delay; } if (dkiGetState(gameVar.k_moveLeft)) { map->camLookAt[0] -= 10 * delay; } if (dkiGetState(gameVar.k_moveUp)) { map->camLookAt[1] += 10 * delay; } if (dkiGetState(gameVar.k_moveDown)) { map->camLookAt[1] -= 10 * delay; } } // On performe les collisions sur notre joueur if (thisPlayer->status == PLAYER_STATUS_ALIVE) { for (int i=0;i<MAX_PLAYER;++i) { if (players[i] && players[i] != thisPlayer) { if (players[i]->status == PLAYER_STATUS_ALIVE && players[i]->timeAlive > 3.0f && thisPlayer->timeAlive > 3.0f) // player msut have been on the field for more than 3 second before we check collisions with him { float disSq = distanceSquared(thisPlayer->currentCF.position, players[i]->currentCF.position); if (disSq <= .5f*.5f) { CVector3f dis = players[i]->currentCF.position - thisPlayer->currentCF.position; normalize(dis); thisPlayer->currentCF.position = players[i]->currentCF.position - dis * .51f; thisPlayer->currentCF.vel = -thisPlayer->currentCF.vel * BOUNCE_FACTOR; if (map) map->performCollision(thisPlayer->lastCF, thisPlayer->currentCF, .25f); map->collisionClip(thisPlayer->currentCF, .25f); thisPlayer->lastCF.position = thisPlayer->currentCF.position; } } } } if (map) map->performCollision(thisPlayer->lastCF, thisPlayer->currentCF, .25f); // Performing a final clip cibole de caliss map->collisionClip(thisPlayer->currentCF, .25f); //--- Est-ce qu'on est stuck dans un wall??? Oui? on respawn request int x = (int)thisPlayer->currentCF.position[0]; int y = (int)thisPlayer->currentCF.position[1]; if ((!map->dko_map && !map->cells[(y)*map->size[0]+(x)].passable) || (map->dko_map && (x < 0 || x > map->size[0] || y < 0 || y > map->size[1]))) { // Respawn request! if (!thisPlayer->spawnRequested) { // Ici on le call juste une fois, isshh sinon ça sera pas trop bon... // On request to spawn thisPlayer->spawnRequested = true; net_clsv_spawn_request spawnRequest; spawnRequest.playerID = thisPlayer->playerID; spawnRequest.weaponID = thisPlayer->nextSpawnWeapon; spawnRequest.meleeID = thisPlayer->nextMeleeWeapon; memcpy(spawnRequest.skin, thisPlayer->skin.s, (thisPlayer->skin.len() <= 6)?thisPlayer->skin.len()+1:7); spawnRequest.blueDecal[0] = (unsigned char)(thisPlayer->blueDecal[0] * 255.0f); spawnRequest.blueDecal[1] = (unsigned char)(thisPlayer->blueDecal[1] * 255.0f); spawnRequest.blueDecal[2] = (unsigned char)(thisPlayer->blueDecal[2] * 255.0f); spawnRequest.greenDecal[0] = (unsigned char)(thisPlayer->greenDecal[0] * 255.0f); spawnRequest.greenDecal[1] = (unsigned char)(thisPlayer->greenDecal[1] * 255.0f); spawnRequest.greenDecal[2] = (unsigned char)(thisPlayer->greenDecal[2] * 255.0f); spawnRequest.redDecal[0] = (unsigned char)(thisPlayer->redDecal[0] * 255.0f); spawnRequest.redDecal[1] = (unsigned char)(thisPlayer->redDecal[1] * 255.0f); spawnRequest.redDecal[2] = (unsigned char)(thisPlayer->redDecal[2] * 255.0f); bb_clientSend(scene->client->uniqueClientID, (char*)&spawnRequest, sizeof(net_clsv_spawn_request), NET_CLSV_SPAWN_REQUEST); } } } } // On update la map if (map && thisPlayer) { map->update(delay, thisPlayer); //--- Est-ce qu'il pleut? if (map->weather == WEATHER_RAIN) { for (int i=0;i<5;++i) { //--- Spawn da rain! int idrip = getNextDrip(); drips[idrip].life = 1; drips[idrip].position = rand(map->camPos + CVector3f(-5,-5,0), map->camPos + CVector3f(5,5,0)); drips[idrip].position[2] = 0; drips[idrip].size = .15f; drips[idrip].fadeSpeed = 2; } //--- Spawn des drip sous les players for (int i=0;i<MAX_PLAYER;++i) { if (players[i]) { if (players[i]->status == PLAYER_STATUS_ALIVE) { if (map->cells[(int)(players[i]->currentCF.position[1] - .5f) * map->size[0] + (int)(players[i]->currentCF.position[0] - .5f)].splater[0] > .5f) { if (players[i]->currentCF.vel.length() >= 2.25f) { //--- Spawn da rain! int idrip = getNextDrip(); drips[idrip].life = .5f; drips[idrip].position = players[i]->currentCF.position; drips[idrip].position[2] = 0; drips[idrip].size = .3f; drips[idrip].fadeSpeed = 1; } } } } } } //--- Si on roule dans la lave, on spawn de la fumé :D if (map->theme == THEME_LAVA) { //--- Spawn des drip sous les players for (int i=0;i<MAX_PLAYER;++i) { if (players[i]) { if (players[i]->status == PLAYER_STATUS_ALIVE && rand()%50 == 5) { if (map->cells[(int)(players[i]->currentCF.position[1] - .5f) * map->size[0] + (int)(players[i]->currentCF.position[0] - .5f)].splater[0] > .5f) { //--- Spawn da smoke psssiiii for (int j=0;j<4;++j) { dkpCreateParticle( players[i]->currentCF.position.s,//float *position, CVector3f(0,0,(float)j* .25f).s,//float *vel, CVector4f(.7f,.7f,.7f,1).s,//float *startColor, CVector4f(.7f,.7f,.7f,0).s,//float *endColor, .25f,//float startSize, .5f,//float endSize, 2,//float duration, 0,//float gravityInfluence, 0,//float airResistanceInfluence, 30,//float rotationSpeed, gameVar.tex_smoke1,//unsigned int texture, DKP_SRC_ALPHA,//unsigned int srcBlend, DKP_ONE_MINUS_SRC_ALPHA,//unsigned int dstBlend, 0);//int transitionFunc); } dksPlay3DSound(gameVar.sfx_lavaSteam, -1, 5, players[i]->currentCF.position,125); } } } } } // La view qui shake if (viewShake > 0) { if (viewShake > 2.5f) viewShake = 2.5f; CVector3f dir(1,0,0); dir = rotateAboutAxis(dir, rand(0.0f, 360.0f), CVector3f(0,0,1)); dir *= viewShake * .10f; map->camPos += dir; viewShake -= delay*.75f; if (viewShake < 0) viewShake = 0; } //-- We check for all enable guns scene->client->btn_guns[WEAPON_SMG]->enable = gameVar.sv_enableSMG; scene->client->btn_guns[WEAPON_SHOTGUN]->enable = gameVar.sv_enableShotgun; scene->client->btn_guns[WEAPON_SNIPER]->enable = gameVar.sv_enableSniper; scene->client->btn_guns[WEAPON_DUAL_MACHINE_GUN]->enable = gameVar.sv_enableDualMachineGun; scene->client->btn_guns[WEAPON_CHAIN_GUN]->enable = gameVar.sv_enableChainGun; scene->client->btn_guns[WEAPON_BAZOOKA]->enable = gameVar.sv_enableBazooka; scene->client->btn_guns[WEAPON_PHOTON_RIFLE]->enable = gameVar.sv_enablePhotonRifle; scene->client->btn_guns[WEAPON_FLAME_THROWER]->enable = gameVar.sv_enableFlameThrower; if(gameVar.sv_enableSecondary) { scene->client->btn_meleeguns[WEAPON_KNIVES-WEAPON_KNIVES]->enable = gameVar.sv_enableKnives; scene->client->btn_meleeguns[WEAPON_NUCLEAR-WEAPON_KNIVES]->enable = gameVar.sv_enableNuclear; scene->client->btn_meleeguns[WEAPON_SHIELD-WEAPON_KNIVES]->enable = gameVar.sv_enableShield; scene->client->btn_meleeguns[WEAPON_MINIBOT-WEAPON_KNIVES]->enable = gameVar.sv_enableMinibot; } else { scene->client->btn_meleeguns[WEAPON_KNIVES-WEAPON_KNIVES]->enable = false; scene->client->btn_meleeguns[WEAPON_NUCLEAR-WEAPON_KNIVES]->enable = false; scene->client->btn_meleeguns[WEAPON_SHIELD-WEAPON_KNIVES]->enable = false; scene->client->btn_meleeguns[WEAPON_MINIBOT-WEAPON_KNIVES]->enable = false; } } // On update les trails for (int i=0;i<(int)trails.size();++i) { trails[i]->update(delay); if (trails[i]->delay >= 1) { delete trails[i]; trails.erase(trails.begin()+i); i--; } } // On update les floor mark for (int i=0;i<MAX_FLOOR_MARK;++i) { if (floorMarks[i].delay > 0) { floorMarks[i].update(delay); } if (drips[i].life > 0) { drips[i].update(delay); } } #endif // On update les projectiles for (int i=0;i<(int)projectiles.size();++i) { Projectile * projectile = projectiles[i]; projectile->update(delay, map); projectile->projectileID = (short)i; // On l'update toujours if ( projectile->needToBeDeleted ) { if( !projectile->reallyNeedToBeDeleted ) { projectile->reallyNeedToBeDeleted = true; continue; } projectiles.erase(projectiles.begin()+i); net_svcl_delete_projectile deleteProjectile; deleteProjectile.projectileID = projectile->uniqueID; bb_serverSend((char*)&deleteProjectile,sizeof(net_svcl_delete_projectile),NET_SVCL_DELETE_PROJECTILE,0); i--; delete projectile; } } #ifndef CONSOLE // On update les projectiles client for (int i=0;i<(int)clientProjectiles.size();++i) { Projectile * projectile = clientProjectiles[i]; projectile->update(delay, map); projectile->projectileID = (short)i; // On l'update toujours if (projectile->needToBeDeleted) { clientProjectiles.erase(projectiles.begin()+i); i--; delete projectile; } } // On update les douilles for (int i=0;i<(int)douilles.size();++i) { Douille * douille = douilles[i]; douille->update(delay, map); if (douille->delay<=0) { douilles.erase(douilles.begin()+i); i--; delete douille; } } #endif // Update les particules // gameVar.ro_nbParticle = dkpUpdate(delay); }
int main(int argc, char* argv[]) { bool bIsbowlingMode = false; std::wstring input2 = L"Hello! Please enter 1 if you wish to try the bowling mode. Enter anything else to play checkpoint mode"; std::wcout << input2 << std::endl; std::wstring input; std::getline(std::wcin, input); if (input == L"1") { bIsbowlingMode = true; } bool bLoadTires = false; std::wstring input3 = L"Would you like to load the tire models? (loading tires may cause slowdown) y/n"; std::wcout << input3 << std::endl; std::wstring input4; std::getline(std::wcin, input4); if (input4 == L"y") { bLoadTires = true; } printTheWhatsThisProgramAboutBlurb(); ::g_gameState.currentGameMode = CGameState::GAME_LOADING; ::OpenGL_Initialize( argc, argv, 1200, 800 ); // Initialize(argc, argv); //::OpenGL_Initialize( argc, argv, 640, 480 ); // Initialize(argc, argv); // CModelLoaderManager g_pModelLoader = new CModelLoaderManager(); g_pModelLoader->SetRootDirectory( "assets/models" ); std::vector< CModelLoaderManager::CLoadInfo > vecModelsToLoad; if (bIsbowlingMode) ReadInModelsInfo("assets/BowlingScene.txt"); else ReadInModelsInfo("assets/Scene.txt"); for (unsigned int i = 0; i < vecModelsInfo.size(); i++) { ::g_mapModelTypes[vecModelsInfo[i].type] = vecModelsInfo[i].file; if (vecModelsInfo[i].tex.size() > 0) ::g_mapTextures[i] = vecModelsInfo[i].tex[0]; //vecModelsToLoad.push_back(CModelLoaderManager::CLoadInfo(vecModelsInfo[i].file, 1.0f, true)); } for (unsigned int i = 0; i < vecModelsInfo.size(); i++) { for (std::map<std::string, std::string>::iterator jIterator = g_mapModelTypes.begin(); jIterator != ::g_mapModelTypes.end(); jIterator++) { if (vecModelsInfo[i].type == jIterator->first){ if (vecModelsInfo[i].isEnvironment){ vecModelsToLoad.push_back(CModelLoaderManager::CLoadInfo(jIterator->second)); } else vecModelsToLoad.push_back(CModelLoaderManager::CLoadInfo(jIterator->second, 1.0f, true)); } } } vecModelsToLoad.push_back( CModelLoaderManager::CLoadInfo("sphere_UV_xyz.ply", 1.0f, true) ); vecModelsToLoad.push_back( CModelLoaderManager::CLoadInfo("Cube.ply", 1.0f, true ) ); vecModelsToLoad.push_back( CModelLoaderManager::CLoadInfo("Cube2.ply", 1.0f, true)); vecModelsToLoad.push_back( CModelLoaderManager::CLoadInfo("1x1_6_Star_2_Sided.ply", 1.0f, true ) ); vecModelsToLoad.push_back( CModelLoaderManager::CLoadInfo("truck.ply", 1.0f, true)); //vecModelsToLoad.push_back( CModelLoaderManager::CLoadInfo("truck2.ply", 1.0f, true)); if (bLoadTires) vecModelsToLoad.push_back( CModelLoaderManager::CLoadInfo("tire.ply", 1.0f, true)); if ( ! g_pModelLoader->LoadModels( vecModelsToLoad ) ) { std::cout << "Can't load one or more models. Sorry it didn't work out." << std::endl; return -1; } g_pShaderManager = new CGLShaderManager(); //LoadShaders(); // Moved from CreateCube CShaderDescription uberVertex; uberVertex.filename = "assets/shaders/OpenGL.LightTexSkyUber.vertex.glsl"; uberVertex.name = "UberVertex"; CShaderDescription uberFragment; uberFragment.filename = "assets/shaders/OpenGL.LightTexSkyUber.fragment_texture.glsl"; uberFragment.name = "UberFragment"; CShaderProgramDescription uberShader("UberShader", uberVertex, uberFragment ); if ( !g_pShaderManager->CreateShaderProgramFromFile( uberShader ) ) { std::cout << "Error compiling one or more shaders..." << std::endl; std::cout << g_pShaderManager->getLastError() << std::endl; std::cout << uberShader.getErrorString() << std::endl; return -1; } ::SetUpTextures(); std::cout << "Starting Havok" << std::endl; g_pFactoryMediator = new CFactoryMediator(); // ****************************************************** // Set up the Havok physics thing // Create a Havok Physic thingie: // Passing "Havok" gives us a physics manager using Havok. // Anything else is an error... // if crashing on release, right click on Desktop->NVIDIA Contol Panel->Set PhysX configuration. Select a PhysX dropdown menu->CPU //::g_pPhysicsManager = CPhysicsManagerFactory::CreatePhysicsMananger( L"Havok" ); if ((::g_pPhysicsManager = CPhysicsManagerFactory::CreatePhysicsMananger(L"Havok")) == 0){ std::cout << "Failed Creating Havok" << std::endl; std::cout.flush(); } // std::cout << "Havok Created" << std::endl; std::cout.flush(); std::vector< CNameValuePair2 > vecParams; vecParams.push_back( CNameValuePair2( L"VisualDebugger", true ) ); ::g_pPhysicsManager->Init(vecParams); // ****************************************************************** std::cout << "Done with physics." << std::endl; std::cout.flush(); static const float oneDegreeInRadians = static_cast<float>(PI) / 180.0f; for (unsigned i = 0; i < vecModelsInfo.size(); i++) { CPhysicalProp physicalProp; physicalProp.position = vecModelsInfo[i].pos; physicalProp.setOrientationEulerAngles(CVector3f(oneDegreeInRadians * vecModelsInfo[i].rot.x, oneDegreeInRadians * vecModelsInfo[i].rot.y, oneDegreeInRadians * vecModelsInfo[i].rot.z)); physicalProp.rotStep = vecModelsInfo[i].rot; CMeshDesc mesh(vecModelsInfo[i].file); mesh.scale = vecModelsInfo[i].scale; mesh.bIsSkybox = vecModelsInfo[i].isSkybox; mesh.bIsPlayer = vecModelsInfo[i].isPlayer; mesh.modelID = i; mesh.blend = vecModelsInfo[i].blend; mesh.debugColour = CVector4f(vecModelsInfo[i].col.x, vecModelsInfo[i].col.y, vecModelsInfo[i].col.z, 1.0f); mesh.bIsParticle = vecModelsInfo[i].isParticle; if (vecModelsInfo[i].isTransparent){ mesh.bIsTransparent = true; mesh.tranparency = vecModelsInfo[i].transparency; } else{ mesh.bIsTransparent = false; mesh.tranparency = 1.0f; } if (vecModelsInfo[i].tex.size() > 0) { mesh.bHasTexture = true; mesh.firstTex = vecModelsInfo[i].firstTex; } mesh.ObjectType = vecModelsInfo[i].type; if (vecModelsInfo[i].isSkybox || vecModelsInfo[i].isParticle) mesh.bIsHavok = false; vecModelsInfo[i].ID = g_pFactoryMediator->CreateObjectByType(vecModelsInfo[i].type, physicalProp, mesh); makeHavokObject(vecModelsInfo[i].ID); if (vecModelsInfo[i].isPlayer) ::g_FloorHavokID = vecModelsInfo[i].ID; if (vecModelsInfo[i].isSkybox) ::g_skyBoxID = vecModelsInfo[i].ID; //if (vecModelsInfo[i].isLightBall) // ::g_lightModelID = vecModelsInfo[i].ID; if (vecModelsInfo[i].isParticle) ::g_vecParticleID.push_back(vecModelsInfo[i].ID); } CMeshDesc sphereMesh("sphere_UV_xyz.ply"); sphereMesh.debugColour = CVector4f(0.75f, 0.5f, 0.3f, 0.0f); sphereMesh.bIsTransparent = true; sphereMesh.tranparency = 0.4f; CPhysicalProp sphereProps( CVector3f( 0.0f, 5.0f, 4.0f ) ); sphereProps.position = (CVector3f(0.0f, 5.0f, 0.0f)); ::g_lightModelID = g_pFactoryMediator->CreateObjectByType( "Sphere UV", sphereProps, sphereMesh ); CMeshDesc sphereHavokMesh("sphere_UV_xyz.ply"); sphereHavokMesh.debugColour = CVector4f(0.75f, 0.5f, 0.3f, 0.0f); sphereHavokMesh.ObjectType = "Star"; sphereHavokMesh.bIsHavok = false; CPhysicalProp sphereHavokProps( CVector3f( 0.0f, 5.0f, -10.0f ) ); ::g_StarHavokID = g_pFactoryMediator->CreateObjectByType( "Sphere UV", sphereHavokProps, sphereHavokMesh ); //makeHavokObject(::g_StarHavokID); //for (int i = 1; i < 4; i++){ // for (int j = 1; j < 4; j++){ // CMeshDesc floorHavokMesh("Cube2.ply"); // floorHavokMesh.debugColour = CVector4f(0.75f, 0.5f, 0.3f, 0.0f); // floorHavokMesh.bHasTexture = true; // if (i == 2 && j == 2){ // floorHavokMesh.ObjectType = "IceFloor"; // } // else { // floorHavokMesh.ObjectType = "GroundFloor"; // } // floorHavokMesh.scale = floorSize; // //CPhysicalProp floorHavokProps(CVector3f(-(floorSize / 2.0f), -floorSize, -(floorSize / 2.0f))); // CVector3f floorPosition; // floorPosition.x = i*(-(floorSize / 2.0f)); // floorPosition.z = j*(-(floorSize / 2.0f)); // floorPosition.y = -floorSize; // CPhysicalProp floorHavokProps(floorPosition); // unsigned int floorID = g_pFactoryMediator->CreateObjectByType("Cube UV", floorHavokProps, floorHavokMesh); // makeHavokObject(floorID); // } //} CMeshDesc truckMesh("truck.ply"); truckMesh.ObjectType = "Vehicle"; truckMesh.scale = 5.0f; CPhysicalProp truckProps(CVector3f(0.0f, 5.0f, 4.0f)); truckProps.position = (CVector3f(0.0f, 5.0f, 0.0f)); ::g_Player_ID = g_pFactoryMediator->CreateObjectByType("Player", truckProps, truckMesh); makeHavokObject(::g_Player_ID); if (bLoadTires){ CMeshDesc tireMesh("tire.ply"); tireMesh.bIsHavok = false; tireMesh.scale = 1.0f; g_pFactoryMediator->addMeshDescription(::g_Player_ID, tireMesh); g_pFactoryMediator->addMeshDescription(::g_Player_ID, tireMesh); g_pFactoryMediator->addMeshDescription(::g_Player_ID, tireMesh); g_pFactoryMediator->addMeshDescription(::g_Player_ID, tireMesh); } /*CMeshDesc checkpointHavokMesh("Cube2.ply"); checkpointHavokMesh.debugColour = CVector4f(0.75f, 0.5f, 0.3f, 0.0f); checkpointHavokMesh.ObjectType = "CheckPoint"; CPhysicalProp checkpointHavokProps(CVector3f(0.0f, 0.0f, 0.0f)); unsigned int checkpoint_ID = g_pFactoryMediator->CreateObjectByType("Sphere UV", checkpointHavokProps, checkpointHavokMesh); makeHavokObject(checkpoint_ID);*/ g_pPhysicsManager->SetCheckPoints(vecCheckPointsInfo); //g_pPhysicsManager //GenerateAABBWorld(); // Added October 3, 2014 g_pCamera = new CCamera(); // Camera expects an IMediator*, so cast it as that g_pCamera->SetMediator( (IMediator*)g_pFactoryMediator ); g_pCamera->eye.x = 0.0f; // Centred (left and right) g_pCamera->eye.y = 5.0f; // 2.0 units "above" the "ground" g_pCamera->eye.z = -20.0f; // .0funits0 from "back" the origin . 1, 2.5, 1.8 g_pCamera->target.x = 50.0f; // Centred (left and right) g_pCamera->target.y = 350.0f; // 2.0 units "above" the "ground" g_pCamera->target.z = 50.0f; // 0.0 units "back" from the origin g_pCamera->cameraAngleYaw = 2.8f; g_pCamera->cameraAnglePitch = -0.2f; g_pCamera->up.x = 0.0f; g_pCamera->up.y = 1.0f; // The Y axis is "up and down" g_pCamera->m_LEFPLookupMode = CCamera::LERP; g_pCamera->setMode_FollowAtDistance( ::g_Player_ID ); float followSpeed = 30.0f; // 1.0f whatever per second float followMinDistance = 3.0f; float followMaxSpeedDisance = 100.0f; g_pCamera->setFollowDistances( followMinDistance, followMaxSpeedDisance ); g_pCamera->setFollowMaxSpeed( followSpeed ); // A "fly through" camera // These numbers are sort of in the direction of the original camera g_pCamera->orientation = glm::fquat( 0.0960671529f, 0.972246766f, -0.0900072306f, -0.193443686f ); glm::normalize( g_pCamera->orientation ); //g_pCamera->setMode_IndependentFreeLook(); g_pMouseState = new CMouseState(); // Set up the basic lighting ExitOnGLError("Error setting light values"); SetupLights(); // if ( !::g_p_LightManager->initShadowMaps( 1, CLightManager::DEFAULT_SHADOW_DEPTH_TEXTURE_SIZE ) ) { std::cout << "Error setting up the shadow textures: " << std::endl; std::cout << ::g_p_LightManager->getLastError(); } setUpShadowTexture(); g_p_GameControllerManager = CGameControllerManager::getGameControllerManager(); g_p_GameController_0 = g_p_GameControllerManager->getController(0); if ( ( g_p_GameController_0 != 0 ) && ( g_p_GameController_0->bIsConnected() ) ) { g_p_GameController_0->AddVibrationSequence( IGameController::CVibStep::LEFT, 0.5f, 2.0f ); g_p_GameController_0->AddVibrationSequence( IGameController::CVibStep::RIGHT, 0.5f, 1.0f ); std::cout << "Game controller 0 found!" << std::endl; } else { std::cout << "Didn't get an ID for the game controller; is there one plugged in?" << std::endl; } //*************************************** g_p_checkpointEmitter = new CParticleEmitter(); g_p_timerEmitter = new CParticleEmitter(); //************************************** CPhysicalProp starProps; ::g_pFactoryMediator->getPhysicalPropertiesByID(::g_StarHavokID, starProps); g_p_checkpointEmitter->SetLocation(starProps.position); ::g_p_checkpointEmitter->GenerateParticles(1, /*number of particles*/ CVector3f(0.0f, 0.0f, 0.0f), /*Init veloc.*/ 0.1f, /*dist from source */ 5.0f, /*seconds*/ true); ::g_p_checkpointEmitter->SetAcceleration(CVector3f(0.0f, 0.0f, 0.0f)); g_p_timerEmitter->SetLocation(truckProps.position); ::g_p_timerEmitter->GenerateParticles(1, /*number of particles*/ CVector3f(0.0f, 1.0f, 0.0f), /*Init veloc.*/ 0.01f, /*dist from source */ 1.0f, /*seconds*/ true); ::g_p_timerEmitter->SetAcceleration(CVector3f(0.0f, 1.0f, 0.0f)); ::g_p_PhysicsThingy = new CPhysicsCalculatron(); // Added in animation on Sept 19 ::g_simTimer.Reset(); ::g_simTimer.Start(); // Start "counting" if (bIsbowlingMode) { ::g_gameState.currentGameMode = CGameState::GAME_BOWLING; } else ::g_gameState.currentGameMode = CGameState::GAME_RUNNING; // FULL SCREEN, Mr. Data! //::glutFullScreen(); ExitOnGLError("Error getting uniform light variables"); glutMainLoop(); std::cout << "Shutting down..." << std::endl; ShutDown(); exit(EXIT_SUCCESS); }