bounding box

aiman

02-09-2012 05:05:41

how can i show bounding box of node????????????????

ianhfar

03-09-2012 12:25:24

Cast your Node to a SceneNode
then set the property ShowBoundingBox to true


eg.
SceneNode scn = this.Node as SceneNode;
scn.ShowBoundingBox = true;

aiman

03-09-2012 23:18:43

i do that but it doesn't appear

ianhfar

04-09-2012 09:18:07

Aiman, any chance of posting you code ?

aiman

06-09-2012 08:03:13

//select 3D model by clicking on it
SceneNode f_select_object()
{
SceneNode p_active_sceneNode = null;
Ray r = new Ray();
//taking intersection point
RaySceneQuery mRaySceneQuery_select = mgr.CreateRayQuery(r);

Point mouse_pos = MousePosition;
mouse_pos.X = mouse_pos.X - 18;
mouse_pos.Y = mouse_pos.Y - 218;
Ray mouseRay_select = cam.GetCameraToViewportRay((float)mouse_pos.X / (float)panel1.Width, (float)mouse_pos.Y / (float)panel1.Height);

mRaySceneQuery_select.Ray = (mouseRay_select);
mRaySceneQuery_select.SetSortByDistance(true);
// Execute query
RaySceneQueryResult result_select = mRaySceneQuery_select.Execute();
RaySceneQueryResult.Iterator itr_select;
// loop through the results
for ( itr_select = result_select.Begin(); itr_select != result_select.End(); itr_select++ )
{
if (itr_select.Value.movable != null)
{
p_active_sceneNode = itr_select.Value.movable.ParentSceneNode;
string nodName = p_active_sceneNode.Name;
string comp1= "obj_";
string comp2= "Ogre/SceneRoot";

for(int i = 0 ; i< 10; i++)
{
nodName = p_active_sceneNode.Name;
bool res1 = compareStart(nodName ,comp1);
bool res2 = compareStart(nodName ,comp2);
if(res1)
{
break;
}
if(res2)
{
p_active_sceneNode = null;
break;
}
p_active_sceneNode = p_active_sceneNode.ParentSceneNode;
}
if(p_active_sceneNode != null)
{
if(compareStart(p_active_sceneNode.Name ,comp1))
{
break;
}
}
}
}
return p_active_sceneNode;
}


// then in mouseclick function
if (e.Button == MouseButtons.Left)
{
if (active_scene_node == null)
{
active_scene_node = f_select_object();
active_scene_node.ShowBoundingBox = true;
}
}




i can catch the object but the bounding box doesn't be shown

Tubulii

11-09-2012 10:36:38

Try this:
MySceneManager.ShowBoundingBoxes = true;
This, of cource, affects all nodes.

Alternatively you could use a debug drawer and draw be aabb manually.

aiman

19-09-2012 09:39:59

MySceneManager.ShowBoundingBoxes = true;
show all bounding boxes , but i want to show bounding box for specific sceneNode

ianhfar

19-09-2012 09:52:46

With out trying to debug your code, some of the reasons why you selected node is not showing a bounding box,
If the your "active_scene_node" is not valid during a screen update
on you button press you check for null, and then proceed to assign the "active_scene_node" but in your " f_select_object()" method, there are cases where it will return null, no check is done on assignment.

eg.

// then in mouseclick function
if (e.Button == MouseButtons.Left)
{
if (active_scene_node == null)
{
active_scene_node = f_select_object(); // This could still be null
active_scene_node.ShowBoundingBox = true;
}
}

aiman

19-09-2012 23:18:45

// then in mouseclick function
if (e.Button == MouseButtons.Left)
{
if (active_scene_node == null)
{
active_scene_node = f_select_object(); ////////// (((((((((((((((((((((( This is not null )))))))))))))))))))))))))
active_scene_node.ShowBoundingBox = true;
}
}
//////////////////////////////
i have scenNode please help me who know how to show bounding box, i want correct code
please please please