Сообщения, созданные пользователем amiarun
17 марта 2016 08:48
I have another query with regard to moving objects along the wall. This is the code I have:
where:
When I try to move it along a single wall at a time, it works perfectly. But when I put them all together it obviously takes only only one condition because of the way I've structured my if statements.
Is there a better way of doing this movement along the wall? Is there some way I can find the object that the ray from the camera is intersecting? Sorry if this sounds more like a programming question…
var point_w = m_util.line_plane_intersect(FRONT_WALL_PLANE_NORMAL, 3,
cam_trans, camera_ray, _vec3_tmp3);
var point_wl = m_util.line_plane_intersect(LEFT_WALL_PLANE_NORMAL, -2.45,
cam_trans, camera_ray, _vec3_tmp3);
var point_wr = m_util.line_plane_intersect(RIGHT_WALL_PLANE_NORMAL, -1.95,
cam_trans, camera_ray, _vec3_tmp3);
if (point_w && camera_ray[1] < 0) {
var obj_parent = m_obj.get_parent(_selected_obj);
if (obj_parent && m_obj.is_armature(obj_parent))
// translate the parent (armature) of the animated object
m_trans.set_translation_v(obj_parent, point_w);
else
m_trans.set_translation_v(_selected_obj, point_w);
limit_object_position(_selected_obj);
}
if (point_wl && camera_ray[1] < 0) {
m_trans.set_rotation(_selected_obj,0,0.7071,0,0.7071);
var obj_parent = m_obj.get_parent(_selected_obj);
if (obj_parent && m_obj.is_armature(obj_parent))
// translate the parent (armature) of the animated object
m_trans.set_translation_v(obj_parent, point_wl);
else
m_trans.set_translation_v(_selected_obj, point_wl);
limit_object_position(_selected_obj);
}
if (point_wr && camera_ray[1] < 0) {
m_trans.set_rotation(_selected_obj,0,0.7071,0,0.7071);
var obj_parent = m_obj.get_parent(_selected_obj);
if (obj_parent && m_obj.is_armature(obj_parent))
// translate the parent (armature) of the animated object
m_trans.set_translation_v(obj_parent, point_wr);
else
m_trans.set_translation_v(_selected_obj, point_wr);
limit_object_position(_selected_obj);
}
where:
var FRONT_WALL_PLANE_NORMAL = [1, 0, 0];
var LEFT_WALL_PLANE_NORMAL = [0, 0, 1];
var RIGHT_WALL_PLANE_NORMAL = [0, 0, -1];
When I try to move it along a single wall at a time, it works perfectly. But when I put them all together it obviously takes only only one condition because of the way I've structured my if statements.
Is there a better way of doing this movement along the wall? Is there some way I can find the object that the ray from the camera is intersecting? Sorry if this sounds more like a programming question…
10 марта 2016 15:24
10 марта 2016 08:58
In your Furnishing the room demo, we are trying to place objects by line_plane_intersect on the floor. However, if i want to do the same for the ceiling, How would it be possible?
Here the FLOOR_PLANE_NORMAL has the value [0, 1, 0]. If I define another value called CEILING_PLANE_NORMAL with the value [0,-1, 0], it doesnt seem to work with the following call :
This could be a mistake in my calculation but an explanation would be great
var point = m_util.line_plane_intersect(FLOOR_PLANE_NORMAL, 0,
cam_trans, camera_ray, _vec3_tmp3);
Here the FLOOR_PLANE_NORMAL has the value [0, 1, 0]. If I define another value called CEILING_PLANE_NORMAL with the value [0,-1, 0], it doesnt seem to work with the following call :
m_util.line_plane_intersect(CEILING_PLANE_NORMAL, 1.63189,
cam_trans, camera_ray, _vec3_tmp3);
This could be a mistake in my calculation but an explanation would be great
02 марта 2016 09:05
29 февраля 2016 12:41
25 февраля 2016 13:22
25 февраля 2016 12:20
25 февраля 2016 11:28
25 февраля 2016 08:19
23 февраля 2016 11:38
I can give you a more detailed example:
Here I'm searching for an object with name - obname. And _objs is storing all the objects in the scene. I am then looking for the object in the array and printing its name out. Please check the screenshot attached. The objects is found and its name is printed. But when I use get_object_by_name() it says that its not found.
Any help would be appreciated. :)
var obname = "ItaliaMateArmchairMain";
var _objs = [];
_objs = m_scenes.get_all_objects("MESH");
for(var i = 0 ; i < _objs.length; ++i)
{
if(_objs[i].name == obname) {
console.log(_objs[i].name);
var materials = m_mat.get_materials_names(m_scenes.get_object_by_name(_objs[i].name));
console.log(materials);
}
}
Here I'm searching for an object with name - obname. And _objs is storing all the objects in the scene. I am then looking for the object in the array and printing its name out. Please check the screenshot attached. The objects is found and its name is printed. But when I use get_object_by_name() it says that its not found.
Any help would be appreciated. :)