00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef MESHDRAWER_H
00017 #define MESHDRAWER_H
00018
00019 #include "pandabase.h"
00020 #include "luse.h"
00021 #include "pandaNode.h"
00022 #include "pointerTo.h"
00023 #include "lpoint2.h"
00024 #include "lvecBase2.h"
00025 #include "pnmImage.h"
00026 #include "nodePath.h"
00027 #include "texture.h"
00028 #include "geomVertexFormat.h"
00029 #include "geomVertexArrayFormat.h"
00030 #include "geomVertexData.h"
00031 #include "geomVertexWriter.h"
00032 #include "geomVertexRewriter.h"
00033 #include "boundingVolume.h"
00034
00035 #include "nodePathCollection.h"
00036
00037 #include "geomTristrips.h"
00038 #include "geomTriangles.h"
00039 #include "geom.h"
00040 #include "geomNode.h"
00041 #include "nodePath.h"
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 class EXPCL_PANDA_GRUTIL MeshDrawer : public TypedObject {
00059 PUBLISHED:
00060 INLINE MeshDrawer();
00061 INLINE ~MeshDrawer();
00062
00063 INLINE void set_budget(int budget);
00064 INLINE int get_budget();
00065
00066 INLINE NodePath get_root();
00067
00068 void begin(NodePath camera, NodePath render);
00069 INLINE void tri(const LVector3 &v1, const LVector4 &c1, const LVector2 &uv1,
00070 const LVector3 &v2, const LVector4 &c2, const LVector2 &uv2,
00071 const LVector3 &v3, const LVector4 &c3, const LVector2 &uv3);
00072
00073 void particle(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, const LVector4 &color, PN_stdfloat rotation);
00074 void blended_particle(const LVector3 &pos, const LVector4 &frame1, const LVector4 &frame2,
00075 PN_stdfloat blend, PN_stdfloat size, const LVector4 &color, PN_stdfloat rotation);
00076 void billboard(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, const LVector4 &color);
00077 void segment(const LVector3 &start, const LVector3 &stop, const LVector4 &frame, PN_stdfloat thickness, const LVector4 &color);
00078 void cross_segment(const LVector3 &start, const LVector3 &stop, const LVector4 &frame, PN_stdfloat thickness, const LVector4 &color);
00079 void uneven_segment(const LVector3 &start, const LVector3 &stop,
00080 const LVector4 &frame, PN_stdfloat thickness_start, const LVector4 &color_start,
00081 PN_stdfloat thickness_stop, const LVector4 &color_stop);
00082
00083 void link_segment(const LVector3 &pos, const LVector4 &frame, PN_stdfloat thickness, const LVector4 &color);
00084 void link_segment_end(const LVector4 &frame, const LVector4 &color);
00085
00086 void explosion(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, const LVector4 &color,
00087 int seed, int number, PN_stdfloat distance);
00088 void stream(const LVector3 &start, const LVector3 &stop, const LVector4 &frame, PN_stdfloat size, const LVector4 &color,
00089 int number, PN_stdfloat offset);
00090 void geometry(NodePath node);
00091 void end();
00092
00093 private:
00094
00095
00096 NodePath _root;
00097 NodePath _camera, _render;
00098 int _budget;
00099
00100
00101 PT(Geom) _geom;
00102 PT(GeomNode) _geomnode;
00103 PT(GeomVertexData) _vdata;
00104 PT(GeomTriangles) _prim;
00105 CPT(GeomPrimitive) _dprim;
00106
00107
00108 GeomVertexRewriter *_vertex;
00109 GeomVertexRewriter *_normal;
00110 GeomVertexRewriter *_uv;
00111 GeomVertexRewriter *_color;
00112
00113
00114 LVector4 _colorv;
00115 LVector3 _normalv;
00116 LVector3 _eyePos;
00117 LVector3 _b1, _b2, _b3, _b4;
00118 LVector3 _up, _right;
00119
00120
00121 int _last_clear_index, _start_clear_index, _end_clear_index, _clear_index;
00122
00123
00124 int _at_start;
00125 LVector3 _last_v1,_last_v2,_last_v3,_last_v4,_last_pos;
00126 PN_stdfloat _last_thickness;
00127 LVector4 _last_color;
00128
00129
00130 PT(BoundingVolume) _bv;
00131
00132
00133 void generator(int budget);
00134
00135 public:
00136 static TypeHandle get_class_type() {
00137 return _type_handle;
00138 }
00139 static void init_type() {
00140 TypedObject::init_type();
00141 register_type(_type_handle, "MeshDrawer",
00142 TypedObject::get_class_type());
00143 }
00144 virtual TypeHandle get_type() const {
00145 return get_class_type();
00146 }
00147 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00148
00149 private:
00150 static TypeHandle _type_handle;
00151
00152 };
00153
00154 #include "meshDrawer.I"
00155
00156 #endif