コード例 #1
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));
        }
コード例 #2
0
        /// <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;
        }
コード例 #3
0
        /// <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);
            }
        }