Beispiel #1
0
        private void InitScene()
        {
            myOnyxInstance = new Onyx3DInstance();
            myOnyxInstance.Init();

            RebuildShader();

            myCamera = new PerspectiveCamera("MainCamera", 1.5f, (float)renderCanvas.Width / (float)renderCanvas.Height);
            myCamera.Transform.LocalPosition = new Vector3(0, 0.85f, 2);
            myCamera.Transform.LocalRotation = Quaternion.FromAxisAngle(new Vector3(1, 0, 0), -0.45f);

            myObject = new SceneObject("BaseObject");
            //myObject.Transform.LocalRotation = Quaternion.FromEulerAngles(0, 0, -90);

            //mMaterial = myOnyxInstance.Content.BuiltInMaterials.Default; // TODO = Copy this shit instead


            myRenderer          = myObject.AddComponent <MeshRenderer>();
            myRenderer.Mesh     = myOnyxInstance.Resources.GetMesh(BuiltInMesh.Teapot);
            myRenderer.Material = myOnyxInstance.Resources.GetMaterial(BuiltInMaterial.Default);
            myShader            = myRenderer.Material.Shader;


            gridRenderer = new SceneObject("Grid").AddComponent <GridRenderer>();
            gridRenderer.GenerateGridMesh(10, 10, 0.25f, 0.25f);
            gridRenderer.Material = myOnyxInstance.Resources.GetMaterial(BuiltInMaterial.Default);
        }
Beispiel #2
0
        private void InitScene()
        {
            myScene = new Scene();

            myOnyxInstance = Onyx3DEngine.Instance;
            myOnyxInstance.Init();

            SceneObject  teapot     = new SceneObject("Teapot");
            MeshRenderer teapotMesh = teapot.AddComponent <MeshRenderer>();

            teapotMesh.Mesh = myOnyxInstance.Resources.GetMesh(BuiltInMesh.Teapot);
            teapot.Transform.LocalPosition = new Vector3(0, 0.5f, 0);
            teapotMesh.Material            = myOnyxInstance.Resources.GetMaterial(BuiltInMaterial.Default);
            teapot.Parent = myScene.Root;



            SceneObject  teapot2     = new SceneObject("Teapot2");
            MeshRenderer teapot2Mesh = teapot2.AddComponent <MeshRenderer>();

            teapot2Mesh.Mesh                = myOnyxInstance.Resources.GetMesh(BuiltInMesh.Teapot);
            teapot2Mesh.Material            = myOnyxInstance.Resources.GetMaterial(BuiltInMaterial.Default);
            teapot2.Transform.LocalScale    = new Vector3(0.5f, 0.5f, 0.5f);
            teapot2.Transform.LocalPosition = new Vector3(2, 0, 2);
            teapot2.Transform.LocalRotation = Quaternion.FromEulerAngles(new Vector3(0, 90, 0));
            teapot2.Parent = myScene.Root;

            myTeapot = teapot2;

            // Editor objects --------------------------------------

            SceneObject grid = new SceneObject("Grid");

            myGridRenderer = grid.AddComponent <GridRenderer>();
            myGridRenderer.GenerateGridMesh(100, 100, 0.25f, 0.25f);
            myGridRenderer.Material = myOnyxInstance.Resources.GetMaterial(BuiltInMaterial.Unlit);
            myGridRenderer.Material.Properties["color"].Data = new Vector4(1, 1, 1, 0.1f);

            //myBox = teapot.AddComponent<BoxRenderer>();
            //myBox.Material = myOnyxInstance.Resources.GetMaterial(BuiltInMaterial.UnlitVertexColor);

            mNavigation.CreateCamera();

            UpdateTreeView();
        }
Beispiel #3
0
        // --------------------------------------------------------------------

        private void InitializeEditor()
        {
            Onyx3DEngine.InitMain(renderCanvas.Context, renderCanvas.WindowInfo);
            mOnyxInstance = Onyx3DEngine.Instance;

            mNavigation.CreateCamera();

            mObjectHandler = new ObjectHandler(mOnyxInstance, renderCanvas, mNavigation.Camera);
            mObjectHandler.OnTransformModified += OnTransformModifiedFromObjectHandler;

            selectedObjectInspector.InspectorChanged += OnInspectorChanged;

            SceneObject grid = new SceneObject("Grid");

            mGridRenderer = grid.AddComponent <GridRenderer>();
            mGridRenderer.GenerateGridMesh(100, 100, 0.25f, 0.25f, Vector3.One);
            mGridRenderer.Material = mOnyxInstance.Resources.GetMaterial(BuiltInMaterial.Unlit);
            mGridRenderer.Material.Properties["color"].Data = new Vector4(1, 1, 1, 0.1f);
        }
Beispiel #4
0
        // --------------------------------------------------------------------

        public virtual void InitializeBasicScene()
        {
            Scene = new Scene(OnyxInstance);

            Camera = new PerspectiveCamera("MainCamera", 0.5f, (float)mFrameBuffer.Width / (float)mFrameBuffer.Height);
            Camera.Transform.LocalPosition = new Vector3(0, 1.45f, 3f);
            Camera.Transform.LocalRotation = OpenTK.Quaternion.FromAxisAngle(new Vector3(1, 0, 0), -0.45f);

            Scene.ActiveCamera = Camera;

            mCamPivot        = new SceneObject("camPivot");
            mCamPivot.Parent = Scene.Root;
            Camera.Parent    = mCamPivot;

            SceneObject grid = new SceneObject("Grid");

            mGridRenderer = grid.AddComponent <GridRenderer>();
            mGridRenderer.GenerateGridMesh(10, 10, 0.25f, 0.25f, new Vector3(0.8f, 0.8f, 0.8f));
            mGridRenderer.Material = OnyxInstance.Resources.GetMaterial(BuiltInMaterial.UnlitVertexColor);

            SceneObject light  = new SceneObject("Light");
            Light       lightC = light.AddComponent <Light>();

            light.Parent = Scene.Root;
            light.Transform.LocalPosition = new Vector3(1, 2, 1);
            lightC.Intensity = 5;

            SceneObject test = new SceneObject("ReflectionProbe");

            test.Parent = Scene.Root;
            test.Transform.LocalPosition = new Vector3(0, 0, 0);
            mReflectionProbe             = test.AddComponent <ReflectionProbe>();
            mReflectionProbe.Init(64);

            mReflectionProbe.Bake(OnyxInstance.Renderer);
        }