Animation Environment

Thoughts on the further development of Haven & Hearth? Feel free to opine!

Re: Animation Environment

Postby y1yr » Mon Oct 31, 2011 9:24 am

If I possessed the means, if so, purchase the program for 2d animation, I try to do it.
User avatar
y1yr
 
Posts: 39
Joined: Wed May 11, 2011 1:51 pm
Location: East Europe

Re: Animation Environment

Postby burgingham » Mon Oct 31, 2011 9:40 am

AnnaC wrote:The majority of players will just see flat red boxes anyway. :D


...and isn't that just sad?

Glad our client always had opaque objects so I could always have both: The nice atmosphere the game creates and full sight on everything around me.
User avatar
burgingham
 
Posts: 8486
Joined: Fri Aug 14, 2009 10:58 pm

Re: Animation Environment

Postby Flame » Mon Oct 31, 2011 12:24 pm

from when i've updated the graphics, i admit that i'm sad to use the red squares. I use them only when i need or while i'm outside, because i really like those new graphics and, at last for some time, i'll enjoy those.
User avatar
Flame
 
Posts: 1834
Joined: Thu Oct 08, 2009 5:03 pm

Re: Animation Environment

Postby Gauteamus » Mon Oct 31, 2011 1:54 pm

y1yr wrote:If I possessed the means, if so, purchase the program for 2d animation, I try to do it.


MSPaint
GIMP
Image<<Bottleneck>>
What if Rosa Parks had a car?
User avatar
Gauteamus
 
Posts: 858
Joined: Fri May 29, 2009 7:16 pm

Re: Animation Environment

Postby boshaw » Mon Oct 31, 2011 2:33 pm

Just so you guys know there's more to it than just making another image and trying to put it in the resource.

Whenever you extract all the resources you notice you get those files that end with something like "nonimageLayer" which are where the whole Resource Layers are stored.

There are 9 different layers:
Image,Tile,Neg,Anim,Tileset,Pagina,AButton,Audio,Tooltip

Some are obvious as to what they do and the one for animation is Anim.

So basically if you want to make something animated you would most likely have to edit this Anim nonimageLayer file to include your extra Images

further lets take a look at what the Anim layer even is:
Code: Select all
    public class Anim extends Layer {
   private int[] ids;
   public int id, d;
   public Image[][] f;
      
   public Anim(byte[] buf) {
       id = Utils.int16d(buf, 0);
       d = Utils.uint16d(buf, 2);
       ids = new int[Utils.uint16d(buf, 4)];
       if(buf.length - 6 != ids.length * 2)
         throw(new LoadException("Invalid anim descriptor in " + name, Resource.this));
       for(int i = 0; i < ids.length; i++)
      ids[i] = Utils.int16d(buf, 6 + (i * 2));
   }
      
   public void init() {
       f = new Image[ids.length][];
       Image[] typeinfo = new Image[0];
       for(int i = 0; i < ids.length; i++) {
      LinkedList<Image> buf = new LinkedList<Image>();
      for(Image img : layers(Image.class)) {
          if(img.id == ids[i])
         buf.add(img);
      }
      f[i] = buf.toArray(typeinfo);
       }
   }
    }


So first of all you can see in the constructor of this layer it'll fetch its own id, 'd' (not sure what that does) and then inits the array of ids which would be the Images that are part of the animation.

Now move on to the init method and that's where you see the actual storing of the Images that are part of the animation and if you look closely you'll notice one of the lines in the inner loop is : "if(img.id == ids[i])" thus showing if you wanted to add an image to an existing animation or make a new animation you would have to provide the Image's id. One could also conclude from this source snipit that it seems that one set of images for 1 type of animation should have the same id as the other images that are part of that animation set. The Image Object is a 2D array so it can hold multiple sets given by the length of the ids array.


