3D Sprites Library

Learn to use DS Game Maker by Example.

3D Sprites Library

Postby Buck_7 » January 24th, 2015, 7:59 pm

Hi everyone!

Here's a lib that allows you to load sprites using the DS's 3D GPU (whatever that means)
Credit to Foxi4 for his generous help over the years(and helping me with this ;) )

With this, you may load up to "1024 sprites" so says PAlib. Let's just say more than 128 sprites which is the maximum number of normal sprites you may load in DSGM. All sprites may also be zoomed/rotated.

This also uses up layer 0 so if you want to have text or backgrounds above the sprites, you'll have to initialize text onto a different layer.

This function will help to swap BG layers:
Code: Select all
PA_SetBgPrioSeq (u8 screen, u8 priority0, u8 priority1, u8 priority2, u8 priority3)


There is a bit of an issue with deleting. It's probably best to avoid deleting at all if possible .

___________________________________________________________________________________________


1. To use it in your project, add it to Game Settings -> Coding -> Include Files

Library
DSGM_Nitro3DSprites.h
(4.21 KiB) Downloaded 210 times

2. Then take your sprite and convert it using PAGfx:

Converter
PAGfx.zip
(118.49 KiB) Downloaded 222 times

Comvert I.PNG

Locate the converted files inside PAGfx\bin
You should have two files; a Sprite_pal.bin and a Sprite_texture.bin

3. Add these two files in Game Settings - > Coding -> NitroFS Files

___________________________________________________________________________________________

Explanation coming soon
Here are the list of functions

FAT_3DSpriteInit();
PA_3DProcess();
FAT_LoadPalette(char* Name, u8 PalID);
FAT_LoadTexture(char* Name, u16 TexID, u16 Width, u16 Height, u8 Type);
FAT_Create3DSpriteFromTex(u16 Sprite, u16 GfxID, u16 Width, u16 Height, u8 Palette, s16 X, s16 Y);
FAT_Delete3DSprite(u16 ID);
FAT_DeleteAll3DSprites();
Next_3DSprite();
Count_3DSprites();
FAT_BasicCreate3DSprite(u16 SpriteNum, u16 GfxID, char* Name, u16 Width, u16 Height, u8 Palette, s16 X, s16 Y, u8 Type);
FAT_Create3DSpriteII(u16 SpriteNum, u16 GfxID, char* Name, u16 Width, u16 Height, u8 Palette, s16 X, s16 Y, u8 Type);
FAT_Create3DSpriteIII(u16 SpriteNum, u16 GfxID, u16 Width, u16 Height, u8 Palette, s16 X, s16 Y, u8 Type)


Code: Select all
FAT_3DSpriteInit();
This is used to initialize the 3D Sprites. Always use this once in the create event of an object in a room.

Code: Select all
PA_3DProcess();
This is needed to display your sprites!! Use it in the step event!!

Code: Select all
FAT_LoadPalette(char* Name, u8 PalID)
This is used to load the color palette the sprite uses. Type the name of the file encased in "quotation marks" without the _Pal extension. eg Sprite_Pal.bin would be FAT_LoadPalette(Sprite, 0). There are 0-255 color palette slots. Sprites with the same palette slot Id will end up using the same list of colors.

Code: Select all
FAT_LoadTexture(char* Name, u16 TexID, u16 Width, u16 Height, u8 Type)
This loads the sprite's graphic.
Name: Name of texture eg. "Sprite"_Texture.bin (Sprite in quote marks).
TexID: Texture slot ID. Sprites having the same ID slot will use the same graphic.
Width: Width of sprite.
Height: Height of sprite.
Type: If your image is a 256 color image use TEX_256COL. For 4 color images use TEX_4COL, for 16 color images: TEX_16COL

Code: Select all
FAT_Create3DSpriteFromTex(u16 Sprite, u16 GfxID, u16 Width, u16 Height, u8 Palette, s16 X, s16 Y);
This creates a sprite from existing resources(after you load the palette and texture files). Note: All sprites that are the same using FAT_Create3DSpriteFromTex will render the same frame when animated

Code: Select all
FAT_Delete3DSprite(u16 ID);
This deletes a sprite. eg.
Code: Select all
FAT_Delete3DSprite(5); //deletes sprite number 5.


Code: Select all
FAT_DeleteAll3DSprites();
This function deletes all Sprites.

Code: Select all
Next_3DSprite();
Similar to Next_Instance(), this function returns the next usable sprite number.

Code: Select all
Count_3DSprites();
Akin to the function Count_Instances(), this function returns the number of sprites currently loaded.

Code: Select all
FAT_BasicCreate3DSprite(u16 SpriteNum, u16 GfxID, char* Name, u16 Width, u16 Height, u8 Palette, s16 X, s16 Y, u8 Type);
Unlike load sprite from tex function, this function includes it all in one.
___________________________________________________________________________________________

Examples
User avatar
Buck_7
 
Posts: 1460
Joined: February 19th, 2011, 1:44 am

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

cron