void Mesh::loadMesh(const char* filename) { bool res = loadOBJ(filename, vertices, uvs, normals); VBO(); }
void Scene::updateVBOs() { QSegMesh * mesh = activeObject(); if(mesh && mesh->isReady) { // Create VBO for each segment if needed for (int i=0;i<(int)mesh->nbSegments();i++) { QSurfaceMesh* seg = mesh->getSegment(i); QString objId = seg->objectName(); if (VBO::isVBOSupported() && !vboCollection.contains(objId)) { Surface_mesh::Vertex_property<Point> points = seg->vertex_property<Point>("v:point"); Surface_mesh::Vertex_property<Point> vnormals = seg->vertex_property<Point>("v:normal"); Surface_mesh::Vertex_property<Color> vcolors = seg->vertex_property<Color>("v:color"); seg->fillTrianglesList(); // Create VBO vboCollection[objId] = VBO( seg->n_vertices(), points.data(), vnormals.data(), vcolors.data(), seg->triangles ); } } } }
Context(){ float funnyShapeData[] = { -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0 }; float planeData[] = { -1.0,0,-1.0, -1.0,0,1.0, 1.0,0,1.0, 1.0,0,-1.0 }; float plane2DData[] = { -1.0,-1.0, 1.0,-1.0, 1.0,1.0, -1.0,1.0}; float boxData[] = { -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0,-1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0,-1.0,-1.0, 1.0,-1.0,-1.0, 1.0,-1.0,1.0, -1.0,-1.0,1.0, -1.0,1.0,-1.0, 1.0,1.0,-1.0, 1.0,1.0,1.0, -1.0,1.0,1.0, 1.0,-1.0,-1.0, 1.0,1.0,-1.0, 1.0,1.0,1.0, 1.0,-1.0,1.0, -1.0,-1.0,-1.0, -1.0,1.0,-1.0, -1.0,1.0,1.0, -1.0,-1.0,1.0 }; float stars[30000]; for(int i = 0; i < 30000; i+=3){ double za = D(rand() % 10000) / 1000.0 ; double xa = D(rand() % 10000) / 1000.0 ; double x = sin(za); double y = cos(za)*cos(xa); double z = sin(xa); stars[i] = x*100000; stars[i+1] = y*100000; stars[i+2] = z*100000; } FunnyShape = VBO(funnyShapeData,8,3,VBODrawType::Static); Plane = VBO(planeData,4,3,VBODrawType::Static); Plane2D = VBO(plane2DData,4,2,VBODrawType::Static); Stars = VBO(stars,10000,3,VBODrawType::Static); BoxShape = VBO(boxData,24,3,VBODrawType::Static); Smilie = Texture::FromFile("smilie.png",Interpolation::Linear, TextureWrap::Repeat,PixelFormat::RGB); Grass = Texture::FromFile("grass.png",Interpolation::Linear, TextureWrap::Repeat,PixelFormat::RGB); StarColors = Texture::FromFile("star_colors.png",Interpolation::Nearest, TextureWrap::Repeat, PixelFormat::RGB); }