diff --git a/main.go b/main.go index d4e1b12..85a9d89 100755 --- a/main.go +++ b/main.go @@ -13,7 +13,7 @@ func main() { pvd := pgo.CreatePvd(f) println("Pvd:", pvd) - println("connect:", pvd.Connect(pvdTr, pgo.PvdInstrumentationFlag_eALL)) + println("connected to PVD:", pvd.Connect(pvdTr, pgo.PvdInstrumentationFlag_eALL)) ts := pgo.NewTolerancesScale(1, 9.81) p := pgo.CreatePhysics(f, ts, false, pvd) @@ -55,10 +55,21 @@ func main() { dynBox2 := pgo.CreateDynamic(p, tr2, box.ToGeometry(), pMat, 10, shapeOffset) s.AddActor(dynBox2.ToActor()) + //Add sphere + v = pgo.NewVec3(0, 16, 0) + tr3 := pgo.NewTransform(v, qID) + dynSphere := pgo.CreateDynamic(p, tr3, pgo.NewSphereGeometry(3).ToGeometry(), pMat, 10, shapeOffset) + s.AddActor(dynSphere.ToActor()) + + //Add capsule + v = pgo.NewVec3(0, 20, 0) + tr4 := pgo.NewTransform(v, qID) + dynCapsule := pgo.CreateDynamic(p, tr4, pgo.NewCapsuleGeometry(0.25, 0.5).ToGeometry(), pMat, 10, shapeOffset) + s.AddActor(dynCapsule.ToActor()) + for { s.Simulate(1 / 60.0) - a, b := s.FetchResults(true) - println("a:", a, "; b:", b) + s.FetchResults(true) } p.Release() diff --git a/pgo/libs/libphysx-c.a b/pgo/libs/libphysx-c.a index 9a89d38..02b81e5 100755 Binary files a/pgo/libs/libphysx-c.a and b/pgo/libs/libphysx-c.a differ diff --git a/pgo/pgo.go b/pgo/pgo.go index 74fb315..ff29f8b 100755 --- a/pgo/pgo.go +++ b/pgo/pgo.go @@ -272,6 +272,22 @@ func NewBoxGeometry(hx, hy, hz float32) *BoxGeometry { } } +type CapsuleGeometry struct { + cCg C.struct_CPxCapsuleGeometry +} + +func (bg *CapsuleGeometry) ToGeometry() *Geometry { + return &Geometry{ + cG: C.CPxCapsuleGeometry_toCPxGeometry(&bg.cCg), + } +} + +func NewCapsuleGeometry(radius, halfHeight float32) *CapsuleGeometry { + return &CapsuleGeometry{ + cCg: C.NewCPxCapsuleGeometry(C.float(radius), C.float(halfHeight)), + } +} + type Actor struct { cA C.struct_CPxActor } diff --git a/pgo/physx-c/CPxCapsuleGeometry.h b/pgo/physx-c/CPxCapsuleGeometry.h new file mode 100755 index 0000000..9f59419 --- /dev/null +++ b/pgo/physx-c/CPxCapsuleGeometry.h @@ -0,0 +1,19 @@ +#ifndef CPxCapsuleGeometry_H +#define CPxCapsuleGeometry_H + +#ifdef __cplusplus +extern "C" { +#endif + + struct CPxCapsuleGeometry + { + CPxReal radius, halfHeight; + }; + + CPxAPI CPxInline CSTRUCT CPxCapsuleGeometry NewCPxCapsuleGeometry(CPxReal radius, CPxReal halfHeight); + +#ifdef __cplusplus +} +#endif + +#endif // !CPxCapsuleGeometry_H diff --git a/pgo/physx-c/CPxGeometry.h b/pgo/physx-c/CPxGeometry.h index 56726a4..24400ce 100755 --- a/pgo/physx-c/CPxGeometry.h +++ b/pgo/physx-c/CPxGeometry.h @@ -3,6 +3,7 @@ #include "CPxBoxGeometry.h" #include "CPxSphereGeometry.h" +#include "CPxCapsuleGeometry.h" #ifdef __cplusplus extern "C" { @@ -27,12 +28,14 @@ extern "C" { CENUM CPxGeometryType type; }; - CPxAPI CPxInline CSTRUCT CPxSphereGeometry CPxGeometry_toCPxSphere(CSTRUCT CPxGeometry); + CPxAPI CPxInline CSTRUCT CPxSphereGeometry CPxGeometry_toCPxSphereGeometry(CSTRUCT CPxGeometry); CPxAPI CPxInline CSTRUCT CPxGeometry CPxSphereGeometry_toCPxGeometry(CSTRUCT CPxSphereGeometry*); - CPxAPI CPxInline CSTRUCT CPxBoxGeometry CPxGeometry_toCPxBox(CSTRUCT CPxGeometry); + CPxAPI CPxInline CSTRUCT CPxBoxGeometry CPxGeometry_toCPxBoxGeometry(CSTRUCT CPxGeometry); CPxAPI CPxInline CSTRUCT CPxGeometry CPxBoxGeometry_toCPxGeometry(CSTRUCT CPxBoxGeometry*); + CPxAPI CPxInline CSTRUCT CPxCapsuleGeometry CPxGeometry_toCPxCapsuleGeometry(CSTRUCT CPxGeometry); + CPxAPI CPxInline CSTRUCT CPxGeometry CPxCapsuleGeometry_toCPxGeometry(CSTRUCT CPxCapsuleGeometry*); #ifdef __cplusplus } diff --git a/pgo/wrap.c b/pgo/wrap.c index 6904302..143a2ce 100755 --- a/pgo/wrap.c +++ b/pgo/wrap.c @@ -25,4 +25,5 @@ #include #include #include -#include \ No newline at end of file +#include +#include \ No newline at end of file