From: Carlos Delgado (C.Delgado++at++pgr.salford.ac.uk)
Date: 09/22/2003 05:47:04
Hi there,
I am having problems with transparency. The sphere I create is
completely opaque.
I have tried setting the different types of transparency to no avail.
Please find attached the class I develop to create the (expected)
translucent spheres.
I am working with IRIS Performer 2.2.10 on a 02
Thanks,
Carlos
// Start of code
const float clveGeoParticleSet_impl::_DEF_RADIUS = 1.0f;
const float clveGeoParticleSet_impl::_MAX_RADIUS_ALPHA = 10.5f; //35sec
(expectancy) x 0.3 (m/s)
clveGeoParticleSet_impl::clveGeoParticleSet_impl () {
_pDCS = new pfDCS();
_pSphere = _createSphere (_DEF_RADIUS);
_pDCS->addChild ( _pSphere);
// For transparency!
_pGState = new pfGeoState ();
//_pGState->setMode (PFSTATE_TRANSPARENCY, PFTR_ON);
_pGState->setMode (PFSTATE_TRANSPARENCY, PFTR_BLEND_ALPHA);
//_pGState->setMode (PFSTATE_TRANSPARENCY, PFTR_FAST);
_pMaterial = new pfMaterial ();
// Link them to sphere!!!
_pGSet->setGState (_pGState);
_pGState->setAttr (PFSTATE_FRONTMTL, _pMaterial);
// Set collision Mask so that is doesn't collide!
}
pfGeode * clveGeoParticleSet_impl::_createSphere(float radius)
{
//pfVec4 *colorAttr;
pfMatrix matrix;
pfGeode *geode = new pfGeode;
_pGSet = pfdNewSphere(32,pfGetSharedArena());
//colorAttr = (pfVec4 *) pfMalloc(sizeof(pfVec4),pfGetSharedArena());
//*colorAttr = color;
//gset->setAttr(PFGS_COLOR4,PFGS_OVERALL,colorAttr,NULL);
matrix.makeScale(radius,radius,radius);
pfdXformGSet(_pGSet,matrix);
geode->addGSet(_pGSet);
return geode;
}
int clveGeoParticleSet_impl::show (){
//add _pDCS to scene
clveWorld::getSingleton()->addToScene (_pDCS);
return VE_OK;
}
int clveGeoParticleSet_impl::hide (){
//remove _pDCS from scene
clveWorld::getSingleton()->removeFromScene (_pDCS);
return VE_OK;
}
int clveGeoParticleSet_impl::update (float fRadius, const stveVector
&pos) {
_pDCS->setTrans (pos.x, pos.y, pos.z);
// Here Convert from Units in Formula to Units in VE
_pDCS->setScale (fRadius);
float fAlpha = 0.3;
//depending on Radius and intensity (strength ?)
//fAlpha = (clveGeoParticleSet_impl::_MAX_RADIUS_ALPHA - fRadius) *
_fIntensity / clveGeoParticleSet_impl::_MAX_RADIUS_ALPHA;
_pMaterial->setAlpha( fAlpha );
return VE_OK;
}
int clveGeoParticleSet_impl::initialise (int iType, float fIntensity) {
_pDCS->setScale (1.0f);
_fIntensity = fIntensity;
//(depending on type) colour
_pMaterial->setColorMode( PFMTL_BOTH, PFMTL_CMODE_COLOR );
_pMaterial->setColor( PFMTL_AMBIENT, 0.3f, 0.3f, 0.3f );
_pMaterial->setColor( PFMTL_DIFFUSE, 1.0f, 0.9f, 0.7f );
_pMaterial->setAlpha( 0.5f );
return VE_OK;
}
-- Carlos Delgado ~~~~~ Centre for Virtual Environments (\o o/) The University of Salford ___________ &!& _______________ Business House M5 4WT, U.K. &"Inspiration exists, but it has & (44) +161 295 2918 & to find us working" --Picasso & Fax (44) + 161 285 2925 ________________________________ web http://www.nicve.salford.ac.uk/carlos
This archive was generated by hypermail 2b29 : Mon Sep 22 2003 - 05:32:26 PDT