to dos format

This commit is contained in:
rdb 2008-12-21 19:14:19 +00:00
parent 6d4d8f8ea9
commit 98d970ed2c
3 changed files with 779 additions and 779 deletions

View File

@ -1,129 +1,129 @@
// Filename: meshDrawer.I // Filename: meshDrawer.I
// Created by: treeform (19dec08) // Created by: treeform (19dec08)
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// //
// PANDA 3D SOFTWARE // PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved. // Copyright (c) Carnegie Mellon University. All rights reserved.
// //
// All use of this software is subject to the terms of the revised BSD // All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along // license. You should have received a copy of this license along
// with this source code in a file named "LICENSE." // with this source code in a file named "LICENSE."
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include "lpoint2.h" #include "lpoint2.h"
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: MeshDrawer::Constructor // Function: MeshDrawer::Constructor
// Access: Published // Access: Published
// Description: Creates the MeshDrawer low level system. // Description: Creates the MeshDrawer low level system.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE MeshDrawer:: INLINE MeshDrawer::
MeshDrawer() { MeshDrawer() {
_root = NodePath("MeshDrawer"); _root = NodePath("MeshDrawer");
_at_start = 0; _at_start = 0;
_bv = NULL; _bv = NULL;
_vertex = NULL; _vertex = NULL;
_normal = NULL; _normal = NULL;
_uv = NULL; _uv = NULL;
_color = NULL; _color = NULL;
_budget = 5000; _budget = 5000;
_plate_size = 16; _plate_size = 16;
_frame_size = 1.0f / float(_plate_size); _frame_size = 1.0f / float(_plate_size);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: MeshDrawer::Destructor // Function: MeshDrawer::Destructor
// Access: Published // Access: Published
// Description: Destroys the MeshDrawer low level system. // Description: Destroys the MeshDrawer low level system.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE MeshDrawer:: INLINE MeshDrawer::
~MeshDrawer() { ~MeshDrawer() {
_root.remove_node(); _root.remove_node();
if (_vertex != NULL) delete _vertex; if (_vertex != NULL) delete _vertex;
if (_normal != NULL) delete _normal; if (_normal != NULL) delete _normal;
if (_uv != NULL) delete _uv; if (_uv != NULL) delete _uv;
if (_color != NULL) delete _color; if (_color != NULL) delete _color;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: MeshDrawer::set_plate_size // Function: MeshDrawer::set_plate_size
// Access: Published // Access: Published
// Description: Sets the number of images are on one side // Description: Sets the number of images are on one side
// of a sqare plate. // of a sqare plate.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE void MeshDrawer:: INLINE void MeshDrawer::
set_plate_size(int one_side_size) { set_plate_size(int one_side_size) {
_plate_size = one_side_size; _plate_size = one_side_size;
_frame_size = 1.0f / float(_plate_size); _frame_size = 1.0f / float(_plate_size);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: MeshDrawer::get_plate_size // Function: MeshDrawer::get_plate_size
// Access: Published // Access: Published
// Description: Gets the number of images are on one side // Description: Gets the number of images are on one side
// of a sqare plate. // of a sqare plate.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE int MeshDrawer:: INLINE int MeshDrawer::
get_plate_size() { get_plate_size() {
return _plate_size; return _plate_size;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: MeshDrawer::get_root // Function: MeshDrawer::get_root
// Access: Published // Access: Published
// Description: Returns the root NodePath. // Description: Returns the root NodePath.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE NodePath MeshDrawer:: INLINE NodePath MeshDrawer::
get_root() { get_root() {
return _root; return _root;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: MeshDrawer::set_budget // Function: MeshDrawer::set_budget
// Access: Published // Access: Published
// Description: Sets the total budget of particles. // Description: Sets the total budget of particles.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE void MeshDrawer:: INLINE void MeshDrawer::
set_budget(int total_budget) { set_budget(int total_budget) {
_budget = total_budget; _budget = total_budget;
generator(_budget); generator(_budget);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: MeshDrawer::get_budget() // Function: MeshDrawer::get_budget()
// Access: Published // Access: Published
// Description: Gets the total budget of particles. // Description: Gets the total budget of particles.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE int MeshDrawer:: INLINE int MeshDrawer::
get_budget() { get_budget() {
return _budget; return _budget;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: MeshDrawer::tri // Function: MeshDrawer::tri
// Access: Published // Access: Published
// Description: Draws a triangle with the given parameters. // Description: Draws a triangle with the given parameters.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE void MeshDrawer::tri(LVector3f v1, LVector4f c1, LVector2f uv1, INLINE void MeshDrawer::tri(LVector3f v1, LVector4f c1, LVector2f uv1,
LVector3f v2, LVector4f c2, LVector2f uv2, LVector3f v2, LVector4f c2, LVector2f uv2,
LVector3f v3, LVector4f c3, LVector2f uv3) { LVector3f v3, LVector4f c3, LVector2f uv3) {
if( _clear_index > _end_clear_index) return; if( _clear_index > _end_clear_index) return;
_vertex->add_data3f(v1); _vertex->add_data3f(v1);
_color->add_data4f(c1); _color->add_data4f(c1);
_uv->add_data2f(uv1); _uv->add_data2f(uv1);
_vertex->add_data3f(v2); _vertex->add_data3f(v2);
_color->add_data4f(c2); _color->add_data4f(c2);
_uv->add_data2f(uv2); _uv->add_data2f(uv2);
_vertex->add_data3f(v3); _vertex->add_data3f(v3);
_color->add_data4f(c3); _color->add_data4f(c3);
_uv->add_data2f(uv3); _uv->add_data2f(uv3);
_clear_index += 1; _clear_index += 1;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,145 +1,145 @@
// Filename: meshDrawer.h // Filename: meshDrawer.h
// Created by: treeform (19dec08) // Created by: treeform (19dec08)
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// //
// PANDA 3D SOFTWARE // PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved. // Copyright (c) Carnegie Mellon University. All rights reserved.
// //
// All use of this software is subject to the terms of the revised BSD // All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along // license. You should have received a copy of this license along
// with this source code in a file named "LICENSE." // with this source code in a file named "LICENSE."
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#ifndef MESHDRAWER_H #ifndef MESHDRAWER_H
#define MESHDRAWER_H #define MESHDRAWER_H
#include "pandabase.h" #include "pandabase.h"
#include "luse.h" #include "luse.h"
#include "pandaNode.h" #include "pandaNode.h"
#include "pointerTo.h" #include "pointerTo.h"
#include "lpoint2.h" #include "lpoint2.h"
#include "lvecBase2.h" #include "lvecBase2.h"
#include "pnmImage.h" #include "pnmImage.h"
#include "nodePath.h" #include "nodePath.h"
#include "texture.h" #include "texture.h"
#include "geomVertexFormat.h" #include "geomVertexFormat.h"
#include "geomVertexArrayFormat.h" #include "geomVertexArrayFormat.h"
#include "geomVertexData.h" #include "geomVertexData.h"
#include "geomVertexWriter.h" #include "geomVertexWriter.h"
#include "geomVertexRewriter.h" #include "geomVertexRewriter.h"
#include "boundingVolume.h" #include "boundingVolume.h"
#include "nodePathCollection.h" #include "nodePathCollection.h"
#include "geomTristrips.h" #include "geomTristrips.h"
#include "geomTriangles.h" #include "geomTriangles.h"
#include "geom.h" #include "geom.h"
#include "geomNode.h" #include "geomNode.h"
#include "nodePath.h" #include "nodePath.h"
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Class : MeshDrawer // Class : MeshDrawer
// Description : // Description :
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_GRUTIL MeshDrawer : public TypedObject { class EXPCL_PANDA_GRUTIL MeshDrawer : public TypedObject {
PUBLISHED: PUBLISHED:
INLINE MeshDrawer(); INLINE MeshDrawer();
INLINE ~MeshDrawer(); INLINE ~MeshDrawer();
INLINE void set_plate_size(int plate_size); INLINE void set_plate_size(int plate_size);
INLINE int get_plate_size(); INLINE int get_plate_size();
INLINE void set_budget(int budget); INLINE void set_budget(int budget);
INLINE int get_budget(); INLINE int get_budget();
INLINE NodePath get_root(); INLINE NodePath get_root();
void begin(NodePath camera, NodePath render); void begin(NodePath camera, NodePath render);
INLINE void tri(LVector3f v1, LVector4f c1, LVector2f uv1, INLINE void tri(LVector3f v1, LVector4f c1, LVector2f uv1,
LVector3f v2, LVector4f c2, LVector2f uv2, LVector3f v2, LVector4f c2, LVector2f uv2,
LVector3f v3, LVector4f c3, LVector2f uv3); LVector3f v3, LVector4f c3, LVector2f uv3);
void particle(LVector3f pos, int frame, float size, LVector4f color, float rotation); void particle(LVector3f pos, int frame, float size, LVector4f color, float rotation);
void billboard(LVector3f pos, int frame, float size, LVector4f color); void billboard(LVector3f pos, int frame, float size, LVector4f color);
void segment(LVector3f start, LVector3f stop, int frame, float thickness, LVector4f color); void segment(LVector3f start, LVector3f stop, int frame, float thickness, LVector4f color);
void uneven_segment(LVector3f start, LVector3f stop, void uneven_segment(LVector3f start, LVector3f stop,
int frame, int multi_frame, int frame, int multi_frame,
float thickness_start, LVector4f color_start, float thickness_start, LVector4f color_start,
float thickness_stop, LVector4f color_stop); float thickness_stop, LVector4f color_stop);
void link_segment(LVector3f pos, int frame, float thickness, LVector4f color); void link_segment(LVector3f pos, int frame, float thickness, LVector4f color);
void link_segment_end(LVector4f color, int frame); void link_segment_end(LVector4f color, int frame);
void explosion(LVector3f pos, int frame, float size, LVector4f color, void explosion(LVector3f pos, int frame, float size, LVector4f color,
int seed, int number, float distance); int seed, int number, float distance);
void stream(LVector3f start, LVector3f stop, int frame, float size, LVector4f color, void stream(LVector3f start, LVector3f stop, int frame, float size, LVector4f color,
int number, float offset); int number, float offset);
void geometry(NodePath node); void geometry(NodePath node);
void end(); void end();
private: private:
// use vars // use vars
NodePath _root; NodePath _root;
NodePath _camera, _render; NodePath _camera, _render;
int _plate_size; int _plate_size;
float _frame_size; float _frame_size;
int _budget; int _budget;
// store regeneration geoms & nodes // store regeneration geoms & nodes
PT(Geom) _geom; PT(Geom) _geom;
PT(GeomNode) _geomnode; PT(GeomNode) _geomnode;
PT(GeomVertexData) _vdata; PT(GeomVertexData) _vdata;
PT(GeomTriangles) _prim; PT(GeomTriangles) _prim;
CPT(GeomPrimitive) _dprim; CPT(GeomPrimitive) _dprim;
// writers // writers
GeomVertexRewriter *_vertex; GeomVertexRewriter *_vertex;
GeomVertexRewriter *_normal; GeomVertexRewriter *_normal;
GeomVertexRewriter *_uv; GeomVertexRewriter *_uv;
GeomVertexRewriter *_color; GeomVertexRewriter *_color;
// billboard vectors // billboard vectors
LVector4f _colorv; LVector4f _colorv;
LVector3f _normalv; LVector3f _normalv;
LVector3f _eyePos; LVector3f _eyePos;
LVector3f _b1, _b2, _b3, _b4; LVector3f _b1, _b2, _b3, _b4;
LVector3f _up, _right; LVector3f _up, _right;
// clear indexes // clear indexes
int _last_clear_index, _start_clear_index, _end_clear_index, _clear_index; int _last_clear_index, _start_clear_index, _end_clear_index, _clear_index;
// used for curves // used for curves
int _at_start; int _at_start;
LVector3f _last_v1,_last_v2,_last_v3,_last_v4,_last_pos; LVector3f _last_v1,_last_v2,_last_v3,_last_v4,_last_pos;
float _last_thickness; float _last_thickness;
LVector4f _last_color; LVector4f _last_color;
// bounding volume // bounding volume
PT(BoundingVolume) _bv; PT(BoundingVolume) _bv;
// private create all the needed geoms // private create all the needed geoms
void generator(int budget); void generator(int budget);
public: public:
static TypeHandle get_class_type() { static TypeHandle get_class_type() {
return _type_handle; return _type_handle;
} }
static void init_type() { static void init_type() {
TypedObject::init_type(); TypedObject::init_type();
register_type(_type_handle, "MeshDrawer", register_type(_type_handle, "MeshDrawer",
TypedObject::get_class_type()); TypedObject::get_class_type());
} }
virtual TypeHandle get_type() const { virtual TypeHandle get_type() const {
return get_class_type(); return get_class_type();
} }
virtual TypeHandle force_init_type() {init_type(); return get_class_type();} virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private: private:
static TypeHandle _type_handle; static TypeHandle _type_handle;
}; };
#include "meshDrawer.I" #include "meshDrawer.I"
#endif /*MESHDRAWER_H*/ #endif /*MESHDRAWER_H*/