Assigning verts

Blitz3D Forums/Blitz3D Programming/Assigning verts

SabataRH(Posted 2003) [#1]
I've been playing with some weird stuff lately but came to a point where i need to link verts from a preloaded mesh to a diffrent surface/parent.. Is it possible to assign verts to a parent other then their original? Or will i need to completely rebuild the mesh with code?

Also... I know this has been asked before but i never saw a viable means of preforming it, how would one go about rotating verts?

Let's see if i can describe my dilima a little better.
I'm attempting to build a model editor, bones are placed manually and i want to assign weightmaps to the joints.
I select a group of verts and assign them to a joint. I can fake the x,y,z deformation using vertexcoords but i havent been able to append for rotations. Exporting the tween data to b3d will be automatic, but i need the editor to show the animations as they are being edited.. etc...

TFormPoint seemed to be my answer, but i've noticed the rotation values get swapped or the axis is offset by the bones rotation value.




Thanks in advance!


SabataRH(Posted 2003) [#2]
Another option was to write/export the entity each time a vert was assigned to a bone.. Then reload the mesh allowing blitz's native loader to handle the assignments.... Before i venture down that road I would like to get confirmation as to if this is the only viable means to do what i need done..


Binary_Moon(Posted 2003) [#3]
You want to write your own bone system using vertex coords? You can do that with tformpoint. I had a working sample on my computer but recently formatted my harddisk and started from scratch.

Just hads a quick look and I have found a back upof the code. Email me (Ben at Binarymoon.co.uk) and i will send you the demo. The update bones code is about 5 lines long :)


FlameDuck(Posted 2003) [#4]
Is it possible to assign verts to a parent other then their original? Or will i need to completely rebuild the mesh with code?
You will need to completely bebuild the mesh with code.
I can fake the x,y,z deformation using vertexcoords but i havent been able to append for rotations.
The easy way would be using TFormVector or TFormPoint (depending on what type of result you're after). TFormPoint vx,vy,vz,bone_pivot,0 where vx/vy/vz are the vertice positions and bone_pivot is the entity of the bone object, should give you the correct *global* coordinates for the vertices when they are rotated. Since this seems to be what you're doing I think you'll need to be a little more specific with regards to why you aren't getting the results you wanted.
Before i venture down that road I would like to get confirmation as to if this is the only viable means to do what i need done..
No it is not.


SabataRH(Posted 2003) [#5]
BM, thanks for the code example, thats some neat stuff you got there! I now see how i was messing up the TformPoint's... :) Many thanks

Flame, thanks for confirming 'the way not to do it' :) Rebuilding the mesh does seem to be the proper route... I've started this approach today..

To better explain, imagine Milkshape (the editor).. you select and assign verts to a bone/pivot. After doing such you enter animation mode and contort the bones around causing animation.. This is the effect im tring to achieve - as it would be easy enough to record the frame tweens to file, i need the real time editor to show/update these animation tweens as well...


JoshK(Posted 2003) [#6]
Custom vertex weights can be faster than Blitz's, because they only need to get updated before a RenderWorld, not with every UpdateWorld.


SabataRH(Posted 2003) [#7]
I've been looking over Marks c++ milkshape exporter code tring to determine what w-rot is... further more - I'm tring to figure out how to get that formula into blitz notation.. :)

Any clues as to what wrot is? Im guessing its an offset value from the bone to center axis?

Anyhow, if anyone has converted that equation from the exporter to blitz notation I would love to see it :)




Rebuilding the mesh within code after each assignment is glued... so animation/deform is real time now!, but darn that w-rot....




Thanks!


SabataRH(Posted 2003) [#8]
Discovered the wrot value as being a quaternion representation... also the pitch,yaw and roll being values based off the wrot. BUT im stumped again... this changes the values of my x,y,z positoning... xyz are offsets from the chunks center, but i can't seem to put my finger on how the coords work.. sometimes they are inverted.. sometimes z is listed and y and what not...

Anyone with a brief run down on how positioning coordinates are recorded in a mesh?

heres a xml of a node im working with :
<NODE name="neck" xpos="5.01093e-004" ypos="0.0295951" zpos="-0.383532" xscale="1.0" yscale="1.0" zscale="1.0" wrot="1.0" xrot="0.0" yrot="0.0" zrot="0.0">

the xyz values make no sense to me as the neck should be Yvalue higher then the center axis - but clearly shown the Xvalue is greater then Y..

Is xyz position coordinates; a quaternion value as well? If so where are these calculated as I see no wrot value listed in this node other then '1' (default).

Thanks


TeraBit(Posted 2003) [#9]
Positioning should be sensible enough. Only the rotations should be Quaternions. The Xpos you mentioned is a:

"5.01093e-004"

Which appears to be a notation which denotes a number too small to be represent in 0.0000001 type digits. Hence the e-004 at the end.

I ran into these dudes when doing the Lightwave convertor! :/


SabataRH(Posted 2003) [#10]
Thanks Tera... I exported a few larger models and looked at their positionings and as you mentioned - its a size issue!

One last question for you kind folks... I've managed to export the model with bones assigned, i've linked verts to the bones as mentioned earlier.. BUT im having another problem with the vertexnormals... I noticed when i ran the animation in blitz none of the triangles appeared to be attached. I then loaded the model in Unwrap3d and welded all the verts - then back to blitz for a test.. Sure enough the model deformed and the triangles stayed together.

So i noticed, in the b3d export code, my <VRTS> flag not being set to 'normals' so i changed that - but i'm abit lost on how to obtain the vertexnormal values to pass to the my exporter function()....

What's the proper procedure for setting vertexnormals? - ive dug and dug but found little enough on this topic and blitz docs... to say the least - is vague on this topic.

It sounds to simple to be true, but Vertexnx(surf,indx) does return a value... but not set bymyself... should i pass this to the Vrts chunk?


Beaker(Posted 2003) [#11]
Use VertexNx() etc to pass to your VRTS chunk.

To set the vertex normal use the VertexNormal command.

Hope this helps.


SabataRH(Posted 2003) [#12]
Thanks MB.


Problem with the broken tri's is sorted, I had a mis-assignment in the vert numbering system :(