GLBasic forum

Codesnippets => 3D-snippets => Topic started by: Kitty Hello on 2011-Dec-23

Title: Auto-rounded 3D block landscapes
Post by: Kitty Hello on 2011-Dec-23
Well, I thought this might be some cool idea to easily produce levels for games like:
(http://purenintendo.com/wp-content/uploads/2011/09/super_mario_3d_land_art.jpg)

But it turned out to be cooler than sliced awesome.
(http://www.glbasic.com/pix/tnedge_cutter3.png) (http://www.glbasic.com/pix/edge_cutter3.png)

So, you only need a 3D array of sprite indices, and it creates you rounded cubes that also merge together if they have neighbours. The only "tiny" trouble so far are the tiny holes you get at L-shaped connections. So fra - don't use them :P


Attached the source.

[attachment deleted by admin]
Title: Re: Auto-rounded 3D block landscapes
Post by: Ian Price on 2011-Dec-23
Nice :)
Title: Re: Auto-rounded 3D block landscapes
Post by: erico on 2011-Dec-23
wonderful! can we set the amount of roundness on the blocks?
Title: Re: Auto-rounded 3D block landscapes
Post by: Kitty Hello on 2011-Dec-23
Yes. But its one face. Not really "rounded".
Title: Re: Auto-rounded 3D block landscapes
Post by: mentalthink on 2011-Dec-23
For me crashes when I start the program , some sttange?¿, don´t needed nothing, no?¿...
Title: Re: Auto-rounded 3D block landscapes
Post by: Ian Price on 2011-Dec-24
Quote
For me crashes when I start the program
same here. I get a black screen for a few seconds and then it exits. :(

Win 7 64Bit. GLB V10.209
Title: Re: Auto-rounded 3D block landscapes
Post by: mentalthink on 2011-Dec-24
HI it´s the same error in my computer...

Well I leave you this 2 simple box models, a box a little reounded, it´s very brusc, and another more smooth, but have very few polygons, I think make a lot of instances can works in mobile devices whitout troubles...

I put the 2 textures , and the template of each box, you can paint what do you want whit PS, paint, or anything can paint textures...



[attachment deleted by admin]
Title: Re: Auto-rounded 3D block landscapes
Post by: Kitty Hello on 2011-Dec-24
It creates a terrain.ddd in media. Open with samples/_projects_/dddview
Title: Re: Auto-rounded 3D block landscapes
Post by: mentalthink on 2011-Dec-24
Perfect, now.... it´s looks very nice...
Title: Re: Auto-rounded 3D block landscapes
Post by: Kitty Hello on 2011-Dec-29
I started adding billboard sprites. How does that look? I see a great advantage of this technique - a SEUCK/GACK type gamemaker might be easy to do with this technique and does not look too bad.

(http://www.glbasic.com/pix/tnsuperblockmanland_1_.png) (http://www.glbasic.com/pix/superblockmanland_1_.png)

Title: Re: Auto-rounded 3D block landscapes
Post by: Ian Price on 2011-Dec-29
That is a brilliant idea :)
Title: Re: Auto-rounded 3D block landscapes
Post by: Schranz0r on 2011-Dec-29
yes, cool idea so far :D
InfinityMario   :good:
Title: Re: Auto-rounded 3D block landscapes
Post by: bigsofty on 2011-Dec-29
Looks great, I never saw it personally but didn't Paper Mario have a similar engine to this?
Title: Re: Auto-rounded 3D block landscapes
Post by: erico on 2011-Dec-30
damn it, I can´t test yet, only my laptop here and it has a wonderful sis 672 mirage 3 onboard that hardly can cope with 2d, 3d never mind.... :giveup:

even my currently going 2d game displays 60 fps on original size, scaled it drops to 12fps :(

back on subject,
this sure has a great potential...it may be a little too much for me to cope with on doing something on my own.
but if anything needed count me in.

It does not remind me of mario couse I never played any, but it does remind me of FEZ:


but I just have a hunch this system can get to a whole lot more.
Title: Re: Auto-rounded 3D block landscapes
Post by: mentalthink on 2012-Jan-05
Genot this it´s cool.

The billboards, are 3D or will be the add of rotation in X-Sprite, I think can be maravellous, have an X_Sprite rotating, in depth...
Title: Re: Auto-rounded 3D block landscapes
Post by: Kitty Hello on 2012-Jan-08
My bilboards are reay X_OBJ.. objects. Here's the code to create them:

Code: (glbasic) [Select]

// draw sprites after the camera was set
FUNCTION DrawBillboards%: id%, idtexture%, blockpix%, sprites[] AS Tsprite3D

LOCAL tx, ty
GETSPRITESIZE idtexture%, tx, ty
LOCAL nperrow% = INTEGER(tx / blockpix)
GetTextureSize(idtexture%, tx, ty)


// texture size of a half pixel movement
LOCAL offset = 0.50
LOCAL halfpx_x = offset / tx
LOCAL halfpx_y = offset / ty

// scale factor to make a block 1 pixel smaller on texture than required
// we want edge[0,0] be on center of pixel 0,0;
// and edge[1,0] on center of pixel 15 (if blocksize=16)
LOCAL txblockscale = (blockpix - 2.0*offset)/(1.0 * blockpix)
LOCAL tyblockscale = (blockpix - 2.0*offset)/(1.0 * blockpix)

// make tx/ty be the texture size of one block
tx = blockpix / tx
ty = blockpix / ty



LOCAL mat[]
X_GETCAMERAMATRIX mat[]


// X_SPOT_LT 0, 0, 0,0,0,  0,0,0, 0
X_AUTONORMALS 1
X_OBJSTART id%

LOCAL h = 1.0, w = 0.5*h // size of this sprite
// we need the "X" axis direction for the x-values of the sprite
LOCAL dxx =mat[0], dxy=mat[4], dxz=mat[8] // dxy = 0.0 it camera-up is Y
LOCAL upx =mat[1], upy=mat[5], upz=mat[9]


LOCAL uw = tx * txblockscale // width of image to texture (15px for 16px blocks)
LOCAL vh = ty * tyblockscale

FOREACH spr IN sprites[]
LOCAL deltau = MOD(spr.id%, nperrow)       // number of blocks to move
LOCAL deltav = INTEGER(spr.id% / nperrow%) // nof blocks

LOCAL u0 = halfpx_x + deltau * tx
LOCAL v0 = halfpx_y + deltav * ty

X_OBJADDVERTEX spr.x+w*dxx, spr.y-w*dxy+h, spr.z+w*dxz, u0+uw,v0   , 0xffffff
X_OBJADDVERTEX spr.x+w*dxx, spr.y-w*dxy  , spr.z+w*dxz, u0+uw,v0+vh, 0xffffff
X_OBJADDVERTEX spr.x-w*dxx, spr.y-w*dxy+h, spr.z-w*dxz, u0   ,v0   , 0xffffff
X_OBJADDVERTEX spr.x-w*dxx, spr.y-w*dxy  , spr.z-w*dxz, u0   ,v0+vh, 0xffffff
X_OBJNEWGROUP
NEXT
X_OBJEND

X_MOVEMENT 0,0,0
X_SCALING 1,1,1

X_CULLMODE 1

SMOOTHSHADING FALSE
X_SETTEXTURE idtexture%, -1
X_DRAWOBJ id%, 0
ENDFUNCTION

Title: Re: Auto-rounded 3D block landscapes
Post by: mentalthink on 2012-Jan-12
Thanks Gernnot  :nw: :nw: