[ODE] For Nate

Nate W coding at natew.com
Sat Feb 22 15:01:01 2003


On Sat, 22 Feb 2003, w Wei wrote:

>   I got the joint stuff to work actually, thanks for all your help
> with the suggestions.  Your web site is of great help.

Glad I could help. :-)

> New Question: I posted one about dGeomCCylinderGetParams, where I need
> to get parameters from a capped cylinder geom.  The return types are
> pointers, it strikes me as odd since the two params are just dReals,
> there's no need for the dReal*s.  I'm wondering how you retrieved the
> params in this case

I don't think I ever used that function, but try this:

	dReal Radius = 0;
	dReal Length = 0;

	dGeomCCylinderGetParams (WhateverCylinderID, &Radius, &Length);

This is a very common way to get a C function that "returns" more than one
value.  You have to use pointers (or should I say, Russ had to use
pointers), otherwise the function has no way to set the values of the
variables that were passed in.  (In C++ you can use references instead,
but ODE uses a C-compatible API so it's done with pointers.)

I think it would be cool if C++ supported the perl syntax to do the same
thing:

	(Radius, Length) = dGeomCCylinderGetParams (WhateverCylinderID);

...but I'm not holding my breath.  :-)

-- 

Nate Waddoups
Redmond WA USA
http://www.natew.com