Help with 'walking' on a Goldberg

Dear all,
I am new here! I been trying to modify an existing playground to walk on a glodberg instead of a ground.
Here is the playground

My questions are as follows

  1. Am I setting the gravity correctly ? As each face of the goldberg are oriented differently, I need to make sure the gravity vector is created correctly.
  2. How to fix the rotation and movement of the camera using the arrow keys, based on the face I am on while I walk.
  3. How to find the goldberg face number from the faceId ( returned from Ray picking ) ? The method getFaceNbFromFacetId takes facetId and not faceId. facetId is returned from mousepointer picking but is not returned during ray picking. Basically I like to know which face I am standing on so that I can find the adjustment faces and render content on them, for example

Sorry for so many questions! Thank you kindly for your help.

Regards,
Vpuna

Some confusion in terminology because of different authors, using a ray to pick returns pickinginfo which gives faceId which is equivalent of facetId for a Mesh.

facetId always returns the id of a triangular facet

faceId can be the id of a triangular facet of a mesh or the id of the collection of facets that form a flat surface of a mesh depending on the context

1 Like

Thank you! I just tested it and it works! That answers question 3!
Could you also look at questions 1 and 2 please ?

With boxes placed on adjustment faces

1 Like

Once you know the faceId then faceYAxis gives you the normal to the face and hence the direction for gravity see properties

Without doing any checking I would think that you need to align the camera with faceXAxis, faceYAxis and faceZaxis with forward in terms of faceXAxis and faceZAxis and rotation around faceYAxis. Try camera alignment

thanks @JohnK ! I was able to set the gravity correctly now for each face when I am on it.
Regarding point 2, Since I was using placeOnGoldbergFaceAt to set the camera on the face, I believe it was already orienting itself correctly to the face. As there was no change in the orientation when i set
camera.rotation = BABYLON.Vector3.RotationFromAxis(goldberg.goldbergData.faceXaxis[placeOnFace], goldberg.goldbergData.faceYaxis[placeOnFace], goldberg.goldbergData.faceZaxis[placeOnFace]);

How do I rotate the camera around the faceYAxis ? I see that the mesh has a .rotate function that takes an axis as input. However I dont see a rotate method on the camera .

Also, how do I move forward and backward with respect to faceXAxis and faceZAxis?

Thank you so much for your support!

Was not entirely sure how to do this myself.

Here is an experiment using a TransformNode as a parent to the camera. I tilted the ground and then used the upVector to align the camera with the ground. You will need to experiment further to see if it will work for you.

@JohnK Thanks! that fixed the rotation. Here is the updated project

I was excited and to experiment on the forward and backward movement but quickly realized that the TransformNode does not have moveWithCollisions function :frowning:
Any direction here please ?

Best I csn suggest is to replace TransformNode with an invisible box mesh of a suitable size and then use intersectsMesh

On the objects on the face you are on and maybe adjacent faces.

1 Like

Thanks @JohnK , I will try with an invisible mesh

@JohnK , I actually just tried with the translate method on the TransformNode. It works but I am not sure how to create the right axis .If I use faceXaxis or faceZaxis, it obviously does not move in the direction I am facing. How do I create the axis in the direction I am facing, parallel to the face ? Thank you for your support!