How to read updated cloth particles positions - physx

Currently, I'm reading the Krishna Kumar's book "Learning Physics Modeling with PhysX".
Source code for the cloth example uses a method getRenderBuffer() to get points, triangles and quads that we define for the mesh description but he doesn't explain anything about this method on his book.
What does getRenderBuffer() actually do? Is this the (only) way to get updated cloth particles positions? If so, since getRenderBuffer() is a PxScene object's method, what should we do when we have lots of cloth actors in the scene?

Related

What is Buffer Geometry of three.js?

The explanation presented in the three.js documentation about the command BufferGeometry is quite hard to understand to me.
It says..
BufferGeometry is a representation of mesh, line, or point geometry.
Includes vertex positions, face indices, normals, colors, UVs, and
custom attributes within buffers, reducing the cost of passing all
this data to the GPU.
I didn't quite understand what those sentences meant.
What is the purpose of BufferGeometry? How do you visualize BufferGeometry in real life?
Thank you!
An instance of this class holds the geometry data intended for rendering.
If you want to visualize these data, you have to define a material and the type of 3D object (mesh, lines or points). The code example of the documentation page shows the respective JavaScript statements.

Three.js: Make raycaster's direction the same as object's

all!
I'm currently making a game in THREE.js and while I've got the 'vertical' collision with the ground sorted with a raycaster, I am having trouble with horizontal collision. I've consulted a few tutorials, but they don't do what I want them to.
Basically, I've got a load of cubes. I've given them a random y-axis rotation and used translate to make them move 'forward' - pretty basic stuff. How do I get a raycaster to point the same direction as the cube, almost like a line sticking out of its 'nose'? i.e. how do I get a raycaster's direction to copy that of an object?
It's been a while since I've been on here, but kind regards anyway,
Matthew

cloth with ammo softBodyHelpers.CreatePatch

I'm trying to use the three.js physics cloth demo to create a tablecloth but the resulting cloth is always a vertical banner. Is uses the ammo softBodyHelpers.CreatePatch function to make the softbody but I could not find doc on how this can be used. Does any one know how this can be adapted to make a table cloth ? My initial mesh looks fine as a table cloth but as soon as the first physics loop updates the mesh it moves immediately vertices into a vertical banner.
According to ammo.js github page:
ammo.js is a direct port of the Bullet physics engine to JavaScript,
using Emscripten. The source code is translated directly to
JavaScript, without human rewriting, so functionality should be
identical to the original Bullet.
Looking at the documentation for Bullet's SoftBodyHelpers, CreatePatch is indeed meant for rectangular geometry only.
Good news, though - there's a separate function called CreateEllipsoid.
Do you have any other static geometry in the scene for the cloth to collide with? Otherwise it will just be a sheet, falling through frictionless space.

best geometry for kirigami in three.js?

I'm trying to model simple pop-up kirigami objects in three.js. Here are some real-world examples:
At the moment I can build them using Shape objects, first drawn in 2d and then rotated and translated into place.
It works, but I wonder if there's a more appropriate sort of geometry I should be using, to recreate the whole sheet of paper as a single object in three.js, instead of a collection of individual surfaces. Ultimately I'd like to be able to open and close the popup.
I've read and reread the docs and examples, but I can't figure this one out. I'm new to threejs and dazzled by its capabilities, but it's a steep learning curve. Thanks for any wisdom.

three.js, clothing and shape keys

How can I dress a human body?. I have imported the body model and t-shirt in two separated meshes. The human body includes shape keys.
But when I modify the morphTargetInfluences key of the body, the t-shirt doesn't fit in the new body shape.
How can I make the T-shirt fits when the key change the value?, How can I do that using three.js?
I'm using the version 1.4.0 of the Three.js exporter (three.js r71) and Blender 2.75a
The point is, your morph targets are only present in your character model and won't magically fit the cloth unfortunately. Apply the morph to the cloth too in your editing tool and morph both equally, this would work without extra effort.
I'm actually also working on a solution for wearable cloth, i'll give shared vertex buffers a try where the vertices "connects" to the vertices of the domain model with a relative offset, so you would just have to take care about assigning the cloth once, instead applying and exporting whole morph target sets at all.
The downside would be, your vertices has to stay the same, once you modify the mesh, you'd have to export all related cloth again. This can be basically solved by a automated process, like one which searches for nearest vertices, but cloth is usually extruded from the base mesh to perfectly "fit" without intersections, so this isn't really a surprising thing.

Resources