iso 3d

Blitz3D Forums/Blitz3D Programming/iso 3d

can any help me to create a better iso system plz!?!

screens



download the source code here:
http://www.diablogames.133h.co.uk/3D%20ISO%20-%20SJL.zip

I don,t know why but it just shows up pitch black on my computer.
Here try mine.
http://www.blitzbasic.com/codearcs/codearcs.php?code=1268

I have some good iso code in another language, but you'd NEVER be able to read/understand it. I'll dig up the basic equations eventually, but beyond that, I can't really help you, sorry :(

What is an iso system? :|

ISO style games are the likes of the original sim city 2000. Its basically an angled look down view with no perspective.

Did you search for "isometric" in the code archives?
-RZ

OK I played with it a bit... added camera mode 2 to see what could happen. looks like this:
; =========================================================|
; | 3D Isometric tiling example						||	D  |
; |-------------------------------------------------||	I  |
; | This examples demonstraits how you can use 3D   ||	A  |
; | to create a 2D ISO tiled map system with cool   ||	B  |
; | lighting effects!!!								||	L  |
; ====================================================	O  |
; | File warning									||	   |
; |-------------------------------------------------||	G  |
; | This file was create by Stefan J Lulham         ||	A  |
; | Do not say th content was created by you        ||	M  |
; | because it wasn't, FACT!!!						||	E  |
; ====================================================	S  |
; | Insperation										||	   |
; |-------------------------------------------------||	%  |
; | After playing Avernum i decide that i would like||	%  |
; | to try out a ISO system for myself.             ||	%  |
; | Visit - www.spidersoftware.com    				||	%  |
; ====================================================	%  |  
; | About the author								||	%  |
; |-------------------------------------------------||	%  |
; | Stefan J Lulham is currently studying at A-Level||	%  |
; | in computer sceine & IT. His fav games include  ||	%  |
; | FF7, FF9, Exile, Exile II, Exile III            ||	%  |   
; =========================================================| 

Graphics3D 1024, 768, 32, 1 ; setup the 3D engine
AppTitle "3D Isometric example" ; title

Const width = 20 ; width of the map
Const height = 80 ; the height of the map (for a square map, make it 4 times bigger then the width)

camera = CreateCamera() ; create a camera so you can see
CameraProjMode camera, 2 ;  was 1    
MoveEntity camera, width / 2, height / 8, -4.5 ; so we're not too close to the tiles and in the center

light = CreateLight() ; a light, so its not dark

Dim tile(width, height) ; stores the tile handles
Dim map(width, height) ; stores the map data, used for texturing

tile_base = CreateMesh() ; the basic tile shape

MoveMouse GraphicsWidth() / 2, GraphicsHeight() / 2

; BELOW: Create of an iso tile
tilesurface = CreateSurface(tile_base)

v0 = AddVertex(tilesurface, 0, .5, 0)
v1 = AddVertex(tilesurface, .5, .25, 0)
v2 = AddVertex(tilesurface, .5, .75, 0)
v3 = AddVertex(tilesurface, 1, .5, 0)

t1 = AddTriangle(tilesurface, v0, v1, v2)
t2 = AddTriangle(tilesurface, v1, v3, v2)

; Makes it so the texture is placed correctly
VertexTexCoords tilesurface, 0, 0, 0
VertexTexCoords tilesurface, 1, 1, 0
VertexTexCoords tilesurface, 2, 0, 1
VertexTexCoords tilesurface, 3, 1, 1

; flip it, so you can see it
FlipMesh tile_base
HideEntity tile_base ; this is the basic tile so it will just look wired if you could see it!

; colored shading
; play around with the values here: you can make some realy cool effects!!! (This can also be used in the loop to perform light triks!)
Global shadecolor_red = 255
Global shadecolor_green = 255
Global shadecolor_blue = 255
For vert = 0 To 3
	VertexColor tilesurface, vert, shadecolor_red / (vert + 1), shadecolor_green / (vert + 1), shadecolor_blue / (vert + 1), 1
Next
EntityFX tile_base,34 

For x# = 1 To width
	For y# = 1 To height
		tile(x, y) = CopyEntity(tile_base) ; get handles for the maps tiles
	Next
Next

