/// <summary> /// Builds the standard scene. /// </summary> /// <param name="newScene">The scenegraph to be updated.</param> /// <param name="newCamera">The camera to be updated.</param> public static void BuildStandardFloor(SceneManipulator manipulator, string sceneLayer) { SceneLayer bgLayer = manipulator.AddLayer("BACKGROUND"); manipulator.SetLayerOrderID(bgLayer, 0); manipulator.SetLayerOrderID(Scene.DEFAULT_LAYER_NAME, 1); ResourceLink sourceBackgroundTexture = new AssemblyResourceLink( typeof(SeeingSharpSampleResources), "Textures.Background.dds"); ResourceLink sourceTileTexture = new AssemblyResourceLink( typeof(SeeingSharpSampleResources), "Textures.Floor.dds"); var resBackgroundTexture = manipulator.AddTexture(sourceBackgroundTexture); manipulator.Add(new FullscreenTextureObject(resBackgroundTexture), bgLayer.Name); // Define textures and materials var resTileTexture = manipulator.AddResource(() => new StandardTextureResource(sourceTileTexture)); var resTileMaterial = manipulator.AddResource(() => new SimpleColoredMaterialResource(resTileTexture)); // Define floor geometry FloorType floorType = new FloorType(new Vector2(4f, 4f), 0f); floorType.BottomMaterial = resTileMaterial; floorType.DefaultFloorMaterial = resTileMaterial; floorType.SideMaterial = resTileMaterial; floorType.SetTilemap(25, 25); // Add floor to scene var resFloorGeometry = manipulator.AddResource((() => new GeometryResource(floorType))); var floorObject = manipulator.AddGeneric(resFloorGeometry, sceneLayer); }
/// <summary> /// Adds a new simple colored material resource to the scene. /// </summary> /// <param name="sceneManipulator">The manipulator of the scene.</param> /// <param name="textureSourceHighQuality">The source of the texture which should be loaded.</param> /// <param name="textureSourceLowQuality">The source of the texture with low quality.</param> public static NamedOrGenericKey AddSimpleColoredMaterial( this SceneManipulator sceneManipulator, ResourceLink textureSourceHighQuality, ResourceLink textureSourceLowQuality) { NamedOrGenericKey resTexture = sceneManipulator.AddTexture(textureSourceHighQuality, textureSourceLowQuality); return(sceneManipulator.AddResource <SimpleColoredMaterialResource>(() => new SimpleColoredMaterialResource(resTexture))); }
private static void AppendWallObjectToScene(SceneManipulator manipulator, int sideLength) { // Define wall object (define geometry and create object for the scene). var resWallTexture = manipulator.AddTexture( new AssemblyResourceLink( typeof(SeeingSharpSampleResources), "Textures.Wall.png")); var resWallMaterial = manipulator.AddSimpleColoredMaterial(resWallTexture); VertexStructure wallStructure = new VertexStructure(); wallStructure.FirstSurface.EnableTextureTileMode(new Vector2(2f, 2f)); wallStructure.FirstSurface.BuildCube24V( new Vector3(-sideLength * SPACE_X / 2f - 10f, 0f, -sideLength * SPACE_Z / 2f), new Vector3(0.2f, sideLength * SPACE_Y, sideLength * SPACE_Z), Color4.Gray); wallStructure.FirstSurface.Material = resWallMaterial; var resWallGeometry = manipulator.AddGeometry(wallStructure); GenericObject wallObject = manipulator.AddGeneric(resWallGeometry, new Vector3(6.3f, 0f, 0f)); }
/// <summary> /// This method is called after the scene was created. /// Be carefull: This method run's in 3D-Engines update thread. /// </summary> /// <param name="manipulator">The manipulator.</param> private void OnBodyScene_Initialize(SceneManipulator manipulator) { SceneLayer bgLayer = manipulator.AddLayer("BACKGROUND"); manipulator.SetLayerOrderID(bgLayer, 0); manipulator.SetLayerOrderID(Scene.DEFAULT_LAYER_NAME, 1); ResourceLink sourceWallTexture = new Uri( "/SeeingSharp.ModelViewer;component/Resources/Textures/Background.png", UriKind.Relative); var resBackgroundTexture = manipulator.AddTexture(sourceWallTexture); manipulator.Add(new TexturePainter(resBackgroundTexture), bgLayer.Name); FloorType floorType = new FloorType(new Vector2(3f, 3f), 0.1f); floorType.SetTilemap(40, 40); floorType.DefaultFloorMaterial = manipulator.AddSimpleColoredMaterial(new Uri( "/SeeingSharp.ModelViewer;component/Resources/Textures/Floor.png", UriKind.Relative)); var resGeometry = manipulator.AddResource<GeometryResource>(() => new GeometryResource(floorType)); GenericObject floorObject = manipulator.AddGeneric(resGeometry); floorObject.IsPickingTestVisible = false; }