test this please fps and basic veiws welcome

Blitz3D Forums/Blitz3D Programming/test this please fps and basic veiws welcome

Duckstab[o](Posted 2005) [#1]
Graphics3D 1024,768,32,1

ClearWorld(1,1,1)

Global Player=CreateSphere(32)
PositionEntity player,4,4,4
Global MAPRANGE=50;CHANGES THE NUMBER OF TERRAINS IN VIEW
Global brush,cam

cam=CreateCamera()
lgt=CreateLight(2)
LightRange lgt,200
PositionEntity cam,0,5,0
RotateEntity cam,0,45,0
CameraRange cam,1,1000
brush=LoadBrush("grass1.png");PLACE ANY TEXTURE HERE
;BrushFX brush,1
Dim Vertx#(11,11)
Dim Verty#(11,11)
Dim Vertz#(11,11)
Dim Maparray.Map_area(100)

Type Map_tile
    Field Maptile
	Field Active
	Field tile_id[100]
	Field Brush_id[100]
	Field tilex
	Field tiley
	Field tilez
End Type

Type Map_Segm
	Field Active
	Field Maptile.Map_tile[10000]
End Type

Type Map_sect
	Field Active
	Field Mapsegm.Map_segm[100]
End Type

Type Map_area
    Field Active
	Field Mapsect.Map_sect[100]
End Type

For times4=1 To 10
maparray(times4)=New Map_area
For times3=1 To 10
maparray(times4)\mapsect[times3]=New map_sect
For times2=1 To 10
maparray(times4)\mapsect[times3]\mapsegm[times2]=New Map_Segm
For times=1 To 100
maparray(times4)\mapsect[times3]\mapsegm[times2]\maptile[times]=New Map_tile
maparray(times4)\mapsect[times3]\mapsegm[times2]\maptile[times]\active=1
Next
Next
Next
Next


For tiles=1 To 100
read_Maptile(tiles)
log_maptile(tiles)
create_maptile(tiles)
Next
tiles=0


For x=1 To 10
For z=1 To 10
tiles=tiles+1
PositionEntity maparray(1)\mapsect[1]\mapsegm[1]\maptile[tiles]\maptile,x*10,0,z*10
Next
Next

;create_skybox()
Print maparray(1)\mapsect[1]\mapsegm[1]\maptile[1]\tile_id[32]

While Not KeyHit(1)
If KeyDown(200) Then MoveEntity cam,0,0,.02
If KeyDown(208) Then MoveEntity cam,0,0,-.02
If KeyDown(203) Then TurnEntity cam,0,.05,0
If KeyDown(205) Then TurnEntity cam,0,-.05,0
EntityParent lgt,cam 
Hide_it
UpdateWorld
RenderWorld


Flip 0
Wend
End



.Sector1
Data 3,3,2,1,1,1,1,2,3,3
Data 3,3,2,1,1,1,1,2,3,3
Data 2,2,2,1,1,1,1,2,2,2
Data 1,1,1,1,1,1,1,1,1,1
Data 1,1,1,1,1,1,1,1,1,1
Data 1,1,1,1,1,1,1,1,1,1
Data 1,1,1,1,1,1,1,1,1,1
Data 2,2,2,1,1,1,1,2,2,2
Data 3,3,2,1,1,1,1,2,3,3
Data 3,3,2,1,1,1,1,2,3,3


Function Read_Maptile(tiles)
Restore Sector1
For times=1 To 100
Read maparray(1)\mapsect[1]\mapsegm[1]\maptile[tiles]\tile_id[times]
maparray(1)\mapsect[1]\mapsegm[1]\maptile[tiles]\tile_id[times]=maparray(1)\mapsect[1]\mapsegm[1]\maptile[tiles]\tile_id[times]
Next
End Function

Function log_maptile(tiles)
For high=1 To 9
times=0
For x=1 To 10
For z=1 To 10
times=times+1
If maparray(1)\mapsect[1]\mapsegm[1]\maptile[tiles]\tile_id[times]=high Then 
vertx#(x,z)=-6+x
verty#(x,z)=high/2-1
vertz#(x,z)=-6+z
vertx#(x,z+1)=-6+x
verty#(x,z+1)=high/2-1
vertz#(x,z+1)=-6+z+1
vertx#(x+1,z+1)=-6+x+1
verty#(x+1,z+1)=high/2-1
vertz#(x+1,z+1)=-6+z+1
vertx#(x+1,z)=-6+x+1
verty#(x+1,z)=high/2-1
vertz#(x+1,z)=-6+z
EndIf
Next
Next
Next
End Function

Function create_maptile(tiles)
maparray(1)\mapsect[1]\mapsegm[1]\maptile[tiles]\maptile=CreateMesh()
surf=CreateSurface(maparray(1)\mapsect[1]\mapsegm[1]\maptile[tiles]\maptile,brush)
For x=1 To 10
For z=1 To 10
v1=AddVertex (surf,vertx#(x,z),verty#(x,z),vertz#(x,z),0,0)
v2=AddVertex (surf,vertx#(x,z+1),verty#(x,z+1),vertz#(x,z+1),0,1)
v3=AddVertex (surf,vertx#(x+1,z+1),verty#(x+1,z+1),vertz#(x+1,z+1),1,1)
v4=AddVertex (surf,vertx#(x+1,z),verty#(x+1,z),vertz#(x+1,z),1,0)
t1=AddTriangle(surf,v1,v2,v3)
t2=AddTriangle(surf,v3,v4,v1)
Next
Next
UpdateNormals maparray(1)\mapsect[1]\mapsegm[1]\maptile[tiles]\maptile
End Function

Function Hide_it()
For times=1 To 100
If EntityDistance(maparray(1)\mapsect[1]\mapsegm[1]\maptile[times]\maptile,cam)>maprange Then 
HideEntity maparray(1)\mapsect[1]\mapsegm[1]\maptile[times]\maptile
EndIf
If EntityDistance(maparray(1)\mapsect[1]\mapsegm[1]\maptile[times]\maptile,cam)<maprange Then 
ShowEntity maparray(1)\mapsect[1]\mapsegm[1]\maptile[times]\maptile
EndIf
Next
End Function

Function create_skybox()
    mesh = CreateMesh()

    ;front face
    brush = LoadBrush("front.jpg",49)
    surface = CreateSurface(mesh,brush)
    AddVertex surface,-1,+1,-1,0,0
    AddVertex surface,+1,+1,-1,1,0
    AddVertex surface,+1,-1,-1,1,1
    AddVertex surface,-1,-1,-1,0,1
    AddTriangle surface,0,1,2
    AddTriangle surface,0,2,3
    FreeBrush brush

    ;right face
    brush = LoadBrush("right.jpg",49)
    surface = CreateSurface(mesh,brush)
    AddVertex surface,+1,+1,-1,0,0
    AddVertex surface,+1,+1,+1,1,0
    AddVertex surface,+1,-1,+1,1,1
    AddVertex surface,+1,-1,-1,0,1
    AddTriangle surface,0,1,2
    AddTriangle surface,0,2,3
    FreeBrush brush

    ;back face
    brush = LoadBrush("back.jpg",49)
    surface = CreateSurface(mesh,brush)
    AddVertex surface,+1,+1,+1,0,0
    AddVertex surface,-1,+1,+1,1,0
    AddVertex surface,-1,-1,+1,1,1
    AddVertex surface,+1,-1,+1,0,1
    AddTriangle surface,0,1,2
    AddTriangle surface,0,2,3
    FreeBrush brush
 
    ;left face
    brush = LoadBrush("left.jpg",49)
    surface = CreateSurface(mesh,brush)
    AddVertex surface,-1,+1,+1,0,0
    AddVertex surface,-1,+1,-1,1,0
    AddVertex surface,-1,-1,-1,1,1
    AddVertex surface,-1,-1,+1,0,1
    AddTriangle surface,0,1,2
    AddTriangle surface,0,2,3
    FreeBrush brush

    ;top face
    brush = LoadBrush("top.jpg",49)
    surface = CreateSurface(mesh,brush)
    AddVertex surface,-1,+1,+1,0,1
    AddVertex surface,+1,+1,+1,0,0
    AddVertex surface,+1,+1,-1,1,0
    AddVertex surface,-1,+1,-1,1,1
    AddTriangle surface,0,1,2
    AddTriangle surface,0,2,3
    FreeBrush brush
   
    ;bottom face 
    brush = LoadBrush("bottom.jpg",49)
    surface = CreateSurface(mesh,brush)
    AddVertex surface,-1,-1,-1,1,0
    AddVertex surface,+1,-1,-1,1,1
    AddVertex surface,+1,-1,+1,0,1
    AddVertex surface,-1,-1,+1,0,0
    AddTriangle surface,0,1,2
    AddTriangle surface,0,2,3
    FreeBrush brush
    
    ScaleMesh mesh,200,200,200
    FlipMesh mesh
    EntityFX mesh,1 ; make fullbright
    Return mesh
    UpdateNormals mesh
End Function



Duckstab[o](Posted 2005) [#2]
any how do you get those code tags to work :(

the above is part of a massive terrain gen prog im working on

each base map is 10,10
and is contained in areas sectors segments
to give maps 10,000,000 tiles on average

working on a lod routein

and texturing editor


jfk EO-11110(Posted 2005) [#3]
it's (code)...(/code) - and use [] insead of ()


Techlord(Posted 2005) [#4]
[tag] [/tag]



N(Posted 2005) [#5]
The problem is you're not using lower-case characters in your tags, Duck. You got the names right.


Duckstab[o](Posted 2005) [#6]
thanks lads god if you could have heard that outburst
:) what a plonka


Duckstab[o](Posted 2005) [#7]
I will be creating 50 to 100+ baseset for four different tiers to make anything from valleys to mountains

there will be up to 5 textures styles per baseset
with a max of 10 textures included

going to be posting this one free for those who have trouble modelling and have to use memory robbing terrains commands


jfk EO-11110(Posted 2005) [#8]
sounds good, thanks for sharing!


wizzlefish(Posted 2005) [#9]
jfk - I've always wanted to ask: What does "EO-11110" mean? I think the EO means "executive order," but what are the numbers for?


gpete(Posted 2005) [#10]
binary for "30" ????


Duckstab[o](Posted 2005) [#11]
;note another possiblity of terrain editor
;duckstab

;left mouse sellect triangle
;q vert up
;a vert down
;arrow keys rotate map
;page up and down zoom
;create a texture with a black background and a white circle outline for target (30 by 30)
;create a texture with a green background with a 1 pixle border for vertile (30 by 30) 
Graphics3D 1024,768,32,1

ClearWorld(1,1,1)
Global cam1=CreateCamera()
Global lgt1=CreateLight()
Global mesh

Global picked#,tri,surface
Global v1x#,v1y#,v1z#,v1
Global v2x#,v2y#,v2z#,v2
Global v3x#,v3y#,v3z#,v3


PositionEntity cam1,0,2,-40
Global tex=LoadBrush("vertile.png")
target=LoadImage("target.png")

mesh_create2
RotateEntity mesh,90,0,0
While Not KeyHit(1)

If KeyDown(200) Then TurnEntity mesh,.1,0,0
If KeyDown(203) Then TurnEntity mesh,0,-.1,0
If KeyDown(208) Then TurnEntity mesh,-.1,0,0
If KeyDown(205) Then TurnEntity mesh,0,.1,0
If KeyDown(201) Then MoveEntity cam1,0,0,.1
If KeyDown(209) Then MoveEntity cam1,0,0,-.1
If KeyDown(16) And picked>0 Then movevert1
If KeyDown(30) And picked>0 Then movevert2
If MouseHit(1) Then getpicked
UpdateWorld
RenderWorld
Text 100,100,"picked="+picked
Text 100,115,"Tri="+tri
Text 100,130,"vert1 x="+v1x+"  y="+v1y+"  z="+v1z
DrawImage target,MouseX(),MouseY()
Flip 0
Wend
End


Function mesh_create1()
mesh=CreateMesh()
	For x=1 To 10
		For z=1 To 10
			surf=CreateSurface(mesh)
			v1=AddVertex(surf,x-5,0,z-4)
			v2=AddVertex(surf,x-5,0,z-5)
			v3=AddVertex(surf,x-4,0,z-5)
			v4=AddVertex(surf,x-4,0,z-4)
			t1=AddTriangle(surf,v1,v2,v3)
			t2=AddTriangle(surf,v3,v4,v1)
		Next
	Next
UpdateNormals Mesh
EntityColor mesh,50,255,30
End Function

Function mesh_create2()
mesh=CreateMesh()
surf=CreateSurface(mesh,tex)
	For x=1 To 20
		For z=1 To 20			
		    v1=AddVertex(surf,x-10,0,z-9,0,0)
			v2=AddVertex(surf,x-10,0,z-10,0,1)
			v3=AddVertex(surf,x-9,0,z-10,1,1)
			v4=AddVertex(surf,x-9,0,z-9,1,0)
			t1=AddTriangle(surf,v1,v2,v3)
			t2=AddTriangle(surf,v3,v4,v1)
		Next
	Next
UpdateNormals Mesh
EntityColor mesh,50,255,30
EntityPickMode mesh,2
End Function

Function mesh_create2b()
mesh=CreateMesh()
surf=CreateSurface(mesh,tex)
	For x=1 To 20
		For z=1 To 20			
		    v1=AddVertex(surf,x-10,0,z-9,0,0)
			v2=AddVertex(surf,x-10,0,z-10,0,1)
			v3=AddVertex(surf,x-9,0,z-10,1,1)
			v4=AddVertex(surf,x-9,0,z-9,1,0)
			t1=AddTriangle(surf,v1,v2,v3)
			t2=AddTriangle(surf,v3,v4,v1)
		Next
	Next
UpdateNormals Mesh
EntityColor mesh,50,255,30
EntityPickMode mesh,2
End Function

Function mesh_create3()
mesh=CreateMesh()
	For x=1 To 10
		For z=1 To 10
			surf=CreateSurface(mesh)
			v1=AddVertex(surf,x-5,0,z-4)
			v2=AddVertex(surf,x-5,0,z-5)
			v3=AddVertex(surf,x-4,0,z-5)
			v4=AddVertex(surf,x-4,0,z-4)
			t1=AddTriangle(surf,v1,v2,v3)
			t2=AddTriangle(surf,v3,v4,v1)
			t3=AddTriangle(surf,v3,v2,v1)
			t4=AddTriangle(surf,v1,v4,v3)
		Next
	Next
UpdateNormals Mesh
EntityColor mesh,50,255,30
End Function

Function mesh_create4()
mesh=CreateMesh()
surf=CreateSurface(mesh)
	For x=1 To 90
		For z=1 To 98
		    v1=AddVertex(surf,x-5,0,z-4,0,0)
			v2=AddVertex(surf,x-5,0,z-5)
			v3=AddVertex(surf,x-4,0,z-5)
			v4=AddVertex(surf,x-4,0,z-4)
			t1=AddTriangle(surf,v1,v2,v3)
			t2=AddTriangle(surf,v3,v4,v1)
			t3=AddTriangle(surf,v3,v2,v1)
			t4=AddTriangle(surf,v1,v4,v3)
		Next
	Next
UpdateNormals Mesh
EntityColor mesh,50,255,30
End Function

Function Getpicked()
picked=CameraPick(cam1,MouseX()+15,MouseY()+15)
If picked>0 Then getvert
End Function


Function Getvert()
tri=PickedTriangle()
surface=GetSurface(mesh,1)
v1=TriangleVertex(surface,tri,0)
v1x=VertexX(surface,v1)
v1y=VertexY(surface,v1)
V1z=VertexZ(surface,v1)
End Function

Function movevert1()
v1y=v1y+.001
VertexCoords (surface,v1,v1x,v1y,v1z)

End Function

Function movevert2()
v1y=v1y+-.001
VertexCoords (surface,v1,v1x,v1y,v1z)
UpdateNormals mesh
End Function


working on another possible method of terrain gen
what would does the public think would suit them better

i know the verts are not morphing properly added to many verts in testing code


wizzlefish(Posted 2005) [#12]
That looks cool


Duckstab[o](Posted 2005) [#13]
Going to implement controls for

1 quad raise lower
2 quad tilt 4way
3 tri raise lower
4 tri tilt 4way
5 vert 1 to 4 raise or lower as in each

this prog will export to a dat file or even b3d if i get it working well enough

.texture editor in progress


wizzlefish(Posted 2005) [#14]
I couldn't get anything to work except for moving the map, zooming, and clicking the triangles.


Duckstab[o](Posted 2005) [#15]
pick a tri then use q or a to move the verts


wizzlefish(Posted 2005) [#16]
I did - nothing happened.


Duckstab[o](Posted 2005) [#17]
you need to hold down the key Q or A


wizzlefish(Posted 2005) [#18]
I'll try again.


Duckstab[o](Posted 2005) [#19]
;3d terrain editor in progress
;duckstab

;left mouse select triangle
;hold q vert up
;hold a vert down
;arrow keys rotate map
;page up and down zoom
;create a texture with a black background and a white circle outline for target (30 by 30)
;create a texture with a green background with a 1 pixle border for vertile (30 by 30) 
Graphics3D 1024,768,32,1
ClearWorld(1,1,1)
Global cam1=CreateCamera()
Global lgt1=CreateLight()
Global mesh

Global picked#,tri,surface
Global v1x#,v1y#,v1z#,v1
Global v2x#,v2y#,v2z#,v2
Global v3x#,v3y#,v3z#,v3,uvmap1#,uvmap2#

Dim Vert#(21,21)
PositionEntity cam1,0,2,-40
tex=LoadTexture("vertile.png")
target=LoadImage("target.png")

mesh_create
EntityTexture mesh,tex
ScaleTexture tex,.05,.05
;EntityColor mesh,255,126,46
RotateEntity mesh,90,0,0
While Not KeyHit(1)

If KeyDown(200) Then TurnEntity mesh,.1,0,0
If KeyDown(203) Then TurnEntity mesh,0,-.1,0
If KeyDown(208) Then TurnEntity mesh,-.1,0,0
If KeyDown(205) Then TurnEntity mesh,0,.1,0
If KeyDown(201) Then MoveEntity cam1,0,0,.1
If KeyDown(209) Then MoveEntity cam1,0,0,-.1
If KeyDown(16) And picked>0 Then movevert1
If KeyDown(30) And picked>0 Then movevert2
If MouseDown(1) Then getpicked
UpdateWorld
RenderWorld
Text 100,100,"picked="+picked
Text 100,115,"Tri="+tri
Text 100,130,"vert1 x="+v1x+"  y="+v1y+"  z="+v1z
Text 100,145,"uv1="+uvmap1
Text 100,160,"uv2="+uvmap2
DrawImage target,MouseX(),MouseY()
Flip 0
Wend
End

Function Mesh_create()
mesh=CreateMesh()
surf=CreateSurface(mesh)
	For x=1 To 21
		For z=1 To 21
		vert(x,z)=AddVertex(surf,x-9,0,z-9,(x*.05)-.05,((z*.05)-.05))
		Next
	Next
	For x=1 To 20
		For z=1 To 20
			AddTriangle surf,vert(x,z),vert(x+1,z),vert(x,z+1)
			AddTriangle surf,vert(x,z+1),vert(x+1,z),vert(x+1,z+1)
		Next
	Next
UpdateNormals Mesh
EntityPickMode mesh,2	
End Function

		

Function Getpicked()
picked=CameraPick(cam1,MouseX()+15,MouseY()+15)
If picked>0 Then getvert
End Function


Function Getvert()
tri=PickedTriangle()
surface=GetSurface(mesh,1)
v1=TriangleVertex(surface,tri,0)
v2=TriangleVertex(surface,tri,1)
v3=TriangleVertex(surface,tri,2)
v1x=VertexX(surface,v1)
v1y=VertexY(surface,v1)
V1z=VertexZ(surface,v1)
v2x=VertexX(surface,v2)
v2y=VertexY(surface,v2)
V2z=VertexZ(surface,v2)
v3x=VertexX(surface,v3)
v3y=VertexY(surface,v3)
V3z=VertexZ(surface,v3)
uvmap1=VertexV# ( surface,v1,0 )
uvmap2=VertexU# ( surface,v1,1)
End Function

Function movevert1()

v1y=v1y+.003
v2y=v2y+.003
v3y=v3y+.003

VertexCoords (surface,v1,v1x,v1y,v1z)
VertexCoords (surface,v2,v2x,v2y,v2z)
VertexCoords (surface,v3,v3x,v3y,v3z)

UpdateNormals mesh
End Function

Function movevert2()

v1y=v1y-.003
v2y=v2y-.003
v3y=v3y-.003

VertexCoords (surface,v1,v1x,v1y,v1z)
VertexCoords (surface,v2,v2x,v2y,v2z)
VertexCoords (surface,v3,v3x,v3y,v3z)

UpdateNormals mesh
End Function



updated code slimline added testing for vertical move of tris