예제 #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);
        }
예제 #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();
        }