Beispiel #1
0
    void Effect::set(unsigned int level, const Texture* texture)
    {
        char semantic[] = {'T', 'E', 'X', static_cast<unsigned char> (level + 48), '\0'};

        CGparameter parameter = cgGetEffectParameterBySemantic(effect.get(), semantic);
        cgGLSetTextureParameter(parameter, texture->getID());
    }
void CgfxRenderPassChunk::updateGLMatricies(DrawEnv *pEnv)
{
	if( getSemanticParameters() & ((UInt32)(1 << CGFX_MODELVIEWPROJECTION_PARAMETER))) //ok
	{
		CGparameter theMatrix = cgGetEffectParameterBySemantic(*_mEffect, "ModelViewProjection");
		OSG::Matrixr obj2World(pEnv->getObjectToWorld()),world2scrn(pEnv->getWorldToScreen());
		world2scrn.mult(obj2World);
		cgGLSetMatrixParameterfc(theMatrix,world2scrn.getValues());
	}

	if(getSemanticParameters() & ((UInt32)(1 << CGFX_MODELVIEW_PARAMETER))) //ok?
	{
		CGparameter theMatrix = cgGetEffectParameterBySemantic(*_mEffect, "ModelView");
		OSG::Matrixr obj2World(pEnv->getObjectToWorld()),cameraViewing(pEnv->getCameraViewing());
		cameraViewing.mult(obj2World);
		cgGLSetMatrixParameterfc(theMatrix,cameraViewing.getValues());
	}

	if(getSemanticParameters() & ((UInt32)(1 << CGFX_MODELINVERSETRANSPOSE_PARAMETER))) //ok?
	{
		CGparameter theMatrix = cgGetEffectParameterBySemantic(*_mEffect, "ModelInverseTranspose");
		OSG::Matrixr obj2World(pEnv->getObjectToWorld()),cameraViewing(pEnv->getCameraViewing());
		cameraViewing.mult(obj2World);
		cameraViewing.invert();
		cameraViewing.transpose();
		cgGLSetMatrixParameterfc(theMatrix,cameraViewing.getValues());
	}

	if(getSemanticParameters() & ((UInt32)(1 << CGFX_MODELTRANSPOSE_PARAMETER))) //ok?
	{
		CGparameter theMatrix = cgGetEffectParameterBySemantic(*_mEffect, "ModelTranspose");
		OSG::Matrixr obj2World(pEnv->getObjectToWorld()),cameraViewing(pEnv->getCameraViewing());
		cameraViewing.mult(obj2World);
		cameraViewing.transpose();
		cgGLSetMatrixParameterfc(theMatrix,cameraViewing.getValues());
	}

	if(getSemanticParameters() & ((UInt32)(1 << CGFX_WORLDVIEWPROJECTION_PARAMETER))) // ok
	{
		CGparameter theMatrix = cgGetEffectParameterBySemantic(*_mEffect, "WorldViewProjection");
		OSG::Matrixr obj2World(pEnv->getObjectToWorld()),world2scrn(pEnv->getWorldToScreen());
		world2scrn.mult(obj2World);
		cgGLSetMatrixParameterfc(theMatrix,world2scrn.getValues());
	}

	if(getSemanticParameters() & ((UInt32)(1 << CGFX_WORLD_PARAMETER))) //ok?
	{
		CGparameter theMatrix = cgGetEffectParameterBySemantic(*_mEffect, "World");
		OSG::Matrixr obj2World(pEnv->getObjectToWorld()),cameraViewing(pEnv->getCameraViewing());
		cameraViewing.mult(obj2World);
		cgGLSetMatrixParameterfc(theMatrix,cameraViewing.getValues());
	}

	if(getSemanticParameters() & ((UInt32)(1 << CGFX_WORLDINVERSETRANSPOSE_PARAMETER))) //ok?
	{
		CGparameter theMatrix = cgGetEffectParameterBySemantic(*_mEffect, "WorldInverseTranspose");
		OSG::Matrixr obj2World(pEnv->getObjectToWorld()),cameraViewing(pEnv->getCameraViewing());
		cameraViewing.mult(obj2World);
		cameraViewing.invert();
		cameraViewing.transpose();
		cgGLSetMatrixParameterfc(theMatrix,cameraViewing.getValues());
	}

	if(getSemanticParameters() & ((UInt32)(1 << CGFX_VIEWINVERSE_PARAMETER)))
	{
		CGparameter theMatrix = cgGetEffectParameterBySemantic(*_mEffect, "ViewInverse");
		OSG::Matrixr cameraViewing(pEnv->getCameraViewing());
		cameraViewing.invert();
		cgGLSetMatrixParameterfc(theMatrix,cameraViewing.getValues());
	}

	if(getSemanticParameters() & ((UInt32)(1 << CGFX_VIEW_PARAMETER)))
	{
		CGparameter theMatrix = cgGetEffectParameterBySemantic(*_mEffect, "View");
		cgGLSetMatrixParameterfc(theMatrix,pEnv->getCameraViewing().getValues());
	}

	if(getSemanticParameters() & ((UInt32)(1 << CGFX_VIEWINVERSETRANSPOSE_PARAMETER)))
	{
		CGparameter theMatrix = cgGetEffectParameterBySemantic(*_mEffect, "ViewInverseTranspose");
		OSG::Matrixr cameraViewing(pEnv->getCameraViewing());
		cameraViewing.invert();
		cameraViewing.transpose();
		cgGLSetMatrixParameterfc(theMatrix,cameraViewing.getValues());
	}
    
	if(getSemanticParameters() & ((UInt32)(1 << CGFX_VIEWTRANSPOSE_PARAMETER)))
	{
		CGparameter theMatrix = cgGetEffectParameterBySemantic(*_mEffect, "ViewTranspose");
		OSG::Matrixr cameraViewing(pEnv->getCameraViewing());
		cameraViewing.transpose();
		cgGLSetMatrixParameterfc(theMatrix,cameraViewing.getValues());
	}

}
Beispiel #3
0
 void Effect::set(const char* semantic, const Math::Vector4& v)
 {
     CGparameter parameter = cgGetEffectParameterBySemantic(effect.get(), semantic);
     cgSetParameter4d(parameter, v.X, v.Y, v.Z, v.W);
 }
Beispiel #4
0
 void Effect::set(const char* semantic, double d)
 {
     CGparameter parameter = cgGetEffectParameterBySemantic(effect.get(), semantic);
     cgSetParameter1d(parameter, d);
 }
Beispiel #5
0
 void Effect::set(const char* semantic, const Math::Matrix4& matrix)
 {
     CGparameter parameter = cgGetEffectParameterBySemantic(effect.get(), semantic);
     cgSetMatrixParameterdc(parameter, matrix);
 }