Raydium 3D Game Engine

Official forum for everything about Raydium, ManiaDrive, MeMak, ...
It is currently Tue Mar 19, 2024 3:53 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: ODE Cylinder
PostPosted: Fri Jan 11, 2008 4:42 am 
Offline

Joined: Tue Jan 08, 2008 3:10 pm
Posts: 10
I think the only thing missing is the ODE recording function.
The ODE cylinder appears to be bugged as it just won't stop moving. I compiled against ODE 0.9 and got the same behavior, but I haven't tried the latest svn snapshot yet.

headers/ode.h
Code:
679,689d678
< __rayapi int raydium_ode_object_cylinder_add (char *name, int group, dReal mass, dReal radius, dReal length, signed char type, int tag, char *mesh);
< /**
< This function will add an new "cylinder" element to an object (##group##).
< Arguments are the same as ##raydium_ode_object_sphere_add## (see above) but
< ##length##, used for box sizes. As for spheres, you can
< use ##RAYDIUM_ODE_AUTODETECT##.
< Again, Things like  ##RAYDIUM_ODE_AUTODETECT*2## are ok, meaning
< "twice the detected size".
< **/
<
<


ode.c
Code:
1170,1261d1169
< //CYLINDER
< int raydium_ode_object_cylinder_add(char *name, int group, dReal mass, dReal radius, dReal length, signed char type, int tag, char *mesh)
< {
< int i;
< dMass m;
< dReal sizes[3];
< dReal tx, ty;
<
< //if(m.mass <= 0) { m.mass = 1; }
<
< if(raydium_ode_element_find(name)>=0)
<     {
<     raydium_log("ODE: Cannot add element \"%s\": name already exists",name);
<     return -1;
<     }
<
< if(!raydium_ode_object_isvalid(group))
<     {
<     raydium_log("ODE: Error: object not found while adding \"%s\"",name);
<     return -1;
<     }
<
< if(tag<0)
<     {
<     raydium_log("ODE: Error: Element creation failed: negative tags are forbidden");
<     return -1;
<     }
<
< // First element is reserved
< for(i=1;i<RAYDIUM_ODE_MAX_ELEMENTS;i++)
<     if(!raydium_ode_element[i].state)
<      {
<      strcpy(raydium_ode_element[i].name,name);
<      raydium_ode_element[i].object=group;
<      raydium_ode_element[i].user_tag=tag;
<      if(strlen(mesh))
<      {
<       raydium_ode_element[i].mesh=raydium_object_find_load(mesh);
<       if(radius<0) // AUTODETECT
<       {
<       radius=raydium_object_find_dist_max(raydium_ode_element[i].mesh)*-radius;
<      }
<
<       if(length < 0) // Autodetect length
<       {
<       //int ratio=tx;
<        int ratio = length;
<          raydium_object_find_axes_max(raydium_ode_element[i].mesh,&tx,&ty,&length);
<     //tx*=(-ratio);
<     //ty*=(-ratio);
<     //tz*=(-ratio);
<       length*=(-ratio);
<      }
<      }
<
<      if(type==RAYDIUM_ODE_STANDARD)
<      {
<         raydium_ode_element[i].body=dBodyCreate(raydium_ode_world);
<         dMassSetCylinder(&m,1,3,radius,length);
<    dMassAdjust(&m,mass);
<         dBodySetMass(raydium_ode_element[i].body,&m);
<         dBodySetData(raydium_ode_element[i].body,&raydium_ode_element[i]);
< //   dBodySetAutoDisableSF1(raydium_ode_element[i].body,1);
<      }
<      else raydium_ode_element[i].body=0;
<
<      raydium_ode_element[i].geom=dCreateCylinder(0,radius,length);
<      raydium_ode_element[i].state=type;
<      dGeomSetBody(raydium_ode_element[i].geom,raydium_ode_element[i].body);
<      dGeomSetData(raydium_ode_element[i].geom,&raydium_ode_element[i]);
<      dSpaceAdd(raydium_ode_object[group].group,raydium_ode_element[i].geom);
<      raydium_ode_element_material(i,RAYDIUM_ODE_MATERIAL_DEFAULT);
<      raydium_ode_element_slip(i,RAYDIUM_ODE_SLIP_DEFAULT);
<      raydium_ode_element[i].distant=raydium_ode_network_distant_create;
<      raydium_ode_network_distant_create=0;
<      if(!raydium_ode_network_next_local_only)
<         raydium_ode_network_element_new(i);
<      raydium_ode_network_next_local_only=0;
<
<      //sizes[0]=tx;
<      //sizes[1]=ty;
<      //sizes[2]=tz;
<      //raydium_ode_capture_internal_create(RAYDIUM_ODE_RECORD_NEWBOX,i,sizes,mesh);
<
<      return i;
<      }
< raydium_log("ODE: No more element slots ! aborting \"%s\" creation",name);
< return -1;
<
< }
< // END CYLINDER
<
3711d3618
<
3759,3769d3665
<
<       else
<       if(dGeomGetClass(raydium_ode_element[i].geom)==dCylinderClass)
<            {
<       float cradius;
<       float clength;
<
<       dGeomCylinderGetParams(raydium_ode_element[i].geom, &cradius, &clength);
<          //printf("%f-%f\n", cradius, clength);
<          glutWireCylinder(cradius, clength, 10, 5);
<             }


