public AngleFunc(int nMu, int nPhi, bool nMuHalf) { R = new float[nMu][]; for (int i = 0; i < nMu; i++) { R[i] = new float[nPhi]; } if (!nMuHalf) { var legzoResult = SHMath.Legzo(nMu); Mu = legzoResult.Mu.Select(x => (float)x).ToList(); GaussWeights = legzoResult.Weight.Select(x => (float)x).ToList(); } else { var legzoResult = SHMath.Legzo(nMu * 2); Mu = new List <float>(); GaussWeights = new List <float>(); for (int i = 0; i < nMu; i++) { Mu.Add((float)legzoResult.Mu[i]); GaussWeights.Add((float)legzoResult.Weight[i]); } } Phi = new List <float>(); for (int i = 0; i < nPhi; i++) { Phi.Add((float)(i * 2 * Math.PI / ((double)nPhi - 1))); } }
public MFaceIlluminanceAngles(Vector normal, IMaterial material, IList <float> theta, IList <float> mu, IList <float> phi, IList <double> gaussWeight, int nSH) { Normal = normal; Theta = theta; Mu = mu; Phi = phi; GaussWeight = gaussWeight; NSH = nSH; Qkm = new List <double[][]>(); foreach (var m in Mu) { Qkm.Add(SHMath.Schmidt(m, nSH)); } Directions = new List <Vector>(); foreach (var t in theta) { foreach (var p in phi) { Vector v = new Vector(t, p); v = v.ChangeCoordinateSystem(normal); Directions.Add(v); } } //Тут создаем реальные направления }
private void OnChangeToDie(params object[] pArgs) { InitPhysicsValue(); StopMoveTween(); var pStick = (SHUIWidget_Stick)pArgs[0]; var eCrashDir = Single.Balance.GetDirection(pStick, this); PlayAnim(eDirection.Front, gameObject, (eDirection.Left == eCrashDir) ? m_pDie_Left : m_pDie_Right, null); var eAccuracy = Single.Balance.GetDecision(pStick, this); var iBonusCoin = GetBonusCoin(eAccuracy); SHUtils.For(0, iBonusCoin, (iIndex) => { var pHUD = Single.UI.GetPanel <SHUIPanel_HUD>("Panel_HUD"); Single.Damage.AddDamage("Dmg_Coin", new SHAddDamageParam(this, pHUD.GetCoinTarget(), null, null)); }); if ((0 != iBonusCoin) && (eDecision.Good == eAccuracy)) { PlayParticle("Particle_Crash_Dust_Big"); } else { PlayParticle("Particle_Crash_Dust_Small"); } m_fSpeed = m_pInfo.m_vDieSpeed.magnitude; m_vDirection = m_pInfo.m_vDieSpeed.normalized; m_vDirection.x = (eDirection.Left == eCrashDir) ? -m_vDirection.x : m_vDirection.x; m_vDirection.x *= SHMath.Random(0.0f, 2.0f); }
float GetLoadPrograss() { // 로드할 파일이 없으면 100프로지~ if (false == IsReMainLoadFiles()) { return(100.0f); } float iProgress = 0.0f; SHUtils.ForToDic <string, SHLoadStartInfo>(m_pPrograss.LoadingFiles, (pKey, pValue) => { if (true == m_pPrograss.IsDone(pKey)) { return; } iProgress += pValue.GetPrograss(); }); SHPair <int, int> pCountInfo = m_pPrograss.GetCountInfo(); float fCountGap = SHMath.Divide(100.0f, pCountInfo.Value1); float fComplatePercent = (fCountGap * pCountInfo.Value2); float fProgressPercent = (fCountGap * iProgress); return(fComplatePercent + fProgressPercent); }
void UpdateToTime() { m_fAccTime += Time.deltaTime; if (m_fTimeGap > m_fAccTime) { return; } m_fAccTime = 0.0f; ++m_iCurIndex; switch (m_eWrapMode) { case eWrapMode.Once: Single.Coroutine.NextUpdate(() => Destroy(gameObject)); break; case eWrapMode.ClampToLast: m_bIsStop = (m_iMaxIndex <= m_iCurIndex); break; case eWrapMode.ClampToStart: m_bIsStop = (m_iMaxIndex < m_iCurIndex); break; case eWrapMode.Loop: m_iCurIndex = SHMath.LoopingNumber(m_iCurIndex, 0, m_iMaxIndex); break; } m_iCurIndex = Mathf.Clamp(m_iCurIndex, 0, m_iMaxIndex); }
private float GetRandomFactor() { return(SHMath.RandomN(new List <float>() { 0.0f, 1.0f })); }
public MeshSettings(int maxDivideDeep, int nTheta, int nPhi, int nSH) { MaxDivideDeep = maxDivideDeep; NSH = nSH; var phi0 = -Math.PI; var phi = new List <float>(); for (int i = 0; i < nPhi; i++) { phi.Add((float)(phi0 + (i * 2 * Math.PI / ((double)nPhi - 1)))); } /* * var theta0 = 0; * var theta = new List<float>(); * for ( int i = 0; i < nTheta; i++ ) * theta.Add( (float)( theta0 + i * ( Math.PI / 2 ) / ( (double)nTheta - 1 ) ) ); */ var theta = new List <float>(); var weights = new List <double>(); var legzoResult = SHMath.Legzo(nTheta * 2); for (int i = 0; i < nTheta; i++) { theta.Add((float)Math.Acos(legzoResult.Mu[i])); weights.Add(legzoResult.Weight[i]); } SpectrumAngles = new MSpectrumAngles(theta, phi, weights); }
Spectrum GetIlluminanceBySphericalHarmonics(Vector direction, MVertexIlluminanceMode mode) { var directionProjected = Face.Normal.Projected(direction); var sphCoord = directionProjected.ToSphCoord(); double valR = 0; double valG = 0; double valB = 0; var mu = (float)Math.Cos(sphCoord.Theta); var phi = (float)sphCoord.Phi; var qkm = SHMath.Schmidt(mu, IlluminanceAngles.NSH); if (mode == MVertexIlluminanceMode.Full || mode == MVertexIlluminanceMode.Direct) { valR += SHMath.SHToAF(directIlluminanceSHR, mu, phi, qkm); valG += SHMath.SHToAF(directIlluminanceSHG, mu, phi, qkm); valB += SHMath.SHToAF(directIlluminanceSHB, mu, phi, qkm); } if (mode == MVertexIlluminanceMode.Full || mode == MVertexIlluminanceMode.Indirect) { valR += SHMath.SHToAF(indirectIlluminanceSHR, mu, phi, qkm); valG += SHMath.SHToAF(indirectIlluminanceSHG, mu, phi, qkm); valB += SHMath.SHToAF(indirectIlluminanceSHB, mu, phi, qkm); } return(new Spectrum((float)valR, (float)valG, (float)valB)); }
public eMonsterType GenMonsterType() { if (0.1 >= SHMath.Random(0.0f, 1.0f)) { return(eMonsterType.Monster_Bonus); } return(SHMath.RandomN(Single.Inventory.GetEnableMonstersForDic())); }
void Initialize() { m_iMaxIndex = m_iTileCntX * m_iTileCntY; m_bIsStop = false; m_fAccTime = 0.0f; m_iCurIndex = 0; m_vTileSize = new Vector2(SHMath.Divide(1.0f, (float)m_iTileCntX), SHMath.Divide(1.0f, (float)m_iTileCntY)); }
public eMonsterType GenMonsterTypeForFirst() { var eFirstMon = eMonsterType.Monster_4; if (false == Single.Inventory.IsEnableMonsterToPlayerPrefs(eFirstMon)) { eFirstMon = SHMath.RandomN(Single.Inventory.GetEnableMonstersForDic()); } return(eFirstMon); }
public int GetBonusCoin(eDecision eDec) { switch (eDec) { case eDecision.Bad: return(m_pInfo.m_iMinCoin); case eDecision.Normal: return(SHMath.Lerp(m_pInfo.m_iMinCoin, m_pInfo.m_iMaxCoin, 0.5f)); case eDecision.Good: return(m_pInfo.m_iMaxCoin); } return(0); }
private void CheckCreateMonster() { if (0 != m_pMonsters.Count) { return; } var pMonster = CreateMonster( Single.Balance.GenMonsterType(), GetRandomFactor(), SHMath.Random(MIN_CREATE_POS_Y, MAX_CREATE_POS_Y)); pMonster.PlayMoveTween(); AddMonster(pMonster); }
void OnEventToPrograss(object pSender, EventArgs vArgs) { var pInfo = Single.Event.GetArgs <SHLoadEvent>(vArgs); if (null == pInfo) { return; } // 어싱크 프로그래스 if (true == pInfo.m_bIsAsyncPrograss) { Debug.Log(string.Format("로드 진행상황 어싱크 체커(" + "Percent:<color=yellow>{0}</color>, " + "Count:<color=yellow>{1}/{2}</color>)", pInfo.m_fPercent, pInfo.m_pCount.Value2, pInfo.m_pCount.Value1)); return; } // 싱크 프로그래스 if (false == pInfo.m_bIsSuccess) { Debug.LogError(string.Format("<color=red>데이터 로드실패</color>(" + "Type:<color=yellow>{0}</color>, " + "Percent:<color=yellow>{2}%</color>, " + "현재Time:<color=yellow>{3}sec</color>, " + "전체Time:<color=yellow>{4}sec</color>" + "Name:<color=yellow>{1}</color>)", pInfo.m_eType, pInfo.m_strFileName, pInfo.m_fPercent, SHMath.Round(pInfo.m_pTime.Value2, 3), SHMath.Round(pInfo.m_pTime.Value1, 2))); } else { Debug.Log(string.Format("데이터 로드성공(" + "Type:<color=yellow>{0}</color>, " + "Percent:<color=yellow>{2}%</color>, " + "현재Time:<color=yellow>{3}sec</color>, " + "전체Time:<color=yellow>{4}sec</color>" + "Name:<color=yellow>{1}</color>)", pInfo.m_eType, pInfo.m_strFileName, pInfo.m_fPercent, SHMath.Round(pInfo.m_pTime.Value2, 3), SHMath.Round(pInfo.m_pTime.Value1, 2))); } }
void SetupPhysicsValue() { InitPhysicsValue(); m_fSpeed = m_pInfo.m_fStartSpeed; if (true == m_pInfo.m_bIsRandomStartDirection) { m_vDirection = SHMath.RandomDirection(); } else { m_vDirection = m_pInfo.m_vStartDirection; } m_pBeforeBounds = GetCollider().bounds; }
void CheckCollision(SHDamageObject pDamage) { if (null == pDamage) { return; } if (false == pDamage.IsCheckCrash()) { return; } SHUtils.ForToList(GetTargets(pDamage), (pTarget) => { var pDamageCollider = pDamage.GetCollider(); var pTargetCollider = pTarget.GetCollider(); if ((null == pDamageCollider) || (null == pTargetCollider)) { return; } var bIsCollistion = false; var bBounds = pDamage.m_pBeforeBounds; for (float fRatio = 0.0f; fRatio <= 1.0f; fRatio += 0.1f) { bBounds.center = SHMath.Lerp(pDamage.m_pBeforeBounds.center, pDamageCollider.bounds.center, fRatio); if (true == bBounds.Intersects(pTargetCollider.bounds)) { bIsCollistion = true; break; } } if (false == bIsCollistion) { return; } pTarget.OnCrashDamage(pDamage); pDamage.OnCrashDamage(pTarget); }); }
public eDirection GetDirection(SHUIWidget_Stick pStick, SHUIWidget_Monster pMonster) { if ((null != pStick) && (null != pMonster)) { if (pMonster.GetLocalPosition().x < pStick.GetLocalPosition().x) { return(eDirection.Left); } if (pMonster.GetLocalPosition().x > pStick.GetLocalPosition().x) { return(eDirection.Right); } } return(SHMath.RandomN(new List <eDirection>() { eDirection.Left, eDirection.Right, })); }
public void UpdateStatistics() { var directIlluminanceArrays = IlluminanceAngles.IlluminanceToArrays(IlluminanceDirect); var indirectIlluminanceArrays = IlluminanceAngles.IlluminanceToArrays(IlluminanceIndirect); var arrT = IlluminanceAngles.Theta.Select(x => (double)x).ToArray(); var arrP = IlluminanceAngles.Phi.Select(x => (double)x).ToArray(); alglib.spline2dbuildbicubic(arrP, arrT, directIlluminanceArrays.R, arrT.Length, arrP.Length, out directIlluminanceSplineCoeffsR); alglib.spline2dbuildbicubic(arrP, arrT, directIlluminanceArrays.G, arrT.Length, arrP.Length, out directIlluminanceSplineCoeffsG); alglib.spline2dbuildbicubic(arrP, arrT, directIlluminanceArrays.B, arrT.Length, arrP.Length, out directIlluminanceSplineCoeffsB); alglib.spline2dbuildbicubic(arrP, arrT, indirectIlluminanceArrays.R, arrT.Length, arrP.Length, out indirectIlluminanceSplineCoeffsR); alglib.spline2dbuildbicubic(arrP, arrT, indirectIlluminanceArrays.G, arrT.Length, arrP.Length, out indirectIlluminanceSplineCoeffsG); alglib.spline2dbuildbicubic(arrP, arrT, indirectIlluminanceArrays.B, arrT.Length, arrP.Length, out indirectIlluminanceSplineCoeffsB); directIlluminanceSHR = SHMath.AFToSH(directIlluminanceArrays.R, IlluminanceAngles.Mu, IlluminanceAngles.Phi, IlluminanceAngles.NSH, IlluminanceAngles.GaussWeight, IlluminanceAngles.Qkm); directIlluminanceSHG = SHMath.AFToSH(directIlluminanceArrays.G, IlluminanceAngles.Mu, IlluminanceAngles.Phi, IlluminanceAngles.NSH, IlluminanceAngles.GaussWeight, IlluminanceAngles.Qkm); directIlluminanceSHB = SHMath.AFToSH(directIlluminanceArrays.B, IlluminanceAngles.Mu, IlluminanceAngles.Phi, IlluminanceAngles.NSH, IlluminanceAngles.GaussWeight, IlluminanceAngles.Qkm); indirectIlluminanceSHR = SHMath.AFToSH(indirectIlluminanceArrays.R, IlluminanceAngles.Mu, IlluminanceAngles.Phi, IlluminanceAngles.NSH, IlluminanceAngles.GaussWeight, IlluminanceAngles.Qkm); indirectIlluminanceSHG = SHMath.AFToSH(indirectIlluminanceArrays.G, IlluminanceAngles.Mu, IlluminanceAngles.Phi, IlluminanceAngles.NSH, IlluminanceAngles.GaussWeight, IlluminanceAngles.Qkm); indirectIlluminanceSHB = SHMath.AFToSH(indirectIlluminanceArrays.B, IlluminanceAngles.Mu, IlluminanceAngles.Phi, IlluminanceAngles.NSH, IlluminanceAngles.GaussWeight, IlluminanceAngles.Qkm); /* * for ( int it = 0; it < arrT.Length; it++ ) * for ( int ip = 0; ip < arrP.Length; ip++ ) * { * var val = alglib.spline2dcalc( directIlluminanceSplineCoeffsR, arrP[ip], arrT[it] ); * if ( val > 0.00001 ) * { * var error = directIlluminanceArrays.R[it, ip] - val; * if ( Math.Abs( error ) > 0.000001 ) * throw new Exception( "aaa" ); * } * } */ }
public float GetMonsterSpeed() { var iLevel = (int)(Single.ScoreBoard.m_iScore / 10.0f); var pWeight = new List <float>(); switch (iLevel) { case 0: pWeight = new List <float>() { 1.00f, 0.90f, 0.30f, 0.10f, 0.00f, 0.00f }; break; case 1: pWeight = new List <float>() { 0.90f, 0.80f, 0.40f, 0.20f, 0.10f, 0.00f }; break; case 2: pWeight = new List <float>() { 0.80f, 0.70f, 0.40f, 0.30f, 0.20f, 0.10f }; break; case 3: pWeight = new List <float>() { 0.70f, 0.60f, 0.40f, 0.40f, 0.30f, 0.20f }; break; case 4: pWeight = new List <float>() { 0.60f, 0.50f, 0.40f, 0.40f, 0.30f, 0.30f }; break; case 5: pWeight = new List <float>() { 0.50f, 0.40f, 0.50f, 0.40f, 0.40f, 0.30f }; break; case 6: pWeight = new List <float>() { 0.40f, 0.30f, 0.50f, 0.50f, 0.40f, 0.40f }; break; case 7: pWeight = new List <float>() { 0.30f, 0.20f, 0.50f, 0.50f, 0.40f, 0.40f }; break; case 8: pWeight = new List <float>() { 0.20f, 0.10f, 0.50f, 0.50f, 0.50f, 0.50f }; break; case 9: pWeight = new List <float>() { 0.10f, 0.10f, 0.50f, 0.60f, 0.50f, 0.50f }; break; default: pWeight = new List <float>() { 0.10f, 0.10f, 0.60f, 0.60f, 0.50f, 0.70f }; break; } return(SHMath.RandomW(new List <float>() { 1.00f, 0.90f, 0.80f, 0.70f, 0.60f, 0.50f }, pWeight)); }