Exemplo n.º 1
0
 /** Allow this dedicated thread to handle input from this client */
 public void run() {
   try {
     ClientMessage myMessage = (ClientMessage) clObj.getObIn().readObject();
     this.username = myMessage.getSender();
     clObj.setName(username);
     System.out.println("Server gets: " + myMessage.toString());
     clientList.userConnect(username, clObj);
   } catch (Exception e) {
     JOptionPane.showMessageDialog(panel, "Unrecoverablable error in input stream");
     e.printStackTrace();
     System.exit(1);
   }
   while (true) {
     try {
       ClientMessage myMessage = (ClientMessage) clObj.getObIn().readObject();
       System.out.println("Server gets: " + myMessage.toString());
       List<ObjectOutputStream> destinations =
           clientList.getUserOutStreams(myMessage.getDestinations());
       for (ObjectOutputStream s : destinations) {
         s.writeObject(new ServerMessage(this.username, myMessage.getMessage()));
       }
     } catch (SocketException e) {
       System.out.println("Disconnecting user: "******"Some other error in client handler (run)");
       JOptionPane.showMessageDialog(panel, "Unrecoverablable error in input stream");
       ex.printStackTrace();
       System.exit(1);
       break;
     }
   }
 }
Exemplo n.º 2
0
  static {
    try {
      SimpleStream ss = new SimpleStream("data/crate.3ds");
      bluePrint = new ClientObject(Loader.load3DS(ss.getStream(), 0.09f)[0]);
      ss.close();
      bluePrint.translate(0, -4.3f, -5);
      bluePrint.translateMesh();
      bluePrint.getTranslationMatrix().setIdentity();
      TextureInfo ti = null;
      if (!Globals.normalMapping) {
        bluePrint.setTexture("crate");
      } else {
        ti = new TextureInfo(TextureManager.getInstance().getTextureID("crate"));
        ti.add(
            TextureManager.getInstance().getTextureID("cratenormals"), TextureInfo.MODE_MODULATE);
        bluePrint.setTexture(ti);
      }

      bluePrint.getMesh().compress();
      bluePrint.build();

      Object3D child = null;
      Animation anim = new Animation(6);
      anim.setClampingMode(Animation.USE_CLAMPING);
      anim.createSubSequence("explosion");

      Loader.setVertexOptimization(false);

      for (int i = 1; i < 6; i++) {
        String name = "data/crate" + i + ".3ds";
        ss = new SimpleStream(name);
        Object3D obj = Loader.load3DS(ss.getStream(), 4.4050189f)[0];
        ss.close();
        obj.translate(0, -5f, -0.6f);
        obj.translateMesh();
        obj.getTranslationMatrix().setIdentity();
        if (!Globals.normalMapping) {
          obj.setTexture("crate");
        } else {
          obj.setTexture(ti);
        }
        obj.build();

        if (i == 1) {
          child = obj;
          child.setMesh(child.getMesh().cloneMesh(true));
        }
        obj.getMesh().compress();
        anim.addKeyFrame(obj.getMesh());
      }
      child.setAnimationSequence(anim);

      Loader.setVertexOptimization(true);

      childBluePrint = child;

      /*
       * for (int i=0; i<child.getMesh().getBoundingBox().length; i++) {
       * System.out.print(child.getMesh().getBoundingBox()[i]);
       * System.out.println("="+bluePrint.getMesh().getBoundingBox()[i]);
       * }
       */
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 3
0
 public void addToWorld(World world) {
   super.addToWorld(world);
   this.world = world;
 }