About Monkey 2 › Forums › Monkey 2 Code Library › Canvas textured box
This topic contains 0 replies, has 1 voice, and was last updated by Simon Armstrong 6 months, 1 week ago.
Viewing 1 post (of 1 total)
-
AuthorPosts
-
August 15, 2018 at 1:06 am #15306
An example of a canvas textured box for rendering virtual 2d displays in 3d.
Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798Namespace myapp3d#Import "<std>"#Import "<mojo>"#Import "<mojo3d>"Using std..Using mojo..Using mojo3d..Class MyWindow Extends WindowField _scene:SceneField _camera:CameraField _light:LightField _ground:ModelField _shader:ShaderField _texture:TextureField _canvas:CanvasField _material:PbrMaterialField _box:ModelField _frameCount:IntMethod New( title:String="Simple mojo3d app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )Super.New( title,width,height,flags )EndMethod OnCreateWindow() Override'create (current) scene_scene=New Scene_scene.ClearColor = New Color( 0.2, 0.6, 1.0 )_scene.AmbientLight = _scene.ClearColor * 0.25_scene.FogColor = _scene.ClearColor_scene.FogNear = 1.0_scene.FogFar = 200.0'create camera_camera=New Camera( Self )_camera.AddComponent<FlyBehaviour>()_camera.Move( 0,2.5,-20 )'create light_light=New Light_light.CastsShadow=True_light.Rotate( 45, 45, 0 )'create groundLocal groundBox:=New Boxf( -100,-1,-100,100,0,100 )Local groundMaterial:=New PbrMaterial( Color.Lime )_ground=Model.CreateBox( groundBox,1,1,1,groundMaterial )_ground.CastsShadow=False'create canvas textured box_texture=New Texture(128,128,PixelFormat.RGBA8,TextureFlags.Filter)_canvas=New Canvas(New Image(_texture,_shader))_material=New PbrMaterial( Color.White, 0.5, 0.5 )_material.ColorTexture=_texture_box=Model.CreateBox(New Boxf(-10,-10,-1,10,10,0 ),1,1,1,_material)_box.Move(0,10,0)EndMethod UpdateCanvas()_canvas.Clear(Color.Brown)_canvas.DrawText("Hello From Mojo3D",10,10)_canvas.DrawText("Frame = "+_frameCount,10,30)_canvas.Flush()_frameCount+=1EndMethod OnRender( canvas:Canvas ) OverrideUpdateCanvas()RequestRender()_scene.Update()_camera.Render( canvas )canvas.DrawText( "FPS="+App.FPS,0,0 )EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()End -
AuthorPosts
Viewing 1 post (of 1 total)
You must be logged in to reply to this topic.