mirror of
https://github.com/bloeys/physx-go.git
synced 2025-12-29 07:58:20 +00:00
Capsule geometry
This commit is contained in:
17
main.go
17
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()
|
||||
|
||||
Binary file not shown.
16
pgo/pgo.go
16
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
|
||||
}
|
||||
|
||||
19
pgo/physx-c/CPxCapsuleGeometry.h
Executable file
19
pgo/physx-c/CPxCapsuleGeometry.h
Executable file
@ -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
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -26,3 +26,4 @@
|
||||
#include <CPxGeometry.h>
|
||||
#include <CPxBoxGeometry.h>
|
||||
#include <CPxSphereGeometry.h>
|
||||
#include <CPxCapsuleGeometry.h>
|
||||
Reference in New Issue
Block a user