+
This commit is contained in:
@ -81,16 +81,28 @@ namespace DroneSimulator
|
||||
return mem;
|
||||
}
|
||||
|
||||
public struct DataVisual
|
||||
public VisualData.VisualDrone GetVisual(int count, int index)
|
||||
{
|
||||
public int ID; // Идентификатор
|
||||
public float W, X, Y, Z; // Кватернион вращения
|
||||
public float PosX, PosY, PosZ; // Координаты в пространстве
|
||||
}
|
||||
VisualData.VisualDrone drone = new VisualData.VisualDrone();
|
||||
|
||||
public DataVisual GetVisual()
|
||||
{
|
||||
return new DataVisual() { ID = this.ID, W = this.Quat.W, X = this.Quat.X, Y = this.Quat.Y, Z = this.Quat.Z, PosX = this.PosXYZ.X, PosY = this.PosXYZ.Y, PosZ = this.PosXYZ.Z };
|
||||
drone.Head.Size = Marshal.SizeOf(typeof(VisualData.VisualDrone));
|
||||
drone.Head.Type = VisualData.VisualHead.VisualType.Drone;
|
||||
|
||||
drone.Count = count;
|
||||
drone.Index = index;
|
||||
|
||||
drone.ID = ID;
|
||||
drone.Color.A = 255; drone.Color.R = 255; drone.Color.G = 0; drone.Color.B = 0;
|
||||
|
||||
drone.Rotate.X = Quat.X; drone.Rotate.Y = Quat.Y; drone.Rotate.Z = Quat.Z; drone.Rotate.W = Quat.W;
|
||||
drone.Position.X = PosXYZ.X; drone.Position.Y = PosXYZ.Y; drone.Position.Z = PosXYZ.Z;
|
||||
drone.Scale = 1.0f;
|
||||
|
||||
drone.State = VisualData.VisualDrone.DroneState.Active;
|
||||
|
||||
drone.Power = Power;
|
||||
|
||||
return drone;
|
||||
}
|
||||
|
||||
private void ThreadFunction()
|
||||
@ -189,7 +201,7 @@ namespace DroneSimulator
|
||||
|
||||
SpdPRY += AccPRY * (Dynamic * time / (Mass * Length));
|
||||
|
||||
float wind_x = 0, wind_y = 0;
|
||||
float wind_x = 0, wind_y = 0, wind_z = 0;
|
||||
|
||||
if (Area.Wind.Enable)
|
||||
{
|
||||
@ -201,13 +213,15 @@ namespace DroneSimulator
|
||||
|
||||
float spd_x = spd.X - SpdXYZ.X;
|
||||
float spd_y = spd.Y - SpdXYZ.Y;
|
||||
float spd_z = spd.Z - SpdXYZ.Z;
|
||||
|
||||
wind_x = 0.5f * Area.Wind.Density * Area.Wind.Resist * (spd_x * MathF.Abs(spd_x));
|
||||
wind_y = 0.5f * Area.Wind.Density * Area.Wind.Resist * (spd_y * MathF.Abs(spd_y));
|
||||
wind_z = 0.5f * Area.Wind.Density * Area.Wind.Resist * (spd_z * MathF.Abs(spd_z));
|
||||
}
|
||||
|
||||
Quaternion pow = Quaternion.Inverse(Quat) * new Quaternion(0, 0, flow, 0) * Quat;
|
||||
AccXYZ = new Vector3(pow.X + wind_x, pow.Y + wind_y, pow.Z) * (Gravity / Mass);
|
||||
AccXYZ = new Vector3(pow.X + wind_x, pow.Y + wind_y, pow.Z + wind_z) * (Gravity / Mass);
|
||||
SpdXYZ += (AccXYZ + new Vector3(0, 0, -Gravity)) * time;
|
||||
PosXYZ += SpdXYZ * time;
|
||||
|
||||
|
Reference in New Issue
Block a user