public NiPSysMeshEmitter() { numEmitterMeshes = (uint)0; initialVelocityType = (VelocityType)0; emissionType = (EmitFrom)0; emissionAxis = 1.0, 0.0, 0.0; }
public void Activity() { int incrementAmount = 25; switch (mVelocityType) { case VelocityType.Add: if (Color.R < 255) { Color.R = (byte)Math.Min(255, Color.R + incrementAmount); } else { mVelocityType = VelocityType.Subtract; } break; case VelocityType.Subtract: if (Color.R > 0) { Color.R = (byte)Math.Max(0, Color.R - incrementAmount); } else { mVelocityType = VelocityType.Add; } break; } Color.G = Color.R; Color.B = Color.R; }
public void Activity() { int incrementAmount = 25; switch (mVelocityType) { case VelocityType.Add: if (Color.R < 255) { Color.R = (byte)Math.Min(255, Color.R + incrementAmount); } else { mVelocityType = VelocityType.Subtract; } break; case VelocityType.Subtract: if (Color.R > 0) { Color.R = (byte)Math.Max(0, Color.R - incrementAmount); } else { mVelocityType = VelocityType.Add; } break; } Color.G = Color.R; Color.B = Color.R; }
public NiPSMeshEmitter() { numMeshEmitters = (uint)0; emitterObject = null; meshEmissionType = (EmitFrom)0; initialVelocityType = (VelocityType)0; }
public virtual Vector2 GetMaxComponentVelocity(VelocityType type) { if (!_maxComponentVelocities.ContainsKey(type)) { _maxComponentVelocities.Add(type, _maxDefaultComponentSpeed); } return(_maxComponentVelocities[type]); }
public override void UpdateVelocity(VelocityType id, Vector2 vel) { if (!_velocities.ContainsKey(id)) { _velocities.Add(id, vel); } _velocities[id] = vel; }
public Vector2 GetVelocity(VelocityType id) { if (!_velocities.ContainsKey(id)) { _velocities.Add(id, Vector2.zero); } return(_velocities[id]); }
protected override void GenerateMessage() { try { micomWritingData = GetMessageData <messages.Param>(); } catch { Debug.LogWarning("GetMessageData: ERROR"); } if (micomWritingData.Name.Equals("control") && micomWritingData.Childrens.Count == 2) { var child0 = micomWritingData.Childrens[0]; var child1 = micomWritingData.Childrens[1]; // Set reversed value due to differnt direction // Right-handed -> Left-handed direction of rotation if (micomWritingData.Value.IntValue == 0) { controlType = VelocityType.LinearAndAngular; linearVelocity = (!child0.Name.Equals("LinearVelocity")) ? 0 : (float)-child0.Value.DoubleValue; angularVelocity = (!child1.Name.Equals("AngularVelocity")) ? 0 : (float)-child1.Value.DoubleValue; // Debug.Log(linearVelocity.ToString("F10") + ", " + (-child0.Value.DoubleValue).ToString("F10") + " | " + angularVelocity.ToString("F10") + ", " + (-child1.Value.DoubleValue).ToString("F10")); } else if (micomWritingData.Value.IntValue == 1) { controlType = VelocityType.LeftAndRight; wheelLinearVelocityLeft = (!child0.Name.Equals("LeftWheelVelocity")) ? 0 : (float)-child0.Value.DoubleValue; wheelLinearVelocityRight = (!child1.Name.Equals("RightWheelVelocity")) ? 0 : (float)-child1.Value.DoubleValue; } else { controlType = VelocityType.Unknown; Debug.LogWarningFormat("MicomInput: Unsupported Control Type({0}", controlType); } } else if (micomWritingData.Name.Equals("command")) { if (micomWritingData.Value.StringValue.Equals("reset_odometry")) { micomForWheelDrive.Reset(); Debug.Log("MicomInput::command(reset_odometry)"); } } }
public void SetVelocity(Vector3 vel, VelocityType type) { if (type == VelocityType.Default) { SetVelocity(vel); return; } limitedVelocity = vel; limitedVelocity = limitedVelocity.Clamp(-limitedVelocity_limit, limitedVelocity_limit); }
void FormatFixed() { #region VelocityTypeDemo2_FormatFixed Debug.Log(VelocityType.Format(1234.5678, format: "0.0000")); // Prints: "1234.5678m/s" Debug.Log(VelocityType.Format(1234.5678, format: "0.00")); // Prints: "1234.57m/s" Debug.Log(VelocityType.Format(1234.5678, format: "#,##0.00")); // Prints: "1,234.57m/s" #endregion }
public void AddVelocity(Vector3 vel, VelocityType type) { if (type == VelocityType.Default) { AddVelocity(vel); return; } // Add limited velocity limitedVelocity += vel; limitedVelocity = limitedVelocity.Clamp(-limitedVelocity_limit, limitedVelocity); }
public virtual void AddVelocity(VelocityType id, Vector2 velocityVector) { var velocityDelta = velocityVector; var tempVel = GetVelocity(id) + velocityDelta; var maxComponentSpeed = GetMaxComponentVelocity(id); if (tempVel.magnitude > maxComponentSpeed.magnitude) { tempVel = tempVel.normalized * maxComponentSpeed.magnitude; } _velocities[id] = tempVel; }
void FormatDefault() { #region VelocityTypeDemo2_FormatDefault Debug.Log(VelocityType.Format(0.051)); // Prints: "Speed is: 0.051m/s" Debug.Log(VelocityType.Format(0.45)); // Prints: "Speed is: 0.45m/s" Debug.Log(VelocityType.Format(95.45)); // Prints: "Speed is: 95.5m/s" Debug.Log(VelocityType.Format(120.45)); // Prints: "Speed is: 121m/s" Debug.Log(VelocityType.Format(9535.45)); // Prints: "Speed is: 9.54km/s" #endregion }
protected override void GenerateMessage() { try { micomWritingData = GetMessageData <messages.Param>(); } catch { Debug.LogWarning("GetMessageData: ERROR"); } if (micomWritingData.Name.Equals("control_type") && micomWritingData.Childrens.Count == 2) { var child0 = micomWritingData.Childrens[0]; var child1 = micomWritingData.Childrens[1]; if (micomWritingData.Value.IntValue == 0) { controlType = VelocityType.LinearAndAngular; linearVelocity = (!child0.Name.Equals("LinearVelocity")) ? 0 : (float)child0.Value.DoubleValue; angularVelocity = (!child1.Name.Equals("AngularVelocity")) ? 0 : (float)child1.Value.DoubleValue; } else if (micomWritingData.Value.IntValue == 1) { controlType = VelocityType.LeftAndRight; wheelLinearVelocityLeft = (!child0.Name.Equals("LeftWheelVelocity")) ? 0 : (float)child0.Value.DoubleValue; wheelLinearVelocityRight = (!child1.Name.Equals("RightWheelVelocity")) ? 0 : (float)child1.Value.DoubleValue; } else { controlType = VelocityType.Unknown; Debug.LogWarningFormat("MicomInput: Unsupported Control Type({0}", controlType); } } }
public static T SetVelocityType <T>(this T entity, VelocityType value) where T : EffectDescription { entity.SetField("velocityType", value); return(entity); }
public void UpdateGORBVelocity(GravityObjectRigidBody GORB, VelocityType type, Vector2 dir) { GORB.UpdateVelocity(type, dir); }
public string GetNowcastingData() { try { GetRegistrationInfo(); TimeZone zone = TimeZone.CurrentTimeZone; DateTime dNowDate = DateTime.Now.ToUniversalTime(); TimeSpan mySpan = dNowDate.Subtract(new DateTime(1970, 1, 1)); //DateDiff("s", "1/1/1970", dNowDate) int iStartTime = (int)mySpan.TotalSeconds; Initialize(); string sBlockString = GetGridBlocks2(); int dDifference1, dDifference2; string sPArc = ""; int iLFT = 0, iLUT = 0, iNDP = m_iDataType, lFCHours = 0; if ((m_dteStartTime < dNowDate) && (m_dteEndTime < dNowDate)) //both archive times { mySpan = m_dteStartTime.Subtract(dNowDate); dDifference1 = (int)mySpan.TotalHours; mySpan = m_dteEndTime.Subtract(dNowDate); dDifference2 = (int)mySpan.TotalHours; if (dDifference1 < m_cNCMaxArchive) { dDifference1 = m_cNCMaxArchive; } for (int i = dDifference1; i <= dDifference2; i++) { sPArc += i.ToString() + ","; } if (sPArc != "") { sPArc = sPArc.Substring(0, sPArc.Length - 1) + (char)0; } lFCHours = 0; } else if ((m_dteStartTime < dNowDate) && (m_dteEndTime >= dNowDate)) //starts off in the past, then needs forecast data { mySpan = m_dteEndTime.Subtract(dNowDate); dDifference2 = (int)mySpan.TotalHours; //get archive data, then determine how much forecast data to get if (dDifference2 < 24) { lFCHours = 1; } else if ((dDifference2 >= 24) && (dDifference2 < 48)) { lFCHours = 2; } else if (dDifference2 >= 48) { lFCHours = 3; } mySpan = m_dteStartTime.Subtract(dNowDate); dDifference1 = (int)mySpan.TotalHours; if (dDifference1 < m_cNCMaxArchive) { dDifference1 = m_cNCMaxArchive; } sPArc = ""; for (int irec = dDifference1; irec <= -1; irec++) { sPArc += irec.ToString() + ","; } if (sPArc != "") { sPArc = sPArc.Substring(0, sPArc.Length - 1) + (char)0; } } else //only need forecast data, determine how much to get { mySpan = m_dteEndTime.Subtract(dNowDate); dDifference2 = (int)mySpan.TotalHours; if (dDifference2 < 24) { lFCHours = 1; } else if ((dDifference2 >= 24) && (dDifference2 < 48)) { lFCHours = 2; } else if (dDifference2 >= 48) { lFCHours = 3; } sPArc = "" + (char)0; } int m_lResult; m_lResult = CreateProRequestB(m_sCompany, m_sCompany.Length, m_sUser, m_sUser.Length, m_sPass, m_sPass.Length, iStartTime, iLFT, iLUT, iNDP, lFCHours, sBlockString, sBlockString.Length, sPArc, sPArc.Length); m_lResult = MakeTheRequest(m_sWebadd, m_sWebadd.Length, m_iUseProxy, m_sProxyadd, m_sProxyadd.Length, m_iThePort, m_sProxyUser, m_sProxyUser.Length, m_sProxyPass, m_sProxyPass.Length, m_iProxyAuth, m_iDoDisconn); if (m_lResult != 0) { throw new Exception(String.Format("MakeTheRequest:\r\n{0}\r\n{1}\r\n{2}\r\n{3}\r\n{4}\r\n{5}\r\n{6}\r\n{7}\r\n{8}\r\n{9}\r\n{10}", GetNowcastError(m_lResult), m_sCompany, m_sUser, m_sPass, iStartTime, iLFT, iLUT, iNDP, lFCHours, sBlockString, sPArc)); } m_lResult = InterpretData(); if (m_lResult != 0) { throw new Exception("InterpretData:\r\n" + GetNowcastError(m_lResult)); } int lTotalRec = 0; m_lResult = GetTotalRecords(ref lTotalRec); if (m_lResult != 0) { throw new Exception("GetTotalRecords:\r\n" + GetNowcastError(m_lResult)); } if (lTotalRec == 0) { return(""); } List <string> aPos = new List <string>(); List <int> aTimes = new List <int>(); byte byDT = 0; float sgLat = 0, sgLon = 0, sgV1 = 0, sgV2 = 0; int lFT = 0; string sCurrentPos; for (int irec = 1; irec <= lTotalRec; irec++) { GetARecord(irec, ref byDT, ref sgLat, ref sgLon, ref lFT, ref sgV1, ref sgV2); sCurrentPos = sgLat.ToString() + sgLon.ToString(); if (!(aPos.Contains(sCurrentPos))) //current position hasn't been put in yet { aPos.Add(sCurrentPos); } } int[] iCellID = new int[] { 0 }; float[] fLat = new float[] { 0 }; float[] fLon = new float[] { 0 }; int[] iTimeID = new int[] { 0 }; int[] iTime = new int[] { 0 }; float[] iVal = new float[] { 0 }; int[] aIndex = new int[2]; int lTimeVarID = 0, lCellVarID = 0; int lLatVarID = 0, lLonVarID = 0; int lUID = 0, lVID = 0; int lID = CreateDefaultNCFile(m_sFilename, aPos.Count, ref lTimeVarID, ref lCellVarID, ref lLatVarID, ref lLonVarID, ref lUID, ref lVID); int iResult = 0; aPos.Clear(); for (int irec = 1; irec <= lTotalRec; irec++) { GetARecord(irec, ref byDT, ref sgLat, ref sgLon, ref lFT, ref sgV1, ref sgV2); sCurrentPos = sgLat.ToString() + sgLon.ToString(); if (!(aPos.Contains(sCurrentPos))) //current position hasn't been put in yet { iCellID[0] = aPos.Count; iResult = NetCDF.nc_put_var1_int(lID, lCellVarID, iCellID, iCellID); fLat[0] = sgLat; iResult = NetCDF.nc_put_var1_float(lID, lLatVarID, iCellID, fLat); fLon[0] = sgLon; iResult = NetCDF.nc_put_var1_float(lID, lLonVarID, iCellID, fLon); aPos.Add(sCurrentPos); } if (!(aTimes.Contains(lFT))) //current time hasn't been added { iTimeID[0] = aTimes.Count; iTime[0] = lFT; iResult = NetCDF.nc_put_var1_int(lID, lTimeVarID, iTimeID, iTime); aTimes.Add(lFT); } aIndex[0] = aTimes.IndexOf(lFT); aIndex[1] = aPos.IndexOf(sCurrentPos); switch (m_iDataType) { case m_cWinds: sgV1 = mps2knots(sgV1); sgV2 += 180; break; case m_cCurrents: sgV1 = kmph2knots(sgV1); break; } VelocityType tVelocity = GetVVectors(sgV2, sgV1); iVal[0] = tVelocity.u; iResult = NetCDF.nc_put_var1_float(lID, lUID, aIndex, iVal); iVal[0] = tVelocity.v; iResult = NetCDF.nc_put_var1_float(lID, lVID, aIndex, iVal); } NetCDF.nc_close(lID); } catch (Exception ex) { m_sFilename = ""; } finally { ResetForNewRequest(); Finalize(); } return(m_sFilename); }
/// <summary> /// Given a VelocityType (ScenCon defined object), a new DataValue is created, and assigned as a /// VelocityValue. This LocationValue's coordinate settings are set to the input /// VelocityType, and then the VelocityType is returned as a DataValue. /// </summary> /// <param name="input"> /// A VelocityType object, whose coordinates are assigned to a VelocityValue. /// </param> /// <returns> ///</returns> private static DataValue ConvertVelocity(VelocityType input) {//Replaced by method in DataValueFactory... DataValue dv = new VelocityValue(); ((VelocityValue)dv).VX = input.VX; ((VelocityValue)dv).VY = input.VY; ((VelocityValue)dv).VZ = input.VZ; return dv; }
public override void AddVelocity(VelocityType id, Vector2 velocityVector) { base.AddVelocity(id, velocityVector * _speedMultiplier); }
public override Vector2 GetMaxComponentVelocity(VelocityType type) { return(base.GetMaxComponentVelocity(type) * _speedMultiplier); }
public void AddLinearAcceleration(VelocityType id, Vector2 AccelerationVector) { AddVelocity(id, AccelerationVector * Time.fixedDeltaTime); }