Browse Source

Moved ABOUT.HTML to root dir + added WIP scenedocument.

Mark Sibly 8 years ago
parent
commit
4a1171739c
5 changed files with 178 additions and 12 deletions
  1. 7 5
      ABOUT.HTML
  2. 1 1
      src/ted2/helpactions.monkey2
  3. 1 6
      src/ted2/mainwindow.monkey2
  4. 167 0
      src/ted2/scenedocument.monkey2
  5. 2 0
      src/ted2/ted2.monkey2

+ 7 - 5
src/ted2/assets/about.html → ABOUT.HTML

@@ -4,7 +4,7 @@
 <style>
 
 body{
-	background: transparent;
+	background: #333;
 	color: #eee;
 	font-size: 16px;
 	margin: 8px;
@@ -44,13 +44,15 @@ a:hover{
 
 <body>
 
-<h1>Monkey2 v1.1.04</h1>
+<h1>Monkey2 v1.1.05</h1>
 
-<p>Welcome to monkey2, a new, open source, user friendly, multi target programming language by Mark Sibly.
+<p>Welcome to monkey2, an open source, user friendly, multi target programming language by Mark Sibly.
 
-<p>Please post any bug reports or feature requests to the monkey2 github repository: <a href="https://github.com/blitz-research/monkey2">https://github.com/blitz-research/monkey2</a>.
+<p>Example programs can be found in the bananas directory.
+
+<p>For monkey2 discussion and programming help, feel free to drop by the monkey2 forums: <a href="http://monkeycoder.co.nz/forums">http://monkeycoder.co.nz/forums</a>.
 
-<p>For monkey2 discussion and programming help, feel free to drop by the monkey2 forums: <a href="http://monkey2.monkey-x.com/forums">http://monkey2.monkey-x.com/forums</a>.
+<p>Please post any bug reports or feature requests to the monkey2 github repository: <a href="https://github.com/blitz-research/monkey2">https://github.com/blitz-research/monkey2</a>.
 
 <p>Monkey2 is a crowd funded project. If you like what you see, please consider contributing to development either via paypal donation or by becoming a Patreon supporter.
 

+ 1 - 1
src/ted2/helpactions.monkey2

@@ -34,7 +34,7 @@ Class HelpActions
 		about.Triggered=Lambda()
 		
 			Local htmlView:=New HtmlView
-			htmlView.Go( "asset::ted2/about.html" )
+			htmlView.Go( "ABOUT.HTML" )
 	
 			Local dialog:=New Dialog( "About monkey2" )
 			dialog.ContentView=htmlView

+ 1 - 6
src/ted2/mainwindow.monkey2

@@ -1,8 +1,6 @@
 
 Namespace ted2
 
-#Import "assets/about.html@/ted2"
-
 #Import "assets/themes/@/themes"
 
 #Import "assets/newfiles/@/ted2/newfiles"
@@ -58,10 +56,7 @@ Class MainWindowInstance Extends Window
 		_buildConsole=New Console
 		_outputConsole=New Console
 		_helpView=New HtmlView
-'		_helpView.Style=New Style( _helpView.Style )
-'		_helpView.Style.Border=New Recti( 0,-4,0,0 )
-'		_helpView.Style.BorderColor=App.Theme.GetColor( "content" )
-		_helpView.Go( "asset::ted2/about.html" )
+		_helpView.Go( "ABOUT.HTML" )
 		
 		_projectView=New ProjectView( _docsManager )
 		

+ 167 - 0
src/ted2/scenedocument.monkey2

@@ -0,0 +1,167 @@
+
+Namespace ted2
+
+#Import "<mojo3d>"
+#Import "<mojo3d-assimp>"
+
+Using mojo3d..
+
+Class SceneDocumentView Extends View
+
+	Method New( doc:SceneDocument )
+		_doc=doc
+		
+		Layout="fill"
+	End
+	
+	Protected
+	
+	Method OnRender( canvas:Canvas ) Override
+	
+		For Local x:=0 Until Width Step 64
+			For Local y:=0 Until Height Step 64
+				canvas.Color=(x~y) & 64 ? New Color( .1,.1,.1 ) Else New Color( .05,.05,.05 )
+				canvas.DrawRect( x,y,64,64 )
+			Next
+		Next
+		
+		Local model:=_doc.Model
+		If Not model
+			canvas.Clear( Color.Sky )
+			Return
+		Endif
+		
+		RequestRender()
+		
+		If Keyboard.KeyDown( Key.Up )
+			model.RotateX( .1 )
+		Else If Keyboard.KeyDown( Key.Down )
+			model.RotateX( -.1 )
+		Endif
+		
+		If Keyboard.KeyDown( Key.Left )
+			model.RotateY( .1,True )
+		Else If Keyboard.KeyDown( Key.Right )
+			model.RotateY( -.1,True )
+		Endif
+
+		If Keyboard.KeyDown( Key.A )
+			_doc.Camera.MoveZ( .1 )
+		Else If Keyboard.KeyDown( Key.Z )
+			_doc.Camera.MoveZ( -.1 )
+		Endif
+		
+		_doc.Scene.Render( canvas,_doc.Camera )
+	End
+	
+	Method OnMouseEvent( event:MouseEvent ) Override
+	End
+	
+	Private
+
+	Field _doc:SceneDocument
+End
+
+Class SceneDocument Extends Ted2Document
+	
+	Method New( path:String )
+		Super.New( path )
+		
+		_view=New SceneDocumentView( Self )
+		
+		_scene=New Scene
+		
+		Scene.SetCurrent( _scene )
+		
+		_camera=New Camera
+		_camera.Near=.1
+		_camera.Far=100
+		_camera.MoveZ( -2.5 )
+			
+		_light=New Light
+		_light.RotateX( Pi/2 )
+		
+		Scene.SetCurrent( Null )
+	End
+	
+	Property Model:Model()
+	
+		Return _model
+	End
+	
+	Property Scene:Scene()
+		
+		Return _scene
+	End
+	
+	Property Camera:Camera()
+		
+		Return _camera
+	End
+	
+	Protected
+	
+	Method OnLoad:Bool() Override
+
+		Scene.SetCurrent( _scene )
+		
+		Print "Loading model:"+Path
+
+		_model=Model.Load( Path )
+
+		If _model
+			_model.Mesh.FitVertices( New Boxf( -1,1 ) )
+		Endif
+		
+		Scene.SetCurrent( Null )
+	
+		Return True
+	End
+	
+	Method OnSave:Bool() Override
+
+		Return False
+	End
+	
+	Method OnClose() Override
+		
+	End
+	
+	Method OnCreateView:SceneDocumentView() Override
+	
+		Return _view
+	End
+	
+	Private
+	
+	Field _view:SceneDocumentView
+	
+	Field _scene:Scene
+	
+	Field _camera:Camera
+	
+	Field _light:Light
+	
+	Field _model:Model
+End
+
+Class SceneDocumentType Extends Ted2DocumentType
+
+	Protected
+	
+	Method New()
+		AddPlugin( Self )
+		
+		Extensions=New String[]( ".b3d",".3ds",".dae" )
+	End
+	
+	Method OnCreateDocument:Ted2Document( path:String ) Override
+		
+		Return New SceneDocument( path )
+	End
+	
+	Private
+	
+	Global _instance:=New SceneDocumentType
+	
+End

+ 2 - 0
src/ted2/ted2.monkey2

@@ -35,6 +35,8 @@
 #import "jsondocument"
 #import "xmldocument"
 
+'#Import "scenedocument"
+
 #import "textviewkeyeventfilter"
 
 #Import "buildproduct"