jPCT-AE - a 3d engine for Android > Support

Moving an Object3D to another smoothly.

<< < (4/5) > >>

EgonOlsen:
Don't be confused with the wording in the Javadoc...they are taken from desktop jPCT and i forgot to change them. In AE, the camera isn't double buffered. Everything works directly on one matrix. The only difference between rotateY(angle) and rotateCameraY(angle) is, that one rotates the matrix by angle and the other one by -angle. That can't be the reason of the problem.

dl.zerocool:
Oh strange.

Let me just show what I do:

--- Quote ---tiltSensors.addSensorsListener(new SensorEventAdapter() {
       public void onOrientationChanged(OrientationEvent e) {
      // NOT A GOOD IDEA !!!! initial camera position should be kept
      // when initialized and then the necessary angle calculated.
      PLAYER.lookAt(honeyPot);
      PLAYER.rotateCameraY(e.yaw);
      PLAYER.rotateCameraX(-e.roll);
      // PLAYER.rotateCameraZ(e.pitch);
       }
   });

--- End quote ---
PLAYER inherits from Camera so it's a camera with few more members and function I added ( I know it should be composed instead of inheriting but I've very few time left and I'm doing as fast as I can).

now when I shout a projectile I take the vector direction and position to get the "starting point + direction" of the projectile.

I've just a little function live wich create the projectile

--- Code: ---public void live(SimpleVector start, SimpleVector dir) {
this.dir = dir;
alive = true;
System.out.println("Bee : " + getName() + " IA id: " + getID());
System.out.println("Bee dir : " + dir.toString());
System.out.println("Bee start : " + start.toString());
translate(start);
//rotateY(Game.ROTATION_Y_FACE_SCENE_FROM_CAMERA);
show();
enableCollisionListeners();
    }
--- End code ---

So nothing big here...
Then to move the projectile I do this

              dir.add(dir);
              translate(dir);

The problem is when I do this.

--- Code: ---    
public void onFireBee()
    {
for(Weapon w: bees){
   if(!w.isALive()){
w.live(PLAYER.getPosition(), PLAYER.getDirection());
System.out.println("Live a bee : "+w.getName()+" id: "+w.getID());
break;
   }
}

--- End code ---
I just "create" make a projectile alive, on an arraylist of projectiles when a button is pressed.

That's all, but when I do this the projectile still follow the initial camera direction not the current one...

ps: I don't touch camera values or function inside PLAYER, it's a direct call to Camera functions.

EgonOlsen:
As said, rotateXXX in Camera works on the same matrix that getDirection uses. I don't see any reason why this shouldn't work nor have i ever experienced that problem. Does all this processing happens in the same thread? Remember that you have two (both triggered by Android), one that started the Activity and one that does the GL drawing. Maybe this interferes somehow? If that isn't the problem, a test case would be helpful as i can't verify this problem.

And another question: What is the "initial camera position" in this case?

dl.zerocool:
hmmmm I'm going to check this, but getDirection and getPosition are in one thread (game)

Sensors are initialized inside Game so basically rotates called by sensors event should be made inside game thread.
sensors are certainly threaded by android of course but I don't think this is the problem.

Because it should only cause a small change in angle in case fire bee is called before the angle is updated by sensors.
So this is not the case

The case is that it's always fired to ->initial getDirection

When I start the game Camera looking at center of the scene :

--- Code: ---05-29 08:18:36.314: INFO/System.out(12161): End initialisation
05-29 08:18:38.844: INFO/System.out(12161): Bee : Bee0 IA id: 6
05-29 08:18:38.854: INFO/System.out(12161): Bee dir : (0.0,0.0,1.0)
05-29 08:18:38.854: INFO/System.out(12161): Bee start : (0.0,0.0,0.0)

--- End code ---


After moved the camera and waited a while (to be sure that camera values have been update, but of cours they where because the camera moved)
Bee0 had time to die that's why it's again bee0 who is fired.

--- Code: ---05-29 08:18:41.014: INFO/System.out(12161): Bee : Bee0 IA id: 6
05-29 08:18:41.014: INFO/System.out(12161): Bee dir : (0.0,0.0,1.0)
05-29 08:18:41.014: INFO/System.out(12161): Bee start : (0.0,0.0,0.0)
--- End code ---


dl.zerocool:
Better print to understand :  start direction is  getDirection from camera  and start position getPosition.
Called each time a bee is fire

[First fire -> camera looking scene]

--- Code: ---05-29 09:32:46.719: INFO/System.out(15615): Bee start direction : (0.0,0.0,1.0)
05-29 09:32:46.719: INFO/System.out(15615): Bee start position: (0.0,0.0,0.0)
05-29 09:32:46.719: INFO/System.out(15615): Live a bee : Bee0 id: 6

--- End code ---

[Second fire -> camera looking away]

--- Code: ---05-29 09:32:50.869: INFO/System.out(15615): Bee start direction : (0.0,0.0,1.0)
05-29 09:32:50.869: INFO/System.out(15615): Bee start position: (0.0,0.0,0.0)
05-29 09:32:50.879: INFO/System.out(15615): Live a bee : Bee0 id: 6
--- End code ---


[edit]
since I only apply rotation to camera I understand that position never change
but direction should change T_T

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version