LOD::set_stress_factor

This commit is contained in:
David Rose 2002-09-16 18:07:10 +00:00
parent b8ac8d8e21
commit c65538b0e1
3 changed files with 46 additions and 38 deletions

View File

@ -17,22 +17,19 @@
////////////////////////////////////////////////////////////////////
#include "LOD.h"
#include <datagram.h>
#include <datagramIterator.h>
#include <indent.h>
#include "datagram.h"
#include "datagramIterator.h"
#include "indent.h"
#include "config_gobj.h"
#define EXPCL EXPCL_PANDA
#define EXPTP EXPTP_PANDA
#define TYPE LODSwitch
#define NAME LODSwitchVector
#include <vector_src.cxx>
#include "config_gobj.h"
#include "vector_src.cxx"
////////////////////////////////////////////////////////////////////
// Static variables
////////////////////////////////////////////////////////////////////
TypeHandle LOD::_type_handle;
float LOD::_stress_factor = lod_stress_factor;
////////////////////////////////////////////////////////////////////
// Function: LOD::constructor
@ -97,7 +94,7 @@ int LOD::
compute_child(const LPoint3f &cam_pos, const LPoint3f &center) const {
LVector3f v = cam_pos - center;
float dist = dot(v, v);
float dist = dot(v, v) * _stress_factor;
LODSwitchVector::const_iterator i;
int child = 0;
for (i = _switch_vector.begin(), child = 0;
@ -206,3 +203,26 @@ write(ostream &out, int indent_level) const {
}
}
////////////////////////////////////////////////////////////////////
// Function: LOD::set_stress_factor
// Access: Published, Static
// Description: Sets the factor that globally scales all LOD's. This
// factor is applied to the square of the LOD distance,
// so the larger the number, the lower the detail that
// is presented. The normal value is 1.0.
////////////////////////////////////////////////////////////////////
void LOD::
set_stress_factor(float stress_factor) {
_stress_factor = stress_factor;
}
////////////////////////////////////////////////////////////////////
// Function: LOD::get_stress_factor
// Access: Published, Static
// Description: Returns the factor that globally scales all LOD's.
// See get_stress_factor().
////////////////////////////////////////////////////////////////////
float LOD::
get_stress_factor() {
return _stress_factor;
}

View File

@ -15,16 +15,14 @@
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#ifndef LOD_H
#define LOD_H
//
////////////////////////////////////////////////////////////////////
// Includes
////////////////////////////////////////////////////////////////////
#include <pandabase.h>
#include <luse.h>
#include <typedReferenceCount.h>
#include "pandabase.h"
#include "luse.h"
#include "typedReferenceCount.h"
class Datagram;
class DatagramIterator;
@ -82,11 +80,11 @@ protected:
// Description : Computes whether a level-of-detail should be rendered
// or not based on distance from the rendering camera.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA LOD : public TypedReferenceCount {
class EXPCL_PANDA LOD {
public:
LOD(void);
LOD();
LOD(const LOD &copy);
~LOD(void);
~LOD();
void xform(const LMatrix4f &mat);
@ -99,26 +97,16 @@ public:
void output(ostream &out) const;
void write(ostream &out, int indent_level = 0) const;
PUBLISHED:
static void set_stress_factor(float stress_factor);
static float get_stress_factor();
public:
LPoint3f _center;
LODSwitchVector _switch_vector;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
TypedReferenceCount::init_type();
register_type(_type_handle, "LOD",
TypedReferenceCount::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
static float _stress_factor;
};
INLINE ostream &operator << (ostream &out, const LOD &lod) {

View File

@ -17,7 +17,6 @@
////////////////////////////////////////////////////////////////////
#include <config_util.h>
#include "LOD.h"
#include "boundedObject.h"
#include "config_gobj.h"
#include "drawable.h"
@ -118,6 +117,8 @@ const int select_LOD_number = config_gobj.GetInt("select-LOD-number", -1);
// will screen out successively higher levels
const int minimum_LOD_number = config_gobj.GetInt("minimum-LOD-number", 0);
const float lod_stress_factor = config_gobj.GetFloat("lod-stress-factor", 1.0f);
// The default near and far plane distances.
const float default_near = config_gobj.GetFloat("default-near", 1.0f);
const float default_far = config_gobj.GetFloat("default-far", 1000.0f);
@ -181,7 +182,6 @@ ConfigureFn(config_gobj) {
GeomTrifan::init_type();
GeomTristrip::init_type();
ImageBuffer::init_type();
LOD::init_type();
Material::init_type();
OrthographicLens::init_type();
MatrixLens::init_type();