Author Topic: Flier Match  (Read 99845 times)

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Flier Match
« Reply #105 on: October 17, 2008, 05:21:49 pm »
Well, I began coding this 2 days ago, I make a Bullet class, a Shot class and a movingThread for the bullets. I will have a Thread just for moving the bullets. On that way it wont depend on the speed of the rendering Thread nor on the lag from the server. I have not been at home this last 2 days (HANGOVER) but with a bit of luck I would have the basics of the shooting stuff by tomorrow.
Nada por ahora

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Flier Match
« Reply #106 on: October 20, 2008, 03:40:12 am »
Hi, I am having problems here. My problem is mainly that I am confused about how to set the initial position and direction from my bullets. I made some code here and there and I have now bullets being shot from my camera position "aparently". But I am having some problems, I guess I messed arround the rotation matrix of the camera and the bullets. Egon would you mind checking it a bit. Actually, I guess that is all that is missing from the client visulization. I have not added the shotting on the server yet. I just have a small code for shooting a bullet from my client. I will post the code tomorrow.
Nada por ahora

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Flier Match
« Reply #107 on: October 20, 2008, 08:58:31 am »
You probably already thought of this, but just in case.  When applying the Camera rotation matrix to an Object3D, you might need to clone and invert it:

Code: [Select]
myObject3D.setRotationMatrix( myCamera.getBack().cloneMatrix().invert3x3() );
Then you could translate the bullet to the Camera's position in World space.  Then fire it in the direction of Camera.getDriection().

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Flier Match
« Reply #108 on: October 20, 2008, 04:37:27 pm »
Thats exactly what I am doing. But the bullet is rotated 90 degrees and I dont know why. another problem is that I set the initial position of the bullet on the camera.getPosition SimpleVector but is not being fired exactly from the camera position. And when I move the camera down and lookAt the old camera position I dont look ant the center of the bullet. I also checked about the pivot of the bullet and everything is right.

I will continue trying it and post the code by tomorrow to see if I can fix it on somehow.
Nada por ahora

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Flier Match
« Reply #109 on: October 20, 2008, 08:45:50 pm »
Another thing I thought of: are you loading the bullet model from a 3ds file?  If so, make sure the orientation on it is correct after loading.  I usually have to do something like this to make the object in jPCT match what the 3DS Max orientation looks like.  I always do this right after loading a 3DS model, before adding it to the world:

obj.rotateX( (float) Math.PI / 2 );
obj.rotateY( (float) Math.PI );
obj.rotateZ( (float) Math.PI );
obj.rotateMesh();
obj.setRotationMatrix( new Matrix() );

I'm not sure why the position is wrong though.  Could you post a link to the bullet model you are using, and I'll play around with it to see if I can help figure something out.
« Last Edit: October 20, 2008, 09:48:39 pm by paulscode »

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Flier Match
« Reply #110 on: October 20, 2008, 08:48:22 pm »
Well, I exported to a md2 model as is a very simple model. I checked the model orientation inside max and seems to be well, I will post everything by tomorrow, today I am at office and forgot my pen drive.

I will check that and try to post the project tomorrow.
Nada por ahora

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Flier Match
« Reply #111 on: October 20, 2008, 09:46:56 pm »
Ran a couple of tests on MD2 files created with 3DS MAX + QTip, and discovered that there is also an orientation difference with the MD2 format.  Unlike 3DS files, MD2 files only needed to be turned 90 degrees around the Y-axis.  Do this right after loading the file:

