DirectX Media for Animation Java Reference |
![]() Previous |
![]() Classes |
![]() Index |
![]() Next |
public abstract class Model extends Statics { // Constructor public Model(); // Methods public ImageBvr getImage(); public SoundBvr getSound(); public void modifyPreferences(Preferences p); public void setImage(ImageBvr im1); public void setSound(SoundBvr snd); public abstract void createModel(double startTime, BehaviorCtx ctx); }
The model is the set of behaviors actually sampled and displayed for an application. An instance of the Model class must be provided when constructing a Direct Animation viewer to actually view a behavior. The Model class can also optionally set some model-specific preferences, such as rendering quality. The following example uses several methods included in the Model class to display the familiar phrase, "Hello, World."
public class MyModel extends Model { // Create the behaviors that will be displayed public void createModel(double startTime, BehaviorCtx ctx) { // Convert the text to a behavior TextBvr tx = simpleText(toBvr("Hello, World")); // Render the TextBvr ImageBvr im = tx.render(); // set the image setImage(im); } }
For more information about behaviors, see the Behavior class.
public Model();Creates an Model object.
public ImageBvr getImage();Returns the model's image.
Return Value:
Returns the ImageBvr object.
public SoundBvr getSound();Return's the model's sound.
Return Value:
Returns the SoundBvr object.
public void modifyPreferences(Preferences p);Modifies the preferences (such as rendering quality) for a model. See the Preferences class for information about preferences.
Parameter Description p The model preferences to be modified.
public void setImage(ImageBvr im1);Establishes the image behavior displayed by Direct Animation when this model is displayed. Typically called by the model inside of the createModel method provided by the application. See the ImageBvr class for information about image behaviors.
Parameter Description im The ImageBvr object.
public void setSound(SoundBvr snd);Establishes the sound behavior displayed by Direct Animation when this model is displayed. Typically called by the model inside of the createModel method provided by the application. See the SoundBvr class for information about sound behaviors.
Parameter Description snd The SoundBvr object.
public abstract void createModel(double startTime, BehaviorCtx ctx);Builds the behaviors to be viewed. Behaviors are run as soon as the model is started, and are all started at time = startTime. The developer implements this method, constructs the behaviors, sets them in the model with setImage and setSound, and returns. It is up to the Direct Animation system to invoke this method.
Parameter Description startTime The time the model is created. ctx Contains state information (such as the view).
© 1997 Microsoft Corporation. All rights reserved. Legal Notices.