Exemplo n.º 1
0
 public void tilemap(Message msg) {
   while (!msg.eom()) {
     int id = msg.uint8();
     String resnm = msg.string();
     int resver = msg.uint16();
     nsets[id] = new Resource.Spec(resnm, resver);
   }
 }
Exemplo n.º 2
0
 public static int decnum(Message sdt) {
   if (sdt == null) return (0);
   int ret = 0, off = 0;
   while (!sdt.eom()) {
     ret |= sdt.uint8() << off;
     off += 8;
   }
   return (ret);
 }
Exemplo n.º 3
0
 public Res cons(Resource res, Message buf) {
   int id = buf.uint16();
   Res ret = new Res(res, id);
   while (!buf.eom()) {
     String nm = buf.string();
     Object[] args = buf.list();
     if (nm.equals("linear")) {
       /* XXX: These should very much be removed and
        * specified directly in the texture layer
        * instead. */
       ret.linear = true;
     } else if (nm.equals("mipmap")) {
       ret.mipmap = true;
     } else {
       ResCons2 cons = rnames.get(nm);
       if (cons == null)
         throw (new Resource.LoadException("Unknown material part name: " + nm, res));
       ret.left.add(cons.cons(res, args));
     }
   }
   return (ret);
 }
Exemplo n.º 4
0
 public Res cons(final Resource res, Message buf) {
   int id = buf.uint16();
   Res ret = new Res(res, id);
   GLState light = Light.deflight;
   while (!buf.eom()) {
     String thing = buf.string().intern();
     if (thing == "col") {
       Color amb = col(buf);
       Color dif = col(buf);
       Color spc = col(buf);
       double shine = buf.cpfloat();
       Color emi = col(buf);
       ret.states.add(new Colors(amb, dif, spc, emi, (float) shine));
     } else if (thing == "linear") {
       ret.linear = true;
     } else if (thing == "mipmap") {
       ret.mipmap = true;
     } else if (thing == "nofacecull") {
       ret.states.add(nofacecull);
     } else if (thing == "tex") {
       final int tid = buf.uint16();
       ret.left.add(
           new Res.Resolver() {
             public void resolve(Collection<GLState> buf) {
               for (Resource.Image img : res.layers(Resource.imgc)) {
                 if (img.id == tid) {
                   buf.add(img.tex().draw());
                   buf.add(img.tex().clip());
                   return;
                 }
               }
               throw (new RuntimeException(
                   String.format("Specified texture %d not found in %s", tid, res)));
             }
           });
     } else if (thing == "texlink") {
       final String nm = buf.string();
       final int ver = buf.uint16();
       final int tid = buf.uint16();
       ret.left.add(
           new Res.Resolver() {
             public void resolve(Collection<GLState> buf) {
               Indir<Resource> tres = res.pool.load(nm, ver);
               for (Resource.Image img : tres.get().layers(Resource.imgc)) {
                 if (img.id == tid) {
                   buf.add(img.tex().draw());
                   buf.add(img.tex().clip());
                   return;
                 }
               }
               throw (new RuntimeException(
                   String.format(
                       "Specified texture %d for %s not found in %s", tid, res, tres)));
             }
           });
     } else if (thing == "light") {
       String l = buf.string();
       if (l.equals("pv")) {
         light = Light.vlights;
       } else if (l.equals("pp")) {
         light = Light.plights;
       } else if (l.equals("n")) {
         light = null;
       } else {
         throw (new Resource.LoadException("Unknown lighting type: " + thing, res));
       }
     } else {
       throw (new Resource.LoadException("Unknown material part: " + thing, res));
     }
   }
   if (light != null) ret.states.add(light);
   return (ret);
 }