Alternativa3D 7 mouse intersection without mouse movement tip

Hi! If you’re foced to avoid mouse movement, but still have to find mouse intersection with a some object (e.g. if moves only object), here is a quick tip:

//place this code to the EnterFrame or Timer event handler
var origin:Vector3D = new Vector3D();
var direction:Vector3D = new Vector3D();
var concatenatedMatrix:Matrix3D;
var rayData:RayIntersectionData;

_camera.calculateRay(origin, direction, mouseX, mouseY);

// _containerSurface - object to intersect
concatenatedMatrix = _containerSurface.concatenatedMatrix;
concatenatedMatrix.invert();
origin = concatenatedMatrix.transformVector(origin);
direction = concatenatedMatrix.deltaTransformVector(direction);

rayData = _containerSurface.intersectRay(origin, direction);
if (rayData)
{
  // just highlighting intersected face
  rayData.face.material = new FillMaterial(0xFF0000);
}

Found a typo? Please, highlight it and press Shift + Enter or click here to inform me!

Share Button

Inverting animation in the Alternativa3D

Hi! If you wish to reverse (play from the end to the beginning) some of your animations in the Alternativa3D engine, you could try to set the AnimationClip‘s property speed to the negative value, but it could be harmful in most cases and don’t officially supported.

Unfortunately, there is no any information or suggests about inverting animations like so on the public yet and nothing about it in the official documentation. I think, current engine build (7.7) have no lightweight native implementation of this functionality. It could be nice to see something like boolean reverse property at the AnimationClip class, isn’t it? Bot there is nothing similar yet =(

So, with great tip from the Vladimir Babushkin (about rebuilding animation by keyframes with reversed time), I came to this piece of code:
Continue reading

Found a typo? Please, highlight it and press Shift + Enter or click here to inform me!

Share Button