Exemplo 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);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds a new texture resource to the scene.
 /// </summary>
 /// <param name="sceneManipulator">The manipulator of the scene.</param>
 /// <param name="textureSourceHighQuality">The source of the texture in high quality.</param>
 /// <param name="textureSourceLowQuality">The texture in low quality.</param>
 public static NamedOrGenericKey AddTextureResource(
     this SceneManipulator sceneManipulator,
     ResourceLink textureSourceHighQuality,
     ResourceLink textureSourceLowQuality)
 {
     return sceneManipulator.AddResource(_ => new StandardTextureResource(textureSourceHighQuality, textureSourceLowQuality));
 }
        /// <summary>
        /// Builds the demo scene.
        /// </summary>
        /// <param name="manipulator">Current scene manipulator object.</param>
        /// <param name="sideLength">The side length of the pallet cube.</param>
        /// <param name="camera">The camera to be manipulated too.</param>
        private static void BuildPalletCubes(SceneManipulator manipulator, NamedOrGenericKey[] resPalletGeometrys, int sideLength)
        {
            // Build the scene
            Vector3 startPosition = new Vector3(-sideLength * SPACE_X / 2f, 0f, -sideLength * SPACE_Z / 2f);
            Random  randomizer    = new Random(Environment.TickCount);

            for (int loopX = 0; loopX < sideLength; loopX++)
            {
                for (int loopY = 0; loopY < sideLength; loopY++)
                {
                    for (int loopZ = 0; loopZ < sideLength; loopZ++)
                    {
                        GenericObject palletObject = new GenericObject(
                            resPalletGeometrys[randomizer.Next(0, resPalletGeometrys.Length)],
                            new Vector3(loopX * SPACE_X, loopY * SPACE_Y, loopZ * SPACE_Z) + startPosition);
                        palletObject.Color = POSSIBLE_COLORS[randomizer.Next(0, POSSIBLE_COLORS.Length)];
                        palletObject.EnableShaderGeneratedBorder();
                        manipulator.Add(palletObject);

                        // Define animation
                        palletObject.BuildAnimationSequence()
                        .Delay(randomizer.Next(100, 1000))
                        .Apply();
                        palletObject.BuildAnimationSequence()
                        .Scale3DTo(0.5f, TimeSpan.FromSeconds(2.0))
                        .WaitFinished()
                        .Scale3DTo(1f, TimeSpan.FromSeconds(2.0))
                        .ApplyAndRewind();
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Builds a floor to the given scene.
        /// </summary>
        protected void BuildStandardFloor(SceneManipulator manipulator, string sceneLayer)
        {
            var bgLayer = manipulator.AddLayer("BACKGROUND");

            manipulator.SetLayerOrderId(bgLayer, 0);
            manipulator.SetLayerOrderId(Scene.DEFAULT_LAYER_NAME, 1);
            ResourceLink sourceBackgroundTexture = new AssemblyResourceLink(
                typeof(SampleBase),
                "Assets.Background.dds");
            ResourceLink sourceTileTexture = new AssemblyResourceLink(
                typeof(SampleBase),
                "Assets.Floor.dds");

            var resBackgroundTexture = manipulator.AddTextureResource(sourceBackgroundTexture);

            manipulator.AddObject(new FullscreenTexture(resBackgroundTexture), bgLayer.Name);

            // Define textures and materials
            var resTileTexture  = manipulator.AddResource(device => new StandardTextureResource(sourceTileTexture));
            var resTileMaterial = manipulator.AddResource(device => new StandardMaterialResource(resTileTexture));

            // Define floor geometry
            var floorType = new FloorGeometryFactory(new Vector2(4f, 4f));

            floorType.SetTilemap(25, 25);

            // AddObject floor to scene
            var resFloorGeometry = manipulator.AddResource(device => new GeometryResource(floorType));

            manipulator.AddMeshObject(resFloorGeometry, sceneLayer, resTileMaterial);
        }
Exemplo n.º 5
0
 /// <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 AddStandardMaterialResource(
     this SceneManipulator sceneManipulator,
     ResourceLink textureSourceHighQuality, ResourceLink textureSourceLowQuality)
 {
     var resTexture = sceneManipulator.AddTextureResource(textureSourceHighQuality, textureSourceLowQuality);
     return sceneManipulator.AddResource(_ => new StandardMaterialResource(resTexture));
 }
        /// <summary>
        /// Attaches this component to a scene.
        /// Be careful, this method gets called from a background thread of seeing#!
        /// It may also be called from multiple scenes in parallel or simply withoud previous Detach call.
        /// </summary>
        /// <param name="manipulator">The manipulator of the scene we attach to.</param>
        /// <param name="correspondingView">The view which attached this component.</param>
        /// <returns></returns>
        protected override PerSceneContext Attach(SceneManipulator manipulator, ViewInformation correspondingView)
        {
            PerSceneContext result = new PerSceneContext();

            result.CameraDistance   = this.CameraDistanceInitial;
            result.CameraHVRotation = m_hvRotation;
            return(result);
        }
Exemplo n.º 7
0
        /// <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)));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates the configured layer if it does not exist on the given scene.
        /// </summary>
        /// <param name="manipulator">The manipulator for manipulating the scene.</param>
        protected void CreateLayerIfNotAvailable(SceneManipulator manipulator)
        {
            this.TargetLayer.EnsureNotNullOrEmptyOrWhiteSpace(nameof(this.TargetLayer));

            if (!manipulator.ContainsLayer(this.TargetLayer))
            {
                SceneLayer bgLayer = manipulator.AddLayer(this.TargetLayer);
                manipulator.SetLayerOrderID(bgLayer, this.TargetLayerOrderID);
            }
        }
Exemplo n.º 9
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);
        }
        /// <summary>
        /// Attaches this component to a scene.
        /// Be careful, this method gets called from a background thread of seeing#!
        /// It may also be called from multiple scenes in parallel or simply withoud previous Detach call.
        /// </summary>
        /// <param name="manipulator">The manipulator of the scene we attach to.</param>
        /// <param name="correspondingView">The view which attached this component.</param>
        protected override PerSceneContext Attach(SceneManipulator manipulator, ViewInformation correspondingView)
        {
            PerSceneContext context = new PerSceneContext();

            switch (m_gradientDirection)
            {
            case GradientDirection.LeftToRight:
                context.BrushResource = new LinearGradientBrushResource(
                    new System.Numerics.Vector2(0f, 0f),
                    new System.Numerics.Vector2(m_textureWidth, 0f),
                    new GradientStop[]
                {
                    new GradientStop(m_colorStart, 0f),
                    new GradientStop(m_colorEnd, 1f)
                });
                break;

            case GradientDirection.TopToBottom:
                context.BrushResource = new LinearGradientBrushResource(
                    new System.Numerics.Vector2(0f, 0f),
                    new System.Numerics.Vector2(0f, m_textureHeight),
                    new GradientStop[]
                {
                    new GradientStop(m_colorStart, 0f),
                    new GradientStop(m_colorEnd, 1f)
                });
                break;

            case GradientDirection.Directional:
                context.BrushResource = new LinearGradientBrushResource(
                    new System.Numerics.Vector2(0f, 0f),
                    new System.Numerics.Vector2(m_textureWidth, m_textureHeight),
                    new GradientStop[]
                {
                    new GradientStop(m_colorStart, 0f),
                    new GradientStop(m_colorEnd, 1f)
                });
                break;
            }

            // Create the background layer if not available already
            base.CreateLayerIfNotAvailable(manipulator);

            // Create and add the background
            context.BackgroundTextureKey = manipulator.AddResource(
                () => new Direct2DSingleRenderTextureResource(context.BrushResource, m_textureWidth, m_textureHeight));
            context.BackgroundPainter         = new FullscreenTextureObject(context.BackgroundTextureKey);
            context.BackgroundPainter.Scaling = 1.1f;
            manipulator.Add(context.BackgroundPainter, DEFAULT_LAYER);

            return(context);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Adds a new simple colored material resource to the scene.
 /// </summary>
 /// <param name="sceneManipulator">The manipulator of the scene.</param>
 /// <param name="textureKey">The resource key of the texture to be used.</param>
 /// <param name="clipFactor">Pixel are clipped up to an alpha value defined by this Clipfactor within the pixel shader.</param>
 /// <param name="maxClipDistance">The maximum distance on which to apply pixel clipping (defined by ClipFactor property).</param>
 /// <param name="adjustTextureCoordinates">Interpolate texture coordinate based on xy-scaling.</param>
 /// <param name="addToAlpha">Needed for video rendering (Frames from the MF SourceReader have alpha always to zero).</param>
 public static NamedOrGenericKey AddSimpleColoredMaterial(
     this SceneManipulator sceneManipulator, NamedOrGenericKey textureKey,
     float clipFactor              = 0f,
     float maxClipDistance         = 1000f,
     bool adjustTextureCoordinates = false,
     float addToAlpha              = 0f)
 {
     return(sceneManipulator.AddResource <SimpleColoredMaterialResource>(
                () => new SimpleColoredMaterialResource(textureKey)
     {
         AdjustTextureCoordinates = adjustTextureCoordinates,
         MaxClipDistance = maxClipDistance,
         ClipFactor = clipFactor,
         AddToAlpha = addToAlpha
     }));
 }
Exemplo n.º 12
0
        protected override Mesh CreateMesh(SceneManipulator manipulator, SampleSettings sampleSettings, NamedOrGenericKey resMaterial)
        {
            var castedSettings = (PyramidSampleSettings)sampleSettings;

            var resGeometry = manipulator.AddResource(
                device => new GeometryResource(
                    new PyramidGeometryFactory
            {
                Width  = castedSettings.Width,
                Height = castedSettings.Height
            }));

            var result = new Mesh(resGeometry, resMaterial);

            result.Position = new Vector3(0f, 0.5f + castedSettings.Height / 2f, 0f);
            return(result);
        }
Exemplo n.º 13
0
        protected override Mesh CreateMesh(SceneManipulator manipulator, SampleSettings sampleSettings, NamedOrGenericKey resMaterial)
        {
            var castedSettings = (GeosphereSampleSettings)sampleSettings;

            var resGeometry = manipulator.AddResource(
                device => new GeometryResource(
                    new GeosphereGeometryFactory
            {
                CountSubdivisions = castedSettings.CountSubdivisions,
                Radius            = castedSettings.Radius
            }));

            var result = new Mesh(resGeometry, resMaterial);

            result.Position = new Vector3(0f, 0.5f + castedSettings.Radius, 0f);
            return(result);
        }
Exemplo n.º 14
0
        protected override Mesh CreateMesh(SceneManipulator manipulator, SampleSettings sampleSettings, NamedOrGenericKey resMaterial)
        {
            var castedSettings = (CylinderSampleSettings)sampleSettings;

            var resGeometry = manipulator.AddResource(
                device => new GeometryResource(
                    new CylinderGeometryFactory
            {
                Radius          = castedSettings.Radius,
                Height          = castedSettings.Height,
                CountOfSegments = castedSettings.CountOfSegments
            }));

            var result = new Mesh(resGeometry, resMaterial);

            result.Position = new Vector3(0f, 0.5f, 0f);
            return(result);
        }
Exemplo n.º 15
0
        protected override Mesh CreateMesh(SceneManipulator manipulator, SampleSettings sampleSettings, NamedOrGenericKey resMaterial)
        {
            var castedSettings = (TorusSampleSettings)sampleSettings;

            var resGeometry = manipulator.AddResource(
                device => new GeometryResource(
                    new TorusGeometryFactory()
            {
                TDiv        = castedSettings.TDiv,
                PDiv        = castedSettings.PDiv,
                TorusRadius = castedSettings.TorusRadius,
                TubeRadius  = castedSettings.TubeRadius,
            }));

            var result = new Mesh(resGeometry, resMaterial);

            result.Position = new Vector3(0f, 0.5f + castedSettings.TubeRadius + castedSettings.TorusRadius, 0f);
            return(result);
        }
Exemplo n.º 16
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));
        }
