create pgraphnodes directory; move some things there from pgraph

This commit is contained in:
David Rose 2008-11-06 00:06:39 +00:00
parent 4684bf10c9
commit 075710bced
54 changed files with 385 additions and 157 deletions

View File

@ -9,7 +9,7 @@
#define USE_PACKAGES net
#define COMPONENT_LIBS \
recorder pgraph pipeline \
recorder pgraph pgraphnodes pipeline \
pvrpn grutil chan pstatclient \
char chat collide cull device \
dgraph display event gobj graph gsgbase \

View File

@ -5,7 +5,7 @@
#begin lib_target
#define TARGET display
#define LOCAL_LIBS \
pgraph cull putil gsgbase gobj linmath mathutil \
pgraph pgraphnodes cull putil gsgbase gobj linmath mathutil \
pstatclient
#define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx

View File

@ -318,6 +318,9 @@
#define EXPCL_PANDA_PGRAPH EXPCL_PANDA
#define EXPTP_PANDA_PGRAPH EXPTP_PANDA
#define EXPCL_PANDA_PGRAPHNODES EXPCL_PANDA
#define EXPTP_PANDA_PGRAPHNODES EXPTP_PANDA
#define EXPCL_PANDA_RECORDER EXPCL_PANDA
#define EXPTP_PANDA_RECORDER EXPTP_PANDA

View File

