Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.jme3.export.Savable;
- import com.jme3.math.Quaternion;
- import com.jme3.math.Transform;
- import com.jme3.math.Vector3f;
- import com.jme3.renderer.RenderManager;
- import com.jme3.renderer.ViewPort;
- import com.jme3.scene.Geometry;
- import com.jme3.scene.Spatial;
- import com.jme3.scene.control.AbstractControl;
- import com.jme3.scene.control.Control;
- import java.util.HashMap;
- public class ShootBulletControl extends AbstractControl implements Savable, Cloneable
- {
- Geometry geoo;
- Spatial spaa;
- Transform bulletTrans;
- ShootBulletRun shoBuRu;
- Quaternion quaObj;
- Vector3f frontVec;
- float timer2;
- public ShootBulletControl(Geometry zgeoo, Spatial zspaa, ShootBulletRun zshb)
- {
- this.shoBuRu = zshb;
- this.spaa = zspaa;
- this.geoo = zgeoo;
- bulletTrans = spaa.getWorldTransform().setScale(0.5f,0.5f,0.5f);
- geoo.setLocalTransform(bulletTrans);
- // geoo.move(0,0,5f);
- quaObj = spaa.getWorldRotation();
- frontVec = quaObj.mult(Vector3f.UNIT_Z).normalize();
- shoBuRu.getRootNode().attachChild(geoo);
- }
- public Control cloneForSpatial(Spatial arg0)
- {
- return null;
- }
- protected void controlRender(RenderManager arg0, ViewPort arg1) {}
- @Override
- protected void controlUpdate(float arg0) {
- timer2 += arg0*4f;
- this.geoo.move(frontVec.mult(1.2f));
- if (timer2 > 3f) {
- this.geoo.removeControl(this);
- shoBuRu.getRootNode().detachChild(this.geoo);
- }
- // this.geoo.move(0,0,7f*arg0);
- // geoo.rotate(0, 7f*arg0, 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement