[ODE] Bjarne Stroustrup sings Snoop Dogg
Martin C. Martin
martin at metahuman.org
Tue Apr 30 14:30:02 2002
This is a multi-part message in MIME format.
--------------BF5B97BC2C62B1B2038366B8
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Here are the new C++ rappers for the ODE. These ones use inheritance,
so that e.g. dBallAndSocketJoint is derived from dJoint.
This breaks test_chain2, so I've included a fixed version.
odecpp.h won't quite compile out of the box: you need to get rid of
dUniversalJoint::getAnchor2(). I've also included wrappers for the
Transform/Rotate functions I posted earlier, as well as equivalent ones
for dGeoms. In other words, anyone should be able to use odecpp.h, just
delete wrappers for functions/classes you don't have.
Cheers,
Martin
--------------BF5B97BC2C62B1B2038366B8
Content-Type: application/x-unknown-content-type-hfile;
name="odecpp.h"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="odecpp.h"
LyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioNCiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqDQogKiBPcGVuIER5
bmFtaWNzIEVuZ2luZSwgQ29weXJpZ2h0IChDKSAyMDAxIFJ1c3NlbGwgTC4gU21pdGguICAg
ICAgICAgICAgKg0KICogICBFbWFpbDogcnVzc0BxMTIub3JnICAgV2ViOiB3d3cucTEyLm9y
ZyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoNCiAqICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAq
DQogKiBUaGlzIGxpYnJhcnkgaXMgZnJlZSBzb2Z0d2FyZTsgeW91IGNhbiByZWRpc3RyaWJ1
dGUgaXQgYW5kL29yICAgICAgICAgKg0KICogbW9kaWZ5IGl0IHVuZGVyIHRoZSB0ZXJtcyBv
ZiB0aGUgR05VIExlc3NlciB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20gKGRHZW9tSUQgZ2VvbSkNCiAgICB7IGRHZW9tVHJhbnNmb3JtU2V0
R2VvbShfaWQsIGdlb20pOyB9DQogIGRHZW9tSUQgZ2V0R2VvbSgpIGNvbnN0DQogICAgeyBy
ZXR1cm4gZEdlb21UcmFuc2Zvcm1HZXRHZW9tKF9pZCk7IH0NCn07DQoNCg0KI2VuZGlmDQoj
ZW5kaWYNCg==
--------------BF5B97BC2C62B1B2038366B8
Content-Type: application/x-unknown-content-type-cppfile;
name="test_chain2.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="test_chain2.cpp"
LyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioNCiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqDQogKiBPcGVuIER5
bmFtaWNzIEVuZ2luZSwgQ29weXJpZ2h0IChDKSAyMDAxIFJ1c3NlbGwgTC4gU21pdGguICAg
ICAgICAgICAgKg0KICogICBFbWFpbDogcnVzc0BxMTIub3JnICAgV2ViOiB3d3cucTEyLm9y
ZyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoNCiAqICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAq
DQogKiBUaGlzIGxpYnJhcnkgaXMgZnJlZSBzb2Z0d2FyZTsgeW91IGNhbiByZWRpc3RyaWJ1
dGUgaXQgYW5kL29yICAgICAgICAgKg0KICogbW9kaWZ5IGl0IHVuZGVyIHRoZSB0ZXJtcyBv
ZiB0aGUgR05VIExlc3NlciBHZW5lcmFsIFB1YmxpYyAgICAgICAgICAgICoNCiAqIExpY2Vu
c2UgYXMgcHVibGlzaGVkIGJ5IHRoZSBGcmVlIFNvZnR3YXJlIEZvdW5kYXRpb247IGVpdGhl
ciAgICAgICAgICAqDQogKiB2ZXJzaW9uIDIuMSBvZiB0aGUgTGljZW5zZSwgb3IgKGF0IHlv
dXIgb3B0aW9uKSBhbnkgbGF0ZXIgdmVyc2lvbi4gICAgKg0KICogICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICoNCiAqIFRoaXMgbGlicmFyeSBpcyBkaXN0cmlidXRlZCBpbiB0aGUgaG9wZSB0aGF0IGl0
IHdpbGwgYmUgdXNlZnVsLCAgICAgICAqDQogKiBidXQgV0lUSE9VVCBBTlkgV0FSUkFOVFk7
IHdpdGhvdXQgZXZlbiB0aGUgaW1wbGllZCB3YXJyYW50eSBvZiAgICAgICAgKg0KICogTUVS
Q0hBTlRBQklMSVRZIG9yIEZJVE5FU1MgRk9SIEEgUEFSVElDVUxBUiBQVVJQT1NFLiBTZWUg
dGhlIEdOVSAgICAgICoNCiAqIExlc3NlciBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlIGZvciBt
b3JlIGRldGFpbHMuICAgICAgICAgICAgICAgICAgICAgICAqDQogKiAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgKg0KICogWW91IHNob3VsZCBoYXZlIHJlY2VpdmVkIGEgY29weSBvZiB0aGUgR05VIExl
c3NlciBHZW5lcmFsIFB1YmxpYyAgICAgICoNCiAqIExpY2Vuc2UgYWxvbmcgd2l0aCB0aGlz
IGxpYnJhcnkgKHNlZSB0aGUgZmlsZSBMSUNFTlNFLlRYVCk7IGlmIG5vdCwgICAqDQogKiB3
cml0ZSB0byB0aGUgRnJlZSBTb2Z0d2FyZSBGb3VuZGF0aW9uLCBJbmMuLCA1OSBUZW1wbGUg
UGxhY2UsICAgICAgICAgKg0KICogU3VpdGUgMzMwLCBCb3N0b24sIE1BIDAyMTExLTEzMDcg
VVNBLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoNC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