forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

2D Rotation (libgs or gsKit, etc)?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
Spectre



Joined: 07 Aug 2009
Posts: 6
Location: The third dimension with two-dimensional thoughts

PostPosted: Mon Aug 10, 2009 3:09 pm    Post subject: 2D Rotation (libgs or gsKit, etc)? Reply with quote

In terms of simplicity, which library would be best to use for 2D sprite rotation/animation? I've seen the awesome power of properly coded libgs applications, but can't find anything in regards to rotation... Which leads me to believe that sequentially rotated image frames would have to be preloaded into vram to get the job done. Too wasteful for my tastes, yet still functional enough to help me get by.

From what I've gathered in studying gsKit, I'd have to use textured quads for 2D sprites (much like OpenGL or DirectX8+), using gsKit_prim_sprite_texture & gsKit_prim_quad_texture_3d. I'm not too knowledgeable on using 3D math for simple 2D projections... but for rotations, I'm assuming it'd be as simple as spinning the 2D primitive from it's central origin (along the Z axis)?

Is there something I'm missing? What's the best way to get the job done?
Back to top
View user's profile Send private message
ps2devman



Joined: 09 Oct 2006
Posts: 265

PostPosted: Wed Aug 12, 2009 3:48 pm    Post subject: Reply with quote

You can start with initial fantasy 3D engine.
Since you can provide your 3DS mesh and a texture, you can
easily just draw a textured square in space at a constant Z
(example supplies a textured fighter or a textured biplane)

http://minilgos.perso.sfr.fr/ps2_initial_fantasy.zip

(it uses the professional game devs method : full speed dma transferts
there is a bit of gskit just for a few text and line drawing and inits)
Back to top
View user's profile Send private message
Fakeuser



Joined: 01 Sep 2007
Posts: 15

PostPosted: Sun Aug 16, 2009 1:46 pm    Post subject: Reply with quote

Hi,ps2devman,Wonderful example!Thank you!
Where can i get following examples mentioned in readme.txt?
url seems broken.

http://home.tele2.fr/~fr-51785/ps2_qbert.zip (2D sprites)
http://home.tele2.fr/~fr-51785/ps2_pong.zip (wiimote)
http://home.tele2.fr/~fr-51785/ps2_afl_pktdrv.zip (packet driver)
Back to top
View user's profile Send private message
ifcaro



Joined: 19 Oct 2008
Posts: 23

PostPosted: Mon Aug 17, 2009 11:24 pm    Post subject: Reply with quote

ps2devman wrote:
You can start with initial fantasy 3D engine.
Since you can provide your 3DS mesh and a texture, you can
easily just draw a textured square in space at a constant Z
(example supplies a textured fighter or a textured biplane)

http://minilgos.perso.sfr.fr/ps2_initial_fantasy.zip

(it uses the professional game devs method : full speed dma transferts
there is a bit of gskit just for a few text and line drawing and inits)


I compiled it but only reset my ps2 :S

EDIT: I added this in system.c and now works :D

Code:
    gsGlobal->Mode = GS_MODE_NTSC;
    gsGlobal->Interlace = GS_INTERLACED;
    gsGlobal->Field = GS_FIELD;
    gsGlobal->Width = 640;
    gsGlobal->Height = 448;
Back to top
View user's profile Send private message
ps2devman



Joined: 09 Oct 2006
Posts: 265

PostPosted: Wed Aug 19, 2009 10:21 pm    Post subject: Reply with quote

Thank you all for trying and fixing.

I had to change my ISP (my ISP got actually bought by another one)
replace http://home.tele2.fr/~fr-51785 with the new path and you
will find other files
Back to top
View user's profile Send private message
Spectre



Joined: 07 Aug 2009
Posts: 6
Location: The third dimension with two-dimensional thoughts

PostPosted: Fri Aug 21, 2009 6:54 am    Post subject: Reply with quote

Umm...
ps2devman wrote:
Thank you all for trying and fixing.

I had to change my ISP (my ISP got actually bought by another one)
replace http://home.tele2.fr/~fr-51785 with the new path and you
will find other files

http://minilgos.perso.sfr.fr/ps2_gasp_vcl.zip
http://minilgos.perso.sfr.fr/ps2_qbert.zip (2D sprites)
http://minilgos.perso.sfr.fr/ps2_pong.zip (wiimote)
http://minilgos.perso.sfr.fr/ps2_afl_pktdrv.zip (packet driver)

PS: Thanks, ps2devman! Very clean & informational stuff, there.
Back to top
View user's profile Send private message
Spectre



Joined: 07 Aug 2009
Posts: 6
Location: The third dimension with two-dimensional thoughts

PostPosted: Fri Aug 21, 2009 8:06 am    Post subject: Bug Reply with quote

In ./ps2_initial_fantasy/main.c:

Code:
   *(p++)=   ((th&3)<<30)|
         (tw<<26)|
         (texture->PSM<<20)|
         (texture->TBW<<14)|
         (texture->Vram>>8);

MINGW32 wrote:
main.c: In function `init_vu1':
main.c:174: structure has no member named `TBW'
make: *** [main.o] Error 1

... Seems ../gsKit/gsInit.h doesn't have 'TBW' defined in the GSTEXTURE struct.
My gsKit version is an unedited v0.2 (and compiles just fine), if that helps.
Back to top
View user's profile Send private message
ifcaro



Joined: 19 Oct 2008
Posts: 23

PostPosted: Fri Aug 21, 2009 8:15 am    Post subject: Re: Bug Reply with quote

Spectre wrote:
In ./ps2_initial_fantasy/main.c:

Code:
   *(p++)=   ((th&3)<<30)|
         (tw<<26)|
         (texture->PSM<<20)|
         (texture->TBW<<14)|
         (texture->Vram>>8);

MINGW32 wrote:
main.c: In function `init_vu1':
main.c:174: structure has no member named `TBW'
make: *** [main.o] Error 1

... Seems ../gsKit/gsInit.h doesn't have 'TBW' defined in the GSTEXTURE struct.
My gsKit version is an unedited v0.2 (and compiles just fine), if that helps.


I have compiled the latest code from svn and it has worked. But sometimes I get the error "ERROR: Not enough VRAM for this allocation!" when trying to make pal mode or for some reason I dont know :S
Back to top
View user's profile Send private message
ps2devman



Joined: 09 Oct 2006
Posts: 265

PostPosted: Sat Aug 22, 2009 5:06 am    Post subject: Reply with quote

dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
D_CTRL_STD_OFF, D_CTRL_RCYC_8);

...to:

dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);

in system.c

(it's a note I took from other users posting fixes as well)
Back to top
View user's profile Send private message
ifcaro



Joined: 19 Oct 2008
Posts: 23

PostPosted: Mon Aug 24, 2009 10:10 am    Post subject: Reply with quote

ps2devman wrote:
dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
D_CTRL_STD_OFF, D_CTRL_RCYC_8);

...to:

dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC,
D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);

in system.c

(it's a note I took from other users posting fixes as well)


Thanks Ps2devman but I already had it changed.

The problem was that when loading the texture, did not have enough VRAM.

I solved by disabling DoubleBuffering, I dont know if this will change something.

PS: Here is the file vu.c edited to eliminate warnings when compiling.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group