Jump to content

Export mesh with pivot point at origin


qqdarren
 Share

Recommended Posts

Not sure if this is a Babylon or Blender question. I've made a single mesh (an extruded letter) in Blender, exported it, and imported it into my BabylonJS script. I then have an ArcRotateCamera which rotates round it. by setting `camera.target` to be the imported mesh.

 

       Q = newMeshes[0];

       Q.position = new BABYLON.Vector3(5, -9, -15);

       camera.target = Q;
       camera.radius = 1.2;

 

It works, but the camera is sometimes further away from the letter, sometimes crashing through it. I.e. the reference point it is rotating around is the bottom-left of the glyph mesh.

 

In Blender I'd positioned the bottom left of the mesh at the origin. So I moved it, so that the centre of the mesh is at the origin, and exported again. But that made no difference at all. I think all I've done is move the position of the mesh in the blender scene, whereas I want to alter the internal reference point of just the mesh?

 

--------------------------------------------

BTW, I found this http://www.html5gamedevs.com/topic/10118-set-origin-or-pivot-of-mesh/  But when I tried that:

 

    var matrix = new BABYLON.Matrix.TranslationToRef(0.23, 0, 0.15, Q.getPivotMatrix());
    Q.setPivotMatrix(matrix);

 

I get an error from inside the Babylon.js file itself:

 

    TypeError: this._pivotMatrix.multiplyToRef is not a function
    ...s.position.z,this._localTranslation);if(this._pivotMatrix.multiplyToRef(this._lo...

 

(But, anyway, I really want to fix the model, not have to hack solutions over in the JavaScript.)

Link to comment
Share on other sites

This fixed the setPivotMatrix() problem:

 

    var matrix = BABYLON.Matrix.Translation(-0.46, 0, -0.30);
    Q.setPivotMatrix(matrix);

 

The magic numbers there came from the babylon file:

 

      "position":[-0.4571,0,-0.295]

Link to comment
Share on other sites

Aha, I'd just dragged it.

 

My first attempt, just now, to use "Object->Transform->Geometry to Origin" did nothing, as I did it on the curve, then converted to a mesh.

 

My second attempt did work, yay! So the process is:

   Make text & extrude it

   Object -> Convert to mesh

   Object->Transform->Geometry to Origin

   File > Export to babylon format

 

Thanks :-)

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