Code: Select all
   public Image(byte[] buf) {
       z = Utils.int16d(buf, 0);
       subz = Utils.int16d(buf, 2);
       /* Obsolete flag 1: Layered */
       nooff = (buf[4] & 2) != 0;
       id = Utils.int16d(buf, 5);
       o = cdec(buf, 7);
       try {
      img = ImageIO.read(new ByteArrayInputStream(buf, 11, buf.length - 11));
       } catch(IOException e) {
      throw(new LoadException(e, Resource.this));
       }
       if(img == null)
      throw(new LoadException("Invalid image data in " + name, Resource.this));
       sz = Utils.imgsz(img);
   }


The above is a snip it of the Image constructor which shows the structure of its layer. This layer also obviously contains the actual Image.

whenever you use the extractor on resource files you also get those things called "png.flags" which might be what these refer to, I can't confirm that though.



So anyway, none of you are probably going to be able to make new/edit animations until you can come up with your own anim layer decoder/encoder and image decoder/encoder (that includes the images data along with the image, my guess is within that "png.flags" file) And actually it probably wouldn't be hard at all to write your own decoder/encoder since you can literally just copy the Layer's constructor to decode it into ints,etc and then to encode it back to proper form my guess is that loftar is saving them just by saving the whole class since they are Serializable which allows java to write the whole object to a file.

Edit: I don't think the Anim is saved by Serializable actually since if it was then he would be saving the Image[][] 2d array in the nonimageLayer which he isn't.

Edit #2:
https://github.com/boshaw/LayerUtil
I put together a quick Anim Layer decoder that you guys can use, read the README for instructions
I'll make it more formal + gui based later on when i have the time and allow it to support all non-image layers since im sure some of you will find use for editing the other layers
User avatar
boshaw
 
Posts: 1590
Joined: Tue Jun 01, 2010 10:22 pm

Re: Animation Environment

Postby Tj2u1 » Tue Nov 01, 2011 2:31 pm

A 6 stage animation for the taller vegetation would not be likely to do harm to anyone's computer,unless your computer is made of cardboard with holes punched in it.I had a cowpat computer once,it ran more complex and many numerous things simultaneously then trees swaying in the wind. But if your still hung up on that,why not make some kind of code that makes wind blow and it effects only some of the trees and not all of them.
Tj2u1
 
Posts: 8
Joined: Mon Sep 05, 2011 6:34 pm

Re: Animation Environment

Postby TeckXKnight » Tue Nov 01, 2011 2:38 pm

Tj2u1 wrote:A 6 stage animation for the taller vegetation would not be likely to do harm to anyone's computer,unless your computer is made of cardboard with holes punched in it.I had a cowpat computer once,it ran more complex and many numerous things simultaneously then trees swaying in the wind. But if your still hung up on that,why not make some kind of code that makes wind blow and it effects only some of the trees and not all of them.

You heard him guys, dynamic trees can't overload your computer, lets all play crysis on maxed settings.
User avatar
TeckXKnight
 
Posts: 8274
Joined: Tue Jul 13, 2010 2:31 am
Location: How Do I?

Re: Animation Environment

Postby Shadow7168 » Tue Nov 01, 2011 3:34 pm

Oh god, imagine the amount of lag wheat fields would have...
Potjeh wrote:They're using swords as throwing weapons now? Damn cheaters!

MagicManICT wrote:Most raiders aren't into choking another man's chicken. They can do some pretty gay shit, but that's usually the line.
User avatar
Shadow7168
 
Posts: 753
Joined: Tue Aug 03, 2010 8:33 pm

Re: Animation Environment

Postby TeckXKnight » Tue Nov 01, 2011 3:36 pm

Shadow7168 wrote:Oh god, imagine the amount of lag wheat fields would have...

You don't need to imagine, just play on the default clients. They'll usually just crash your client as is.
User avatar
TeckXKnight
 
Posts: 8274
Joined: Tue Jul 13, 2010 2:31 am
Location: How Do I?

Re: Animation Environment

Postby cobaltjones » Tue Nov 01, 2011 3:38 pm

To be fair the lag is due to poor optimization. There's no instance where a modern computer shouldn't be able to display hundreds of 2D tiles at full speed.
User avatar
cobaltjones
 
Posts: 2725
Joined: Tue Dec 07, 2010 1:27 am

PreviousNext

Return to Critique & Ideas

Who is online

Users browsing this forum: Claude [Bot] and 4 guests