Пример #1
0
        public void ResetCamera(State state)
        {
            Camera.Position = Vector3.ZERO;
            Camera.Orientation = Quaternion.IDENTITY;

            CameraNode = new SimNode(state.SceneManager.RootSceneNode.CreateChildSceneNode());
            CameraChildNode = new SimNode(CameraNode.SceneNode, Camera);
        }
Пример #2
0
 public MainWindow(State state)
     : this()
 {
     State = state;
     SuspendLayout();
     ClientSize = new Size(Screen.PrimaryScreen.Bounds.Right, Screen.PrimaryScreen.Bounds.Bottom);
     ResumeLayout(false);
     WindowState = FormWindowState.Maximized;
 }
Пример #3
0
        private void CreateCore()
        {
            State = new State();
            State.Root = CreateRoot();

            State.MainWindow = new MainWindow(State);
            State.MainWindow.Init();

            State.SceneManager = CreateSceneManager();
        }
Пример #4
0
        public SimCameraManager Init(State state)
        {
            state.CameraManager = this;
            var misc = new NameValuePairList();
            misc["externalWindowHandle"] = state.MainWindow.Handle.ToString();
            RenderWindow = state.Root.CreateRenderWindow("Autumn main RenderWindow", 0, 0, false, misc);

            CreateCamera(state);

            return this;
        }
Пример #5
0
        public void Init(State state)
        {
            this.state = state;
            state.InputManger = this;
            var paramList = new ParamList();
            paramList.Insert("w32_mouse", "DISCL_FOREGROUND");
            paramList.Insert("w32_mouse", "DISCL_NONEXCLUSIVE");
            paramList.Insert("w32_keyboard", "DISCL_FOREGROUND");
            paramList.Insert("w32_keyboard", "DISCL_NONEXCLUSIVE");
            paramList.Insert("WINDOW", state.MainWindow.Handle.ToString());
            InputManager.CreateInputSystem(paramList);
            inputManager = InputManager.CreateInputSystem(paramList);
            //inputManager = InputManager.CreateInputSystem((uint)state.MainWindow.Handle.ToInt32());

            CreateInputDevices();
        }
Пример #6
0
        public PhysicsNode(SimNode simNode, State State)
            : base(simNode.SceneNode)
        {
            SceneNode = simNode.SceneNode;
            SceneNode child = SceneNode;
            while (child.NumChildren() > 0) child = child.GetChild(0) as SceneNode;

            var hull = new MogreNewt.CollisionPrimitives.ConvexHull(State.PhysicsWorld.World, child, child.Orientation, 0.002f, SceneNode.Name.GetHashCode());
            Body = new Body(State.PhysicsWorld.World, hull);
            Body.AttachNode(SceneNode);
            Body.IsGravityEnabled = true;

            Body.SetPositionOrientation(SceneNode._getDerivedPosition(), SceneNode.Orientation); // REALPosition Orient
            Body.ForceCallback += State.PhysicsWorld.ForceCallback;
            //            Body.AngularDamping = new Vector3(1,1,1);
            //            Body.LinearDamping = 1;
            Body.UserData = new PhysicsControlData();
            hull.Dispose();
        }
Пример #7
0
        public void SerlializationTest()
        {
            var xmlSerializer = new XmlSerializer(typeof(WorldXml));
            var builder = new StringBuilder();
            var writer = new StringWriter(builder);
            var state = new State();

            var world = new World(state);
            world.Water = new Water(state);
            world.Water.Position = new Vector3(0,1,2);
            world.Water.Orientation = new Quaternion(1, 2, 3, 4);

            world.Sub = new Sub(state);

            world.WorldObjects = new WorldObjects(state);
            world.WorldObjects.Add(new WorldObject(state, "worldObject1"));
            world.WorldObjects.Add(new WorldObject(state, "worldObject2"));

            xmlSerializer.Serialize(writer,new WorldXml(world));
            Console.WriteLine(builder.ToString());
        }
Пример #8
0
        public void Init(State State)
        {
            this.State = State;
            State.PhysicsWorld = this;
            World = new MogreNewt.World();
            World.SetPlatformArchitecture(MogreNewt.World.PlatformArchitecture.PA_BEST_HARDWARE);
            World.SetWorldSize(new Vector3(-500, -500, -500), new Vector3(500, 500, 500));
            World.SetSolverModel(MogreNewt.World.SolverModelMode.SM_2_PASS);
            World.DebuggerInstance.Init(State.SceneManager);

            // using the new "SceneParser" TreeCollision primitive.  this will automatically parse an entire tree of
            // SceneNodes (parsing all children), and add collision for all meshes in the tree.
            var statCol = new MogreNewt.CollisionPrimitives.TreeCollisionSceneParser(World);
            statCol.ParseScene(State.SceneManager.RootSceneNode, true, 0); // was floornode
            var sceneBody = new Body(World, statCol);
            statCol.Dispose();

            sceneBody.AttachNode(State.SceneManager.RootSceneNode); // was floornode
            sceneBody.SetPositionOrientation(new Vector3(0.0f, 0.0f, 0.0f), Quaternion.IDENTITY);

            var ent = State.SceneManager.CreateEntity("cylinder_body", "mocksub.mesh");
            var simNode = new SimNode(State.SceneManager.RootSceneNode, ent);

            // rigid body.
            var phyNode = new PhysicsNode(simNode, State);

            phyNode.Body.SetPositionOrientation(new Vector3(0, 10, 0), Quaternion.IDENTITY);
            phyNode.Body.SetMassMatrix(125, Vector3.ZERO);

            var physicsNode = new PhysicsNode(State.SubNode, State);
            physicsNode.Body.SetMassMatrix(125, Vector3.ZERO);
            // TODO: FIX THIS State.SubNode = physicsNode;

            // initial position
            State.Root.FrameStarted += NewtonUpdate;
        }
Пример #9
0
        private void CreateCamera(State state)
        {
            Camera = state.SceneManager.CreateCamera("MainCamera");
            Camera.NearClipDistance = 0.1F;

            Viewport = RenderWindow.AddViewport(Camera, 0);

            Camera.AspectRatio = (float)Viewport.ActualWidth / Viewport.ActualHeight;
            //Viewport.SetDimensions(window.Left, window.Top, window.Width, window.Height);

            Camera2 = state.SceneManager.CreateCamera("MainCamera2");
            Camera2.NearClipDistance = 0.1F;
            //Camera2.Yaw(Math.HALF_PI);

            ResetCamera(state);
        }