For x# = 1 To width
	For y# = 1 To height
	
	  tilez=Rnd(1) ; pick what kind of tile to put
	
		map(x, y) = tilez ; the kind of tile (0 = mud, 1 = floor)
		
		; position the tiles
		If Y / 2 = Int(Y / 2) Then
			XPos# = X
			YPos# = Y / 4
		Else
			XPos# = X + .5
			YPos# = Y / 4
		EndIf
		MoveEntity tile(x, y), xpos#, ypos#, 0
		NameEntity tile(x, y), x + ";" + y ; for referance
		EntityPickMode tile(x, y), 1 ; make it pickable
	Next
Next

Dim textures(99) ; an arry of texxtures

; load all the textures here
textures(0) = LoadTexture("mud.bmp")
textures(1) = LoadTexture("floor.bmp")

For x = 1 To width
	For y = 1 To height
		EntityTexture tile(x, y), textures(map(x, y)) ; texture all the tiles with the correct texture
	Next
Next

WireFrame 0 ; shaded
zoom#=.01  ; sets initial zoom value way out there
While Not KeyHit(1)

CameraZoom camera,zoom#		; poke the zoom factor in there

	RenderWorld: UpdateWorld
	
	If KeyDown(200) Then MoveEntity camera, 0, .1, 0
	If KeyDown(208) Then MoveEntity camera, 0, -.1, 0
	If KeyDown(203) Then MoveEntity camera, -.1, 0, 0
	If KeyDown(205) Then MoveEntity camera, .1, 0, 0
If KeyDown(13) = True Then zoom#=zoom#+.1 : Delay 10
If KeyDown(12)  = True Then zoom#=zoom#-.1 : Delay 10

	;If KeyDown(13) Then MoveEntity camera, 0, 0, .1
	;If KeyDown(12) Then MoveEntity camera, 0, 0, -.1
	
	If KeyHit(57) Then PositionEntity camera, width / 2, height / 8, -4.5
	
	Text 10, 10 + (12 * 0), "==================="
	Text 10, 10 + (12 * 1), "|Debug information|"
	Text 10, 10 + (12 * 2), "==================="
	
	Text 10, 10 + (12 * 4), "Map info"
	Text 10, 10 + (12 * 5), "--------"
	Text 10, 10 + (12 * 6), "map width = " + width
	Text 10, 10 + (12 * 7), "map width = " + height
	
	
	selected_tile = CameraPick(camera, GraphicsWidth() / 2, GraphicsHeight() / 2)
	If selected_tile <> 0 Then
		str_xpos$ = "": str_ypos$ = ""
		For i = 1 To Len(EntityName(selected_tile))
			If Mid(EntityName(selected_tile), i, 1) = ";" Then Exit
			str_xpos$ = str_xpos$ + Mid(EntityName(selected_tile), i, 1)
		Next
		str_ypos$ = Mid(EntityName(selected_tile), i+1, Len(EntityName(selected_tile)) - i)
	EndIf
	
	Text 10, 10 + (12 * 9), "Center tile info"
	Text 10, 10 + (12 * 10), "----------------"
	Text 10, 10 + (12 * 11), "X Pos = " + Int(str_xpos$)
	Text 10, 10 + (12 * 12), "Y Pos = " + Int(str_ypos$)
	Text 10, 10 + (12 * 13), "Texture no. = " + map(Int(str_xpos$), Int(str_ypos$))
	Text 10, 10 + (12 * 14), "Handle = " + selected_tile
	
	selected_tile = CameraPick(camera, MouseX(), MouseY())
	If selected_tile <> 0 Then
		str_xpos$ = "": str_ypos$ = ""
		For i = 1 To Len(EntityName(selected_tile))
			If Mid(EntityName(selected_tile), i, 1) = ";" Then Exit
			str_xpos$ = str_xpos$ + Mid(EntityName(selected_tile), i, 1)
		Next
		str_ypos$ = Mid(EntityName(selected_tile), i+1, Len(EntityName(selected_tile)) - i)
	EndIf
	
	Text 10, 10 + (12 * 16), "Mouse tile info"
	Text 10, 10 + (12 * 17), "---------------"
	Text 10, 10 + (12 * 18), "X Pos = " + Int(str_xpos$)
	Text 10, 10 + (12 * 19), "Y Pos = " + Int(str_ypos$)
	Text 10, 10 + (12 * 20), "Texture no. = " + map(Int(str_xpos$), Int(str_ypos$))
	Text 10, 10 + (12 * 21), "Handle = " + selected_tile
	
	Text 10, 10 + (12 * 23), "Camera info"
	Text 10, 10 + (12 * 24), "-----------"
	Text 10, 10 + (12 * 25), "X Pos = " + EntityX(camera)
	Text 10, 10 + (12 * 26), "Y Pos = " + EntityY(camera)
	Text 10, 10 + (12 * 27), "Z Pos = " + EntityZ(camera)
	Text 10, 10 + (12 * 28), "Wireframe = " + w
	Text 10,10+(12*29),"Zoom: "+zoom#
	If KeyHit(17) Then
		If w = 0 Then w = 1: Else w = 0
		WireFrame w
	EndIf
	
	Text GraphicsWidth() / 2, GraphicsHeight() - 24, "CREATED BY: STEFAN J LULHAM", 1
	
	Color 0, 0, 0: Rect MouseX() - 1, MouseY() - 1, 4, 4
	Color 255, 255, 255: Rect MouseX(), MouseY(), 2, 2
	
	;shadecolor_red = shadecolor_red - 5 ; *
	;If shadecolor_red < 0 Then shadecolor_red = 255 ; *
	;shadecolor_green = shadecolor_green - 5 ; *
	;If shadecolor_green < 0 Then shadecolor_green = 255 ; *
	;shadecolor_blue = shadecolor_blue - 5 ; *
	;If shadecolor_blue < 0 Then shadecolor_blue = 255 ; *
	;For vert = 0 To 3 ; *
	;	VertexColor tilesurface, vert, shadecolor_red / (vert + 1), shadecolor_green / (vert + 1), shadecolor_blue / (vert + 1), 1 ; *
	;Next ; *
	; * Uncomment these lines to start flashing tiles!
	

