本文整理汇总了C#中Scene.GetSceneNode方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.GetSceneNode方法的具体用法?C# Scene.GetSceneNode怎么用?C# Scene.GetSceneNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scene
的用法示例。
在下文中一共展示了Scene.GetSceneNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProjectedShadowSample
public ProjectedShadowSample(Microsoft.Xna.Framework.Game game)
: base(game)
{
SampleFramework.IsMouseVisible = false;
var delegateGraphicsScreen = new DelegateGraphicsScreen(GraphicsService)
{
RenderCallback = Render,
};
GraphicsService.Screens.Insert(0, delegateGraphicsScreen);
// Create a new empty scene.
_scene = new Scene();
Services.Register(typeof(IScene), null, _scene);
// Add a custom game object which controls the camera.
_cameraObject = new CameraObject(Services);
_cameraObject.ResetPose(new Vector3F(-8, 6, 8), -ConstantsF.PiOver4, -0.4f);
GameObjectService.Objects.Add(_cameraObject);
// Add a default light setup (ambient light + 3 directional lights).
var defaultLightsObject = new DefaultLightsObject(Services);
GameObjectService.Objects.Add(defaultLightsObject);
// Get the main directional light.
_mainDirectionalLightNode = ((LightNode)_scene.GetSceneNode("KeyLight"));
// Add a ground plane model to the scene graph.
var grid = ContentManager.Load<ModelNode>("Ground/Ground").Clone();
grid.ScaleLocal = new Vector3F(0.3f);
_scene.Children.Add(grid);
// Add a tank model to the scene graph.
var tank = ContentManager.Load<ModelNode>("Tank/tank").Clone();
_scene.Children.Add(tank);
// Remember the mesh nodes of tank node.
_tankMeshNodes = tank.GetSubtree().Where(n => n is MeshNode).ToArray();
// Create the renderers.
_meshRenderer = new MeshRenderer();
var spriteFont = UIContentManager.Load<SpriteFont>("UI Themes/BlendBlue/Default");
_debugRenderer = new DebugRenderer(GraphicsService, spriteFont);
_projectedShadowRenderer = new ProjectedShadowRenderer(GraphicsService)
{
// The plane onto which the shadows are projected. It is positioned a bit above the ground
// plane to avoid z-fighting.
ShadowedPlane = new Plane(new Vector3F(0, 1, 0), 0.01f),
// The shadow color is a transparent black.
ShadowColor = new Vector4F(0, 0, 0, 0.4f),
// The light position is set in Update().
//LightPosition = ...
};
}
示例2: ProjectedShadowSample2
public ProjectedShadowSample2(Microsoft.Xna.Framework.Game game)
: base(game)
{
SampleFramework.IsMouseVisible = false;
var delegateGraphicsScreen = new DelegateGraphicsScreen(GraphicsService)
{
RenderCallback = Render,
};
GraphicsService.Screens.Insert(0, delegateGraphicsScreen);
// The dude model uses a new ProjectedShadowSkinned.fx effect. This effect contains new
// parameters 'ShadowMatrix' and 'ShadowColor' which are not yet supported. When an mesh is
// loaded via the content manager, effect bindings are automatically created. This is done
// by effect interpreters and effect binders. The graphics service uses several predefined
// effect interpreter and binder classes to support the most common effect parameters. E.g.
// the SceneEffectInterpreter and SceneEffectBinder handle parameters like 'World', 'View',
// 'ViewProjection', 'CameraPosition', 'FogColor', etc. (see also class
// SceneEffectParameterSemantics).
// We can add new effect interpreters/binders or we can add an entry to an existing
// interpreter/binder. Let's add entries to the standard SceneEffectInterpreter which creates
// meta-data for the new parameters:
var sceneEffectInterpreter = GraphicsService.EffectInterpreters.OfType<SceneEffectInterpreter>().First();
sceneEffectInterpreter.ParameterDescriptions.Add(
"ShadowMatrix",
(parameter, index) => new EffectParameterDescription(parameter, "ShadowMatrix", index, EffectParameterHint.Global));
sceneEffectInterpreter.ParameterDescriptions.Add(
"ShadowColor",
(parameter, index) => new EffectParameterDescription(parameter, "ShadowColor", index, EffectParameterHint.Global));
// Add entries to the standard SceneEffectBinder which create DelegateParameterBindings for
// the new parameters. The delegate bindings use callback methods to compute the parameter
// value.
var sceneEffectBinder = GraphicsService.EffectBinders.OfType<SceneEffectBinder>().First();
sceneEffectBinder.MatrixBindings.Add(
"ShadowMatrix",
(effect, parameter, data) => new DelegateParameterBinding<Matrix>(effect, parameter, GetShadowMatrix));
sceneEffectBinder.Vector4Bindings.Add(
"ShadowColor",
(effect, parameter, data) => new DelegateParameterBinding<Vector4>(effect, parameter, GetShadowColor));
// Create a new empty scene.
_scene = new Scene();
Services.Register(typeof(IScene), null, _scene);
// Add a custom game object which controls the camera.
_cameraObject = new CameraObject(Services);
_cameraObject.ResetPose(new Vector3F(-2, 2, 2), -ConstantsF.PiOver4, -0.4f);
GameObjectService.Objects.Add(_cameraObject);
// Add a default light setup (ambient light + 3 directional lights).
var defaultLightsObject = new DefaultLightsObject(Services);
GameObjectService.Objects.Add(defaultLightsObject);
// Get the main directional light.
_mainDirectionalLightNode = ((LightNode)_scene.GetSceneNode("KeyLight"));
// Add a ground plane model to the scene graph.
var grid = ContentManager.Load<ModelNode>("Ground/Ground").Clone();
grid.ScaleLocal = new Vector3F(0.3f);
_scene.Children.Add(grid);
// Add a dude model to the scene graph.
var dude = ContentManager.Load<ModelNode>("DudeWithProjectedShadow/Dude").Clone();
dude.PoseWorld = new Pose(Matrix33F.CreateRotationY(ConstantsF.Pi));
SampleHelper.EnablePerPixelLighting(dude);
_scene.Children.Add(dude);
// Start walk animation.
StartDudeAnimation(dude);
// Create the renderers.
_meshRenderer = new MeshRenderer();
_shadowColor = new Vector4(0, 0, 0, 0.4f);
}