mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
Remove old MLightVector TexGen mode and FFP-based normal mapping
This commit is contained in:
parent
3423a09f4f
commit
142bd6a021
@ -3751,7 +3751,7 @@ update_standard_texture_bindings() {
|
||||
|
||||
switch (mode) {
|
||||
case TexGenAttrib::M_off:
|
||||
case TexGenAttrib::M_light_vector:
|
||||
case TexGenAttrib::M_unused2:
|
||||
set_texture_stage_state(si, D3DTSS_TEXCOORDINDEX, texcoord_index);
|
||||
break;
|
||||
|
||||
|
@ -9645,7 +9645,7 @@ do_issue_tex_gen() {
|
||||
TexGenAttrib::Mode mode = _target_tex_gen->get_mode(stage);
|
||||
switch (mode) {
|
||||
case TexGenAttrib::M_off:
|
||||
case TexGenAttrib::M_light_vector:
|
||||
case TexGenAttrib::M_unused2:
|
||||
break;
|
||||
|
||||
case TexGenAttrib::M_eye_sphere_map:
|
||||
|
@ -134,11 +134,6 @@ PUBLISHED:
|
||||
|
||||
// The union of the above shade model types.
|
||||
GR_shade_model_bits = 0x06000,
|
||||
|
||||
// If there is a TexGenAttrib in effect with M_light_vector
|
||||
// enabled, meaning we need to generate the tangent space light
|
||||
// vector as the texture coordinates.
|
||||
GR_texcoord_light_vector = 0x08000,
|
||||
};
|
||||
|
||||
// The shade model specifies whether the per-vertex colors and
|
||||
|
@ -38,7 +38,6 @@ PStatCollector CullableObject::_munge_geom_pcollector("*:Munge:Geom");
|
||||
PStatCollector CullableObject::_munge_sprites_pcollector("*:Munge:Sprites");
|
||||
PStatCollector CullableObject::_munge_sprites_verts_pcollector("*:Munge:Sprites:Verts");
|
||||
PStatCollector CullableObject::_munge_sprites_prims_pcollector("*:Munge:Sprites:Prims");
|
||||
PStatCollector CullableObject::_munge_light_vector_pcollector("*:Munge:Light Vector");
|
||||
PStatCollector CullableObject::_sw_sprites_pcollector("SW Sprites");
|
||||
|
||||
TypeHandle CullableObject::_type_handle;
|
||||
@ -123,23 +122,6 @@ munge_geom(GraphicsStateGuardianBase *gsg,
|
||||
}
|
||||
}
|
||||
|
||||
bool cpu_animated = false;
|
||||
|
||||
if (unsupported_bits & Geom::GR_texcoord_light_vector) {
|
||||
// If we have to compute the light vector, we have to animate
|
||||
// the vertices in the CPU--and we have to do it before we call
|
||||
// munge_geom(), which might lose the tangent and binormal.
|
||||
CPT(GeomVertexData) animated_vertices =
|
||||
_munged_data->animate_vertices(force, current_thread);
|
||||
if (animated_vertices != _munged_data) {
|
||||
cpu_animated = true;
|
||||
swap(_munged_data, animated_vertices);
|
||||
}
|
||||
if (!munge_texcoord_light_vector(traverser, force)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Now invoke the munger to ensure the resulting geometry is in
|
||||
// a GSG-friendly form.
|
||||
if (!munger->munge_geom(_geom, _munged_data, force, current_thread)) {
|
||||
@ -150,17 +132,17 @@ munge_geom(GraphicsStateGuardianBase *gsg,
|
||||
DCAST_INTO_R(state_munger, munger, false);
|
||||
_state = state_munger->munge_state(_state);
|
||||
|
||||
if (!cpu_animated) {
|
||||
// If there is any animation left in the vertex data after it
|
||||
// has been munged--that is, we couldn't arrange to handle the
|
||||
// animation in hardware--then we have to calculate that
|
||||
// animation now.
|
||||
CPT(GeomVertexData) animated_vertices =
|
||||
_munged_data->animate_vertices(force, current_thread);
|
||||
if (animated_vertices != _munged_data) {
|
||||
cpu_animated = true;
|
||||
swap(_munged_data, animated_vertices);
|
||||
}
|
||||
// If there is any animation left in the vertex data after it
|
||||
// has been munged--that is, we couldn't arrange to handle the
|
||||
// animation in hardware--then we have to calculate that
|
||||
// animation now.
|
||||
bool cpu_animated = false;
|
||||
|
||||
CPT(GeomVertexData) animated_vertices =
|
||||
_munged_data->animate_vertices(force, current_thread);
|
||||
if (animated_vertices != _munged_data) {
|
||||
cpu_animated = true;
|
||||
swap(_munged_data, animated_vertices);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
@ -599,109 +581,6 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CullableObject::munge_texcoord_light_vector
|
||||
// Access: Private
|
||||
// Description: Generates the vector from each vertex to the
|
||||
// indicated light as a 3-d texture coordinate.
|
||||
//
|
||||
// This may replace _geom, _munged_data, and _state.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool CullableObject::
|
||||
munge_texcoord_light_vector(const CullTraverser *traverser, bool force) {
|
||||
Thread *current_thread = traverser->get_current_thread();
|
||||
PStatTimer timer(_munge_light_vector_pcollector, current_thread);
|
||||
|
||||
if (_net_transform->is_singular()) {
|
||||
// If we're under a singular transform, never mind.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!_munged_data->has_column(InternalName::get_vertex()) ||
|
||||
!_munged_data->has_column(InternalName::get_normal())) {
|
||||
// No vertex or normal; can't compute light vector.
|
||||
return true;
|
||||
}
|
||||
|
||||
CPT(TexGenAttrib) tex_gen = DCAST(TexGenAttrib, _state->get_attrib(TexGenAttrib::get_class_slot()));
|
||||
nassertr(tex_gen != (TexGenAttrib *)NULL, false);
|
||||
|
||||
const TexGenAttrib::LightVectors &light_vectors = tex_gen->get_light_vectors();
|
||||
TexGenAttrib::LightVectors::const_iterator lvi;
|
||||
for (lvi = light_vectors.begin();
|
||||
lvi != light_vectors.end();
|
||||
++lvi) {
|
||||
TextureStage *stage = (*lvi);
|
||||
NodePath light = tex_gen->get_light(stage);
|
||||
if (light.is_empty()) {
|
||||
// If a particular light isn't specified in the TexGenAttrib,
|
||||
// use the most important light in the current state.
|
||||
CPT(RenderAttrib) attrib = _state->get_attrib(LightAttrib::get_class_slot());
|
||||
if (attrib != (RenderAttrib *)NULL) {
|
||||
CPT(LightAttrib) la = DCAST(LightAttrib, attrib);
|
||||
light = la->get_most_important_light();
|
||||
}
|
||||
}
|
||||
if (!light.is_empty()) {
|
||||
string source_name = tex_gen->get_source_name(stage);
|
||||
Light *light_obj = light.node()->as_light();
|
||||
nassertr(light_obj != (Light *)NULL, false);
|
||||
|
||||
// Determine the names of the tangent and binormal columns
|
||||
// associated with the stage's texcoord name.
|
||||
PT(InternalName) tangent_name = InternalName::get_tangent_name(source_name);
|
||||
PT(InternalName) binormal_name = InternalName::get_binormal_name(source_name);
|
||||
|
||||
PT(InternalName) texcoord_name = stage->get_texcoord_name();
|
||||
|
||||
if (_munged_data->has_column(tangent_name) &&
|
||||
_munged_data->has_column(binormal_name)) {
|
||||
|
||||
if (!force && !_munged_data->request_resident()) {
|
||||
// The data isn't resident; give up.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create a new column for the new texcoords.
|
||||
PT(GeomVertexData) new_data = _munged_data->replace_column
|
||||
(texcoord_name, 3, Geom::NT_stdfloat, Geom::C_texcoord);
|
||||
_munged_data = new_data;
|
||||
|
||||
// Remove this TexGen stage from the state, since we're handling
|
||||
// it now.
|
||||
_state = _state->add_attrib(tex_gen->remove_stage(stage));
|
||||
|
||||
// Get the transform from the light to the object.
|
||||
CPT(TransformState) light_transform =
|
||||
_net_transform->invert_compose(light.get_net_transform());
|
||||
const LMatrix4 &light_mat = light_transform->get_mat();
|
||||
|
||||
GeomVertexWriter texcoord(new_data, texcoord_name, current_thread);
|
||||
GeomVertexReader vertex(new_data, InternalName::get_vertex(),
|
||||
current_thread);
|
||||
GeomVertexReader tangent(new_data, tangent_name, current_thread);
|
||||
GeomVertexReader binormal(new_data, binormal_name, current_thread);
|
||||
GeomVertexReader normal(new_data, InternalName::get_normal(),
|
||||
current_thread);
|
||||
|
||||
while (!vertex.is_at_end()) {
|
||||
LPoint3 p = vertex.get_data3();
|
||||
LVector3 t = tangent.get_data3();
|
||||
LVector3 b = binormal.get_data3();
|
||||
LVector3 n = normal.get_data3();
|
||||
|
||||
LVector3 lv;
|
||||
if (light_obj->get_vector_to_light(lv, p, light_mat)) {
|
||||
texcoord.add_data3(lv.dot(t), lv.dot(b), lv.dot(n));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CullableObject::get_flash_cpu_state
|
||||
// Access: Private, Static
|
||||
|
@ -89,7 +89,6 @@ public:
|
||||
|
||||
private:
|
||||
bool munge_points_to_quads(const CullTraverser *traverser, bool force);
|
||||
bool munge_texcoord_light_vector(const CullTraverser *traverser, bool force);
|
||||
|
||||
static CPT(RenderState) get_flash_cpu_state();
|
||||
static CPT(RenderState) get_flash_hardware_state();
|
||||
@ -130,7 +129,6 @@ private:
|
||||
static PStatCollector _munge_sprites_pcollector;
|
||||
static PStatCollector _munge_sprites_verts_pcollector;
|
||||
static PStatCollector _munge_sprites_prims_pcollector;
|
||||
static PStatCollector _munge_light_vector_pcollector;
|
||||
static PStatCollector _sw_sprites_pcollector;
|
||||
|
||||
public:
|
||||
|
@ -4359,38 +4359,6 @@ set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode, int priority) {
|
||||
node()->set_attrib(tga->add_stage(stage, mode), priority);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_tex_gen
|
||||
// Access: Published
|
||||
// Description: Enables automatic texture coordinate generation for
|
||||
// the indicated texture stage. This version of this
|
||||
// method is useful when setting M_light_vector, which
|
||||
// requires the name of the texture coordinate set that
|
||||
// supplies the tangent and binormal, as well as the
|
||||
// specific light to generate coordinates for.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode,
|
||||
const string &source_name, const NodePath &light, int priority) {
|
||||
nassertv_always(!is_empty());
|
||||
|
||||
const RenderAttrib *attrib =
|
||||
node()->get_attrib(TexGenAttrib::get_class_slot());
|
||||
|
||||
CPT(TexGenAttrib) tga;
|
||||
|
||||
if (attrib != (const RenderAttrib *)NULL) {
|
||||
priority = max(priority,
|
||||
node()->get_state()->get_override(TextureAttrib::get_class_slot()));
|
||||
tga = DCAST(TexGenAttrib, attrib);
|
||||
|
||||
} else {
|
||||
tga = DCAST(TexGenAttrib, TexGenAttrib::make());
|
||||
}
|
||||
|
||||
node()->set_attrib(tga->add_stage(stage, mode, source_name, light), priority);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_tex_gen
|
||||
// Access: Published
|
||||
@ -4500,28 +4468,6 @@ get_tex_gen(TextureStage *stage) const {
|
||||
return TexGenAttrib::M_off;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::get_tex_gen_light
|
||||
// Access: Published
|
||||
// Description: Returns the particular Light set for the indicated
|
||||
// texgen mode's texture stage, or empty NodePath if no
|
||||
// light is set. This is only meaningful if the texgen
|
||||
// mode (returned by get_tex_gen()) is M_light_vector.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
NodePath NodePath::
|
||||
get_tex_gen_light(TextureStage *stage) const {
|
||||
nassertr_always(!is_empty(), NodePath::fail());
|
||||
|
||||
const RenderAttrib *attrib =
|
||||
node()->get_attrib(TexGenAttrib::get_class_slot());
|
||||
if (attrib != (const RenderAttrib *)NULL) {
|
||||
const TexGenAttrib *tga = DCAST(TexGenAttrib, attrib);
|
||||
return tga->get_light(stage);
|
||||
}
|
||||
|
||||
return NodePath();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_tex_projector
|
||||
// Access: Published
|
||||
@ -4676,99 +4622,6 @@ project_texture(TextureStage *stage, Texture *tex, const NodePath &projector) {
|
||||
set_tex_projector(stage, NodePath(), projector);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_normal_map
|
||||
// Access: Published
|
||||
// Description: A convenience function to set up a normal map on this
|
||||
// geometry. This uses the single highest-priority
|
||||
// light on the object only. It also requires
|
||||
// multitexture, and consumes at least two texture
|
||||
// stages, in addition to what may already be in use.
|
||||
//
|
||||
// The normal_map parameter is the texture that contains
|
||||
// the normal map information (with a 3-d delta vector
|
||||
// encoded into the r,g,b of each texel). texcoord_name is
|
||||
// the name of the texture coordinate set that contains
|
||||
// the tangent and binormal we wish to use. If
|
||||
// preserve_color is true, then one additional texture
|
||||
// stage is consumed to blend in the geometry's original
|
||||
// vertex color.
|
||||
//
|
||||
// Only one normal map may be in effect through this
|
||||
// interface at any given time.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_normal_map(Texture *normal_map, const string &texcoord_name,
|
||||
bool preserve_color) {
|
||||
clear_normal_map();
|
||||
|
||||
// First, we apply the normal map itself, to the bottom layer.
|
||||
PT(TextureStage) normal_map_ts = new TextureStage("__normal_map");
|
||||
normal_map_ts->set_texcoord_name(texcoord_name);
|
||||
normal_map_ts->set_sort(-20);
|
||||
normal_map_ts->set_mode(TextureStage::M_replace);
|
||||
set_texture(normal_map_ts, normal_map);
|
||||
|
||||
// Then, we apply a normalization map, to normalize, per-pixel, the
|
||||
// vector to the light.
|
||||
PT(Texture) normalization_map = TexturePool::get_normalization_cube_map(32);
|
||||
PT(TextureStage) normalization_map_ts = new TextureStage("__normalization_map");
|
||||
normalization_map_ts->set_combine_rgb
|
||||
(TextureStage::CM_dot3_rgb,
|
||||
TextureStage::CS_texture, TextureStage::CO_src_color,
|
||||
TextureStage::CS_previous, TextureStage::CO_src_color);
|
||||
normalization_map_ts->set_texcoord_name("light_vector");
|
||||
normalization_map_ts->set_sort(-15);
|
||||
set_texture(normalization_map_ts, normalization_map);
|
||||
|
||||
// Finally, we enable M_light_vector texture coordinate generation.
|
||||
set_tex_gen(normalization_map_ts, TexGenAttrib::M_light_vector,
|
||||
texcoord_name, NodePath());
|
||||
|
||||
if (preserve_color) {
|
||||
// One more stage to get back the original color.
|
||||
PT(TextureStage) orig_color_ts = new TextureStage("__orig_color");
|
||||
orig_color_ts->set_combine_rgb
|
||||
(TextureStage::CM_modulate,
|
||||
TextureStage::CS_primary_color, TextureStage::CO_src_color,
|
||||
TextureStage::CS_previous, TextureStage::CO_src_color);
|
||||
set_texture(orig_color_ts, normal_map);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::clear_normal_map
|
||||
// Access: Published
|
||||
// Description: Undoes the effect of a previous call to
|
||||
// set_normal_map().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
clear_normal_map() {
|
||||
// Scan through the TextureStages, and if we find any whose name
|
||||
// matches one of the stages that would have been left by
|
||||
// set_normal_map(), remove it from the state.
|
||||
|
||||
CPT(RenderAttrib) attrib =
|
||||
get_state()->get_attrib(TextureAttrib::get_class_slot());
|
||||
if (attrib != (const RenderAttrib *)NULL) {
|
||||
const TextureAttrib *ta = DCAST(TextureAttrib, attrib);
|
||||
for (int i = 0; i < ta->get_num_on_stages(); i++) {
|
||||
TextureStage *stage = ta->get_on_stage(i);
|
||||
if (stage->get_name() == "__normal_map") {
|
||||
clear_texture(stage);
|
||||
|
||||
} else if (stage->get_name() == "__normalization_map") {
|
||||
clear_texture(stage);
|
||||
clear_tex_gen(stage);
|
||||
|
||||
} else if (stage->get_name() == "__orig_color") {
|
||||
clear_texture(stage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::has_vertex_column
|
||||
// Access: Published
|
||||
|
@ -704,9 +704,6 @@ PUBLISHED:
|
||||
INLINE LVecBase3 get_tex_scale_3d(const NodePath &other, TextureStage *stage) const;
|
||||
|
||||
void set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode, int priority = 0);
|
||||
void set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode,
|
||||
const string &source_name, const NodePath &light,
|
||||
int priority = 0);
|
||||
void set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode,
|
||||
const LTexCoord3 &constant_value,
|
||||
int priority = 0);
|
||||
@ -714,7 +711,6 @@ PUBLISHED:
|
||||
void clear_tex_gen(TextureStage *stage);
|
||||
bool has_tex_gen(TextureStage *stage) const;
|
||||
RenderAttrib::TexGenMode get_tex_gen(TextureStage *stage) const;
|
||||
NodePath get_tex_gen_light(TextureStage *stage) const;
|
||||
|
||||
void set_tex_projector(TextureStage *stage, const NodePath &from, const NodePath &to,
|
||||
int lens_index = 0);
|
||||
@ -727,10 +723,6 @@ PUBLISHED:
|
||||
void project_texture(TextureStage *stage, Texture *tex, const NodePath &projector);
|
||||
INLINE void clear_project_texture(TextureStage *stage);
|
||||
|
||||
void set_normal_map(Texture *normal_map, const string &texcoord_name = string(),
|
||||
bool preserve_color = false);
|
||||
void clear_normal_map();
|
||||
|
||||
INLINE bool has_texcoord(const string &texcoord_name) const;
|
||||
bool has_vertex_column(const InternalName *name) const;
|
||||
InternalNameCollection find_all_vertex_columns() const;
|
||||
|
@ -131,7 +131,7 @@ PUBLISHED:
|
||||
// Typically, a statically-generated cube map will be in eye
|
||||
// space, while a dynamically-generated map will be in world
|
||||
// space.
|
||||
|
||||
//
|
||||
// Cube mapping is not supported on all hardware.
|
||||
M_world_cube_map,
|
||||
M_eye_cube_map,
|
||||
@ -153,7 +153,7 @@ PUBLISHED:
|
||||
// lower-right across the point's face. Without this, each point
|
||||
// will have just a single uniform texture coordinate value across
|
||||
// its face.
|
||||
|
||||
//
|
||||
// Unfortunately, the generated texture coordinates are inverted
|
||||
// (upside-down) from Panda's usual convention, but this is what
|
||||
// the graphics card manufacturers decided to use. You could use
|
||||
@ -163,16 +163,12 @@ PUBLISHED:
|
||||
// hardware sprites.
|
||||
M_point_sprite,
|
||||
|
||||
// M_light_vector generates special 3-d texture coordinates that
|
||||
// represent the vector to a particular Light in the scene graph,
|
||||
// expressed in each vertex's tangent space. This is used to
|
||||
// implement bumpmapping. It is always computed on the CPU.
|
||||
|
||||
// This requires a Light to be specified to the TexGenAttrib. It
|
||||
// also requires each vertex to define a normal, as well as a
|
||||
// tangent and binormal for the particular named texture
|
||||
// coordinate set.
|
||||
M_light_vector,
|
||||
// M_light_vector generated special 3-d texture coordinates that
|
||||
// represented the vector to a particular Light in the scene graph,
|
||||
// expressed in each vertex's tangent space. This has now been
|
||||
// removed. We need to reserve the slot in the enum, though, to
|
||||
// make sure the following enum value still has the same value.
|
||||
M_unused2,
|
||||
|
||||
// M_constant generates the same fixed texture coordinates at each
|
||||
// vertex. Not terribly useful, of course, except for certain
|
||||
|
@ -22,7 +22,6 @@
|
||||
INLINE TexGenAttrib::
|
||||
TexGenAttrib() :
|
||||
_num_point_sprites(0),
|
||||
_num_light_vectors(0),
|
||||
_point_geom_rendering(0),
|
||||
_geom_rendering(0)
|
||||
{
|
||||
@ -39,7 +38,6 @@ TexGenAttrib(const TexGenAttrib ©) :
|
||||
_stages(copy._stages),
|
||||
_no_texcoords(copy._no_texcoords),
|
||||
_num_point_sprites(copy._num_point_sprites),
|
||||
_num_light_vectors(copy._num_light_vectors),
|
||||
_point_geom_rendering(copy._point_geom_rendering),
|
||||
_geom_rendering(copy._geom_rendering)
|
||||
{
|
||||
@ -62,22 +60,10 @@ get_geom_rendering(int geom_rendering) const {
|
||||
return geom_rendering | _geom_rendering;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexGenAttrib::get_light_vectors
|
||||
// Access: Public
|
||||
// Description: Returns the set of TextureStages that have
|
||||
// M_light_vector in effect, as well as the associated
|
||||
// Lights.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const TexGenAttrib::LightVectors &TexGenAttrib::
|
||||
get_light_vectors() const {
|
||||
return _light_vectors;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexGenAttrib::ModeDef::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE TexGenAttrib::ModeDef::
|
||||
ModeDef() :
|
||||
@ -88,7 +74,7 @@ ModeDef() :
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexGenAttrib::ModeDef::compare_to
|
||||
// Access: Public
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int TexGenAttrib::ModeDef::
|
||||
compare_to(const TexGenAttrib::ModeDef &other) const {
|
||||
|
@ -28,7 +28,7 @@ int TexGenAttrib::_attrib_slot;
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexGenAttrib::Destructor
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
TexGenAttrib::
|
||||
~TexGenAttrib() {
|
||||
@ -84,7 +84,7 @@ make_default() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) TexGenAttrib::
|
||||
add_stage(TextureStage *stage, TexGenAttrib::Mode mode) const {
|
||||
nassertr(mode != M_light_vector && mode != M_constant, this);
|
||||
nassertr(mode != M_constant, this);
|
||||
|
||||
CPT(RenderAttrib) removed = remove_stage(stage);
|
||||
TexGenAttrib *attrib = new TexGenAttrib(*DCAST(TexGenAttrib, removed));
|
||||
@ -96,34 +96,6 @@ add_stage(TextureStage *stage, TexGenAttrib::Mode mode) const {
|
||||
return return_new(attrib);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexGenAttrib::add_stage
|
||||
// Access: Published, Static
|
||||
// Description: Returns a new TexGenAttrib just like this one,
|
||||
// with the indicated generation mode for the given
|
||||
// stage. If this stage already exists, its mode is
|
||||
// replaced.
|
||||
//
|
||||
// This variant also accepts source_name and light,
|
||||
// which are only meaningful if mode is M_light_vector.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) TexGenAttrib::
|
||||
add_stage(TextureStage *stage, TexGenAttrib::Mode mode,
|
||||
const string &source_name, const NodePath &light) const {
|
||||
nassertr(mode == M_light_vector, this);
|
||||
|
||||
CPT(RenderAttrib) removed = remove_stage(stage);
|
||||
TexGenAttrib *attrib = new TexGenAttrib(*DCAST(TexGenAttrib, removed));
|
||||
|
||||
ModeDef &mode_def = attrib->_stages[stage];
|
||||
mode_def._mode = mode;
|
||||
mode_def._source_name = source_name;
|
||||
mode_def._light = light;
|
||||
attrib->record_stage(stage, mode_def);
|
||||
|
||||
return return_new(attrib);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexGenAttrib::add_stage
|
||||
// Access: Published, Static
|
||||
@ -136,7 +108,7 @@ add_stage(TextureStage *stage, TexGenAttrib::Mode mode,
|
||||
// only meaningful if mode is M_constant.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) TexGenAttrib::
|
||||
add_stage(TextureStage *stage, TexGenAttrib::Mode mode,
|
||||
add_stage(TextureStage *stage, TexGenAttrib::Mode mode,
|
||||
const LTexCoord3 &constant_value) const {
|
||||
nassertr(mode == M_constant, this);
|
||||
|
||||
@ -174,12 +146,6 @@ remove_stage(TextureStage *stage) const {
|
||||
if (attrib->_num_point_sprites == 0) {
|
||||
attrib->_point_geom_rendering &= ~Geom::GR_point_sprite;
|
||||
}
|
||||
} else if (mode == M_light_vector) {
|
||||
attrib->_light_vectors.erase(stage);
|
||||
attrib->_num_light_vectors--;
|
||||
if (attrib->_num_light_vectors == 0) {
|
||||
attrib->_geom_rendering &= ~Geom::GR_texcoord_light_vector;
|
||||
}
|
||||
}
|
||||
return return_new(attrib);
|
||||
}
|
||||
@ -238,43 +204,6 @@ has_gen_texcoord_stage(TextureStage *stage) const {
|
||||
return (mi != _no_texcoords.end());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexGenAttrib::get_source_name
|
||||
// Access: Published
|
||||
// Description: Returns the source name associated with the named
|
||||
// texture stage, or the empty string if no name is
|
||||
// associated with the indicated stage. This is only
|
||||
// meaningful if the mode is M_light_vector, in which
|
||||
// case it indicates the name of the source texture
|
||||
// coordinate set from which the tangent and binormal
|
||||
// are derived.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string TexGenAttrib::
|
||||
get_source_name(TextureStage *stage) const {
|
||||
Stages::const_iterator mi = _stages.find(stage);
|
||||
if (mi != _stages.end()) {
|
||||
return (*mi).second._source_name;
|
||||
}
|
||||
return string();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexGenAttrib::get_light
|
||||
// Access: Published
|
||||
// Description: Returns the Light associated with the named texture
|
||||
// stage, or the empty NodePath if no light is
|
||||
// associated with the indicated stage. This is only
|
||||
// meaningful if the mode is M_light_vector.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
NodePath TexGenAttrib::
|
||||
get_light(TextureStage *stage) const {
|
||||
Stages::const_iterator mi = _stages.find(stage);
|
||||
if (mi != _stages.end()) {
|
||||
return (*mi).second._light;
|
||||
}
|
||||
return NodePath();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexGenAttrib::get_constant_value
|
||||
// Access: Published
|
||||
@ -294,7 +223,7 @@ get_constant_value(TextureStage *stage) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexGenAttrib::output
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void TexGenAttrib::
|
||||
output(ostream &out) const {
|
||||
@ -339,16 +268,12 @@ output(ostream &out) const {
|
||||
out << "point_sprite";
|
||||
break;
|
||||
|
||||
case M_light_vector:
|
||||
out << "light_vector: \"" << mode_def._source_name << "\", "
|
||||
<< mode_def._light;
|
||||
break;
|
||||
|
||||
case M_constant:
|
||||
out << "constant: " << mode_def._constant_value;
|
||||
break;
|
||||
|
||||
case M_unused:
|
||||
case M_unused2:
|
||||
break;
|
||||
}
|
||||
out << ")";
|
||||
@ -374,7 +299,7 @@ int TexGenAttrib::
|
||||
compare_to_impl(const RenderAttrib *other) const {
|
||||
const TexGenAttrib *ta;
|
||||
DCAST_INTO_R(ta, other, 0);
|
||||
|
||||
|
||||
Stages::const_iterator ai, bi;
|
||||
ai = _stages.begin();
|
||||
bi = ta->_stages.begin();
|
||||
@ -566,7 +491,7 @@ invert_compose_impl(const RenderAttrib *other) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexGenAttrib::get_auto_shader_attrib_impl
|
||||
// Access: Protected, Virtual
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) TexGenAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
@ -608,26 +533,6 @@ record_stage(TextureStage *stage, TexGenAttrib::ModeDef &mode_def) {
|
||||
_num_point_sprites++;
|
||||
break;
|
||||
|
||||
case M_light_vector:
|
||||
{
|
||||
if (!mode_def._light.is_empty()) {
|
||||
Light *light_obj = mode_def._light.node()->as_light();
|
||||
if (light_obj == (Light *)NULL) {
|
||||
#ifndef NDEBUG
|
||||
ostringstream strm;
|
||||
strm << "Not a light: " << mode_def._light;
|
||||
nassert_raise(strm.str());
|
||||
#endif
|
||||
mode_def._light = NodePath();
|
||||
}
|
||||
}
|
||||
|
||||
_light_vectors.insert(stage);
|
||||
_geom_rendering |= Geom::GR_texcoord_light_vector;
|
||||
_num_light_vectors++;
|
||||
}
|
||||
break;
|
||||
|
||||
case M_off:
|
||||
break;
|
||||
|
||||
|
@ -54,7 +54,6 @@ PUBLISHED:
|
||||
static CPT(RenderAttrib) make_default();
|
||||
|
||||
CPT(RenderAttrib) add_stage(TextureStage *stage, Mode mode) const;
|
||||
CPT(RenderAttrib) add_stage(TextureStage *stage, Mode mode, const string &source_name, const NodePath &light) const;
|
||||
CPT(RenderAttrib) add_stage(TextureStage *stage, Mode mode, const LTexCoord3 &constant_value) const;
|
||||
CPT(RenderAttrib) remove_stage(TextureStage *stage) const;
|
||||
|
||||
@ -62,16 +61,11 @@ PUBLISHED:
|
||||
bool has_stage(TextureStage *stage) const;
|
||||
Mode get_mode(TextureStage *stage) const;
|
||||
bool has_gen_texcoord_stage(TextureStage *stage) const;
|
||||
string get_source_name(TextureStage *stage) const;
|
||||
NodePath get_light(TextureStage *stage) const;
|
||||
const LTexCoord3 &get_constant_value(TextureStage *stage) const;
|
||||
|
||||
INLINE int get_geom_rendering(int geom_rendering) const;
|
||||
|
||||
public:
|
||||
typedef pset<TextureStage *> LightVectors;
|
||||
INLINE const LightVectors &get_light_vectors() const;
|
||||
|
||||
virtual void output(ostream &out) const;
|
||||
|
||||
protected:
|
||||
@ -105,16 +99,11 @@ private:
|
||||
typedef pset<TextureStage *> NoTexCoordStages;
|
||||
NoTexCoordStages _no_texcoords;
|
||||
|
||||
// This is another optimization during rendering; it lists the
|
||||
// texture stages (if any) that use M_light_vector.
|
||||
LightVectors _light_vectors;
|
||||
|
||||
// This element is only used during reading from a bam file. It has
|
||||
// no meaningful value any other time.
|
||||
pvector<Mode> _read_modes;
|
||||
|
||||
int _num_point_sprites;
|
||||
int _num_light_vectors;
|
||||
|
||||
// _point_geom_rendering is the GeomRendering bits that are added by
|
||||
// the TexGenAttrib if there are any points in the Geom.
|
||||
@ -122,7 +111,7 @@ private:
|
||||
// regardless of the kind of Geom it is.
|
||||
int _point_geom_rendering;
|
||||
int _geom_rendering;
|
||||
|
||||
|
||||
static CPT(RenderAttrib) _empty_attrib;
|
||||
|
||||
PUBLISHED:
|
||||
@ -141,7 +130,7 @@ public:
|
||||
protected:
|
||||
static TypedWritable *make_from_bam(const FactoryParams ¶ms);
|
||||
void fillin(DatagramIterator &scan, BamReader *manager);
|
||||
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
|
Loading…
x
Reference in New Issue
Block a user