Flip: Cls

Wend: End

EndGraphics ; finshed with the 3d engine

There is a little mor flavor here... added camera zoom but it is really fast on my cpu/ati gfx...

-RZ

I don't know if CameraZoom Camera,0 would be any use, or some form of utilising CameraProjectMode (the no - z mode)?

Unfortunately, 3D graphics cameras add eprspective by default for the purpose of 'true-3d' images.

hey Rook Zimbabwe thanks for that. i tried using camera mode 2 but i thought i was too close, i didn't know that you had to use camerazoom. thanks!

Now all i have todo is add height

add height??? I am about 6 foot tall... does that help?
;P
Yeah, camera mode and zoom are a little shakey. at least with my current change you can see what would look good and then know what to set it as. I use that for more than...

Camera Zoom can be used to simulate the SNIPER RIFLE SCOPE effect really well but applying a mask just before zooming is a bit tricky.

Are you planning to use sprites?

-RZ

add height???
hills and stuff. cause the world isn't flat.

Are you planning to use sprites?
yes, i download that spritcontrol.

I don't know if you have played with HEIGHTMAP yet... it is pretty easy BUT once again it all goes back to scale. There also seems to be a limitation to the number of sprites on screen VS game speed. Good luck!

-RZ

I read before Sprites can have a big impact on speed, due to their (partial) teransparent nature I think. To minimise this, try to keep them small where necessary, try best to recycle particle effect sprites and decals where possible too.

Hope this helps.

Rook,
i have herd of a HEIGHTMAP map but its just that i have to impliment it.

This is what I did... I hacked this out of my older 3d game but it should work.
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= MAP

Global terr=LoadTerrain("textures\hmap_1024.bmp") 
; I have a 1024X1024 heightmap in GS
ScaleEntity terr,25,400,25 
; scaling is important... middle number increases height or depth
PositionEntity terr,-20*512,0,-20*512
; you will have to monkey with this... I am still trying to cut the center
EntityFX terr,1
EntityType terr,2	;Load terrain

;apply textures To terrain	
tex1=LoadTexture( "textures\coolgrass1.bmp",1 )
ScaleTexture tex1,10,10
; lightmap ALPHa for terrain.....
tex2=LoadTexture( "textures\lmap_256.bmp" ) ; i like a nice set of colors
ScaleTexture tex2,TerrainSize(terr),TerrainSize(terr)
EntityTexture terr,tex1,0,0
EntityTexture terr,tex2,0,1

OK you are going to need a greyscale heightmap... BMP and JPG work ok... JPG is smaller in Greyscale. You will also need a nice 256X256 colormap for your terrain... I have to research how to link images in to here but I will post when I do.

-RZ