2006-7-2 18:40
Arraydoudoubb
为什么我的骨骼动画放做出来是黑乎乎的?!
mesh应该没有问题呀。
灯光和纹理设置也不管用。
就是一个黑色剪影在走,问题出在哪里呢?:eek:
放上代码,帮忙,呜呜~:cry:
2006-7-2 21:02
wangzhonnew
seems file corruption
2006-7-2 21:25
doudoubb
呜呜,网速太慢,传布上来附件,着急呀,明天要跟导师交待呀,呜呜
2006-7-2 22:14
doudoubb
好了,把debug文件删了,变小了,下载看看吧~~
多多指点呀~
2006-7-4 21:09
wangzhonnew
i have trouble to compile the program....(don't have VC6.0, seems the program doesn't compatible with VS2005)
so i couldn't debug it....
but here is some interesting thing i've noticed
light2.Type = D3DLIGHT_DIRECTIONAL;
light2.Diffuse = D3DXCOLOR( 0.0F, 1.0F, 1.0F, 1.0F );
light2.Position = D3DXVECTOR3( 0.0F, -1.0F, 1.0F);
light2.Range = 1000.0F;
i think for directional light we should specify the direction instead of position, isn't it?
also i beleive all the directions are required to be normalized (like the following code, for your both light1 and light 2)
void CreateSunLight()
{
// Fill in a light structure defining our light
D3DLIGHT9 light;
ZeroMemory( &light, sizeof(D3DLIGHT9) );
light.Type = D3DLIGHT_DIRECTIONAL;
light.Diffuse.r = 1.0f;
light.Diffuse.g = 1.0f;
light.Diffuse.b = 1.0f;
light.Diffuse.a = 1.0f
light.Range = 1000.0f;
// Create a direction for our light - it must be normalized
D3DXVECTOR3 vecDir;
vecDir = D3DXVECTOR3(0.0f,-0.3f,0.5);
D3DXVec3Normalize( (D3DXVECTOR3*)&light.Direction, &vecDir );
// Tell the device about the light and turn it on
gD3dDevice->SetLight( 0, &light );
gD3dDevice->LightEnable( 0, TRUE );
}
and i didn't see you set the light on:
gD3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
ex:
VOID SetupLights()
{
// Set up a material. The material here just has the diffuse and ambient
// colors set to yellow. Note that only one material can be used at a time.
D3DMATERIAL8 mtrl;
ZeroMemory( &mtrl, sizeof(D3DMATERIAL8) );
mtrl.Diffuse.r = mtrl.Ambient.r = 1.0f;
mtrl.Diffuse.g = mtrl.Ambient.g = 1.0f;
mtrl.Diffuse.b = mtrl.Ambient.b = 0.0f;
mtrl.Diffuse.a = mtrl.Ambient.a = 1.0f;
g_pd3dDevice->SetMaterial( &mtrl );
// Set up a white, directional light, with an oscillating direction.
// Note that many lights may be active at a time (but each one slows down
// the rendering of our scene). However, here we are just using one. Also,
// we need to set the D3DRS_LIGHTING renderstate to enable lighting
D3DXVECTOR3 vecDir;
D3DLIGHT8 light;
ZeroMemory( &light, sizeof(D3DLIGHT8) );
light.Type = D3DLIGHT_DIRECTIONAL;
light.Diffuse.r = 1.0f;
light.Diffuse.g = 1.0f;
light.Diffuse.b = 1.0f;
vecDir = D3DXVECTOR3(0.f, 0.f, 1.f);
D3DXVec3Normalize( (D3DXVECTOR3*)&light.Direction, &vecDir );
light.Range = 1000.0f;
g_pd3dDevice->SetLight( 0, &light );
g_pd3dDevice->LightEnable( 0, TRUE );
g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
// Finally, turn on some ambient light.
g_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00202020 );
}
2006-7-4 23:11
doudoubb
版主!!!就是这块儿出的问题!
按你的指点,已经修改好了
谢谢~~~~~~~~~
新的问题是F3,F4键所改变的textureType和RenderState怎么不明显呢?:sweat2:
2006-7-5 02:02
wangzhonnew
for F4, i didn't see where you used textureType in the source code.... can you make sure you have used this variable?
for f3 :
//// if materials provided, copy them
if (NumMaterials > 0)
{
memcpy(pMeshContainer->pMaterials, pMaterials, sizeof(D3DXMATERIAL) * NumMaterials);
for (iMaterial = 0; iMaterial < NumMaterials; iMaterial++)
{
if (pMeshContainer->pMaterials[iMaterial].pTextureFilename != NULL)
{
// material ¶Áȡʧ°Ü
if( FAILED( D3DXCreateTextureFromFile( pd3dDevice, pMeshContainer->pMaterials[iMaterial].pTextureFilename,
&pMeshContainer->ppTextures[iMaterial] ) ) )
pMeshContainer->ppTextures[iMaterial] = NULL;
//don't remember a pointer into the dynamic memory, just forget the name after loading
pMeshContainer->pMaterials[iMaterial].pTextureFilename = NULL;
}
}
}
else // if no materials provided, use a default one
{
pMeshContainer->pMaterials[0].pTextureFilename = NULL;
memset(&pMeshContainer->pMaterials[0].MatD3D, 0, sizeof(D3DMATERIAL9));
pMeshContainer->pMaterials[0].MatD3D.Diffuse.r = 0.5f;
pMeshContainer->pMaterials[0].MatD3D.Diffuse.g = 0.5f;
pMeshContainer->pMaterials[0].MatD3D.Diffuse.b = 0.5f;
pMeshContainer->pMaterials[0].MatD3D.Specular = pMeshContainer->pMaterials[0].MatD3D.Diffuse;
}
i didn't see you defined the Power
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/D3DMATERIAL9.asp[/url]
maybe you got that value 0 so that specular effect doesn't work.
try to define it as 1 or higher and see what's going on...
2006-7-5 07:53
doudoubb
抱歉,我的英语....我的基本专业知识....
"i didn't see you defined the Power"
这里的Power是指什么呢?
“maybe you got that value 0 so that specular effect doesn't work.
try to define it as 1 or higher and see what's going on...”
这里that又是只那个参数呢?
F4的问题,经版主提醒,发现我在设置texture-blending operations时,竟然用的是常量,而不是改变Mode的变量。
// texture stage state
d3d9_device->SetTextureStageState( 0, D3DTSS_COLOROP, textureType );
d3d9_device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
d3d9_device->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
d3d9_device->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
就在第一句的最后一个参数。不过,似乎这几个变化还是看不出来。是否因为setupDevice()不会在程序中循环调用?
2006-7-5 18:26
wangzhonnew
呵呵,那个f4的暂时先不看(因为俺编译不了程序)
我们知道phong shading的算法是
Ip=KaIa+Sigma(lights)(Kd(L*N)Id+Ks(R*V)^a*Is)
这里Ks(R*V)^a*Is就是specular的计算部分,而其中的Ks指的是specular reflection constant,
a指的就是shininess constant for the material。
在你的程序里我好像没有发现关于这个a的define,在程序中就是D3DMATERIAL9:Power
你可以试一试将Power调整到10或者更高(也许1可能看不出什么),然后关掉ambient,diffuse和emissive单独打开specular进行调试……
2006-7-6 18:08
doudoubb
//// if materials provided, copy them
if (NumMaterials > 0)
{
memcpy(pMeshContainer->pMaterials, pMaterials, sizeof(D3DXMATERIAL) * NumMaterials);
for (iMaterial = 0; iMaterial < NumMaterials; iMaterial++)
{
if (pMeshContainer->pMaterials[iMaterial].pTextureFilename != NULL)
{
[COLOR=deeppink]pMeshContainer->pMaterials[iMaterial].MatD3D.Diffuse.r = 1.5f;[/COLOR]
[COLOR=deeppink]pMeshContainer->pMaterials[iMaterial].MatD3D.Diffuse.g = 1.5f;[/COLOR]
[COLOR=deeppink]pMeshContainer->pMaterials[iMaterial].MatD3D.Diffuse.b = 1.5f;[/COLOR]
[COLOR=deeppink] pMeshContainer->pMaterials[iMaterial].MatD3D.Specular = pMeshContainer->pMaterials[0].MatD3D.Diffuse;[/COLOR]
[COLOR=deeppink] pMeshContainer->pMaterials[iMaterial].MatD3D.Power = 15;[/COLOR]
// material 读取失败
..................................
我在CreateMeshContainer函数里面填了上面粉色的那几行,不知道版主是不是这个意思,可是仍是没有效果。
版主不要被我气到哦:sweat2:
2006-7-6 21:37
wangzhonnew
Ks(R*V)^a*Is
恩……检查一下Ks和Is?
就是pMeshContainer->pMaterials[iMaterial].MatD3D.Specular = pMeshContainer->pMaterials[0].MatD3D.Diffuse;, 这里你用的是pMaterials[0]的Diffuse材质带入pMaterials[iMaterial]的specular,能不能确认一下这个的数值是正确的?
要不你可以hardcode Ks,Is和a然后看一看能不能有正确显示。
如果hardcode的值还是看不出变化,那么关闭ambient, diffuse(把他们都强制设为0就可以了)只保留specular看一看能不能出来色彩。
如果不行估计就是D3D的设置问题,去网上下载个例子看一看。
如果可以那么单独用specular来测试F3,如果不工作说明逻辑问题,如果工作的话再打开其他的效果继续测试……
俺编译不了程序所以不能帮你测:(不好意思哦
2006-7-8 08:12
doudoubb
版主虽然不能调试,但是每次指点的都是问题的关键,已经非常感谢了~
最近实在太忙了,这个程序我主要为了实现一个3d人物行走,F3、F4都是附带功能,主要目的已经达到了,暂时想放一边。版主最后的指点,我会好好做调试的。
每次来请教,都能耐心给我很大指点,真的谢谢版主!
2008-3-5 13:58
it1pub19
回复 #12 doudoubb 的帖子
问题就在灯光,我已经修改好了,有兴趣加我,我把修改后的代码给你.
2008-3-5 13:59
it1pub19
我的QQ530487204
页:
[1]

Powered by ITPUB论坛