added some more functions to the mesh drawer class.

This commit is contained in:
treeform 2008-12-21 23:14:28 +00:00
parent 3a14549dd7
commit bdfa9c64e3
3 changed files with 68 additions and 25 deletions

View File

@ -52,6 +52,14 @@ INLINE MeshDrawer::
// 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.
// Geom drawer expects a plate of square image for
// most of its billboard operatoins. If plate size is
// 3 the frame numbering would look like this:
// 0 1 2
// 3 4 5
// 6 7 8
// you can select any frame you like for many of the
// billboards and segments.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE void MeshDrawer:: INLINE void MeshDrawer::
set_plate_size(int one_side_size) { set_plate_size(int one_side_size) {
@ -84,7 +92,7 @@ get_root() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: MeshDrawer::set_budget // Function: MeshDrawer::set_budget
// Access: Published // Access: Published
// Description: Sets the total budget of particles. // Description: Sets the total triangle budget of the drawer.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE void MeshDrawer:: INLINE void MeshDrawer::
set_budget(int total_budget) { set_budget(int total_budget) {
@ -95,7 +103,7 @@ set_budget(int total_budget) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: MeshDrawer::get_budget() // Function: MeshDrawer::get_budget()
// Access: Published // Access: Published
// Description: Gets the total budget of particles. // Description: Gets the total triangle budget of the drawer
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE int MeshDrawer:: INLINE int MeshDrawer::
get_budget() { get_budget() {

View File

@ -152,7 +152,7 @@ void MeshDrawer::end() {
// Description: Draws a particle that is sort of like a bill board // Description: Draws a particle that is sort of like a bill board
// but has an extra rotation component. // but has an extra rotation component.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void MeshDrawer::particle(LVector3f pos, int frame, float size, LVector4f _color, float rotation) { void MeshDrawer::particle(LVector3f pos, int frame, float size, LVector4f color, float rotation) {
rotation = rotation / 57.29578; rotation = rotation / 57.29578;
@ -165,13 +165,30 @@ void MeshDrawer::particle(LVector3f pos, int frame, float size, LVector4f _color
float v = 1.0f-float(int(frame/_plate_size+1))*_frame_size; float v = 1.0f-float(int(frame/_plate_size+1))*_frame_size;
tri( tri(
v1, _color, LVector2f(u,v), v1, color, LVector2f(u,v),
v2, _color, LVector2f(u+_frame_size,v), v2, color, LVector2f(u+_frame_size,v),
v3, _color, LVector2f(u+_frame_size,v+_frame_size)); v3, color, LVector2f(u+_frame_size,v+_frame_size));
tri( tri(
v3, _color, LVector2f(u+_frame_size,v+_frame_size), v3, color, LVector2f(u+_frame_size,v+_frame_size),
v4, _color, LVector2f(u,v+_frame_size), v4, color, LVector2f(u,v+_frame_size),
v1, _color, LVector2f(u,v)); v1, color, LVector2f(u,v));
}
////////////////////////////////////////////////////////////////////
// Function: MeshDrawer::blended_particle
// Access: Published
// Description: Works just like particle but accepts 2 frames and
// a blend (from 0 to 1) component between them
////////////////////////////////////////////////////////////////////
void MeshDrawer::blended_particle(LVector3f pos, int frame1, int frame2,
float blend, float size, LVector4f color, float rotation) {
float original_w = color.get_w();
color.set_w((1.f-blend)*original_w);
particle(pos,frame1,size,color,rotation);
color.set_w(blend*original_w);
particle(pos,frame2,size,color,rotation);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -201,14 +218,27 @@ void MeshDrawer::billboard(LVector3f pos, int frame, float size, LVector4f _colo
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: MeshDrawer::segment // Function: MeshDrawer::segment
// Access: Published // Access: Published
// Description: Draws a segment a line with a thickness. // Description: Draws a segment a line with a thickness. That has
// billboarding effect.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void MeshDrawer::segment(LVector3f start, LVector3f stop, int frame, void MeshDrawer::segment(LVector3f start, LVector3f stop, int frame,
float thickness, LVector4f color) { float thickness, LVector4f color) {
link_segment(start, frame, thickness, color);
link_segment(stop, frame, thickness, color);
link_segment_end(frame, color);
}
////////////////////////////////////////////////////////////////////
// Function: MeshDrawer::cross_segment
// Access: Published
// Description: Draws a segment a line with a thickness. This
// segment does not use the bill boarding behavior
// and instead draws 2 planes in a cross.
////////////////////////////////////////////////////////////////////
void MeshDrawer::cross_segment(LVector3f start, LVector3f stop, int frame,
float thickness, LVector4f color) {
float u = float(int(frame%_plate_size))*_frame_size; float u = float(int(frame%_plate_size))*_frame_size;
float v = 1.0f-float(int(frame/_plate_size+1))*_frame_size; float v = 1.0f-float(int(frame/_plate_size+1))*_frame_size;
@ -240,6 +270,8 @@ void MeshDrawer::segment(LVector3f start, LVector3f stop, int frame,
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: MeshDrawer::uneven_segment // Function: MeshDrawer::uneven_segment
// Access: Published // Access: Published
@ -493,7 +525,7 @@ void MeshDrawer::link_segment(LVector3f pos, int frame,
// two calls to link_segment before it can end // two calls to link_segment before it can end
// the linked segment. // the linked segment.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void MeshDrawer::link_segment_end(LVector4f color, int frame) void MeshDrawer::link_segment_end(int frame, LVector4f color)
{ {
float u = float(int(frame%_plate_size))*_frame_size; float u = float(int(frame%_plate_size))*_frame_size;
float v = 1.0f-float(int(frame/_plate_size+1))*_frame_size; float v = 1.0f-float(int(frame/_plate_size+1))*_frame_size;

View File

@ -60,15 +60,18 @@ PUBLISHED:
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 blended_particle(LVector3f pos, int frame1, int frame2,
float blend, 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 cross_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(int frame, LVector4f color);
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);