Posted by: bobo May 23 2007, 12:24 AM
Suppose I have a Box primitive and some code that makes it spin on one axis based on where the mouse is, like so:
http://www.betawavepool.com/sandyTests/flash/BoxMovie_az3C.html
(or see attached file)
supposing
that when you click on one of the sides of the box that the spinning
stops and a plane is created that starts in the same placement as the
side clicked on and transitions to a different view so that it's facing
the camera head on and moving forward towards the camera.
Is this possible?
if so, how?
I've
been messing around with trying to getVertex() on the TriFace3D that
was clicked, as well as it's companion triangle and then creating a new
plane object and setting it's aPoints array to the right vertices from
the 2 getVertex returned arrays.
But it's not working.
Here's sample code:
CODE
function pressFace(e:ObjectEvent):Void {
var t:TriFace3D = e.getTarget();
//getDataRef is a public method I added to TriFace3D so I could set and
get my own property from...
//...an object, inthis case the prop a reference to this face's paired face on the cube
var t2 = t.getDataRef();
var vertices1:Array = t.getVertex();
var vertices2:Array = t2.getVertex();
var plane:Plane3D = new Plane3D(80,80,1,'tri');
plane.aPoints = [vertices1[0],vertices1[2],vertices2[0],vertices1[1]];
plane.setSkin(new MixedSkin(0x2345aa, 100, 0x000000, 100));
var tg:TransformGroup = new TransformGroup();
tg.setTransform(rotation);
var transGroup = new TransformGroup();
var translation = new Transform3D();
transGroup.setTransform(translation);
translation.translate(0,0,0);
transGroup.addChild(plane);
tg.addChild(transGroup);
rootGroup.addChild(tg);
}
Attached File(s)
BoxMovie_az3C.swf ( 209.21k )
Number of downloads: 6
Posted by: Petit May 23 2007, 09:00 AM
QUOTE(bobo @ May 23 2007, 12:24 AM)

supposing
that when you click on one of the sides of the box that the spinning
stops and a plane is created that starts in the same placement as the
side clicked on and transitions to a different view so that it's facing
the camera head on and moving forward towards the camera.
Is this possible?
It should be possible to
- get the normal vector of the clicked face
- calculate the position of the cube side it belongs to
- then create a plane, and position it where cube side is by a combination of rotation/translation.
- animate it from that position to the final one, using a RotationInterpolator to rotate around the y axis
- using setPointOfReference ( v:Vector ) to have the axis of rotation through the center of the cube.
- finally use a PostionInterpolator to close in to the plane.
This is nothing but a qualified guess.
It's based on the assumption that it is the cube that is rotating and not the camera.
There may be simpler solutions as well.
Good luck!
Posted by: bobo May 23 2007, 06:46 PM
QUOTE(Petit @ May 23 2007, 02:00 AM)

- get the normal vector of the clicked face
- calculate the position of the cube side it belongs to
can
you explain what a normal vector is? In math terms, I thought a normal
is a line or vector perpendicular to some point on a curve.
what is a normal in terms of a 3d face?
thanks
Posted by: zeusprod May 23 2007, 08:16 PM
QUOTE(bobo @ May 23 2007, 02:46 PM)

can
you explain what a normal vector is? In math terms, I thought a normal
is a line or vector perpendicular to some point on a curve.
what is a normal in terms of a 3d face?
thanks

The "normal" of a 3D face is a vector perpendicular to the face, sort of like pins sticking out of a pin cushion.
Posted by: bobo May 24 2007, 05:20 AM
thanks
does anyone have any particular recommendations for good books on the subject of 3D theory and mathematics?
Posted by: zeusprod May 24 2007, 11:19 AM
Although
they are specific to Director, not Flash, I like "Director Shockwave
Studio Developer's Guide" by James Newton, published by Osborne ISBN #
0-07-213265-5 and "Director's Third Dimension - Fundamentals of 3D
Programming in Director 8.5" by Paul Catanese, published by Que, ISBN
#0-672-32228-5.
They both cover a lot of the same principles as you'll need for understanding 3D in Flash.
And if Adobe ever adds a realtime 3D engine to Flash, they'll probably re-purpose a lot of the code.