ModelMakerApplet Class

The ModelMakerApplet class is used for constructing models in Java and using them in windowless controls. It is similar to DXMApplet except that it exposes some COM interfaces and doesn't do any ticking (this is performed by the Microsoft® DirectAnimation® control called DAViewer). Here is the basic syntax for using ModelMakerApplet:

public class MyTest extends ModelMakerApplet{
    public MyTest() { 
        setModel(new testModel());
    }
}

The grabBackgroundImageComPtr, grabImageComPtr, grabSoundComPtr, and grabViewComPtr methods are used on the HTML page and can be called either from VBScript or JScript. Here is an example of an HTML page that calls these methods, using VBScript:

<HTML>
<HEAD>
<TITLE>myTest Windowless Control</TITLE>
</HEAD>

<body>

<DIV ID=LAYOUT STYLE="position:absolute;
left:0; top:0; width:600; height:400">

<DIV ID=text STYLE="position:absolute;
left:0; top:0; width:450; height:280">
<FONT SIZE=4 FACE="Verdana,Tahoma,Arial">
      
' This is standard HTML arranged using DIV tags, and atop it we're
' going to place our DirectX Animation windowless control.

</FONT></DIV>
</DIV>


<DIV ID=controlDiv>
<OBJECT ID="DAViewer"
    STYLE="position:absolute;left:50;top:10;width:200;height:300" 
    CLASSID="CLSID:B6FFC24C-7E13-11D0-9B47-00C04FC2F51D">
</OBJECT>
</DIV>

</DIV>

' The width and height parameters are placeholders. They need to
' be there to specify the applet and must be set to 1.

<applet code=myTest.class codebase=. width=1 height=1 id=javaApp>
</applet>

<script language="VBScript">
    sub window_onLoad
        set a = document.javaApp

        ' Get model components out of the Java applet and give it
        ' to the control. 
        DAViewer.View            = a.grabViewComPtr
        DAViewer.Image           = a.grabImageComPtr
        DAViewer.BackgroundImage = a.grabBackgroundImageComPtr
        DAViewer.Sound           = a.grabSoundComPtr

        ' Start the control viewing
        DAViewer.Start 

    end sub
</script>

</BODY>
</HTML>

ModelMakerApplet Methods

createBackgroundImage Used so that models constructed in Java, intended for windowless controls, will have a background image if they appear in a browser that does not support this feature.
grabBackgroundImageComPtr Retrieves the background image component of the model.
grabImageComPtr Retrieves the image component of the model.
grabSoundComPtr Retrieves the sound component of the model.
grabViewComPtr Retrieves the viewer component of the model.
ModelMakerApplet Creates a ModelMakerApplet object.
registerErrorAndWarningReceiver Enables the application to register an object that will have its methods invoked upon asynchronous errors encountered when DirectAnimation media is controlling the frame loop or when recoverable errors occur when sampling and displaying the model.
setModel Sets the model that will be used.

createBackgroundImage

ModelMakerApplet Class

Used so that models constructed in Java, intended for windowless controls, will have a background image if they appear in a browser that does not support this feature. The model will then be displayed in its own window, as if it were in a standard DirectAnimation applet. Just as these models need a background image to be explicitly inserted, so do windowless applets if they are to degrade gracefully to a windowed display.

Syntax

public ImageBvr createBackgroundImage( );

Return Value

Returns the ImageBvr object.

Remarks

This method should be called within ModelMakerApplet and not during the createModel implementation. Here is an example:

public class myTest extends ModelMakerApplet {

    public ImageBvr createBackgroundImage() {
        return Statics.solidColorImage(Statics.black);
    }
        setModel(new testModel());
}

grabBackgroundImageComPtr

ModelMakerApplet Class

Retrieves the background image component of the model. This method is called from a script on the HTML page.

Syntax

public IDABehavior grabBackgroundImageComPtr( );

Return Value

Returns the COM pointer to the IDABehavior interface (rather than an ImageBvr.)

grabImageComPtr

ModelMakerApplet Class

Retrieves the image component of the model. This method is called from a script on the HTML page.

Syntax

public IDABehavior grabImageComPtr( );

Return Value

Returns the COM pointer to the IDABehavior interface (rather than an ImageBvr.)

grabSoundComPtr

ModelMakerApplet Class

Retrieves the sound component of the model. This method is called from a script on the HTML page.

Syntax

public IDABehavior grabSoundComPtr( );

Return Value

Returns the COM pointer to the IDABehavior interface (rather than a SoundBvr.)

grabViewComPtr

ModelMakerApplet Class

Retrieves the viewer component of the model. This method is called from a script on the HTML page.

Syntax

public IDAView grabViewComPtr( );

Return Value

Returns the COM pointer to the IDABehavior interface (rather than a Viewer.)

ModelMakerApplet

ModelMakerApplet Class

Creates a ModelMakerApplet object.

Syntax

public ModelMakerApplet( );

registerErrorAndWarningReceiver

ModelMakerApplet Class

Enables the application to register an object that will have its methods invoked upon asynchronous errors encountered when DirectAnimation media is controlling the frame loop or when recoverable errors occur when sampling and displaying the model.

Syntax

public ErrorAndWarningReceiver registerErrorAndWarningReceiver(
ErrorAndWarningReceiver w );

Parameters

w
ErrorAndWarningReceiver object to be registered.

Return Value

Returns the ErrorAndWarningReceiver object.

setModel

ModelMakerApplet Class

Sets the model that will be used.

Syntax

public synchronized void setModel( Model model );

Parameters

model
Model to be set.

Remarks

This method must be called before the model is started. Calling it after the model has started causes an exception.


Top of Page Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.