Jump to content

Josh

Staff
  • Posts

    23,145
  • Joined

  • Last visited

Posts posted by Josh

  1. My tests indicated touch move events were working correctly. (I printed out the events and could see the numbers corresponding to my input.) Do you have a test that proves otherwise? Drawing some squares on the screen under the touch positions would be a good way to demonstrate it.

  2. It just calls AddForce(gravity) where gravity by default is 0,-9.8,0 times mass:

    Vec3 force = (spaceship->GetPosition(true) - planet->GetPosition(true)) * spaceship->GetMass();
    spaceship->AddForce(force);

     

    Technically, gravity increases as you get closer to an object though, so it should really be something like this:

    Vec3 force = (spaceship->GetPosition(true) - planet->GetPosition(true)) * spaceship->GetMass();
    const float gravityrange = 100;
    force *= 1.0 - min(force.Length() / gravityrange,1.0);
    spaceship->AddForce(force);

     

    If you do this in the UpdatePhysics callback or script function, it will only get called for active bodies, and it will be called once per physics update.

     

    Fun physics fact: See how I multiplied the force by the object's mass? That's the reason a piano and a walnut will fall at the same speed (not counting wind resistance).

    • Upvote 2
  3. Ha!

     

    Those are the files I just uploaded.

     

    Windows 8 keeps changing the clock's time on me, randomly. Right now it says it is November 5 at 3:47 A.M. when it is really November 4th at 7:47. So those files must have been modified...tomorrow. Since those files are from the future, they will always be newer than the ones you have on your hard drive.

     

    The problem will roll over in about 7 hours, once we catch up with the future. blink.png

  4. I believe I have the solution.

     

    In AndroidActivity.java, replace onTouchEvent with this code:

        @Override
       public boolean onTouchEvent(MotionEvent event) {
           Integer action,pointerIndex,pointerId;
           Float x,y;
    
           action = event.getAction();
           pointerIndex = event.getActionIndex();//(action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; //index of this pointer        
           x = event.getX(pointerIndex);
           y = event.getY(pointerIndex);
           pointerId = event.getPointerId(pointerIndex);
    
           switch (action & MotionEvent.ACTION_MASK){
           case MotionEvent.ACTION_DOWN:
           case MotionEvent.ACTION_POINTER_DOWN:
               // Log.i("touchtest", "action_down " + pointerId.toString() +
               // "(" + x + "," + y + ")");
               androidRenderer.touch(x, y, pointerId);
               break;
           case MotionEvent.ACTION_MOVE:
      		 for (int i = 0; i < event.getPointerCount(); i++)
      		 {
      	         Log.i("touchtest", "begin_move ");
      	         pointerId=event.getPointerId(i);
                   x = event.getX(i);
                   y = event.getY(i);	        
                   //Log.i("touchtest", "action_move " + pointerId.toString() +
                   //     "(" + x + "," + y + ")");                                
                   androidRenderer.move(x, y, pointerIndex);
      		 }                
               break;
           case MotionEvent.ACTION_UP:
           case MotionEvent.ACTION_POINTER_UP:
               //Log.i("touchtest", "action_up " + pointerId.toString() + "("
               // + x + "," + y + ")");
               androidRenderer.up(x, y, pointerId);
               break;
           }
           return true;
       }

     

    In main.cpp replace the Java_com_leadwerks_leandroidb_AndroidRenderer_move function with this code:

        JNIEXPORT void JNICALL Java_com_leadwerks_leandroidb_AndroidRenderer_move(JNIEnv * env, jobject obj, jfloat x, jfloat y, jint touchId)
       {
           if(touchId < 0) return;
           if (Leadwerks::Window::_TouchPosition[pointerIndex].x!=x || Leadwerks::Window::_TouchPosition[pointerIndex].y!=y)
           {
               Leadwerks3D::_TouchPosition[touchId].x = x;
               Leadwerks3D::_TouchPosition[touchId].y = y;
               Leadwerks3D::Event(EVENT_TOUCH_MOVE,NULL,touchId,x,y).Emit();
               //Leadwerks3D::Print("Move! "+Leadwerks3D::String(x)+", "+Leadwerks3D::String(y));
           }
       }

     

    I will upload the fix now.

  5. Working off of this code now:

    http://stackoverflow.com/questions/14201130/how-does-the-ontouch-event-behave

     

    It appears that touch indexes are not persistent. In other words, when touch index zero is lifted, the touches "shift" to the left, and touch index 1 becomes touch index 0.

     

    Motion events always indicate touch index 0, so I tried looping through from 0 to event.getPointerCount(), but I get a crash on getEventX():

       		 for (int i = 0; i < event.getPointerCount(); i++)
      		 {
      	         Log.i("touchtest", "begin_move ");
      	         pointerIndex=event.getPointerId(i);
                   x = event.getX(pointerIndex);
                   y = event.getY(pointerIndex);	        
                   Log.i("touchtest", "action_move " + pointerIndex.toString() +
                        "(" + x + "," + y + ")");                                
                   androidRenderer.move(x, y, pointerIndex);
      		 }

  6. A few of those items in your list will be supported in 3.1 right away. Almost everything there will be supported in 2014. I don't have exact release dates for each item, but that's the direction we're moving in.

     

    We did have a self-shadowing parallax shader in Leadwerks 2. Tessellation makes self-shadowing bumpmaps obsolete, because it actually creates geometry on the surface that self-shadows using the real lighting system. (Texture-based lighting like you describe typically just uses a single input vector for a directional shadow.)

    • Upvote 2
  7. Well, it looks like TJHeldna is the only participant, so he wins all the prizes:

    http://www.leadwerks.com/werkspace/files/file/461-cold-feet-machine-for-penguins-demo-game/

     

    I'm disappointed there was so little participation. On the other hand, I really like "Cold Feet" and I think it's the most polished looking demo we've gotten from these tournaments so far. The developer did a really nice job of blending in three themes: Linux, Halloween, and machinery. I hope we can get this game running on Linux soon.

     

    post-1364-0-42539400-1383237703_thumb.jpg

    • Upvote 1
  8. This is built into the Leadwerks 3 editor. Right-click on a model in the Asset Browser, then select the Generate Shape > Polymesh or Convex Hull menu item to save a physics shape from the model.

     

    The Leadwerks 3 physics shape format is not the same as the Leadwerks 2 format. (The Leadwerks 2 format is Newton serialized data, while the Leadwerks 3 format is our own and will not change.)

  9. The VIsual Studio compiler tends to be very slow compared to GCC and LLVM, but you might have other settings or something that slow it down. UAC or antivirus programs could be the cause, possibly. You might get better results if you delete the .suo file. The whole question is rather mysterious, but it's not uncommon.

  10. Sorry, you should include files from App.h, in the "Source" directory, to include all your includes from. Main.cpp varies depending on platform. Android uses a special version of it, so App.h is the one to use.

×
×
  • Create New...