EntityPosition of a child loaded wth LoadAnimMesh?

Blitz3D Forums/Blitz3D Programming/EntityPosition of a child loaded wth LoadAnimMesh?

Gabriel(Posted 2005) [#1]
I want to be able to parse objects in my b3d file for various in-game objects. I'm sure I've done this but it's been so long since I've used b3d that I can't get it working. I load it with LoadAnimMesh so that I can parse children, then use FindChild() to find the children.

But EntityX#(), EntityY#() and EntityZ#() all return 0, whether I force global or local coordinates. Short of parsing the vertices and finding the geometric center of the object, how can I just grab the position of the object?


Tom(Posted 2005) [#2]
Got a sample mesh we could look at?


John Blackledge(Posted 2005) [#3]
Try some of the function in this tutorial:
http://www.blitzbasic.co.nz/codearcs/codearcs.php?code=1496


Ricky Smith(Posted 2005) [#4]
The method you are using should work. The fact that you are getting back zero makes me think that you are not getting or finding the child entity and its returning the position of the mesh.
The other thing tht could be happening is that your model has multiple root joints . You could be searching for the children of the first root node that has no children. A susequent root node could be the one containing all the children.


Gabriel(Posted 2005) [#5]
Tom: Not right now, perhaps tomorrow. Your question implies that you think it's the way the object is exported, which was my suspicion too. Since I want to be able to support user-created meshes with this, I won't be able to guarantee the export process they use. If this is indeed the case, I may have to stick with the workaround I'm using.

John: Yeah, that's kinda what I'm doing. It works, but it's not very elegant.

Smiff: No, nothing like that. I'm finding the meshes just fine. I know this because I hide them after processing them, so if I wasn't finding them I'd see cubes all over the scene.


Ricky Smith(Posted 2005) [#6]
Are you using flat hierarchy i.e. all meshes are siblings under the root node ? If so it might be possible that their origins are all at Zero even though the vertices are in the right place. How do they rotate ? Just a thought.


Gabriel(Posted 2005) [#7]
Are you using flat hierarchy i.e. all meshes are siblings under the root node ?

Seems to be that way, yeah. I think most b3d exporters do this, don't they?

If so it might be possible that their origins are all at Zero even though the vertices are in the right place.

This what I was thinking. The origins are all in the right place within 3dsMax so it's happening somewhere along the export pipeline from 3dsMax to UU, from UU to Gile[s] and from Gile[s] to B3d. Probably somewhere involving UU.

Unfortunately, I have to live with it if I want users to be able to use their own meshes.


Beaker(Posted 2005) [#8]
UU tends to zero positions AFAIR.


John Blackledge(Posted 2005) [#9]
John: Yeah, that's kinda what I'm doing. It works, but it's not very elegant.

As far as I know the only way is to track down all the vertices. At least it works.


Naughty Alien(Posted 2005) [#10]
Why MAx to UU? Over B3D pipeline for max you can go straight to Giles..I did try just now few of my meshes, loaded with LoadAnimMesh and working fine for all children within with proper EntityX,Y,Z ..


John Blackledge(Posted 2005) [#11]
Alien, that's baffling. I tried a Giles output B3D and each child entity had x,y,z of -2,000,000; which is why I had to write the code I've linked above.


jhocking(Posted 2005) [#12]
I don't know about gile[s] but I can confirm what Beaker said, that UU zeroes the positions when you save a multi-object mesh to b3d. UU doesn't support pivot points for objects (technically it doesn't even support multiple objects; exporting a mesh with multiple objects is done via a trick of grouping.)


Gabriel(Posted 2005) [#13]
Why MAx to UU? Over B3D pipeline for max you can go straight to Giles.


Because not many people have 3dsMax and a lot of export paths involves Ultimate Unwrap in some way.

Thanks to Beaker and Joe for the confirmation that UU is the problem. I'll stick with my functions to find the geometric centre of an object using vertex positions.


John Blackledge(Posted 2005) [#14]
I must agree with Gabriel:
Unfortunately, I have to live with it if I want users to be able to use their own meshes.

Gabriel, you said my code at www.blitzbasic.co.nz/codearcs/codearcs.php?code=1496
was not very elegant - do you want to realease yours?


Gabriel(Posted 2005) [#15]
No no no, I didn't say your code wasn't very elegant. I said having to use vertex positions wasn't very elegant. My code is rarely elegant, so mine is probably less elegant than yours. It's just a shame that UU can't deal with each object having it's own pivot point.


big10p(Posted 2005) [#16]
Email the author of UU about the problem. He's always been very keen to help when I've had issues with UU.


jhocking(Posted 2005) [#17]
I would second that comment (that he's really responsive to email and keen to help,) but do note that years ago when he was first developing b3d support I had a conversation with him about this and it was sort of a fundamental conflict with what UU is/does. But I haven't talked with him since then, so it may very well be that by now the situation is more amenable to that change.