Exemplo n.º 17
0
 /// <summary>
 /// Adds a new simple colored material resource to the scene.
 /// </summary>
 /// <param name="sceneManipulator">The manipulator of the scene.</param>
 /// <param name="textureKey">The resource key of the texture to be used.</param>
 /// <param name="clipFactor">Pixel are clipped up to an alpha value defined by this clipping factor within the pixel shader.</param>
 /// <param name="maxClipDistance">The maximum distance on which to apply pixel clipping (defined by ClipFactor property).</param>
 /// <param name="adjustTextureCoordinates">Interpolate texture coordinate based on xy-scaling.</param>
 /// <param name="addToAlpha">Needed for video rendering (Frames from the MF SourceReader have alpha always to zero).</param>
 /// <param name="materialDiffuseColor">The fixed diffuse color for this material.</param>
 /// <param name="useVertexColors">Set this to false to use the material's diffuse color.</param>
 /// <param name="enableShaderGeneratedBorder">Enable drawing of borders which are generated by the pixel shader?</param>
 public static NamedOrGenericKey AddStandardMaterialResource(
     this SceneManipulator sceneManipulator,
     NamedOrGenericKey textureKey = default,
     float clipFactor = 0f,
     float maxClipDistance = 1000f,
     bool adjustTextureCoordinates = false,
     float addToAlpha = 0f,
     Color4 materialDiffuseColor = default,
     bool useVertexColors = true,
     bool enableShaderGeneratedBorder = false)
 {
     return sceneManipulator.AddResource(
         _ => new StandardMaterialResource(textureKey, enableShaderGeneratedBorder)
         {
             AdjustTextureCoordinates = adjustTextureCoordinates,
             MaxClipDistance = maxClipDistance,
             ClipFactor = clipFactor,
             AddToAlpha = addToAlpha,
             MaterialDiffuseColor = materialDiffuseColor,
             UseVertexColors = useVertexColors
         });
 }
