Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. CU::Vector4<float> temp = aCamera.myOrientation.GetTranslation();
  2. CU::Vector3<float>toCamera(temp.x, temp.y, temp.z);
  3.  
  4. CU::Vector3<float> reverseLightDir = aLightSource.LightDir * -1.f;
  5. CU::Vector3<float> colors(myPoints[i]->myColor.r, myPoints[i]->myColor.g, myPoints[i]->myColor.b);
  6.  
  7. float Diffuse = Dot(myPoints[i]->myNormal, reverseLightDir);
  8. ColorClamp(Diffuse);
  9. CU::Vector3<float> DiffuseVector = colors * aLightSource.LightColor * Diffuse;
  10.  
  11. CU::Vector3<float> halfvector = (toCamera + reverseLightDir);
  12. Normalize(halfvector);
  13.  
  14. float specular = Dot(halfvector, myPoints[i]->myNormal);
  15. ColorClamp(specular);
  16.  
  17. CU::Vector3<float> specularVector = colors * pow(specular, aLightSource.specularpower);
  18.  
  19. colors = DiffuseVector + specularVector;
  20.  
  21. ColorClamp(colors.r);
  22. ColorClamp(colors.g);
  23. ColorClamp(colors.b);
  24.  
  25. hgeColor aColor(myPoints[i]->myColor.r, myPoints[i]->myColor.g, myPoints[i]->myColor.b, 1);
  26.  
  27. CU::Vector4<float> normal = (CU::Vector4<float>(myPoints[i]->myNormal.x,
  28. myPoints[i]->myNormal.y, myPoints[i]->myNormal.z, 0)
  29. * toWorldMatrix)* aCamera.GetInverse();
  30.  
  31. aColor.r = colors.r;
  32. aColor.g = colors.g;
  33. aColor.b = colors.b;
  34.  
  35.  
  36. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  37. CU::Vector4<float> cameraPoint(myPoints[i]->GetPosition().x, myPoints[i]->GetPosition().y, myPoints[i]->GetPosition().z, 1.f);
  38.  
  39. cameraPoint *= toWorldMatrix;
  40. cameraPoint *= aCamera.GetInverse();
  41. cameraPoint *= CreateProjectionMatrixLH(0.001f, 100.f, 800.f / 600.f, 3.1415f / 180.f * 90.f);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement