Position Tree ( Mesh ) 2 Terrain problem

Blitz3D Forums/Blitz3D Beginners Area/Position Tree ( Mesh ) 2 Terrain problem

Jack Dawson(Posted 2011) [#1]
Ok, I try to use this code :




I am trying to get the tree to move up 17. But, this is what ends up happening.



When I comment out that middle line, it show it at coordinates 0.0.0 like this.



and I get this




What I am trying to do, is move it. The whole thing, not just the trunk. Any ideas on what I am doing wrong here ? I don't need to attach it anywhere, I just want the whole tree to float.

Here is the B3D file

http://www.youdidwhattowho.com/tree_1.b3d

Last edited 2011


Warner(Posted 2011) [#2]
Why are you using PositionMesh and not PositionEntity?
PositionMesh moves the vertices of a Mesh.
The tree model contains an hierarchy that contains several meshes. The trunk seems to be at the top of this hierarchy.
If you want to move the entire model, use PositionEntity instead. If you want to move the vertices in all meshes inside the hierachy, use a recursive function, along the lines of this:
Function RecursivePositionMesh( ent, x#,y#,z# )
   if EntityClass(ent) = "Mesh" PositionMesh ent, x, y, z
   for i = 1 to countchildren(ent)
       RecursivePositionMesh( GetChild(ent,i), x,y,z )
   next
End Function
Note that it doesn't take in account the scale+orientation of the meshes. It just modifies the vertex data, regardless of each Meshes transformation.


Jack Dawson(Posted 2011) [#3]
I tried PositionEntity but it doesn't move B3D files. I tried.

PositionEntity tree,0,17,0

FYI.. I have never been able to get PositionEntity to move a B3D file. Its why I am having this trouble. And its also why I chose the other command.

And I am using the latest patch. 1.106. I have tried 0.9x. None of them worked either. Again, and I repeat. I have never been able to get B3D meshes to move with positionentity command.

Last edited 2011


Jack Dawson(Posted 2011) [#4]
I tried calling your function using this

RecursivePositionMesh( tree, 0,17,0 )

and I ended up with this



Got any other ideas ?

Last edited 2011


Matty(Posted 2011) [#5]
Then you're doing something wrong if you can't get position entity to work - it is a standard blitz command that works on any entity.

Post some more code.


Charrua(Posted 2011) [#6]
hi
seeing the simple 3 lines of code, i think that the problem is in the .b3d file. PositionEntity must work. Try LoadMesh (without "anim"), try another b3d.
when you say never get to work, with your b3d meshes, or exported from the same modeller? There must be a point in common. I refuse to think that is the "porperly working for most of us" blitz command.
hope it help
Juan

Last edited 2011


Charrua(Posted 2011) [#7]
hi
seeing the simple 3 lines of code, i think that the problem is in the .b3d file. PositionEntity must work. Try LoadMesh (without "anim"), try another b3d.
when you say never get to work, with your b3d meshes, or exported from the same modeller? There must be a point in common. I refuse to think that is the "porperly working for most of us" blitz command.
hope it help
Juan

Last edited 2011


SLotman(Posted 2011) [#8]
Create a pivot on tree position, parent the tree to that pivot, and move the pivot. Should work.


Floyd(Posted 2011) [#9]
I don't see any problem, using the tree_1.b3d model. It is an entity and can be Moved or Positioned as usual. In the following test the tree travels upward as expected.




Jack Dawson(Posted 2011) [#10]
@ Floyd

Ok with this code, I see it working, and I knew it was not my mesh.



I went back and tested it without ANY of my other code and tried it like this and it worked. So now I'm really confused as to why I could never get it to work in the past.



Floyd, again, thank you for your help. I am getting a better understanding now. I'll work out the problem with the rest of my code and see what could be preventing me from using that command.

Last edited 2011


Warner(Posted 2011) [#11]
This works:

This doesn't:

When the mesh is animated, it places it back into it's original position.
So do as SLotman suggests:


Last edited 2011


Jack Dawson(Posted 2011) [#12]
@ Warner

ANIMATE !!! Thats it.. Ok thank you.. i'll check it out. :-)

EDIT : I went back and tried as suggested and it was in the order of where the animate was. I thank you guys for the suggestions. Animate is a pain. So the pivot was the answer to this problem. I just didn't have that command. This also explains why I have never been able to use B3D meshes.

You guys are geniuses. :-)



Last edited 2011