Comments (6)
I'm creating it the following way, here's TriangleMesh (physics
is PhysicsFoundation):
And here's TriangleMeshGeometry (mesh
is TriangleMesh from previous step):
The snippets above are a pretty straightforward port of the physx documentation (I like PhysX 3 docs better, and nothing has really changed since then):
from physx-rs.
I'm creating it the following way, here's TriangleMesh (
physics
is PhysicsFoundation):And here's TriangleMeshGeometry (
mesh
is TriangleMesh from previous step):The snippets above are a pretty straightforward port of the physx documentation (I like PhysX 3 docs better, and nothing has really changed since then):
Thanks a lot! I wish there were a little more Rusty way to do this, just like the sphere example.
from physx-rs.
Can you please help me once again? I can't build the rigid dynamic:
let indices = o.get_indices(scene.get_data());
let vertices = o.get_vertices_physx(scene.get_data());
let mut mesh_desc = PxTriangleMeshDesc::new();
mesh_desc.obj.points.count = vertices.len() as u32;
mesh_desc.obj.points.stride = std::mem::size_of::<PxVec3>() as u32;
mesh_desc.obj.points.data = vertices.as_ptr() as *const _;
mesh_desc.obj.triangles.count = indices.len() as u32;
mesh_desc.obj.triangles.stride = std::mem::size_of::<[u32; 3]>() as u32;
mesh_desc.obj.triangles.data = indices.as_ptr() as *const _;
let physics = &mut self.foundation;
let params = physx::cooking::PxCookingParams::new(physics).unwrap();
let mut geometry =
match physx::cooking::create_triangle_mesh(physics, ¶ms, &mesh_desc) {
physx::cooking::TriangleMeshCookingResult::Success(geometry) => geometry,
_ => panic!("Oops."),
};
let (_, rotation, translation) =
o.get_transform_matrix().to_scale_rotation_translation();
let translation = PxVec3::new(translation.x, translation.y, translation.z);
let rotation = PxQuat::new(rotation.x, rotation.y, rotation.z, rotation.w);
let scale = PxMeshScale {
scale: PxVec3::new(1.0f32, 1.0f32, 1.0f32).into(),
rotation: PxQuat::new(1.0f32, 1.0f32, 1.0f32, 1.0f32).into(),
};
let geometry = PxTriangleMeshGeometry::new(
geometry.as_mut(),
// &unsafe { PxMeshScale_new() },
&scale,
// PxMeshGeometryFlags::TightBounds,
PxMeshGeometryFlags::empty(),
);
self.foundation
.create_rigid_dynamic(
PxTransform::from_translation_rotation(&translation, &rotation),
&geometry,
material.as_mut(),
1.0f32,
PxTransform::default(),
(),
)
.expect("Couldn't build rigid dynamic actor.")
The Option
returned is always None
. There is nothing I can see in the error callback and the assertion handler. Everything before that was created just fine.
from physx-rs.
Can you please help me once again?
Can you link to a full repository with the code, or simplify it down, or preferably both?
Errors can happen for a lot of reasons (invalid geometry, non-unit quaternion as rotation, etc.). Typically they are shown in the error callback, but I can't verify it from the snippet above.
Do simple shapes (e.g. tetrahedron) with zero transforms work?
from physx-rs.
I found the problem. It was my thinking that we could use the TriangleMesh
with dynamic actors, but we don't. Thanks for taking the time to help me!
from physx-rs.
I found the problem. It was my thinking that we could use the TriangleMesh with dynamic actors, but we don't.
Yeah physx doesn't support those. You may want to look into convex decomposition (with something like V-HACD) to break down triangle mesh into multiple convex ones.
from physx-rs.
Related Issues (20)
- Port PxCooking
- Emit default values in FFI bindings
- Reevaluate structgen HOT 1
- Cleanup C++ source files
- Flow support? HOT 2
- Generate `physx-safe` on top of `physx-sys`
- run error in msvs target HOT 4
- Build error after updating ubuntu HOT 7
- Spring/damper has no effect in driving articulation joint HOT 10
- ActorMap is missing read-only API HOT 2
- Unable to get collision callbacks in bouncing ball example. HOT 6
- Misaligned pointer dereference HOT 24
- How can i remove a Rigid Dynamic actor from scene when it collide with a specific object ? HOT 2
- `pxbind` needs update HOT 1
- iOS support HOT 1
- How to create completion task for passing in scene.step function ?
- Add support for `eDEFAULT` for bitflags (and maybe enums)
- Change MacOS CI to aarch64
- Round out `Controller` trait functions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from physx-rs.