00001
00010 #ifndef _NektarMODEL_H
00011 #define _NektarMODEL_H
00012
00013 #include <G3D/G3D.h>
00014 #include <GLG3D/PosedModel.h>
00015 #include "IS3DCommon.H"
00016
00017
00018
00019
00020 namespace IS3D {
00021
00022
00023 typedef ReferenceCountedPointer<class NektarModel> NektarModelRef;
00029 class NektarModelObj;
00030
00031 class NektarModel : public ReferenceCountedObject {
00032
00033 private:
00034
00035
00036
00037
00038
00039 class PosedNektarModel : public PosedModel {
00040 public:
00041 NektarModelRef model;
00042 CoordinateFrame cframe;
00043 bool perVertexNormals;
00044 bool useMaterial;
00045 GMaterial material;
00046 static GFontRef labelFont;
00047
00048 PosedNektarModel(NektarModelRef _model, const CoordinateFrame& _cframe, bool _pvn,
00049 const GMaterial& _mat, bool _useMat);
00050 virtual ~PosedNektarModel() {}
00051 virtual std::string name() const;
00052 virtual void getCoordinateFrame(CoordinateFrame&) const;
00053 virtual const MeshAlg::Geometry& objectSpaceGeometry() const;
00054 virtual const Array<MeshAlg::Face>& faces() const;
00055 virtual const Array<MeshAlg::Edge>& edges() const;
00056 virtual const Array<MeshAlg::Vertex>& vertices() const;
00057 virtual const Array<MeshAlg::Face>& weldedFaces() const;
00058 virtual const Array<MeshAlg::Edge>& weldedEdges() const;
00059 virtual const Array<MeshAlg::Vertex>& weldedVertices() const;
00060 virtual const Array<int>& triangleIndices() const;
00061 virtual void getObjectSpaceBoundingSphere(Sphere&) const;
00062 virtual void getObjectSpaceBoundingBox(Box&) const;
00063 virtual void render(RenderDevice* renderDevice) const;
00064 virtual int numBoundaryEdges() const;
00065 virtual int numWeldedBoundaryEdges() const;
00066 virtual const Array<Vector3>& objectSpaceFaceNormals(bool normalize = true) const;
00067 };
00068
00069 friend class PosedNektarModel;
00070 friend class NektarModelObj;
00071
00072 std::string filename;
00073
00074
00075 Array< MeshAlg::Geometry > geometry;
00076 Array< Array<int> > indexArray;
00077
00078
00079 Array< Array<Vector3> > faceNormalArray;
00080 Array< Array<MeshAlg::Face> > weldedFaceArray;
00081 Array< Array<MeshAlg::Edge> > weldedEdgeArray;
00082 Array< Array<MeshAlg::Vertex> > weldedVertexArray;
00083 Array< Array<MeshAlg::Face> > faceArray;
00084 Array< Array<MeshAlg::Edge> > edgeArray;
00085 Array< Array<MeshAlg::Vertex> > vertexArray;
00086
00087
00088 Sphere boundingSphere;
00089 Box boundingBox;
00090 int numBoundaryEdges;
00091 int numWeldedBoundaryEdges;
00092 std::string name;
00093
00094 int _num_triangles, _num_timesteps, _curr_timestep;
00095 bool _show_vertex_numbers, _show_face_numbers;
00096
00098 static VARAreaRef varArea;
00099
00101 NektarModel();
00102
00104 void load(const std::string& filename,
00105 int numTriangles, int numTimesteps,
00106 const Vector3& scale, const CoordinateFrame& cframe);
00107
00109 void reset();
00110
00112 void makeG3DMesh();
00113
00115 void parseAllTimesteps( TextInput& nektarTextFile );
00116 void parseTimestep ( TextInput& nektarTextFile );
00117 void parseTriangle ( TextInput& nektarTextFile );
00118
00119 public:
00120
00121 virtual ~NektarModel();
00122
00132 static NektarModelRef create(const std::string& filename,
00133 int numTriangles, int numTimesteps,
00134 const Vector3& scale = Vector3(1,1,1), const CoordinateFrame& cframe = CoordinateFrame());
00135 static NektarModelRef create(const std::string& filename,
00136 int numTriangles, int numTimesteps,
00137 const double scale, const CoordinateFrame& cframe = CoordinateFrame());
00138
00144 virtual PosedModelRef pose(const CoordinateFrame& cframe, bool perVertexNormals = true);
00145
00150 virtual PosedModelRef pose(const CoordinateFrame& cframe, const GMaterial& material, bool perVertexNormals = true);
00151
00152 virtual size_t mainMemorySize() const;
00153
00154 virtual const MeshAlg::Geometry& getGeometry() { return geometry[ _curr_timestep ]; }
00155
00156
00157 };
00158
00159 }
00160
00161 #endif