Advertisement
mifth

ShootBulletControl.java

Sep 29th, 2011
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.72 KB | None | 0 0
  1.  
  2. import com.jme3.export.Savable;
  3. import com.jme3.math.Quaternion;
  4. import com.jme3.math.Transform;
  5. import com.jme3.math.Vector3f;
  6. import com.jme3.renderer.RenderManager;
  7. import com.jme3.renderer.ViewPort;
  8. import com.jme3.scene.Geometry;
  9. import com.jme3.scene.Spatial;
  10. import com.jme3.scene.control.AbstractControl;
  11. import com.jme3.scene.control.Control;
  12. import java.util.HashMap;
  13.  
  14. public class ShootBulletControl extends AbstractControl implements Savable, Cloneable
  15. {
  16.     Geometry geoo;
  17.     Spatial spaa;
  18.     Transform bulletTrans;
  19.     ShootBulletRun shoBuRu;
  20.     Quaternion quaObj;
  21.     Vector3f frontVec;
  22.     float timer2;
  23.  
  24.     public ShootBulletControl(Geometry zgeoo, Spatial zspaa, ShootBulletRun zshb)
  25.     {
  26.         this.shoBuRu = zshb;
  27.         this.spaa = zspaa;
  28.         this.geoo = zgeoo;
  29.         bulletTrans = spaa.getWorldTransform().setScale(0.5f,0.5f,0.5f);
  30.         geoo.setLocalTransform(bulletTrans);
  31. //        geoo.move(0,0,5f);
  32.      
  33.         quaObj = spaa.getWorldRotation();
  34.         frontVec = quaObj.mult(Vector3f.UNIT_Z).normalize();
  35.      
  36.         shoBuRu.getRootNode().attachChild(geoo);
  37.        
  38.        
  39.     }
  40.  
  41.     public Control cloneForSpatial(Spatial arg0)
  42.     {
  43.         return null;
  44.     }
  45.  
  46.     protected void controlRender(RenderManager arg0, ViewPort arg1) {}
  47.  
  48.  
  49.     @Override
  50.     protected void controlUpdate(float arg0) {
  51.    
  52.         timer2 += arg0*4f;
  53.         this.geoo.move(frontVec.mult(1.2f));
  54.        
  55.         if (timer2 > 3f) {
  56.             this.geoo.removeControl(this);
  57.             shoBuRu.getRootNode().detachChild(this.geoo);
  58.            
  59.         }
  60. //        this.geoo.move(0,0,7f*arg0);
  61. //        geoo.rotate(0, 7f*arg0, 0);
  62.        
  63.     }
  64.    
  65.  
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement