3D in DSGM

Learn to use DS Game Maker by Example.

3D in DSGM

Postby Foxi4 » July 22nd, 2013, 12:52 am

Not really a tutorial - more of a Proof-of-Concept project. Because y'know, everybody since the dawn of forever always chants that "You can't use 3D in DSGM". There you have it then, 3D in DSGM5 using libnds's pseudoOpenGL function set. The texture is a 16-bit uncompressed raster (converted with GRIT), Globals are declared in an included .h file for the sake of convenience. The file is richly commented so everyone should have a clue on what's going on. The source is heavily based on libnds's Textured Quad example.

Enjoy the little floating Quad! :grin:

Tested on DSGM5.12
*File Removed, improved version below*
Last edited by Foxi4 on July 22nd, 2013, 3:27 am, edited 1 time in total.
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1221
Joined: December 31st, 2010, 3:25 am

Re: 3D in DSGM

Postby boe6eod7nty » July 22nd, 2013, 1:14 am

nicely done :)
that akward moment when somthing akward happens.....
wait.....
what?
boe6eod7nty
 
Posts: 209
Joined: September 11th, 2012, 4:28 pm
Location: USA. WI.

Re: 3D in DSGM

Postby Foxi4 » July 22nd, 2013, 1:17 am

Myeh. It's 90% copy-paste and 10% optimization so that it works under DSGM conditions. I was just bored out of my mind and wanted to show that it "can be done". ;)
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1221
Joined: December 31st, 2010, 3:25 am

Re: 3D in DSGM

Postby Foxi4 » July 22nd, 2013, 3:27 am

Version with the texture embedded into the ROM as a .c file, since NitroFS likes to be quirky and doesn't work on all flashcarts/loaders (or at all when it doesn't feel like it). :grin:

Tested on DSGM5.12
DSGM3D_v2.dsgm
(8.37 KiB) Downloaded 284 times
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1221
Joined: December 31st, 2010, 3:25 am

Re: 3D in DSGM

Postby Buck_7 » July 22nd, 2013, 3:40 am

Cool, its kinda neat.You should get bored more often XD.
[EDIT]: Woah, did you type all that out for the DSGM3D.c file?!
User avatar
Buck_7
 
Posts: 1460
Joined: February 19th, 2011, 1:44 am

Re: 3D in DSGM

Postby Foxi4 » July 22nd, 2013, 3:43 am

DSGM3D.c is a file generated by GRIT. It's literally the Bitmap I used for the texture, just in raw form. ;)
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1221
Joined: December 31st, 2010, 3:25 am

Re: 3D in DSGM

Postby Buck_7 » July 22nd, 2013, 3:54 am

Ah, I see. So these are libnds code in there? It's alot just for one 3D image.
User avatar
Buck_7
 
Posts: 1460
Joined: February 19th, 2011, 1:44 am

Re: 3D in DSGM

Postby Foxi4 » July 22nd, 2013, 3:57 am

The texture is just a .bmp converted into text form without a palette, each number represents the color of a given pixel until 128x128 pixels are all covered - you don't actually type it yourself.

As for "being a lot of code", all this can be closed in convenient functions (or DSGM Actions), this is standard OpenGL syntax. Nobody does it the way it's shown - it's like this for the purpose of showing how it works under the surface. ;)

With the right co-ordinates (which can be calculated via an algorithm) you can make all sorts of shapes from Quads and Poly's:
Cube3D.nds
(328.06 KiB) Downloaded 253 times


...it's just that using Models is much, much easier as all the code you see in the example is replaced with a handful of lines (everything the DS needs to know is in the saved model).
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1221
Joined: December 31st, 2010, 3:25 am

Re: 3D in DSGM

Postby Buck_7 » July 22nd, 2013, 4:10 am

Wow, that's impressive. Thanks for showing.
User avatar
Buck_7
 
Posts: 1460
Joined: February 19th, 2011, 1:44 am

Re: 3D in DSGM

Postby Foxi4 » July 22nd, 2013, 4:13 am

Buck_7 wrote:Wow, that's impressive. Thanks for showing.

>"Impressive"
>libnds example copy-pasta with optimization and minor code changes to work in a DSGM environment + bugfixing + commenting + new texture

You overestimate my abilities. :grin:
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1221
Joined: December 31st, 2010, 3:25 am

Re: 3D in DSGM

Postby BLsquared » July 22nd, 2013, 4:17 am

Doesn't the PAlib 3d functions use external 3d models? You know, like in PAlib.chm?
You may call me BLsquared, Commodore, or TexasBatman. Preferably BLsquared.
My avatar was made by this guy: http://christianmanga.com/smf/index.php ... bum;in=374

"Every puzzle has an answer." - Professor Layton
"In war, there is indeed no substitute for victory." - Douglas MacArthur
"Love and Peace!" - Vash the Stampede
"It's High Noon!" - McCree
Member of Memefefe's Squad
User avatar
BLsquared
 
Posts: 997
Joined: August 10th, 2011, 4:39 pm
Location: United States of America

