TOKRB_AddConvex()

Blitz3D Forums/Blitz3D Userlibs/TOKRB_AddConvex()

Paolo(Posted 2005) [#1]
"BankSize% = Size of the bank holding vertex data."

I can't find how exactly you set the bank with the
vertex data ... I saw it anywhere but can't remember where...

Ideas?

thanks
Paolo.


Picklesworth(Posted 2005) [#2]
Haha! Just did this :D

;APOE Physics Editor 0.1; output for Fighter1.3ds ;Hehe... Shameless :D
;Surfaces
;Object
Fighter1=TOKRB_Create()
TOKRB_SetPosition Fighter1,x#,y#,z#
TOKRB_SetRotation Fighter1,pitch#,yaw#,roll#
TOKRB_SetLinearDamping Fighter1,0.0
TOKRB_SetAngularDamping Fighter1,0.0
TOKRB_SetMass Fighter1,0.0
TOKRB_SetBoxInertiaTensor Fighter1,12.8823,3.73948,13.1859,0.0
cHull = LoadConvex("Fighter1_CHull_0.off")
Geom_1=TOKRB_AddConvex(Fighter1,cHull,BankSize(cHull))
TOKGEOM_SetPositionAndRotation Geom_1,-3.95875,0.0196976,-2.448,0.0,0.0,0.0
cHull = LoadConvex("Fighter1_CHull_1.off")
Geom_2=TOKRB_AddConvex(Fighter1,cHull,BankSize(cHull))
TOKGEOM_SetPositionAndRotation Geom_2,3.8196,0.0196976,-2.448,0.0,0.0,0.0
Function LoadConvex(file$)
 Convex = CreateBank(FileSize(file$))
 filein = ReadFile(file$)
 For i=0 To FileSize(file$)
  PokeByte Convex,i,ReadByte(filein)
 Next
 CloseFile filein
 Return Convex
End Function


Oh right... and code doesn't work (and don't try it) because I need to set some default values for stuff.

USe the LoadConvex() function to load your convex hull, then when calling TokRB_AddConvex use BankSize(cHull) to get (duh!) the bank size :D



And you probably saw it in the Convex example in the Tokamak wrapper folder.


Paolo(Posted 2005) [#3]
Thanks Picklesworth,
but you didn't get me ... :)
What I need is how to create your ".off" file for a certain mesh.

The help for the static mesh is very clear, it says you need
16 bytes for each vertice, the first 12 are 3 floats representing X,Y,Z,
and 24 bytes for each triangle where the first 12 are 3 integers
representing the 3 corners, the next integer is the material index ...

I need the same information about how to set the bank's floats and integers for convex bodies...

Paolo.


Fabian.(Posted 2005) [#4]
I've the same problems. I think it would be usefull to have a function to convert ".x" or ".b3d" files to ".off" files.

thanks


Picklesworth(Posted 2005) [#5]
I'm assuming that you have QHull and Adjacency.
This module for my program here (posted below) doesn't work on its own (at all) but maybe it will help you out a bit. Look at the writefile bits. The create_tok_hull function creates a .off file using qhull (this .off file is used to make a mesh out of Adjacency's output). Then (I got lazy, but hey, it works!) it creates a file very ridiculously similar to that which was sent to qhull, and sends it to Adjacency via the command line. Adjacency then creates the requested .bin file, which is loaded into Tokamak.

Obviously, this will all be made easier "Shortly". Right now, I have two stupid busy-work assignments to do for school.

Here's that code:



Oh yah, and you may notice that I am suddenly using .bin files instead of .off files.
It turns out that the .off files are actually only for easily getting the shape of the convex hull (or something) and are recieved from qhull. These have nothing to do with the .bin file created by Adjacency (thankfully, using a nearly - possibly copmletely and I'm just dumb - identical input file). The .bin file is what Tokamak uses.


Rhyolite(Posted 2005) [#6]
Errr, what is a convex hull?

Sorry to lower the standard of the post ;)

Rhy :)


Picklesworth(Posted 2005) [#7]
A convex hull is a thing that many physics engines use to create more precise simulations.
Basically, it is a version of a mesh with no internal angles (it's convex), which can then recieve very precise collisions.


Rhyolite(Posted 2005) [#8]
Ah, I think I understand. You mean there are no 'corners', everything is curved? But I see, its bascialy a more accurate representation of the mesh.

Cheers :)