Is this possible

Blitz3D Forums/Blitz3D Programming/Is this possible

JBR(Posted 2004) [#1]
Hello,

I'm going to be writing a scrolling tiled game and instead of just using 'DrawBlock' to draw the tiles I was wondering if I could use some 3D commands.

i.e. set up a surface with the required number of quads and then apply a texture which maps the required block graphics to the tile quad. using VertexCoords & VertexTexCoords.

I hope this makes sense.

My major concern is that the graphics on screen won't look right due to smoothing of edges of textures or 'errors' in the use of u & v for the texture.

Anyone tried this?
Any advice appreciated

Marg


poopla(Posted 2004) [#2]
Yeah, you can do it. The only times you'll see errors is durring rotation, and they aren't that noticable while and object is rotating. Skid posted some code used a while back, I would suggest trying to use it as a base. But it most definately will work!


sswift(Posted 2004) [#3]
It is possible to render pixel accurate tile graphics in 3D. There is code in the code archives to do so. The requirement of this however is that a 32 pixel wide tile must cover a 3D pixel wide area, which means higher res will see many more tiles than low res.

If you don't make it pixel accurate then you're gonna get some blurring, and probably see some sharp edges between tiles.

You can rotate and scale the sprites on top of the tiled background of course, though if you do they might not appear as sharp as the tiles do.


poopla(Posted 2004) [#4]
Granted, you get some blurring with rotated graphics as well(via code). So it may not be avoidable easily either way. So in the end, you're probably going to see the same artifacts in either system.


JBR(Posted 2004) [#5]
To clarify,

If I load a texture of size 1024 by 768 which holds 192 tile graphics of size 64 by 64 say.

I can then apply 4 texture coords to a quad. e.g. for the 3rd tile i'd have u = (0.0625)*2 and v = 0 for the top left? etc

If the 'part' texture is 64 pixels then I must use 64 pixels on the screen to keep the edges sharp?

I'm just going to check out the archives.

Thanks
Marg


John Pickford(Posted 2004) [#6]
Yes it does work but you do get some bleeding between tiles. I'm not sure how to fix this but one way it to arrange tiles so that likely neigbours ARE neigbours in the tile map. Another option is to make the tiles (say) 30x30 but arrange them on a 32x32 grid, with the extra pixel around each tile repeat the adjascent pixel to prevent bleed.


Richard Betson(Posted 2004) [#7]






This may or may not help. :) I need to work out this kind of thing for another project so I wipped this up to show how you might be able to do this sort of thing with sprites.

Block.Jpg Pic:


Heres the code:

;Pixel perfect sprite
;Copyright (c) 2004 Richard R Betson 
;www.redeyeware.50megs.com
;USE - Free to all

;09/15/04


Graphics3D 800,600,16,2

sprt=LoadSprite("block.jpg",4)
EntityFX sprt,1



source_w=128
source_h=128

;Pixel width and height (64 appears to = 1 Blitz3D unit)
rect_w=64
rect_h=64


Dim sprite(50)
Dim sprite_x(50)
Dim sprite_y(50)


;Globals for ScaleToPixel Function
Global w#
Global h#

;Given the 
ScaleToPixel(rect_w,rect_h,source_w,source_h)



For i=1 To 35
	
	
	sprite(i)=CopyEntity(sprt)
	EntityColor sprite(i),Rnd(128)+128,Rnd(128)+128,Rnd(128)+128
	sprite_x(i)=i*rect_w
	sprite_y(i)=i*rect_h

	ScaleSprite sprite(i),w#,h#
Next
i=0

FreeEntity sprt



cam=CreateCamera()
PositionEntity cam,0,0,-4
PointEntity cam,sprite(1)




While Not KeyHit(1)

	For y= 0 To 4
		
		For x=0 To 6
			i=i+1
			PositionEntity sprite(i),x-3,y-2,0
		Next
	Next
	i=0
	UpdateWorld
	RenderWorld
	
	Flip
Wend



;Returns the proper scale to match a pixel width and height. source_w/source_h are the actual image size
Function ScaleToPixel(rect_w,rect_h,source_w,source_h)

	w#=( Float(rect_w)/Float(source_w) )
	h#=( Float(rect_h)/Float(source_h) )

End Function