- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgVolume/FixedFunctionTechnique.cpp
r12597 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 47 47 { 48 48 if (_numSlices==numSlices) return; 49 49 50 50 _numSlices = numSlices; 51 51 52 52 if (_volumeTile) _volumeTile->setDirty(true); 53 53 } 54 54 55 55 osg::Node* createCube(const osg::Vec3& center, float size, unsigned int numSlices) 56 56 { … … 75 75 (*coords)[i*4+3].set(halfSize,y,halfSize); 76 76 } 77 77 78 78 osg::Vec3Array* normals = new osg::Vec3Array(1); 79 79 (*normals)[0].set(0.0f,-1.0f,0.0f); … … 92 92 billboard->addDrawable(geom); 93 93 billboard->setPosition(0,center); 94 94 95 95 return billboard; 96 96 } … … 120 120 121 121 float alphaFuncValue = 0.1; 122 122 123 123 osg::Image* image_3d = 0; 124 124 osgVolume::Locator* masterLocator = _volumeTile->getLocator(); 125 osg::Texture::InternalFormatMode internalFormatMode = osg::Texture::USE_IMAGE_DATA_FORMAT; 125 osg::Texture::InternalFormatMode internalFormatMode = osg::Texture::USE_IMAGE_DATA_FORMAT; 126 126 127 127 image_3d = _volumeTile->getLayer()->getImage(); 128 128 129 129 CollectPropertiesVisitor cpv; 130 130 if (_volumeTile->getLayer()->getProperty()) … … 155 155 matrix = masterLocator->getTransform(); 156 156 } 157 157 158 158 OSG_NOTICE<<"Matrix = "<<matrix<<std::endl; 159 159 … … 165 165 osg::Vec3d v010 = osg::Vec3d(0.0,1.0,0.0) * matrix; 166 166 osg::Vec3d v110 = osg::Vec3d(1.0,1.0,0.0) * matrix; 167 167 168 168 osg::Vec3d v001 = osg::Vec3d(0.0,0.0,1.0) * matrix; 169 169 osg::Vec3d v101 = osg::Vec3d(1.0,0.0,1.0) * matrix; 170 170 osg::Vec3d v011 = osg::Vec3d(0.0,1.0,1.0) * matrix; 171 171 osg::Vec3d v111 = osg::Vec3d(1.0,1.0,1.0) * matrix; 172 172 173 173 double cubeSize = (v111-v000).length(); 174 174 osg::Vec3d center = (v000+v111)*0.5; … … 186 186 osg::TexGenNode* texgenNode_0 = new osg::TexGenNode; 187 187 texgenNode_0->addChild(clipnode); 188 texgenNode_0->setTextureUnit(0); 189 texgenNode_0->getTexGen()->setMode(osg::TexGen::EYE_LINEAR); 190 texgenNode_0->getTexGen()->setPlanesFromMatrix(osg::Matrix::inverse(matrix)); 188 texgenNode_0->setTextureUnit(0); 189 texgenNode_0->getTexGen()->setMode(osg::TexGen::EYE_LINEAR); 190 texgenNode_0->getTexGen()->setPlanesFromMatrix(osg::Matrix::inverse(matrix)); 191 191 192 192 osg::StateSet* stateset = texgenNode_0->getOrCreateStateSet(); … … 194 194 stateset->setMode(GL_LIGHTING,osg::StateAttribute::ON); 195 195 stateset->setMode(GL_BLEND,osg::StateAttribute::ON); 196 196 197 197 if (cpv._afProperty.valid()) 198 198 { … … 203 203 stateset->setAttributeAndModes(new osg::AlphaFunc(osg::AlphaFunc::GREATER,alphaFuncValue), osg::StateAttribute::ON); 204 204 } 205 205 206 206 osg::Material* material = new osg::Material; 207 207 material->setDiffuse(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0f,1.0f,1.0f,1.0f)); 208 208 stateset->setAttributeAndModes(material); 209 209 210 210 if (cpv._mipProperty.valid()) 211 211 { … … 226 226 texture3D->setWrap(osg::Texture3D::WRAP_S,osg::Texture3D::CLAMP_TO_EDGE); 227 227 texture3D->setWrap(osg::Texture3D::WRAP_T,osg::Texture3D::CLAMP_TO_EDGE); 228 if (image_3d->getPixelFormat()==GL_ALPHA || 228 if (image_3d->getPixelFormat()==GL_ALPHA || 229 229 image_3d->getPixelFormat()==GL_LUMINANCE) 230 230 { … … 246 246 247 247 stateset->setTextureAttributeAndModes(0,new osg::TexEnv(),osg::StateAttribute::ON); 248 248 249 249 _node = texgenNode_0; 250 250 } … … 257 257 void FixedFunctionTechnique::cull(osgUtil::CullVisitor* cv) 258 258 { 259 //OSG_NOTICE<<"FixedFunctionTechnique::cull(osgUtil::CullVisitor* nv)"<<std::endl; 259 //OSG_NOTICE<<"FixedFunctionTechnique::cull(osgUtil::CullVisitor* nv)"<<std::endl; 260 260 if (_node.valid()) 261 261 { … … 284 284 update(uv); 285 285 return; 286 } 287 286 } 287 288 288 } 289 289 else if (nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR) … … 298 298 299 299 300 if (_volumeTile->getDirty()) 300 if (_volumeTile->getDirty()) 301 301 { 302 302 OSG_INFO<<"******* Doing init ***********"<<std::endl; … … 304 304 } 305 305 } 306 306