Re: 3D in DSGM

Postby Foxi4 » July 22nd, 2013, 4:21 am

PALib doesn't support models of any kind - the extent of "3D" it supports is 3D sprites and that's it (they're quite buggy too). PAlib is just... outdated and causes a lot of problems in the long run.

In fact, the very presence of PAlib makes this code produce results different than those you would get if you compiled it without PAlib. Normally the cube would be rendered on the top screen, but for some reason with PAlib around the screens switch, possibly due to lcdMainOnBottom(); used somewhere in the library code, but I can't be arsed to look for that. :P
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1221
Joined: December 31st, 2010, 3:25 am

Re: 3D in DSGM

Postby boe6eod7nty » July 22nd, 2013, 3:12 pm

Foxi4 wrote:As for "being a lot of code", all this can be closed in convenient functions (or DSGM Actions), this is standard OpenGL syntax. Nobody does it the way it's shown - it's like this for the purpose of showing how it works under the surface. ;)


Do you mean Nobody as in the user or in general? :D
(jk, I just had to say it)
that akward moment when somthing akward happens.....
wait.....
what?
boe6eod7nty
 
Posts: 209
Joined: September 11th, 2012, 4:28 pm
Location: USA. WI.

Re: 3D in DSGM

Postby Buck_7 » July 22nd, 2013, 5:21 pm

At least I can load a background on the top screen - loading backgrounds doesn't really work using nitro engine.
User avatar
Buck_7
 
Posts: 1460
Joined: February 19th, 2011, 1:44 am

Re: 3D in DSGM

Postby Foxi4 » July 22nd, 2013, 5:33 pm

Loading both backgrounds and sprites using NitroFS works perfectly fine - I've done it in numerous projects without fail. You just have to account for readout times (SD's tend to vary in speed and the DS's cart slot speed additionally caps that).
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1221
Joined: December 31st, 2010, 3:25 am

Re: 3D in DSGM

Postby Buck_7 » July 22nd, 2013, 6:34 pm

No, I meant when I'm using the nitro engine (the thing I used to load a 3d model: http://dsgamemaker.com/dsgmforum/viewtopic.php?f=8&t=3542) I couldn't load any backgrounds using PA_Loadbackground(); whereas in the dsgm you made, backgrounds work.
User avatar
Buck_7
 
Posts: 1460
Joined: February 19th, 2011, 1:44 am

Re: 3D in DSGM

Postby Foxi4 » July 22nd, 2013, 6:59 pm

It should be pretty obvious as to why that happened. Using 3D switches Modes and Nitro no doubt re-assigns VRAM Banks - as such, you can't just randomly load a 2D tiled background on any layer you want - PA_LoadBackground requires the VRAM Banks and the Mode to be assigned in a specific way, the way PAlib assigned them.

All it'd take to add a background would be to stretch a quad on the screen and scroll your background on it or use a layer that does support backgrounds outside of PAlib.
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1221
Joined: December 31st, 2010, 3:25 am

Re: 3D in DSGM

Postby Nobody » July 22nd, 2013, 7:27 pm

I haven't looked into 3D yet, but would we now have a new 3D camera or would we still have the traditional 2D one?
Feel free to ask me for help. I'm on the forum a lot.

Recent Projects:
Retro Ducks: viewtopic.php?f=13&t=3533 (latest)
The Living Dead 2: viewtopic.php?f=13&t=3483
Crafters DS (Minecraft 2D Clone!) viewtopic.php?f=13&t=3082
User avatar
Nobody
 
Posts: 2323
Joined: February 14th, 2011, 12:08 am
Location: United States of America

Re: 3D in DSGM

Postby Foxi4 » July 22nd, 2013, 10:27 pm

We would have a new camera:
Code: Select all
static void gluLookAt(float eyex,
float    eyey,
float    eyez,
float    lookAtx,
float    lookAty,
float    lookAtz,
float    upx,
float    upy,
float    upz);

/*Parameters

eyeX, eyeY, eyeZ - Position of the eye point.

centerX, centerY, centerZ - position of the reference point.

upX, upY, upZ - direction of the up vector*/

...as specified in libnds and OpenGL. Of course this doesn't mean you wouldn't be able to use the current camera settings to some extent.

A picture kindly donated by Google Images:
Image

:lol:
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1221
Joined: December 31st, 2010, 3:25 am

Re: 3D in DSGM

Postby BLsquared » July 22nd, 2013, 10:33 pm

What would be the object limit?
You may call me BLsquared, Commodore, or TexasBatman. Preferably BLsquared.
My avatar was made by this guy: http://christianmanga.com/smf/index.php ... bum;in=374

"Every puzzle has an answer." - Professor Layton
"In war, there is indeed no substitute for victory." - Douglas MacArthur
"Love and Peace!" - Vash the Stampede
"It's High Noon!" - McCree
Member of Memefefe's Squad
User avatar
BLsquared
 
Posts: 997
Joined: August 10th, 2011, 4:39 pm
Location: United States of America

Next

Return to Tutorials

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron