DirectX Media for Animation Java Reference Previous
Previous
Classes
Classes
Index
Index
Next
Next

Model Class

Constructor , Methods

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.


Constructor


Model

public Model();

Creates an Model object.


Methods


getImage

public ImageBvr getImage();

Returns the model's image.

Return Value:

Returns the ImageBvr object.


getSound

public SoundBvr getSound();

Return's the model's sound.

Return Value:

Returns the SoundBvr object.


modifyPreferences

public void modifyPreferences(Preferences p);

Modifies the preferences (such as rendering quality) for a model. See the Preferences class for information about preferences.

ParameterDescription
p The model preferences to be modified.


setImage

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.

ParameterDescription
im The ImageBvr object.


setSound

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.

ParameterDescription
snd The SoundBvr object.


createModel

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.

ParameterDescription
startTime The time the model is created.
ctx Contains state information (such as the view).



Top© 1997 Microsoft Corporation. All rights reserved. Legal Notices.