Alice Community  

Go Back   Alice Community > Alice 2 > Share Objects

Reply
 
Thread Tools Display Modes
Objects named 'head' turn to face camera before deleted
Old
jedavis
Junior Member
 
Status: Offline
Posts: 14
Join Date: Jun 2008
Default Objects named 'head' turn to face camera before deleted - 06-19-2008, 02:42 PM

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...
________
Michigan Marijuana Dispensary
________
HOW TO CLEAN IOLITE VAPORIZER

Last edited by jedavis; 05-11-2011 at 04:53 AM.
   
Reply With Quote
Old
DrJim
Guest
 
Status:
Posts: n/a
Default 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.
   
Reply With Quote
Old
jedavis
Junior Member
 
Status: Offline
Posts: 14
Join Date: Jun 2008
Default 06-20-2008, 03:50 PM

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

Code:
edu.cmu.cs.stage3.alice.core.Element[] heads = model.search( 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 );
			pointAt.target.set( 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:
model.search( namedHeadCriterion );
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)
Code:
if( (heads != null) && (heads.length > 0) )
means "if we found a piece named 'head' in the model".

Code:
heads[0]
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")
________
oxygen vaporizer
________
Mexico Hotels

Last edited by jedavis; 05-11-2011 at 04:53 AM.
   
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



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