Alice Community

Alice Community (
-   Share Objects (
-   -   Objects named 'head' turn to face camera before deleted (

jedavis 06-19-2008 02:42 PM

Objects named 'head' turn to face camera before deleted
I spent a little while trying to figure out this little anomoly: characters turning to face the camera when deleted.

It turns out any object or sub-object named "head" will turn to face the camera when the instance is deleted.

Maybe this information is worth a thread...
[URL=""]Michigan Marijuana Dispensary[/URL]

DrJim 06-19-2008 07:12 PM

Actually I believe the head returns to its original position rather than turning to face the camera. I have assume this was partially an artifact of having to clear the coordinate references for the deleted object and partially (like the spin) an attept to add a bit of humor as the necessary housekeeping took place.

jedavis 06-20-2008 03:50 PM

Here is the code that does it... for those who are interested:

edu.cmu.cs.stage3.alice.core.Element[] heads = namedHeadCriterion );
if( (heads != null) && (heads.length > 0) ) {
edu.cmu.cs.stage3.alice.core.Element head = heads[0];
if( head instanceof edu.cmu.cs.stage3.alice.core.Transformable ) {
edu.cmu.cs.stage3.alice.core.Camera camera = authoringTool.getCurrentCamera();
if( camera != null ) {
edu.cmu.cs.stage3.alice.core.response.PointAtAnimation pointAt = new edu.cmu.cs.stage3.alice.core.response.PointAtAnimation();
pointAt.subject.set( head ); camera );
pointAt.duration.set( new Double( .5 ) );
doInOrder.componentResponses.add( pointAt );
edu.cmu.cs.stage3.alice.core.response.Wait wait2 = new edu.cmu.cs.stage3.alice.core.response.Wait();
wait2.duration.set( new Double( .4 ) );
doInOrder.componentResponses.add( wait2 );
[CODE] namedHeadCriterion );[/CODE] returns an array of elements (sub-objects) that meet the "namedHeadCriterion", that is, those that are named "head". (I'm leaving out the "namedHeadCriterion" code)
if( (heads != null) && (heads.length > 0) )[/CODE] means "if we found a piece named 'head' in the model".

[CODE]heads[0][/CODE] is our element named "head". Since objects can't be named the same thing there can be only one.

The rest of the code is more obvious.. it just sets up the PointAtAnimation (turn the subject, "head," to point at the target, "camera") and does it. (helpful hint: in the Alice code "methods" are referred to as "responses")
[URL=""] oxygen vaporizer[/URL]
[URL=""]Mexico Hotels[/URL]

All times are GMT -5. The time now is 11:37 PM.

Copyright ©2020, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.