Why is everyone talking about storage, and no-one talking about usage? Who cares how it's represented? It's more important to understand what it's used for.
A vector represents an offset from an origin. Given a vector and an appropriately generated matrix, you can get another vector from the first that has been rotated or offset in almost any way imaginable.
Now, the real magic is in the matrix, not the vector. Starting with an identity matrix, you can multiply it by one of many rotation matrices or translation matrices, and due to the magic of matrices , all of those operations can be carried out with a single operation on the vector simply by multiplying the two.
I don't have code converted to the GDK, but you can probably convert this DBPro code if you spend a little time:
sync on
sync rate 0
sync sleep 1
` Working storage - need a matrix to apply rotations
null = make matrix4(100)
` Need a mesh sphere to use as a limb
make object sphere 1, 0.1
make mesh from object 1, 1
delete object 1
` Create a cube and attach the limb to the position of the cubes first vertex
make object cube 1, 1.0
add limb 1, 1, 1
lock vertexdata for limb 1, 0
offset limb 1, 1, get vertexdata position x(0), get vertexdata position y(0), get vertexdata position z(0)
unlock vertexdata
`position object 1, 2.0, 5.0, -2.5
`position camera 0.0, 0.0, 0.0
`point camera 4.0, 10.0, -5.0
do
` Place into vertex 1 the position of object 1, limb 0, vertex 0
GetVertexPosition(1, 1, 0, 0)
` Display the world-coordinates
set cursor 0, 0
print "Limb position"
print limb position x(1, 1)
print limb position y(1, 1)
print limb position z(1, 1)
print ""
print "Calculated vertex position"
print x vector3(1)
print y vector3(1)
print z vector3(1)
print ""
print "Use left/right to rotate around object x axis"
print "Use up/down to rotate around object y axis"
print "Use a/d to rotate around object z axis"
print "Press SPACE to reset angles to 0"
` Simple rotation
if spacekey()
rotate object 1, 0.0, 0.0, 0.0
else
rotate object 1, object angle x(1) + downkey() - upkey(), object angle y(1) + rightkey() - leftkey(), object angle z(1) + keystate(32) - keystate(30)
endif
sync
loop
function GetVertexPosition(Vector as integer, Object as integer, Limb as integer, Vertex as integer)
` Ensure that the target vector is a vector and the right size
null = delete vector3(Vector)
null = make vector3(Vector)
` Take the vertex position
lock vertexdata for limb Object, Limb
set vector3 Vector, get vertexdata position x(Vertex), get vertexdata position y(Vertex), get vertexdata position z(Vertex)
unlock vertexdata
` Rotate by the limb direction (not its rotation - direction!)
` Magic number * 0.0174532925194 is used to convert degrees to radians
rotate x matrix4 100, limb direction x(Object, Limb) * 0.0174532925194
transform coords vector3 Vector, Vector, 100
rotate y matrix4 100, limb direction y(Object, Limb) * 0.0174532925194
transform coords vector3 Vector, Vector, 100
rotate z matrix4 100, limb direction z(Object, Limb) * 0.0174532925194
transform coords vector3 Vector, Vector, 100
` Offset by limb position (not its offset - position!)
set vector3 Vector, limb position x(Object, Limb) + x vector3(Vector), limb position y(Object, Limb) + y vector3(Vector), limb position z(Object, Limb) + z vector3(Vector)
endfunction
The function uses matrix/vector maths to calculate the position of a single vertex of an object into its final world coordinate.