Ejemplo n.º 1
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            _flags         = loader.ReadUInt32();
            PolygonControl = new PolygonControl()
            {
                Value = loader.ReadUInt32()
            };
            DepthControl = new DepthControl()
            {
                Value = loader.ReadUInt32()
            };
            AlphaControl = new AlphaControl()
            {
                Value = loader.ReadUInt32()
            };
            AlphaRefValue = loader.ReadSingle();
            ColorControl  = new ColorControl()
            {
                Value = loader.ReadUInt32()
            };
            BlendTarget  = loader.ReadUInt32();
            BlendControl = new BlendControl()
            {
                Value = loader.ReadUInt32()
            };
            BlendColor = loader.ReadVector4F();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderState"/> class.
        /// </summary>
        public RenderState()
        {
            FlagsMode      = RenderStateFlagsMode.Opaque;
            FlagsBlendMode = RenderStateFlagsBlendMode.None;

            PolygonControl = new PolygonControl()
            {
                CullBack                  = false,
                CullFront                 = false,
                FrontFace                 = GX2FrontFaceMode.CounterClockwise,
                PolygonModeBack           = GX2PolygonMode.Triangle,
                PolygonModeFront          = GX2PolygonMode.Triangle,
                PolygonOffsetBackEnabled  = false,
                PolygonOffsetFrontEnabled = false,
                PolygonLineOffsetEnabled  = false,
                PolygonModeEnabled        = true,
            };

            AlphaControl = new AlphaControl()
            {
                AlphaFunc = GX2CompareFunction.GreaterOrEqual,
            };

            DepthControl = new DepthControl()
            {
                BackStencilEnabled = false,
                BackStencilFail    = GX2StencilFunction.Replace,
                BackStencilFunc    = GX2CompareFunction.Always,
                BackStencilZFail   = GX2StencilFunction.Replace,
                BackStencilZPass   = GX2StencilFunction.Replace,
                DepthFunc          = GX2CompareFunction.LessOrEqual,
                DepthTestEnabled   = true,
                DepthWriteEnabled  = true,
                FrontStencilFail   = GX2StencilFunction.Replace,
                FrontStencilFunc   = GX2CompareFunction.Always,
                FrontStencilZFail  = GX2StencilFunction.Replace,
                FrontStencilZPass  = GX2StencilFunction.Replace,
                StencilTestEnabled = false,
            };

            AlphaRefValue = 0.5F;


            BlendControl = new BlendControl()
            {
                AlphaCombine          = GX2BlendCombine.Add,
                AlphaDestinationBlend = GX2BlendFunction.Zero,
                AlphaSourceBlend      = GX2BlendFunction.Zero,
                ColorCombine          = GX2BlendCombine.Add,
                ColorDestinationBlend = GX2BlendFunction.OneMinusSourceAlpha,
                ColorSourceBlend      = GX2BlendFunction.SourceAlpha,
                SeparateAlphaBlend    = true,
            };

            BlendColor = new Vector4F(0, 0, 0, 0);
        }
