示例#1
0
        protected override void LoadContent()
        {
            ModelLoaderParameters mlp = new ModelLoaderParameters();

            mlp.SwapWindingOrder = true;
            mlp.NormalGeneration = NormalGeneration.Face;

            mlp.PreferLitMaterials   = true;
            mlp.GenerateTangentBasis = false;
            ship = ContentManager.Load <Spatial>("Models\\station.dxs", mlp);

            ship.AddController(new Tesla.Scene.Extension.RotateController(new Vector3(0, 1, 0), 5));
            ship.SetRenderState(SamplerState.AnisotropicWrap);
            engineMat = ContentManager.Load <Material>("BasicTexture.tem");

            Material mat = new Material();

            mat.LoadEffect(ContentManager.Load <Effect>("Shaders//TextureGlowEffect.fx"));
            mat.SetActiveTechnique("TextureGlow");
            mat.SetParameter("DiffuseMap", ContentManager.Load <Texture2D>("Textures//station_diff.dds"));
            mat.SetParameter("EmissiveMap", ContentManager.Load <Texture2D>("Textures//station_glow.dds"));
            mat.SetParameter("MatEmissive", new Vector3(.5f, .5f, .5f));
            mat.SetEngineParameter("WVP", Tesla.Core.EngineValue.WorldViewProjection);
            mat.SetEngineParameter("World", Tesla.Core.EngineValue.WorldMatrix);
            mat.SetEngineParameter("WorldIT", Tesla.Core.EngineValue.WorldInverseTranspose);
            mat.SetEngineParameter("EyePos", Tesla.Core.EngineValue.CameraPosition);

            ship.SetMaterial(mat);

            engineMat.SetParameter("DiffuseMap", ContentManager.Load <Texture2D>("Textures//station_glow.dds"));

            width  = Renderer.CurrentCamera.Viewport.Width;
            height = Renderer.CurrentCamera.Viewport.Height;

            bool test = Renderer.Adapter.QueryRenderTargetFormat(SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 4);

            sceneRT    = new RenderTarget2D(width, height, false, Window.SwapChain.PresentationParameters.BackBufferFormat, Window.SwapChain.PresentationParameters.DepthStencilFormat, Window.SwapChain.PresentationParameters.MultiSampleCount, RenderTargetUsage.DiscardContents);
            rt1        = new RenderTarget2D(width, height, true, sceneRT.Format, DepthFormat.None);
            rt2        = new RenderTarget2D(width, height, true, sceneRT.Format, DepthFormat.None);
            rt3        = new RenderTarget2D(width, height, true, sceneRT.Format, DepthFormat.None);
            blurEffect = ContentManager.Load <Effect>("Shaders//GaussianBlur.fx");
            batch      = new SpriteBatch();

            RootNode.AddChild(ship);
            sky = new Box("Space", Vector3.Zero, 100, 100, 100);
            sky.SceneHints.RenderBucketType = RenderBucketType.Skip;
            sky.Material = ContentManager.Load <Material>("Materials//SpaceSkybox.tem");

            RootNode.SetModelBound(new Tesla.Bounding.BoundingBox());
        }
示例#2
0
        protected override void LoadContent()
        {
            Window.Title = "DXS Model Loading Sample";
            Renderer.CurrentCamera.Position = new Vector3(-70, 90, 120);
            Renderer.CurrentCamera.LookAt(new Vector3(0, 0, 0), Vector3.Up);
            Renderer.CurrentCamera.Update();

            //When calling ContentManager.Load<T>(), an optional loader parameter can be passed that tells the content importer
            //how to process the content. Model loaders take ModelLoaderParameters and image loaders take ImageLoaderParameters. They
            //can be re-used.
            //
            //In this case, we have to tell the model loader that we want to swap the winding order of polygons so we do not get
            //incorrect rendering. Other options include the angle at which to rotate the model about the XYZ axes, how normals should
            //be generated (if any), if a tangent basis should be generated, where to find textures, or overload material creation by
            //supplying a material to load and use as a template.
            ModelLoaderParameters mlp = new ModelLoaderParameters();

            mlp.SwapWindingOrder   = true;
            mlp.PreferLitMaterials = false;

            //In BasicApp, we registered a DXSModelLoader to the content manager, if we didn't this will throw
            //an exception that we do not have a means to handle the requested content. Loaders are designated by
            //both the runtime type and the content file extension.
            //
            //Notice with loading this model, we use Spatial rather than Mesh, because a model may be in fact a
            //scene graph with multiple parts. We can either have a Node or Mesh returned. In this case,
            //we should have a mesh returned since the model is a single mesh in the file. If the model
            //used two different materials, it would have to be split up into two different meshes
            //and then attached to a Node that would be returned, for example.
            Spatial model = ContentManager.Load <Spatial>("Models//station.dxs", mlp);

            model.AddController(new RotateController(Vector3.Up, 5));
            model.SetModelBound(new BoundingBox());
            RootNode.AddChild(model);

            Box sky = new Box("Space", Vector3.Zero, 100, 100, 100);

            sky.SceneHints.RenderBucketType = RenderBucketType.PreBucket;
            sky.Material = ContentManager.Load <Material>("Materials//SpaceSkybox.tem");

            RootNode.AddChild(sky);
        }