fix line_width and RenderModeAttrib
This commit is contained in:
parent
1f3ed386b4
commit
d9d30855d0
|
|
@ -196,12 +196,20 @@ setup_antialias_point() {
|
|||
INLINE void CLP(GraphicsStateGuardian)::
|
||||
setup_antialias_polygon() {
|
||||
if (_antialias_mode == (unsigned short)AntialiasAttrib::M_best) {
|
||||
if (_render_mode == RenderModeAttrib::M_wireframe) {
|
||||
switch (_render_mode) {
|
||||
case RenderModeAttrib::M_wireframe:
|
||||
// In wireframe mode, we're really drawing lines.
|
||||
enable_multisample(false);
|
||||
enable_line_smooth(true);
|
||||
break;
|
||||
|
||||
} else {
|
||||
case RenderModeAttrib::M_point:
|
||||
// In point mode, we're drawing points.
|
||||
enable_multisample(false);
|
||||
enable_point_smooth(true);
|
||||
break;
|
||||
|
||||
default:
|
||||
// For polygons, multisample is best if it's available, otherwise
|
||||
// polygon smoothing will do.
|
||||
enable_multisample(true);
|
||||
|
|
|
|||
|
|
@ -774,7 +774,6 @@ draw_point(GeomPoint *geom, GeomContext *gc) {
|
|||
_vertices_other_pcollector.add_level(geom->get_num_vertices());
|
||||
#endif
|
||||
|
||||
GLP(PointSize)(geom->get_size());
|
||||
issue_scene_graph_color();
|
||||
|
||||
int nprims = geom->get_num_prims();
|
||||
|
|
@ -845,7 +844,6 @@ draw_line(GeomLine *geom, GeomContext *gc) {
|
|||
_vertices_other_pcollector.add_level(geom->get_num_vertices());
|
||||
#endif
|
||||
|
||||
GLP(LineWidth)(geom->get_width());
|
||||
issue_scene_graph_color();
|
||||
|
||||
int nprims = geom->get_num_prims();
|
||||
|
|
@ -929,7 +927,6 @@ draw_linestrip(GeomLinestrip *geom, GeomContext *gc) {
|
|||
_vertices_other_pcollector.add_level(geom->get_num_vertices());
|
||||
#endif
|
||||
|
||||
GLP(LineWidth)(geom->get_width());
|
||||
issue_scene_graph_color();
|
||||
|
||||
int nprims = geom->get_num_prims();
|
||||
|
|
@ -2542,19 +2539,28 @@ issue_render_mode(const RenderModeAttrib *attrib) {
|
|||
_render_mode = attrib->get_mode();
|
||||
|
||||
switch (_render_mode) {
|
||||
case RenderModeAttrib::M_unchanged:
|
||||
case RenderModeAttrib::M_filled:
|
||||
GLP(PolygonMode)(GL_FRONT_AND_BACK, GL_FILL);
|
||||
break;
|
||||
|
||||
case RenderModeAttrib::M_wireframe:
|
||||
GLP(LineWidth)(attrib->get_line_width());
|
||||
GLP(PolygonMode)(GL_FRONT_AND_BACK, GL_LINE);
|
||||
break;
|
||||
|
||||
case RenderModeAttrib::M_point:
|
||||
GLP(PolygonMode)(GL_FRONT_AND_BACK, GL_POINT);
|
||||
break;
|
||||
|
||||
default:
|
||||
GLCAT.error()
|
||||
<< "Unknown render mode " << (int)_render_mode << endl;
|
||||
}
|
||||
|
||||
// The thickness affects both the line width and the point size.
|
||||
GLP(LineWidth)(attrib->get_thickness());
|
||||
GLP(PointSize)(attrib->get_thickness());
|
||||
|
||||
report_my_gl_errors();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,10 +62,6 @@ void GeomLine::
|
|||
write_datagram(BamWriter *manager, Datagram &me)
|
||||
{
|
||||
Geom::write_datagram(manager, me);
|
||||
// Changed from uint32 to float32 on 1/16/02; didn't bother to
|
||||
// update the bam version on the assumption that no actual bam files
|
||||
// contain GeomLine objects.
|
||||
me.add_float32(_width);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -95,9 +91,13 @@ make_GeomLine(const FactoryParams ¶ms) {
|
|||
// place
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GeomLine::
|
||||
fillin(DatagramIterator& scan, BamReader* manager) {
|
||||
fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
Geom::fillin(scan, manager);
|
||||
_width = scan.get_float32();
|
||||
|
||||
if (manager->get_file_minor_ver() < 15) {
|
||||
// Skip width parameter.
|
||||
scan.get_float32();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
class EXPCL_PANDA GeomLine : public Geom
|
||||
{
|
||||
public:
|
||||
GeomLine( void ) : Geom() { _width = 1.0f; }
|
||||
GeomLine( void ) : Geom() { }
|
||||
virtual Geom *make_copy() const;
|
||||
virtual void print_draw_immediate( void ) const { }
|
||||
virtual void draw_immediate(GraphicsStateGuardianBase *gsg, GeomContext *gc);
|
||||
|
|
@ -51,12 +51,6 @@ public:
|
|||
return new GeomLine(*this);
|
||||
}
|
||||
|
||||
INLINE void set_width(float width) { _width = width; }
|
||||
INLINE float get_width(void) const { return _width; }
|
||||
|
||||
protected:
|
||||
float _width;
|
||||
|
||||
public:
|
||||
static void register_with_read_factory(void);
|
||||
virtual void write_datagram(BamWriter* manager, Datagram &me);
|
||||
|
|
|
|||
|
|
@ -74,10 +74,6 @@ explode() const {
|
|||
void GeomLinestrip::
|
||||
write_datagram(BamWriter *manager, Datagram &me) {
|
||||
Geom::write_datagram(manager, me);
|
||||
// Changed from uint32 to float32 on 1/16/02; didn't bother to
|
||||
// update the bam version on the assumption that no actual bam files
|
||||
// contain GeomLinestrip objects.
|
||||
me.add_float32(_width);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -109,7 +105,11 @@ make_GeomLinestrip(const FactoryParams ¶ms) {
|
|||
void GeomLinestrip::
|
||||
fillin(DatagramIterator& scan, BamReader* manager) {
|
||||
Geom::fillin(scan, manager);
|
||||
_width = scan.get_float32();
|
||||
|
||||
if (manager->get_file_minor_ver() < 15) {
|
||||
// Skip width parameter.
|
||||
scan.get_float32();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
class EXPCL_PANDA GeomLinestrip : public Geom
|
||||
{
|
||||
public:
|
||||
GeomLinestrip(void) : Geom() { _width = 1.0f; }
|
||||
GeomLinestrip(void) : Geom() { }
|
||||
virtual Geom *make_copy() const;
|
||||
virtual void print_draw_immediate( void ) const { }
|
||||
virtual void draw_immediate(GraphicsStateGuardianBase *gsg, GeomContext *gc);
|
||||
|
|
@ -50,12 +50,6 @@ public:
|
|||
|
||||
virtual Geom *explode() const;
|
||||
|
||||
INLINE void set_width(float width) { _width = width; }
|
||||
INLINE float get_width(void) const { return _width; }
|
||||
|
||||
protected:
|
||||
float _width;
|
||||
|
||||
public:
|
||||
static void register_with_read_factory(void);
|
||||
virtual void write_datagram(BamWriter* manager, Datagram &me);
|
||||
|
|
|
|||
|
|
@ -70,10 +70,6 @@ draw_immediate(GraphicsStateGuardianBase *gsg, GeomContext *gc) {
|
|||
void GeomPoint::
|
||||
write_datagram(BamWriter *manager, Datagram &me) {
|
||||
Geom::write_datagram(manager, me);
|
||||
// Changed from uint32 to float32 on 1/16/02; didn't bother to
|
||||
// update the bam version on the assumption that no actual bam files
|
||||
// contain GeomPoint objects.
|
||||
me.add_float32(_size);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -105,7 +101,11 @@ make_GeomPoint(const FactoryParams ¶ms) {
|
|||
void GeomPoint::
|
||||
fillin(DatagramIterator& scan, BamReader* manager) {
|
||||
Geom::fillin(scan, manager);
|
||||
_size = scan.get_float32();
|
||||
|
||||
if (manager->get_file_minor_ver() < 15) {
|
||||
// Skip size parameter.
|
||||
scan.get_float32();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA GeomPoint : public Geom {
|
||||
public:
|
||||
GeomPoint() : Geom() { _size = 1.0f; }
|
||||
GeomPoint() : Geom() { }
|
||||
virtual Geom *make_copy() const;
|
||||
|
||||
virtual void print_draw_immediate() const;
|
||||
|
|
@ -51,12 +51,6 @@ public:
|
|||
return new GeomPoint(*this);
|
||||
}
|
||||
|
||||
INLINE void set_size(float size) { _size = size; }
|
||||
INLINE float get_size(void) const { return _size; }
|
||||
|
||||
protected:
|
||||
float _size;
|
||||
|
||||
public:
|
||||
static void register_with_read_factory(void);
|
||||
virtual void write_datagram(BamWriter* manager, Datagram &me);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "lineSegs.h"
|
||||
#include "renderState.h"
|
||||
#include "renderModeAttrib.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LineSegs::Constructor
|
||||
|
|
@ -180,6 +182,9 @@ create(GeomNode *previous, bool) {
|
|||
}
|
||||
}
|
||||
|
||||
CPT(RenderAttrib) thick = RenderModeAttrib::make(RenderModeAttrib::M_unchanged, _thick);
|
||||
CPT(RenderState) state = RenderState::make(thick);
|
||||
|
||||
// Now create the lines.
|
||||
if (line_index.size() > 0) {
|
||||
// Create a new Geom and add the line segments.
|
||||
|
|
@ -188,7 +193,6 @@ create(GeomNode *previous, bool) {
|
|||
// Here's a special case: just one line segment.
|
||||
GeomLine *geom_line = new GeomLine;
|
||||
geom_line->set_num_prims(1);
|
||||
geom_line->set_width(_thick);
|
||||
geom = geom_line;
|
||||
|
||||
} else {
|
||||
|
|
@ -197,14 +201,13 @@ create(GeomNode *previous, bool) {
|
|||
GeomLinestrip *geom_linestrip = new GeomLinestrip;
|
||||
geom_linestrip->set_num_prims(lengths.size());
|
||||
geom_linestrip->set_lengths(lengths);
|
||||
geom_linestrip->set_width(_thick);
|
||||
geom = geom_linestrip;
|
||||
}
|
||||
|
||||
geom->set_colors(_created_colors, G_PER_VERTEX, line_index);
|
||||
geom->set_coords(_created_verts, line_index);
|
||||
|
||||
previous->add_geom(geom);
|
||||
previous->add_geom(geom, state);
|
||||
}
|
||||
|
||||
// And now create the points.
|
||||
|
|
@ -213,11 +216,10 @@ create(GeomNode *previous, bool) {
|
|||
GeomPoint *geom = new GeomPoint;
|
||||
|
||||
geom->set_num_prims(point_index.size());
|
||||
geom->set_size(_thick);
|
||||
geom->set_colors(_created_colors, G_PER_VERTEX, point_index);
|
||||
geom->set_coords(_created_verts, point_index);
|
||||
|
||||
previous->add_geom(geom);
|
||||
previous->add_geom(geom, state);
|
||||
}
|
||||
|
||||
// And reset for next time.
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#include "cullHandler.h"
|
||||
#include "geomLinestrip.h"
|
||||
#include "geomTristrip.h"
|
||||
#include "renderState.h"
|
||||
#include "renderModeAttrib.h"
|
||||
#include "bamWriter.h"
|
||||
#include "bamReader.h"
|
||||
#include "datagram.h"
|
||||
|
|
@ -322,7 +324,6 @@ render_thread(CullTraverser *trav, CullTraverserData &data,
|
|||
}
|
||||
|
||||
PT(GeomLinestrip) geom = new GeomLinestrip;
|
||||
geom->set_width(get_thickness());
|
||||
geom->set_num_prims(num_prims);
|
||||
geom->set_coords(verts);
|
||||
if (get_uv_mode() != UV_none) {
|
||||
|
|
@ -335,8 +336,11 @@ render_thread(CullTraverser *trav, CullTraverserData &data,
|
|||
geom->set_colors(colors, G_OVERALL);
|
||||
}
|
||||
geom->set_lengths(lengths);
|
||||
|
||||
CPT(RenderAttrib) thick = RenderModeAttrib::make(RenderModeAttrib::M_unchanged, get_thickness());
|
||||
CPT(RenderState) state = data._state->add_attrib(thick);
|
||||
|
||||
CullableObject *object = new CullableObject(geom, data._state,
|
||||
CullableObject *object = new CullableObject(geom, state,
|
||||
data._render_transform);
|
||||
trav->get_cull_handler()->record_object(object);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void PointParticleRenderer::
|
||||
set_point_size(float point_size) {
|
||||
_point_primitive->set_size(point_size);
|
||||
_point_size = point_size;
|
||||
_thick = RenderModeAttrib::make(RenderModeAttrib::M_unchanged, _point_size);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ PointParticleRenderer(ParticleRendererAlphaMode am,
|
|||
const Colorf& sc, const Colorf& ec) :
|
||||
BaseParticleRenderer(am),
|
||||
_start_color(sc), _end_color(ec),
|
||||
_point_size(point_size),
|
||||
_blend_type(bt), _blend_method(bm)
|
||||
{
|
||||
_point_primitive = new GeomPoint;
|
||||
set_point_size(point_size);
|
||||
init_geoms();
|
||||
}
|
||||
|
||||
|
|
@ -56,6 +56,8 @@ PointParticleRenderer(const PointParticleRenderer& copy) :
|
|||
_blend_method = copy._blend_method;
|
||||
_start_color = copy._start_color;
|
||||
_end_color = copy._end_color;
|
||||
_point_size = copy._point_size;
|
||||
_thick = copy._thick;
|
||||
_point_primitive = new GeomPoint;
|
||||
init_geoms();
|
||||
}
|
||||
|
|
@ -114,11 +116,10 @@ void PointParticleRenderer::
|
|||
init_geoms(void) {
|
||||
|
||||
_point_primitive->set_num_prims(0);
|
||||
_point_primitive->set_size(_point_size);
|
||||
|
||||
GeomNode *render_node = get_render_node();
|
||||
render_node->remove_all_geoms();
|
||||
render_node->add_geom(_point_primitive, _render_state);
|
||||
render_node->add_geom(_point_primitive, _render_state->add_attrib(_thick));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "baseParticleRenderer.h"
|
||||
#include "baseParticle.h"
|
||||
|
||||
#include "renderModeAttrib.h"
|
||||
#include "pointerTo.h"
|
||||
#include "pointerToArray.h"
|
||||
#include "luse.h"
|
||||
|
|
@ -74,6 +74,7 @@ private:
|
|||
Colorf _start_color;
|
||||
Colorf _end_color;
|
||||
float _point_size;
|
||||
CPT(RenderAttrib) _thick;
|
||||
|
||||
PT(GeomPoint) _point_primitive;
|
||||
|
||||
|
|
|
|||
|
|
@ -3652,6 +3652,20 @@ set_render_mode_filled(int priority) {
|
|||
node()->set_attrib(RenderModeAttrib::make(RenderModeAttrib::M_filled), priority);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_render_mode
|
||||
// Access: Published
|
||||
// Description: Sets up the geometry at this level and below (unless
|
||||
// overridden) to render in the specified mode and with
|
||||
// the indicated line and/or point thickness.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_render_mode(RenderModeAttrib::Mode mode, float thickness, int priority) {
|
||||
nassertv_always(!is_empty());
|
||||
|
||||
node()->set_attrib(RenderModeAttrib::make(mode, thickness), priority);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::clear_render_mode
|
||||
// Access: Published
|
||||
|
|
@ -3670,9 +3684,9 @@ clear_render_mode() {
|
|||
// Function: NodePath::has_render_mode
|
||||
// Access: Published
|
||||
// Description: Returns true if a render mode has been explicitly set
|
||||
// on this particular node via
|
||||
// on this particular node via set_render_mode() (or
|
||||
// set_render_mode_wireframe() or
|
||||
// set_render_mode_filled(), false otherwise.
|
||||
// set_render_mode_filled()), false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool NodePath::
|
||||
has_render_mode() const {
|
||||
|
|
@ -3680,6 +3694,46 @@ has_render_mode() const {
|
|||
return node()->has_attrib(RenderModeAttrib::get_class_type());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::get_render_mode
|
||||
// Access: Published
|
||||
// Description: Returns the render mode that has been specifically
|
||||
// set on this node via set_render_mode(), or
|
||||
// M_unchanged if nothing has been set.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
RenderModeAttrib::Mode NodePath::
|
||||
get_render_mode() const {
|
||||
nassertr_always(!is_empty(), RenderModeAttrib::M_unchanged);
|
||||
const RenderAttrib *attrib =
|
||||
node()->get_attrib(RenderModeAttrib::get_class_type());
|
||||
if (attrib != (const RenderAttrib *)NULL) {
|
||||
const RenderModeAttrib *ta = DCAST(RenderModeAttrib, attrib);
|
||||
return ta->get_mode();
|
||||
}
|
||||
|
||||
return RenderModeAttrib::M_unchanged;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::get_render_mode_thickness
|
||||
// Access: Published
|
||||
// Description: Returns the render mode thickness that has been
|
||||
// specifically set on this node via set_render_mode(),
|
||||
// or 0.0 if nothing has been set.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float NodePath::
|
||||
get_render_mode_thickness() const {
|
||||
nassertr_always(!is_empty(), 0.0f);
|
||||
const RenderAttrib *attrib =
|
||||
node()->get_attrib(RenderModeAttrib::get_class_type());
|
||||
if (attrib != (const RenderAttrib *)NULL) {
|
||||
const RenderModeAttrib *ta = DCAST(RenderModeAttrib, attrib);
|
||||
return ta->get_thickness();
|
||||
}
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_two_sided
|
||||
// Access: Published
|
||||
|
|
@ -3757,72 +3811,6 @@ get_two_sided() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// programmers prolly wont need alpha-test control
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_alpha_test
|
||||
// Access: Published
|
||||
// Description: Specifically sets or disables the testing of the
|
||||
// alpha buffer on this particular node. This is
|
||||
// normally on in the 3-d scene graph and off in the 2-d
|
||||
// scene graph; it should be on for rendering most 3-d
|
||||
// objects properly.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_alpha_test(RenderAttrib::PandaCompareFunc alpha_test_mode,float reference_alpha, int priority) {
|
||||
nassertv_always(!is_empty());
|
||||
node()->set_attrib(AlphaTestAttrib::make(alpha_test_mode,reference_alpha), priority);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::clear_alpha_test
|
||||
// Access: Published
|
||||
// Description: Completely removes any alpha-test adjustment that
|
||||
// may have been set on this node via set_alpha_test().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
clear_alpha_test() {
|
||||
nassertv_always(!is_empty());
|
||||
node()->clear_attrib(AlphaTestAttrib::get_class_type());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::has_alpha_test
|
||||
// Access: Published
|
||||
// Description: Returns true if a alpha-test adjustment has been
|
||||
// explicitly set on this particular node via
|
||||
// set_alpha_test(). If this returns true, then
|
||||
// get_alpha_test() may be called to determine which has
|
||||
// been set.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool NodePath::
|
||||
has_alpha_test() const {
|
||||
nassertr_always(!is_empty(), false);
|
||||
return node()->has_attrib(AlphaTestAttrib::get_class_type());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::get_alpha_test
|
||||
// Access: Published
|
||||
// Description: Returns true if alpha-test rendering has been
|
||||
// specifically set on this node via set_alpha_test(), or
|
||||
// false if alpha-test rendering has been specifically
|
||||
// disabled, or if nothing has been specifically set. See
|
||||
// also has_alpha_test().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool NodePath::
|
||||
get_alpha_test() const {
|
||||
nassertr_always(!is_empty(), false);
|
||||
const RenderAttrib *attrib =
|
||||
node()->get_attrib(AlphaTestAttrib::get_class_type());
|
||||
if (attrib != (const RenderAttrib *)NULL) {
|
||||
const AlphaTestAttrib *dta = DCAST(AlphaTestAttrib, attrib);
|
||||
return (dta->get_mode() != AlphaTestAttrib::M_none);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_depth_test
|
||||
// Access: Published
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "renderState.h"
|
||||
#include "transformState.h"
|
||||
#include "texGenAttrib.h"
|
||||
#include "renderModeAttrib.h"
|
||||
#include "transparencyAttrib.h"
|
||||
#include "nodePathComponent.h"
|
||||
|
||||
|
|
@ -598,19 +599,17 @@ PUBLISHED:
|
|||
|
||||
void set_render_mode_wireframe(int priority = 0);
|
||||
void set_render_mode_filled(int priority = 0);
|
||||
void set_render_mode(RenderModeAttrib::Mode mode, float thickness, int priority = 0);
|
||||
void clear_render_mode();
|
||||
bool has_render_mode() const;
|
||||
RenderModeAttrib::Mode get_render_mode() const;
|
||||
float get_render_mode_thickness() const;
|
||||
|
||||
void set_two_sided(bool two_sided, int priority = 0);
|
||||
void clear_two_sided();
|
||||
bool has_two_sided() const;
|
||||
bool get_two_sided() const;
|
||||
#if 0
|
||||
void set_alpha_test(RenderAttrib::PandaCompareFunc alpha_test_mode,float reference_alpha,int priority = 0);
|
||||
void clear_alpha_test();
|
||||
bool has_alpha_test() const;
|
||||
bool get_alpha_test() const;
|
||||
#endif
|
||||
|
||||
void set_depth_test(bool depth_test, int priority = 0);
|
||||
void clear_depth_test();
|
||||
bool has_depth_test() const;
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@
|
|||
// RenderModeAttrib object.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE RenderModeAttrib::
|
||||
RenderModeAttrib(RenderModeAttrib::Mode mode, float line_width) :
|
||||
RenderModeAttrib(RenderModeAttrib::Mode mode, float thickness) :
|
||||
_mode(mode),
|
||||
_line_width(line_width)
|
||||
_thickness(thickness)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -41,12 +41,12 @@ get_mode() const {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderModeAttrib::get_line_width
|
||||
// Function: RenderModeAttrib::get_thickness
|
||||
// Access: Published
|
||||
// Description: Returns the line width. This is only relevant when
|
||||
// the mode is M_wireframe.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE float RenderModeAttrib::
|
||||
get_line_width() const {
|
||||
return _line_width;
|
||||
get_thickness() const {
|
||||
return _thickness;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,16 +34,15 @@ TypeHandle RenderModeAttrib::_type_handle;
|
|||
// or wireframe mode, or in some other yet-to-be-defined
|
||||
// mode.
|
||||
//
|
||||
// The line_width is relevant only if mode is
|
||||
// M_wireframe, and specifies the thickness of the
|
||||
// lines, in pixels, to use for wireframe.
|
||||
// The thickness parameter specifies the thickness to be
|
||||
// used for wireframe lines, as well as for ordinary
|
||||
// linestrip lines; it also specifies the diameter of
|
||||
// points. It is not supported in DirectX, which only
|
||||
// supports pixel-based lines and points.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) RenderModeAttrib::
|
||||
make(RenderModeAttrib::Mode mode, float line_width) {
|
||||
if (mode != M_wireframe) {
|
||||
line_width = 0.0f;
|
||||
}
|
||||
RenderModeAttrib *attrib = new RenderModeAttrib(mode, line_width);
|
||||
make(RenderModeAttrib::Mode mode, float thickness) {
|
||||
RenderModeAttrib *attrib = new RenderModeAttrib(mode, thickness);
|
||||
return return_new(attrib);
|
||||
}
|
||||
|
||||
|
|
@ -70,12 +69,20 @@ void RenderModeAttrib::
|
|||
output(ostream &out) const {
|
||||
out << get_type() << ":";
|
||||
switch (get_mode()) {
|
||||
case M_unchanged:
|
||||
out << "unchanged(" << get_thickness() << ")";
|
||||
break;
|
||||
|
||||
case M_filled:
|
||||
out << "filled";
|
||||
out << "filled(" << get_thickness() << ")";
|
||||
break;
|
||||
|
||||
case M_wireframe:
|
||||
out << "wireframe(" << get_line_width() << ")";
|
||||
out << "wireframe(" << get_thickness() << ")";
|
||||
break;
|
||||
|
||||
case M_point:
|
||||
out << "point(" << get_thickness() << ")";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -102,12 +109,43 @@ compare_to_impl(const RenderAttrib *other) const {
|
|||
if (_mode != ta->_mode) {
|
||||
return (int)_mode - (int)ta->_mode;
|
||||
}
|
||||
if (_line_width != ta->_line_width) {
|
||||
return _line_width < ta->_line_width ? -1 : 1;
|
||||
if (_thickness != ta->_thickness) {
|
||||
return _thickness < ta->_thickness ? -1 : 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderModeAttrib::compose_impl
|
||||
// Access: Protected, Virtual
|
||||
// Description: Intended to be overridden by derived RenderAttrib
|
||||
// types to specify how two consecutive RenderAttrib
|
||||
// objects of the same type interact.
|
||||
//
|
||||
// This should return the result of applying the other
|
||||
// RenderAttrib to a node in the scene graph below this
|
||||
// RenderAttrib, which was already applied. In most
|
||||
// cases, the result is the same as the other
|
||||
// RenderAttrib (that is, a subsequent RenderAttrib
|
||||
// completely replaces the preceding one). On the other
|
||||
// hand, some kinds of RenderAttrib (for instance,
|
||||
// ColorTransformAttrib) might combine in meaningful
|
||||
// ways.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) RenderModeAttrib::
|
||||
compose_impl(const RenderAttrib *other) const {
|
||||
const RenderModeAttrib *ta;
|
||||
DCAST_INTO_R(ta, other, 0);
|
||||
|
||||
// The special mode M_unchanged means to keep the current mode.
|
||||
Mode mode = ta->get_mode();
|
||||
if (mode == M_unchanged) {
|
||||
mode = get_mode();
|
||||
}
|
||||
|
||||
return make(mode, get_thickness());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderModeAttrib::make_default_impl
|
||||
// Access: Protected, Virtual
|
||||
|
|
@ -121,7 +159,7 @@ compare_to_impl(const RenderAttrib *other) const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
RenderAttrib *RenderModeAttrib::
|
||||
make_default_impl() const {
|
||||
return new RenderModeAttrib(M_filled, 0.0f);
|
||||
return new RenderModeAttrib(M_filled, 1.0f);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -146,7 +184,7 @@ write_datagram(BamWriter *manager, Datagram &dg) {
|
|||
RenderAttrib::write_datagram(manager, dg);
|
||||
|
||||
dg.add_int8(_mode);
|
||||
dg.add_float32(_line_width);
|
||||
dg.add_float32(_thickness);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -181,5 +219,5 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
|||
RenderAttrib::fillin(scan, manager);
|
||||
|
||||
_mode = (Mode)scan.get_int8();
|
||||
_line_width = scan.get_float32();
|
||||
_thickness = scan.get_float32();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,21 +32,20 @@ class FactoryParams;
|
|||
class EXPCL_PANDA RenderModeAttrib : public RenderAttrib {
|
||||
PUBLISHED:
|
||||
enum Mode {
|
||||
M_unchanged,
|
||||
M_filled,
|
||||
M_wireframe,
|
||||
// M_point
|
||||
|
||||
// Perhaps others to be added later.
|
||||
M_point
|
||||
};
|
||||
|
||||
private:
|
||||
INLINE RenderModeAttrib(Mode mode, float line_width);
|
||||
INLINE RenderModeAttrib(Mode mode, float thickness);
|
||||
|
||||
PUBLISHED:
|
||||
static CPT(RenderAttrib) make(Mode mode, float line_width = 1.0f);
|
||||
static CPT(RenderAttrib) make(Mode mode, float thickness = 1.0f);
|
||||
|
||||
INLINE Mode get_mode() const;
|
||||
INLINE float get_line_width() const;
|
||||
INLINE float get_thickness() const;
|
||||
|
||||
public:
|
||||
virtual void issue(GraphicsStateGuardianBase *gsg) const;
|
||||
|
|
@ -54,11 +53,12 @@ public:
|
|||
|
||||
protected:
|
||||
virtual int compare_to_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
|
||||
virtual RenderAttrib *make_default_impl() const;
|
||||
|
||||
private:
|
||||
Mode _mode;
|
||||
float _line_width;
|
||||
float _thickness;
|
||||
|
||||
public:
|
||||
static void register_with_read_factory();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ static const unsigned short _bam_major_ver = 4;
|
|||
// Bumped to major version 3 on 12/8/00 to change float64's to float32's.
|
||||
// Bumped to major version 4 on 4/10/02 to store new scene graph.
|
||||
|
||||
static const unsigned short _bam_minor_ver = 14;
|
||||
static const unsigned short _bam_minor_ver = 15;
|
||||
// Bumped to minor version 1 on 4/10/03 to add CullFaceAttrib::reverse.
|
||||
// Bumped to minor version 1 on 4/10/03 to add CullFaceAttrib::reverse.
|
||||
// Bumped to minor version 2 on 4/12/03 to add num_components to texture.
|
||||
|
|
@ -50,6 +50,7 @@ static const unsigned short _bam_minor_ver = 14;
|
|||
// Bumped to minor version 12 on 09/22/04 to add PandaNode::into_collide_mask.
|
||||
// Bumped to minor version 13 on 09/24/04 to store actual LODNode switch distances instead of squares.
|
||||
// Bumped to minor version 14 on 11/18/04 to differentiate old_hpr from new_hpr in compressed anim channels.
|
||||
// Bumped to minor version 15 on 1/16/05 to remove width from GeomLine, etc.
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
#include "geometricBoundingVolume.h"
|
||||
#include "accumulatedAttribs.h"
|
||||
#include "renderState.h"
|
||||
#include "renderModeAttrib.h"
|
||||
#include "dcast.h"
|
||||
#include "bamFile.h"
|
||||
#include "zStream.h"
|
||||
|
|
@ -606,20 +607,21 @@ make_frame() {
|
|||
verts.push_back(Vertexf(right, 0.0f, top));
|
||||
verts.push_back(Vertexf(left, 0.0f, top));
|
||||
|
||||
CPT(RenderAttrib) thick = RenderModeAttrib::make(RenderModeAttrib::M_unchanged, _frame_width);
|
||||
CPT(RenderState) state = RenderState::make(thick);
|
||||
|
||||
geoset->set_num_prims(1);
|
||||
geoset->set_lengths(lengths);
|
||||
|
||||
geoset->set_coords(verts);
|
||||
geoset->set_width(_frame_width);
|
||||
frame_geode->add_geom(geoset);
|
||||
frame_geode->add_geom(geoset, state);
|
||||
|
||||
if (get_frame_corners()) {
|
||||
GeomPoint *geoset = new GeomPoint;
|
||||
|
||||
geoset->set_num_prims(4);
|
||||
geoset->set_coords(verts);
|
||||
geoset->set_size(_frame_width);
|
||||
frame_geode->add_geom(geoset);
|
||||
frame_geode->add_geom(geoset, state);
|
||||
}
|
||||
|
||||
return frame_geode.p();
|
||||
|
|
|
|||
Loading…
Reference in New Issue