5 #ifndef VART_MESHOBJECT_H
6 #define VART_MESHOBJECT_H
44 void MakeBox(
double minX,
double maxX,
double minY,
double maxY,
double minZ,
double maxZ);
51 void GetYProjection(std::list<Point4D>* resultPtr,
double height=0)
const;
73 void SetVertices(
const std::vector<Point4D>& vertexVec);
80 void SetNormals(
const std::vector<Point4D>& normalVec);
112 void AddFace(
const char* indexStr);
205 static bool ReadFromOBJ(
const std::string& filename, std::list<MeshObject*>* resultPtr);
287 static void ReadVertex(std::istringstream& iss,
unsigned int* vi,
unsigned int* ti,
unsigned int* ni);
290 std::map<std::string,Material>* matMapPtr);
293 std::list<VertexTriplet>* resultPtr);
302 void subDivideBBox(
VART::BoundingBox motherBox,
int subdivisions, std::vector<VART::Point4D> pointList );
305 void computeNewSubBBox(
VART::BoundingBox oldBox,
int subdivisions, std::vector<VART::Point4D> pointList);
311 std::vector<VART::BoundingBox> subBBoxes;
Base class for objects that compose a scene graph.
Point4D GetVertex(unsigned int pos)
Returns a copy of a vertex.
static void ReadMaterialTable(const std::string &filename, std::map< std::string, Material > *matMapPtr)
Points and vectors using homogeneous coordinates.
void AddNormal(unsigned int idx, const Point4D &vec)
Adds a vector to a vertex normal.
Header file for V-ART class "GraphicObj".
Point4D Vertex(unsigned int i) const
Returns a vertex as a Point4D.
static void ComputeTriangleNormal(const Point4D &v1, const Point4D &v2, const Point4D &v3, Point4D *resultPtr)
Computes the normal of a triangle.
void AddFace(const char *indexStr)
Adds a face (a mesh of a single polygon) based on previously set vertices.
std::list< Mesh > meshList
List of Meshes.
Header file for V-ART class "Mesh".
friend std::ostream & operator<<(std::ostream &output, const MeshObject &m)
Output operator.
void GetYProjection(std::list< Point4D > *resultPtr, double height=0) const
Computes the projection of all vertices along the Y axis.
Axis aligned bounding box.
void SetVertices(const std::vector< Point4D > &vertexVec)
Sets the vector of vertices.
A mesh is part of an graphical object, in which faces are made of vertices according to some rule of ...
std::vector< VART::BoundingBox > GetSubBBoxes()
returns the list of subdivided bounding boxes.
Point4D GetVertexMedia()
Return the Aritmethic mean of vertexes values.
virtual TypeID GetID() const
Returns type identification of the node.
bool IsEmpty()
Checks whether the object contains geometry data.
std::vector< double > normCoordVec
Vector of all vertex normals (their coordinates in sequence).
void NormalizeAllNormals()
Normalizes all vertex normals.
void SmallerVertex(Point4D *resultPtr)
Computes and returns the smaller vertex.
virtual void ComputeBoundingBox()
Computes the bounding box.
An scene node that is associated with a shape.
void Clear()
Erases internal structures.
Material properties for graphical objects.
std::vector< float > textCoordVec
Vector of all texture coordinates.
void SetMaterial(const Material &mat)
Assigns a material to all meshes of the mesh object.
VertexTriplet(unsigned int vi, unsigned int ti, unsigned int ni)
virtual bool DrawInstanceOGL() const
Non-recursive drawing - should be overriden by every derived class.
void ComputeSubBBoxes(const Transform &trans, int subdivisions)
Computes de SubBBoxes and stores them.
void AddMesh(const Mesh &m)
Adds a copy of the mesh to the object.
unsigned int NumFaces()
Computes the number of faces.
void ApplyTransform(const Transform &trans)
Apply Transformation to all vertices.
static float sizeOfNormals
Size of normals for rendering (in world coordinates).
void SetVertex(unsigned int index, const Point4D &newValue)
Changes one vertex.
void SetNormals(const std::vector< Point4D > &normalVec)
Sets the vector of normals.
static void ReadVertex(std::istringstream &iss, unsigned int *vi, unsigned int *ti, unsigned int *ni)
Reads a vertex description from a face on a OBJ file.
bool operator<(VertexTriplet indexes) const
std::vector< double > vertCoordVec
Vector of all vertex coordinates (their coordinates in sequence).
std::vector< Point4D > normVec
Vector of all normals.
const std::vector< double > & GetVerticesCoordinates()
Returns the coordinates of the vertices in the object.
static void ReadVerticesLine(std::istringstream &input, std::list< VertexTriplet > *resultPtr)
Header file for V-ART class "Point4D".
void Optimize()
Optimize object for display.
std::vector< Point4D > vertVec
Vector of all vertices.
static bool ReadFromOBJ(const std::string &filename, std::list< MeshObject * > *resultPtr)
Read MeshObjects from a Wavefront OBJ file.
void MakeBox(double minX, double maxX, double minY, double maxY, double minZ, double maxZ)
Creates a box aligned with the 3 reference planes (XY, XZ and YZ).
void MergeWith(const MeshObject &obj)
Merges one mesh object with another.
virtual VART::SceneNode * Copy()
Returns a copy of an MeshObject. Every derived class must reimplements this method, to avoid errors with VART::SceneNode::RecursiveCopy.
void ComputeVertexNormals()
Computes the normal of every vertex.
Graphical object made of polygon meshes.
MeshObject & operator=(const MeshObject &obj)