Browse Source

Un-removed modules ;-)

woollybah 7 năm trước cách đây
mục cha
commit
23a486ccae
100 tập tin đã thay đổi với 1689 bổ sung0 xóa
  1. 85 0
      b3d.mod/b3d.bmx
  2. 96 0
      b3dglgraphics.mod/b3dglgraphics.bmx
  3. 96 0
      b3dglsdlgraphics.mod/b3dglsdlgraphics.bmx
  4. 69 0
      openb3d.mod/examples/CreateTexture.bmx
  5. 45 0
      openb3d.mod/examples/CreateTexture2.bmx
  6. 54 0
      openb3d.mod/examples/LoadTexture.bmx
  7. 171 0
      openb3d.mod/examples/balls_collision.bmx
  8. 91 0
      openb3d.mod/examples/bones.bmx
  9. 93 0
      openb3d.mod/examples/camerapick.bmx
  10. 54 0
      openb3d.mod/examples/cameraprojmode.bmx
  11. 188 0
      openb3d.mod/examples/cubemap.bmx
  12. 55 0
      openb3d.mod/examples/entityvisible.bmx
  13. 75 0
      openb3d.mod/examples/fog.bmx
  14. 73 0
      openb3d.mod/examples/geosphere.bmx
  15. 79 0
      openb3d.mod/examples/light.bmx
  16. 179 0
      openb3d.mod/examples/max2d.bmx
  17. 138 0
      openb3d.mod/examples/maxgui.bmx
  18. BIN
      openb3d.mod/examples/media/07_DIFFUSE.jpg
  19. BIN
      openb3d.mod/examples/media/07_DISP.jpg
  20. BIN
      openb3d.mod/examples/media/07_NORMAL.jpg
  21. BIN
      openb3d.mod/examples/media/09_DIFFUSE.jpg
  22. BIN
      openb3d.mod/examples/media/09_DISP.jpg
  23. BIN
      openb3d.mod/examples/media/09_NORMAL.jpg
  24. BIN
      openb3d.mod/examples/media/Ball.bmp
  25. BIN
      openb3d.mod/examples/media/Castle/Castle/Brick01.bmp
  26. BIN
      openb3d.mod/examples/media/Castle/Castle/Brick02.bmp
  27. BIN
      openb3d.mod/examples/media/Castle/Castle/Button.bmp
  28. BIN
      openb3d.mod/examples/media/Castle/Castle/Button_MASK.bmp
  29. BIN
      openb3d.mod/examples/media/Castle/Castle/CapMark.bmp
  30. BIN
      openb3d.mod/examples/media/Castle/Castle/CapMark_MASK.bmp
  31. BIN
      openb3d.mod/examples/media/Castle/Castle/Carpet.bmp
  32. BIN
      openb3d.mod/examples/media/Castle/Castle/Door.bmp
  33. BIN
      openb3d.mod/examples/media/Castle/Castle/Fence.bmp
  34. BIN
      openb3d.mod/examples/media/Castle/Castle/Fence_MASK.bmp
  35. BIN
      openb3d.mod/examples/media/Castle/Castle/Grass01.bmp
  36. BIN
      openb3d.mod/examples/media/Castle/Castle/Grass02.bmp
  37. BIN
      openb3d.mod/examples/media/Castle/Castle/Main.b3d
  38. BIN
      openb3d.mod/examples/media/Castle/Castle/Main2.b3d
  39. BIN
      openb3d.mod/examples/media/Castle/Castle/Marble01.bmp
  40. BIN
      openb3d.mod/examples/media/Castle/Castle/Marble02.bmp
  41. BIN
      openb3d.mod/examples/media/Castle/Castle/Net.bmp
  42. BIN
      openb3d.mod/examples/media/Castle/Castle/Net_MASK.bmp
  43. BIN
      openb3d.mod/examples/media/Castle/Castle/Photo01.bmp
  44. BIN
      openb3d.mod/examples/media/Castle/Castle/Photo01_MASK.bmp
  45. BIN
      openb3d.mod/examples/media/Castle/Castle/Photo02.bmp
  46. BIN
      openb3d.mod/examples/media/Castle/Castle/Photo02_MASK.bmp
  47. BIN
      openb3d.mod/examples/media/Castle/Castle/Rock.bmp
  48. BIN
      openb3d.mod/examples/media/Castle/Castle/RockSand.bmp
  49. BIN
      openb3d.mod/examples/media/Castle/Castle/Roof.bmp
  50. BIN
      openb3d.mod/examples/media/Castle/Castle/Sand01.bmp
  51. BIN
      openb3d.mod/examples/media/Castle/Castle/Sand02.bmp
  52. 1 0
      openb3d.mod/examples/media/Castle/Castle/Settings.ini
  53. BIN
      openb3d.mod/examples/media/Castle/Castle/Star.bmp
  54. BIN
      openb3d.mod/examples/media/Castle/Castle/Stone.bmp
  55. BIN
      openb3d.mod/examples/media/Castle/Castle/Tree.bmp
  56. BIN
      openb3d.mod/examples/media/Castle/Castle/Tree_MASK.bmp
  57. BIN
      openb3d.mod/examples/media/Castle/Castle/Water01.bmp
  58. BIN
      openb3d.mod/examples/media/Castle/Castle/Water02.bmp
  59. BIN
      openb3d.mod/examples/media/Castle/Castle/Window.bmp
  60. BIN
      openb3d.mod/examples/media/Castle/Castle/Window_MASK.bmp
  61. BIN
      openb3d.mod/examples/media/Castle/Castle/Wood01.bmp
  62. BIN
      openb3d.mod/examples/media/Castle/Castle/Wood02.bmp
  63. BIN
      openb3d.mod/examples/media/Envroll.bmp
  64. BIN
      openb3d.mod/examples/media/Envwall.bmp
  65. BIN
      openb3d.mod/examples/media/MapOfEarth.jpg
  66. BIN
      openb3d.mod/examples/media/Zombie.jpg
  67. BIN
      openb3d.mod/examples/media/alpha_map.jpg
  68. BIN
      openb3d.mod/examples/media/cactus2.b3d
  69. BIN
      openb3d.mod/examples/media/camel.b3d
  70. BIN
      openb3d.mod/examples/media/colorkey.jpg
  71. BIN
      openb3d.mod/examples/media/compressed.gif
  72. BIN
      openb3d.mod/examples/media/compressed.jpg
  73. BIN
      openb3d.mod/examples/media/compressed.tga
  74. BIN
      openb3d.mod/examples/media/gradient.bmp
  75. BIN
      openb3d.mod/examples/media/green_ufo.b3d
  76. BIN
      openb3d.mod/examples/media/grid.b3d
  77. BIN
      openb3d.mod/examples/media/oil-drum/oildrum.3ds
  78. BIN
      openb3d.mod/examples/media/oil-drum/oildrum.jpg
  79. BIN
      openb3d.mod/examples/media/sand.bmp
  80. BIN
      openb3d.mod/examples/media/shingle.bmp
  81. BIN
      openb3d.mod/examples/media/sky.bmp
  82. BIN
      openb3d.mod/examples/media/spark.png
  83. BIN
      openb3d.mod/examples/media/spheremap.bmp
  84. BIN
      openb3d.mod/examples/media/srtm_ramp2.world.jpg
  85. BIN
      openb3d.mod/examples/media/stars.png
  86. BIN
      openb3d.mod/examples/media/teapot.b3d
  87. BIN
      openb3d.mod/examples/media/test.b3d
  88. BIN
      openb3d.mod/examples/media/test.png
  89. BIN
      openb3d.mod/examples/media/test_lm.bmp
  90. BIN
      openb3d.mod/examples/media/tex1.jpg
  91. BIN
      openb3d.mod/examples/media/tex2.jpg
  92. BIN
      openb3d.mod/examples/media/uncompressed.bmp
  93. BIN
      openb3d.mod/examples/media/uncompressed.png
  94. BIN
      openb3d.mod/examples/media/uncompressed.psd
  95. BIN
      openb3d.mod/examples/media/uncompressed.tga
  96. BIN
      openb3d.mod/examples/media/wood-crate/wcrate.jpg
  97. BIN
      openb3d.mod/examples/media/wood-crate/wcrate1.3ds
  98. BIN
      openb3d.mod/examples/media/zombie.b3d
  99. 33 0
      openb3d.mod/examples/post.bmk
  100. 14 0
      openb3d.mod/examples/shaders/alphamap.frag.glsl

+ 85 - 0
b3d.mod/b3d.bmx

