-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
341 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
import away3d.primitives.CubeGeometry; | ||
import oimo.dynamics.rigidbody.RigidBodyType; | ||
import away3d.containers.View3D; | ||
import away3d.entities.Mesh; | ||
import away3d.materials.ColorMaterial; | ||
import away3d.materials.lightpickers.StaticLightPicker; | ||
import openfl.geom.Vector3D; | ||
|
||
class Level{ | ||
class Level { | ||
var view:View3D; | ||
var meshlist:Array<Mesh>; | ||
var ambientlight:Int; | ||
var lightpicker:StaticLightPicker; | ||
public function new(_view:View3D, _ambientlight:Int, _lightpicker:StaticLightPicker){ | ||
|
||
public function new(_view:View3D, _ambientlight:Int, _lightpicker:StaticLightPicker) { | ||
view = _view; | ||
ambientlight = _ambientlight; | ||
lightpicker = _lightpicker; | ||
meshlist = []; | ||
} | ||
public function add(meshname:String, pos:Vector3D, angle:Float = 0.0, sx:Float = 1.0, sy:Float = 1.0, sz:Float = 1.0):Mesh{ | ||
|
||
public function add(meshname:String, pos:Vector3D, angle:Float = 0.0, sx:Float = 1.0, sy:Float = 1.0, sz:Float = 1.0):Mesh { | ||
var newmesh:Mesh = MeshLibrary.getmesh(meshname).clone(); | ||
|
||
newmesh.material = new ColorMaterial(ambientlight); | ||
newmesh.material.lightPicker = lightpicker; | ||
|
||
newmesh.position = pos; | ||
newmesh.rotationX = 0; | ||
newmesh.rotationY = (180 + angle) % 360; //Matches Unity coordinates | ||
newmesh.rotationY = (180 + angle) % 360; // Matches Unity coordinates | ||
newmesh.rotationZ = 0; | ||
newmesh.scaleX = sx; | ||
newmesh.scaleY = sy; | ||
newmesh.scaleZ = sz; | ||
|
||
meshlist.push(newmesh); | ||
view.scene.addChild(newmesh); | ||
|
||
return newmesh; | ||
} | ||
|
||
public function cleanup(){ | ||
|
||
} | ||
} | ||
|
||
public function cleanup() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,90 @@ | ||
import away3d.containers.*; | ||
import away3d.entities.*; | ||
import away3d.materials.*; | ||
import away3d.primitives.*; | ||
import away3d.utils.*; | ||
import away3d.core.managers.Stage3DManager; | ||
import away3d.core.managers.Stage3DProxy; | ||
import away3d.events.Stage3DEvent; | ||
import away3d.debug.AwayStats; | ||
|
||
import away3d.events.Stage3DEvent; | ||
import oimo.common.Vec3; | ||
import oimo.dynamics.World; | ||
import openfl.display.*; | ||
import openfl.events.*; | ||
import openfl.geom.Vector3D; | ||
|
||
import starling.core.*; | ||
|
||
class Main extends Sprite { | ||
//engine variables | ||
// engine variables | ||
private var stage3DManager:Stage3DManager; | ||
private var stage3DProxy:Stage3DProxy; | ||
private var away3dview:View3D; | ||
|
||
private var starlinglayer:Starling; | ||
//scene objects | ||
|
||
// scene objects | ||
private var gamestate:GameState; | ||
|
||
public function new(){ | ||
|
||
private var oimo_world:World; | ||
|
||
public function new() { | ||
super(); | ||
|
||
stage.scaleMode = StageScaleMode.NO_SCALE; | ||
stage.align = StageAlign.TOP_LEFT; | ||
|
||
|
||
oimo_world = new World(new Vec3(0, -9.80665, 0)); | ||
|
||
// first step, must do before anything else !!! | ||
OimoUtils.setWorld(oimo_world); | ||
|
||
initProxies(); | ||
} | ||
|
||
private function initProxies() { | ||
// Define a new Stage3DManager for the Stage3D objects | ||
stage3DManager = Stage3DManager.getInstance(stage); | ||
|
||
// Create a new Stage3D proxy to contain the separate views | ||
stage3DProxy = stage3DManager.getFreeStage3DProxy(); | ||
stage3DProxy.addEventListener(Stage3DEvent.CONTEXT3D_CREATED, onContextCreated); | ||
} | ||
|
||
private function onContextCreated(event:Stage3DEvent) { | ||
// Create the first Away3D view | ||
away3dview = new View3D(); | ||
away3dview.stage3DProxy = stage3DProxy; | ||
away3dview.shareContext = true; | ||
//setup the camera | ||
|
||
// setup the camera | ||
away3dview.camera.z = -60; | ||
away3dview.camera.y = 20; | ||
away3dview.camera.lookAt(new Vector3D()); | ||
|
||
MeshLibrary.load( | ||
["island1", "island2", "island3", "island4", "island5", | ||
"big1", "big2", "radio", "small1", "small2", "small3"], | ||
onloadcomplete); | ||
|
||
|
||
MeshLibrary.load([ | ||
"island1", "island2", "island3", "island4", "island5", "big1", "big2", "radio", "small1", "small2", "small3" | ||
], onloadcomplete); | ||
|
||
addChild(away3dview); | ||
addChild(new AwayStats(away3dview)); | ||
//initStarling(); | ||
|
||
initStarling(); | ||
} | ||
private function onloadcomplete(){ | ||
|
||
private function onloadcomplete() { | ||
gamestate = new GameState(away3dview, stage); | ||
//setup the render loop | ||
stage.addEventListener(Event.ENTER_FRAME, _onEnterFrame); | ||
|
||
// setup the render loop | ||
stage3DProxy.addEventListener(Event.ENTER_FRAME, _onEnterFrame); | ||
} | ||
private function initStarling(){ | ||
|
||
private function initStarling() { | ||
starlinglayer = new Starling(StarlingLayer, stage, stage3DProxy.viewPort, stage3DProxy.stage3D); | ||
starlinglayer.shareContext = true; | ||
} | ||
|
||
private function _onEnterFrame(e:Event) { | ||
stage3DProxy.clear(); | ||
OimoUtils.updatePhysics(); | ||
|
||
gamestate.update(); | ||
away3dview.render(); | ||
//starlinglayer.nextFrame(); | ||
|
||
stage3DProxy.present(); | ||
StarlingLayer.getInstance().update(); | ||
starlinglayer.nextFrame(); | ||
} | ||
} | ||
} |
Oops, something went wrong.