Li, thank you for your comments; trying to be pretty is one of the
main goals of the project :)
Well, it's almost a 'yes' to all what you described in your first
mail: it's all fine when the planet is
on the centre of the scene and the 'eclipse formation' behaves exactly
as you say.
I have applied your patch but it's not working for me: the program
behaves almost the same and I can't appreciate much difference in the
test class. The example you provide does seems to be working however.
Have you tried the patch with the test class? Is it working for you?
I have little time on weekdays so there's few things I can try.
Alright, here is an ugly patch for you. I'll try to get a proper fix
as soon as possible.
Results look like this:
http://www.lidev.com.ar/demos/away3d/dirlights_pfix1/
On the mean time, replace these methods in DirectionalLight.as:
public function setDiffuseTransform(source:
Object3D):void
{
if (!diffuseTransform[source])
diffuseTransform[source] = new MatrixAway3D();
// UGLY PATCH BY Li (REVIEW!!)
-----------------------------------
direction.x = _light.x - source.scenePosition.x;
direction.y = _light.y - source.scenePosition.y;
direction.z = _light.z - source.scenePosition.z;
direction.normalize();
nx = direction.x;
ny = direction.y;
mod = Math.sqrt(nx*nx + ny*ny);
transform.rotationMatrix(ny/mod, -nx/mod, 0,
-Math.acos(-direction.z));
//clearTransform();
//
---------------------------------------------------------------
diffuseTransform[source].multiply3x3(transform,
source.sceneTransform);
diffuseTransform[source].normalize(diffuseTransform[source]);
}
public function setSpecularTransform(source:Object3D, view:View3D):void
{
//find halfway matrix between camera and direction matricies
cameraTransform = view.camera.transform;
cameraDirection.x = -cameraTransform.sxz;
cameraDirection.y = -cameraTransform.syz;
cameraDirection.z = -cameraTransform.szz;
// UGLY PATCH BY Li (REVIEW!!)
-----------------------------------
var applDirection:Number3D = new Number3D(_light.x -
source.scenePosition.x,
_light.y -
source.scenePosition.y,
_light.z -
source.scenePosition.z);
applDirection.normalize();
//
---------------------------------------------------------------
halfVector.add(cameraDirection, applDirection);
halfVector.normalize();
nx = halfVector.x;
ny = halfVector.y;
mod = Math.sqrt(nx*nx + ny*ny);
halfTransform.rotationMatrix(-ny/mod, nx/mod, 0,
Math.acos(-halfVector.z));
if(!specularTransform[source][view])
specularTransform[source][view] = new MatrixAway3D();
specularTransform[source][view].multiply4x4(halfTransform,
source.sceneTransform);
specularTransform[source][view].normalize(specularTransform[source][view]);
}