Jump to content

how to set mesh's center and how to setPhysicsState at heightmap


thecco
 Share

Recommended Posts

hello 

 

i have 3 question

 

first. i want to set mesh's center 

(I do not know correct - if using setpivotposition is correct, how can i make matrix)

 

 

second,  check collision in Uneven ground.

 

 

last. how to make Underwater.

 

i know BABYLON is not support  doubleside.

 

Happy New Year..

 

post-5970-0-21397200-1388656888_thumb.jp

(1/2 question image)

 

 

 

 

 

Link to comment
Share on other sites

For your first question: do you want to set the center of your mesh, let's say, at the barycenter of its vertices and then move the mesh at the right location or actually, you don't really mind about its position but visually you want its vertices to be at the right places?

 

+: vertex

0: origin of parent space (or world space if no parent)

1: origin of local space ("mesh center")

x: where you would like to have the vertices

 

Barycenter

 

     0

 

+ + + + + +

+             +

+      1     +                              x

+             + 

+ + + + + +

 

Result:

 

     0

 

                                        + + + + + +

                                        +             +

                                        +      1     + 

                                        +             + 

                                        + + + + + +

 

Center it's somewhere...

 

     0

 

+ + + + + +

+             +

+             +                              x

+             +          1

+ + + + + +

 

 

Result:

 

     0

 

                                       + + + + + +

                                       +             +

                                       +       x    +

                                       +             +          1

                                       + + + + + +

 

For both you will have to set mesh.position at the right location so the cloud of vertices will translate with it. Just be aware that rotation will be different since the center of the rotation will be the center of your mesh (representing by 1). You can indeed change this behavior thanks to the pivot matrix. If you have the position of your pivot, you can create the matrix with BABYLON.Matrix.Translation and then call mesh.setPivotMatrix.

var p = BABYLON.Matrix.Translation(x,y,z); // (x,y,z) must be expressed in parent spacemesh.setPivotMatrix(p);

I give you only some pists, I hope it's enough. Don't hesitate if I have to be clearer.

Link to comment
Share on other sites

  • 2 weeks later...

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...