<script
language="JavaScript"
src="/js/Kribi3DPlayer.js"
type="text/javascript"></script>
<script
language="JavaScript"
src="/js/gFunct.js"
type="text/javascript"></script>
<script
language="JavaScript"
type="text/javascript">
var controlCount = 1;
var loadedControls = 0;
var opening =
false;
var opened =
false;
var materialCurrent = -1;
var materialVersion = -1;
/*
------------------------------------------------------------ */
/* This function is invoked every time the
player sends a message to the
* browser, we use it to intercept the Ready event which is sent when
* the player is ready to accept commands and the ModelOpened event which
is
* sent when the model has been loaded. */
function KribiPlayer_Tell(msg) {
var player = document.getElementById("KribiPlayer");
if (msg ==
"Ready") {
// The player is ready to accept commands.
} else if
(msg == "ModelOpened") {
// The model has been opened, initialize the
camera and the page controls.
opened = true;
DefaultView_init();
} else if
(msg == "Refresh") {
if ((loadedControls == controlCount) &&
!opening) {
// Wait for all the controls to be
opened, make sure that this will run only once.
opening = true;
player.Do("Model OpenAsync '" +
FullModelsPath() + "Toys_MatBumpV01_OP.kmo");
} else if
(opened) {
// If the model has already been opened do a
normal refresh.
var version = player.Do("Material
GetVersion");
var current = player.Do("Material
GetCurrent");
if ((current != materialCurrent) ||
(version != materialVersion)) {
materialCurrent = current;
materialVersion = version;
set_Parameter();
}
}
}
}
/*
------------------------------------------------------------ */
// Set default
function DefaultView_init() {
var player = document.getElementById("KribiPlayer");
// Set the camera to its initial position.
player.Do("Camera Position
-1910.91,-5051.08,3266.14");
player.Do("Camera Orientation
-110.438,13.3213,0");
player.Do("Camera FieldOfView 71.00");
// Enable realistic rendering.
player.Do("Renderer Shading Realistic");
// Set tool
InstanceHorizontalPlaneMove();
//Set the default material
player.Do("Material SetCurrent 'MATERIAL'");
}
/*
------------------------------------------------------------ */
// Tools
function InstanceHorizontalPlaneMove() {
// Set Tool InstanceHorizontalPlaneMove
var player = document.getElementById("KribiPlayer");
player.Do("Tool SetCurrent 'InstanceHorizontalPlaneMove'");
player.Do("View SelectionStyle None");
}
/*
------------------------------------------------------------ */
// Function
function ConvertPercentage(myValue) {
var convert_value = myValue / 100.0;
return convert_value.toString();
}
/*
------------------------------------------------------------ */
function set_Parameter() {
var player = document.getElementById("KribiPlayer");
var materialSelected = player.Do("Material
GetCurrent");
if (materialSelected !=
"") {
player.Do("Material SetCurrent " +
materialSelected + " ");
var materialBumpMapAmount = player.Do("Material
Bumpiness ");
// set value of textbox and slider
window.document.getElementById("txt_BumpMapAmount").value
= materialBumpMapAmount * 100;
var js_slider_BumpMapAmount = $find("<%=
slider_BumpMapAmount.ClientID %>");
js_slider_BumpMapAmount.set_value(parseInt(materialBumpMapAmount *
100));
}
}
/*
------------------------------------------------------------ */
// Event handlers.
/* Increase the count of the 'loaded' global
variable, this is used to
* check when all the Telerik controls have been loaded before sending
* commands to the player. */
function HandleClientLoad() {
loadedControls++;
}
/*
------------------------------------------------------------ */
function HandleValueChange_BumpMapAmount(sender,
eventArgs) {
$get("txt_BumpMapAmount").value =
sender.get_value();
var player = document.getElementById("KribiPlayer");
player.Do("Material Bumpiness " +
ConvertPercentage(sender.get_value()) + " ");
}
|