Panda3D
 All Classes Functions Variables Enumerations
indexedFaceSet.h
00001 // Filename: indexedFaceSet.h
00002 // Created by:  drose (24Jun99)
00003 // 
00004 ////////////////////////////////////////////////////////////////////
00005 // PANDA 3D SOFTWARE
00006 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00007 //
00008 // All use of this software is subject to the terms of the revised BSD
00009 // license.  You should have received a copy of this license along
00010 // with this source code in a file named "LICENSE."
00011 ////////////////////////////////////////////////////////////////////
00012 
00013 #ifndef INDEXEDFACESET_H
00014 #define INDEXEDFACESET_H
00015 
00016 #include "pandatoolbase.h"
00017 #include "pvector.h"
00018 #include "pset.h"
00019 #include "eggPolygon.h"
00020 #include "eggVertex.h"
00021 #include "eggAttributes.h"
00022 
00023 class VrmlNode;
00024 class EggData;
00025 class EggGroup;
00026 class EggVertexPool;
00027 class VRMLAppearance;
00028 class LMatrix4d;
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //       Class : IndexedFaceSet
00032 // Description : Decodes the vertices and faces in a VRML indexed face
00033 //               set, and creates the corresponding egg geometry.
00034 ////////////////////////////////////////////////////////////////////
00035 class IndexedFaceSet {
00036 public:
00037   IndexedFaceSet(const VrmlNode *geometry, const VRMLAppearance &appearance);
00038 
00039   void convert_to_egg(EggGroup *group, const LMatrix4d &net_transform);
00040 
00041 private:
00042   void get_coord_values();
00043   void get_polys();
00044   void get_vrml_colors(const VrmlNode *color_node, double transparency,
00045                        pvector<UnalignedLVecBase4> &color_list);
00046   void get_vrml_normals(const VrmlNode *normal_node, 
00047                         pvector<LNormald> &normal_list);
00048   void get_vrml_uvs(const VrmlNode *texCoord_node, 
00049                     pvector<LTexCoordd> &uv_list);
00050 
00051   bool get_colors();
00052   bool get_normals();
00053   void assign_per_vertex_normals();
00054   bool get_uvs();
00055   void assign_per_vertex_uvs();
00056   void make_polys(EggVertexPool *vpool, EggGroup *group,
00057                   const LMatrix4d &net_transform);
00058   void compute_normals(EggGroup *group);
00059 
00060   class VrmlVertex {
00061   public:
00062     int _index;
00063     LVertexd _pos;
00064     EggVertex _attrib;
00065   };
00066   class VrmlPolygon {
00067   public:
00068     EggPolygon _attrib;
00069     epvector<VrmlVertex> _verts;
00070   };
00071   pvector<LVertexd> _coord_values;
00072   epvector<VrmlPolygon> _polys;
00073   pvector<LTexCoordd> _per_vertex_uvs;
00074   pvector<LNormald> _per_vertex_normals;
00075 
00076   bool _has_normals;
00077 
00078   const VrmlNode *_geometry;
00079   const VRMLAppearance &_appearance;
00080 };
00081 
00082 #endif
 All Classes Functions Variables Enumerations