Game Development Community

GuiRadarCtrl: render a round minimap with a alpha texture and a map texture,what is wrong

by JianWei Wang · in Torque 3D Professional · 05/18/2012 (12:34 am) · 0 replies

hi,every one,please help me;
I want to render a round minimap, Now I have a alpha texture and a map texture ,but when rendered ,I cannot see the map texture ,what is wrong,code below:
if (mMapTextureObject && mShowMap && mAlphaTextureObject)
{

Point3F points[4]; //4个点
F32 kx_halfwidth = getExtent().x * 0.5;
F32 kx_halfheight = getExtent().y * 0.5;

points[0] = Point3F(-kx_halfwidth, -kx_halfheight, 0.0f);
points[1] = Point3F(-kx_halfwidth, kx_halfheight, 0.0f);
points[2] = Point3F( kx_halfwidth, kx_halfheight, 0.0f);
points[3] = Point3F( kx_halfwidth, -kx_halfheight, 0.0f);

for(int i = 0; i < 4; i++)
{
points[i] += center;
}

GFXTextureObject* texture = mMapTextureObject;
GFXTextureObject* alphatexture = mAlphaTextureObject;

GFX->setTexture( 0, alphatexture );
GFX->setTexture( 1, texture );

GFXStateBlockDesc desc2;
desc2.setCullMode(GFXCullNone);
desc2.zEnable = false;
desc2.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);
desc2.samplersDefined = true;


desc2.samplers[0].textureColorOp = GFXTOPSelectARG1;
desc2.samplers[0].colorArg1 = GFXTATexture;
desc2.samplers[0].addressModeU = GFXAddressWrap;
desc2.samplers[0].addressModeV = GFXAddressWrap;

desc2.samplers[1].textureColorOp = GFXTOPModulate;
desc2.samplers[1].colorArg1 = GFXTATexture;
desc2.samplers[1].colorArg2 = GFXTACurrent;
desc2.samplers[1].addressModeU = GFXAddressWrap;
desc2.samplers[1].addressModeV = GFXAddressWrap;


desc2.samplers[0].alphaOp = GFXTOPSelectARG1;
desc2.samplers[0].alphaArg1 = GFXTATexture;

desc2.samplers[1].alphaOp = GFXTOPModulate;
desc2.samplers[1].alphaArg1 = GFXTATexture;
desc2.samplers[1].alphaArg2 = GFXTACurrent;

GFX->setStateBlockByDesc( desc2 );
//------------------------------------------

PrimBuild::color3f(1.0f,1.0f,1.0f);
PrimBuild::begin(GFXTriangleFan, 4);

PrimBuild::texCoord2f(0, 0);
PrimBuild::vertex3fv(points[0]);
PrimBuild::texCoord2f(0, 1);
PrimBuild::vertex3fv(points[1]);

PrimBuild::texCoord2f(1, 1);
PrimBuild::vertex3fv(points[2]);

PrimBuild::texCoord2f(1, 0);
PrimBuild::vertex3fv(points[3]);

PrimBuild::end();


GFXStateBlockDesc desc3;
desc3.setBlend(false, GFXBlendOne, GFXBlendZero);
desc3.samplers[0].textureColorOp = GFXTOPModulate;
desc3.samplers[1].textureColorOp = GFXTOPDisable;

desc3.samplers[0].alphaOp = GFXTOPModulate; //抄自shanhai
desc3.samplers[1].alphaOp = GFXTOPDisable;
GFX->setStateBlockByDesc( desc3 );
}
help me please!!