@ -15,7 +15,6 @@
#define SOURCES \
accumulatedAttribs.I accumulatedAttribs.h \
alphaTestAttrib.I alphaTestAttrib.h \
ambientLight.I ambientLight.h \
antialiasAttrib.I antialiasAttrib.h \
attribNodeRegistry.I attribNodeRegistry.h \
attribSlots.h attribSlots.I \
@ -48,10 +47,10 @@
depthOffsetAttrib.I depthOffsetAttrib.h \
depthTestAttrib.I depthTestAttrib.h \
depthWriteAttrib.I depthWriteAttrib.h \
directionalLight.I directionalLight.h \
drawMaskAttrib.I drawMaskAttrib.h \
eventStorePandaNode.I eventStorePandaNode.h \
fadeLodNode.I fadeLodNode.h fadeLodNodeData.h \
fadeLodNode.I fadeLodNode.h \
fadeLodNodeData.h \
findApproxLevelEntry.I findApproxLevelEntry.h \
findApproxPath.I findApproxPath.h \
fog.I fog.h \
@ -63,8 +62,6 @@
light.I light.h \
lightAttrib.I lightAttrib.h \
lightRampAttrib.I lightRampAttrib.h \
lightLensNode.I lightLensNode.h \
lightNode.I lightNode.h \
loader.I loader.h \
loaderFileType.h \
loaderFileTypeBam.h \
@ -85,9 +82,8 @@
pandaNode.I pandaNode.h \
pandaNodeChain.I pandaNodeChain.h \
planeNode.I planeNode.h \
pointLight.I pointLight.h \
polylightNode.I polylightNode.h \
polylightEffect.I polylightEffect.h \
polylightNode.I polylightNode.h \
portalNode.I portalNode.h \
portalClipper.I portalClipper.h \
renderAttrib.I renderAttrib.h \
@ -101,18 +97,14 @@
sceneSetup.I sceneSetup.h \
scissorAttrib.I scissorAttrib.h \
scissorEffect.I scissorEffect.h \
selectiveChildNode.I selectiveChildNode.h \
sequenceNode.I sequenceNode.h \
shadeModelAttrib.I shadeModelAttrib.h \
shaderAttrib.I shaderAttrib.h \
shaderGenerator.I shaderGenerator.h \
shaderGeneratorBase.I shaderGeneratorBase.h \
shaderInput.I shaderInput.h \
shaderPool.I shaderPool.h \
showBoundsEffect.I showBoundsEffect.h \
spotlight.I spotlight.h \
stateMunger.I stateMunger.h \
stencilAttrib.I stencilAttrib.h \
switchNode.I switchNode.h \
texMatrixAttrib.I texMatrixAttrib.h \
texProjectorEffect.I texProjectorEffect.h \
textureAttrib.I textureAttrib.h \
@ -130,7 +122,6 @@
#define INCLUDED_SOURCES \
accumulatedAttribs.cxx \
alphaTestAttrib.cxx \
ambientLight.cxx \
antialiasAttrib.cxx \
attribNodeRegistry.cxx \
attribSlots.cxx \
@ -161,10 +152,10 @@
depthOffsetAttrib.cxx \
depthTestAttrib.cxx \
depthWriteAttrib.cxx \
directionalLight.cxx \
drawMaskAttrib.cxx \
eventStorePandaNode.cxx \
fadeLodNode.cxx fadeLodNodeData.cxx \
fadeLodNode.cxx \
fadeLodNodeData.cxx \
findApproxLevelEntry.cxx \
findApproxPath.cxx \
fog.cxx \
@ -176,8 +167,6 @@
light.cxx \
lightAttrib.cxx \
lightRampAttrib.cxx \
lightLensNode.cxx \
lightNode.cxx \
loader.cxx \
loaderFileType.cxx \
loaderFileTypeBam.cxx \
@ -197,9 +186,8 @@
pandaNode.cxx \
pandaNodeChain.cxx \
planeNode.cxx \
pointLight.cxx \
polylightNode.cxx \
polylightEffect.cxx \
polylightNode.cxx \
portalNode.cxx \
portalClipper.cxx \
renderAttrib.cxx \
@ -213,18 +201,14 @@
sceneSetup.cxx \
scissorAttrib.cxx \
scissorEffect.cxx \
selectiveChildNode.cxx \
sequenceNode.cxx \
shadeModelAttrib.cxx \
shaderAttrib.cxx \
shaderGenerator.cxx \
shaderGeneratorBase.cxx \
shaderInput.cxx \
shaderPool.cxx \
showBoundsEffect.cxx \
spotlight.cxx \
stateMunger.cxx \
stencilAttrib.cxx \
switchNode.cxx \
texMatrixAttrib.cxx \
texProjectorEffect.cxx \
textureAttrib.cxx \
@ -239,7 +223,6 @@
#define INSTALL_HEADERS \
accumulatedAttribs.I accumulatedAttribs.h \
alphaTestAttrib.I alphaTestAttrib.h \
ambientLight.I ambientLight.h \
antialiasAttrib.I antialiasAttrib.h \
attribNodeRegistry.I attribNodeRegistry.h \
attribSlots.h attribSlots.I \
@ -272,10 +255,10 @@
depthOffsetAttrib.I depthOffsetAttrib.h \
depthTestAttrib.I depthTestAttrib.h \
depthWriteAttrib.I depthWriteAttrib.h \
directionalLight.I directionalLight.h \
drawMaskAttrib.I drawMaskAttrib.h \
eventStorePandaNode.I eventStorePandaNode.h \
fadeLodNode.I fadeLodNode.h fadeLodNodeData.h \
fadeLodNode.I fadeLodNode.h \
fadeLodNodeData.h \
fog.I fog.h \
fogAttrib.I fogAttrib.h \
geomNode.I geomNode.h \
@ -285,8 +268,6 @@
light.I light.h \
lightAttrib.I lightAttrib.h \
lightRampAttrib.I lightRampAttrib.h \
lightLensNode.I lightLensNode.h \
lightNode.I lightNode.h \
loader.I loader.h \
loaderFileType.h \
loaderFileTypeBam.h \
@ -307,9 +288,8 @@
pandaNode.I pandaNode.h \
pandaNodeChain.I pandaNodeChain.h \
planeNode.I planeNode.h \
pointLight.I pointLight.h \
polylightNode.I polylightNode.h \
polylightEffect.I polylightEffect.h \
polylightNode.I polylightNode.h \
portalNode.I portalNode.h \
portalClipper.I portalClipper.h \
renderAttrib.I renderAttrib.h \
@ -323,18 +303,14 @@
sceneSetup.I sceneSetup.h \
scissorAttrib.I scissorAttrib.h \
scissorEffect.I scissorEffect.h \
selectiveChildNode.I selectiveChildNode.h \
sequenceNode.I sequenceNode.h \
shadeModelAttrib.I shadeModelAttrib.h \
shaderAttrib.I shaderAttrib.h \
shaderGenerator.I shaderGenerator.h \
shaderGeneratorBase.I shaderGeneratorBase.h \
shaderInput.I shaderInput.h \
shaderPool.I shaderPool.h \
showBoundsEffect.I showBoundsEffect.h \
spotlight.I spotlight.h \
stateMunger.I stateMunger.h \
stencilAttrib.I stencilAttrib.h \
switchNode.I switchNode.h \
texMatrixAttrib.I texMatrixAttrib.h \
texProjectorEffect.I texProjectorEffect.h \
textureAttrib.I textureAttrib.h \

View File

