Raydium 3D Game Engine

Official forum for everything about Raydium, ManiaDrive, MeMak, ...
It is currently Mon Oct 21, 2019 1:04 pm

All times are UTC




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: sprites
PostPosted: Thu Aug 09, 2007 10:06 am 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
I'm working on the sprites(2d sub-engine) . I have put this on the top of my TODO cause it's needed for a job (that will be paid).

I'm pretty sure that Raydium has "something" to put a QUAD polygon(i have draw it directly using openGL) always facing the camera. Right?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 09, 2007 2:02 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2590
Location: gnniiiii (Scrat)
There's many ways to do it, but OSD is probably the better way. This function, for example, should do the trick :
Code:
void raydium_osd_draw_name (char *tex, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);


There's a few others (with 2D clipping, for example) and we may write quickly missing features, if needed.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 22, 2007 8:29 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Well, in fact, the 2D sprites should placed in a 3D world, so i need correct 3D positions for the sprites. I mean screen coordinates are not usefull here.

Maybe i need similar to the debug of ODE, where the name of the objects appears in its 3D place.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 12:58 am 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Well, here is the first try re-using osd functions.
http://pastebin.com/f4bcca963

Big problem: Using this way i can not use Depth test...
As sprites should be integrated into a 3D world, the 3D objects will be sometimes in front of the sprites and the sprites should be occluded by them, so OSD, i think, is a bad option.
Only i see one way using OSD: Guess which is the Z coordinate (3D) for the 0,0,0 of the sprite and then draw its depth buffer with that value... but i'm not sure if this can be done.

Ideas please


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 1:14 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2590
Location: gnniiiii (Scrat)
Particle system do such things, it's called "billboarding". See raydium_particle_draw_all() for involved maths. If you plan to write something like this, it's important to factorize the code (for example particle system may use your billboard function).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 24, 2007 9:18 am 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
hmm, you mean i should not repeat code used in both cases, right?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 08, 2007 12:26 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2590
Location: gnniiiii (Scrat)
Exactly, yes. This is probably quiet easy in this case.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 16, 2007 8:41 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
i'm making a try with the sprites and worked. But when i tried to modify a few things i noticed i have no idea about the maths involved.

What are rx,ry,rz,ux,uy,uz?
And why are they sumed(+) and taked away(-) in such strange order?

I'm refering to the code of the functions raydium_particle_draw and raydium_particle_draw_all boths in particle2.c


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 23, 2007 4:53 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2590
Location: gnniiiii (Scrat)
Hoping I'm not answering too late (this year is very ("real") work loaded ... :/ ).

The basics are :
- raydium_particle_draw_all() extracts MODELVIEW matrix from OpenGL stack to compute the current "camera plane" in the 3D space.
- Then raydium_particle_draw is using U and R vectors to draw the particules on parallel (to the camera) planes, centered on "p->position" ("minus" and "plus" are here to draw the particule around its center, simply).

Is it a bit more clear ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 24, 2007 10:46 am 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Aham... i'll take a look again this night with this info. Maybe it could be a bit clearer. Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 06, 2007 1:35 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
First test ready.

You can download the files (and also there is a binary) from here:

http://vicentecarro.dyndns.org/masguada ... h1.tar.bz2

Currently is all ugly, dirty and no raydium styled.

About its funcionality, it loads a sprite.sprite file that indicate which texture is related with each frame and which s and t coordinates are the right ones.

Whit this format, one sprite could have frames from different textures.

Also all the textures are "searched" at load, storing just the texture ID, not the texture names (Since all internal of sprites don't need human interaction). This have increased highly the rendering speed of sprites.

Still a lot of job to do, but what do you say about this?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 07, 2007 5:44 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2590
Location: gnniiiii (Scrat)
Haven't look at the code yet, but the result is very good. Looks nice !

There's an alpha filter for "cutout textures" in render.c (glAlphaFunc), and it's not the first time I found that the default value (0.5) is not good. When you "zoom" a lot on the animated character of your demo, the borders looks a bit strange.

We must probably try to update this value to almost one (0.9) to correct this strange rendering, I think. Test by yourself and feel free to commit this small change if you want ;)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 07, 2007 8:07 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Done.
With 0.78 looks nice.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 08, 2007 5:31 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
New cleaner raydium-friendly (but not final) version.

http://pastebin.com/f60b0d8d8


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 08, 2007 8:39 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2590
Location: gnniiiii (Scrat)
Looks almost ok. There's still some duplicated code of particles2.c, it's important to factorize this. A small point : it seems that this code is framerate dependent, no ?

How do you plan your API to move sprites ? Change animation ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


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 post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group