DAViewerControl Class

The DAViewerControl object provides a control that you can embed in an HTML page to display a Microsoft® DirectAnimation® model. The following example shows how to specify the control.

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

The DAViewerControl has the CLSID B6FFC24C-7E13-11D0-9B47-00C04FC2F51D and is a windowless control, so it can be used with dynamic HTML, and it can be used over or under other objects on the screen.

DirectAnimation also provides the more traditional windowed control (class DAViewerControlWindowed) with the CLSID 69AD90EF-1C20-11D1-8801-00C04FC29D46. If you are working in a traditional environment, such as Microsoft Visual Basic®, it is recommended that you use the windowed control. The DAViewerControlWindowed class supports all the methods and properties of the DAViewerControl class.

DAViewerControl Functions

AddBehaviorToRunAdds DABehavior objects that are not a part of the model.
GetPreference Retrieves the value of the specified preference.
PausePauses the model by stopping the tick count and holding the current state.
RegisterErrorHandler Enables the application to register a script function that will be invoked upon errors.
ResumeRestarts the model after it has been paused.
SetPreference Sets the value of the specified preference.
StartStarts the model.
StopStops the model.
TickEnables the host of the control to manually tick the model, rather than having the control tick itself.

DAViewerControl Properties

BackgroundImageA read/write property that sets or retrieves the background image for situations where the browser does not support windowless controls.
ImageA read/write property that sets or retrieves the DAImage displayed by the model.
MeterLibraryA read-only property that returns the DAStatics library associated with meter construction mode, so that units of measurement are meters and the positive y-axis is up.
OpaqueForHitDetectA read/write property that specifies whether or not hitting inside the control itself counts as a hit or whether the hit must be on a feature in a scene within a control when QueryHitPoint is called.
PixelLibraryA read-only property that returns the DAStatics library associated with pixel construction mode, so that units of measurement are pixels and the positive y-axis is down.
SoundA read/write property that sets or retrieves the sound behavior when the model is displayed.
TimerSourceA read/write property that sets or retrieves the timer source.
UpdateIntervalA read/write property that sets or retrieves the interval for updating the model, in seconds (a double).
ViewA read/write property that sets or retrieves the DAView object through which you access the view.

DAViewerControl Functions

This section contains reference material for the DAViewerControl functions.

AddBehaviorToRun

DAViewerControl Class

Adds DABehavior objects that are not a part of the model. When the system starts the model, it retrieves these additional behaviors and runs them with the same start time as the behaviors included in the model.

Syntax

controlObj.AddBehaviorToRun( bvr )

Parameters

bvr
DABehavior object to add.

Return Value

No return value.

Remarks

You can see a VBScript example in the AnimatedProperties.html sample found in the Samples/Multimedia/Danim/Vbscript/Templates subdirectory and a JScript example in the Plane3D.html and MSWorldLogo.html samples found in the Samples/Multimedia/Danim/Jscript/Showcase subdirectory.

Example

Consider the following VBScript sample, which displays the local time as a text value.

<HTML>
<BODY>
<CENTER><INPUT TYPE="TEXT" NAME="txtInp" VALUE=""></CENTER>

<OBJECT ID="DAControl" WIDTH=400 HEIGHT=300
CLASSID="CLSID:B6FFC24C-7E13-11D0-9B47-00C04FC2F51D">
</OBJECT>
</HTML>
</BODY>

<SCRIPT LANGUAGE="VBScript">
Sub window_onLoad
   Set m = DAControl.MeterLibrary
   Set timeVal = m.Localtime
   Set timeVal = timeVal.AnimateProperty( "txtInp.value", "VBScript", false, .01 )
   Call DAControl.AddBehaviorToRun( timeVal )
   DAControl.Start
End Sub
</SCRIPT>

GetPreference

DAViewerControl Class

Retrieves the value of the specified preference.

Syntax

controlObj.GetPreference( preference )

Parameters

preference
The name of the preference whose value is to be retrieved.

Return Value

Returns the value of the specified preference.

Remarks

You can set rendering and viewing preference settings in DirectAnimation, such as texture mapping quality, output audio format, and maximum frames per second. For a list of possible preferences and their settings, see SetPreference.

The following example shows how to retrieve the value of the FILL_MODE preference.

 currentvalue = DAControl.GetPreference("FILL_MODE");
 

Pause

DAViewerControl Class

Pauses the model by stopping the tick count and holding the current state.

Note You can only use this function with DirectAnimation versions later than 6.0; for example, version 6.00.06.xxx or later. Versions with this function are available in Microsoft Internet Explorer 5, Microsoft Windows® 98 Second Edition, and Windows 2000.

Syntax

controlObj.Pause( )

Return Value

No return value.

RegisterErrorHandler

DAViewerControl Class

Enables the application to register a script function that will be invoked upon errors.

Syntax

controlObj.RegisterErrorHandler( scriptlet )

Return Value

No return value.

Resume

DAViewerControl Class

Restarts the model after it has been paused. Sets the start time to the current time minus the paused time.