Exemplo n.º 18
0
        /// <summary>
        /// Builds the demo scene.
        /// </summary>
        /// <param name="manipulator">Current scene manipulator object.</param>
        /// <param name="sideLength">The side length of the pallet cube.</param>
        /// <param name="camera">The camera to be manipulated too.</param>
        private static void BuildPalletCubes(SceneManipulator manipulator, NamedOrGenericKey[] resPalletGeometrys, int sideLength)
        {
            // Build the scene
            Vector3 startPosition = new Vector3(-sideLength * SPACE_X / 2f, 0f, -sideLength * SPACE_Z / 2f);
            Random  randomizer    = new Random(Environment.TickCount);

            for (int loopX = 0; loopX < sideLength; loopX++)
            {
                for (int loopY = 0; loopY < sideLength; loopY++)
                {
                    for (int loopZ = 0; loopZ < sideLength; loopZ++)
                    {
                        GenericObject palletObject = new GenericObject(
                            resPalletGeometrys[randomizer.Next(0, resPalletGeometrys.Length)],
                            new Vector3(loopX * SPACE_X, loopY * SPACE_Y, loopZ * SPACE_Z) + startPosition);
                        palletObject.Color = POSSIBLE_COLORS[randomizer.Next(0, POSSIBLE_COLORS.Length)];
                        palletObject.EnableShaderGeneratedBorder();
                        palletObject.IsStatic = true;
                        manipulator.Add(palletObject);
                    }
                }
            }
        }
