Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        protected override PerSceneContext Attach(SceneManipulator manipulator, ViewInformation correspondingView)
        {
            PerSceneContext context = new PerSceneContext();

            NamedOrGenericKey resCubeGeometry = manipulator.AddGeometry(new CubeType());

            context.CubeObject       = manipulator.AddGeneric(resCubeGeometry);
            context.CubeObject.Color = Color4.RedColor;

            return(context);
        }
Ejemplo n.º 3
0
        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));
        }
        private static void AppendPalletObjectsToScene(SceneManipulator manipulator)
        {
            Util.NamedOrGenericKey resPalletGeometry;
            Util.NamedOrGenericKey resPalletGeometryRed;
            Util.NamedOrGenericKey resPalletGeometryGreen;

            // Define pallet geometry
            PalletType palletType      = new PalletType();
            PalletType palletTypeRed   = new PalletType();
            PalletType palletTypeGreen = new PalletType();

            palletTypeRed.ContentColor   = Color4.DarkRed;
            palletTypeGreen.ContentColor = Color4.DarkOliveGreen;

            // Append pallet geometry to scene
            resPalletGeometry      = manipulator.AddGeometry(palletType);
            resPalletGeometryRed   = manipulator.AddGeometry(palletTypeRed);
            resPalletGeometryGreen = manipulator.AddGeometry(palletTypeGreen);

            //Append objects to the scene
            Vector3 relocVector = new Vector3(0.5f, 0f, 0);
            List <GenericObject> standardPallets    = new List <GenericObject>();
            List <GenericObject> transparentPallets = new List <GenericObject>();

            for (int loopX = 0; loopX < 20; loopX++)
            {
                float xPos = loopX * 1.2f;
                if (loopX >= 5)
                {
                    xPos += 1f;
                }

                //White pallets
                standardPallets.Add(manipulator.AddGeneric(resPalletGeometry, relocVector + new Vector3(xPos, 0f, 0f)));
                transparentPallets.Add(manipulator.AddGeneric(resPalletGeometry, relocVector + new Vector3(xPos, 0f, 1.5f)));
                transparentPallets.Add(manipulator.AddGeneric(resPalletGeometry, relocVector + new Vector3(xPos, 0f, -1.5f)));

                //Red pallets
                transparentPallets.Add(manipulator.AddGeneric(resPalletGeometryRed, relocVector + new Vector3(xPos, 0f, 5.0f)));
                standardPallets.Add(manipulator.AddGeneric(resPalletGeometryRed, relocVector + new Vector3(xPos, 0f, 6.5f)));
                transparentPallets.Add(manipulator.AddGeneric(resPalletGeometryRed, relocVector + new Vector3(xPos, 0f, 8f)));
                transparentPallets.Add(manipulator.AddGeneric(resPalletGeometryRed, relocVector + new Vector3(xPos, 0f, 9.5f)));

                //Red pallets
                transparentPallets.Add(manipulator.AddGeneric(resPalletGeometryRed, relocVector + new Vector3(xPos, 5f, 5.0f)));
                standardPallets.Add(manipulator.AddGeneric(resPalletGeometryRed, relocVector + new Vector3(xPos, 5f, 6.5f)));
                transparentPallets.Add(manipulator.AddGeneric(resPalletGeometryRed, relocVector + new Vector3(xPos, 5f, 8f)));
                transparentPallets.Add(manipulator.AddGeneric(resPalletGeometryRed, relocVector + new Vector3(xPos, 5f, 9.5f)));

                //Red pallets
                transparentPallets.Add(manipulator.AddGeneric(resPalletGeometryGreen, relocVector + new Vector3(xPos, 0f, -5.0f)));
                standardPallets.Add(manipulator.AddGeneric(resPalletGeometryGreen, relocVector + new Vector3(xPos, 0f, -6.5f)));
                transparentPallets.Add(manipulator.AddGeneric(resPalletGeometryGreen, relocVector + new Vector3(xPos, 0f, -8f)));
                transparentPallets.Add(manipulator.AddGeneric(resPalletGeometryGreen, relocVector + new Vector3(xPos, 0f, -9.5f)));
            }

            standardPallets.ForEachInEnumeration((actPallet) =>
            {
                actPallet.BorderMultiplyer = 50f;
                actPallet.BorderPart       = 0.01f;
            });
            transparentPallets.ForEachInEnumeration((actPallet) =>
            {
                actPallet.BorderMultiplyer = 50f;
                actPallet.BorderPart       = 0.01f;
                actPallet.Opacity          = 0.5f;
            });
        }
        /// <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;
        }