change center of object help please:|
Blitz3D Forums/Blitz3D Beginners Area/change center of object help please:|
| ||
please help me i want to change center of my 3d model how please... i use a pivot but still not working i want to post image to help u understand but i dont know how to upload a pic can u say me... |
| ||
Here is a quick example of how to do it using a pivot then parenting the object to a pivot. Use left & right to turn the pivot Use A & D to turn the cube Graphics3D 800,600,0,2 SetBuffer BackBuffer() Light= CreateLight() RotateEntity light,90,0,0 camera = CreateCamera() PositionEntity camera,0,0,-10 cube = CreateCube() ;creates the cube with it's center at 0,0,0 pivot = CreatePivot() ;Creates the pivot PositionEntity pivot,1,0,0 ;Positions the pivot at 1,0,0. Play around with the x position (1) to change where the cube will rotate around EntityParent cube,pivot ;Parents the cube to the pivot While Not KeyDown (1) If KeyDown(203) TurnEntity pivot,0,-1,0 ;Turns the pivot the cube is parented, moving the cube off center If KeyDown(205) TurnEntity pivot,0,1,0 ;Turns the pivot the cube is parented, moving the cube off center If KeyDown(30) TurnEntity cube,0,-1,0 ;Turns the cube around it's center If KeyDown(32) TurnEntity cube,0,1,0 ;Turns the cube around it's center UpdateWorld RenderWorld Flip Wend End Hope this helps. :) The other way to change the center of you model is in a 3d modeling program. What are you using? |
| ||
i already did this......but i will try your above method again thx.... i made my model in some software called blender(i think)....... thanks for the help:) |
| ||
If you are using blender. Open your .blend file with the model in it. Go to Edit mode & select the Vertices option. Select all of the Vertices on your model by hitting "A" until they are all selected. Now grab them all & move them around until you have re positioned the mesh around where you want the center of your model to be. This is the way i do it, there may be better ways but this way works for me. :) |
| ||
I agree with Aussie, i think it is better to position the mesh with the vertices at the correct position in your modeling software, so then you only have to load it in Blitz3d. If you absolutely want to reposition it, rerotate it in Blitz3d you can use PositionMesh() and RotateMesh(), these commands will move all vertices of the mesh. |
| ||
If you want "pure code" stuff, you need to get the bouding box, else there is no build-in blitz command to achieve such a thing according to the specific models. Here is a sample of how to do it (support animmesh/scenes) Last edited 2012 |
| ||
Fitmesh is the best way to centre the mesh quickly, if it's not animated. |
| ||
This is a piece of code I wrote some years ago to cope with centring/placing of models created in any modeller (AutoCad creates models miles away from the origin point). http://www.blitzbasic.co.nz/codearcs/codearcs.php?code=1785 |