diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index b145b466e4..ec136a454e 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -42,6 +42,7 @@ #include "sequenceNode.h" #include "switchNode.h" #include "portalNode.h" +#include "polylightNode.h" #include "lodNode.h" #include "modelNode.h" #include "modelRoot.h" @@ -1626,8 +1627,25 @@ make_node(EggGroup *egg_group, PandaNode *parent) { if (pnode->get_num_vertices() == 0) { egg2pg_cat.warning() << "Portal " << egg_group->get_name() << " has no vertices!\n"; - } + } + } else if (egg_group->get_polylight_flag()) { + // Create a polylight instead of a regular polyset. + // use make_sphere to get the center, radius and color + //egg2pg_cat.debug() << "polylight node\n"; + LPoint3f center; + Colorf color; + float radius; + + if(!make_sphere(egg_group,center,radius,color)) { + egg2pg_cat.warning() + << "Polylight " << egg_group->get_name() << " make_sphere failed!\n"; + } + PolylightNode *pnode = new PolylightNode(egg_group->get_name(), + center[0], center[1], center[2], color[0], color[1], color[2], + radius, "linear", false, "random"); + node = pnode; + } else { // A normal group; just create a normal node, and traverse. node = new PandaNode(egg_group->get_name()); @@ -1832,7 +1850,7 @@ find_first_polygon(EggGroup *egg_group) { // Polylight sphere. It could be used for other spheres. //////////////////////////////////////////////////////////////////// bool EggLoader:: -make_sphere(EggGroup *egg_group, LPoint3f ¢er, float &radius) { +make_sphere(EggGroup *egg_group, LPoint3f ¢er, float &radius, Colorf &color) { bool success=false; EggGroup *geom_group = find_collision_geometry(egg_group); if (geom_group != (EggGroup *)NULL) { @@ -1863,6 +1881,7 @@ make_sphere(EggGroup *egg_group, LPoint3f ¢er, float &radius) { if (num_vertices > 0) { d_center /= (double)num_vertices; + //egg2pg_cat.debug() << "make_sphere d_center: " << d_center << "\n"; LMatrix4d mat = egg_group->get_vertex_to_node(); d_center = d_center * mat; @@ -1872,13 +1891,23 @@ make_sphere(EggGroup *egg_group, LPoint3f ¢er, float &radius) { for (vi = vertices.begin(); vi != vertices.end(); ++vi) { EggVertex *vtx = (*vi); LPoint3d p3 = vtx->get_pos3(); - LVector3d v = p3 * mat - d_center; + LVector3d v = p3 * mat - d_center; radius2 = max(radius2, v.length_squared()); } center = LCAST(float,d_center); - float radius = sqrtf(radius2); + radius = sqrtf(radius2); + //egg2pg_cat.debug() << "make_sphere radius: " << radius << "\n"; + vi = vertices.begin(); + EggVertex *clr_vtx = (*vi); + if (clr_vtx->has_color()) { + color = clr_vtx->get_color(); + } + else { + color = Colorf(1.0,1.0,1.0,1.0); + } success = true; + } } return success; @@ -2015,7 +2044,8 @@ make_collision_sphere(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { LPoint3f center; float radius; - if (make_sphere(egg_group, center, radius)) { + Colorf dummycolor; + if (make_sphere(egg_group, center, radius, dummycolor)) { CollisionSphere *cssphere = new CollisionSphere(center, radius); apply_collision_flags(cssphere, flags); @@ -2479,6 +2509,9 @@ expand_object_types(EggGroup *egg_group, const pset &expanded, // Ignorable group; stop here. return false; } + //else + //egg2pg_cat.debug() << "returned true\n"; + } } @@ -2551,6 +2584,7 @@ do_expand_object_type(EggGroup *egg_group, const pset &expanded, egg2pg_cat.error() << "Unknown ObjectType " << object_type << "\n"; _error = true; + egg2pg_cat.debug() << "returning true\n"; return true; } } diff --git a/panda/src/egg2pg/eggLoader.h b/panda/src/egg2pg/eggLoader.h index 6f1fbbbc4f..2d047a62b6 100644 --- a/panda/src/egg2pg/eggLoader.h +++ b/panda/src/egg2pg/eggLoader.h @@ -52,6 +52,7 @@ class CollisionNode; class CollisionPlane; class CollisionPolygon; class PortalNode; +class PolylightNode; /////////////////////////////////////////////////////////////////// // Class : EggLoader @@ -113,7 +114,7 @@ private: void set_portal_polygon(EggGroup *egg_group, PortalNode *pnode); EggPolygon *find_first_polygon(EggGroup *egg_group); - bool make_sphere(EggGroup *start_group, LPoint3f ¢er, float &radius); + bool make_sphere(EggGroup *start_group, LPoint3f ¢er, float &radius, Colorf &color); void make_collision_solids(EggGroup *start_group, EggGroup *egg_group, CollisionNode *cnode); diff --git a/panda/src/pgraph/Sources.pp b/panda/src/pgraph/Sources.pp index 7099a04518..e495230639 100644 --- a/panda/src/pgraph/Sources.pp +++ b/panda/src/pgraph/Sources.pp @@ -1,282 +1,288 @@ -#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ - dtoolutil:c dtoolbase:c dtool:m -#define LOCAL_LIBS \ - lerp event gsgbase gobj putil linmath \ - downloader express pandabase pstatclient - -#begin lib_target - #define TARGET pgraph - - #define SOURCES \ - accumulatedAttribs.I accumulatedAttribs.h \ - alphaTestAttrib.I alphaTestAttrib.h \ - ambientLight.I ambientLight.h \ - bamFile.I bamFile.h \ - billboardEffect.I billboardEffect.h \ - binCullHandler.I binCullHandler.h \ - camera.I camera.h \ - clipPlaneAttrib.I clipPlaneAttrib.h \ - colorAttrib.I colorAttrib.h \ - colorBlendAttrib.I colorBlendAttrib.h \ - colorScaleAttrib.I colorScaleAttrib.h \ - colorWriteAttrib.I colorWriteAttrib.h \ - compassEffect.I compassEffect.h \ - config_pgraph.h \ - cullBin.I cullBin.h \ - cullBinAttrib.I cullBinAttrib.h \ - cullBinBackToFront.I cullBinBackToFront.h \ - cullBinFixed.I cullBinFixed.h \ - cullBinFrontToBack.I cullBinFrontToBack.h \ - cullBinManager.I cullBinManager.h \ - cullBinUnsorted.I cullBinUnsorted.h \ - cullFaceAttrib.I cullFaceAttrib.h \ - cullHandler.I cullHandler.h \ - cullResult.I cullResult.h \ - cullTraverser.I cullTraverser.h \ - cullTraverserData.I cullTraverserData.h \ - cullableObject.I cullableObject.h \ - decalEffect.I decalEffect.h \ - depthOffsetAttrib.I depthOffsetAttrib.h \ - depthTestAttrib.I depthTestAttrib.h \ - depthWriteAttrib.I depthWriteAttrib.h \ - directionalLight.I directionalLight.h \ - drawCullHandler.I drawCullHandler.h \ - findApproxLevel.I findApproxLevel.h \ - findApproxLevelEntry.I findApproxLevelEntry.h \ - findApproxPath.I findApproxPath.h \ - fog.I fog.h \ - fogAttrib.I fogAttrib.h \ - geomNode.I geomNode.h \ - geomTransformer.I geomTransformer.h \ - lensNode.I lensNode.h \ - light.I light.h \ - lightAttrib.I lightAttrib.h \ - lightLensNode.I lightLensNode.h \ - lightNode.I lightNode.h \ - loader.I loader.h \ - loaderFileType.h \ - loaderFileTypeBam.h \ - loaderFileTypeRegistry.h \ - lodNode.I lodNode.h \ - materialAttrib.I materialAttrib.h \ - modelNode.I modelNode.h \ - modelPool.I modelPool.h \ - modelRoot.I modelRoot.h \ - nodePath.I nodePath.h nodePath.cxx \ - nodePathCollection.I nodePathCollection.h \ - nodePathComponent.I nodePathComponent.h \ - nodePathLerps.h \ - pandaNode.I pandaNode.h \ - planeNode.I planeNode.h \ - pointLight.I pointLight.h \ - portalNode.I portalNode.h \ - portalClipper.I portalClipper.h \ - renderAttrib.I renderAttrib.h \ - renderEffect.I renderEffect.h \ - renderEffects.I renderEffects.h \ - renderModeAttrib.I renderModeAttrib.h \ - renderState.I renderState.h \ - sceneGraphAnalyzer.h \ - sceneGraphReducer.I sceneGraphReducer.h \ - sceneSetup.I sceneSetup.h \ - selectiveChildNode.I selectiveChildNode.h \ - sequenceNode.I sequenceNode.h \ - showBoundsEffect.I showBoundsEffect.h \ - spotlight.I spotlight.h \ - switchNode.I switchNode.h \ - texMatrixAttrib.I texMatrixAttrib.h \ - textureApplyAttrib.I textureApplyAttrib.h \ - textureAttrib.I textureAttrib.h \ - textureCollection.I textureCollection.h \ - transformState.I transformState.h \ - transparencyAttrib.I transparencyAttrib.h \ - workingNodePath.I workingNodePath.h - - #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx - #define INCLUDED_SOURCES \ - accumulatedAttribs.cxx \ - alphaTestAttrib.cxx \ - ambientLight.cxx \ - bamFile.cxx \ - billboardEffect.cxx \ - binCullHandler.cxx \ - camera.cxx \ - clipPlaneAttrib.cxx \ - colorAttrib.cxx \ - colorBlendAttrib.cxx \ - colorScaleAttrib.cxx \ - colorWriteAttrib.cxx \ - compassEffect.cxx \ - config_pgraph.cxx \ - cullBin.cxx \ - cullBinAttrib.cxx \ - cullBinBackToFront.cxx \ - cullBinFixed.cxx \ - cullBinFrontToBack.cxx \ - cullBinManager.cxx \ - cullBinUnsorted.cxx \ - cullFaceAttrib.cxx \ - cullHandler.cxx \ - cullResult.cxx \ - cullTraverser.cxx \ - cullTraverserData.cxx \ - cullableObject.cxx \ - decalEffect.cxx \ - depthOffsetAttrib.cxx \ - depthTestAttrib.cxx \ - depthWriteAttrib.cxx \ - directionalLight.cxx \ - drawCullHandler.cxx \ - findApproxLevel.cxx \ - findApproxLevelEntry.cxx \ - findApproxPath.cxx \ - fog.cxx \ - fogAttrib.cxx \ - geomNode.cxx \ - geomTransformer.cxx \ - lensNode.cxx \ - light.cxx \ - lightAttrib.cxx \ - lightLensNode.cxx \ - lightNode.cxx \ - loader.cxx \ - loaderFileType.cxx \ - loaderFileTypeBam.cxx \ - loaderFileTypeRegistry.cxx \ - lodNode.cxx \ - materialAttrib.cxx \ - modelNode.cxx \ - modelPool.cxx \ - modelRoot.cxx \ - nodePath.cxx \ - nodePathCollection.cxx \ - nodePathComponent.cxx \ - nodePathLerps.cxx \ - pandaNode.cxx \ - planeNode.cxx \ - pointLight.cxx \ - portalNode.cxx \ - portalClipper.cxx \ - renderAttrib.cxx \ - renderEffect.cxx \ - renderEffects.cxx \ - renderModeAttrib.cxx \ - renderState.cxx \ - sceneGraphAnalyzer.cxx \ - sceneGraphReducer.cxx \ - sceneSetup.cxx \ - selectiveChildNode.cxx \ - sequenceNode.cxx \ - showBoundsEffect.cxx \ - spotlight.cxx \ - switchNode.cxx \ - texMatrixAttrib.cxx \ - textureApplyAttrib.cxx \ - textureAttrib.cxx \ - textureCollection.cxx \ - transformState.cxx \ - transparencyAttrib.cxx \ - workingNodePath.cxx - - #define INSTALL_HEADERS \ - accumulatedAttribs.I accumulatedAttribs.h \ - alphaTestAttrib.I alphaTestAttrib.h \ - ambientLight.I ambientLight.h \ - bamFile.I bamFile.h \ - billboardEffect.I billboardEffect.h \ - binCullHandler.I binCullHandler.h \ - camera.I camera.h \ - clipPlaneAttrib.I clipPlaneAttrib.h \ - colorAttrib.I colorAttrib.h \ - colorBlendAttrib.I colorBlendAttrib.h \ - colorScaleAttrib.I colorScaleAttrib.h \ - colorWriteAttrib.I colorWriteAttrib.h \ - compassEffect.I compassEffect.h \ - config_pgraph.h \ - cullBin.I cullBin.h \ - cullBinAttrib.I cullBinAttrib.h \ - cullBinBackToFront.I cullBinBackToFront.h \ - cullBinFixed.I cullBinFixed.h \ - cullBinFrontToBack.I cullBinFrontToBack.h \ - cullBinManager.I cullBinManager.h \ - cullBinUnsorted.I cullBinUnsorted.h \ - cullFaceAttrib.I cullFaceAttrib.h \ - cullHandler.I cullHandler.h \ - cullResult.I cullResult.h \ - cullTraverser.I cullTraverser.h \ - cullTraverserData.I cullTraverserData.h \ - cullableObject.I cullableObject.h \ - decalEffect.I decalEffect.h \ - depthOffsetAttrib.I depthOffsetAttrib.h \ - depthTestAttrib.I depthTestAttrib.h \ - depthWriteAttrib.I depthWriteAttrib.h \ - directionalLight.I directionalLight.h \ - drawCullHandler.I drawCullHandler.h \ - fog.I fog.h \ - fogAttrib.I fogAttrib.h \ - geomNode.I geomNode.h \ - geomTransformer.I geomTransformer.h \ - lensNode.I lensNode.h \ - light.I light.h \ - lightAttrib.I lightAttrib.h \ - lightLensNode.I lightLensNode.h \ - lightNode.I lightNode.h \ - loader.I loader.h \ - loaderFileType.h \ - loaderFileTypeBam.h \ - loaderFileTypeRegistry.h \ - lodNode.I lodNode.h \ - materialAttrib.I materialAttrib.h \ - modelNode.I modelNode.h \ - modelPool.I modelPool.h \ - modelRoot.I modelRoot.h \ - nodePath.I nodePath.h \ - nodePathCollection.I nodePathCollection.h \ - nodePathComponent.I nodePathComponent.h \ - nodePathLerps.h \ - pandaNode.I pandaNode.h \ - planeNode.I planeNode.h \ - pointLight.I pointLight.h \ - portalNode.I portalNode.h \ - portalClipper.I portalClipper.h \ - renderAttrib.I renderAttrib.h \ - renderEffect.I renderEffect.h \ - renderEffects.I renderEffects.h \ - renderModeAttrib.I renderModeAttrib.h \ - renderState.I renderState.h \ - sceneGraphAnalyzer.h \ - sceneGraphReducer.I sceneGraphReducer.h \ - sceneSetup.I sceneSetup.h \ - selectiveChildNode.I selectiveChildNode.h \ - sequenceNode.I sequenceNode.h \ - showBoundsEffect.I showBoundsEffect.h \ - spotlight.I spotlight.h \ - switchNode.I switchNode.h \ - texMatrixAttrib.I texMatrixAttrib.h \ - textureApplyAttrib.I textureApplyAttrib.h \ - textureAttrib.I textureAttrib.h \ - textureCollection.I textureCollection.h \ - transformState.I transformState.h \ - transparencyAttrib.I transparencyAttrib.h \ - workingNodePath.I workingNodePath.h - -// No need to install these. -// findApproxLevel.I findApproxLevel.h \ -// findApproxLevelEntry.I findApproxLevelEntry.h \ -// findApproxPath.I findApproxPath.h \ - - #define IGATESCAN all - -#end lib_target - - -#begin test_bin_target - #define TARGET test_pgraph - - #define SOURCES \ - test_pgraph.cxx - - #define LOCAL_LIBS $[LOCAL_LIBS] pgraph - #define OTHER_LIBS $[OTHER_LIBS] pystub - -#end test_bin_target +#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ + dtoolutil:c dtoolbase:c dtool:m +#define LOCAL_LIBS \ + lerp event gsgbase gobj putil linmath \ + downloader express pandabase pstatclient + +#begin lib_target + #define TARGET pgraph + + #define SOURCES \ + accumulatedAttribs.I accumulatedAttribs.h \ + alphaTestAttrib.I alphaTestAttrib.h \ + ambientLight.I ambientLight.h \ + bamFile.I bamFile.h \ + billboardEffect.I billboardEffect.h \ + binCullHandler.I binCullHandler.h \ + camera.I camera.h \ + clipPlaneAttrib.I clipPlaneAttrib.h \ + colorAttrib.I colorAttrib.h \ + colorBlendAttrib.I colorBlendAttrib.h \ + colorScaleAttrib.I colorScaleAttrib.h \ + colorWriteAttrib.I colorWriteAttrib.h \ + compassEffect.I compassEffect.h \ + config_pgraph.h \ + cullBin.I cullBin.h \ + cullBinAttrib.I cullBinAttrib.h \ + cullBinBackToFront.I cullBinBackToFront.h \ + cullBinFixed.I cullBinFixed.h \ + cullBinFrontToBack.I cullBinFrontToBack.h \ + cullBinManager.I cullBinManager.h \ + cullBinUnsorted.I cullBinUnsorted.h \ + cullFaceAttrib.I cullFaceAttrib.h \ + cullHandler.I cullHandler.h \ + cullResult.I cullResult.h \ + cullTraverser.I cullTraverser.h \ + cullTraverserData.I cullTraverserData.h \ + cullableObject.I cullableObject.h \ + decalEffect.I decalEffect.h \ + depthOffsetAttrib.I depthOffsetAttrib.h \ + depthTestAttrib.I depthTestAttrib.h \ + depthWriteAttrib.I depthWriteAttrib.h \ + directionalLight.I directionalLight.h \ + drawCullHandler.I drawCullHandler.h \ + findApproxLevel.I findApproxLevel.h \ + findApproxLevelEntry.I findApproxLevelEntry.h \ + findApproxPath.I findApproxPath.h \ + fog.I fog.h \ + fogAttrib.I fogAttrib.h \ + geomNode.I geomNode.h \ + geomTransformer.I geomTransformer.h \ + lensNode.I lensNode.h \ + light.I light.h \ + lightAttrib.I lightAttrib.h \ + lightLensNode.I lightLensNode.h \ + lightNode.I lightNode.h \ + loader.I loader.h \ + loaderFileType.h \ + loaderFileTypeBam.h \ + loaderFileTypeRegistry.h \ + lodNode.I lodNode.h \ + materialAttrib.I materialAttrib.h \ + modelNode.I modelNode.h \ + modelPool.I modelPool.h \ + modelRoot.I modelRoot.h \ + nodePath.I nodePath.h nodePath.cxx \ + nodePathCollection.I nodePathCollection.h \ + nodePathComponent.I nodePathComponent.h \ + nodePathLerps.h \ + pandaNode.I pandaNode.h \ + planeNode.I planeNode.h \ + pointLight.I pointLight.h \ + polylightNode.I polylightNode.h \ + polylightEffect.I polylightEffect.h \ + portalNode.I portalNode.h \ + portalClipper.I portalClipper.h \ + renderAttrib.I renderAttrib.h \ + renderEffect.I renderEffect.h \ + renderEffects.I renderEffects.h \ + renderModeAttrib.I renderModeAttrib.h \ + renderState.I renderState.h \ + sceneGraphAnalyzer.h \ + sceneGraphReducer.I sceneGraphReducer.h \ + sceneSetup.I sceneSetup.h \ + selectiveChildNode.I selectiveChildNode.h \ + sequenceNode.I sequenceNode.h \ + showBoundsEffect.I showBoundsEffect.h \ + spotlight.I spotlight.h \ + switchNode.I switchNode.h \ + texMatrixAttrib.I texMatrixAttrib.h \ + textureApplyAttrib.I textureApplyAttrib.h \ + textureAttrib.I textureAttrib.h \ + textureCollection.I textureCollection.h \ + transformState.I transformState.h \ + transparencyAttrib.I transparencyAttrib.h \ + workingNodePath.I workingNodePath.h + + #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx + #define INCLUDED_SOURCES \ + accumulatedAttribs.cxx \ + alphaTestAttrib.cxx \ + ambientLight.cxx \ + bamFile.cxx \ + billboardEffect.cxx \ + binCullHandler.cxx \ + camera.cxx \ + clipPlaneAttrib.cxx \ + colorAttrib.cxx \ + colorBlendAttrib.cxx \ + colorScaleAttrib.cxx \ + colorWriteAttrib.cxx \ + compassEffect.cxx \ + config_pgraph.cxx \ + cullBin.cxx \ + cullBinAttrib.cxx \ + cullBinBackToFront.cxx \ + cullBinFixed.cxx \ + cullBinFrontToBack.cxx \ + cullBinManager.cxx \ + cullBinUnsorted.cxx \ + cullFaceAttrib.cxx \ + cullHandler.cxx \ + cullResult.cxx \ + cullTraverser.cxx \ + cullTraverserData.cxx \ + cullableObject.cxx \ + decalEffect.cxx \ + depthOffsetAttrib.cxx \ + depthTestAttrib.cxx \ + depthWriteAttrib.cxx \ + directionalLight.cxx \ + drawCullHandler.cxx \ + findApproxLevel.cxx \ + findApproxLevelEntry.cxx \ + findApproxPath.cxx \ + fog.cxx \ + fogAttrib.cxx \ + geomNode.cxx \ + geomTransformer.cxx \ + lensNode.cxx \ + light.cxx \ + lightAttrib.cxx \ + lightLensNode.cxx \ + lightNode.cxx \ + loader.cxx \ + loaderFileType.cxx \ + loaderFileTypeBam.cxx \ + loaderFileTypeRegistry.cxx \ + lodNode.cxx \ + materialAttrib.cxx \ + modelNode.cxx \ + modelPool.cxx \ + modelRoot.cxx \ + nodePath.cxx \ + nodePathCollection.cxx \ + nodePathComponent.cxx \ + nodePathLerps.cxx \ + pandaNode.cxx \ + planeNode.cxx \ + pointLight.cxx \ + polylightNode.cxx \ + polylightEffect.cxx \ + portalNode.cxx \ + portalClipper.cxx \ + renderAttrib.cxx \ + renderEffect.cxx \ + renderEffects.cxx \ + renderModeAttrib.cxx \ + renderState.cxx \ + sceneGraphAnalyzer.cxx \ + sceneGraphReducer.cxx \ + sceneSetup.cxx \ + selectiveChildNode.cxx \ + sequenceNode.cxx \ + showBoundsEffect.cxx \ + spotlight.cxx \ + switchNode.cxx \ + texMatrixAttrib.cxx \ + textureApplyAttrib.cxx \ + textureAttrib.cxx \ + textureCollection.cxx \ + transformState.cxx \ + transparencyAttrib.cxx \ + workingNodePath.cxx + + #define INSTALL_HEADERS \ + accumulatedAttribs.I accumulatedAttribs.h \ + alphaTestAttrib.I alphaTestAttrib.h \ + ambientLight.I ambientLight.h \ + bamFile.I bamFile.h \ + billboardEffect.I billboardEffect.h \ + binCullHandler.I binCullHandler.h \ + camera.I camera.h \ + clipPlaneAttrib.I clipPlaneAttrib.h \ + colorAttrib.I colorAttrib.h \ + colorBlendAttrib.I colorBlendAttrib.h \ + colorScaleAttrib.I colorScaleAttrib.h \ + colorWriteAttrib.I colorWriteAttrib.h \ + compassEffect.I compassEffect.h \ + config_pgraph.h \ + cullBin.I cullBin.h \ + cullBinAttrib.I cullBinAttrib.h \ + cullBinBackToFront.I cullBinBackToFront.h \ + cullBinFixed.I cullBinFixed.h \ + cullBinFrontToBack.I cullBinFrontToBack.h \ + cullBinManager.I cullBinManager.h \ + cullBinUnsorted.I cullBinUnsorted.h \ + cullFaceAttrib.I cullFaceAttrib.h \ + cullHandler.I cullHandler.h \ + cullResult.I cullResult.h \ + cullTraverser.I cullTraverser.h \ + cullTraverserData.I cullTraverserData.h \ + cullableObject.I cullableObject.h \ + decalEffect.I decalEffect.h \ + depthOffsetAttrib.I depthOffsetAttrib.h \ + depthTestAttrib.I depthTestAttrib.h \ + depthWriteAttrib.I depthWriteAttrib.h \ + directionalLight.I directionalLight.h \ + drawCullHandler.I drawCullHandler.h \ + fog.I fog.h \ + fogAttrib.I fogAttrib.h \ + geomNode.I geomNode.h \ + geomTransformer.I geomTransformer.h \ + lensNode.I lensNode.h \ + light.I light.h \ + lightAttrib.I lightAttrib.h \ + lightLensNode.I lightLensNode.h \ + lightNode.I lightNode.h \ + loader.I loader.h \ + loaderFileType.h \ + loaderFileTypeBam.h \ + loaderFileTypeRegistry.h \ + lodNode.I lodNode.h \ + materialAttrib.I materialAttrib.h \ + modelNode.I modelNode.h \ + modelPool.I modelPool.h \ + modelRoot.I modelRoot.h \ + nodePath.I nodePath.h \ + nodePathCollection.I nodePathCollection.h \ + nodePathComponent.I nodePathComponent.h \ + nodePathLerps.h \ + pandaNode.I pandaNode.h \ + planeNode.I planeNode.h \ + pointLight.I pointLight.h \ + polylightNode.I polylightNode.h \ + polylightEffect.I polylightEffect.h \ + portalNode.I portalNode.h \ + portalClipper.I portalClipper.h \ + renderAttrib.I renderAttrib.h \ + renderEffect.I renderEffect.h \ + renderEffects.I renderEffects.h \ + renderModeAttrib.I renderModeAttrib.h \ + renderState.I renderState.h \ + sceneGraphAnalyzer.h \ + sceneGraphReducer.I sceneGraphReducer.h \ + sceneSetup.I sceneSetup.h \ + selectiveChildNode.I selectiveChildNode.h \ + sequenceNode.I sequenceNode.h \ + showBoundsEffect.I showBoundsEffect.h \ + spotlight.I spotlight.h \ + switchNode.I switchNode.h \ + texMatrixAttrib.I texMatrixAttrib.h \ + textureApplyAttrib.I textureApplyAttrib.h \ + textureAttrib.I textureAttrib.h \ + textureCollection.I textureCollection.h \ + transformState.I transformState.h \ + transparencyAttrib.I transparencyAttrib.h \ + workingNodePath.I workingNodePath.h + +// No need to install these. +// findApproxLevel.I findApproxLevel.h \ +// findApproxLevelEntry.I findApproxLevelEntry.h \ +// findApproxPath.I findApproxPath.h \ + + #define IGATESCAN all + +#end lib_target + + +#begin test_bin_target + #define TARGET test_pgraph + + #define SOURCES \ + test_pgraph.cxx + + #define LOCAL_LIBS $[LOCAL_LIBS] pgraph + #define OTHER_LIBS $[OTHER_LIBS] pystub + +#end test_bin_target diff --git a/panda/src/pgraph/config_pgraph.cxx b/panda/src/pgraph/config_pgraph.cxx index b985604fab..cddab63124 100644 --- a/panda/src/pgraph/config_pgraph.cxx +++ b/panda/src/pgraph/config_pgraph.cxx @@ -62,6 +62,8 @@ #include "pandaNode.h" #include "planeNode.h" #include "pointLight.h" +#include "polylightNode.h" +#include "polylightEffect.h" #include "portalNode.h" #include "portalClipper.h" #include "renderAttrib.h" @@ -203,12 +205,15 @@ init_libpgraph() { LoaderFileTypeBam::init_type(); MaterialAttrib::init_type(); ModelNode::init_type(); + ModelRoot::init_type(); NodePath::init_type(); NodePathComponent::init_type(); PandaNode::init_type(); PlaneNode::init_type(); PointLight::init_type(); + PolylightNode::init_type(); + PolylightEffect::init_type(); PortalNode::init_type(); PortalClipper::init_type(); RenderAttrib::init_type(); diff --git a/panda/src/pgraph/cullTraverserData.cxx b/panda/src/pgraph/cullTraverserData.cxx index 6ae3029aab..3f76fe00a5 100644 --- a/panda/src/pgraph/cullTraverserData.cxx +++ b/panda/src/pgraph/cullTraverserData.cxx @@ -18,14 +18,15 @@ #include "cullTraverserData.h" #include "cullTraverser.h" +#include "config_pgraph.h" #include "pandaNode.h" #include "colorAttrib.h" -#include "config_pgraph.h" #include "textureAttrib.h" #include "renderModeAttrib.h" #include "billboardEffect.h" #include "compassEffect.h" - +#include "polylightEffect.h" +#include "renderState.h" //////////////////////////////////////////////////////////////////// // Function: CullTraverserData::apply_specific_transform // Access: Public @@ -42,22 +43,35 @@ apply_transform_and_state(CullTraverser *trav, // compass and billboard effects. _net_transform = _net_transform->compose(node_transform); - const CompassEffect *compass = node_effects->get_compass(); - if (compass != (const CompassEffect *)NULL) { - CPT(TransformState) compass_transform = - compass->do_compass(_net_transform, node_transform); - _net_transform = _net_transform->compose(compass_transform); - node_transform = node_transform->compose(compass_transform); + if (!node_effects->is_empty()) { + const CompassEffect *compass = node_effects->get_compass(); + if (compass != (const CompassEffect *)NULL) { + CPT(TransformState) compass_transform = + compass->do_compass(_net_transform, node_transform); + _net_transform = _net_transform->compose(compass_transform); + node_transform = node_transform->compose(compass_transform); + } + + const BillboardEffect *billboard = node_effects->get_billboard(); + if (billboard != (const BillboardEffect *)NULL) { + CPT(TransformState) billboard_transform = + billboard->do_billboard(_net_transform, trav->get_camera_transform()); + _net_transform = _net_transform->compose(billboard_transform); + node_transform = node_transform->compose(billboard_transform); + } + + + const PolylightEffect *poly_light = node_effects->get_polylight(); + if(poly_light != (const PolylightEffect *) NULL) { + if(poly_light->is_enabled()) { + CPT(RenderAttrib) poly_light_attrib = poly_light->do_poly_light( this , node_transform); + CPT(RenderState) poly_light_state=RenderState::make(poly_light_attrib); + node_state=node_state->compose(poly_light_state); + } + } + } - const BillboardEffect *billboard = node_effects->get_billboard(); - if (billboard != (const BillboardEffect *)NULL) { - CPT(TransformState) billboard_transform = - billboard->do_billboard(_net_transform, trav->get_camera_transform()); - _net_transform = _net_transform->compose(billboard_transform); - node_transform = node_transform->compose(billboard_transform); - } - if (!node_transform->is_identity()) { _render_transform = _render_transform->compose(node_transform); diff --git a/panda/src/pgraph/pgraph_composite2.cxx b/panda/src/pgraph/pgraph_composite2.cxx index 4d5169e189..4557dc0214 100644 --- a/panda/src/pgraph/pgraph_composite2.cxx +++ b/panda/src/pgraph/pgraph_composite2.cxx @@ -18,6 +18,8 @@ #include "pandaNode.cxx" #include "planeNode.cxx" #include "pointLight.cxx" +#include "polylightNode.cxx" +#include "polylightEffect.cxx" #include "portalNode.cxx" #include "portalClipper.cxx" #include "renderAttrib.cxx" diff --git a/panda/src/pgraph/renderEffects.I b/panda/src/pgraph/renderEffects.I index 70d2dff0cb..928d581254 100644 --- a/panda/src/pgraph/renderEffects.I +++ b/panda/src/pgraph/renderEffects.I @@ -200,6 +200,25 @@ get_compass() const { return _compass; } +//////////////////////////////////////////////////////////////////// +// Function: RenderEffects::get_polylight +// Access: Public +// Description: This function is provided as an optimization, to +// speed up the render-time checking for the existance +// of a PolylightEffect on this state. It returns a +// pointer to the PolylightEffect, if there is one, or +// NULL if there is not. +//////////////////////////////////////////////////////////////////// +INLINE const PolylightEffect *RenderEffects:: +get_polylight() const { + if ((_flags & F_checked_polylight) == 0) { + // We pretend this function is const, even though it transparently + // modifies the internal polylight cache. + ((RenderEffects *)this)->determine_polylight(); + } + return _polylight; +} + //////////////////////////////////////////////////////////////////// // Function: RenderEffects::has_show_bounds // Access: Public diff --git a/panda/src/pgraph/renderEffects.cxx b/panda/src/pgraph/renderEffects.cxx index 9b0b99e65f..1777bdf186 100644 --- a/panda/src/pgraph/renderEffects.cxx +++ b/panda/src/pgraph/renderEffects.cxx @@ -20,6 +20,7 @@ #include "billboardEffect.h" #include "decalEffect.h" #include "compassEffect.h" +#include "polylightEffect.h" #include "showBoundsEffect.h" #include "config_pgraph.h" #include "bamReader.h" @@ -476,6 +477,23 @@ determine_compass() { _flags |= F_checked_compass; } + +//////////////////////////////////////////////////////////////////// +// Function: RenderEffects::determine_polylight +// Access: Private +// Description: This is the private implementation of has_polylight(). +//////////////////////////////////////////////////////////////////// +void RenderEffects:: +determine_polylight() { + const RenderEffect *effect = get_effect(PolylightEffect::get_class_type()); + _polylight = (const PolylightEffect *)NULL; + if (effect != (const RenderEffect *)NULL) { + _polylight = DCAST(PolylightEffect, effect); + } + _flags |= F_checked_polylight; +} + + //////////////////////////////////////////////////////////////////// // Function: RenderEffects::determine_show_bounds // Access: Private diff --git a/panda/src/pgraph/renderEffects.h b/panda/src/pgraph/renderEffects.h index 89f53ba548..d060f28102 100644 --- a/panda/src/pgraph/renderEffects.h +++ b/panda/src/pgraph/renderEffects.h @@ -29,6 +29,7 @@ class BillboardEffect; class CompassEffect; +class PolylightEffect; class FactoryParams; //////////////////////////////////////////////////////////////////// @@ -91,6 +92,7 @@ public: INLINE const BillboardEffect *get_billboard() const; INLINE bool has_decal() const; INLINE const CompassEffect *get_compass() const; + INLINE const PolylightEffect *get_polylight() const; INLINE bool has_show_bounds() const; private: @@ -98,6 +100,7 @@ private: void determine_billboard(); void determine_decal(); void determine_compass(); + void determine_polylight(); void determine_show_bounds(); private: @@ -133,6 +136,7 @@ private: // state, if they exist. const BillboardEffect *_billboard; const CompassEffect *_compass; + const PolylightEffect *_polylight; enum Flags { F_checked_billboard = 0x0001, @@ -141,9 +145,11 @@ private: F_checked_show_bounds = 0x0008, F_has_show_bounds = 0x0010, F_checked_compass = 0x0020, + F_checked_polylight = 0x0040, }; short _flags; + public: static void register_with_read_factory(); virtual void write_datagram(BamWriter *manager, Datagram &dg); diff --git a/panda/src/testbed/Sources.pp b/panda/src/testbed/Sources.pp index 997c259763..9394f39a8a 100644 --- a/panda/src/testbed/Sources.pp +++ b/panda/src/testbed/Sources.pp @@ -1,38 +1,38 @@ -#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ - dtoolutil:c dtoolbase:c dtool:m pystub - -#define LOCAL_LIBS \ - framework putil collide pgraph chan text \ - pnmimage pnmimagetypes event effects gobj display \ - mathutil putil express dgraph device tform \ - linmath pstatclient panda - -#if $[LINK_ALL_STATIC] - // If we're statically linking, we need to explicitly link with - // at least one graphics renderer. - #define LOCAL_LIBS pandagl pandadx $[LOCAL_LIBS] - - // And we might like to have the egg loader available. - #define LOCAL_LIBS pandaegg $[LOCAL_LIBS] -#endif - - -#begin bin_target - #define TARGET pview - - #define SOURCES \ - pview.cxx -#end bin_target - -#begin test_bin_target - #define TARGET pgrid - - #define SOURCES \ - pgrid.cxx - #define UNIX_SYS_LIBS m -#end test_bin_target - -#begin test_bin_target - #define TARGET test_texmem - #define SOURCES test_texmem.cxx -#end test_bin_target +#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ + dtoolutil:c dtoolbase:c dtool:m pystub + +#define LOCAL_LIBS \ + framework putil collide pgraph chan text \ + pnmimage pnmimagetypes event effects gobj display \ + mathutil putil express dgraph device tform \ + linmath pstatclient panda + +#if $[LINK_ALL_STATIC] + // If we're statically linking, we need to explicitly link with + // at least one graphics renderer. + #define LOCAL_LIBS pandagl pandadx $[LOCAL_LIBS] + + // And we might like to have the egg loader available. + #define LOCAL_LIBS pandaegg $[LOCAL_LIBS] +#endif + + +#begin bin_target + #define TARGET pview + + #define SOURCES \ + pview.cxx +#end bin_target + +#begin test_bin_target + #define TARGET pgrid + + #define SOURCES \ + pgrid.cxx + #define UNIX_SYS_LIBS m +#end test_bin_target + +#begin test_bin_target + #define TARGET test_texmem + #define SOURCES test_texmem.cxx +#end test_bin_target