Exemplo n.º 19
0
 protected override void Detach(SceneManipulator manipulator, ViewInformation correspondingView, PerSceneContext context)
 {
     manipulator.Remove(context.CubeObject);
 }
        /// <summary>
        /// Frees the current screen.
        /// </summary>
        /// <param name="manipulator">The manipulator.</param>
        private void FreeCurrentScreen(SceneManipulator manipulator)
        {
            foreach (CardPairLogic actCardPair in m_cardPairsOnScreen)
            {
                manipulator.Remove(actCardPair);
                manipulator.RemoveRange(actCardPair.Cards);
            }

            for (int loopX = 0; loopX < m_cardMapOnScreen.GetLength(0); loopX++)
            {
                for (int loopY = 0; loopY < m_cardMapOnScreen.GetLength(1); loopY++)
                {
                    m_cardMapOnScreen[loopX, loopY] = null;
                }
            }
        }
        /// <summary>
        /// Builds up the given screen on the given SceneManipulator.
        /// </summary>
        /// <param name="manipulator">The manipulator.</param>
        /// <param name="currentScreen">The screen to be build.</param>
        private void BuildScreen(SceneManipulator manipulator, ScreenData currentScreen)
        {
            int tilesX = m_currentLevel.Tilemap.TilesX;
            int tilesY = m_currentLevel.Tilemap.TilesY;
            float tileDistX = Constants.TILE_DISTANCE_X;
            float tileDistY = -Constants.TILE_DISTANCE_Y;
            Vector3 midPoint = new Vector3((tilesX - 1) * tileDistX / 2f, 0f, ((tilesY - 1) * tileDistY / 2f));

            foreach (CardPairData actPairData in currentScreen.MemoryPairs)
            {
                CardPairLogic actCardPair = new CardPairLogic(actPairData);

                // Define all resources needed for a card for this pair
                var resTitleMaterial = manipulator.AddSimpleColoredMaterial(actPairData.TitleFile);
                var resGeometry1 = manipulator.AddGeometry(new CardObjectType()
                {
                    FrontMaterial = resTitleMaterial,
                    BackMaterial = m_resBackgroundMaterial1
                });
                var resGeometry2 = manipulator.AddGeometry(new CardObjectType()
                {
                    FrontMaterial = resTitleMaterial,
                    BackMaterial = m_resBackgroundMaterial2
                });

                // Create both cards for this pair
                Card cardA = new Card(resGeometry1, actCardPair);
                Card cardB = new Card(resGeometry2, actCardPair);
                Tuple<int, int> slotA = SearchFreeCardSlot(m_currentLevel, m_cardMapOnScreen);
                m_cardMapOnScreen[slotA.Item1, slotA.Item2] = cardA;
                Tuple<int, int> slotB = SearchFreeCardSlot(m_currentLevel, m_cardMapOnScreen);
                m_cardMapOnScreen[slotB.Item1, slotB.Item2] = cardB;

                // Add both cards to the scene
                cardA.Position = new Vector3(slotA.Item1 * tileDistX, 0f, slotA.Item2 * tileDistY) - midPoint;
                cardA.AccentuationFactor = 1f;
                cardB.Position = new Vector3(slotB.Item1 * tileDistX, 0f, slotB.Item2 * tileDistY) - midPoint;
                cardB.AccentuationFactor = 1f;
                manipulator.Add(cardA);
                manipulator.Add(cardB);

                // Assigns the cards to the pair object
                actCardPair.Cards = new Card[] { cardA, cardB };
                manipulator.Add(actCardPair);

                m_cardPairsOnScreen.Add(actCardPair);
            }
        }