@@ -0,0 +1,85 @@
+' Copyright (c) 2015, Bruce A Henderson
+' All rights reserved.
+' 
+' Redistribution and use in source and binary forms, with or without
+' modification, are permitted provided that the following conditions are met:
+' 
+' * Redistributions of source code must retain the above copyright notice, this
+'   list of conditions and the following disclaimer.
+' 
+' * Redistributions in binary form must reproduce the above copyright notice,
+'   this list of conditions and the following disclaimer in the documentation
+'   and/or other materials provided with the distribution.
+' 
+' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+' IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+' DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+' FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+' DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+' SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+' CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+' OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+' OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+'
+SuperStrict
+
+Rem
+bbdoc: 
+End Rem
+Module b3d.b3d
+
+ModuleInfo "Version: 1.00"
+ModuleInfo "License: BSD"
+ModuleInfo "Copyright: 2015 Bruce A Henderson. All rights reserved"
+
+ModuleInfo "History: 1.00"
+ModuleInfo "History: Initial Release."
+
+
+Private
+
+Global mesh_loaders:TMeshLoader
+
+Public
+
+Rem
+bbdoc: Returns a mesh loader capable of loading @extension.
+End Rem
+Function GetMeshLoader:TMeshLoader(extension:String)
+
+	Local loader:TMeshLoader = mesh_loaders
+	
+	While loader
+		If loader.CanLoadMesh(extension) Then
+			Return loader
+		End If
+		loader = loader._succ
+	Wend
+
+End Function
+
+
+Type TMeshLoader
+	Field _succ:TMeshLoader
+	
+	Method New()
+		_succ=mesh_loaders
+		mesh_loaders=Self
+	End Method
+	
+	Method CanLoadMesh:Int(extension:String) Abstract
+
+	Rem
+	bbdoc: Call mesh loader implementation.
+	about: @obj could be filename (string) or perhaps TStream, if implementation supports it.
+	End Rem
+	Method LoadMesh:Object(obj:Object, parent:Object = Null) Abstract
+
+	Rem
+	bbdoc: Call animated mesh loader implementation
+	about: @obj could be filename (string) or perhaps TStream, if implementation supports it.
+	End Rem
+	Method LoadAnimMesh:Object(obj:Object, parent:Object = Null) Abstract
+	
+End Type

+ 96 - 0
b3dglgraphics.mod/b3dglgraphics.bmx

@@ -0,0 +1,96 @@
+' Copyright (c) 2014 Mark Mcvittie, Bruce A Henderson
+'
+' This software is provided 'as-is', without any express or implied
+' warranty. In no event will the authors be held liable for any damages
+' arising from the use of this software.
+'
+' Permission is granted to anyone to use this software for any purpose,
+' including commercial applications, and to alter it and redistribute it
+' freely, subject to the following restrictions:
+'
+'    1. The origin of this software must not be misrepresented; you must not
+'    claim that you wrote the original software. If you use this software
+'    in a product, an acknowledgment in the product documentation would be
+'    appreciated but is not required.
+'
+'    2. Altered source versions must be plainly marked as such, and must not be
+'    misrepresented as being the original software.
+'
+'    3. This notice may not be removed or altered from any source
+'    distribution.
+'
+SuperStrict
+
+Rem
+bbdoc: GLGraphics backend for B3D.
+End Rem
+Module b3d.b3dglgraphics
+
+ModuleInfo "Version: 1.00"
+ModuleInfo "License: zlib/libpng"
+ModuleInfo "Copyright: 2014 Mark Mcvittie, Bruce A Henderson"
+
+ModuleInfo "History: 1.00 Initial Release"
+
+
+Import brl.systemdefault
+Import b3d.Openb3d
+Import BRL.GLMax2d
+
+Rem
+bbdoc: <a href="http://www.blitzbasic.com/b3ddocs/command.php?name=Graphics3D">Online doc</a>
+about: The flags argument sets the graphics buffers (back, alpha, depth, stencil and accum). 
+The usecanvas argument is set to true if using maxgui with a canvas context.
+End Rem
+Function Graphics3D( width%, height%, depth%=0, Mode%=0, rate%=60, flags%=-1, usecanvas%=False )
+
+	'OpenLibrary()
+	
+	Select flags ' buffer values: back=2, alpha=4, depth=8, stencil=16, accum=32
+		Case -1 flags=GRAPHICS_BACKBUFFER|GRAPHICS_ALPHABUFFER|GRAPHICS_DEPTHBUFFER|GRAPHICS_STENCILBUFFER|GRAPHICS_ACCUMBUFFER
+		Case -2 flags=GRAPHICS_BACKBUFFER|GRAPHICS_ALPHABUFFER ' 2+4
+		Case -3 flags=GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER ' 2+8
+		Case -4 flags=GRAPHICS_BACKBUFFER|GRAPHICS_STENCILBUFFER ' 2+16
+		Case -5 flags=GRAPHICS_BACKBUFFER|GRAPHICS_ACCUMBUFFER ' 2+32
+		Default flags=GRAPHICS_BACKBUFFER
+	End Select
+	
+	SetGraphicsDriver( GLMax2DDriver(),flags ) ' mixed 2d/3d
+	
+	If usecanvas ' using a canvas context
+		GraphicsResize( width,height )
+	Else ' create gfx context
+		Graphics( width,height,depth,rate,flags )		
+	EndIf
+	
+	_b3dDriver.GraphicsInit()
+	
+	Graphics3D_( width,height,depth,Mode,rate )
+	
+End Function
+
+Rem
+bbdoc: Draw text, does not need Max2D.
+End Rem
+Function Text( x%, y%, str$ )
+
+	' set active texture to texture 0 so gldrawtext will work correctly
+	If THardwareInfo.VBOSupport 'SMALLFIXES hack to keep non vbo GFX from crashing
+		glActiveTextureARB(GL_TEXTURE0)
+		glClientActiveTextureARB(GL_TEXTURE0)
+	EndIf
+		
+	glDisable(GL_LIGHTING)
+	glColor3f(1.0,1.0,1.0)
+	
+	' enable blend to hide text background
+	glEnable(GL_BLEND)
+	GLDrawText str,x,y
+	
+	glDisable(GL_BLEND)
+	glEnable(GL_LIGHTING)
+	
+	' disable texture 2D - needed as gldrawtext enables it, but doesn't disable after use
+	glDisable(GL_TEXTURE_2D)
+	
+End Function

+ 96 - 0
b3dglsdlgraphics.mod/b3dglsdlgraphics.bmx

