About Monkey 2 › Forums › Monkey 2 Programming Help › Is there a way to set model/mesh alpha?
This topic contains 1 reply, has 2 voices, and was last updated by
Mark Sibly
1 year, 3 months ago.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
January 11, 2018 at 4:05 am #12801
I want my cubes to fade out, but I haven’t found any way to set alpha level so far… do I need to fiddle with the materials somehow?
I’ve tried creating a PbrMaterial using Color with alpha, and PbrMaterial.BlendMode = BlendMode.Alpha, but that doesn’t work. See highlighted Game.New portion:
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384#Import "<std>"#Import "<mojo>"#Import "<mojo3d>"Using std..Using mojo..Using mojo3d..Class Game Extends WindowField scene:SceneField cam:CameraField light:LightField background:ModelField cube:ModelMethod New (title:String, width:Int, height:Int, flags:WindowFlags)Super.New (title, width, height, flags)scene = Scene.GetCurrent ()cam = New Cameralight = New Lightbackground = Model.CreateBox (New Boxf (-5, -5, -1, 5, 5, 1), 8, 8, 8, New PbrMaterial (Color.White))background.Move (5, 0, 5)' --------------------------------------------------------------------------------------------------Local alpha:Float = 0.25Local pm:PbrMaterial = New PbrMaterial (New Color (0, 1, 0, alpha))pm.BlendMode = BlendMode.Alphacube = Model.CreateBox (New Boxf (-0.5, -0.5, -0.5, 0.5, 0.5, 0.5), 8, 8, 8, pm)cube.Move (0, 0, 2.5)' --------------------------------------------------------------------------------------------------scene.AmbientLight = Color.White * 0.75scene.ClearColor = Color.Sky * 0.75cam.Near = 0.01cam.Far = 1000light.CastsShadow = Truelight.Range = 1000light.Move (0, 50, 10)light.PointAt (cube)EndMethod OnRender (canvas:Canvas) OverrideIf Keyboard.KeyHit (Key.Escape) Then App.Terminate ()cube.Rotate (0.1, 0.2, 0.4)RequestRender ()scene.Update ()scene.Render (canvas, cam)EndEndFunction Run3D (title:String, width:Int, height:Int, flags:WindowFlags = WindowFlags.Center)New AppInstanceNew Game (title, width, height, flags)App.Run ()EndFunction Main ()Run3D ("3D Scene", 960, 540, WindowFlags.Center) ' 1/4 HD!' Run3D ("3D Scene", 1920, 1080, WindowFlags.Fullscreen)EndObviously, the expectation here is that the background will show through the green cube…
January 12, 2018 at 3:02 am #12822The is no transparency yet apart from sprites.
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.