Sign in to follow this  

I wanna use 0 represent invalid

This topic is 4392 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

//--------------------------------------------------------------
Terrain::Terrain(IDirect3DDevice9* device,
				 std::string heightmapFileName,
				 int numVertsPerRow,
				 int numVertsPerCol,
				 int cellSize,
				 float heightScale,
				 D3DXVECTOR3 *direction,
				 std::string baseMapName)
{
	m_device         = device;
	m_numVertsPerRow = numVertsPerRow;
	m_numVertsPerCol = numVertsPerCol;
	m_cellSize		 = cellSize;

//............

	if (baseMapName != 0)
		if( !genBigTexture(	baseMapName.c_str() ))
			exit(0);

	if (direction != 0)
	        if( !genBigTexture(	direction ))
		         exit(0);
}

here direction and baseMapName is optional. If you use one ,another one is forbidden. but string can not access 0 ,how to do???

Share this post


Link to post
Share on other sites
thanks , another similar question:

void Terrain::loadMultiTexture(std::string name1, std::string name2);

bool Terrain::setMultiTexture(bool b)
{
if(!b)
{
m_device->SetTexture(0, m_tex);
m_device->SetTexture(1, 0);
m_device->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
m_device->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
return true;
}
m_device->SetTexture(0, m_tex);
m_device->SetTexture(1, m_detailTex1);
m_device->SetTexture(2, m_alpha1);

m_device->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
m_device->SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);

//base pic
m_device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
m_device->SetTextureStageState(0, D3DTSS_RESULTARG, D3DTA_TEMP);

// detail pic1
m_device->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
// first alpha
m_device->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHA);
m_device->SetTextureStageState(2, D3DTSS_COLORARG1, D3DTA_TEMP);
m_device->SetTextureStageState(2, D3DTSS_COLORARG2, D3DTA_CURRENT);
m_device->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
m_device->SetTextureStageState(2, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
//m_device->SetTextureStageState(3, D3DTSS_RESULTARG, D3DTA_TEMP);

m_device->SetTextureStageState( 3, D3DTSS_COLOROP, D3DTOP_DISABLE );
m_device->SetTextureStageState( 3, D3DTSS_ALPHAOP, D3DTOP_DISABLE );

////detail pic2
//m_device->SetTextureStageState(4, D3DTSS_COLORARG1, D3DTA_TEXTURE);
//m_device->SetTextureStageState(4, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
////2nd alpha
//m_device->SetTextureStageState(5, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHA);
//m_device->SetTextureStageState(5, D3DTSS_COLORARG1, D3DTA_CURRENT);
//m_device->SetTextureStageState(5, D3DTSS_COLORARG2, D3DTA_TEMP);
//m_device->SetTextureStageState(5, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
//m_device->SetTextureStageState(5, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);

////detail pic3
//m_device->SetTextureStageState(6, D3DTSS_COLORARG1, D3DTA_TEXTURE);
//m_device->SetTextureStageState(6, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
////3nd alpha
//m_device->SetTextureStageState(7, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHA);
//m_device->SetTextureStageState(7, D3DTSS_COLORARG1, D3DTA_CURRENT);
//m_device->SetTextureStageState(7, D3DTSS_COLORARG2, D3DTA_TEMP);
//m_device->SetTextureStageState(7, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
//m_device->SetTextureStageState(7, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);

return D3D_OK;
}


if I load 2 map (detailmap and alpha) I will use and set 1 detail map,

if I load 4 map (detailmap and alpha) I will use and set 2 detail map,

So I must use 2 function or better way available??

Share this post


Link to post
Share on other sites

This topic is 4392 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this