Hello
I'm very stuck on what I thought would be a simple mathematical problem. I'm trying to bind a gun to a players hand by reading in the vertice information.
I'm using my own code driven mesh deformation for the animation so there is no other way to read off the position of the characters hand.
Getting the vertice positions is easy enough, after figuring out the surface/vertex identity
x#=VertexX(surface,vertex)
y#=VertexY(surface,vertex)
z#=VertexZ(surface,vertex)
I then need to rescale the vertex information because my model is rescaled, so I multiply it by *.01 which should give me the x/y/z of the vertex relative to the objects pivot position.
The above all works, but now I need it to rotate depending upon the rotateEntity command. I thought in order to perform the rotation I would simply need to orbit the X/Z around the pivot based on it's distance from the epicentre - like a planet orbits the sun.
p\facing = the rotation of the character entity:
r#=Sqr((x*x)+(z*z))
x=x+(Cos(p\facing)*r)
z=z+(Sin(p\facing)*r)
If I now add the entities world position with the rescaling for the entityscale command and rotate the gun to the angle of the entity (i'll figure out how to rotate the gun in line with the vertex once this works, probably using normals).
PositionEntity p\gunObj,p\x+(x*.01),p\y+(y*.01),p\z+(z*.01)
RotateEntity p\gunObj,0,p\facing,0
Now the only problem is, this completely doesn't work :(
Have I done something wrong ?
I'm very stuck on what I thought would be a simple mathematical problem. I'm trying to bind a gun to a players hand by reading in the vertice information.
I'm using my own code driven mesh deformation for the animation so there is no other way to read off the position of the characters hand.
Getting the vertice positions is easy enough, after figuring out the surface/vertex identity
x#=VertexX(surface,vertex)
y#=VertexY(surface,vertex)
z#=VertexZ(surface,vertex)
I then need to rescale the vertex information because my model is rescaled, so I multiply it by *.01 which should give me the x/y/z of the vertex relative to the objects pivot position.
The above all works, but now I need it to rotate depending upon the rotateEntity command. I thought in order to perform the rotation I would simply need to orbit the X/Z around the pivot based on it's distance from the epicentre - like a planet orbits the sun.
p\facing = the rotation of the character entity:
r#=Sqr((x*x)+(z*z))
x=x+(Cos(p\facing)*r)
z=z+(Sin(p\facing)*r)
If I now add the entities world position with the rescaling for the entityscale command and rotate the gun to the angle of the entity (i'll figure out how to rotate the gun in line with the vertex once this works, probably using normals).
PositionEntity p\gunObj,p\x+(x*.01),p\y+(y*.01),p\z+(z*.01)
RotateEntity p\gunObj,0,p\facing,0
Now the only problem is, this completely doesn't work :(
Have I done something wrong ?