From 3001809bc3fd679268426e02945195fb9addab8f Mon Sep 17 00:00:00 2001 From: Christian Schmitt Date: Tue, 28 Aug 2012 12:59:33 +0200 Subject: [PATCH] Remove unused source files --- simgear/scene/model/shadowvolume.cxx | 998 --------------------------- simgear/scene/model/shadowvolume.hxx | 146 ---- 2 files changed, 1144 deletions(-) delete mode 100644 simgear/scene/model/shadowvolume.cxx delete mode 100644 simgear/scene/model/shadowvolume.hxx diff --git a/simgear/scene/model/shadowvolume.cxx b/simgear/scene/model/shadowvolume.cxx deleted file mode 100644 index 88c652d5..00000000 --- a/simgear/scene/model/shadowvolume.cxx +++ /dev/null @@ -1,998 +0,0 @@ -// Shadow volume class -// -// Written by Harald JOHNSEN, started June 2005. -// -// Copyright (C) 2005 Harald JOHNSEN - hjohnsen@evc.net -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include "shadowvolume.hxx" - -/* - geometry and edge list - - traverse object graph until leaf to get geometry - - what about transform and selection ? - - use sub objects rather then objects - - get local transform and selection - - range anim : ssgRangeSelector ( min, max ) => ssgSelector ( true/false ) - => selection [0..n], kids [0..n] - - select/timed anim : ssgSelector ( true/false ) - => isSelected( nkid ) - - spin/rotate/trans/scale/... : ssgTransform ( matrix ) - => getNetTransform - - on new object : - - for one object branch - - for each leaf - - save geometry - - save address in cache - - when rendering object - - for each leaf - - getNetTransform + object global rotation (ac) => transform for light position - - go up in tree and check isSelected( self ) - - generate connectivity each time the geometry change - => using local light so connectivity never changes - - generate active edge list when : - - light moves - - subpart moves (animation code) - - ac rotate - => cache rotation matrix and generate edge list only if something change - => even if it changes, no need to do that every frame - - - static objects have static edge list if light does not move - - shadowing a scene - - render full scene as normal - - render occluder in stencil buffer with their shadow volumes - - apply stencil to framebuffer (darkens shadowed parts) - - shadows using the alpha buffer - http://wwwvis.informatik.uni-stuttgart.de/~roettger/html/Pages/shadows.html -*/ - -// TODO -// - shadow for objects -// * aircraft -// * tile objects (from .stg) -// - ai objects -// - random objects => tie shadow geometry to lib objects and reuse them -// - zfail if camera inside shadow -// - queue geometry work if lot of objects -// * add a render property on/off (for aircraft, for scene objects, for ai) -// * add a render property in rendering dialog -// * filter : halo, light, shadow, disc, disk, flame, (exhaust), noshadow - -static int statSilhouette=0; -static int statGeom=0; -static int statObj=0; - -static SGShadowVolume *states; -static glBlendEquationProc glBlendEquationPtr = NULL; -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 - - -SGShadowVolume::ShadowCaster::ShadowCaster( int _num_tri, ssgBranch * _geometry_leaf ) : - geometry_leaf ( _geometry_leaf ), - scenery_object ( 0 ), - first_select ( 0 ), - frameNumber ( 0 ), - indices ( 0 ), - numTriangles ( 0 ), - vertices ( 0 ), - lastSilhouetteIndicesCount ( 0 ) -{ - int num_tri = _num_tri; - numTriangles = num_tri; - triangles = new triData[ num_tri ]; - indices = new int[1 + num_tri * 3]; - vertices = new sgVec4[1 + num_tri * 3]; - silhouetteEdgeIndices = new GLushort[(1+num_tri) * 3*3]; - indices [ num_tri * 3 ] = num_tri * 3; - sgSetVec3(last_lightpos, 0.0, 0.0, 0.0); - statGeom ++; - - ssgBranch *branch = (ssgBranch *) _geometry_leaf; - while( branch && branch->getNumParents() > 0 ) { - if( branch->isAKindOf(ssgTypeSelector())) { - first_select = branch; - break; - } - if( sgCheckAnimationBranch( (ssgEntity *) branch ) ) - if( ((SGAnimation *) branch->getUserData())->get_animation_type() == 1) { - first_select = branch; - break; - } - branch = branch->getParent(0); - } -} - -void SGShadowVolume::ShadowCaster::addLeaf( int & tri_idx, int & ind_idx, ssgLeaf *geometry_leaf ) { - int num_tri = geometry_leaf->getNumTriangles(); - for(int i = 0; i < num_tri ; i ++ ) { - short v1, v2, v3; - sgVec3 a, b, c; - geometry_leaf->getTriangle( i, &v1, &v2, &v3 ); - sgCopyVec3(a, geometry_leaf->getVertex(v1)); - sgCopyVec3(b, geometry_leaf->getVertex(v2)); - sgCopyVec3(c, geometry_leaf->getVertex(v3)); - - int p = tri_idx; - sgMakePlane ( triangles[p].planeEquations, a, b, c ); - sgCopyVec3(vertices[ind_idx + v1], a); - sgCopyVec3(vertices[ind_idx + v2], b); - sgCopyVec3(vertices[ind_idx + v3], c); - vertices[ind_idx + v1][SG_W] = 1.0f; - vertices[ind_idx + v2][SG_W] = 1.0f; - vertices[ind_idx + v3][SG_W] = 1.0f; - indices[p*3] = ind_idx + v1; - indices[p*3+1] = ind_idx + v2; - indices[p*3+2] = ind_idx + v3; - - tri_idx++; - } - if( num_tri == 0 ) - return; - isTranslucent |= geometry_leaf->isTranslucent() ? true : false; - int num_ind = geometry_leaf->getNumVertices(); - ind_idx += num_ind; -} - -SGShadowVolume::ShadowCaster::~ShadowCaster() { - delete [] indices ; - delete [] vertices ; - delete [] triangles; - delete [] silhouetteEdgeIndices; -} - - - -bool SGShadowVolume::ShadowCaster::sameVertex(int edge1, int edge2) { - if( edge1 == edge2) - return true; - sgVec3 delta_v; - sgSubVec3( delta_v, vertices[edge1], vertices[edge2]); - if( delta_v[SG_X] != 0.0) return false; - if( delta_v[SG_Y] != 0.0) return false; - if( delta_v[SG_Z] != 0.0) return false; - return true; -} - - -//Calculate neighbour faces for each edge -// caution, this is O(n2) -void SGShadowVolume::ShadowCaster::SetConnectivity(void) -{ - int edgeCount = 0; - - //set the neighbour indices to be -1 - for(int ii=0; ii 0.0 ) - triangles[i].isFacingLight=true; - else - triangles[i].isFacingLight=false; - } - - //loop through faces - int iEdgeIndices = 0; - sgVec4 farCap = {-lightPosition[SG_X], -lightPosition[SG_Y], -lightPosition[SG_Z], 1.0f}; - sgCopyVec4( vertices[ numTriangles*3 ], farCap ); - - for(int t=0; t < numTriangles; t++) { - int v = t * 3; - //if this face is not facing the light, not a silhouette edge - if(!triangles[t].isFacingLight) - { - triangles[t].isSilhouetteEdge[0]=false; - triangles[t].isSilhouetteEdge[1]=false; - triangles[t].isSilhouetteEdge[2]=false; - continue; - } - //loop through edges - for(int j = 0 ; j < 3 ; j++) { - //this face is facing the light - //if the neighbouring face is not facing the light, or there is no neighbouring face, - //then this is a silhouette edge - if(triangles[t].neighbourIndices[j]==-1 || - !triangles[triangles[t].neighbourIndices[j]].isFacingLight ) { - triangles[t].isSilhouetteEdge[j]=true; - silhouetteEdgeIndices[ iEdgeIndices++ ] = indices[v+(j == 2 ? 0 : j+1)]; - silhouetteEdgeIndices[ iEdgeIndices++ ] = indices[v+j]; - silhouetteEdgeIndices[ iEdgeIndices++ ] = numTriangles * 3; - } - else - triangles[t].isSilhouetteEdge[j]=false; - } - } - lastSilhouetteIndicesCount = iEdgeIndices; -} - -void SGShadowVolume::ShadowCaster::DrawInfiniteShadowVolume(sgVec3 lightPosition, bool drawCaps) -{ - glEnableClientState ( GL_VERTEX_ARRAY ) ; - glVertexPointer ( 4, GL_FLOAT, 0, vertices ) ; - glDrawElements ( GL_TRIANGLES, lastSilhouetteIndicesCount, GL_UNSIGNED_SHORT, silhouetteEdgeIndices ) ; - - //Draw caps if required - if(drawCaps) - { - glBegin(GL_TRIANGLES); - { - for(int i=0; iisA(ssgTypeTransform()) ) { - sgMat4 transform; - if( first ) { - ((ssgTransform *) branch)->getTransform( xform ); - first = false; - } else { - ((ssgTransform *) branch)->getTransform(transform); - sgPostMultMat4 ( xform, transform ) ; - } - } - branch = branch->getParent( 0 ); - } - if( first ) - sgMakeIdentMat4 ( xform ) ; -} - -// check the value of