|
@@ -2,7 +2,7 @@
|
|
Namespace ted2
|
|
Namespace ted2
|
|
|
|
|
|
#Import "<mojo3d>"
|
|
#Import "<mojo3d>"
|
|
-#Import "<mojo3d-assimp>"
|
|
|
|
|
|
+#Import "<mojo3d-loaders>"
|
|
|
|
|
|
Using mojo3d..
|
|
Using mojo3d..
|
|
|
|
|
|
@@ -34,15 +34,15 @@ Class SceneDocumentView Extends View
|
|
RequestRender()
|
|
RequestRender()
|
|
|
|
|
|
If Keyboard.KeyDown( Key.Up )
|
|
If Keyboard.KeyDown( Key.Up )
|
|
- model.RotateX( .1 )
|
|
|
|
|
|
+ model.RotateX( 3 )
|
|
Else If Keyboard.KeyDown( Key.Down )
|
|
Else If Keyboard.KeyDown( Key.Down )
|
|
- model.RotateX( -.1 )
|
|
|
|
|
|
+ model.RotateX( -3 )
|
|
Endif
|
|
Endif
|
|
|
|
|
|
If Keyboard.KeyDown( Key.Left )
|
|
If Keyboard.KeyDown( Key.Left )
|
|
- model.RotateY( .1,True )
|
|
|
|
|
|
+ model.RotateY( 3,True )
|
|
Else If Keyboard.KeyDown( Key.Right )
|
|
Else If Keyboard.KeyDown( Key.Right )
|
|
- model.RotateY( -.1,True )
|
|
|
|
|
|
+ model.RotateY( -3,True )
|
|
Endif
|
|
Endif
|
|
|
|
|
|
If Keyboard.KeyDown( Key.A )
|
|
If Keyboard.KeyDown( Key.A )
|
|
@@ -57,6 +57,20 @@ Class SceneDocumentView Extends View
|
|
Method OnMouseEvent( event:MouseEvent ) Override
|
|
Method OnMouseEvent( event:MouseEvent ) Override
|
|
End
|
|
End
|
|
|
|
|
|
|
|
+ Method OnKeyEvent( event:KeyEvent ) Override
|
|
|
|
+
|
|
|
|
+ If event.Type=EventType.KeyDown
|
|
|
|
+ Select event.Key
|
|
|
|
+ Case Key.R
|
|
|
|
+ _doc.Camera.Position=New Vec3f(0,0,-2.5)
|
|
|
|
+ _doc.Model.Rotation=New Vec3f(0,0,0)
|
|
|
|
+ Case Key.S
|
|
|
|
+ _doc.Light.ShadowsEnabled=Not _doc.Light.ShadowsEnabled
|
|
|
|
+ End
|
|
|
|
+ Endif
|
|
|
|
+
|
|
|
|
+ End
|
|
|
|
+
|
|
Private
|
|
Private
|
|
|
|
|
|
Field _doc:SceneDocument
|
|
Field _doc:SceneDocument
|
|
@@ -81,14 +95,11 @@ Class SceneDocument Extends Ted2Document
|
|
_light=New Light
|
|
_light=New Light
|
|
_light.RotateX( Pi/2 )
|
|
_light.RotateX( Pi/2 )
|
|
|
|
|
|
|
|
+ _model=null
|
|
|
|
+
|
|
Scene.SetCurrent( Null )
|
|
Scene.SetCurrent( Null )
|
|
End
|
|
End
|
|
|
|
|
|
- Property Model:Model()
|
|
|
|
-
|
|
|
|
- Return _model
|
|
|
|
- End
|
|
|
|
-
|
|
|
|
Property Scene:Scene()
|
|
Property Scene:Scene()
|
|
|
|
|
|
Return _scene
|
|
Return _scene
|
|
@@ -99,21 +110,35 @@ Class SceneDocument Extends Ted2Document
|
|
Return _camera
|
|
Return _camera
|
|
End
|
|
End
|
|
|
|
|
|
|
|
+ Property Light:Light()
|
|
|
|
+
|
|
|
|
+ Return _light
|
|
|
|
+ End
|
|
|
|
+
|
|
|
|
+ Property Model:Model()
|
|
|
|
+
|
|
|
|
+ Return _model
|
|
|
|
+ End
|
|
|
|
+
|
|
Protected
|
|
Protected
|
|
|
|
|
|
Method OnLoad:Bool() Override
|
|
Method OnLoad:Bool() Override
|
|
-
|
|
|
|
- Scene.SetCurrent( _scene )
|
|
|
|
|
|
+
|
|
|
|
+ If _model _model.Destroy()
|
|
|
|
|
|
Print "Loading model:"+Path
|
|
Print "Loading model:"+Path
|
|
|
|
|
|
|
|
+ Scene.SetCurrent( _scene )
|
|
|
|
+
|
|
_model=Model.Load( Path )
|
|
_model=Model.Load( Path )
|
|
|
|
+
|
|
|
|
+ Scene.SetCurrent( Null )
|
|
|
|
|
|
If _model
|
|
If _model
|
|
|
|
+
|
|
_model.Mesh.FitVertices( New Boxf( -1,1 ) )
|
|
_model.Mesh.FitVertices( New Boxf( -1,1 ) )
|
|
|
|
+
|
|
Endif
|
|
Endif
|
|
-
|
|
|
|
- Scene.SetCurrent( Null )
|
|
|
|
|
|
|
|
Return True
|
|
Return True
|
|
End
|
|
End
|
|
@@ -125,6 +150,8 @@ Class SceneDocument Extends Ted2Document
|
|
|
|
|
|
Method OnClose() Override
|
|
Method OnClose() Override
|
|
|
|
|
|
|
|
+ _scene.DestroyAllEntities()
|
|
|
|
+
|
|
End
|
|
End
|
|
|
|
|
|
Method OnCreateView:SceneDocumentView() Override
|
|
Method OnCreateView:SceneDocumentView() Override
|
|
@@ -152,7 +179,7 @@ Class SceneDocumentType Extends Ted2DocumentType
|
|
Method New()
|
|
Method New()
|
|
AddPlugin( Self )
|
|
AddPlugin( Self )
|
|
|
|
|
|
- Extensions=New String[]( ".b3d",".3ds",".dae" )
|
|
|
|
|
|
+ Extensions=New String[]( ".b3d",".3ds",".obj",".dae",".fbx",".blend",".x" )
|
|
End
|
|
End
|
|
|
|
|
|
Method OnCreateDocument:Ted2Document( path:String ) Override
|
|
Method OnCreateDocument:Ted2Document( path:String ) Override
|