void SkyboxRenderObject::Initialize(AABBox3& box) { bbox = box; CreateRenderData(); BuildSkybox(); UpdateMaterial(); }
bool Setup() { D3DXVECTOR3 lightDirection(0.0f, 1.0f, 0.0f); TheTerrain = new Terrain(Device, "Faces.raw", 734,1024,20,1.0f); TheTerrain->genTexture(&lightDirection); TheTerrain->loadTexture("Faces.jpg"); D3DXCreateFont(Device, 20, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Arial"), &m_font ); // // Lights. // Barrels.init(Device, "barells/barrels.x"); Dalek.init(Device, "dalek/dalek.x"); tank.init(Device, "Oiltank/tank.x"); Table.init(Device, "table/table.x"); Ton.init(Device, "ton/ton3.x"); Tree.init(Device, "trees/palm_tree_3.x"); numbertrees = rand() % 100 - 1; for(int i = 0; i < 10; i++) BoolTrash[i] = true; D3DXCreateSprite(Device, &spriteMap); D3DXCreateSprite(Device, &spritePlayer); for(int i = 0; i < 10; i++) { D3DXCreateSprite(Device, &spriteTrash[i]); } D3DXCreateTextureFromFile(Device, "Map.png", &texMap); srand(GetTickCount()); TrashPositions[0].x = rand() % 360 - 180; TrashPositions[0].z = rand() % 360 - 180; float height = TheTerrain->getHeight(TrashPositions[0].x, TrashPositions[0].z); TrashPositions[0].y = height; TrashPositions[1].x = rand() % 360 - 180; TrashPositions[1].z = rand() % 360 - 180; height = TheTerrain->getHeight(TrashPositions[1].x, TrashPositions[1].z); TrashPositions[1].y = height; TrashPositions[2].x = rand() % 360 - 180; TrashPositions[2].z = rand() % 360 - 180; height = TheTerrain->getHeight(TrashPositions[2].x, TrashPositions[2].z); TrashPositions[2].y = height; TrashPositions[3].x = rand() % 360 - 180; TrashPositions[3].z = rand() % 360 - 180; height = TheTerrain->getHeight(TrashPositions[3].x, TrashPositions[3].z); TrashPositions[3].y = height; TrashPositions[4].x = rand() % 360 - 180; TrashPositions[4].z = rand() % 360 - 180; height = TheTerrain->getHeight(TrashPositions[4].x, TrashPositions[4].z); TrashPositions[4].y = height; TrashPositions[5].x = rand() % 360 - 180; TrashPositions[5].z = rand() % 360 - 180; height = TheTerrain->getHeight(TrashPositions[5].x, TrashPositions[5].z); TrashPositions[5].y = height; TrashPositions[6].x = rand() % 360 - 180; TrashPositions[6].z = rand() % 360 - 180; height = TheTerrain->getHeight(TrashPositions[6].x, TrashPositions[6].z); TrashPositions[6].y = height; TrashPositions[7].x = rand() % 360 - 180; TrashPositions[7].z = rand() % 360 - 180; height = TheTerrain->getHeight(TrashPositions[7].x, TrashPositions[7].z); TrashPositions[7].y = height; TrashPositions[8].x = rand() % 360 - 180; TrashPositions[8].z = rand() % 360 - 180; height = TheTerrain->getHeight(TrashPositions[8].x, TrashPositions[8].z); TrashPositions[8].y = height; TrashPositions[9].x = rand() % 360 - 180; TrashPositions[9].z = rand() % 360 - 180; height = TheTerrain->getHeight(TrashPositions[9].x, TrashPositions[9].z); TrashPositions[9].y = height; for(int i = 0; i < numbertrees; i++) { TreePositions[i].x = rand() % 360 - 180; TreePositions[i].z = rand() % 360 - 180; height = TheTerrain->getHeight(TreePositions[i].x, TreePositions[i].z); TreePositions[i].y = height; } D3DXVECTOR3 lightDir(0.707f, -0.707f, 0.707f); D3DXCOLOR color(1.0f, 1.0f, 1.0f, 1.0f); D3DLIGHT9 light = d3d::InitDirectionalLight(&lightDir, &color); Device->SetLight(0, &light); Device->LightEnable(0, true); Device->SetRenderState(D3DRS_NORMALIZENORMALS, true); Device->SetRenderState(D3DRS_SPECULARENABLE, true); //build skybox BuildSkybox(Device); // // Set Camera. // D3DXVECTOR3 pos(-0.0f, -197.0f, -0.0f); D3DXVECTOR3 target(0.0, 0.0f, 0.0f); D3DXVECTOR3 up(0.0f, 1.0f, 0.0f); D3DXMATRIX V; D3DXMatrixLookAtLH(&V, &pos, &target, &up); Device->SetTransform(D3DTS_VIEW, &V); D3DXVECTOR3 pos2(-0.0f, -10.0f, 0.0f); D3DXVECTOR3 target2(0.0, 0.0f, 0.0f); D3DXVECTOR3 up2(0.0f, 1.0f, 0.0f); // D3DXMATRIX V; D3DXMatrixLookAtLH(&mview, &pos2, &target2, &up2); //Device->SetTransform(D3DTS_VIEW, &mview); // // Set projection matrix. // D3DXMATRIX proj; D3DXMatrixPerspectiveFovLH( &proj, D3DX_PI / 4.0f, // 45 - degree (float)Width / (float)Height, 1.0f, 20001.0f); Device->SetTransform(D3DTS_PROJECTION, &proj); D3DXMatrixPerspectiveFovLH(&mprojection, D3DX_PI / 4.0f, (float)Width / (float)Height, 1.0f, 20001.0f); //Device->SetTransform(D3DTS_PROJECTION, &mprojection); return true; }