public Bullet(Model model,FirstPersonCamera cam) { shape = new Sprite3D(model); this.cam = cam; shape.setPosition(cam.getPosition()); shape.setScale(Consts.WORLDSCALE / 10f); float dx = cam.getLookAt().X - shape.getPosition().X; float dy = cam.getLookAt().Y - shape.getPosition().Y; float dz = cam.getLookAt().Z - shape.getPosition().Z; float d = (float)(Math.Sqrt(dx * dx + dy * dy + dz * dz)); this.velocity = new Vector3(dx / d * Consts.BULLETSPEED, dy / d * Consts.BULLETSPEED, dz / d * Consts.BULLETSPEED); }
public Bullet(Model model, FirstPersonCamera cam) { shape = new Sprite3D(model); this.cam = cam; shape.setPosition(cam.getPosition()); shape.setScale(Consts.WORLDSCALE / 10f); float dx = cam.getLookAt().X - shape.getPosition().X; float dy = cam.getLookAt().Y - shape.getPosition().Y; float dz = cam.getLookAt().Z - shape.getPosition().Z; float d = (float)(Math.Sqrt(dx * dx + dy * dy + dz * dz)); this.velocity = new Vector3(dx / d * Consts.BULLETSPEED, dy / d * Consts.BULLETSPEED, dz / d * Consts.BULLETSPEED); }