Code: [Select]
        myObject.rotateY( (float) Math.PI / 2 );
        myObject.rotateMesh();
        myObject.setRotationMatrix( new Matrix() );

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Flier Match
« Reply #112 on: October 20, 2008, 09:51:09 pm »
Thanks, that should solve the problem about the bullet orientation. But I am still having the problem that when setting the position of the bullet on the camera position , it is placed near but not in the exact place.
Nada por ahora

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Flier Match
« Reply #113 on: October 21, 2008, 04:38:31 pm »
 :-[ :-[

The problem about not being shot from the camera center was a problem when modeling the bullet. It was moved a bit from the center. Anyway rotating it the PI/2 over the Y axis was helpfull too. Now the bullets are being fired correctly.

Now my problem is that they doesnt fire any collision event. I added a collisionListener to the bullets but they does not fires the event. I have used the collision listener before when moving the crafts on the server but when shooting the bullets on the client they dont.

Basicly.

When I create the bullet I add the colissionlistener, the bullet and the map has CHECK_SELF | CHECK_OTHERS as the collision mode. I am calling the checkforcollision and checkforcollisionelipsoid methods and they doesnt fire any event. The project is posted at:

melssj5.paulscode.com/FlierMatch.zip

Egon, can you please replace the one in the download section with this new one, is still not finished but it is closest to be finished. And please can any one help me with the collisionListening on the bullets?

About the code: Well, I have this classes:

 - BulletThread (Thread for moving the bullets and detecting the collisions)
 - ManejadorDisparos ("ShotManager"--> add the bullets to the List of bullets to be moved, moves the loist of bullets, creates the predefined bullet types to be used in the game)
 - Disparo ("Shoot"--> Is the shot class, it has the position, direction, speed, and the bullet. Has the methods to move the bullet it has)
 - Bullet (Is an inherited class from Object3d that has the damage, type, sounds to play)

The code and var names are in Spanish and the code is a kind of messy but any help would be very appreciated. Actually the shots are being fired with the control key or the space key. They are being shoot from a class called ManejadorEventos an the end of the method EventosJuego.
« Last Edit: October 21, 2008, 05:03:38 pm by Melssj5 »
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Flier Match
« Reply #114 on: October 21, 2008, 07:56:52 pm »
Judging from a quick look and fighting with spanish method and class names ( ;) ), it seems to me that your code assumes that an Object3D created from another one by new Object3D(<Object3D>) inherits its source's listeners. That's not the case. Try to add the listeners to the newly created bullet not just to the blue print.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Flier Match
« Reply #115 on: October 21, 2008, 08:00:40 pm »
I am adding it to the new created bullet. I have a method on the Disparo class


public void setBulletListener (BulletListener BL) {
       bala.addCollisionListener(BL);
}


here I am adding the collition listener to the new created Bullet called "bala", bala is a global Bullet var inside the Disparo class.


Here on the ManejadorDisparos class, when I add a shot to the shot list I have:

Code: [Select]
public void addDisparo (SimpleVector pos, SimpleVector dir, int tipoBala, World mundo, Camera cam) {

Bullet bala=null;
if (tipoBala==Bullet.BULLET_BALA1) {
bala=new Bullet (bala1);
}
if (tipoBala==Bullet.BULLET_BALA2) {
bala=new Bullet (bala2);
}
if (tipoBala==Bullet.BULLET_MISIL1) {
bala=new Bullet (misil1);
}
if (tipoBala==Bullet.BULLET_MISIL2) {
bala=new Bullet (misil2);
}//CREATE THE BULLET
System.out.println ("Disparo AGREGADO EN POS: "+pos+" - DIR: "+dir);
Disparo D=new Disparo (pos, dir, SoundManager, bala, mundo, cam);
                          //SHOT CREATED WITH THE NEW BULLET
D.setBulletListener (ManejadorColisionesBalas);
                          //COLLISIONLISTENER ADDED TO THE NEW SHOT
disparos.add (D);
}


May it be due to my Bullet class is a subclass of Object3D and maybe is losing the capacity of firing events???? I am just guessing!
« Last Edit: October 21, 2008, 08:06:40 pm by Melssj5 »
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Flier Match
« Reply #116 on: October 21, 2008, 08:07:04 pm »
Yes, my fault...i didn't mean the listener but the collision mode. It won't be cloned either.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Flier Match
« Reply #117 on: October 21, 2008, 08:12:34 pm »
mmmmmmm Yes, I set The collision mode before constructing a new Bullet from the model. Well, I guess I should use a clone method the have an exact copy? I will set the CollisionMode after creating the bullet to see if it helps, I will post the results by tomorrow! Thanks a lot, and please replace the old version of my project beucasse that was a version in which nothing works! Hopefully I will finish the first realease of the game sooner. And of course after that I will have to spend some time modelling some good maps, spacecrafts, bullets, misiles, etc!
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Flier Match
« Reply #118 on: October 21, 2008, 08:23:33 pm »
cloning is just another way to get the same effect as new Object3D(<Object3D>). Just set the mode afterwards. Maybe i should clone it too...i'm undecided... ???

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Flier Match
« Reply #119 on: October 21, 2008, 11:06:25 pm »
Is the collisionMode keeped inside the world when serializing it?

Each tima a new player gets it, I send all the World from the server to the specified client. But I do not know if those objects inside that world will have the same collisionMode set on them.
Nada por ahora