About Monkey 2 › Forums › Monkey 2 Programming Help › Light rotating with model?
Tagged: monkey coding light
This topic contains 2 replies, has 2 voices, and was last updated by
TurkeyLurker 1 year, 7 months ago.
-
AuthorPosts
-
August 23, 2017 at 9:38 pm #9975
When I run the following code, the loaded object is rotating, but the light seems to rotate along with the object. What could I be doing wrong?
[/crayon]Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354[crayon-5cba9534a1477963151305 inline="true" ]Namespace MyModel#Import "<std>"#Import "<mojo>"#Import "<mojo3d>"#Import "<mojo3d-loaders>"#Import "assets/"#Import "util"Using std..Using mojo..Using mojo3d..Class MyWindow Extends WindowField _scene:SceneField _camera:CameraField _light:LightField _ground:ModelField _rim:ModelMethod New( title:String="Simple mojo app mymodel test",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )Super.New( title,width,height,flags )_scene=Scene.GetCurrent()_camera=New Camera_camera.Near=.1_camera.Far=100_camera.Move( 0,0,-2.0)_light=New Light_light.Rotate( Pi/2,0,0 ) 'aim directional light 'down' - Pi/2=90 degrees._rim=Model.Load("asset::intro/introrim.dae" )EndMethod OnRender( canvas:Canvas ) Override_rim.Rotate(0,0,.5)RequestRender()_scene.Render( canvas,_camera )canvas.Scale( Width/640.0,Height/480.0 )canvas.DrawText( "Width="+Width+", Height="+Height+", FPS="+App.FPS,0,0 )EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndAttachments:
August 23, 2017 at 10:39 pm #9977I think there is something about the introrim.dae model monkey2 doesn’t like. How was it created?
If you replace it with the BirdieFly ‘bird’ model or a plain sphere via Model.CreateSphere() etc lighting behaves as expected.
Actaully, looking at the model in Open 3D ModelViewer (which also uses assimp), some of the model normals appear to be ‘twisted’, ie: they are not pointing ‘out of’ the model but at odd angles to it, in same cases parallel to it. This will certainly make lighting look crappy.
August 24, 2017 at 12:23 am #9982The introrim.dae was created in Poser by using a torus primitive and scaling it down with a morph target. After I read your response, I created another torus in blender and now the lights behave as expected in Mojo3d. So much for using Poser as a modeller. :>
Thanks for your time.
-
AuthorPosts
You must be logged in to reply to this topic.