int ScriptBinding::addTextureToCurrentScene(lua_State * s) { const char * path = lua_tostring(s,1); Scene * scene = ScreenManager::GetPtr()->GetCurrentScreen()->GetScene(); scene->AddTexture(path); return 0; }
Scene* CreateScene(void){ Scene* scene = new Scene(); //Initiate materials Material* sunMaterial = new Material( vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f), vec4(1.0f, 1.0f, 0.6f, 1.0f), 1 ); scene->AddMaterial(sunMaterial); Material* earthMaterial = new Material( vec4(0.04f, 0.04f, 0.2f, 1.0f), vec4(0.1f, 0.5f, 0.3f, 1.0f), vec4(0.5f, 0.5f, 0.5f, 1.0f), vec4(0.0f, 0.0f, 0.0f, 1.0f), 5 ); scene->AddMaterial(earthMaterial); Material* moonMaterial = new Material( vec4(0.1f, 0.1f, 0.1f, 1.0f), vec4(0.5f, 0.5f, 0.5f, 1.0f), vec4(0.0f, 0.0f, 0.0f, 1.0f), vec4(0.0f, 0.0f, 0.0f, 1.0f), 1 ); scene->AddMaterial(moonMaterial); Material* brickMaterial = new Material( vec4(-0.3f, -0.3f, -0.3f, 1.0f), vec4(1.5f, 1.5f, 1.5f, 1.0f), vec4(1.6f, 1.6f, 1.6f, 1.0f), vec4(0.0f, 0.0f, 0.0f, 1.0f), 20 ); scene->AddMaterial(earthMaterial); Material* metalMaterial = new Material( vec4(0.2f, 0.2f, 0.2f, 1.0f), vec4(0.2f, 0.2f, 0.2f, 1.0f), vec4(1.0f, 1.0f, 1.0f, 1.0f), vec4(0.0f, 0.0f, 0.0f, 1.0f), 10 ); scene->AddMaterial(metalMaterial); // Initiate Textures Texture* mudBrickTexture = new Texture("Textures/AlternatingMudbrick-ColorMap.png"); scene->AddTexture(mudBrickTexture); Texture* mudBrickNormals = new Texture("Textures/AlternatingMudbrick-NormalMap.png"); scene->AddTexture(mudBrickNormals); Texture* crackedBrickTexture = new Texture("Textures/CrackedAlternatingBricks-ColorMap.png"); scene->AddTexture(crackedBrickTexture); Texture* crackedBrickNormals = new Texture("Textures/CrackedAlternatingBricks-NormalMap.png"); scene->AddTexture(crackedBrickNormals); Texture* sandTexture = new Texture("Textures/Sand_1_Diffuse.png"); scene->AddTexture(sandTexture); Texture* sandNormals = new Texture("Textures/Sand_1_Normal.png"); scene->AddTexture(sandNormals); Texture* heightMap = new Texture("Textures/terrain-heightmap.png"); //Texture* heightMap = new Texture("Textures/heightmap.png"); //Texture* heightMap = new Texture("Textures/z.png"); scene->AddTexture(heightMap); // Initiate Models /* Model* cube = new Cube(); scene->AddModel(cube); */ Model* sphere = new Sphere(24); scene->AddModel(sphere); Model3DS* imported = new Model3DS("Model/pine_green_v3.3DS"); scene->AddModel(imported); Model* plane = new Plane(2.0f, 2.0f, 64, 64); scene->AddModel(plane); Model* heightMapPlane = new HeightMappedPlane(2.0f, 2.0f, 5.0f, 64, 64, heightMap); // Initiate TextureSets TextureSet* brickBlend = new TextureSet(); brickBlend->Add(mudBrickTexture, 2.0f); brickBlend->Add(crackedBrickTexture, 2.0f); TextureSet* blankTextureSet = new TextureSet(); TextureSet* brickBlendNormals = new TextureSet(); brickBlendNormals->Add(mudBrickNormals, 2.0f); brickBlendNormals->Add(crackedBrickNormals, 2.0f); TextureSet* smallBricks = new TextureSet(); smallBricks->Add(crackedBrickTexture, 0.25f); TextureSet* smallBrickNormals = new TextureSet(); smallBrickNormals->Add(crackedBrickNormals, 0.25f); // Initiate Nodes //EulerNode* ground = new EulerNode(plane, brickMaterial, brickBlend); EulerNode* ground = new EulerNode(heightMapPlane, brickMaterial, brickBlend); ground->Position = vec3(0.0f, -10.0f, 0.0f); ground->SetNormalMaps(brickBlendNormals); TextureSwitcher* textureSwitcher = new TextureSwitcher(ground); textureSwitcher->AddTextures(mudBrickTexture, mudBrickNormals); textureSwitcher->AddTextures(crackedBrickTexture, crackedBrickNormals); textureSwitcher->AddTextures(sandTexture, sandNormals); scene->AddNode(textureSwitcher); EulerNode* orb = new EulerNode(sphere, metalMaterial, blankTextureSet); //EulerNode* orb = new EulerNode(sphere, metalMaterial, smallBricks); orb->Position = vec3(0.0f, 5.0f, 0.0f); orb->SetNormalMaps(blankTextureSet); //orb->SetNormalMaps(smallBrickNormals); orb->Size = 5; ground->AddChild(orb); // Initiate Lights PointLight* pointLight = new PointLight(); SpotLight* spotLight = new SpotLight(); spotLight->Ambient = vec4(0.3f, 0.3f, 0.3f, 1.0); spotLight->Diffuse = vec4(0.5f, 0.5f, 0.3f, 0.0); spotLight->Specular = vec4(1.0f, 1.0f, 1.0f, 1.0); spotLight->Angle = 55.0f; spotLight->Direction = vec3(0.0f, -1.0f, 0.0f); scene->AddLight(pointLight); scene->AddLight(spotLight); EulerNode* spotLightModelNode = new EulerNode(sphere, sunMaterial, blankTextureSet); spotLightModelNode->Position = vec3(50.0f, 100.0f, 50.0f); spotLightModelNode->SetNormalMaps(blankTextureSet); spotLightModelNode->Position = vec3(spotLight->Position); scene->AddNode(spotLightModelNode); MouseNode* spotLightMover = new MouseNode(spotLightModelNode, GLUT_LEFT_BUTTON, true); LightNode* spotLightNode = new LightNode(spotLight, spotLightMover); spotLightMover->SetPosition(vec3(5.0f, 5.0f, 5.0f)); scene->AddNode(spotLightNode); EulerNode* pointLightModelNode = new EulerNode(sphere, sunMaterial, blankTextureSet); pointLightModelNode->Position = vec3(50.0f, 50.0f, 50.0f); pointLightModelNode->SetNormalMaps(blankTextureSet); pointLightModelNode->Position = vec3(pointLight->Position); scene->AddNode(pointLightModelNode); MouseNode* pointLightMover = new MouseNode(pointLightModelNode, GLUT_RIGHT_BUTTON, false); LightNode* pointLightNode = new LightNode(pointLight, pointLightMover); pointLightMover->SetPosition(vec3(0.0f, 5.0f, 0.0f)); scene->AddNode(pointLightNode); Node* globalControls = new GlobalControls(); scene->AddNode(globalControls); return scene; }