View Single Post
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