@@ -0,0 +1,96 @@
+' Copyright (c) 2014 Mark Mcvittie, Bruce A Henderson
+'
+' This software is provided 'as-is', without any express or implied
+' warranty. In no event will the authors be held liable for any damages
+' arising from the use of this software.
+'
+' Permission is granted to anyone to use this software for any purpose,
+' including commercial applications, and to alter it and redistribute it
+' freely, subject to the following restrictions:
+'
+'    1. The origin of this software must not be misrepresented; you must not
+'    claim that you wrote the original software. If you use this software
+'    in a product, an acknowledgment in the product documentation would be
+'    appreciated but is not required.
+'
+'    2. Altered source versions must be plainly marked as such, and must not be
+'    misrepresented as being the original software.
+'
+'    3. This notice may not be removed or altered from any source
+'    distribution.
+'
+SuperStrict
+
+Rem
+bbdoc: SDL GLGraphics backend for B3D.
+End Rem
+Module b3d.b3dglsdlgraphics
+
+ModuleInfo "Version: 1.00"
+ModuleInfo "License: zlib/libpng"
+ModuleInfo "Copyright: 2014 Mark Mcvittie, Bruce A Henderson"
+
+ModuleInfo "History: 1.00 Initial Release"
+
+
+Import b3d.Openb3d
+Import SDL.GLSDLmax2d
+
+Rem
+bbdoc: <a href="http://www.blitzbasic.com/b3ddocs/command.php?name=Graphics3D">Online doc</a>
+about: The flags argument sets the graphics buffers (back, alpha, depth, stencil and accum). 
+The usecanvas argument is set to true if using maxgui with a canvas context.
+End Rem
+Function Graphics3D( width%, height%, depth%=0, Mode%=0, rate%=60, flags%=-1, usecanvas%=False )
+
+	'OpenLibrary()
+
+	Select flags ' buffer values: back=2, alpha=4, depth=8, stencil=16, accum=32
+		Case -1 flags=GRAPHICS_BACKBUFFER|GRAPHICS_ALPHABUFFER|GRAPHICS_DEPTHBUFFER|GRAPHICS_STENCILBUFFER|GRAPHICS_ACCUMBUFFER
+		Case -2 flags=GRAPHICS_BACKBUFFER|GRAPHICS_ALPHABUFFER ' 2+4
+		Case -3 flags=GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER ' 2+8
+		Case -4 flags=GRAPHICS_BACKBUFFER|GRAPHICS_STENCILBUFFER ' 2+16
+		Case -5 flags=GRAPHICS_BACKBUFFER|GRAPHICS_ACCUMBUFFER ' 2+32
+		Default flags=GRAPHICS_BACKBUFFER
+	End Select
+	
+	SetGraphicsDriver( GLMax2DDriver(),flags ) ' mixed 2d/3d
+	
+	If usecanvas ' using a canvas context
+		GraphicsResize( width,height )
+	Else ' create gfx context
+		Graphics( width,height,depth,rate,flags )		
+	EndIf
+	
+	_b3dDriver.GraphicsInit()
+	
+	Graphics3D_( width,height,depth,Mode,rate )
+	
+End Function
+
+
+Rem
+bbdoc: Draw text, does not need Max2D.
+End Rem
+Function Text( x%, y%, str$ )
+
+	' set active texture to texture 0 so gldrawtext will work correctly
+	If THardwareInfo.VBOSupport 'SMALLFIXES hack to keep non vbo GFX from crashing
+		glActiveTextureARB(GL_TEXTURE0)
+		glClientActiveTextureARB(GL_TEXTURE0)
+	EndIf
+		
+	glDisable(GL_LIGHTING)
+	glColor3f(1.0,1.0,1.0)
+	
+	' enable blend to hide text background
+	glEnable(GL_BLEND)
+	GLDrawText str,x,y
+	
+	glDisable(GL_BLEND)
+	glEnable(GL_LIGHTING)
+	
+	' disable texture 2D - needed as gldrawtext enables it, but doesn't disable after use
+	glDisable(GL_TEXTURE_2D)
+	
+End Function

+ 69 - 0
openb3d.mod/examples/CreateTexture.bmx

@@ -0,0 +1,69 @@
+' CreateTexture.bmx
+' from Blitz3D help
+Strict
+
+
+Framework b3d.b3dglgraphics
+
+Graphics3D 800,600,0,2
+
+
+Local camera:TCamera=CreateCamera()
+
+Local light:TLight=CreateLight()
+RotateEntity light,90,0,0
+
+Local cube:TMesh=CreateCube()
+PositionEntity cube,0,0,5
+
+' Create texture of size 256x256
+Local tex:TTexture=CreateTexture(256,256)
+	
+BeginMax2D()
+
+' Clear texture buffer with background white color
+SetClsColor 255,255,255
+Cls
+
+' Draw text on texture
+Local font:TImageFont=LoadImageFont("arial",24)
+SetImageFont font
+SetColor 0,0,0
+DrawText "This texture",0,0
+DrawText "was created using",0,40
+SetColor 0,0,255
+DrawText "CreateTexture()",0,80
+SetColor 0,0,0
+DrawText "and drawn to using",0,120
+SetColor 0,0,255
+DrawText "GrabPixmap() and BufferToTex()",0,160
+
+EndMax2D()
+
+Local pix:TPixmap=GrabPixmap(0,0,256,256)
+If PixmapFormat(pix)<>PF_RGBA8888 Then pix=ConvertPixmap(pix,PF_RGBA8888)
+
+BufferToTex(tex,PixmapPixelPtr(pix,0,0))
+
+EntityTexture cube,tex
+
+
+While Not KeyDown(KEY_ESCAPE)
+
+	Local pitch#=0
+	Local yaw#=0
+	Local roll#=0
+
+	If KeyDown( key_down )=True Then pitch#=-1	
+	If KeyDown( key_up )=True Then pitch#=1
+	If KeyDown( key_left )=True Then yaw#=-1
+	If KeyDown( key_right )=True Then yaw#=1
+	If KeyDown( key_z )=True Then roll#=-1
+	If KeyDown( key_x )=True Then roll#=1
+
+	TurnEntity cube,pitch#,yaw#,roll#
+	
+	RenderWorld
+	Flip
+Wend
+End

+ 45 - 0
openb3d.mod/examples/CreateTexture2.bmx

@@ -0,0 +1,45 @@
+' CreateTexture2.bmx
+' per-pixel access for textures
+Strict
+
+
+Framework b3d.b3dglgraphics
+Import brl.random
+
+Graphics3D 800,600,0,2
+
+
+Local camera:TCamera=CreateCamera()
+CameraClsColor camera,80,160,240
+
+Local light:TLight=CreateLight()
+RotateEntity light,90,0,0
+
+Local cube:TMesh=CreateCube()
+PositionEntity cube,0,0,3
+
+Local size%=32
+Local tex:TTexture=CreateTexture(size,size)
+
+Local map:TPixmap=CreatePixmap(size,size,PF_RGBA8888)
+For Local i%=0 To PixmapWidth(map)-1
+	For Local j%=0 To PixmapHeight(map)-1
+		Local rgb%=Rand(0,255)+(Rand(0,255) Shl 8)+(Rand(0,255) Shl 16)
+		WritePixel map,i,j,rgb|$ff000000
+	Next
+Next
+
+BufferToTex tex,PixmapPixelPtr(map,0,0)
+EntityTexture cube,tex
+
+
+While Not KeyDown(key_escape)
+
+	TurnEntity cube,0.0,0.5,-0.1
+	
+	RenderWorld
+	
+	Flip
+
+Wend
+End

+ 54 - 0
openb3d.mod/examples/LoadTexture.bmx

@@ -0,0 +1,54 @@
+' LoadTexture.bmx
+' supported texture formats
+Strict
+
+
+Framework b3d.b3dglgraphics
+
+Graphics3D 800,600,0,2
+
+
+Local camera:TCamera=CreateCamera()
+PositionEntity camera,0,7,0
+MoveEntity camera,0,0,-17
+
+Local light:TLight=CreateLight()
+TurnEntity light,45,45,0
+
+Local pivot:TPivot=CreatePivot()
+PositionEntity pivot,0,4,0
+
+Local temp:TMesh=CreateCube()
+Local box:TEntity[], inc%, tex:TTexture
+
+For Local t%=0 To 359 Step 360/6.9
+	box=box[..inc+1]
+	box[inc]=CopyEntity(temp,pivot)
+	TurnEntity box[inc],0,t,0
+	MoveEntity box[inc],0,0,10
+	If inc=0 Then tex=LoadTexture("media/compressed.gif")
+	If inc=1 Then tex=LoadTexture("media/compressed.jpg")
+	If inc=2 Then tex=LoadTexture("media/compressed.tga")
+	If inc=3 Then tex=LoadTexture("media/uncompressed.bmp")
+	If inc=4 Then tex=LoadTexture("media/uncompressed.png")
+	If inc=5 Then tex=LoadTexture("media/uncompressed.psd")
+	If inc=6 Then tex=LoadTexture("media/uncompressed.tga")
+	If inc<7 Then EntityTexture box[inc],tex
+	inc:+1
+Next
+FreeEntity temp
+
+
+While Not KeyHit(KEY_ESCAPE)
+
+	' turn camera
+	If KeyDown(KEY_LEFT) TurnEntity pivot,0,3,0
+	If KeyDown(KEY_RIGHT) TurnEntity pivot,0,-3,0
+	
+	UpdateWorld
+	RenderWorld
+	
+	Text 0,0,"Left/Right: turn camera"
+	
+	Flip
+Wend

+ 171 - 0
openb3d.mod/examples/balls_collision.bmx

