Hello,
i want to write a sprite3D class, wich has the basic features of moving.
But i have several Problems which i can t solve on my own

Here is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| package de.TWOmas.xith.sprite;
import java.text.DecimalFormat;
import javax.vecmath.Point3d; import javax.vecmath.Tuple3f; import javax.vecmath.Vector3f;
import com.xith3d.scenegraph.Switch; import com.xith3d.scenegraph.Transform3D; import com.xith3d.scenegraph.TransformGroup;
public class Sprite3D { private Vector3f posVec = new Vector3f(0,0,0); private Vector3f directionVec; private Vector3f strafeVec; private Vector3f upVec = new Vector3f(0,1,0); private float spriteSpeed = 10; private TransformGroup transformGroup; private Transform3D transform = new Transform3D(); private Transform3D tmpTransform = new Transform3D(); public Sprite3D(TransformGroup transformGroup, Vector3f direction) { this.transformGroup = transformGroup; transformGroup.getTransform(tmpTransform); tmpTransform.get(posVec); directionVec = direction; } public void move(Vector3f move){ transformGroup.getTransform(transform); tmpTransform.setIdentity(); tmpTransform.setTranslation(move); tmpTransform.scaleTranslation(spriteSpeed); transform.mul(tmpTransform); transformGroup.setTransform(transform); } public void rotXYZ (float x, float y, float z) { transformGroup.getTransform(transform); tmpTransform.setIdentity(); tmpTransform.rotXYZ(x,y,z); transform.mul(tmpTransform); transformGroup.setTransform(transform); } }
|
I don t know, wether this methods work corectly, so plz comment, if u find any trouble.
Here are my problems:
Must i submit the direction of the sprite in the constructor? I think yes. How should the Class know how the sprite is aligned, right?
How do i update my Strafe Vec after rotation?
I need them to rot along strafe and direction axis,
because my sprites should move in terrain.
Thanks for helping...