float ToFloat(LightFloat type, ref LightDataEntry e) { switch (type) { case LightFloat.FogDensity: return(e.fogDensity); case LightFloat.FogEnd: return(e.fogEnd); case LightFloat.FogScale: return(e.fogScaler); default: throw new ArgumentException("Light type not supported yet or invalid"); } }
public float GetFloatForTime(LightFloat table, uint time) { int idx; switch (table) { case LightFloat.FogEnd: idx = 0; break; case LightFloat.FogScale: idx = 1; break; default: return(1.0f); } if (idx < 0 || idx >= 2) { return(0.0f); } var timeValues = mFloatTimes[idx]; var colorValues = mFloatTables[idx]; if (timeValues.Count == 0) { return(0.0f); } time %= 2880; if (timeValues[0] > time) { time = timeValues[0]; } if (timeValues.Count == 1) { return(colorValues[0]); } var v1 = 0.0f; var v2 = 0.0f; uint t1 = 0; uint t2 = 0; for (var i = 0; i < timeValues.Count; ++i) { if (i + 1 >= timeValues.Count) { v1 = colorValues[i]; v2 = colorValues[0]; t1 = timeValues[i]; t2 = timeValues[0] + 2880; break; } var ts = timeValues[i]; var te = timeValues[i + 1]; if (ts <= time && te >= time) { t1 = ts; t2 = te; v1 = colorValues[i]; v2 = colorValues[i + 1]; break; } } var diff = t2 - t1; if (diff == 0) { return(v1); } var sat = (time - t1) / (float)diff; return((1 - sat) * v1 + sat * v2); }
float ToFloat(LightFloat type, ref LightDataEntry e) { switch(type) { case LightFloat.FogDensity: return e.fogDensity; case LightFloat.FogEnd: return e.fogEnd; case LightFloat.FogScale: return e.fogScaler; default: throw new ArgumentException("Light type not supported yet or invalid"); } }
public float GetFloat(LightFloat flt) { var idx = (flt == LightFloat.FogEnd) ? 0 : (flt == LightFloat.FogScale ? 1 : -1); return idx < 0 ? 0.0f : mFloats[idx]; }
public float GetFloat(LightFloat flt) { var idx = (flt == LightFloat.FogEnd) ? 0 : (flt == LightFloat.FogScale ? 1 : -1); return(idx < 0 ? 0.0f : mFloats[idx]); }
public float GetFloatForTime(LightFloat table, uint time) { int idx; switch (table) { case LightFloat.FogEnd: idx = 0; break; case LightFloat.FogScale: idx = 1; break; default: return 1.0f; } if (idx < 0 || idx >= 2) return 0.0f; var timeValues = mFloatTimes[idx]; var colorValues = mFloatTables[idx]; if (timeValues.Count == 0) return 0.0f; if (timeValues[0] > time) time = timeValues[0]; if (timeValues.Count == 1) return colorValues[0]; var v1 = 0.0f; var v2 = 0.0f; uint t1 = 0; uint t2 = 0; for (var i = 0; i < timeValues.Count; ++i) { if (i + 1 >= timeValues.Count) { v1 = colorValues[i]; v2 = colorValues[0]; t1 = timeValues[i]; t2 = timeValues[0] + 2880; break; } var ts = timeValues[i]; var te = timeValues[i + 1]; if (ts <= time && te >= time) { t1 = ts; t2 = te; v1 = colorValues[i]; v2 = colorValues[i + 1]; break; } } var diff = t2 - t1; if (diff == 0) return v1; var sat = (time - t1) / (float)diff; return (1 - sat) * v1 + sat * v2; }