• Content count

  • Joined

  • Last visited

  • Days Won


JohnK last won the day on January 23

JohnK had the most liked content!

1 Follower

About JohnK

  • Rank
    Advanced Member

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    England, Buckinghamshire

Recent Profile Visitors

3,935 profile views
  1. Absolute positioning

    Probably worth reading the documentation on rotations and pivots. Start here and follow the further reading links. In a way you answer your own question. If you want to position a mesh based on its CoG it position will always be (0, 0, 0) since the CoG moves with the mesh and the positions of everything else in the world would have to be recalculated, so you have changed the coord system. So for positioning it is best to maintain one world coord system and allow the CoG to move in the world. On the other hand since rotations generally take place about a CoG is is best to form axes local to the CoG, those in local space to calculate and perform rotations. So you need two coordinate systems for the calculations. Of course Babylon.js does all this internal work for you. Consider the two boxes in the following PG In World Space the CoG for box1 is (0, 0, 0) is its position and the CoG for box2 is (4, 2, 3) also its position. To rotate box2 based on box2's CoG means to rotate box2 about the point (4, 2, 3). Take a rotation about box2's CoG of PI/4 about an axis parallel to the world axis. How do you calculate the new positions of the box corners in the world space? Well it is more straight forward to do rotations about the origin rather than an arbitrary point. In practice the only way to do rotations about an arbitrary point is to treat that point as an origin and use a different set of axes, ie those in local space, through this point as origin. Do the rotation in the local space and then calculate the world space for the corners. In Babylon.js rotations are about the local axes in local space and the engine does the corner calculations for you. Hence box2.rotation.y = Math.PI/4 is a rotation about the CoG in local space. When you need to rotate a box about some other point and not its position you need to set and use a pivot.
  2. Power impulse

    For the ball to hit exactly the place on the ground that was clicked on you need to know the acceleration due to gravity, G, that is being used in the physics engine. Given the horizontal linear velocity, V, of the ball towards the click point you can calculate the speed of the ball ||V|| and you can also calculate the horizontal distance, D, between the ball and click point. Then the time, T, to reach the click point will be found from T = D/||V||. So you now need a vertical velocity W such that after a time T the vertical displacement will be 0, this can be found using Newton's equations of motion in this case 0 = WT - 0.5GT*T.
  3. Сoordinates to the object

  4. Holes in extruded shape

    One way is to merge all of the 'sideHole's into one mesh before using CSG
  5. Сoordinates to the object

    Examining 'pick' in the console shows that 'pickedPoint' is what you need.
  6. Change edges of decahedron

    Another possibility Basically done by examining the positions of the vertices, determining which need to be moved and changing their values.
  7. Simple furMaterial

    It you do not need the animation then would the lower level mode not suit you? Note number of segments increased to "thin" fur
  8. Creating Constant-Width 2D Lines

    Simplest way is probably just rotate the line about x axis
  9. Line System with a UV

    This could be adapted to change thickness along its length if needed. Worth a look.
  10. Something like this?
  11. create ground mesh from a plane

    Hi @yokewang and welcome to the forum. @Amarth2Estel gave an excellent solution a little lost in the PG. Since you cannot change the sideOrientation to BABYLON.Mesh.DOUBLESIDE you cannot see the plane from the position of the camera. A change to camera type and position get you
  12. The default order is YXZ locally. I do remember at some point quite a time ago a comment in the code somewhere that order was a a 'to do'. The function does work correctly so it might be a good job that the order YZX is ignored.
  13. Absolute Position and Pivot Point

    It could perhaps be even more? In starting to re-write the documentation and the PG examples examples that go with it I came across a situation where a further decision needs to be considered. I will follow the issue with the reason for it. Issue Under the breaking change where only the pivot is changed I would expect the following to apply :- A box having width 8, height 4 and depth 2 and origin at (0, 0, 0) is to have a pivot set at its right front lower corner (4, -2, -1) The pivot need to be translated (4, -2, -1) so set the matrix M for this translation. however Box.setPivotMatrix(M) places the pivot at (-4, 2, 1) You can see this in the PG So to place the pivot at (4, -2, -1) requires M to be set using the negative translation (-4, 2, 1) as seen in the PG Decision Possibilities leave the function setPivotMatrix alone and ensure the documentation clearly states that that the matrix needs to use the inverse translation; change the function setPivotMatrix to work with the actual translation, if so the function setPivotPoint (and possibly getPivotPoint and getAbsolutePivotPoint) would need changing; something I haven't thought of. Reasons The original function moved the mesh and so, as in the given example, to place the pivot at the right front lower corner required the translation of the box to be in the opposite direction - see PG using stable version before translating the box back to its original position. The function setPivotMatrix still follows this procedure.