Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGVRMLFile.cpp File Reference

#include <stdlib.h>
#include <stdio.h>
#include "OSGConfig.h"
#include <iostream>
#include "OSGVRMLFile.h"
#include <OSGFieldType.h>
#include <OSGSFSysTypes.h>
#include <OSGMFSysTypes.h>
#include <OSGSFBaseTypes.h>
#include <OSGMFBaseTypes.h>
#include <OSGSFMathTypes.h>
#include <OSGMFMathTypes.h>
#include <OSGSFVecTypes.h>
#include <OSGMFVecTypes.h>
#include <OSGMFFieldContainerTypes.h>
#include <OSGSFFieldContainerTypes.h>
#include <OSGImageFields.h>
#include <OSGGeoProperty.h>
#include <OSGTime.h>
#include <OSGSimpleAttachments.h>
#include <OSGChunkMaterial.h>
#include <OSGMaterialChunk.h>
#include <OSGMaterialGroup.h>
#include <OSGTextureChunk.h>
#include <OSGImage.h>

Go to the source code of this file.

Namespaces

namespace  osg

Defines

#define OSG_COMPILEVRMLLOADERINST

Functions

static Action::ResultE modifyMaterial (NodePtr &node)

Variables

osg::Time startTime = 0.
osg::Time useTime = 0.
osg::Time findTime = 0.
static Char8 cvsid_cpp [] = "@(#)$Id: $"
static Char8 cvsid_hpp [] = OSGVRMLFILE_HEADER_CVSID


Define Documentation

#define OSG_COMPILEVRMLLOADERINST
 

Definition at line 39 of file OSGVRMLFile.cpp.


Function Documentation

static Action::ResultE modifyMaterial NodePtr node  )  [static]
 

Definition at line 2683 of file OSGVRMLFile.cpp.

References osg::beginEditCP(), osg::ChunkMaterialBase::ChunksFieldMask, osg::Action::Continue, osg::AttachmentPtr::dcast(), osg::AttachmentContainerPtr::dcast(), osg::BlendChunkBase::DestFactorFieldMask, osg::MaterialChunkBase::DiffuseFieldMask, osg::endEditCP(), osg::TextureChunkBase::EnvModeFieldMask, osg::BlendChunkBase::getClassType(), osg::MaterialChunkBase::getClassType(), osg::TextureChunkBase::getClassType(), osg::NodePtr::getCore(), osg::NullFC, and osg::BlendChunkBase::SrcFactorFieldMask.

Referenced by osg::VRMLFile::getRoot().

02684 {   
02685     MaterialGroupPtr mg = MaterialGroupPtr::dcast(node->getCore());
02686     
02687     if(mg == NullFC)
02688         return Action::Continue; 
02689     
02690     ChunkMaterialPtr cmat = ChunkMaterialPtr::dcast(mg->getMaterial());
02691     
02692     if(cmat == NullFC)
02693         return Action::Continue; 
02694     
02695     TextureChunkPtr texc = TextureChunkPtr::dcast(cmat->find(TextureChunk::getClassType()));
02696     
02697     if(texc == NullFC)
02698         return Action::Continue;
02699     
02700     MaterialChunkPtr matc = MaterialChunkPtr::dcast(cmat->find(MaterialChunk::getClassType()));
02701     
02702     if(matc == NullFC)
02703     {
02704         // no material chunk so we use the replace mode.
02705         beginEditCP(texc, TextureChunk::EnvModeFieldMask);
02706             texc->setEnvMode(GL_REPLACE);
02707         endEditCP(texc, TextureChunk::EnvModeFieldMask);
02708         return Action::Continue;
02709     }
02710     
02711     if(matc != NullFC)
02712     {
02713         ImagePtr img = texc->getImage();
02714         
02715         beginEditCP(texc, TextureChunk::EnvModeFieldMask);
02716             texc->setEnvMode(GL_MODULATE);
02717         endEditCP(texc, TextureChunk::EnvModeFieldMask);
02718         if(img != NullFC && img->getBpp() > 2)
02719         {
02720             // for color textures the texture replaces only the diffuse part.
02721             beginEditCP(matc, MaterialChunk::DiffuseFieldMask);
02722                 matc->setDiffuse(Color4f(1.0f, 1.0f, 1.0f, 1.0f));
02723             endEditCP(matc, MaterialChunk::DiffuseFieldMask);
02724         }
02725         
02726         
02727         // check for textures with alpha
02728         if(!matc->isTransparent() && img != NullFC &&
02729            img->getBpp() == 4)
02730         {
02731             BlendChunkPtr blendc = BlendChunkPtr::dcast(cmat->find(BlendChunk::getClassType()));
02732             if(blendc == NullFC)
02733             {
02734                 blendc = OSG::BlendChunk::create();
02735 
02736                 beginEditCP(blendc, BlendChunk::SrcFactorFieldMask |
02737                                     BlendChunk::DestFactorFieldMask);
02738                     blendc->setSrcFactor (GL_SRC_ALPHA);
02739                     blendc->setDestFactor(GL_ONE_MINUS_SRC_ALPHA);
02740                 endEditCP(blendc, BlendChunk::SrcFactorFieldMask |
02741                                   BlendChunk::DestFactorFieldMask);
02742     
02743                 beginEditCP(cmat, ChunkMaterial::ChunksFieldMask);
02744                     cmat->addChunk(blendc);
02745                 endEditCP  (cmat, ChunkMaterial::ChunksFieldMask);
02746             }
02747         }
02748     }
02749     
02750     return Action::Continue;
02751 }


Variable Documentation

osg ::Time startTime = 0.
 

Definition at line 94 of file OSGVRMLFile.cpp.

Referenced by osg::GroupSockConnection::connectSocket(), osg::VRMLFile::createStandardPrototypes(), osg::VRMLFile::scanFile(), and osg::VRMLFile::scanStream().

osg ::Time useTime = 0.
 

Definition at line 95 of file OSGVRMLFile.cpp.

Referenced by osg::VRMLFile::scanFile(), osg::VRMLFile::scanStream(), and osg::VRMLFile::use().

osg ::Time findTime = 0.
 

Definition at line 96 of file OSGVRMLFile.cpp.

Char8 cvsid_cpp[] = "@(#)$Id: $" [static]
 

Definition at line 3129 of file OSGVRMLFile.cpp.

Char8 cvsid_hpp[] = OSGVRMLFILE_HEADER_CVSID [static]
 

Definition at line 3130 of file OSGVRMLFile.cpp.


Generated on Thu Aug 25 04:12:24 2005 for OpenSG by  doxygen 1.4.3