Raydium 3D Game Engine

Official forum for everything about Raydium, ManiaDrive, MeMak, ...
It is currently Thu Mar 28, 2024 8:48 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun Feb 03, 2008 1:07 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
I am preparing a set of howto .c files showing certain features in raydium.
I have finished the first one: how_to_point_an_object.c however when i point certain faces of the the nearest box then the values are constantly increasing.
Is there a reason?

Here 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");
   
    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);   
}

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");

/* 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 */


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 03, 2008 8:38 pm 
Offline

Joined: Sun Oct 09, 2005 10:46 pm
Posts: 759
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 04, 2008 3:41 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Thanks.
Can we assume this is a patch for this particular situation or slip 0 should be set generally in simulations/games?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 04, 2008 6:55 pm 
Offline

Joined: Sun Oct 09, 2005 10:46 pm
Posts: 759
Hello,

Normal slip in your app is very small (not the coefficient but the slip effect). So not really perceptible. But in your application it's a bad effect that can lead question.

I think we have to add this only.

have a nice day
Ouille


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 28 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group