entity type

Blitz3D Forums/Blitz3D Programming/entity type

Pudding(Posted 2003) [#1]
Is there any way to tell if an entity is a pivot or a bone? Or if an entity has/is a mesh?

The distinction between entity and mesh seems rather vague in Blitz. This code works most of the time:

For i = 1 To CountChildren(root)
c = GetChild(root,i)
If CountSurfaces(c) then ...

this works even though GetChild returns an entity and CountSurfaces takes a mesh - BUT if the child is a bone then CountSurfaces throws a memory access violation!

The simplest example:
p = CreatePivot()
CountSurfaces(p)

this throws an error instead of returning zero.

Am I missing something obvious? What command can I use before CountSurfaces to avoid a crash???

-Pudding


Sunteam Software(Posted 2003) [#2]
You could try using unique names for your bones so that you could get the entity name and if it matches....voila.

;example
If EntityName$(c)="bone" then...



Pudding(Posted 2003) [#3]
I was hoping for a solution that assumes nothing about the source. I'm using the code in a viewer that loads b3d files and its kind of lame that it would crash if some arbitrary naming convention weren't followed.

-Pudding


Beaker(Posted 2003) [#4]
If you are loading a b3d file you can tell its a bone cos it says BONE in the chunk header in the file. You need to parse the file.


Pudding(Posted 2003) [#5]
I'm sorry, parsing the b3d file for this kind of info is ridiculous - the language needs commands for basic queries of this sort. (btw not bashing your suggestion, thank you for offering a solution)

Guess it's time to head over to the feature request forum...

Maybe the bug report forum too - if Blitz is going to play all loosey-goosey with entities/meshes/bones/pivots then CountSurfaces(pivot) should return 0 instead of crashing...

-Pudding


Pudding(Posted 2003) [#6]
I'm revisiting this problem, so I thought I'd bump this up and see if anyone has found any workaround.

The problem I'm having is my Max B3d Viewer recurses through the scene to calculate a bounding box so it can put the default camera somewhere reasonable. Right now if it hits a bone that doesn't match my naming convention ("bone" or "bip" prefix) it crashes - and there's not a damned thing I can do about it!

I was going to resort to parsing the b3d file to build this bounding box, but right now the viewer can be used with .x and .3ds files as well.

Any ideas?

(Yes I could write .x and .3ds file parsers too, but please, Blitz is supposed to make things easier!!)

-Pudding


Beaker(Posted 2003) [#7]
There really isn't anyway round this. It's either parse the files or hope that Mark adds commands for it. Sorry I can't help more. I'm in the same boat as you.


Skitchy(Posted 2003) [#8]
For this specific situation, what about this :-
Get the Max exporter to write out a temp file of *only* vertex positions (and maybe the tris as well if its easier) - just dont export the bones. This will give the equivelant of a LoadMesh() object as opposed to a LoadAnimMesh() object.
Then have the .b3d viewer calculate the extremities of the mesh from this data. Obviously, any animation will not be taken into account, but you'll be able to get a good idea of the bounding box, add a bit to it, and stick the camera in as neccessary.

Hope that helps in some way :)

BTW Pudding - did you read my suggestions for a 'bone-per-vertex' optimisation in the other thread (Announcing B3D PipeLine). If so, what are your thoughts on that? :)


Pudding(Posted 2003) [#9]
Skitchy, those were some cool optimizations.

I've written a general animation key frame optimizer that approximates the sampled animation curves with far fewer keys. That reduces the file size considerably. As for optimizing the number of bones - I like your ideas, but they're a lot harder to implement! My first optimization is likely to be the option to not make bones for vertices that do not move...

It might be cool to implement your ideas in a post process tool; load a b3d file and interactively tweak optimization parameters. I'm toying with the idea of such a tool. It would also let you join multiple animation sequences together, that sort of thing...

As for the bounding box thing, I think I'm going to have to wait for Mark to add some commands... I can pretty much do what you describe with a b3d file, but .x and .3ds files would require a different solution and I'd like to use the viewer as a generic 3d viewer.

-Pudding