Rotating mesh problem
Blitz3D Forums/Blitz3D Beginners Area/Rotating mesh problem
| ||
I have a mesh that is loaded in and then I need to rotate it. Sounds simple? Well the rotation point on some meshes generated with Blender is way off the centre of the mesh, so that when I try to rotate it, it zooms of into the distance. I am using the routine supplied by PowerPC603 ( Thanks, it works very well ) ............................................................................................... Function load_mesh() ; Create a new TObj instance temp.TObj = New TObj ; Create a new cube entity and store the handle in the type instance temp\Entity =LoadMesh(item$) ; Position the cube at some random coordinates PositionEntity temp\Entity, 0,0,60 ; Scale the cubes ScaleEntity temp\Entity, 25.0, 25.0, 25.0 ; Make the cube polygon-pickable EntityPickMode temp\Entity, 2 ; Set the entityname NameEntity temp\Entity, item$ ;ScaleEntity temp\entity,mesh_scale_x#, mesh_scale_y#, mesh_scale_z# TranslateEntity temp\entity,0,0,200 ; Finally add a number to the instance temp\Value = cntr * 1000 cntr=cntr+1 mode=1 End If but I cannot see where to put the pivot, or is there another way of "centering" the rotation point in the mesh? I did try creating a pivot "pivot" then"temp\Entity =LoadMesh(item$,pivot)", but it doesn't work. Thanks...... Dicon |
| ||
Rather than apply a hack, its much better to export it correctly in the first place. I hate blender and don't know how it works, but you get can get a similar effect in some formats when exporting from almost any 3D app including Lightwave, 3DS Max, even Milkshape. The way I found to correct it was to move the model to global world coordinates 0,0,0 (with the pivot point of the mesh being in that position), then export it. The axis should then be exactly where you put it. |
| ||
In Blender, Place the cursor at world center and with the object selected, in the Editing Panel (F9), click the Center Cursor Button. Alternatively in the object menu select Clear-->Location. which should re-center the object prior to export. Good practice to apply scale and rotations too. Standard practice whatever application you use. |
| ||
This problem frequency rears it's head, when exporting multiple meshes with a modelling application. What seems to happen upon saving to blitz3d format anyway, is all the meshes lose there centre, and take on the centrepoint of the modelling applications global 0,0,0. To solve this, you need to find the centrepoint of the mesh, by looping through all the vertices in it. Then, store this centre. Fit your mesh around it's 0,0,0 axis. Then, use PositionEntity to move it back to it's original location. This way, you shift the axis, without moving the mesh. |
| ||
Thanks all will try this ( just read the posts... Dicon |
| ||
Ross C, I did find the vertex position, and would be quite happy to have the rotation around any of them but do not see how to "fit your mesh around it's 0,0,0 axis". I used entitynz() etc, but the moving of the centre eludes me. The example given doesn't even mention entitynz(). Dicon |
| ||
And yes, I did try centering in Blender, making sure the centre was erm.. in the centre. Ultimate unwrap pro seems to throw out the centering. I will dig around in the tutorials to see if Unwrap can centre the mesh. Thanks Dicon |
| ||
To centre your mesh around the 0,0,0 you would do:FitMesh entity,-meshwidth(entity)/2,-meshheight(entity)/2,-meshdepth(entity)/2,meshwidth(entity),meshheight(entity),meshdepth(entity) |
| ||
Dear Ross C, WOOT!! Great it works. Now that gem has been added to my program, I can get on and progress with it instead of banging my head against the wall. I would never have been able to come up with that solution myself. Thanks to you & all here. Dicon |