Exemplo n.º 22
0
 /// <summary>
 /// Adds a new simple colored material resource to the scene.
 /// </summary>
 /// <param name="sceneManipulator">The manipulator of the scene.</param>
 public static NamedOrGenericKey AddStandardMaterialResource(this SceneManipulator sceneManipulator)
 {
     return sceneManipulator.AddResource(_ => new StandardMaterialResource());
 }
Exemplo n.º 23
0
 /// <summary>
 /// Adds a new geometry resource to the scene.
 /// </summary>
 /// <param name="sceneManipulator">The manipulator of the scene.</param>
 /// <param name="objectType">The geometry to be loaded.</param>
 public static NamedOrGenericKey AddGeometry(this SceneManipulator sceneManipulator, ObjectType objectType)
 {
     return(sceneManipulator.AddResource <GeometryResource>(() => new GeometryResource(objectType)));
 }
Exemplo n.º 24
0
 /// <summary>
 /// Adds a new geometry resource to the scene.
 /// </summary>
 /// <param name="sceneManipulator">The manipulator of the scene.</param>
 /// <param name="objectType">The geometry to be loaded.</param>
 public static NamedOrGenericKey AddGeometryResource(this SceneManipulator sceneManipulator, GeometryFactory objectType)
 {
     return sceneManipulator.AddResource(_ => new GeometryResource(objectType));
 }
