Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / 3d spritesheet

Author
Message
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 19th Jan 2013 14:14 Edited at: 19th Jan 2013 14:27
Hi guys, I just started experimenting with the 3D commands in AppGameKit and im wondering if there is a way to use spritesheets with 3d objects. Im guessing it saves the same amount of performace as it would with 2d. But are there any commmands to do this currently?

I guess I could load the spritesheet then make sprites of it and save the images as separate sprites, but I don'r realy think that would give any performance increase

Im using v1088 beta Tier 2
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 19th Jan 2013 17:07 Edited at: 19th Jan 2013 17:10
Just load the images using loadSubImage and you can apply them as textures. I haven't tried it yet but I was planning on converting the DBPro code for creating explosions from newsletter 43 I think...

Edit: it was newsletter 46, near the bottom if anyone's interested...


this.mess = abs(sin(times#))
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 19th Jan 2013 17:19
Quote: " loadSubImage"


That sounds like a good idea
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 22nd Jan 2013 17:52
I finaly got around to working on this again, however, I don't realy understand what the subimage.txt should contain.

Im guessing that it contains the position of the subimages within the image, but in what way. And how do I tell the command what image I want to load. Because if I understand the documentation correctly, the command has no way of knowing that.
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 22nd Jan 2013 17:58
Here's the format:

id:x:y:width:height

So, example:
1:5:5:60:60

Gives you a rect with ID of 1 and dimensions of:
X1 5, Y1 5, X2 65, Y2 65

Follow me on twitter! @MotionStruct
Motion Struct blog
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 22nd Jan 2013 18:17
If you have gridded your images correctly, you should also be able to get the images using

You do not need a subimage.txt doing it that way. You only need the sub image if your images are not gridded, and therefore need guidance on where to grab things.

The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 22nd Jan 2013 21:15
Quote: "setspriteanimation(sprite,width,height,frames)"


That wouldnt work for 3d though?

Quote: "Here's the format:

id:x:y:width:height

So, example:
1:5:5:60:60

Gives you a rect with ID of 1 and dimensions of:
X1 5, Y1 5, X2 65, Y2 65"


Is the x and y the start of the frame (the top left corner) or is it the center or something like that.

Also, how do I tell the command what subimage I want to load?
TrezSoft
AGK Tool Maker
11
Years of Service
User Offline
Joined: 8th Nov 2012
Location: UK
Posted: 22nd Jan 2013 21:28
x and y are the top left corner of the subimage x2 and y2 are the width and height.

LoadSubImage(atlas image id,"id used in the subimages file")
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 22nd Jan 2013 21:37 Edited at: 22nd Jan 2013 22:02
Oh, that makes sense. I will have to try it then

Edit: This is what the documentation says about the command

As far as I can see, there is no way of saying what subimage ID you want to use
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 22nd Jan 2013 22:21 Edited at: 22nd Jan 2013 22:24
Quote: "sImageFilename - The filename of the sub image as stored in subimages.txt. Do not use a path before the filename."


That is the ID.

For instance, if you have such subimages text file:

1:0:0:32:32
2:32:32:32:32

And you want to load those two subimages, you do:



I believe that you can also name your IDs in different way than giving them numbers.

This should work too:

tree:0:0:32:64
rock:32:0:32:32






It's just easier to load all subimages when their IDs are 1,2,3... and so on. Consider this example:



That'd load subimages with id from 1 to 10 inclusive into an array.

Follow me on twitter! @MotionStruct
Motion Struct blog
TrezSoft
AGK Tool Maker
11
Years of Service
User Offline
Joined: 8th Nov 2012
Location: UK
Posted: 22nd Jan 2013 22:32
Yes you can name the sub image id's with the full file names if you want, or anything else for that matter as long as it does not have the seperator in the name.

I use texture packer and maintain the original file name in the subimages file for reference:

myOriginalImage1.png:0:0:64:64

etc
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 22nd Jan 2013 22:50
Oh, so thats how it works. Im guessing that there can only be one spritesheet per folder then. And that the subimage file has to be named subimages.txt
TrezSoft
AGK Tool Maker
11
Years of Service
User Offline
Joined: 8th Nov 2012
Location: UK
Posted: 22nd Jan 2013 22:54 Edited at: 22nd Jan 2013 22:55
No you can have as many as you need.

If your Atlas Image file is named:

myatlas1.png

then the atlas subimage file would be named:

myatlas1 subimages.txt

(NOTE: its subimages not subimage)
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 22nd Jan 2013 23:22
Oh, I finaly got it working. Thanks for the help guys. The documentation could use some updating for that command

Login to post a reply

Server time is: 2024-05-06 11:00:29
Your offset time is: 2024-05-06 11:00:29