コード例 #1
0
        public STrailsRenderer(PositionFunc positonFunc, FwdFunc fwdDirFunc, UpFunc upFunc,
                               STrailsParameters trailsParams = null)
            : base(new STrailsData(positonFunc, fwdDirFunc, upFunc,
                                   trailsParams ?? new STrailsParameters()),
                   SSTexturedCube.Instance, _defaultUsageHint)
        {
            trailsParams = trailsData.trailsParams;
            var tex = SSAssetManager.GetInstance <SSTextureWithAlpha>(trailsParams.textureFilename);

            renderState.castsShadow     = false;
            renderState.receivesShadows = false;
            renderState.doBillboarding  = false;
            renderState.alphaBlendingOn = true;
            //renderState.alphaBlendingOn = false;
            renderState.depthTest  = true;
            renderState.depthWrite = false;
            renderState.lighted    = false;

            renderState.blendEquationModeRGB = BlendEquationMode.FuncAdd;
            renderState.blendFactorSrcRGB    = BlendingFactorSrc.SrcAlpha;
            //renderState.blendFactorDestRGB = BlendingFactorDest.DstAlpha;
            renderState.blendFactorDestRGB = BlendingFactorDest.OneMinusSrc1Alpha;

            renderState.blendEquationModeAlpha = BlendEquationMode.FuncAdd;
            renderState.blendFactorSrcAlpha    = BlendingFactorSrc.One;
            renderState.blendFactorDestAlpha   = BlendingFactorDest.One;
            //renderState.blendFactorSrcAlpha = BlendingFactorSrc.SrcAlpha;
            renderState.blendFactorDestAlpha = BlendingFactorDest.OneMinusSrcAlpha;

            simulateOnUpdate = false;
            simulateOnRender = true;

            renderState.frustumCulling = true;

            colorMaterial   = SSColorMaterial.pureAmbient;
            textureMaterial = new SSTextureMaterial(diffuse: tex);
            Name            = "simple trails renderer";

            //this.MainColor = Color4Helper.RandomDebugColor();
            this.renderMode = RenderMode.GpuInstancing;
        }
コード例 #2
0
            //protected readonly STrailUpdater _updater;
            #endregion

            public STrailsData(
                PositionFunc positionFunc, FwdFunc fwdDirFunc, UpFunc upFunc,
                STrailsParameters trailsParams = null)
                : base(trailsParams.capacity)
            {
                this.trailsParams  = trailsParams;
                this._positionFunc = positionFunc;
                this._fwdFunc      = fwdDirFunc;
                this._upFunc       = upFunc;

                _headSegmentIdxs            = new ushort[trailsParams.numJets];
                _tailSegmentIdxs            = new ushort[trailsParams.numJets];
                _prevSplineIntervalEndPos   = new Vector3[trailsParams.numJets];
                _prevSplineIntervalEndSlope = new Vector3[trailsParams.numJets];
                _localJetOrients            = new Matrix4[trailsParams.numJets];

                Vector3 pos          = _positionFunc();
                Vector3 fwd          = _fwdFunc();
                Vector3 up           = _upFunc();
                Vector3 right        = Vector3.Cross(fwd, up);
                Matrix4 globalOrient = new Matrix4(
                    new Vector4(right, 0f),
                    new Vector4(up, 0f),
                    new Vector4(fwd, 0f),
                    new Vector4(0f, 0f, 0f, 1f));

                for (int i = 0; i < trailsParams.numJets; ++i)
                {
                    _headSegmentIdxs[i] = STrailsSegment.NotConnected;
                    _tailSegmentIdxs[i] = STrailsSegment.NotConnected;
                    Vector3 localFwd = trailsParams.localJetDir(i);
                    _localJetOrients[i] = OpenTKHelper.neededRotationMat(-Vector3.UnitZ, localFwd);
                    jetTxfm(i, ref pos, ref globalOrient,
                            out _prevSplineIntervalEndPos[i], out _prevSplineIntervalEndSlope[i]);
                }

                _outerColorEffector = new SSColorKeyframesEffector(trailsParams.outerColorKeyframes)
                {
                    particleLifetime = trailsParams.trailLifetime,
                };
                addEffector(_outerColorEffector);

                _innerColorEffector = new STrailsInnerColorEffector(trailsParams.innerColorKeyframes)
                {
                    particleLifetime = trailsParams.trailLifetime,
                };
                addEffector(_innerColorEffector);


                _innerRatioEffector = new STrailsInnerColorRatioEffector(trailsParams.innerColorRatioKeyframes)
                {
                    particleLifetime = trailsParams.trailLifetime,
                };
                addEffector(_innerRatioEffector);

                _outerRatioEffector = new STrailsOuterColorRatioEffector(trailsParams.outerColorRatioKeyframes)
                {
                    particleLifetime = trailsParams.trailLifetime,
                };
                addEffector(_outerRatioEffector);

                _widthEffector = new STrailsWidthEffector(trailsParams.widthKeyFrames)
                {
                    particleLifetime = trailsParams.trailLifetime,
                };
                addEffector(_widthEffector);


                //_updater = new STrailUpdater(trailsParams);
                //addEffector(_updater);
            }
コード例 #3
0
ファイル: MenuLogic.cs プロジェクト: DrexelGoalBall/goalBall
// Protected Functions

		/// <summary>
		///     Checks for user button presses and calls respective function
		/// </summary>
		/// <param name="left">Defined Left function</param>
		/// <param name="right">Defined Right function</param>
		/// <param name="up">Defined Up function</param>
		/// <param name="down">Defined Down function</param>
		protected void directionalMenuLogic(LeftFunc left, RightFunc right, UpFunc up, DownFunc down)
		{
            horiz = InputPlayers.player0.GetAxis(HorizontalButton);
            vert = InputPlayers.player0.GetAxis(VerticalButton);

            if (horiz < LIMIT && vert < LIMIT)
            {
                changeBumpers("off");
            }

			// Audio for each option if user holds down key for long enough
		//	if (!hasSounded) // To be used if the welcome instructions should be skippable if the user presses a button
			 if (horiz >= LIMIT) // Right
			 {
                if (!source.isPlaying) playDirectionalSound(rightSound);
                changeBumpers("Right");
			 }	
			 else if (horiz <= -(LIMIT) ) // Left
			 {
                if (!source.isPlaying) playDirectionalSound(leftSound);
                changeBumpers("Left");
            }	
           
			 if (vert >= LIMIT) // Up
			 {
                if (!source.isPlaying) playDirectionalSound(upSound);
                changeBumpers("Up");
            }
			 else if (vert <= -(LIMIT) ) // Down
			 {
                if (!source.isPlaying) playDirectionalSound(downSound);
                changeBumpers("Down");
            }

            if (InputPlayers.player0.GetButtonDown(SubmitButton))
            {
                if (horiz > LIMIT) // Right
                {
                    right();
                }
                else if (horiz < -1*LIMIT) // Left
                {
                    left();
                }

                if (vert > LIMIT) // Up
                {
                    up();
                }
                else if (vert < -1*LIMIT) // Down
                {
                    down();
                }
            }

        }