ode_net.c
Code:
82,85d81
<     case dCylinderClass:
<       raydium_ode_network_distant_create=1;
<       elem=raydium_ode_object_cylinder_add(name,group,1,get[0],get[1],RAYDIUM_ODE_STATIC,tag,mesh);
<       break;


reg_api.c
Code:
156d155
< PHP_i_sifffiis(raydium_ode_object_cylinder_add);


headers/myglut.h
Code:
91d90
< __rayapi void glutWireCylinder(GLdouble radius, GLdouble length, GLint slices, GLint stacks);


myglut.c
Code:
88,102d87
< // glutWireCylinder
< void glutWireCylinder(GLdouble radius, GLdouble length, GLint slices, GLint stacks)
< {
<   static GLUquadricObj *quadObj=NULL;
<
<   if(!quadObj)
<     quadObj=gluNewQuadric();
<
<   gluQuadricDrawStyle(quadObj, GLU_LINE);
<   gluQuadricNormals(quadObj, GLU_SMOOTH);
<
<   glTranslated(0, 0, -(length/2));
<   gluCylinder(quadObj, radius, radius, length, slices, stacks);
< }
<


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 20, 2008 9:10 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Nice. This patch is a good start for Cylinder RayODE support once ODE will correctly support this shape :
http://opende.sourceforge.net/mediawiki ... tection%29

Thanks for this patch !


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 20, 2008 9:23 pm 
Offline

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

I was waiting for your advice to add cylinder to the svn.

Cylinder are quite well supported by ode. Except for cylinder to cylinder collide.

Including this patch allow use of cylinder, and when opcode add this collider everything will be ok.

Do you really want to wait until ode completly integrate them (it seem that actual behavior is enough for ode user so it can be long).

Have a nice day
Ouille


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 20, 2008 9:52 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
RayODE is supposed to make things simple for Raydium users, so IMHO we must provide stable and complete shapes. It will be hard to explain why cylinders can't collide each other or why they're not always stable on the ground (Trimesh/Cylinder).

But until ODE "full cylinder support", we can provided Cylinder as an option (config.h) if it became a frequent request, I think.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 21, 2008 2:33 pm 
Offline

Joined: Tue Jan 08, 2008 3:10 pm
Posts: 10
It was my pleasure to make it, as I enjoy working with Raydium. Not to mention, it's basically just your own code, copied and pasted with a few adjustments :)

For the time being we might change
dMassSetCylinder(&m,1,3,radius,length);
to
dMassSetSphere(&m,1,radius);
as it seems to help with trimesh collision and it is how cylinders are implemented in the ODE demos.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 09, 2008 9:21 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
If someone can release a patch file, we can add the file (and a small readme) to the new "contrib" directory, so people brave enough can use this new shape :)


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 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:  
Powered by phpBB® Forum Software © phpBB Group