virtual void onCreate() { rh.loadProgram(planetProgram, "week5c_ImageDistortation/planet", 0, -1, -1, -1); mb.init(MeshUtils::makeClipRectangle(), 0, -1, -1, -1); rh.loadCubeMapTexture(cubemap[0], 2048, 2048, "week5c_ImageDistortation/f_negz.jpg", "week5c_ImageDistortation/f_posz.jpg", "week5c_ImageDistortation/f_posy.jpg", "week5c_ImageDistortation/f_negy.jpg", "week5c_ImageDistortation/f_negx.jpg", "week5c_ImageDistortation/f_posx.jpg"); rh.loadCubeMapTexture(cubemap[1], 2048, 2048, "week5c_ImageDistortation/b_negz.jpg", "week5c_ImageDistortation/b_posz.jpg", "week5c_ImageDistortation/b_posy.jpg", "week5c_ImageDistortation/b_negy.jpg", "week5c_ImageDistortation/b_negx.jpg", "week5c_ImageDistortation/b_posx.jpg"); }
virtual void onCreate() { rh.loadProgram(skyboxProgram, "week5b_CubeMapping/skybox", posLoc, -1, -1, -1); rh.loadProgram(environmentMappingProgram, "week5b_CubeMapping/envMap", posLoc, normalLoc, -1, -1); MeshData cube; addCube(cube, 8.0); cubeMeshBuffer.init(cube, posLoc, normalLoc, -1, -1); cubeModel = mat4(); cubeModel = glm::translate(cubeModel, vec3(0.0,0.0,40)); obj::Model m = obj::loadModelFromFile(rh.pathToResource("week5b_CubeMapping/dragon.obj")); MeshData dragonMesh; for(std::map<std::string, std::vector<unsigned short> >::const_iterator g = m.faces.begin(); g != m.faces.end(); ++g) { for (int i = 0 ; i < g->second.size() ; i++) { dragonMesh.index(g->second[i]); } } for (int i = 0; i < m.vertex.size(); i+=3) { vec3 pos = vec3(m.vertex[i], m.vertex[i+1], m.vertex[i+2]); pos *= 30; dragonMesh.vertex(pos); } for (int i = 0; i < m.normal.size(); i+=3) { dragonMesh.normal(m.normal[i], m.normal[i+1], m.normal[i+2]); } dragonMeshBuffer.init(dragonMesh, posLoc, normalLoc, -1, -1); dragonModel = glm::mat4(); dragonModel = glm::translate(dragonModel, vec3(0.0, -1.2, 30.0)); MeshData skybox; addCube(skybox, 100.0); skyboxMeshBuffer.init(skybox, posLoc, -1, -1, -1); //create the cube map texture rh.loadCubeMapTexture(cmt, 2048, 2048, "week5b_CubeMapping/negz.jpg", "week5b_CubeMapping/posz.jpg", "week5b_CubeMapping/posy.jpg", "week5b_CubeMapping/negy.jpg", "week5b_CubeMapping/negx.jpg", "week5b_CubeMapping/posx.jpg"); rotateBehavior = Behavior(now()).delay(1000).length(10000).range(vec3(glm::radians(360.0))).looping(true).repeats(-1); camera = Camera(glm::radians(60.0), (float)width/(float)height, 0.01, 1000.0); glEnable(GL_DEPTH_TEST); }