Note You can only use this function with DirectAnimation versions later than 6.0; for example, version 6.00.06.xxx or later. Versions with this function are available in Microsoft Internet Explorer 5, Windows 98 Second Edition, and Windows 2000.

Syntax

controlObj.Resume( )

Return Value

No return value.

SetPreference

DAViewerControl Class

Sets the value of the specified preference.

Syntax

controlObj.SetPreference( preference, value )

Parameters

preference
Name of the preference whose value is to be set.
value
New value to set for the preference.

Return Value

No return value.

Remarks

You can set rendering and viewing preference settings in DirectAnimation, such as texture mapping quality, output audio format, and maximum frames per second.

The following example shows how to set the value of the FILL_MODE preference.

DAControl.SetPreference("FILL_MODE", FILL_MODE_SOLID);

For a list of preferences you can set, and their default values, see PutPreference.

Start

DAViewerControl Class

Starts the model.

Syntax

controlObj.Start( )

Return Value

No return value.

Stop

DAViewerControl Class

Stops the model.

Note You can only use this function with DirectAnimation versions later than 6.0; for example, version 6.00.06.xxx or later. Versions with this function are available in Microsoft Internet Explorer 5, Windows 98 Second Edition, and Windows 2000.

Syntax

controlObj.Stop( )

Return Value

No return value.

Tick

DAViewerControl Class

Enables the host of the control to manually tick the model, rather than having the control tick itself.

Note You can only use this function with DirectAnimation versions later than 6.0; for example, version 6.00.06.xxx or later. Versions with this function are available in Microsoft Internet Explorer 5, Windows 98 Second Edition, and Windows 2000.

Syntax

controlObj.Tick( )

Return Value

No return value.

Remarks

This function tells the animation what time it is so that it can update accordingly. The control calls Tick at intervals set by the UpdateInterval function. If this interval is set to zero, the control won't update itself, and all ticking can be done by the host of the control.

DAViewerControl Properties

This section contains reference material for the DAViewerControl properties.

BackgroundImage

DAViewerControl Class

Sets or retrieves the background image for situations where the browser does not support windowless controls. A read/write property.

Syntax

controlObj.BackgroundImage

Return Value

Returns a DAImage object.

Image

DAViewerControl Class

Establishes the DAImage displayed by the model. A read/write property.

Syntax

controlObj.Image

Return Value

Returns the DAImage object.

MeterLibrary

DAViewerControl Class

Returns the DAStatics library associated with meter construction mode, and thus sets the unit of measurement to meters and the positive y-axis to up. A read-only property.

Syntax

controlObj.MeterLibrary

Return Value

Returns the DAStatics object.

See Also

PixelLibrary

OpaqueForHitDetect

DAViewerControl Class

A Boolean value that determines whether QueryHitPoint returns success if the hit is anywhere inside the control, or whether the hit must be on a feature in a scene inside the control. A read/write property.

Syntax

controlObj.OpaqueForHitDetect

Return Value

Returns a Boolean value (a VARIANT).

PixelLibrary

DAViewerControl Class

Returns the DAStatics library associated with pixel construction mode, and thus sets the unit of measurement to pixel and the positive y-axis to down. Pixel measurements are available only for constructing behaviors. When inquiring for a value, the returned measurement is always in meters. A read-only property.

Syntax

controlObj.PixelLibrary

Return Value

Returns the DAStatics object.

See Also

Pixel, PixelConstructionMode

Sound

DAViewerControl Class

Establishes the sound behavior when the model is displayed.

Syntax

controlObj.Sound

Return Value

Returns the DASound object.

TimerSource

DAViewerControl Class

Sets or retrieves the timer source (DA_TIMER_SOURCE). A read/write property. The timer source can be one of the following options.

Syntax

controlObj.TimerSource

Return Value

Returns the timer source flag (0, 1, or 2).

Remarks

The following code specifies that the control uses the container's timer.

ctrlObj.TimerSource = 1;

UpdateInterval

DAViewerControl Class

Sets or retrieves the interval for updating the model, in seconds (a double). Examples of where this property is useful include navigational controls and menu elements, which can use a low update rate. A read/write property.

Syntax

controlObj.UpdateInterval

Return Value

Returns a double.

Remarks

The following example is taken from the MSWorldLogo.html sample found in the samples/multimedia/danim/jscript/showcase subdirectory.

  DAControl.UpdateInterval = .05;    

View

DAViewerControl Class

Sets or retrieves the DAView object through which you access the view.

Syntax

controlObj.View

Return Value

Returns the DAView object.

Remarks

The following example is taken from the DxMLogoGeo.html sample found in the Samples/Multimedia/Danim/Jscript/Showcase subdirectory.

  v = DAControl.View;
  p = v.Preferences;
  test = p.GetPreference("Color_Key_Red");
  p.PutPreference("Color_Key_Red", 0.5);
  p.PutPreference("Color_Key_Green", 0.5);
  p.PutPreference("Color_Key_Blue", 0.5);

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