Ejemplo n.º 3
0
        void OnEnable()
        {
            blending     = GetComponent <Blending>();
            targetCamera = GetComponent <Camera>();

            blending.enabled = true;
            mouseTracker.Clear();

            mouseCurr            = new MousePosition(targetCamera, blending.BlendingData);
            fsmTrackerTargetMode = new FSM <TargetModeEnum>(this);
            fsmGUIMode           = new FSM <GUIModeEnum>(this);

            cornerControl = new CornerControl(this, blending, mouseTracker, mouseCurr);
            edgeControl   = new EdgeControl(this, blending, mouseTracker, mouseCurr);
            blendControl  = new BlendControl(this, blending, mouseTracker, mouseCurr);

            #region FSM Setup
            fsmTrackerTargetMode.State(TargetModeEnum.None);
            fsmTrackerTargetMode.State(TargetModeEnum.Corner)
            .Enter(fsm => cornerControl.Activity = true)
            .Update(fsm => cornerControl.Update())
            .Exit(fsm => cornerControl.Activity = false);
            fsmTrackerTargetMode.State(TargetModeEnum.Edge)
            .Enter(fsm => edgeControl.Activity = true)
            .Update(fsm => edgeControl.Update())
            .Exit(fsm => edgeControl.Activity = false);
            fsmTrackerTargetMode.State(TargetModeEnum.Blend)
            .Enter(fsm => blendControl.Activity = true)
            .Update(fsm => blendControl.Update())
            .Exit(fsm => blendControl.Activity = false);
            fsmTrackerTargetMode.Init();

            fsmGUIMode.State(GUIModeEnum.Hidden).Update(fsm => {
                if (Input.GetKeyDown(config.guiModeToggleKey))
                {
                    fsm.Goto(GUIModeEnum.Show);
                }
            });
            fsmGUIMode.State(GUIModeEnum.Show).Update(fsm => {
                if (Input.GetKeyDown(config.guiModeToggleKey))
                {
                    fsm.Goto(GUIModeEnum.Hidden);
                }
            });
            fsmGUIMode.Init();
            #endregion

            #region Reactive setup
            trackerMode.Changed += (r => {
                fsmTrackerTargetMode.Goto(r.Value);
                trackerIndex.Value = EnumOperator <TargetModeEnum> .FindIndex(r.Value);
            });
            trackerIndex.Changed += (r => {
                trackerMode.Value = EnumOperator <TargetModeEnum> .ValueAt(r.Value);
            });

            screenColumnCount.Changed += (r => {
                UpdateScreenSetup(r.Value, screenRowCount.Value);
                screenColumnCountText.Value = r.Value.ToString();
            });
            screenRowCount.Changed += (r => {
                UpdateScreenSetup(screenColumnCount.Value, r.Value);
                screenRowCountText.Value = r.Value.ToString();
            });
            screenColumnCountText.Changed += (r => {
                int nextValue;
                if (int.TryParse(r.Value, out nextValue))
                {
                    screenColumnCount.Value = Mathf.Max(1, nextValue);
                }
            });
            screenRowCountText.Changed += (r => {
                int nextValue;
                if (int.TryParse(r.Value, out nextValue))
                {
                    screenRowCount.Value = Mathf.Max(1, nextValue);
                }
            });

            outputMode.Changed += (r => {
                blending.BlendingData.OutputKeyword = r.Value;
                outputIndex.Value = EnumOperator <KwOutput> .FindIndex(r.Value);
            });
            outputIndex.Changed += (r => {
                outputMode.Value = EnumOperator <KwOutput> .ValueAt(r.Value);
            });

            wireframeMode.Changed += (r => {
                blending.BlendingData.WireframeKeyword = r.Value;
                wireframeIndex.Value = EnumOperator <KwWireframe> .FindIndex(r.Value);
            });
            wireframeIndex.Changed += (r => {
                wireframeMode.Value = EnumOperator <KwWireframe> .ValueAt(r.Value);
            });

            textureBlendMode.Changed += (r => {
                blending.BlendingData.TextureBlendkeyword = r.Value;
                textureBlendIndex.Value = EnumOperator <KwTextureBlend> .FindIndex(r.Value);
            });
            textureBlendIndex.Changed += (r =>
                                          textureBlendMode.Value = EnumOperator <KwTextureBlend> .ValueAt(r.Value));

            maskTextureIndex.Changed += (r => {
                blending.BlendingData.MaskTextureIndex = r.Value;
                maskTextureIndexText.Value = r.Value.ToString();
            });
            maskTextureIndexText.Changed += (r => {
                int nextValue;
                if (int.TryParse(r.Value, out nextValue))
                {
                    maskTextureIndex.Value = nextValue;
                }
            });
            #endregion

            Load();
            UpdateScreenSetup(screenColumnCount.Value, screenRowCount.Value);
        }