由用户创建的信息 Roman_Sementsov
07 December 2015 16:38
07 December 2015 12:03
04 December 2015 18:32
04 December 2015 18:21
Hi.
I've corrected your "setObjectMaterialParameterHeightToRandomValue" function. Take a look at the following code lines, please:
I appended your global variable "objectID" to m_scenes.get_object_by_name function. It's necessary, because this function uses 0 value by default. And the engine tries to find your object in main scene objects. The "get_all_objects" function uses m_obj.DATA_ID_ALL as a default data_id value.
The m_scenes.get_object_by_name cannot use DATA_ID_ALL by default value for data_id variable, because you can load the same scene twice or more times. In this case this function will have to return two or more objects, but it must return only one object.
script.js
I've corrected your "setObjectMaterialParameterHeightToRandomValue" function. Take a look at the following code lines, please:
function setObjectMaterialParameterHeightToRandomValue(){
var sceneName = "TorusScene";
var objName = "Torus";
//objName = "Plane";
var materialName = "Material";
var parameterName = "Height";
var value = Math.random()*2.5;
//console.log( "Before: ", m_scenes.get_active() );
//console.log( "All scene names: ", m_scenes.get_scenes() );
//m_scenes.set_active(sceneName);
//console.log( "After: ", m_scenes.get_active() );
//console.log( "All scene names: ", m_scenes.get_scenes() );
// get_object_by_name("Torus") finds nothing.
var objFoundWithAPICall = m_scenes.get_object_by_name(objName, objectID);
console.log( "Found Object via API-Call get_object_by_name('Torus'): ", objFoundWithAPICall );
// var obj = findObjectByName(objName);
// console.log( "Found Object by Name 'Torus' over all objects via get_all_objects(): ", obj );
m_obj.set_nodemat_value(objFoundWithAPICall, [materialName, parameterName], value);
}
I appended your global variable "objectID" to m_scenes.get_object_by_name function. It's necessary, because this function uses 0 value by default. And the engine tries to find your object in main scene objects. The "get_all_objects" function uses m_obj.DATA_ID_ALL as a default data_id value.
The m_scenes.get_object_by_name cannot use DATA_ID_ALL by default value for data_id variable, because you can load the same scene twice or more times. In this case this function will have to return two or more objects, but it must return only one object.
script.js
04 December 2015 16:32
04 December 2015 15:09
04 December 2015 15:01
Hello,
For example, you've prepared actions in Blender and exported scene. Now you should apply this actions to the object:
And if you want to play the 1th animation, for example, you should call the following code lines:
The "anim_callback" function will be called after animation will have finished.
For example, you've prepared actions in Blender and exported scene. Now you should apply this actions to the object:
function load_cb(data_id) {
m_app.enable_controls();
m_app.enable_camera_controls();
var obj = m_scenes.get_object_by_name("NAME");
if (obj) {
m_anim.apply(obj, "ACTION_NAME_0", 0); // 0 -is slot num
m_anim.apply(obj, "ACTION_NAME_1", 1); // 1 -is slot num
m_anim.apply(obj, "ACTION_NAME_2", 2); // 2 -is slot num
}
}
And if you want to play the 1th animation, for example, you should call the following code lines:
var obj = m_scenes.get_object_by_name("NAME");
var anim_callback = function() {};
m_anim.play(obj, anim_callback, 1); // 1 -is slot num
The "anim_callback" function will be called after animation will have finished.