mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 19:08:55 -04:00
*** empty log message ***
This commit is contained in:
parent
703f3086a8
commit
5fc3406d31
@ -279,6 +279,32 @@ add_polyset(EggBin *egg_bin, LPDIRECTXFILEDATA dx_parent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mesh.has_colors()) {
|
||||||
|
// Tack on colors.
|
||||||
|
LPDIRECTXFILEDATA xcolors;
|
||||||
|
mesh.make_color_data(raw_data);
|
||||||
|
if (!create_object(xcolors, TID_D3DRMMeshVertexColors,
|
||||||
|
"colors" + mesh_index, raw_data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!attach_and_release(xcolors, xobj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mesh.has_uvs()) {
|
||||||
|
// Tack on texture coordinates.
|
||||||
|
LPDIRECTXFILEDATA xuvs;
|
||||||
|
mesh.make_uv_data(raw_data);
|
||||||
|
if (!create_object(xuvs, TID_D3DRMMeshTextureCoords,
|
||||||
|
"uvs" + mesh_index, raw_data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!attach_and_release(xuvs, xobj)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!attach_and_release(xobj, dx_parent)) {
|
if (!attach_and_release(xobj, dx_parent)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
XFileMesh::
|
XFileMesh::
|
||||||
XFileMesh() {
|
XFileMesh() {
|
||||||
_has_normals = false;
|
_has_normals = false;
|
||||||
|
_has_colors = false;
|
||||||
|
_has_uvs = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -38,7 +40,16 @@ XFileMesh() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
XFileMesh::
|
XFileMesh::
|
||||||
~XFileMesh() {
|
~XFileMesh() {
|
||||||
// ** Delete stuff.
|
Vertices::iterator vi;
|
||||||
|
for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
|
||||||
|
XFileVertex *vertex = (*vi);
|
||||||
|
delete vertex;
|
||||||
|
}
|
||||||
|
Normals::iterator ni;
|
||||||
|
for (ni = _normals.begin(); ni != _normals.end(); ++ni) {
|
||||||
|
XFileNormal *normal = (*ni);
|
||||||
|
delete normal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -63,6 +74,13 @@ int XFileMesh::
|
|||||||
add_vertex(EggVertex *egg_vertex, EggPrimitive *egg_prim) {
|
add_vertex(EggVertex *egg_vertex, EggPrimitive *egg_prim) {
|
||||||
int next_index = _vertices.size();
|
int next_index = _vertices.size();
|
||||||
XFileVertex *vertex = new XFileVertex(egg_vertex, egg_prim);
|
XFileVertex *vertex = new XFileVertex(egg_vertex, egg_prim);
|
||||||
|
if (vertex->_has_color) {
|
||||||
|
_has_colors = true;
|
||||||
|
}
|
||||||
|
if (vertex->_has_uv) {
|
||||||
|
_has_uvs = true;
|
||||||
|
}
|
||||||
|
|
||||||
pair<UniqueVertices::iterator, bool> result =
|
pair<UniqueVertices::iterator, bool> result =
|
||||||
_unique_vertices.insert(UniqueVertices::value_type(vertex, next_index));
|
_unique_vertices.insert(UniqueVertices::value_type(vertex, next_index));
|
||||||
|
|
||||||
@ -120,6 +138,28 @@ has_normals() const {
|
|||||||
return _has_normals;
|
return _has_normals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: XFileMesh::has_colors
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns true if any of the vertices or faces added to
|
||||||
|
// this mesh used a color, false otherwise.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool XFileMesh::
|
||||||
|
has_colors() const {
|
||||||
|
return _has_colors;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: XFileMesh::has_uvs
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns true if any of the vertices added to this
|
||||||
|
// mesh used a texture coordinate, false otherwise.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool XFileMesh::
|
||||||
|
has_uvs() const {
|
||||||
|
return _has_uvs;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: XFileMesh::make_mesh_data
|
// Function: XFileMesh::make_mesh_data
|
||||||
// Access: Public
|
// Access: Public
|
||||||
@ -189,3 +229,48 @@ make_normal_data(Datagram &raw_data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: XFileMesh::make_color_data
|
||||||
|
// Access: Public
|
||||||
|
// Description: Fills the datagram with the raw data for the DX
|
||||||
|
// MeshVertexColors template.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void XFileMesh::
|
||||||
|
make_color_data(Datagram &raw_data) {
|
||||||
|
raw_data.clear();
|
||||||
|
raw_data.add_int32(_vertices.size());
|
||||||
|
|
||||||
|
Vertices::const_iterator vi;
|
||||||
|
int i = 0;
|
||||||
|
for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
|
||||||
|
XFileVertex *vertex = (*vi);
|
||||||
|
const Colorf &color = vertex->_color;
|
||||||
|
raw_data.add_int32(i);
|
||||||
|
raw_data.add_float32(color[0]);
|
||||||
|
raw_data.add_float32(color[1]);
|
||||||
|
raw_data.add_float32(color[2]);
|
||||||
|
raw_data.add_float32(color[3]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: XFileMesh::make_uv_data
|
||||||
|
// Access: Public
|
||||||
|
// Description: Fills the datagram with the raw data for the DX
|
||||||
|
// MeshTextureCoords template.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void XFileMesh::
|
||||||
|
make_uv_data(Datagram &raw_data) {
|
||||||
|
raw_data.clear();
|
||||||
|
raw_data.add_int32(_vertices.size());
|
||||||
|
|
||||||
|
Vertices::const_iterator vi;
|
||||||
|
for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
|
||||||
|
XFileVertex *vertex = (*vi);
|
||||||
|
const TexCoordf &uv = vertex->_uv;
|
||||||
|
raw_data.add_float32(uv[0]);
|
||||||
|
raw_data.add_float32(uv[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -47,9 +47,13 @@ public:
|
|||||||
int add_normal(EggVertex *egg_vertex, EggPrimitive *egg_prim);
|
int add_normal(EggVertex *egg_vertex, EggPrimitive *egg_prim);
|
||||||
|
|
||||||
bool has_normals() const;
|
bool has_normals() const;
|
||||||
|
bool has_colors() const;
|
||||||
|
bool has_uvs() const;
|
||||||
|
|
||||||
void make_mesh_data(Datagram &raw_data);
|
void make_mesh_data(Datagram &raw_data);
|
||||||
void make_normal_data(Datagram &raw_data);
|
void make_normal_data(Datagram &raw_data);
|
||||||
|
void make_color_data(Datagram &raw_data);
|
||||||
|
void make_uv_data(Datagram &raw_data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef pvector<XFileVertex *> Vertices;
|
typedef pvector<XFileVertex *> Vertices;
|
||||||
@ -67,6 +71,8 @@ private:
|
|||||||
UniqueNormals _unique_normals;
|
UniqueNormals _unique_normals;
|
||||||
|
|
||||||
bool _has_normals;
|
bool _has_normals;
|
||||||
|
bool _has_colors;
|
||||||
|
bool _has_uvs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,12 +27,15 @@
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
XFileVertex::
|
XFileVertex::
|
||||||
XFileVertex(EggVertex *egg_vertex, EggPrimitive *egg_prim) {
|
XFileVertex(EggVertex *egg_vertex, EggPrimitive *egg_prim) {
|
||||||
|
_has_color = true;
|
||||||
|
_has_uv = true;
|
||||||
_point = LCAST(float, egg_vertex->get_pos3());
|
_point = LCAST(float, egg_vertex->get_pos3());
|
||||||
|
|
||||||
if (egg_vertex->has_uv()) {
|
if (egg_vertex->has_uv()) {
|
||||||
_uv = LCAST(float, egg_vertex->get_uv());
|
_uv = LCAST(float, egg_vertex->get_uv());
|
||||||
} else {
|
} else {
|
||||||
_uv.set(0.0, 0.0);
|
_uv.set(0.0, 0.0);
|
||||||
|
_has_uv = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (egg_vertex->has_color()) {
|
if (egg_vertex->has_color()) {
|
||||||
@ -41,6 +44,7 @@ XFileVertex(EggVertex *egg_vertex, EggPrimitive *egg_prim) {
|
|||||||
_color = egg_prim->get_color();
|
_color = egg_prim->get_color();
|
||||||
} else {
|
} else {
|
||||||
_color.set(1.0, 1.0, 1.0, 1.0);
|
_color.set(1.0, 1.0, 1.0, 1.0);
|
||||||
|
_has_color = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@ public:
|
|||||||
Vertexf _point;
|
Vertexf _point;
|
||||||
TexCoordf _uv;
|
TexCoordf _uv;
|
||||||
Colorf _color;
|
Colorf _color;
|
||||||
|
bool _has_color;
|
||||||
|
bool _has_uv;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user