Jump to content

Where'd scene.createCompoundImpostor go in v3.x?


fort
 Share

Recommended Posts

I'm trying to create simple physics impostors for relatively complex models (to create CPU-friendly yet fairly accurate hitboxes). I noticed the scene.createCompoundImpostor method would likely work nicely for this sort of thing, but it was dropped in v3.0. 

What is the recommended strategy for v3.0?

As an example, I'd like to create a hitbox for something like this:

VKMabWS.png

...using an array of primitives, like this:

NjPyYCz.png

 

edit: here's another example...

jZhX0HV.png

Link to comment
Share on other sites

Howdy!

The old create compound method was removed since we changed the engine's architecture. I actually thought the function stayed deprecated, but hey - it's better to lose old unused functions :)

The way to do compounds now is to use the parenting system. I don't see your images (I only see "Inline Image 1" as text), so I don't quite know what the use case is, but:

1. choose a parent, and connect the rest of the meshes with it.

2. set the impostors, starting from the children and ending with the parent.

3. run the scene! :)

Here is a simple example: https://playground.babylonjs.com/#LMPPXZ

Link to comment
Share on other sites

Thanks for the quick reply, @RaananW! I've updated the images in the OP—thinking those were critical in describing my particular issue. :o 

Would you mind giving it another look when you get a sec? I'm thinking I may be able to apply your approach by doing the following:

  1. Load in the "cabin" mesh
  2. Create the primitives used for the cabin's (the five, multicolored boxes)
  3. Use the cabin mesh as the parent for the boxes
  4. Set the physics impostors for the boxes

Would that work? I'm basically trying to get a fairly accurate hitbox on the cabin without the processing cost of its out-of-the-box mesh impostor.

Link to comment
Share on other sites

Hi fort,

it all depends on the structure of your mesh. Alternatively, you could connect all meshes using a point-to-point joint (which is the same as creating a compound). This would actually be more stable, IMO.

The "problem" with parenting existing meshes, is that their transformation will change as well. Meaning - you will need to reset their transformation after setting the parent (since they automatically get the parent's transformation)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...