From: Oliver O. <fr...@us...> - 2007-06-22 13:48:23
|
Update of /cvsroot/simspark/simspark/spark/oxygen/geometryserver In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv30985 Modified Files: Tag: projectx stdmeshimporter.cpp Log Message: update from rcssserver3D Index: stdmeshimporter.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/geometryserver/stdmeshimporter.cpp,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.1.2.1 diff -C2 -d -r1.1.2.1 -r1.1.2.1.2.1 *** stdmeshimporter.cpp 9 Feb 2007 20:11:56 -0000 1.1.2.1 --- stdmeshimporter.cpp 22 Jun 2007 13:48:20 -0000 1.1.2.1.2.1 *************** *** 42,45 **** --- 42,46 ---- static const string gBoxStr = "StdUnitBox"; static const string gCCylinderStr = "StdCCylinder"; + static const string gCylinderStr = "StdUnitCylinder"; shared_ptr<TriMesh> *************** *** 61,64 **** --- 62,70 ---- } + if (name == gCylinderStr) + { + return UnitCylinder(); + } + return shared_ptr<TriMesh>(); } *************** *** 435,436 **** --- 441,739 ---- } + // + // unit cylinder (radius = 1, length = 1) + // + + static const int gNumCylinderVertices = 66; + static const int gNumCylinderFaces = 128; + + static float gCylinderVertices[gNumCylinderVertices*3] = + { + 0.70711,0.70711,-0.5, + 0.83147,0.55557,-0.5, + 0.92388,0.38268,-0.5, + 0.98079,0.19509,-0.5, + 1.0,0.0,-0.5, + 0.98079,-0.19509,-0.5, + 0.92388,-0.38268,-0.5, + 0.83147,-0.55557,-0.5, + 0.70711,-0.70711,-0.5, + 0.55557,-0.83147,-0.5, + 0.38268,-0.92388,-0.5, + 0.19509,-0.98079,-0.5, + -0.0,-1.0,-0.5, + -0.19509,-0.98079,-0.5, + -0.38268,-0.92388,-0.5, + -0.55557,-0.83147,-0.5, + -0.70711,-0.70711,-0.5, + -0.83147,-0.55557,-0.5, + -0.92388,-0.38268,-0.5, + -0.98079,-0.19509,-0.5, + -1.0,0.0,-0.5, + -0.98079,0.19509,-0.5, + -0.92388,0.38268,-0.5, + -0.83147,0.55557,-0.5, + -0.70711,0.70711,-0.5, + -0.55557,0.83147,-0.5, + -0.38268,0.92388,-0.5, + -0.19509,0.98079,-0.5, + 0.0,1.0,-0.5, + 0.19509,0.98078,-0.5, + 0.38269,0.92388,-0.5, + 0.55557,0.83147,-0.5, + 0.70711,0.70711,0.5, + 0.83147,0.55557,0.5, + 0.92388,0.38268,0.5, + 0.98079,0.19509,0.5, + 1.0,-0.0,0.5, + 0.98078,-0.19509,0.5, + 0.92388,-0.38268,0.5, + 0.83147,-0.55557,0.5, + 0.70711,-0.70711,0.5, + 0.55557,-0.83147,0.5, + 0.38268,-0.92388,0.5, + 0.19509,-0.98079,0.5, + 0.0,-1.0,0.5, + -0.19509,-0.98079,0.5, + -0.38268,-0.92388,0.5, + -0.55557,-0.83147,0.5, + -0.7071,-0.70711,0.5, + -0.83147,-0.55557,0.5, + -0.92388,-0.38269,0.5, + -0.98078,-0.19509,0.5, + -1.0,-0.0,0.5, + -0.98079,0.19509,0.5, + -0.92388,0.38268,0.5, + -0.83147,0.55557,0.5, + -0.70711,0.7071,0.5, + -0.55558,0.83147,0.5, + -0.38269,0.92388,0.5, + -0.1951,0.98078,0.5, + -1e-05,1.0,0.5, + 0.19508,0.98079,0.5, + 0.38268,0.92388,0.5, + 0.55556,0.83147,0.5, + 0.0,-0.0,-0.5, + 0.0,0.0,0.5 + }; + + static float gCylinderNormals[gNumCylinderVertices*3] = + { + 0.49876,0.49876,-0.70879, + 0.5865,0.39189,-0.70879, + 0.65169,0.26994,-0.70879, + 0.69182,0.13761,-0.70879, + 0.70537,0.0,-0.70879, + 0.69182,-0.13761,-0.70879, + 0.65169,-0.26994,-0.70879, + 0.5865,-0.39189,-0.70879, + 0.49876,-0.49876,-0.70879, + 0.39189,-0.5865,-0.70879, + 0.26994,-0.65169,-0.70879, + 0.13761,-0.69182,-0.70879, + 0.0,-0.70537,-0.70879, + -0.13761,-0.69182,-0.70879, + -0.26994,-0.65169,-0.70879, + -0.39189,-0.5865,-0.70879, + -0.49876,-0.49876,-0.70879, + -0.5865,-0.39189,-0.70879, + -0.65169,-0.26994,-0.70879, + -0.69182,-0.13761,-0.70879, + -0.70537,0.0,-0.70879, + -0.69182,0.13761,-0.70879, + -0.65169,0.26994,-0.70879, + -0.5865,0.39189,-0.70879, + -0.49876,0.49876,-0.70879, + -0.39189,0.5865,-0.70879, + -0.26994,0.65169,-0.70879, + -0.13761,0.69182,-0.70879, + 0.0,0.70537,-0.70879, + 0.13761,0.69182,-0.70879, + 0.26994,0.65169,-0.70879, + 0.39189,0.5865,-0.70879, + 0.49876,0.49876,0.70879, + 0.5865,0.39189,0.70879, + 0.65169,0.26994,0.70879, + 0.69182,0.13761,0.70879, + 0.70537,0.0,0.70879, + 0.69182,-0.13761,0.70879, + 0.65169,-0.26994,0.70879, + 0.5865,-0.39189,0.70879, + 0.49876,-0.49876,0.70879, + 0.39189,-0.5865,0.70879, + 0.26994,-0.65169,0.70879, + 0.13761,-0.69182,0.70879, + 0.0,-0.70537,0.70879, + -0.13761,-0.69182,0.70879, + -0.26994,-0.65169,0.70879, + -0.39189,-0.5865,0.70879, + -0.49876,-0.49876,0.70879, + -0.5865,-0.39189,0.70879, + -0.65169,-0.26994,0.70879, + -0.69182,-0.13761,0.70879, + -0.70537,0.0,0.70879, + -0.69182,0.13761,0.70879, + -0.65169,0.26994,0.70879, + -0.5865,0.39189,0.70879, + -0.49876,0.49876,0.70879, + -0.39189,0.5865,0.70879, + -0.26994,0.65169,0.70879, + -0.13761,0.69182,0.70879, + 0.0,0.70537,0.70879, + 0.13761,0.69182,0.70879, + 0.26994,0.65169,0.70879, + 0.39189,0.5865,0.70879, + 0.0,0.0,-1.0, + 0.0,0.0,1.0 + }; + + static unsigned int gCylinderFaces[gNumCylinderFaces*3] = + { + 64,0,1, + 65,33,32, + 64,1,2, + 65,34,33, + 64,2,3, + 65,35,34, + 64,3,4, + 65,36,35, + 64,4,5, + 65,37,36, + 64,5,6, + 65,38,37, + 64,6,7, + 65,39,38, + 64,7,8, + 65,40,39, + 64,8,9, + 65,41,40, + 64,9,10, + 65,42,41, + 64,10,11, + 65,43,42, + 64,11,12, + 65,44,43, + 64,12,13, + 65,45,44, + 64,13,14, + 65,46,45, + 64,14,15, + 65,47,46, + 64,15,16, + 65,48,47, + 64,16,17, + 65,49,48, + 64,17,18, + 65,50,49, + 64,18,19, + 65,51,50, + 64,19,20, + 65,52,51, + 64,20,21, + 65,53,52, + 64,21,22, + 65,54,53, + 64,22,23, + 65,55,54, + 64,23,24, + 65,56,55, + 64,24,25, + 65,57,56, + 64,25,26, + 65,58,57, + 64,26,27, + 65,59,58, + 64,27,28, + 65,60,59, + 64,28,29, + 65,61,60, + 64,29,30, + 65,62,61, + 64,30,31, + 65,63,62, + 31,0,64, + 65,32,63, + 0,32,33, + 33,1,0, + 1,33,34, + 34,2,1, + 2,34,35, + 35,3,2, + 3,35,36, + 36,4,3, + 4,36,37, + 37,5,4, + 5,37,38, + 38,6,5, + 6,38,39, + 39,7,6, + 7,39,40, + 40,8,7, + 8,40,41, + 41,9,8, + 9,41,42, + 42,10,9, + 10,42,43, + 43,11,10, + 11,43,44, + 44,12,11, + 12,44,45, + 45,13,12, + 13,45,46, + 46,14,13, + 14,46,47, + 47,15,14, + 15,47,48, + 48,16,15, + 16,48,49, + 49,17,16, + 17,49,50, + 50,18,17, + 18,50,51, + 51,19,18, + 19,51,52, + 52,20,19, + 20,52,53, + 53,21,20, + 21,53,54, + 54,22,21, + 22,54,55, + 55,23,22, + 23,55,56, + 56,24,23, + 24,56,57, + 57,25,24, + 25,57,58, + 58,26,25, + 26,58,59, + 59,27,26, + 27,59,60, + 60,28,27, + 28,60,61, + 61,29,28, + 29,61,62, + 62,30,29, + 30,62,63, + 63,31,30, + 32,0,31, + 31,63,32 + }; + + shared_ptr<TriMesh> StdMeshImporter::UnitCylinder() + { + shared_ptr<TriMesh> mesh(new TriMesh()); + + shared_array<float> pos(new float[gNumCylinderVertices*3]); + memcpy(pos.get(),gCylinderVertices,gNumCylinderVertices*3*sizeof(float)); + mesh->SetPos(pos,gNumCylinderVertices); + + shared_array<float> normals(new float[gNumCylinderVertices*3]); + memcpy(normals.get(),gCylinderNormals,gNumCylinderVertices*3*sizeof(float)); + mesh->SetNormals(normals); + + shared_ptr<IndexBuffer> idx(new IndexBuffer()); + idx->Cache(gNumCylinderFaces*3,gCylinderFaces); + mesh->AddFace(idx); + + return mesh; + } |