Panda3D
xFileMesh.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file xFileMesh.h
10 * @author drose
11 * @date 2001-06-19
12 */
13
14#ifndef XFILEMESH_H
15#define XFILEMESH_H
16
17#include "pandatoolbase.h"
18#include "pvector.h"
19#include "epvector.h"
20#include "pmap.h"
21#include "indirectCompareTo.h"
22#include "namable.h"
23#include "coordinateSystem.h"
24
25#include "luse.h"
26
27class XFileNode;
28class XFileDataNode;
29class XFileMesh;
30class XFileVertex;
31class XFileNormal;
32class XFileMaterial;
33class XFileFace;
35class XFileDataNode;
36class EggGroupNode;
37class EggVertex;
38class EggPolygon;
39class EggPrimitive;
40class Datagram;
41
42/**
43 * This is a collection of polygons; i.e. a polyset.
44 */
45class XFileMesh : public Namable {
46public:
47 XFileMesh(CoordinateSystem cs = CS_yup_left);
48 ~XFileMesh();
49
50 void clear();
51
52 void add_polygon(EggPolygon *egg_poly);
53 int add_vertex(EggVertex *egg_vertex, EggPrimitive *egg_prim);
54 int add_normal(EggVertex *egg_vertex, EggPrimitive *egg_prim);
55 int add_material(EggPrimitive *egg_prim);
56
57 int add_vertex(XFileVertex *vertex);
58 int add_normal(XFileNormal *normal);
59 int add_material(XFileMaterial *material);
60
61 void set_egg_parent(EggGroupNode *egg_parent);
62
63 bool create_polygons(XFileToEggConverter *converter);
64
65 bool has_normals() const;
66 bool has_colors() const;
67 bool has_uvs() const;
68 bool has_materials() const;
69
70 int get_num_materials() const;
71 XFileMaterial *get_material(int n) const;
72
73 XFileDataNode *make_x_mesh(XFileNode *x_parent, const std::string &suffix);
74 XFileDataNode *make_x_normals(XFileNode *x_mesh, const std::string &suffix);
75 XFileDataNode *make_x_colors(XFileNode *x_mesh, const std::string &suffix);
76 XFileDataNode *make_x_uvs(XFileNode *x_mesh, const std::string &suffix);
77 XFileDataNode *make_x_material_list(XFileNode *x_mesh, const std::string &suffix);
78
79 bool fill_mesh(XFileDataNode *obj);
81 bool fill_normals(XFileDataNode *obj);
82 bool fill_colors(XFileDataNode *obj);
83 bool fill_uvs(XFileDataNode *obj);
86
87private:
92
93 CoordinateSystem _cs;
94
95 Vertices _vertices;
96 Normals _normals;
97 Materials _materials;
98 Faces _faces;
99
101
102 class SkinWeightsData {
103 public:
104 LMatrix4d _matrix_offset;
105 std::string _joint_name;
106 WeightMap _weight_map;
107 };
108 typedef epvector<SkinWeightsData> SkinWeights;
109 SkinWeights _skin_weights;
110
114 UniqueVertices _unique_vertices;
115 UniqueNormals _unique_normals;
116 UniqueMaterials _unique_materials;
117
118 bool _has_normals;
119 bool _has_colors;
120 bool _has_uvs;
121 bool _has_materials;
122
123 EggGroupNode *_egg_parent;
124};
125
126#endif
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:46
A single polygon.
Definition: eggPolygon.h:24
A base class for any of a number of kinds of geometry primitives: polygons, point lights,...
Definition: eggPrimitive.h:49
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal.
Definition: eggVertex.h:39
A base class for all things which can have a name.
Definition: namable.h:26
This is an abstract base class for an XFileNode which is also an XFileDataObject.
Definition: xFileDataNode.h:33
This represents a single face of an XFileMesh.
Definition: xFileFace.h:26
This represents an X file "material", which consists of a color, lighting, and/or texture specificati...
Definition: xFileMaterial.h:31
This is a collection of polygons; i.e.
Definition: xFileMesh.h:45
void clear()
Empties all data from the mesh.
Definition: xFileMesh.cxx:56
bool fill_mesh(XFileDataNode *obj)
Fills the structure based on the raw data from the X file's Mesh object.
Definition: xFileMesh.cxx:619
bool fill_skin_weights(XFileDataNode *obj)
Fills the structure based on the raw data from the SkinWeights template.
Definition: xFileMesh.cxx:796
bool fill_material_list(XFileDataNode *obj)
Fills the structure based on the raw data from the MeshMaterialList template.
Definition: xFileMesh.cxx:837
bool has_uvs() const
Returns true if any of the vertices added to this mesh used a texture coordinate, false otherwise.
Definition: xFileMesh.cxx:415
int add_vertex(EggVertex *egg_vertex, EggPrimitive *egg_prim)
Creates a new XFileVertex, if one does not already exist for the indicated vertex,...
Definition: xFileMesh.cxx:108
bool fill_uvs(XFileDataNode *obj)
Fills the structure based on the raw data from the MeshTextureCoords template.
Definition: xFileMesh.cxx:774
bool has_materials() const
Returns true if any of the faces added to this mesh used a real material, false otherwise.
Definition: xFileMesh.cxx:424
XFileDataNode * make_x_mesh(XFileNode *x_parent, const std::string &suffix)
Creates an X structure corresponding to the mesh.
Definition: xFileMesh.cxx:449
int get_num_materials() const
Returns the number of distinct materials associated with the mesh.
Definition: xFileMesh.cxx:432
int add_normal(EggVertex *egg_vertex, EggPrimitive *egg_prim)
Creates a new XFileNormal, if one does not already exist for the indicated normal,...
Definition: xFileMesh.cxx:140
bool fill_colors(XFileDataNode *obj)
Fills the structure based on the raw data from the MeshVertexColors template.
Definition: xFileMesh.cxx:750
bool fill_mesh_child(XFileDataNode *obj)
Fills the structure based on one of the children of the Mesh object.
Definition: xFileMesh.cxx:662
bool fill_normals(XFileDataNode *obj)
Fills the structure based on the raw data from the MeshNormals template.
Definition: xFileMesh.cxx:706
XFileDataNode * make_x_material_list(XFileNode *x_mesh, const std::string &suffix)
Creates a MeshMaterialList table for the mesh.
Definition: xFileMesh.cxx:586
XFileDataNode * make_x_colors(XFileNode *x_mesh, const std::string &suffix)
Creates a MeshVertexColors table for the mesh.
Definition: xFileMesh.cxx:543
void add_polygon(EggPolygon *egg_poly)
Adds the indicated polygon to the mesh.
Definition: xFileMesh.cxx:97
bool create_polygons(XFileToEggConverter *converter)
Creates a slew of EggPolygons according to the faces in the mesh, and adds them to the previously-ind...
Definition: xFileMesh.cxx:264
void set_egg_parent(EggGroupNode *egg_parent)
Specifies the egg node that will eventually be the parent of this mesh, when create_polygons() is lat...
Definition: xFileMesh.cxx:251
XFileDataNode * make_x_uvs(XFileNode *x_mesh, const std::string &suffix)
Creates a MeshTextureCoords table for the mesh.
Definition: xFileMesh.cxx:566
bool has_colors() const
Returns true if any of the vertices or faces added to this mesh used a color, false otherwise.
Definition: xFileMesh.cxx:406
XFileDataNode * make_x_normals(XFileNode *x_mesh, const std::string &suffix)
Creates a MeshNormals table for the mesh.
Definition: xFileMesh.cxx:506
XFileMaterial * get_material(int n) const
Returns a pointer to the nth materials associated with the mesh.
Definition: xFileMesh.cxx:440
int add_material(EggPrimitive *egg_prim)
Creates a new XFileMaterial, if one does not already exist for the indicated material,...
Definition: xFileMesh.cxx:168
bool has_normals() const
Returns true if any of the vertices or faces added to this mesh used a normal, false otherwise.
Definition: xFileMesh.cxx:397
A single node of an X file.
Definition: xFileNode.h:40
This represents a single normal associated with an XFileFace.
Definition: xFileNormal.h:28
This represents a single vertex associated with an XFileFace.
Definition: xFileVertex.h:26
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.