@@ -0,0 +1,171 @@
+' balls_collision.bmx
+' from minib3d examples
+Strict
+
+
+Framework b3d.b3dglgraphics
+Import brl.random
+
+Local width%=800,height%=600,depth%=0,Mode%=2,hertz%=60
+
+Graphics3D width,height,depth,Mode,hertz
+
+
+' bullet type
+Type TBullet
+
+	Global list:TList=CreateList()
+	Global no% ' no of bullets
+	Field ent:TMesh
+	Field x#,y#,z#
+	Field vx#,vy#,vz#
+	Field life% ' life counter
+	
+	' create bullet
+	Function Shoot(x#,y#,z#,nx#,ny#,nz#)
+	
+		Local bull:TBullet=New TBullet
+		no=no+1
+		bull.ent=CreateSphere()
+		EntityColor bull.ent,64+Rand(191),64+Rand(191),64+Rand(191)
+		bull.x#=x#
+		bull.y#=y#
+		bull.z#=z#
+		bull.vx#=nx#
+		bull.vy#=ny#
+		bull.vz#=nz#
+		PositionEntity bull.ent,x#,y#,z#,True
+		EntityType bull.ent,1
+		EntityRadius bull.ent,1
+		ResetEntity bull.ent
+		ListAddLast(list,bull)
+
+	End Function
+	
+	' update bullet
+	Method Update()
+	 
+		' life counter is over 600, so bullet hasn't collided with anything for a long time - free it
+		If life>600
+			ListRemove list,Self
+			FreeEntity ent
+			no=no-1
+			Return
+		EndIf
+		
+		life=life+1 ' increase bullet life counter
+	
+		x#=EntityX(ent)
+		y#=EntityY(ent)
+		z#=EntityZ(ent)
+	
+		' check to see if the entity collided with the level
+		Local entity_hit% = CountCollisions(ent)
+
+		' if the entity collided with the level, make it bounce
+		If entity_hit
+	
+			' bullet has collided with level - reset life counter
+			life=0
+
+			' get the normal of the surface which the entity collided with
+			Local nx# = CollisionNX#(ent,1)
+			Local ny# = CollisionNY#(ent,1)
+			Local nz# = CollisionNZ#(ent,1)
+
+			' compute the dot product of the entity's motion vector and the normal of the surface collided with
+			Local vdotn# = vx#*nx# + vy#*ny# + vz#*nz#
+			
+			' calculate the normal force
+			Local nfx# = -2.0 * nx# * vdotn#
+			Local nfy# = -2.0 * ny# * vdotn# 
+			Local nfz# = -2.0 * nz# * vdotn#
+
+			' add the normal force to the direction vector. 
+			vx# = vx# + nfx#
+			vy# = vy# + nfy#
+			vz# = vz# + nfz#
+
+		EndIf
+		
+		' apply gravity
+		Local GRAVITY#=0.01
+		vy#=vy#-GRAVITY#
+
+		' update position values
+	
+		x#=x#+vx#
+		y#=y#+vy#
+		z#=z#+vz#
+			
+		PositionEntity ent,x#,y#,z#
+	
+	End Method
+	
+End Type
+
+
+Local cam:TCamera=CreateCamera()
+PositionEntity cam,0,10,-10
+CameraRange cam,.5,500
+
+Local light:TLight=CreateLight(1)
+RotateEntity light,90,0,0
+
+Local mesh:TMesh=LoadMesh("media/test.b3d")
+
+ScaleMesh mesh,10,10,10
+
+' set collision radius and types
+EntityRadius cam,1,1
+EntityType cam,1
+EntityType mesh,2
+
+' enable collisions
+Collisions 1,2,2,2
+
+' used by fps code
+Local old_ms%=MilliSecs()
+Local renders%, fps%
+
+
+While Not KeyDown(KEY_ESCAPE)		
+
+	' control camera
+	MoveEntity cam,KeyDown(KEY_D)-KeyDown(KEY_A),0,KeyDown(KEY_W)-KeyDown(KEY_S)
+	TurnEntity cam,KeyDown(KEY_DOWN)*2-KeyDown(KEY_UP)*2,KeyDown(KEY_LEFT)*2-KeyDown(KEY_RIGHT)*2,0
+
+	' shoot bullet
+	If KeyHit(KEY_SPACE)
+	
+		TFormNormal 0,0,0.05,cam,Null
+	
+		TBullet.Shoot(EntityX#(cam,True),EntityY#(cam,True),EntityZ#(cam,True),TFormedX(),TFormedY(),TFormedZ())
+
+	EndIf
+	
+	' update bullets
+	For Local bull:TBullet=EachIn TBullet.list
+		bull.Update()
+	Next
+
+	UpdateWorld
+	RenderWorld
+	
+	renders=renders+1
+
+	' calculate fps
+	If MilliSecs()-old_ms>=1000
+		old_ms=MilliSecs()
+		fps=renders
+		renders=0
+	EndIf
+	
+	Text 0,0,"FPS: "+fps
+	Text 0,20,"Press space to shoot a bullet"
+	Text 0,40,"No. of bullets: "+TBullet.no
+
+	Flip
+	
+Wend
+End

+ 91 - 0
openb3d.mod/examples/bones.bmx

@@ -0,0 +1,91 @@
+' bones.bmx
+' from minib3d examples
+Strict
+
+Framework b3d.b3dglgraphics
+
+Local width%=800,height%=600,depth%=0,Mode%=2
+
+Graphics3D width,height,depth,Mode
+
+
+Local cam:TCamera=CreateCamera()
+PositionEntity cam,0,10,-15
+
+Local light:TLight=CreateLight()
+
+' load anim mesh
+Local ent:TMesh=LoadAnimMesh("media/zombie.b3d")
+
+' child entity variables
+Local child_ent:TEntity ' this will store child entity of anim mesh
+Local child_no%=1 ' used to select child entity
+Local count_children%=TEntity.CountAllChildren(ent) ' total no. of children belonging to entity
+
+' marker entity. will be used to highlight selected child entity (with zombie anim mesh it will be a bone)
+Local marker_ent:TMesh=CreateSphere(8)
+EntityColor marker_ent,255,255,0
+ScaleEntity marker_ent,.25,.25,.25
+EntityOrder marker_ent,-1
+
+' anim time - this will be incremented/decremented each frame and then supplied to SetAnimTime to animate entity
+Local anim_time#=0
+
+' used by fps code
+Local old_ms%=MilliSecs()
+Local renders%=0, fps%=0
+
+
+While Not KeyDown(KEY_ESCAPE)		
+
+	If KeyHit(KEY_ENTER) Then DebugStop
+
+	' control camera
+	MoveEntity cam,KeyDown(KEY_D)-KeyDown(KEY_A),0,KeyDown(KEY_W)-KeyDown(KEY_S)
+	TurnEntity cam,KeyDown(KEY_DOWN)-KeyDown(KEY_UP),KeyDown(KEY_LEFT)-KeyDown(KEY_RIGHT),0
+
+	' change anim time values
+	If KeyDown(KEY_MINUS) Then anim_time#=anim_time#-0.1
+	If KeyDown(KEY_EQUALS) Then anim_time#=anim_time#+0.1
+	
+	' animte entity
+	SetAnimTime(ent,anim_time#)
+
+	' select child entity
+	If KeyHit(KEY_OPENBRACKET) Then child_no=child_no-1
+	If KeyHit(KEY_CLOSEBRACKET) Then child_no=child_no+1
+	If child_no<1 Then child_no=1
+	If child_no>count_children Then child_no=count_children
+	
+	' get child entity
+	Local count%=0 ' this is just a count variable needed by GetChildFromAll. must be set to 0.
+	child_ent=ent.GetChildFromAll(child_no,count) ' get child entity
+
+	' position marker entity at child entity position
+	If child_ent<>Null
+		PositionEntity marker_ent,EntityX(child_ent,True),EntityY(child_ent,True),EntityZ(child_ent,True)
+	EndIf
+
+	RenderWorld
+	renders=renders+1
+	
+	' calculate fps
+	If MilliSecs()-old_ms>=1000
+		old_ms=MilliSecs()
+		fps=renders
+		renders=0
+	EndIf
+	
+	'Text 0,0,"FPS: "+fps
+	'Text 0,20,"+/- to animate"
+	'Text 0,40,"[] to select different child entity (bone)"
+	If child_ent<>Null
+Local t:TEntity=FindChild(child_ent,EntityName(child_ent))
+	'	Text 0,60,"Child Name: "+EntityName(child_ent)'+", child: "+Int(t)
+	EndIf
+	'Text 0,80,"No children: "+count_children
+
+	Flip
+	
+Wend
+End

+ 93 - 0
openb3d.mod/examples/camerapick.bmx

@@ -0,0 +1,93 @@
+' camerapick.bmx
+' from minib3d examples
+Strict
+
+
+Framework b3d.b3dglgraphics
+
+
+Local width%=800,height%=600,depth%=0,Mode%=2
+
+Graphics3D width,height,depth,Mode
+
+
+Local cam:TCamera=CreateCamera()
+PositionEntity cam,0,0,-15
+
+Local light:TLight=CreateLight()
+RotateEntity light,45,0,0
+
+Local marker:TMesh=CreateSphere()
+ScaleEntity marker,0.2,0.2,0.2
+EntityColor marker,255,0,0
+
+Local sphere:TMesh=CreateSphere()
+EntityRadius sphere,1
+EntityPickMode sphere,1
+PositionEntity sphere,-10,0,0
+
+Local mesh:TMesh=LoadMesh("media/teapot.b3d")
+EntityPickMode mesh,2
+ScaleEntity mesh,4,4,4
+
+Local box:TMesh=CreateCube()
+FitMesh box,-2,-1,-1,4,2,2
+EntityBox box,-2,-1,-1,4,2,2
+EntityPickMode box,3
+PositionEntity box,10,0,0
+
+' used by fps code
+Local old_ms%=MilliSecs()
+Local renders%, fps%
+
+
+While Not KeyDown(KEY_ESCAPE)		
+
+	If KeyHit(KEY_ENTER) Then DebugStop
+
+	' control camera
+	MoveEntity cam,KeyDown(KEY_D)-KeyDown(KEY_A),0,KeyDown(KEY_W)-KeyDown(KEY_S)
+	TurnEntity cam,KeyDown(KEY_DOWN)-KeyDown(KEY_UP),KeyDown(KEY_LEFT)-KeyDown(KEY_RIGHT),0
+	
+	TurnEntity mesh,0,1,0
+
+	' if mousedown then perform camerapick
+	Local myPick:TEntity
+	If MouseDown(1)
+	
+		' reset entity colors
+		EntityColor sphere,255,255,255
+		EntityColor mesh,255,255,255
+		EntityColor box,255,255,255
+
+		myPick=CameraPick(cam,MouseX(),MouseY())
+		
+		If myPick<>Null
+			EntityColor myPick,255,255,0
+			PositionEntity marker,PickedX(),PickedY(),PickedZ()
+		EndIf
+	
+	EndIf
+
+	RenderWorld
+	renders=renders+1
+
+	' calculate fps
+	If MilliSecs()-old_ms>=1000
+		old_ms=MilliSecs()
+		fps=renders
+		renders=0
+	EndIf
+	
+	Text 0,0,"FPS: "+fps
+	
+	If myPick<>Null
+	'	Text 0,20,"Picked!"
+	Else
+	'	Text 0,20,"Not Picked"
+	EndIf
+
+	Flip
+
+Wend
+End

+ 54 - 0
openb3d.mod/examples/cameraprojmode.bmx

@@ -0,0 +1,54 @@
+' cameraprojmode.bmx
+' from minib3d examples
+
+Strict
+
+Framework b3d.b3dglgraphics
+
+Graphics3D 800,600,0
+
+
+Local camera:TCamera=CreateCamera()
+PositionEntity camera,0,0,-10
+
+Local light:TLight=CreateLight()
+RotateEntity light,0,0,0
+
+' create cube 1, near to camera
+Local cube1:TMesh=CreateCube()
+EntityColor cube1,255,0,0
+PositionEntity cube1,0,0,0
+
+' create cube 2, same size as cube 1 but further away
+Local cube2:TMesh=CreateCube()
+EntityColor cube2,0,255,0
+PositionEntity cube2,5,5,5
+
+' camera proj mode value
+Local Mode%=1, zoom#
+
+
+While Not KeyDown(KEY_ESCAPE)
+
+	' If spacebar pressed then change mode value
+	If KeyHit(KEY_SPACE)=True Then Mode=Mode+1 ; If Mode=3 Then Mode=0
+	
+	' If mode value = 2 (orthagraphic), then reduce zoom value To 0.1
+	If Mode=2 Then zoom=0.1 Else zoom=1
+	
+	' set camera projection mode using mode value
+	CameraProjMode camera,Mode
+	
+	' set camera zoom using zoom value
+	CameraZoom camera,zoom
+	
+	RenderWorld
+	
+	Text 0,0,"Press spacebar to change the camera project mode"
+	Text 0,20,"CameraProjMode camera,"+Mode
+	Text 0,40,"CameraZoom camera,"+zoom
+	
+	Flip
+
+Wend
+End

+ 188 - 0
openb3d.mod/examples/cubemap.bmx

@@ -0,0 +1,188 @@
+' cubemap.bmx
+' from minib3d examples
+
+Strict
+
+
+Framework b3d.b3dglgraphics
+
+Local width%=800,height%=600,depth%=0,Mode%=2
+
+Graphics3D width,height,depth,Mode
+
+
+Local cam:TCamera=CreateCamera()
+PositionEntity cam,0,8,-10
+
+' create separate camera for updating cube map - this allows us to avoid any confusion
+Local cube_cam:TCamera=CreateCamera()
+HideEntity cube_cam
+
+Local light:TLight=CreateLight(2)
+RotateEntity light,45,45,0
+PositionEntity light,10,10,0
+LightRange light,10
+
+' load object we will apply cubemap to - the classic teapot
+Local teapot:TMesh=LoadMesh("media/teapot.b3d")
+ScaleEntity teapot,5,5,5
+PositionEntity teapot,0,6,10
+
+' ground
+Local ground:TMesh=LoadMesh("media/grid.b3d")
+ScaleEntity ground,1000,1,1000
+EntityColor ground,168,133,55
+Local ground_tex:TTexture=LoadTexture("media/sand.bmp")
+ScaleTexture ground_tex,0.001,0.001
+EntityTexture ground,ground_tex
+
+' sky
+Local sky:TMesh=CreateSphere(24)
+ScaleEntity sky,500,500,500
+FlipMesh sky
+EntityFX sky,1
+Local sky_tex:TTexture=LoadTexture("media/sky.bmp")
+EntityTexture sky,sky_tex
+
+' cactus
+Local cactus:TMesh=LoadMesh("media/cactus2.b3d")
+FitMesh cactus,-5,0,0,2,6,0.5
+
+' camel
+Local camel:TMesh=LoadMesh("media/camel.b3d")
+FitMesh camel,5,0,0,6,5,4
+
+' load ufo to give us a dynamic moving object that the cubemap will be able to reflect
+Local ufo_piv:TPivot=CreatePivot()
+PositionEntity ufo_piv,0,10,10
+Local ufo:TMesh=LoadMesh("media/green_ufo.b3d",ufo_piv)
+PositionEntity ufo,0,0,10
+
+' create texture with color + cubic environment map
+Local tex:TTexture=CreateTexture(256,256,1+128)
+
+' apply cubic environment map to teapot
+EntityTexture teapot,tex
+
+' used by fps code
+Local old_ms%=MilliSecs()
+Local renders%, fps%, ticks%=0
+
+Local blendmode%, cubemode%=1
+
+
+While Not KeyDown(KEY_ESCAPE)
+
+	' control camera
+	MoveEntity cam,KeyDown(KEY_D)-KeyDown(KEY_A),0,KeyDown(KEY_W)-KeyDown(KEY_S)
+	TurnEntity cam,KeyDown(KEY_DOWN)-KeyDown(KEY_UP),KeyDown(KEY_LEFT)-KeyDown(KEY_RIGHT),0
+	
+	' change cube mode: specular, diffuse
+	If KeyHit(KEY_M)
+		cubemode=cubemode+1
+		If cubemode=3 Then cubemode=1
+		SetCubeMode tex,cubemode
+	EndIf
+	
+	' alpha blending
+	If KeyHit(KEY_B) Then blendmode=Not blendmode
+	If blendmode=0 Then EntityAlpha teapot,1.0
+	If blendmode=1 Then EntityAlpha teapot,0.7
+	
+	' turn ufo pivot, causing child ufo mesh to spin around it (and teapot)
+	TurnEntity ufo_piv,0,2,0
+	TurnEntity teapot,0,0.5,-0.1
+	
+	' hide main camera before updating cube map - we don't need to render it when cube_cam is rendered
+	HideEntity cam
+
+	' update cubemap
+	If ticks=0 Then UpdateCubemap(tex,cube_cam,teapot)
+	ticks:+1 ; If ticks>=2 Then ticks=0 ' once every 3 ticks
+	
+	' show main camera again
+	ShowEntity cam
+
+	RenderWorld
+	
+	' calculate fps
+	renders=renders+1
+	If MilliSecs()-old_ms>=1000
+		old_ms=MilliSecs()
+		fps=renders
+		renders=0
+	EndIf
+	
+	Text 0,0,"FPS: "+fps
+	Text 0,20,"M: cubemode = "+cubemode+", B: blendmode = "+blendmode
+
+	Flip
+
+Wend
+
+
+Function UpdateCubemap(tex:TTexture,camera:TCamera,entity:TEntity)
+
+	Local tex_sz%=TextureWidth(tex)
+
+	' show the camera we have specifically created for updating the cubemap
+	ShowEntity camera
+	
+	' hide entity that will have cubemap applied to it.
+	' This is so we can get cubemap from its position, without it blocking the view
+	HideEntity entity
+
+	' position camera where the entity is - this is where we will be rendering views from for cubemap
+	PositionEntity camera,EntityX#(entity),EntityY#(entity),EntityZ#(entity)
+
+	CameraClsMode camera,False,True
+	
+	' set the camera's viewport so it is the same size as our texture
+	' - so we can fit entire screen contents into texture
+	CameraViewport camera,0,GraphicsHeight()-tex_sz,tex_sz,tex_sz ' y is inverted
+	
+	' update cubemap - Blitz3D uses CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex)
+
+	' do left view	
+	SetCubeFace tex,0
+	RotateEntity camera,0,90,0
+	RenderWorld
+	BackBufferToTex tex
+	
+	' do forward view
+	SetCubeFace tex,1
+	RotateEntity camera,0,0,0
+	RenderWorld
+	BackBufferToTex tex
+	
+	' do right view	
+	SetCubeFace tex,2
+	RotateEntity camera,0,-90,0
+	RenderWorld
+	BackBufferToTex tex
+	
+	' do backward view
+	SetCubeFace tex,3
+	RotateEntity camera,0,180,0
+	RenderWorld
+	BackBufferToTex tex
+	
+	' do up view
+	SetCubeFace tex,4
+	RotateEntity camera,-90,0,0
+	RenderWorld
+	BackBufferToTex tex
+	
+	' do down view
+	SetCubeFace tex,5
+	RotateEntity camera,90,0,0
+	RenderWorld
+	BackBufferToTex tex
+	
+	' show entity again
+	ShowEntity entity
+	
+	' hide the cubemap camera
+	HideEntity camera
+	
+End Function

+ 55 - 0
openb3d.mod/examples/entityvisible.bmx

@@ -0,0 +1,55 @@
+' entityvisible.bmx
+' from minib3d examples
+
+Strict
+
+
+Framework b3d.b3dglgraphics
+
+Local width%=800,height%=600,depth%=0,Mode%=2
+
+Graphics3D width,height,depth,Mode
+
+
+Local light:TLight=CreateLight(1)
+RotateEntity light,90,0,0
+
+Local cam:TCamera=CreateCamera()
+PositionEntity cam,0,10,-10
+
+Local sphere1:TMesh=CreateSphere()
+PositionEntity sphere1,0,0,-2
+EntityColor sphere1,255,0,0
+
+Local box:TMesh=CreateCube()
+ScaleMesh box,2,1.5,0.5
+EntityPickMode box,2,True
+
+Local sphere2:TMesh=CreateSphere()
+PositionEntity sphere2,0,0,2
+EntityColor sphere2,0,255,0
+
+PointEntity cam,sphere2
+
+
+While Not KeyHit(KEY_ESCAPE)
+
+	If KeyDown(KEY_LEFT) Then MoveEntity box,-0.1,0,0
+	If KeyDown(KEY_RIGHT) Then MoveEntity box,0.1,0,0
+	
+	Local visible%=EntityVisible(sphere1,sphere2)
+	
+	RenderWorld
+	
+	Text 0,0,"Use left/right cursor keys to move block"
+	
+	If visible=True
+		Text 0,20,"Balls can see each other"
+	Else
+		Text 0,20,"Balls can't see each other" 
+	EndIf
+	
+	Flip
+
+Wend
+End

+ 75 - 0
openb3d.mod/examples/fog.bmx

@@ -0,0 +1,75 @@
+' fog.bmx
+' from minib3d examples
+
+Framework b3d.b3dglgraphics
+
+Strict
+
+Local width%=800,height%=600,depth%=0,Mode%=2
+
+Graphics3D width,height,depth,Mode
+
+
+ClearTextureFilters
+
+Local cam:TCamera=CreateCamera()
+CameraFogMode cam,1
+CameraFogRange cam,0,1000
+PositionEntity cam,0,100,-100
+
+Local light:TLight=CreateLight(1)
+
+Local grid:TMesh=LoadAnimMesh("media/grid.b3d")
+ScaleEntity grid,100,1,100
+
+Local tex:TTexture=LoadTexture("media/test.png")
+
+Local cube:TMesh=CreateCube()
+Local sphere:TMesh=CreateSphere()
+Local cylinder:TMesh=CreateCylinder()
+Local cone:TMesh=CreateCone()
+
+PositionEntity cube,0,100,250
+PositionEntity sphere,500,100,500
+PositionEntity cylinder,-500,100,750
+PositionEntity cone,0,100,1000
+
+ScaleEntity cube,100,100,100
+ScaleEntity sphere,100,100,100
+ScaleEntity cylinder,100,100,100
+ScaleEntity cone,100,100,100
+
+EntityTexture cube,tex
+EntityTexture sphere,tex
+EntityTexture cylinder,tex
+EntityTexture cone,tex
+
+' used by fps code
+Local old_ms%=MilliSecs()
+Local renders%, fps%
+
+
+While Not KeyDown(KEY_ESCAPE)		
+
+	If KeyHit(KEY_ENTER) Then DebugStop
+
+	' control camera
+	MoveEntity cam,KeyDown(KEY_D)*10-KeyDown(KEY_A)*10,0,KeyDown(KEY_W)*10-KeyDown(KEY_S)*10
+	TurnEntity cam,KeyDown(KEY_DOWN)*2-KeyDown(KEY_UP)*2,KeyDown(KEY_LEFT)*2-KeyDown(KEY_RIGHT)*2,0
+
+	RenderWorld
+	renders=renders+1
+
+	' calculate fps
+	If MilliSecs()-old_ms>=1000
+		old_ms=MilliSecs()
+		fps=renders
+		renders=0
+	EndIf
+	
+	Text 0,0,"FPS: "+fps
+
+	Flip
+	
+Wend
+End

+ 73 - 0
openb3d.mod/examples/geosphere.bmx

@@ -0,0 +1,73 @@
+' geosphere.bmx
+' www.freebasic.net/forum/viewtopic.php?f=14&t=15409&start=705
+
+Strict
+
+
+Framework b3d.b3dglgraphics
+
+
+Graphics3D 800,600,0,2
+
+
+Local camera:TCamera=CreateCamera()
+CameraRange camera,0.00001,100
+MoveEntity camera,0,0,-23
+
+Local x:TGeosphere=LoadGeosphere("media/srtm_ramp2.world.jpg") ' heightmap
+'Local x:TGeosphere=CreateGeosphere(2700)
+ScaleEntity x,0.01,0.01,0.01
+
+Local light:TLight=CreateLight()
+MoveEntity light,10,10,10
+PointEntity light,x
+
+Local tex:TTexture=LoadTexture("media/MapOfEarth.jpg") ' colormap
+Local mapheight%=1350
+ScaleTexture tex,mapheight,mapheight
+EntityTexture x,tex
+
+EntityPickMode x,2
+Local sphere:TMesh=CreateSphere()
+ScaleEntity sphere,0.1,0.1,0.1
+EntityColor sphere,255,0,0
+
+EntityType camera,1
+EntityRadius camera,0.03
+EntityType x,2
+Collisions 1,2,2,2 ' set collisons: 2 = elipsoid-polygon method, 2 = full-slide reponse
+
+Local wiretoggle%=-1
+
+
+While Not KeyDown(KEY_ESCAPE)
+
+	' zoom
+	If KeyDown(KEY_A) Then MoveEntity camera,0,0,0.08
+	If KeyDown(KEY_Z) Then MoveEntity camera,0,0,-0.08
+	
+	' move camera
+	If KeyDown(KEY_UP) Then TurnEntity camera,-0.5,0,0,0
+	If KeyDown(KEY_DOWN) Then TurnEntity camera,0.5,0,0,0
+	If KeyDown(KEY_LEFT) Then TurnEntity camera,0,0.5,0,0
+	If KeyDown(KEY_RIGHT) Then TurnEntity camera,0,-0.5,0,0
+	
+	' spin geosphere
+	If KeyDown(KEY_SPACE) Then TurnEntity x,0,0.5,0
+	
+	' wireframe
+	If KeyHit(KEY_W) Then wiretoggle=-wiretoggle
+	If wiretoggle=1 Then Wireframe True Else Wireframe False
+	
+	CameraPick camera,MouseX(),MouseY()
+	PositionEntity sphere,PickedX(),PickedY(),PickedZ()
+	
+	UpdateWorld 1
+	RenderWorld
+	
+	Text 0,0,"A/Z: zoom, Arrows: move camera, Space: spin geo, W: wireframe"
+	Text 0,20,"x = "+EntityX(camera)+" y = "+EntityY(camera)+" z = "+EntityZ(camera)
+
+	Flip
+
+Wend

+ 79 - 0
openb3d.mod/examples/light.bmx

@@ -0,0 +1,79 @@
+' light.bmx
+' from minib3d examples
+
+Strict
+
+
+Framework b3d.b3dglgraphics
+
+
+Local width%=800,height%=600,depth%=0,Mode%=2
+
+Graphics3D width,height,depth,Mode
+
+
+AmbientLight 32,32,32
+
+Local cam:TCamera=CreateCamera()
+PositionEntity cam,0,0,-60
+
+Local light:TLight=CreateLight(2)
+LightColor light,255,0,0
+LightRange light,5
+
+Local lr%
+Local light2:TLight=CreateLight(2)
+LightColor light2,0,255,0
+LightRange light2,5
+PositionEntity light2,0,0,10
+
+Local ent1:TMesh=LoadAnimMesh("media/grid.b3d")
+Local ent2:TEntity=CopyEntity(ent1)
+
+PositionEntity ent1,0,10,0
+PositionEntity ent2,0,-10,0
+
+RotateEntity ent1,180,0,0
+
+Local ent3:TMesh=CreateSphere()
+Local ent4:TMesh=CreateSphere()
+
+PositionEntity ent3,-10,0,0
+PositionEntity ent4,10,0,0
+
+ScaleEntity ent3,4,4,4
+ScaleEntity ent4,4,4,4
+
+' used by fps code
+Local old_ms%=MilliSecs()
+Local renders%, fps%
+
+
+While Not KeyDown(KEY_ESCAPE)		
+
+	If KeyHit(KEY_ENTER) Then DebugStop
+	If KeyHit(KEY_L)
+		lr=Not lr
+		If lr Then LightRange light2,0 Else LightRange light2,5
+	EndIf
+	
+	' control camera
+	MoveEntity cam,KeyDown(KEY_D)-KeyDown(KEY_A),0,KeyDown(KEY_W)-KeyDown(KEY_S)
+	TurnEntity cam,KeyDown(KEY_DOWN)-KeyDown(KEY_UP),KeyDown(KEY_LEFT)-KeyDown(KEY_RIGHT),0
+	
+	RenderWorld
+	renders=renders+1
+	
+	' calculate fps
+	If MilliSecs()-old_ms>=1000
+		old_ms=MilliSecs()
+		fps=renders
+		renders=0
+	EndIf
+	
+	Text 0,0,"FPS: "+fps
+
+	Flip
+
+Wend
+End

+ 179 - 0
openb3d.mod/examples/max2d.bmx

@@ -0,0 +1,179 @@
+' max2d.bmx
+' from minib3d examples
+
+Strict
+
+
+Framework b3d.b3dglgraphics
+Import sdl.glmax2d
+
+Import brl.random
+Import brl.pngloader
+
+Global width%=800,height%=600,depth%=0,Mode%=2
+
+Graphics3D width,height,depth,Mode
+
+
+' Initialise MiniB3D program (spheremap)
+' --------------------------------------
+
+Local cam:TCamera=CreateCamera()
+PositionEntity cam,0,0,-3
+
+Local light:TLight=CreateLight()
+RotateEntity light,90,0,0
+
+' load object we will apply spheremap to - the classic teapot
+Local teapot:TMesh=LoadMesh("media/teapot.b3d")
+
+' load texture with color + spherical environment map
+Local tex:TTexture=LoadTexture("media/spheremap.bmp",1+64)
+
+' apply spherical environment map to teapot
+EntityTexture teapot,tex
+
+
+' Initialise Max2D program
+' ------------------------
+
+' Create a spark type
+Type spark
+	Field x#,y#,z#,vy#,xd#,yd#,zd#,r#,g#,b#,alpha#
+End Type
+
+' Load spark image
+Global sparki:TImage=LoadImage("media/spark.png")
+
+' Set no. of sparks to be created per firework
+Global no_sparks%=500
+
+' Create spark list
+Global spark_list:TList=New TList
+
+' Load and set font
+Global font:TImageFont=LoadImageFont("Arial.ttf",1)
+SetImageFont font
+
+
+' Main loop
+' ---------
+
+' used by fps code
+Local old_ms%=MilliSecs()
+Local renders%, fps%
+
+While Not KeyDown(KEY_ESCAPE)
+
+	' control camera
+	MoveEntity cam,KeyDown(KEY_D)-KeyDown(KEY_A),0,KeyDown(KEY_W)-KeyDown(KEY_S)
+	TurnEntity cam,KeyDown(KEY_DOWN)-KeyDown(KEY_UP),KeyDown(KEY_LEFT)-KeyDown(KEY_RIGHT),0
+	
+	TurnEntity teapot,0,1,0
+
+	RenderWorld
+	renders=renders+1
+		
+	' calculate fps
+	If MilliSecs()-old_ms>=1000
+		old_ms=MilliSecs()
+		fps=renders
+		renders=0
+	EndIf
+	
+	Text 0,0,"FPS: "+fps
+
+	BeginMax2D() ' MiniB3D function
+	UpdateMax2D() ' your function
+	EndMax2D() ' MiniB3D function
+
+	Flip
+	Cls
+
+Wend
+End
+
+
+Function UpdateMax2D()
+
+	' If space key pressed then create new set of sparks (new firework)
+
+	If KeyHit(KEY_SPACE)
+
+		Local x#=Rand(-100,100)
+		Local y#=Rand(-100,100)
+		Local z#=200
+
+		Local r#=Rand(255)
+		Local g#=Rand(255)
+		Local b#=Rand(255)
+
+		For Local i%=1 To no_sparks
+
+			Local speed#=0.1
+
+			Local ang1#=Rnd!(360)
+			Local ang2#=Rnd!(360)
+
+			Local sp:spark=New Spark
+			spark_list.AddLast sp
+
+			sp.x=x#
+			sp.y=y#
+			sp.z=z#
+
+			sp.xd=Cos(ang1#)*Cos(ang2#)*speed#
+			sp.yd=Cos(ang1#)*Sin(ang2#)*speed#
+			sp.zd=Sin(ang1#)*speed#
+	
+			sp.r=r
+			sp.g=g
+			sp.b=b
+			sp.alpha=1
+	
+		Next
+
+	EndIf
+
+	' Draw all sparks
+
+	For Local sp:spark=EachIn spark_list
+
+		' If spark alpha is above 0 then draw it...
+
+		If sp.alpha>0
+
+			sp.x=sp.x+sp.xd*10.0
+			sp.y=sp.y+sp.yd*10.0
+			sp.z=sp.z+sp.zd*10.0
+			sp.y=sp.y+sp.vy#
+			sp.vy=sp.vy+0.02
+
+			' Calculate x and y draw values based on x,y,z co-ordinates
+			Local x#=(width/2.0)+((sp.x/sp.z)*500)
+			Local y#=(height/2.0)+((sp.y/sp.z)*500)
+
+			sp.alpha=sp.alpha-0.01
+
+			SetColor sp.r#,sp.g#,sp.b#
+			SetBlend LIGHTBLEND
+			SetAlpha sp.alpha
+			SetScale 20/sp.z,20/sp.z
+			DrawImage sparki,x#,y#
+
+		'...else remove spark from spark list
+
+		Else
+
+			spark_list.Remove sp
+
+		EndIf
+
+	Next
+
+	SetBlend SOLIDBLEND
+	SetScale 1,1
+	SetColor 255,255,255
+	DrawText "Press space to ignite firework",0,20
+	
+End Function

+ 138 - 0
openb3d.mod/examples/maxgui.bmx

@@ -0,0 +1,138 @@
+' maxgui.bmx
+' from minib3d examples (Based on code by Birdie and Peter Scheutz)
+
+Import "../openb3dlib.bmx"
+
+?Linux
+Import bah.gtkmaxgui
+?Not Linux
+Import maxgui.drivers
+?
+
+Strict
+
+SetGraphicsDriver GLMax2DDriver() ' needed before CreateCanvas in Windows
+
+Local win:TGadget=CreateWindow("MiniB3D in a GUI window", 10, 10, 512, 512 )
+
+Local can:TGadget=CreateCanvas(0,0,ClientWidth(win),ClientHeight(win),win,0)
+SetGadgetLayout can,1,1,1,1
+SetGraphics CanvasGraphics(can)
+
+Graphics3D ClientWidth(win),ClientHeight(win),0,2,60,-1,True ' true if using a canvas context
+
+
+Local cam:TCamera=CreateCamera()
+PositionEntity cam,0,0,-10
+
+Local light:TLight=CreateLight(1)
+
+Local tex:TTexture=LoadTexture("media/test.png")
+
+Local cube:TMesh=CreateCube()
+Local sphere:TMesh=CreateSphere()
+Local cylinder:TMesh=CreateCylinder()
+Local cone:TMesh=CreateCone() 
+
+PositionEntity cube,-6,0,0
+PositionEntity sphere,-2,0,0
+PositionEntity cylinder,2,0,0
+PositionEntity cone,6,0,0
+
+EntityTexture cube,tex
+EntityTexture sphere,tex
+EntityTexture cylinder,tex
+EntityTexture cone,tex
+
+Local cx#=0
+Local cy#=0
+Local cz#=0
+
+Local pitch#=0
+Local yaw#=0
+Local roll#=0
+
+' used by fps code
+Local old_ms%=MilliSecs()
+Local renders%, fps%
+
+Local up_key%, down_key%, left_key%, right_key%
+
+CreateTimer(60)
+
+
+While True
+
+	WaitEvent()
+
+	Select EventID()
+
+		Case EVENT_KEYDOWN
+		
+			Select EventData()
+				Case KEY_ESCAPE
+					End
+				Case KEY_UP
+					up_key=True
+				Case KEY_DOWN
+					down_key=True			
+				Case KEY_LEFT
+					left_key=True
+				Case KEY_RIGHT
+					right_key=True	
+			EndSelect
+			
+		Case EVENT_KEYUP
+		
+			Select EventData()
+				Case KEY_UP
+					up_key=False
+				Case KEY_DOWN
+					down_key=False			
+				Case KEY_LEFT
+					left_key=False
+				Case KEY_RIGHT
+					right_key=False	
+			EndSelect
+
+		Case EVENT_WINDOWCLOSE
+		
+            End
+
+		Case EVENT_WINDOWSIZE
+		
+			GraphicsResize(ClientWidth(win),ClientHeight(win)) ' update width/height values
+			
+			CameraViewport(cam,0,0,ClientWidth(win),ClientHeight(win)) ' set camera size
+			
+			DebugLog "EVENT_WINDOWSIZE" 
+
+		Case EVENT_TIMERTICK
+
+			If up_key Then cz#=cz#+1.0
+			If left_key Then cx#=cx#-1.0
+			If right_key Then cx#=cx#+1.0
+			If down_key Then cz#=cz#-1.0
+
+			MoveEntity cam,cx#*0.5,cy#*0.5,cz#*0.5
+			RotateEntity cam,pitch#,yaw#,roll#
+			
+			cx#=0
+			cy#=0
+			cz#=0
+
+			RedrawGadget can
+              
+		Case EVENT_GADGETPAINT
+			
+			SetGraphics CanvasGraphics(can)
+
+			TurnEntity cube,0,1,0
+
+			RenderWorld
+			
+			Flip
+                                
+	EndSelect
+	
+Wend

BIN
openb3d.mod/examples/media/07_DIFFUSE.jpg


BIN
openb3d.mod/examples/media/07_DISP.jpg


BIN
openb3d.mod/examples/media/07_NORMAL.jpg


BIN
openb3d.mod/examples/media/09_DIFFUSE.jpg


BIN
openb3d.mod/examples/media/09_DISP.jpg


BIN
openb3d.mod/examples/media/09_NORMAL.jpg


BIN
openb3d.mod/examples/media/Ball.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Brick01.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Brick02.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Button.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Button_MASK.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/CapMark.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/CapMark_MASK.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Carpet.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Door.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Fence.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Fence_MASK.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Grass01.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Grass02.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Main.b3d


BIN
openb3d.mod/examples/media/Castle/Castle/Main2.b3d


BIN
openb3d.mod/examples/media/Castle/Castle/Marble01.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Marble02.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Net.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Net_MASK.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Photo01.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Photo01_MASK.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Photo02.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Photo02_MASK.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Rock.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/RockSand.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Roof.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Sand01.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Sand02.bmp


+ 1 - 0
openb3d.mod/examples/media/Castle/Castle/Settings.ini

@@ -0,0 +1 @@
+2500

BIN
openb3d.mod/examples/media/Castle/Castle/Star.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Stone.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Tree.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Tree_MASK.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Water01.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Water02.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Window.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Window_MASK.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Wood01.bmp


BIN
openb3d.mod/examples/media/Castle/Castle/Wood02.bmp


BIN
openb3d.mod/examples/media/Envroll.bmp


BIN
openb3d.mod/examples/media/Envwall.bmp


BIN
openb3d.mod/examples/media/MapOfEarth.jpg


BIN
openb3d.mod/examples/media/Zombie.jpg


BIN
openb3d.mod/examples/media/alpha_map.jpg


BIN
openb3d.mod/examples/media/cactus2.b3d


BIN
openb3d.mod/examples/media/camel.b3d


BIN
openb3d.mod/examples/media/colorkey.jpg


BIN
openb3d.mod/examples/media/compressed.gif


BIN
openb3d.mod/examples/media/compressed.jpg


BIN
openb3d.mod/examples/media/compressed.tga


BIN
openb3d.mod/examples/media/gradient.bmp


BIN
openb3d.mod/examples/media/green_ufo.b3d


BIN
openb3d.mod/examples/media/grid.b3d


BIN
openb3d.mod/examples/media/oil-drum/oildrum.3ds


BIN
openb3d.mod/examples/media/oil-drum/oildrum.jpg


BIN
openb3d.mod/examples/media/sand.bmp


BIN
openb3d.mod/examples/media/shingle.bmp


BIN
openb3d.mod/examples/media/sky.bmp


BIN
openb3d.mod/examples/media/spark.png


BIN
openb3d.mod/examples/media/spheremap.bmp


BIN
openb3d.mod/examples/media/srtm_ramp2.world.jpg


BIN
openb3d.mod/examples/media/stars.png


BIN
openb3d.mod/examples/media/teapot.b3d


BIN
openb3d.mod/examples/media/test.b3d


BIN
openb3d.mod/examples/media/test.png


BIN
openb3d.mod/examples/media/test_lm.bmp


BIN
openb3d.mod/examples/media/tex1.jpg


BIN
openb3d.mod/examples/media/tex2.jpg


BIN
openb3d.mod/examples/media/uncompressed.bmp


BIN
openb3d.mod/examples/media/uncompressed.png


BIN
openb3d.mod/examples/media/uncompressed.psd


BIN
openb3d.mod/examples/media/uncompressed.tga


BIN
openb3d.mod/examples/media/wood-crate/wcrate.jpg


BIN
openb3d.mod/examples/media/wood-crate/wcrate1.3ds


BIN
openb3d.mod/examples/media/zombie.b3d


+ 33 - 0
openb3d.mod/examples/post.bmk

@@ -0,0 +1,33 @@
+# post build script
+#
+#
+
+@define copyDLL
+	if bmk.Platform() == "macos" then
+
+		framework = "SDL2.framework"
+
+		# frameworks folder exists?
+		folder = %exepath% .. "/../Frameworks"
+
+		if sys.FileType(folder) == 0 then
+			sys.CreateDir(folder)
+		end
+	
+		# framework exists?
+		if sys.FileType(folder .. "/" .. framework) == 0 then
+
+			# assumes Sparkle.framework.zip is in the module folder.
+			zip = utils.ModulePath("sdl.sdl") .. "/lib/macos/" .. framework .. ".zip"
+		
+			os.execute("unzip -qq " .. zip .. " -d " .. folder)
+	
+		end
+
+	end	
+
+@end
+
+
+#copy the shared objects
+copyDLL

+ 14 - 0
openb3d.mod/examples/shaders/alphamap.frag.glsl

@@ -0,0 +1,14 @@
+// www.gamedev.net/topic/626244-glsl-pixel-color-based-on-alpha/
+
+varying vec2 texCoords;
+uniform sampler2D tex;
+uniform sampler2D alphatex;
+
+void main()
+{
+	vec4 pixel = texture2D(tex, texCoords);
+	vec4 alpha_color = texture2D(alphatex, texCoords);
+	pixel.a = alpha_color.r;
+	
+	gl_FragColor = pixel;
+}

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác