public WeightedBlendedOITSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            SampleFramework.IsMouseVisible = false;

            // Weighted blended OIT is implemented in custom graphics screen.
            // (Only mesh nodes are supported.)
            _graphicsScreen = new WeightedBlendedOITScreen(Services);
            GraphicsService.Screens.Insert(0, _graphicsScreen);

            // Create the standard camera object.
            var cameraGameObject = new CameraObject(Services, 500);

            GameObjectService.Objects.Add(cameraGameObject);
            _graphicsScreen.ActiveCameraNode = cameraGameObject.CameraNode;

            // Add some lights.
            SceneSample.InitializeDefaultXnaLights(_graphicsScreen.Scene);

            // The tank model used in this example has special materials.
            // See
            // - Samples\Content\WeightedBlendedOIT\engine_diff_tex.drmat
            // - Samples\Content\WeightedBlendedOIT\turret_alt_diff_tex.drmat
            //
            // These materials support the following render passes:
            // - "Default"
            // - "AlphaBlend" same as "Default" except that the Alpha value is lowered.
            // - "ZOnly" renders only the depth into the depth buffer.
            // - "WeightedBlendedOIT" renders the transparent model into the WBOIT render targets.
            // These render passes are used in the WeightedBlendedOITScreen.

            // Load two instances of the "Tank" model:
            // The first instance is rendered opaque (for reference).
            var model = ContentManager.Load <ModelNode>("WeightedBlendedOIT/tank").Clone();

            model.PoseWorld = new Pose(new Vector3F(-4, 0, 0));
            _graphicsScreen.Scene.Children.Add(model);

            // The second instance is rendered transparent.
            model           = ContentManager.Load <ModelNode>("WeightedBlendedOIT/tank").Clone();
            model.PoseWorld = new Pose(new Vector3F(4, 0, 0));
            // Set flag to indicate that this instance should be rendered transparent.
            model.GetSubtree().ForEach(node => node.UserFlags = (short)WboitFlags.Transparent);
            _graphicsScreen.Scene.Children.Add(model);
        }
Exemple #2
0
    public WeightedBlendedOITSample(Microsoft.Xna.Framework.Game game)
      : base(game)
    {
      SampleFramework.IsMouseVisible = false;

      // Weighted blended OIT is implemented in custom graphics screen.
      // (Only mesh nodes are supported.)
      _graphicsScreen = new WeightedBlendedOITScreen(Services);
      GraphicsService.Screens.Insert(0, _graphicsScreen);

      // Create the standard camera object.
      var cameraGameObject = new CameraObject(Services, 500);
      GameObjectService.Objects.Add(cameraGameObject);
      _graphicsScreen.ActiveCameraNode = cameraGameObject.CameraNode;

      // Add some lights.
      SceneSample.InitializeDefaultXnaLights(_graphicsScreen.Scene);

      // The tank model used in this example has special materials.
      // See
      // - Samples\Content\WeightedBlendedOIT\engine_diff_tex.drmat
      // - Samples\Content\WeightedBlendedOIT\turret_alt_diff_tex.drmat
      //
      // These materials support the following render passes:
      // - "Default"
      // - "AlphaBlend" same as "Default" except that the Alpha value is lowered.
      // - "ZOnly" renders only the depth into the depth buffer.
      // - "WeightedBlendedOIT" renders the transparent model into the WBOIT render targets.
      // These render passes are used in the WeightedBlendedOITScreen.

      // Load two instances of the "Tank" model:
      // The first instance is rendered opaque (for reference).
      var model = ContentManager.Load<ModelNode>("WeightedBlendedOIT/tank").Clone();
      model.PoseWorld = new Pose(new Vector3F(-4, 0, 0));
      _graphicsScreen.Scene.Children.Add(model);

      // The second instance is rendered transparent.
      model = ContentManager.Load<ModelNode>("WeightedBlendedOIT/tank").Clone();
      model.PoseWorld = new Pose(new Vector3F(4, 0, 0));
      // Set flag to indicate that this instance should be rendered transparent.
      model.GetSubtree().ForEach(node => node.UserFlags = (short)WboitFlags.Transparent);
      _graphicsScreen.Scene.Children.Add(model);
    }