Exemplo n.º 1
0
        private void ReBuildSceneBuffers()
        {
            if (device != null && contentType == ContentTypes.SurfacePlot)
            {
                if (abScene != null)
                {
                    abScene.Dispose();
                }

                abScene = new ABScene3D();

                // Geometry
                abScene.Models = softRender.ToAvalonBridgeModel();
                abScene.Models[1].Geometry.Clr = softRender.PenColor.ToArgb();
                abScene.Models[0].BuildBuffers(device);
                abScene.Models[1].BuildBuffers(device);
                abScene.CalcBounds();

                // Cameras
                abScene.Cameras    = new ABCamera[1];
                abScene.Cameras[0] = new ABCameraSpherical(abScene.BoundingSphere * 2f, abScene.Origin);
                abScene.Cameras[0].Scroll(new Vector3());
                abScene.CurrentCamera = 0;
            }
        }
Exemplo n.º 2
0
        internal bool LoadABSupportedScene(string file)
        {
            // determine file type
            string    ext   = Path.GetExtension(file).ToLower();
            ABScene3D scene = null;

            if (ext == ".3ds")
            {
                SceneLoader3ds loader = new SceneLoader3ds();
                scene = loader.LoadScene(file);
            }
            if (scene != null)
            {
                if (abScene != null)
                {
                    abScene.Dispose();
                }
                abScene = scene;
                abScene.CalcBounds();
                foreach (ABModel3D model in scene.Models)
                {
                    model.BuildBuffers(device);
                }

                // set defaults if none loaded
                if (abScene.Cameras == null)
                {
                    abScene.Cameras    = new ABCamera[1];
                    abScene.Cameras[0] = new ABCameraSpherical(abScene.BoundingSphere * 2f, abScene.Origin);
                    abScene.Cameras[0].Scroll(new Vector3());
                    abScene.CurrentCamera = 0;
                }
                if (abScene.Lights == null)
                {
                    abScene.Lights = new ABLight[] { new ABDirectionalLight(new Vector3(-1, -1, -1), Color.White) };
                }

                return(true);
            }
            return(false);
        }