How can i do to dig some hole on the ground and perhaps some tunnel for a rpg game.. I'd tried via addvertex but i can't see the light's render....
Modulabe exterior
Blitz3D Forums/Blitz3D Programming/Modulabe exterior Say what?
what?
I'd like to create floor in a rpg that i can dig...
My ideas are
-with addvertex but it don't render the light
-with terrain and image but i can't have holes to create tunnels
-Or with a lot of cube wich could be too dificult to render
My ideas are
-with addvertex but it don't render the light
-with terrain and image but i can't have holes to create tunnels
-Or with a lot of cube wich could be too dificult to render
Most likely because the vertex normals are pointing the wrong way. Use UpdateNormals mesh after you add the hole.
Wont work
Graphics3D 800,600,16,0
SetBuffer BackBuffer()
;*----------------------
;| OPTION |
;-----------------------
mapw=800
maph=800
Const tile=10
Dim map(mapw,maph,2) ;0 pour vertex, 1 pour z, 2
;-------------------------<
p=CreatePivot()
cam=CreateCamera(p)
PositionEntity p,0,0,0
l=CreateLight(2)
PositionEntity l,0,0,-200
ground=CreateMesh()
surf=CreateSurface(ground)
TurnEntity ground,-180,0,0
PositionEntity ground,0,200,10
For gx=1 To mapw Step tile
For gy=1 To maph Step tile
map(gx,gy,1)=Rand(20)
map(gx,gy,0)=AddVertex(surf,gx,gy,map(gx,gy,1))
Next
Next
For gx=1 To mapw-tile Step tile
For gy=1 To maph-tile Step tile
AddTriangle(surf,map(gx,gy,0),map(gx+tile,gy,0),map(gx+tile,gy+tile,0))
AddTriangle(surf,map(gx,gy+tile,0),map(gx,gy,0),map(gx+tile,gy+tile,0))
Next
Next
tex=LoadTexture ("texture/bison.bmp")
Print tex
EntityTexture ground,tex
Rect 0,50,256,20
SetBuffer BackBuffer()
While Not KeyHit(1)
TurnEntity l,0,1,0
fps=MilliSecs()
If KeyDown(200) Or MouseDown(3) Then
MoveEntity p,0,2,0
ElseIf KeyDown(208) Then
MoveEntity p,0,-2,0
EndIf
If KeyDown(205) Then
MoveEntity p,2,0,0
ElseIf KeyDown(203) Then
MoveEntity p,-2,0,0
EndIf
If KeyDown(77) Or MouseDown(3) Then
MoveEntity p,0,0,2
ElseIf KeyDown(81) Then
MoveEntity p,0,0,-2
EndIf
mx=mx+MouseXSpeed()
my=my+MouseYSpeed()
RotateEntity p,0,0,-mx
RotateEntity cam,my,0,0
RenderWorld
Text 0,0,"Fps: "+(MilliSecs()-fps)
MoveMouse 400,300
Flip
Wend
Also i'd like to know how to texture triangle/triangle if it's possible.
Where must i put UPDATENORMALS mesh?
Thanks anyway...
Graphics3D 800,600,16,0
SetBuffer BackBuffer()
;*----------------------
;| OPTION |
;-----------------------
mapw=800
maph=800
Const tile=10
Dim map(mapw,maph,2) ;0 pour vertex, 1 pour z, 2
;-------------------------<
p=CreatePivot()
cam=CreateCamera(p)
PositionEntity p,0,0,0
l=CreateLight(2)
PositionEntity l,0,0,-200
ground=CreateMesh()
surf=CreateSurface(ground)
TurnEntity ground,-180,0,0
PositionEntity ground,0,200,10
For gx=1 To mapw Step tile
For gy=1 To maph Step tile
map(gx,gy,1)=Rand(20)
map(gx,gy,0)=AddVertex(surf,gx,gy,map(gx,gy,1))
Next
Next
For gx=1 To mapw-tile Step tile
For gy=1 To maph-tile Step tile
AddTriangle(surf,map(gx,gy,0),map(gx+tile,gy,0),map(gx+tile,gy+tile,0))
AddTriangle(surf,map(gx,gy+tile,0),map(gx,gy,0),map(gx+tile,gy+tile,0))
Next
Next
tex=LoadTexture ("texture/bison.bmp")
Print tex
EntityTexture ground,tex
Rect 0,50,256,20
SetBuffer BackBuffer()
While Not KeyHit(1)
TurnEntity l,0,1,0
fps=MilliSecs()
If KeyDown(200) Or MouseDown(3) Then
MoveEntity p,0,2,0
ElseIf KeyDown(208) Then
MoveEntity p,0,-2,0
EndIf
If KeyDown(205) Then
MoveEntity p,2,0,0
ElseIf KeyDown(203) Then
MoveEntity p,-2,0,0
EndIf
If KeyDown(77) Or MouseDown(3) Then
MoveEntity p,0,0,2
ElseIf KeyDown(81) Then
MoveEntity p,0,0,-2
EndIf
mx=mx+MouseXSpeed()
my=my+MouseYSpeed()
RotateEntity p,0,0,-mx
RotateEntity cam,my,0,0
RenderWorld
Text 0,0,"Fps: "+(MilliSecs()-fps)
MoveMouse 400,300
Flip
Wend
Also i'd like to know how to texture triangle/triangle if it's possible.
Where must i put UPDATENORMALS mesh?
Thanks anyway...
Where must i put UPDATENORMALS mesh?
Anytime the mesh is modified. You might want to put one right after you create the triangles, then in your code whenever you add a hole by adding more vertexes and triangles, you use UpdateNormals ground.
Here is a program I wrote that modifies a mesh. It doesn't create holes, but might give you an idea of the proper way to use UpdateNormals.
Graphics3D 800,600,32,0 SetBuffer BackBuffer() AmbientLight 0,0,0 Const size = 64 grid = CreateMesh() surface = CreateSurface(grid) For y# = -size/2 To (size/2 - 1) For x# = -size/2 To (size/2 - 1) v = AddVertex(surface,x,0,y) DebugLog v Next Next For y = 0 To (size - 2) For x = 0 To (size - 1) If x <> 0 v3 = (x - 1) + y * size v2 = x + y * size v1 = x + (y + 1) * size AddTriangle(surface,v1,v2,v3) End If If x <> (size - 1) v3 = x + y * size v2 = x + 1 + (y + 1) * size v1 = x + (y + 1) * size AddTriangle(surface,v1,v2,v3) End If Next Next PositionEntity grid,0,0,0 EntityColor grid,127,127,255 pivot = CreatePivot() camera = CreateCamera(pivot) PositionEntity camera,0,45,-45 PointEntity camera,pivot light = CreateLight() RotateEntity light,45,45,0 angle# = 0 mode = 0 multiplier# = 2 EntityFX grid,2 UpdateNormals grid While Not KeyDown(1) For x = -size/2 To size/2 - 1 For y = -size/2 To size/2 - 1 VertexCoords(surface,x + size/2 + (y + size / 2)* size,x,Sin(x*y+angle)*multiplier,y) Next Next UpdateNormals grid If KeyDown(200) Then MoveEntity camera,0,0,.5 If KeyDown(208) Then MoveEntity camera,0,0,-.5 If KeyDown(203) Then TurnEntity pivot,0,1,0 If KeyDown(205) Then TurnEntity pivot,0,-1,0 If KeyHit(51) Then multiplier = multiplier - 1 If multiplier = 0 Then multiplier = 1 If KeyHit(52) Then multiplier = multiplier + 1 RenderWorld Flip angle = angle + 1 If angle = 181 Then angle = -180 Wend
[Edit to Add] Try commenting out the UpdateNormals command in the code and notice how it affects the lighting.
[edited again cause I misspelled "quote" on the quote tag :)]
OH YEAH great, man, gratz, it's cool, thank you very much