hello,
this is due to light slipping from box to ground.
You can stop object slipping.
Slip is combinated from slip for ground and object.
So add this after loading ground:
Code:
raydium_ode_element_slip_name("ground",0);
And after when creating object just adjust the slip parameter of box
Code:
raydium_ode_element_slip_name("element1",0);
idem for box 2.
After this value are stable (at one 1e-6) which is ode precision.
Here is the code:
Code:
/*
Raydium - CQFD Corp.
http://raydium.org/
License: GPL - GNU General Public License, see "gpl.txt" file.
*/
/*This is a HOWTO file to show how to point an object*/
#include "raydium/index.c"
int object1, object2; /*variables for the 2 objects used in the demo*/
/*function to create a pair of objects in the scene, near 0,0,0*/
void create_objects(void)
{
object1=raydium_ode_object_find("OBJ1");
object1=raydium_ode_object_create ("OBJ1");
raydium_ode_object_box_add("element1",object1,1,RAYDIUM_ODE_AUTODETECT,0,0,RAYDIUM_ODE_STANDARD,0,"crate.tri");
raydium_ode_element_slip_name("element1",0);
object2=raydium_ode_object_find("OBJ2");
object2=raydium_ode_object_create ("OBJ2");
raydium_ode_object_box_add("element2",object2,5,RAYDIUM_ODE_AUTODETECT,0,0,RAYDIUM_ODE_STANDARD,0,"crate.tri");
raydium_ode_object_move_3f (object2,2,0,0);
raydium_ode_element_slip_name("element2",0);
}
void display(void)
{
/*3 variables for the pointing */
dReal pos[3]; /*position of the pointed point */
dReal dist; /*distance of the pointed point from de point of view*/
int id_pointed; /*id of the pointed object */
raydium_joy_key_emul();
if(raydium_key_last==1027)
exit(0);
/*checking the id of the object pointed, at a maximum of 101 units of distance */
id_pointed = raydium_ode_mouse_pick(101,pos,&dist);
raydium_clear_frame();
/* [ place your camera here ] */ raydium_camera_look_at(10,-2,2,0,0,0);
/* [ draw here ] */ raydium_ode_draw_all(0);
/* we put the info on the screen each frame */
raydium_osd_printf(2,98,18,0.5,"font2.tga","HOW TO POINT AN OBJECT",id_pointed);
raydium_osd_printf(2,95,18,0.5,"font2.tga","Id of object:%d",id_pointed);
raydium_osd_printf(2,92,18,0.5,"font2.tga","Position of the pointed point: (%f, %f, %f)",pos[0],pos[1],pos[2]);
raydium_osd_printf(2,89,18,0.5,"font2.tga","Distance to the pointed point: %f (raydium)units.",dist);
raydium_rendering_finish();
}
int main(int argc, char **argv)
{
raydium_init_args(argc,argv);
raydium_window_create(640,480,RAYDIUM_RENDERING_WINDOW,"How to point an object");
raydium_texture_filter_change(RAYDIUM_TEXTURE_FILTER_TRILINEAR);
raydium_window_view_perspective(60,0.01,2500); /* fov 60 + near and far planes */
raydium_fog_disable();
raydium_light_enable();
raydium_light_on(0);
raydium_light_conf_7f(0,50,150,200,1000000,1,0.9,0.7); /* id, pos, intensity and color (RGB) */
raydium_background_color_change(1,0.9,0.7,1);
raydium_sky_box_cache();
/* [ place base scene here ] */ raydium_ode_ground_set_name("cocorobix.tri");
raydium_ode_element_slip_name("ground",0);
/* create a pair of objects to have something to point to */
create_objects();
/*forcing the render of a cursor in the mouse position*/
raydium_osd_cursor_set("BOXcursor.tga",4,4);
raydium_callback(&display);
return(0);
}
/* EOF */
Have a nice day
Ouille.