Infinite Plane OpenB3DMax
Tweet blitzmax code-archives effects openb3d
Infinite Plane for OpenB3DMax.
- texture applied to plane is also moving when applied to other entities
- inverted texture
Author: SLotman, RonTek
Strict Framework Openb3dmax.B3dglgraphics Local width%=DesktopWidth(),height%=DesktopHeight(),depth%=0,Mode%=2 Graphics3D width,height,depth,Mode Global cam_near# = 0.1, cam_far# = 5000 Global range# Global mesh:TMesh Global surf:TSurface Global texture:TTexture Local light:TLight=CreateLight(1) RotateEntity light,90,0,0 Global camera:TCamera=CreateCamera() CameraRange camera,cam_near,cam_far MoveEntity camera,0,1,0 texture = LoadTexture("../media/test.png") While Not KeyHit(KEY_ESCAPE) Cls UpdateWorld UpdatePlane() RenderWorld Flip If KeyDown(KEY_A) Then MoveEntity camera, -0.05,0,0 If KeyDown(KEY_D) Then MoveEntity camera, 0.05,0,0 If KeyDown(KEY_UP) Then MoveEntity camera, 0,0,0.05 If KeyDown(KEY_DOWN) Then MoveEntity camera,0,0,-0.05 If KeyDown(KEY_RIGHT) Then TurnEntity camera, 0,-1,0 If KeyDown(KEY_LEFT) Then TurnEntity camera, 0,1,0 Wend End ClearWorld EndGraphics End Function UpdatePlane() Local r# = cam_far - cam_near If Abs(range - r) > 0.0001 Or mesh = Null Then range = r If mesh Then FreeEntity(mesh) mesh = CreateMesh() surf = CreateSurface(mesh) AddVertex surf,-range,0,range,-range,range,0 AddVertex surf,+range,0,range,range,range,0 AddVertex surf,+range,0,-range,range,-range,0 AddVertex surf,-range,0,-range,-range,-range,0 AddTriangle surf,0,1,2 AddTriangle surf,0,2,3 VertexNormal surf,0,0,1,0 VertexNormal surf,1,0,1,0 VertexNormal surf,2,0,1,0 VertexNormal surf,3,0,1,0 EntityTexture mesh,texture End If Local x#,z# x = EntityX(camera,True) z = EntityZ(camera,True) PositionTexture texture,-x,-z PositionEntity mesh,x,0,z End Function
"Exception Access Violation"
Any idea why I would get that? It doesn't happen if I remove the updateplane() function so it's something to do with it.
Didn't expect to figure that one out:
texture = LoadTexture("../media/test.png")
I changed to:
texture = LoadTexture("./media/test.png")
Removed one dot before the directory name. :P
I don't know why it double posted but it'd be nice if I could delete the extra posts...
Welcome to the forums PlastikCogLiquid
Nice you figured that one out and don't worry about the double post and yes will eventually consider adding a delete posts.
Reply To Topic (minimum 10 characters)
Please log in to reply