Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - 4ebureG

Pages: [1]
1
Support / Re: Move object
« on: October 21, 2013, 06:44:35 am »
Thank you for answer!
If I do how you wrote above, my object is moving on a pixel because of cube.clearTranslation();
Now I do so:

            ..........
              if (me.getAction() == MotionEvent.ACTION_UP) {
              x=me.getX();
              y=me.getY();
          
              trans = new SimpleVector(Interact2D.reproject2D3DWS(world.getCamera(), fb, (int)x,(int) y));
               pos = world.getCamera().getPosition();
               float Z_PLANE=0;
            float a = (Z_PLANE - pos.z) / trans.z;
               float xn = pos.x + a * trans.x;
               float yn = pos.y + a * trans.y;
               moveVector = new SimpleVector(xn,yn,Z_PLANE);

               return true;

           }


                   ..........             
                   if (moveVector!=null){
              сube.translate(moveVector.normalize());
                }

But my object is moving properly. Help me please!

2
Support / Move object
« on: October 18, 2013, 07:05:43 pm »
Hello all!
I am a novice in jpct! Can you help me?
I want my object to move but it looks horrible:

 @Override
   ......
       public boolean onTouchEvent(MotionEvent me) {
       if (me.getAction() == MotionEvent.ACTION_DOWN) {     
          return true;
      }
        if (me.getAction() == MotionEvent.ACTION_UP) {
              x=me.getX();
              y=me.getY();         
       return true;
       }
         if (me.getAction() == MotionEvent.ACTION_MOVE) {           
       return true;
   }
                          try {
               Thread.sleep(15);
           } catch (Exception e) {
           }
           return super.onTouchEvent(me);
       }
            ....
              public void onDrawFrame(GL10 gl) {
      cub = new SimpleVector(Interact2D.projectCenter3D2D(fb, cube));
      if ((x!=0) && (Math.abs(cub.x-x)>5) && (Math.abs(cub.y-y)>5))
      {
      trans = new SimpleVector(Interact2D.reproject2D3DWS(world.getCamera(), fb, (int)x,(int)y));
      trans.z= cube.getCenter().z;
      cub.translate(trans);
      }
              .....
      }
Modify message

Pages: [1]