void Uber::Insert(std::ostream& fout) const {
		int texcolor=0, texbump=0;
		
		texcolor = colorTexture(fout);
		texbump = bumpTexture(fout);
		
		MStatus status;
		MObject object;
		MPlug reflectivityPlug = MFnDependencyNode(shaderNode).findPlug("reflectivity");
		MPlug translucencePlug = MFnDependencyNode(shaderNode).findPlug("translucence");

		MPlug specularPlug = MFnDependencyNode(shaderNode).findPlug("specularColor");
		status = specularPlug.getValue(object);
		if (status != MStatus::kSuccess) { MGlobal::displayWarning("Could not get specular color value out"); }
		
		MFnNumericData specularData(object, &status);
		if (status != MStatus::kSuccess) { MGlobal::displayWarning("Could not get specular color data"); }
		
		
		
		if (texcolor) {
			fout << "Material \"uber\" \"texture Kd\" \"" << texcolor << "\" ";
			if (texbump) fout << "\"texture bumpmap\" \"" << texbump << "\" ";
			
			float r;
			status = reflectivityPlug.getValue(r);
			if (status == MStatus::kSuccess) fout << "\"color Kr\" [" << r << " " << r << " " << r << "] ";
			
			if (specularData.numericType() == MFnNumericData::k3Float) {
				float r,g,b;
				specularData.getData(r,g,b);				
				fout << "\"color Ks\" [" << r << " " << g << " " << b << "] ";
				
			} else if (specularData.numericType() == MFnNumericData::k3Double) {
				double r,g,b;
				specularData.getData(r,g,b);
				fout << "\"color Ks\" [" << r << " " << g << " " << b << "] ";
			}			
			
			float opacity;
			status = translucencePlug.getValue(opacity);
			opacity = 1.f - opacity;
			if (status == MStatus::kSuccess) fout << "\"color opacity\" [" << opacity << " " << opacity << " " << opacity << "] ";
			
			fout << std::endl;
		}
		
	}
