00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024 #ifndef SHUTIL_SHOBJMESH_HPP
00025 #define SHUTIL_SHOBJMESH_HPP
00026
00027 #include <iosfwd>
00028
00029 #include "sh.hpp"
00030 #include "ShMesh.hpp"
00031
00032 namespace ShUtil {
00033
00034 using namespace SH;
00035
00036 struct ShObjVertex;
00037 struct ShObjFace;
00038 struct ShObjEdge;
00039
00040 typedef ShMeshType<ShObjVertex, ShObjFace, ShObjEdge> ShObjMeshType;
00041
00042 struct ShObjVertex: public ShMeshVertex<ShObjMeshType> {
00043 ShPoint3f pos;
00044
00046 ShObjVertex(const ShPoint3f &p);
00047 };
00048
00049 struct ShObjFace: public ShMeshFace<ShObjMeshType> {
00050 ShNormal3f normal;
00051 };
00052
00053 struct ShObjEdge: public ShMeshEdge<ShObjMeshType> {
00054
00055 ShNormal3f normal;
00056 ShVector3f tangent;
00057 ShTexCoord2f texcoord;
00058 };
00059
00060
00061
00062
00063
00064
00065
00066
00067 class ShObjMesh: public ShMesh<ShObjMeshType> {
00068 public:
00069 typedef ShMesh<ShObjMeshType> ParentType;
00070
00072 ShObjMesh();
00073
00075 ShObjMesh(std::istream &in);
00076
00078 std::istream& readObj(std::istream &in);
00079
00081 void generateFaceNormals();
00082
00087 int generateVertexNormals(bool force = false);
00088
00094 int generateTangents(bool force = false);
00095
00101 int generateSphericalTexCoords(bool force = false);
00102
00104 void normalizeNormals();
00105
00109 void consolidateVertices();
00110
00112 friend std::istream& operator>>(std::istream &in, ShObjMesh &mesh);
00113 };
00114
00115 }
00116
00117 #endif