Jump to content
  • Advertisement
Sign in to follow this  
derek7

I wanna use 0 represent invalid

This topic is 4637 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!