Exemple #2
0
U32 WaterObject::packUpdate( NetConnection * conn, U32 mask, BitStream *stream )
{
   U32 retMask = Parent::packUpdate( conn, mask, stream );

   if ( stream->writeFlag( mask & UpdateMask ) )
   {
      stream->write( mDensity );
      stream->write( mViscosity );
      stream->write( mLiquidType );

      if ( stream->writeFlag( mFullReflect ) )
      {
         stream->write( mReflectorDesc.priority );
         stream->writeInt( mReflectorDesc.maxRateMs, 32 );
         //stream->write( mReflectMaxDist );
         //stream->write( mReflectMinDist );
         stream->write( mReflectorDesc.detailAdjust );         
         stream->writeFlag( mReflectNormalUp );
         stream->writeFlag( mReflectorDesc.useOcclusionQuery );
         stream->writeInt( mReflectorDesc.texSize, 32 );
      }

      stream->write( mReflectivity );

      stream->write( mWaterFogData.density );
      stream->write( mWaterFogData.densityOffset );      
      stream->write( mWaterFogData.wetDepth );
      stream->write( mWaterFogData.wetDarkening );

      stream->write( mDistortStartDist );
      stream->write( mDistortEndDist );
      stream->write( mDistortFullDepth );

      stream->write( mDepthGradientMax );
      stream->writeFlag( mEmissive );
      
      stream->write( mFoamMaxDepth );
      stream->write( mFoamAmbientLerp );     
      stream->write( mFoamRippleInfluence );

      stream->write( mWaterFogData.color );

      stream->write( mFresnelBias );
      stream->write( mFresnelPower );
      
      Point4F specularData( mSpecularColor.red, mSpecularColor.green, mSpecularColor.blue, mSpecularPower );      
      mathWrite( *stream, specularData );

      stream->write( mClarity );
      stream->write( mUnderwaterColor );

      stream->write( mOverallRippleMagnitude );
      stream->write( mOverallWaveMagnitude );
      stream->write( mOverallFoamOpacity );
   }

   if ( stream->writeFlag( mask & WaveMask ) )
   {
      for( U32 i=0; i<MAX_WAVES; i++ )
      {
         stream->write( mRippleSpeed[i] );
         mathWrite( *stream, mRippleDir[i] );
         mathWrite( *stream, mRippleTexScale[i] );
         stream->write( mRippleMagnitude[i] );

         stream->write( mWaveSpeed[i] );
         mathWrite( *stream, mWaveDir[i] );
         stream->write( mWaveMagnitude[i] );  
      }

      for ( U32 i = 0; i < MAX_FOAM; i++ )
      {
         stream->write( mFoamSpeed[i] );
         mathWrite( *stream, mFoamDir[i] );
         mathWrite( *stream, mFoamTexScale[i] );
         stream->write( mFoamOpacity[i] );
      }
   }

   if ( stream->writeFlag( mask & MaterialMask ) )
   {
      for ( U32 i = 0; i < NumMatTypes; i++ )      
         stream->write( mSurfMatName[i] );
   }

   if ( stream->writeFlag( mask & TextureMask ) )
   {
      stream->write( mRippleTexName );
      stream->write( mDepthGradientTexName );
      stream->write( mFoamTexName );
      stream->write( mCubemapName );      
   }

   if( stream->writeFlag( mask & SoundMask ) )
      sfxWrite( stream, mSoundAmbience );

   return retMask;
}
Exemple #3
0
	void PhongMat::Insert(std::ostream& fout) const {
		
		MStatus status;
		MObject object;
		/*
		for(int j = 0; j < shaderNode.attributeCount(); j++)
		{			
			MPlug m = shaderNode.findPlug(shaderNode.attribute(j), false);
			std::cout << " " << shaderNode.attribute(j).apiTypeStr() << " " << " plug " << m.name() << std::endl;
		}
		std::cout << std::endl;*/
		//MPlug reflectivityPlug = MFnDependencyNode(shaderNode).findPlug("reflectivity");

		MPlug sigmaPlug = MFnDependencyNode(shaderNode).findPlug("cosinePower");		

		MPlug colorPlug = MFnDependencyNode(shaderNode).findPlug("color");
		status = colorPlug.getValue(object);
		if (status != MStatus::kSuccess) { MGlobal::displayWarning("Could not get color value out"); }

		MFnNumericData colorData(object, &status);
		if (status != MStatus::kSuccess) { MGlobal::displayWarning("Could not get color value out (2)");  }

		MPlug specularPlug = MFnDependencyNode(shaderNode).findPlug("specularColor");
		status = specularPlug.getValue(object);
		if (status != MStatus::kSuccess) { MGlobal::displayWarning("Could not get specular color value out"); }
		
		MFnNumericData specularData(object, &status);
		if (status != MStatus::kSuccess) { MGlobal::displayWarning("Could not get specular color data"); }
				
		fout << "Material \"phongmat\" ";																		
		
		if (colorData.numericType() == MFnNumericData::k3Float) {
			float r,g,b;
			colorData.getData(r,g,b);						
			fout << "\"color rhod\" [" << r << " " << g << " " << b << "] ";
		} else if (colorData.numericType() == MFnNumericData::k3Double) {
			double r,g,b;
			colorData.getData(r,g,b);						
			fout << "\"color rhod\" [" << r << " " << g << " " << b << "] ";
		} else {
			MGlobal::displayWarning("Invalid data type");
		}		
		
		if (specularData.numericType() == MFnNumericData::k3Float) {
			float r,g,b;
			specularData.getData(r,g,b);				
			fout << "\"color rhos\" [" << r << " " << g << " " << b << "] ";
			
		} else if (specularData.numericType() == MFnNumericData::k3Double) {
			double r,g,b;
			specularData.getData(r,g,b);
			fout << "\"color rhos\" [" << r << " " << g << " " << b << "] ";
		} else {
			MGlobal::displayWarning("Invalid data type");
		}
			
		float sigma;
		status = sigmaPlug.getValue(sigma);
		if (status == MStatus::kSuccess) 
			fout << "\"float sigma\" [" << sigma << "] ";
		
		// sigma = cosine_power
		fout << std::endl;		
	}