00001 // Filename: renderModeAttrib.I 00002 // Created by: drose (14Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: RenderModeAttrib::Constructor 00018 // Access: Private 00019 // Description: Use RenderModeAttrib::make() to construct a new 00020 // RenderModeAttrib object. 00021 //////////////////////////////////////////////////////////////////// 00022 INLINE RenderModeAttrib:: 00023 RenderModeAttrib(RenderModeAttrib::Mode mode, PN_stdfloat thickness, 00024 bool perspective) : 00025 _mode(mode), 00026 _thickness(thickness), 00027 _perspective(perspective) 00028 { 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: RenderModeAttrib::get_mode 00033 // Access: Published 00034 // Description: Returns the render mode. 00035 //////////////////////////////////////////////////////////////////// 00036 INLINE RenderModeAttrib::Mode RenderModeAttrib:: 00037 get_mode() const { 00038 return _mode; 00039 } 00040 00041 //////////////////////////////////////////////////////////////////// 00042 // Function: RenderModeAttrib::get_thickness 00043 // Access: Published 00044 // Description: Returns the line width or point thickness. This is 00045 // only relevant when rendering points or lines, such as 00046 // when the mode is M_wireframe or M_point (or when 00047 // rendering actual points or lines primitives in 00048 // M_polygon mode). 00049 //////////////////////////////////////////////////////////////////// 00050 INLINE PN_stdfloat RenderModeAttrib:: 00051 get_thickness() const { 00052 return _thickness; 00053 } 00054 00055 //////////////////////////////////////////////////////////////////// 00056 // Function: RenderModeAttrib::get_perspective 00057 // Access: Published 00058 // Description: Returns the perspective flag. When this is true, the 00059 // point thickness represented by get_thickness() is 00060 // actually a width in 3-d units, and the points should 00061 // scale according to perspective. When it is false, 00062 // the default, the point thickness is actually a width 00063 // in pixels, and points are a uniform size regardless 00064 // of distance from the camera. 00065 //////////////////////////////////////////////////////////////////// 00066 INLINE bool RenderModeAttrib:: 00067 get_perspective() const { 00068 return _perspective; 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: RenderModeAttrib::get_geom_rendering 00073 // Access: Published 00074 // Description: Returns the union of the Geom::GeomRendering bits 00075 // that will be required once this RenderModeAttrib is 00076 // applied to a geom which includes the indicated 00077 // geom_rendering bits. 00078 //////////////////////////////////////////////////////////////////// 00079 INLINE int RenderModeAttrib:: 00080 get_geom_rendering(int geom_rendering) const { 00081 if (_mode == M_point) { 00082 geom_rendering |= Geom::GR_point; 00083 } 00084 if ((geom_rendering & Geom::GR_point) != 0) { 00085 if (_perspective) { 00086 geom_rendering |= (Geom::GR_point_perspective | Geom::GR_point_uniform_size); 00087 } else if (_thickness != 1.0f) { 00088 geom_rendering |= Geom::GR_point_uniform_size; 00089 } 00090 } 00091 00092 return geom_rendering; 00093 }