@ -17,7 +17,6 @@
#include "alphaTestAttrib.h"
#include "audioVolumeAttrib.h"
#include "auxBitplaneAttrib.h"
#include "ambientLight.h"
#include "antialiasAttrib.h"
#include "auxSceneData.h"
#include "billboardEffect.h"
@ -37,12 +36,11 @@
#include "depthOffsetAttrib.h"
#include "depthTestAttrib.h"
#include "depthWriteAttrib.h"
#include "directionalLight.h"
#include "drawMaskAttrib.h"
#include "eventStorePandaNode.h"
#include "findApproxLevelEntry.h"
#include "fadeLodNode.h"
#include "fadeLodNodeData.h"
#include "findApproxLevelEntry.h"
#include "fog.h"
#include "fogAttrib.h"
#include "geomNode.h"
@ -51,8 +49,6 @@
#include "light.h"
#include "lightAttrib.h"
#include "lightRampAttrib.h"
#include "lightLensNode.h"
#include "lightNode.h"
#include "loader.h"
#include "loaderFileType.h"
#include "loaderFileTypeBam.h"
@ -67,9 +63,8 @@
#include "nodePathComponent.h"
#include "pandaNode.h"
#include "planeNode.h"
#include "pointLight.h"
#include "polylightNode.h"
#include "polylightEffect.h"
#include "polylightNode.h"
#include "portalNode.h"
#include "portalClipper.h"
#include "renderAttrib.h"
@ -78,8 +73,6 @@
#include "renderModeAttrib.h"
#include "renderState.h"
#include "rescaleNormalAttrib.h"
#include "selectiveChildNode.h"
#include "sequenceNode.h"
#include "scissorAttrib.h"
#include "scissorEffect.h"
#include "shadeModelAttrib.h"
@ -88,9 +81,7 @@
#include "shader.h"
#include "showBoundsEffect.h"
#include "stencilAttrib.h"
#include "spotlight.h"
#include "stateMunger.h"
#include "switchNode.h"
#include "texMatrixAttrib.h"
#include "texProjectorEffect.h"
#include "textureAttrib.h"
@ -98,7 +89,7 @@
#include "transformState.h"
#include "transparencyAttrib.h"
#include "nodePathLerps.h"
#include "shaderGenerator.h"
#include "shaderGeneratorBase.h"
#include "dconfig.h"
@ -379,7 +370,6 @@ init_libpgraph() {
initialized = true;
AlphaTestAttrib::init_type();
AmbientLight::init_type();
AntialiasAttrib::init_type();
AudioVolumeAttrib::init_type();
AuxBitplaneAttrib::init_type();
@ -401,7 +391,6 @@ init_libpgraph() {
DepthOffsetAttrib::init_type();
DepthTestAttrib::init_type();
DepthWriteAttrib::init_type();
DirectionalLight::init_type();
DrawMaskAttrib::init_type();
EventStorePandaNode::init_type();
FadeLODNode::init_type();
@ -415,8 +404,6 @@ init_libpgraph() {
Light::init_type();
LightAttrib::init_type();
LightRampAttrib::init_type();
LightLensNode::init_type();
LightNode::init_type();
Loader::init_type();
LODNode::init_type();
LoaderFileType::init_type();
@ -431,7 +418,6 @@ init_libpgraph() {
PandaNode::init_type();
PandaNodePipelineReader::init_type();
PlaneNode::init_type();
PointLight::init_type();
PolylightNode::init_type();
PolylightEffect::init_type();
PortalNode::init_type();
@ -442,19 +428,15 @@ init_libpgraph() {
RenderModeAttrib::init_type();
RenderState::init_type();
RescaleNormalAttrib::init_type();
SelectiveChildNode::init_type();
SequenceNode::init_type();
ScissorAttrib::init_type();
ScissorEffect::init_type();
ShadeModelAttrib::init_type();
ShaderInput::init_type();
ShaderAttrib::init_type();
ShaderGenerator::init_type();
ShaderGeneratorBase::init_type();
ShowBoundsEffect::init_type();
Spotlight::init_type();
StateMunger::init_type();
StencilAttrib::init_type();
SwitchNode::init_type();
TexMatrixAttrib::init_type();
TexProjectorEffect::init_type();
TextureAttrib::init_type();
@ -471,7 +453,6 @@ init_libpgraph() {
ColorScaleLerpFunctor::init_type();
AlphaTestAttrib::register_with_read_factory();
AmbientLight::register_with_read_factory();
AntialiasAttrib::register_with_read_factory();
AudioVolumeAttrib::register_with_read_factory();
AuxBitplaneAttrib::register_with_read_factory();
@ -489,7 +470,6 @@ init_libpgraph() {
DepthOffsetAttrib::register_with_read_factory();
DepthTestAttrib::register_with_read_factory();
DepthWriteAttrib::register_with_read_factory();
DirectionalLight::register_with_read_factory();
DrawMaskAttrib::register_with_read_factory();
FadeLODNode::register_with_read_factory();
Fog::register_with_read_factory();
@ -504,14 +484,12 @@ init_libpgraph() {
ModelRoot::register_with_read_factory();
PandaNode::register_with_read_factory();
PlaneNode::register_with_read_factory();
PointLight::register_with_read_factory();
PolylightNode::register_with_read_factory();
PortalNode::register_with_read_factory();
RenderEffects::register_with_read_factory();
RenderModeAttrib::register_with_read_factory();
RenderState::register_with_read_factory();
RescaleNormalAttrib::register_with_read_factory();
SequenceNode::register_with_read_factory();
ScissorAttrib::register_with_read_factory();
ScissorEffect::register_with_read_factory();
ShadeModelAttrib::register_with_read_factory();
@ -519,8 +497,6 @@ init_libpgraph() {
ShaderAttrib::register_with_read_factory();
Shader::register_with_read_factory();
ShowBoundsEffect::register_with_read_factory();
Spotlight::register_with_read_factory();
SwitchNode::register_with_read_factory();
TexMatrixAttrib::register_with_read_factory();
TexProjectorEffect::register_with_read_factory();
TextureAttrib::register_with_read_factory();

View File

@ -13,11 +13,8 @@
////////////////////////////////////////////////////////////////////
#include "cullableObject.h"
#include "ambientLight.h"
#include "lightAttrib.h"
#include "nodePath.h"
#include "material.h"
#include "materialAttrib.h"
#include "texGenAttrib.h"
#include "renderState.h"
#include "clockObject.h"
@ -701,20 +698,10 @@ get_flash_cpu_state() {
// and never free it.
static CPT(RenderState) flash_cpu_state = (const RenderState *)NULL;
if (flash_cpu_state == (const RenderState *)NULL) {
PT(AmbientLight) ambient_light = new AmbientLight("alight");
ambient_light->set_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f));
NodePath alight(ambient_light);
CPT(LightAttrib) light_attrib = DCAST(LightAttrib, LightAttrib::make_all_off());
light_attrib = DCAST(LightAttrib, light_attrib->add_on_light(alight));
PT(Material) material = new Material;
material->set_ambient(flash_cpu_color);
material->set_diffuse(flash_cpu_color);
flash_cpu_state = RenderState::make
(light_attrib,
MaterialAttrib::make(material));
(LightAttrib::make_all_off(),
TextureAttrib::make_off(),
ColorAttrib::make_flat(flash_cpu_color));
}
return flash_cpu_state;
@ -735,20 +722,10 @@ get_flash_hardware_state() {
// and never free it.
static CPT(RenderState) flash_hardware_state = (const RenderState *)NULL;
if (flash_hardware_state == (const RenderState *)NULL) {
PT(AmbientLight) ambient_light = new AmbientLight("alight");
ambient_light->set_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f));
NodePath alight(ambient_light);
CPT(LightAttrib) light_attrib = DCAST(LightAttrib, LightAttrib::make_all_off());
light_attrib = DCAST(LightAttrib, light_attrib->add_on_light(alight));
PT(Material) material = new Material;
material->set_ambient(flash_hardware_color);
material->set_diffuse(flash_hardware_color);
flash_hardware_state = RenderState::make
(light_attrib,
MaterialAttrib::make(material));
(LightAttrib::make_all_off(),
TextureAttrib::make_off(),
ColorAttrib::make_flat(flash_hardware_color));
}
return flash_hardware_state;

View File

@ -65,6 +65,17 @@ Light::
~Light() {
}
////////////////////////////////////////////////////////////////////
// Function: Light::is_ambient_light
// Access: Published, Virtual
// Description: Returns true if this is an AmbientLight, false if it
// is some other kind of light.
////////////////////////////////////////////////////////////////////
bool Light::
is_ambient_light() const {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: Light::get_vector_to_light
// Access: Public, Virtual

View File

@ -50,6 +50,7 @@ PUBLISHED:
virtual ~Light();
virtual PandaNode *as_node()=0;
virtual bool is_ambient_light() const;
INLINE const Colorf &get_color() const;
INLINE void set_color(const Colorf &color);

View File

@ -14,7 +14,6 @@
#include "lightAttrib.h"
#include "attribSlots.h"
#include "ambientLight.h"
#include "pandaNode.h"
#include "nodePath.h"
#include "graphicsStateGuardianBase.h"
@ -506,7 +505,7 @@ filter_to_max(int max_lights) const {
for (li = _on_lights.begin(); li != _on_lights.end(); ++li) {
const NodePath &np = (*li);
nassertr(!np.is_empty() && np.node()->as_light() != (Light *)NULL, this);
if (np.node()->is_exact_type(AmbientLight::get_class_type())) {
if (np.node()->is_ambient_light()) {
ambient_lights.push_back(np);
} else {
priority_lights.push_back(np);
@ -562,7 +561,7 @@ get_most_important_light() const {
for (li = _on_lights.begin(); li != _on_lights.end(); ++li) {
const NodePath &np = (*li);
nassertr(!np.is_empty() && np.node()->as_light() != (Light *)NULL, NodePath());
if (!np.node()->is_exact_type(AmbientLight::get_class_type())) {
if (!np.node()->is_ambient_light()) {
if (best.is_empty() || compare(np, best)) {
best = np;
}

View File

@ -2464,6 +2464,17 @@ as_light() {
return NULL;
}
////////////////////////////////////////////////////////////////////
// Function: PandaNode::is_ambient_light
// Access: Published, Virtual
// Description: Returns true if this is an AmbientLight, false if it
// is not a light, or it is some other kind of light.
////////////////////////////////////////////////////////////////////
bool PandaNode::
is_ambient_light() const {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: PandaNode::get_internal_bounds
// Access: Protected

View File

@ -280,6 +280,7 @@ PUBLISHED:
virtual bool is_geom_node() const;
virtual bool is_lod_node() const;
virtual Light *as_light();
virtual bool is_ambient_light() const;
enum FancyBits {
FB_transform = 0x0001,

View File

@ -1,5 +1,4 @@
#include "accumulatedAttribs.cxx"
#include "ambientLight.cxx"
#include "antialiasAttrib.cxx"
#include "attribNodeRegistry.cxx"
#include "audioVolumeAttrib.cxx"

View File

@ -13,7 +13,6 @@
#include "depthTestAttrib.cxx"
#include "depthWriteAttrib.cxx"
#include "alphaTestAttrib.cxx"
#include "directionalLight.cxx"
#include "drawMaskAttrib.cxx"
#include "eventStorePandaNode.cxx"
#include "fadeLodNode.cxx"

View File

@ -3,8 +3,6 @@
#include "light.cxx"
#include "lightAttrib.cxx"
#include "lightRampAttrib.cxx"
#include "lightLensNode.cxx"
#include "lightNode.cxx"
#include "loader.cxx"
#include "loaderFileType.cxx"
#include "loaderFileTypeBam.cxx"
@ -24,8 +22,7 @@
#include "pandaNode.cxx"
#include "pandaNodeChain.cxx"
#include "planeNode.cxx"
#include "pointLight.cxx"
#include "polylightNode.cxx"
#include "polylightEffect.cxx"
#include "polylightNode.cxx"
#include "portalNode.cxx"
#include "portalClipper.cxx"

View File

@ -6,20 +6,16 @@
#include "rescaleNormalAttrib.cxx"
#include "sceneGraphAnalyzer.cxx"
#include "sceneGraphReducer.cxx"
#include "selectiveChildNode.cxx"
#include "sequenceNode.cxx"
#include "scissorAttrib.cxx"
#include "scissorEffect.cxx"
#include "shadeModelAttrib.cxx"
#include "shaderInput.cxx"
#include "shaderAttrib.cxx"
#include "shaderPool.cxx"
#include "shaderGenerator.cxx"
#include "shaderGeneratorBase.cxx"
#include "showBoundsEffect.cxx"
#include "spotlight.cxx"
#include "stateMunger.cxx"
#include "stencilAttrib.cxx"
#include "switchNode.cxx"
#include "texMatrixAttrib.cxx"
#include "texProjectorEffect.cxx"
#include "textureAttrib.cxx"

View File

@ -36,7 +36,7 @@
#include "lightMutexHolder.h"
#include "thread.h"
#include "attribSlots.h"
#include "shaderGenerator.h"
#include "shaderGeneratorBase.h"
LightReMutex *RenderState::_states_lock = NULL;
RenderState::States *RenderState::_states = NULL;
@ -1258,7 +1258,7 @@ get_generated_shader() const {
if (_generated_shader != (RenderAttrib*)NULL) {
return DCAST(ShaderAttrib, _generated_shader);
}
ShaderGenerator *gen = ShaderGenerator::get_default();
ShaderGeneratorBase *gen = ShaderGeneratorBase::get_default();
((RenderState*)this)->_generated_shader =
gen->synthesize_shader(this);
return DCAST(ShaderAttrib, _generated_shader);

View File

@ -0,0 +1,14 @@
// Filename: shaderGeneratorBase.I
// Created by: drose (05Nov08)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,56 @@
// Filename: shaderGeneratorBase.cxx
// Created by: drose (05Nov08)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#include "shaderGeneratorBase.h"
TypeHandle ShaderGeneratorBase::_type_handle;
PT(ShaderGeneratorBase) ShaderGeneratorBase::_default_generator;
////////////////////////////////////////////////////////////////////
// Function: ShaderGeneratorBase::Constructor
// Access: Protected
// Description:
////////////////////////////////////////////////////////////////////
ShaderGeneratorBase::
ShaderGeneratorBase() {
}
////////////////////////////////////////////////////////////////////
// Function: ShaderGeneratorBase::Destructor
// Access: Published, Virtual
// Description:
////////////////////////////////////////////////////////////////////
ShaderGeneratorBase::
~ShaderGeneratorBase() {
}
////////////////////////////////////////////////////////////////////
// Function: ShaderGeneratorBase::get_default
// Access: Published, Static
// Description: Get a pointer to the default shader generator.
////////////////////////////////////////////////////////////////////
ShaderGeneratorBase *ShaderGeneratorBase::
get_default() {
return _default_generator;
}
////////////////////////////////////////////////////////////////////
// Function: ShaderGeneratorBase::set_default
// Access: Published, Static
// Description: Set the default shader generator.
////////////////////////////////////////////////////////////////////
void ShaderGeneratorBase::
set_default(ShaderGeneratorBase *generator) {
_default_generator = generator;
}

View File

@ -0,0 +1,59 @@
// Filename: shaderGeneratorBase.h
// Created by: drose (05Nov08)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef SHADERGENERATORBASE_H
#define SHADERGENERATORBASE_H
#include "pandabase.h"
#include "typedWritableReferenceCount.h"
////////////////////////////////////////////////////////////////////
// Class : ShaderGeneratorBase
// Description : This is the abstract base class for ShaderGenerator.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PGRAPH ShaderGeneratorBase : public TypedWritableReferenceCount {
private:
static PT(ShaderGeneratorBase) _default_generator;
protected:
ShaderGeneratorBase();
PUBLISHED:
virtual ~ShaderGeneratorBase();
static ShaderGeneratorBase *get_default();
static void set_default(ShaderGeneratorBase *generator);
virtual CPT(RenderAttrib) synthesize_shader(const RenderState *rs)=0;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
TypedWritableReferenceCount::init_type();
register_type(_type_handle, "ShaderGeneratorBase",
TypedWritableReferenceCount::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;
};
#include "shaderGeneratorBase.I"
#endif // SHADERGENERATORBASE_H

View File

@ -0,0 +1,55 @@
#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
dtoolutil:c dtoolbase:c dtool:m prc:c
#define LOCAL_LIBS \
lerp event gsgbase gobj putil linmath \
downloader express pandabase pstatclient pgraph
#define USE_PACKAGES python
#begin lib_target
#define TARGET pgraphnodes
#define COMBINED_SOURCES \
$[TARGET]_composite1.cxx $[TARGET]_composite2.cxx
#define SOURCES \
ambientLight.h ambientLight.I \
config_pgraphnodes.h \
directionalLight.h directionalLight.I \
lightLensNode.h lightLensNode.I \
lightNode.h lightNode.I \
pointLight.h pointLight.I \
selectiveChildNode.h selectiveChildNode.I \
sequenceNode.h sequenceNode.I \
shaderGenerator.h shaderGenerator.I \
spotlight.h spotlight.I \
switchNode.h switchNode.I
#define INCLUDED_SOURCES \
ambientLight.cxx \
config_pgraphnodes.cxx \
directionalLight.cxx \
lightLensNode.cxx \
lightNode.cxx \
pointLight.cxx \
selectiveChildNode.cxx \
sequenceNode.cxx \
shaderGenerator.cxx \
spotlight.cxx \
switchNode.cxx
#define INSTALL_HEADERS \
ambientLight.h ambientLight.I \
config_pgraphnodes.h \
directionalLight.h directionalLight.I \
lightLensNode.h lightLensNode.I \
lightNode.h lightNode.I \
pointLight.h pointLight.I \
selectiveChildNode.h selectiveChildNode.I \
sequenceNode.h sequenceNode.I \
shaderGenerator.h shaderGenerator.I \
spotlight.h spotlight.I \
switchNode.h switchNode.I
#define IGATESCAN all
#end lib_target

View File

@ -85,6 +85,17 @@ write(ostream &out, int indent_level) const {
<< "color " << get_color() << "\n";
}
////////////////////////////////////////////////////////////////////
// Function: AmbientLight::is_ambient_light
// Access: Published, Virtual
// Description: Returns true if this is an AmbientLight, false if it
// is some other kind of light.
////////////////////////////////////////////////////////////////////
bool AmbientLight::
is_ambient_light() const {
return true;
}
////////////////////////////////////////////////////////////////////
// Function: AmbientLight::bind
// Access: Public, Virtual

View File

@ -26,7 +26,7 @@
// be part of the scene graph, since it has no meaningful
// position.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PGRAPH AmbientLight : public LightNode {
class EXPCL_PANDA_PGRAPHNODES AmbientLight : public LightNode {
PUBLISHED:
AmbientLight(const string &name);
@ -36,6 +36,7 @@ protected:
public:
virtual PandaNode *make_copy() const;
virtual void write(ostream &out, int indent_level) const;
virtual bool is_ambient_light() const;
PUBLISHED:
virtual int get_class_priority() const;

View File

@ -0,0 +1,75 @@
// Filename: config_pgraphnodes.cxx
// Created by: drose (05Nov08)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#include "config_pgraphnodes.h"
#include "ambientLight.h"
#include "directionalLight.h"
#include "lightLensNode.h"
#include "lightNode.h"
#include "pointLight.h"
#include "selectiveChildNode.h"
#include "sequenceNode.h"
#include "shaderGenerator.h"
#include "spotlight.h"
#include "switchNode.h"
#include "dconfig.h"
ConfigureDef(config_pgraphnodes);
NotifyCategoryDef(pgraphnodes, "");
ConfigureFn(config_pgraphnodes) {
init_libpgraphnodes();
}
////////////////////////////////////////////////////////////////////
// Function: init_libpgraphnodes
// Description: Initializes the library. This must be called at
// least once before any of the functions or classes in
// this library can be used. Normally it will be
// called by the static initializers and need not be
// called explicitly, but special cases exist.
////////////////////////////////////////////////////////////////////
void
init_libpgraphnodes() {
static bool initialized = false;
if (initialized) {
return;
}
initialized = true;
AmbientLight::init_type();
DirectionalLight::init_type();
LightLensNode::init_type();
LightNode::init_type();
PointLight::init_type();
SelectiveChildNode::init_type();
SequenceNode::init_type();
ShaderGenerator::init_type();
Spotlight::init_type();
SwitchNode::init_type();
AmbientLight::register_with_read_factory();
DirectionalLight::register_with_read_factory();
LightLensNode::register_with_read_factory();
LightNode::register_with_read_factory();
PointLight::register_with_read_factory();
SelectiveChildNode::register_with_read_factory();
SequenceNode::register_with_read_factory();
Spotlight::register_with_read_factory();
SwitchNode::register_with_read_factory();
ShaderGenerator::set_default(new ShaderGenerator());
}

View File

@ -0,0 +1,27 @@
// Filename: config_pgraphnodes.h
// Created by: drose (05Nov08)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef CONFIG_PGRAPHNODES_H
#define CONFIG_PGRAPHNODES_H
#include "pandabase.h"
class DSearchPath;
ConfigureDecl(config_pgraphnodes, EXPCL_PANDA_PGRAPHNODES, EXPTP_PANDA_PGRAPHNODES);
NotifyCategoryDecl(pgraphnodes, EXPCL_PANDA_PGRAPHNODES, EXPTP_PANDA_PGRAPHNODES);
extern EXPCL_PANDA_PGRAPHNODES void init_libpgraphnodes();
#endif

View File

@ -24,7 +24,7 @@
// Description : A light shining from infinitely far away in a
// particular direction, like sunlight.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PGRAPH DirectionalLight : public LightNode {
class EXPCL_PANDA_PGRAPHNODES DirectionalLight : public LightNode {
PUBLISHED:
DirectionalLight(const string &name);
@ -58,7 +58,7 @@ public:
private:
// This is the data that must be cycled between pipeline stages.
class EXPCL_PANDA_PGRAPH CData : public CycleData {
class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
public:
INLINE CData();
INLINE CData(const CData &copy);

View File

@ -24,7 +24,7 @@
// Class : LightLensNode
// Description : A derivative of Light and of LensNode.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PGRAPH LightLensNode : public Light, public LensNode {
class EXPCL_PANDA_PGRAPHNODES LightLensNode : public Light, public LensNode {
PUBLISHED:
LightLensNode(const string &name);

View File

@ -26,7 +26,7 @@
// Light except Spotlight (which must inherit from
// LensNode instead) inherit from this class.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PGRAPH LightNode : public Light, public PandaNode {
class EXPCL_PANDA_PGRAPHNODES LightNode : public Light, public PandaNode {
PUBLISHED:
LightNode(const string &name);

View File

@ -0,0 +1,6 @@
#include "ambientLight.cxx"
#include "config_pgraphnodes.cxx"
#include "directionalLight.cxx"
#include "lightLensNode.cxx"
#include "lightNode.cxx"
#include "pointLight.cxx"

View File

@ -0,0 +1,5 @@
#include "selectiveChildNode.cxx"
#include "sequenceNode.cxx"
#include "shaderGenerator.cxx"
#include "spotlight.cxx"
#include "switchNode.cxx"

View File

@ -24,7 +24,7 @@
// Description : A light originating from a single point in space, and
// shining in all directions.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PGRAPH PointLight : public LightNode {
class EXPCL_PANDA_PGRAPHNODES PointLight : public LightNode {
PUBLISHED:
PointLight(const string &name);
@ -58,7 +58,7 @@ public:
private:
// This is the data that must be cycled between pipeline stages.
class EXPCL_PANDA_PGRAPH CData : public CycleData {
class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
public:
INLINE CData();
INLINE CData(const CData &copy);

View File

@ -24,7 +24,7 @@
// Description : A base class for nodes like LODNode and SequenceNode
// that select only one visible child at a time.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PGRAPH SelectiveChildNode : public PandaNode {
class EXPCL_PANDA_PGRAPHNODES SelectiveChildNode : public PandaNode {
PUBLISHED:
INLINE SelectiveChildNode(const string &name);

View File

@ -26,7 +26,7 @@
// Description : A node that automatically cycles through rendering
// each one of its children according to its frame rate.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PGRAPH SequenceNode : public SelectiveChildNode, public AnimInterface {
class EXPCL_PANDA_PGRAPHNODES SequenceNode : public SelectiveChildNode, public AnimInterface {
PUBLISHED:
INLINE SequenceNode(const string &name);

View File

@ -22,7 +22,6 @@
#include "spotlight.h"
TypeHandle ShaderGenerator::_type_handle;
PT(ShaderGenerator) ShaderGenerator::_default_generator;
////////////////////////////////////////////////////////////////////
// Function: ShaderGenerator::Constructor
@ -106,29 +105,6 @@ alloc_freg() {
return "UNKNOWN";
}
////////////////////////////////////////////////////////////////////
// Function: ShaderGenerator::get_default
// Access: Published, Static
// Description: Get a pointer to the default shader generator.
////////////////////////////////////////////////////////////////////
ShaderGenerator *ShaderGenerator::
get_default() {
if (_default_generator == (ShaderGenerator *)NULL) {
_default_generator = new ShaderGenerator;
}
return _default_generator;
}
////////////////////////////////////////////////////////////////////
// Function: ShaderGenerator::set_default
// Access: Published, Static
// Description: Set the default shader generator.
////////////////////////////////////////////////////////////////////
void ShaderGenerator::
set_default(ShaderGenerator *generator) {
_default_generator = generator;
}
////////////////////////////////////////////////////////////////////
// Function: ShaderGenerator::analyze_renderstate
// Access: Protected

View File

@ -16,8 +16,10 @@
#define SHADERGENERATOR_H
#include "pandabase.h"
#include "typedWritableReferenceCount.h"
#include "shaderGeneratorBase.h"
#include "attribSlots.h"
#include "nodePath.h"
class AmbientLight;
class DirectionalLight;
class PointLight;
@ -58,15 +60,10 @@ class ShaderAttrib;
//
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PGRAPH ShaderGenerator : public TypedWritableReferenceCount {
private:
static PT(ShaderGenerator) _default_generator;
class EXPCL_PANDA_PGRAPHNODES ShaderGenerator : public ShaderGeneratorBase {
PUBLISHED:
ShaderGenerator();
virtual ~ShaderGenerator();
static ShaderGenerator *get_default();
static void set_default(ShaderGenerator *generator);
virtual CPT(RenderAttrib) synthesize_shader(const RenderState *rs);
protected:
@ -135,9 +132,9 @@ public:
return _type_handle;
}
static void init_type() {
TypedReferenceCount::init_type();
ShaderGeneratorBase::init_type();
register_type(_type_handle, "ShaderGenerator",
TypedReferenceCount::get_class_type());
ShaderGeneratorBase::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();

View File

@ -35,7 +35,7 @@ class Texture;
// SpotLight, because "spotlight" is a single English
// word, instead of two words.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PGRAPH Spotlight : public LightLensNode {
class EXPCL_PANDA_PGRAPHNODES Spotlight : public LightLensNode {
PUBLISHED:
Spotlight(const string &name);
@ -78,7 +78,7 @@ private:
private:
// This is the data that must be cycled between pipeline stages.
class EXPCL_PANDA_PGRAPH CData : public CycleData {
class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
public:
INLINE CData();
INLINE CData(const CData &copy);

View File

@ -24,7 +24,7 @@
// Description : A node that renders only one of its children,
// according to the user's indication.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PGRAPH SwitchNode : public SelectiveChildNode {
class EXPCL_PANDA_PGRAPHNODES SwitchNode : public SelectiveChildNode {
PUBLISHED:
INLINE SwitchNode(const string &name);
@ -43,7 +43,7 @@ PUBLISHED:
virtual int get_visible_child() const;
private:
class EXPCL_PANDA_PGRAPH CData : public CycleData {
class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
public:
INLINE CData();
INLINE CData(const CData &copy);