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
AddBehaviorToRun Adds DABehavior objects that are not a part of the model. GetPreference Retrieves the value of the specified preference. Pause Pauses 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. Resume Restarts the model after it has been paused. SetPreference Sets the value of the specified preference. Start Starts the model. Stop Stops the model. Tick Enables the host of the control to manually tick the model, rather than having the control tick itself.
DAViewerControl Properties
BackgroundImage A read/write property that sets or retrieves the background image for situations where the browser does not support windowless controls. Image A read/write property that sets or retrieves the DAImage displayed by the model. MeterLibrary A 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. OpaqueForHitDetect A 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. PixelLibrary A 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. Sound A read/write property that sets or retrieves the sound behavior when the model is displayed. TimerSource A read/write property that sets or retrieves the timer source. UpdateInterval A read/write property that sets or retrieves the interval for updating the model, in seconds (a double). View A read/write property that sets or retrieves the DAView object through which you access the view.
This section contains reference material for the DAViewerControl functions.
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>
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");
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.
Enables the application to register a script function that will be invoked upon errors.
Syntax
controlObj.RegisterErrorHandler( scriptlet )
Return Value
No return value.
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.
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.
Starts the model.
Syntax
controlObj.Start( )
Return Value
No return value.
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.
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.
This section contains reference material for the DAViewerControl properties.
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.
Establishes the DAImage displayed by the model. A read/write property.
Syntax
controlObj.Image
Return Value
Returns the DAImage object.
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
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).
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
Establishes the sound behavior when the model is displayed.
Syntax
controlObj.Sound
Return Value
Returns the DASound object.
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;
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;
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
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.