Probleme mit Specularlighting
-
Hallo ich bins noch mal! Ich bin gerade dabei, meine Engine zu portieren und bin dabei auf ein weiteres Problem gestossen, auf das ich partout keine Lösung finde:
Und zwar funktioniert nun das Specularlighting nicht mehr?

Das ist der Code:
void KB_Engine::__handleModelRendering(KB_Control *pCon){ // declare and init local variables KB_ModelManager *pMgrMdl = pCon->getModelManager(); KB_Model *pMdlCur = 0x00; KB_Component *pComCur = 0x00; // start a loop for walking each model inside the list while(pMdlCur = pMgrMdl->getNextModel()){ // continue if the current model isn't visible if(!pMdlCur->isVisible()) continue; // get the resource of the current model KB_ModelResource *pRscMdl = pMdlCur->getModelResource(); // get the resources of the effect - layers if(pMdlCur->isEffectLayerResourceDefined(KB_EL_PRM)) this->p3DDev->SetTexture(1,pMdlCur->getEffectLayerResource(KB_EL_PRM)->p3DTex); if(pMdlCur->isEffectLayerResourceDefined(KB_EL_SEC)) this->p3DDev->SetTexture(2,pMdlCur->getEffectLayerResource(KB_EL_SEC)->p3DTex); // assign the worldmatrices of the model and the surfaces this->p3DDev->SetTransform(D3DTS_WORLD,pMdlCur->getModelTransform()->getWorldMatrix()); this->p3DDev->SetTransform(D3DTS_TEXTURE0,pMdlCur->getModelSurfaceTransform()->getWorldMatrix()); this->p3DDev->SetTransform(D3DTS_TEXTURE1,pMdlCur->getEffectLayerSurfaceTransform(KB_EL_PRM)->getWorldMatrix()); this->p3DDev->SetTransform(D3DTS_TEXTURE2,pMdlCur->getEffectLayerSurfaceTransform(KB_EL_SEC)->getWorldMatrix()); // create temporary material - struct D3DMATERIAL9 matTmp = {0}; // a loop for rendering each subset for(DWORD i=0;i<pRscMdl->numMat;i++){ // copy the material of the current subset to the temporary material buffer CopyMemory(&matTmp,&pRscMdl->pArrMat[i],sizeof(D3DMATERIAL9)); // multiply each color component of the diffuse color by the parametric color KB_Color *pClrDif = pMdlCur->getDiffuseColor(); matTmp.Diffuse.a *= pClrDif->getAlphaAsFloat(); matTmp.Diffuse.r *= pClrDif->getRedAsFloat(); matTmp.Diffuse.g *= pClrDif->getGreenAsFloat(); matTmp.Diffuse.b *= pClrDif->getBlueAsFloat(); // copy each color component of the ambient color from the diffuse color matTmp.Ambient.a = matTmp.Diffuse.a; matTmp.Ambient.r = matTmp.Diffuse.r; matTmp.Ambient.g = matTmp.Diffuse.g; matTmp.Ambient.b = matTmp.Diffuse.b; // copy the emissive color KB_Color *pClrEmm = &KB_Color(0xff000000);//pMdlCur->getEmissiveColor(); matTmp.Emissive.a = pClrEmm->getAlphaAsFloat(); matTmp.Emissive.r = pClrEmm->getRedAsFloat(); matTmp.Emissive.g = pClrEmm->getGreenAsFloat(); matTmp.Emissive.b = pClrEmm->getBlueAsFloat(); // set the specular - color matTmp.Power = 1000.0f;//pMdlCur->getSpecularPower(); this->p3DDev->SetRenderState(D3DRS_SPECULARMATERIALSOURCE,D3DMCS_MATERIAL); this->p3DDev->SetRenderState(D3DRS_SPECULARENABLE,TRUE); // set the material and the texture this->p3DDev->SetMaterial(&matTmp); this->p3DDev->SetTexture(0,pRscMdl->ppArrTex[i]); // draw the current subset pRscMdl->p3DMsh->DrawSubset(i); this->inf.__setNumberOfRenderedVertices(pRscMdl->p3DMsh->GetNumVertices(),KB_OM_REL); } // unset the textures this->p3DDev->SetTexture(1,0x00); this->p3DDev->SetTexture(2,0x00); } // a loop for walking each component while(KB_Component *pComCur = pCon->getNextComponent()){ // call this method for each sub - component if it is enabled if(pComCur->isVisible()) this->__handleModelRendering(pComCur); } } // --------------------------------------------------------------------------------------------
-
Du setzt keine Specular-Farbe im D3DMATERIAL9...
-
Scheisse, du hast Recht! Ich IDIOT!!! Manchmal ist programmieren wie die Rechtschreibung, der Autor kanns hundertmal durchlesen und sieht den offensichtlichen Fehler nicht.. :p
Danke dir, dass du dir die Mühe gemacht hast, das Teil durchzulesen!!!
Gruss Ishildur