Panda3D
eggToObjConverter.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 eggToObjConverter.h
10  * @author drose
11  * @date 2012-12-19
12  */
13 
14 #ifndef EGGTOOBJCONVERTER_H
15 #define EGGTOOBJCONVERTER_H
16 
17 #include "pandatoolbase.h"
18 
20 #include "eggVertexPool.h"
21 #include "eggGroup.h"
22 
23 /**
24  * Convert an obj file to egg data.
25  */
27 public:
31 
33 
34  virtual std::string get_name() const;
35  virtual std::string get_extension() const;
36  virtual bool supports_compressed() const;
37 
38  virtual bool write_file(const Filename &filename);
39 
40 private:
42  class VertexDef {
43  public:
44  VertexDef();
45  int _vert3_index;
46  int _vert4_index;
47  int _uv2_index;
48  int _uv3_index;
49  int _norm_index;
50  };
52 
53  bool process(const Filename &filename);
54 
55  void collect_vertices(EggNode *egg_node);
56  void write_faces(std::ostream &out, EggNode *egg_node);
57  void write_group_reference(std::ostream &out, EggNode *egg_node);
58  void get_group_name(std::string &group_name, EggGroupNode *egg_group);
59 
60  void record_vertex(EggVertex *vertex);
61  int record_unique(UniqueVertices &unique, const LVecBase4d &vec);
62  int record_unique(UniqueVertices &unique, const LVecBase3d &vec);
63  int record_unique(UniqueVertices &unique, const LVecBase2d &vec);
64  int record_unique(UniqueVertices &unique, double pos);
65 
66  void write_vertices(std::ostream &out, const std::string &prefix, int num_components,
67  const UniqueVertices &unique);
68 
69 private:
70  UniqueVertices _unique_vert3, _unique_vert4, _unique_uv2, _unique_uv3, _unique_norm;
71  VertexMap _vmap;
72  EggGroupNode *_current_group;
73 };
74 
75 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual bool supports_compressed() const
Returns true if this file type can transparently save compressed files (with a .pz extension),...
virtual std::string get_extension() const
Returns the common extension of the file type this converter supports.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:46
virtual bool write_file(const Filename &filename)
Handles the conversion of the internal EggData to the target file format, written to the specified fi...
virtual EggToSomethingConverter * make_copy()
Allocates and returns a new copy of the converter.
virtual std::string get_name() const
Returns the English name of the file type this converter supports.
This is a base class for a family of converter classes that manage a conversion from egg format to so...
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal.
Definition: eggVertex.h:39
A base class for things that may be directly added into the egg hierarchy.
Definition: eggNode.h:35
Convert an obj file to egg data.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.