Exemplo n.º 25
0
 internal abstract void DetachInternal(SceneManipulator manipulator, ViewInformation?correspondingView, object?componentContext);
Exemplo n.º 26
0
 /// <summary>
 /// Adds a new texture resource to the scene.
 /// </summary>
 /// <param name="sceneManipulator">The manipulator of the scene.</param>
 /// <param name="textureSource">The source of the texture.</param>
 public static NamedOrGenericKey AddTexture(this SceneManipulator sceneManipulator, ResourceLink textureSource)
 {
     return(sceneManipulator.AddResource <StandardTextureResource>(() => new StandardTextureResource(textureSource)));
 }
Exemplo n.º 27
0
 /// <summary>
 /// Adds a new geometry resource to the scene.
 /// </summary>
 /// <param name="sceneManipulator">The manipulator of the scene.</param>
 /// <param name="geometry">The geometry.</param>
 public static NamedOrGenericKey AddGeometryResource(this SceneManipulator sceneManipulator, Geometry geometry)
 {
     return sceneManipulator.AddResource(_ => new GeometryResource(geometry));
 }
 /// <summary>
 /// Detaches this component from a scene.
 /// Be careful, this method gets called from a background thread of seeing#!
 /// It may also be called from multiple scenes in parallel.
 /// </summary>
 /// <param name="manipulator">The manipulator of the scene we attach to.</param>
 /// <param name="correspondingView">The view which attached this component.</param>
 /// <param name="componentContext">A context variable containing all createded objects during call of Attach.</param>
 protected override void Detach(SceneManipulator manipulator, ViewInformation correspondingView, PerSceneContext componentContext)
 {
 }
        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;
        }
        /// <summary>
        /// Updates the given body model.
        /// Be carefull.. this method runs within 3D-Engine update thread.
        /// </summary>
        /// <param name="scene">The scene to be manipulated.</param>
        /// <param name="manipulator">The manipulator.</param>
        /// <param name="bodyObject">The body object.</param>
        /// <param name="bodyIndex">Index of the body.</param>
        private static void UpdateBodyModel(Scene scene, SceneManipulator manipulator, Body bodyObject, int bodyIndex)
        {
            // Ensure we have a layer for this body
            string actBodyLayerName = "Body_" + bodyIndex;
            SceneLayer actBodyLayer = manipulator.TryGetLayer(actBodyLayerName);
            if(actBodyLayer == null)
            {
                actBodyLayer = manipulator.AddLayer(actBodyLayerName);
                manipulator.SetLayerOrderID(actBodyLayer, bodyIndex);

            }
        }
Exemplo n.º 32
0
 /// <summary>
 /// Adds a new geometry resource to the scene.
 /// </summary>
 /// <param name="sceneManipulator">The manipulator of the scene.</param>
 /// <param name="vertexStructure">The structures which define the geometry.</param>
 public static NamedOrGenericKey AddGeometry(this SceneManipulator sceneManipulator, VertexStructure vertexStructure)
 {
     return(sceneManipulator.AddResource <GeometryResource>(() => new GeometryResource(vertexStructure)));
 }
Exemplo n.º 33
0
 protected override void Detach(SceneManipulator manipulator, ViewInformation correspondingView)
 {
 }
Exemplo n.º 34
0
 /// <summary>
 /// Adds a new simple colored material resource to the scene.
 /// </summary>
 /// <param name="sceneManipulator">The manipulator of the scene.</param>
 public static NamedOrGenericKey AddSimpleColoredMaterial(this SceneManipulator sceneManipulator)
 {
     return(sceneManipulator.AddResource <SimpleColoredMaterialResource>(() => new SimpleColoredMaterialResource()));
 }