Hmm... This works:
dbConvertObjectFVF (b, 338);
dbSetObjectLight (b, 0);
dbGhostObjectOn (b, 0);
dbDisableObjectZWrite(b);
dbFadeObject (b,50.0f); // 50%
This does not work (wave disappears):
dbConvertObjectFVF (b, 0x040); //from DarkGDK's HELP: FVF_DIFFUSE=0x040 (D3DFVF_DIFFUSE)
dbSetObjectLight (b, 0);
dbGhostObjectOn (b, 0);
dbDisableObjectZWrite(b);
SetObjectAlpha (b,128); // 50%
...where:
void SetObjectAlpha (int objID, unsigned char alpha)
{
dbLockVertexDataForLimb (objID,0);
for (int i=0; i!=dbGetVertexDataVertexCount(); ++i)
{ unsigned long rgb = dbGetVertexDataDiffuse(i) & 0x00FFFFFF;
dbSetVertexDataDiffuse(i, rgb | (alpha<<24));
}
dbUnlockVertexData();
}
1) Why?
2) I can not see this and compare now, but as I understand, SetObjectAlpha() changes only alpha, but 1st method changes alpha AND make colors more dark (this is bad!) because it uses this code:
DARKSDK_DLL void SetDiffuse ( sMesh* pMesh, float fPercentage )
{
// get the offset map for the FVF
sOffsetMap offsetMap;
GetFVFOffsetMap ( pMesh, &offsetMap );
// make sure we have data in the vertices
if ( pMesh->dwFVF & D3DFVF_DIFFUSE )
{
// calculate an RGB from iPercentage
DWORD dwColor = (DWORD)(fPercentage*255);
DWORD dwRGB = D3DCOLOR_ARGB ( dwColor, dwColor, dwColor, dwColor ); // s_i !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! s_i
SetDiffuseEx ( pMesh, dwRGB );
}
else
{
// else apply diffuse to material and activate
pMesh->bUsesMaterial=true;
pMesh->mMaterial.Diffuse.r = fPercentage;
pMesh->mMaterial.Diffuse.g = fPercentage;
pMesh->mMaterial.Diffuse.b = fPercentage;
pMesh->mMaterial.Diffuse.a = 1.0f;
pMesh->mMaterial.Ambient.r = fPercentage;
pMesh->mMaterial.Ambient.g = fPercentage;
pMesh->mMaterial.Ambient.b = fPercentage;
pMesh->mMaterial.Ambient.a = 1.0f;
pMesh->mMaterial.Specular.r = 0.0f;
pMesh->mMaterial.Specular.g = 0.0f;
pMesh->mMaterial.Specular.b = 0.0f;
pMesh->mMaterial.Specular.a = 0.0f;
pMesh->mMaterial.Emissive.r = 0.0f;
pMesh->mMaterial.Emissive.g = 0.0f;
pMesh->mMaterial.Emissive.b = 0.0f;
pMesh->mMaterial.Emissive.a = 0.0f;
}
}
DARKSDK_DLL void SetDiffuseEx ( sMesh* pMesh, DWORD dwRGB )
{
// get the offset map for the FVF
sOffsetMap offsetMap;
GetFVFOffsetMap ( pMesh, &offsetMap );
// make sure we have data in the vertices
if ( pMesh->dwFVF & D3DFVF_DIFFUSE )
{
// go through all of the vertices
for ( int iCurrentVertex = 0; iCurrentVertex < (int)pMesh->dwVertexCount; iCurrentVertex++ )
{
// dwDiffuse = RGB
*( ( DWORD* ) pMesh->pVertexData + offsetMap.dwDiffuse + ( offsetMap.dwSize * iCurrentVertex ) ) = dwRGB;
}
}
// flag mesh for a VB update
pMesh->bVBRefreshRequired=true;
}
... why am I not right?