Here are the examples of the csharp api System.Collections.Generic.List.Add(Vector2) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
804 Examples
19
Source : EventMap.cs
with GNU General Public License v3.0
from deathkiller
with GNU General Public License v3.0
from deathkiller
private void AddWarpTarget(uint id, int x, int y)
{
List<Vector2> targets;
if (!warpTargets.TryGetValue(id, out targets)) {
targets = new List<Vector2>();
warpTargets[id] = targets;
}
targets.Add(new Vector2(x * 32 + 16, y * 32 + 12));
}
19
Source : EventMap.cs
with GNU General Public License v3.0
from deathkiller
with GNU General Public License v3.0
from deathkiller
private void AddSpawnPosition(PlayerType type, int x, int y)
{
List<Vector2> targets;
if (!spawnPositions.TryGetValue(type, out targets)) {
targets = new List<Vector2>();
spawnPositions[type] = targets;
}
targets.Add(new Vector2(32 * x + 16, 32 * y + 16 - 8));
}
19
Source : OBJLoader.cs
with Apache License 2.0
from decentraland
with Apache License 2.0
from decentraland
public static GameObject LoadOBJFile(string filePath, bool inputIsRawOBJ = false)
{
string meshName = !inputIsRawOBJ ? Path.GetFileNameWithoutExtension(filePath) : "LoadedOBJMesh";
bool hasNormals = false;
//OBJ LISTS
List<Vector3> vertices = new List<Vector3>();
List<Vector3> normals = new List<Vector3>();
List<Vector2> uvs = new List<Vector2>();
//UMESH LISTS
List<Vector3> uvertices = new List<Vector3>();
List<Vector3> unormals = new List<Vector3>();
List<Vector2> uuvs = new List<Vector2>();
//MESH CONSTRUCTION
List<string> materialNames = new List<string>();
List<string> objectNames = new List<string>();
Dictionary<string, int> hashtable = new Dictionary<string, int>();
List<OBJFace> faceList = new List<OBJFace>();
string cmaterial = "";
string cmesh = "default";
//CACHE
Material[] materialCache = null;
//save this info for later
FileInfo OBJFileInfo = null;
string[] OBJLines;
if (!inputIsRawOBJ)
{
OBJFileInfo = new FileInfo(filePath);
OBJLines = File.ReadAllLines(filePath);
}
else
{
OBJLines = filePath.Split(new[] { "\r", "\n" }, StringSplitOptions.None);
}
foreach (string ln in OBJLines)
{
if (ln.Length > 0 && ln[0] != '#')
{
string l = ln.Trim().Replace(" ", " ");
string[] cmps = l.Split(' ');
string data = l.Remove(0, l.IndexOf(' ') + 1);
if (cmps[0] == "mtllib" && !inputIsRawOBJ && OBJFileInfo != null)
{
//load cache
string pth = OBJGetFilePath(data, OBJFileInfo.Directory.FullName + Path.DirectorySeparatorChar, meshName);
if (pth != null)
{
materialCache = LoadMTLFile(pth);
}
}
else if ((cmps[0] == "g" || cmps[0] == "o") && splitByMaterial == false)
{
cmesh = data;
if (!objectNames.Contains(cmesh))
{
objectNames.Add(cmesh);
}
}
else if (cmps[0] == "usemtl")
{
cmaterial = data;
if (!materialNames.Contains(cmaterial))
{
materialNames.Add(cmaterial);
}
if (splitByMaterial)
{
if (!objectNames.Contains(cmaterial))
{
objectNames.Add(cmaterial);
}
}
}
else if (cmps[0] == "v")
{
//VERTEX
vertices.Add(ParseVectorFromCMPS(cmps));
}
else if (cmps[0] == "vn")
{
//VERTEX NORMAL
normals.Add(ParseVectorFromCMPS(cmps));
}
else if (cmps[0] == "vt")
{
//VERTEX UV
uvs.Add(ParseVectorFromCMPS(cmps));
}
else if (cmps[0] == "f")
{
int[] indexes = new int[cmps.Length - 1];
for (int i = 1; i < cmps.Length; i++)
{
string felement = cmps[i];
int vertexIndex = -1;
int normalIndex = -1;
int uvIndex = -1;
if (felement.Contains("//"))
{
//doubleslash, no UVS.
string[] elementComps = felement.Split('/');
vertexIndex = int.Parse(elementComps[0]) - 1;
normalIndex = int.Parse(elementComps[2]) - 1;
}
else if (felement.Count(x => x == '/') == 2)
{
//contains everything
string[] elementComps = felement.Split('/');
vertexIndex = int.Parse(elementComps[0]) - 1;
uvIndex = int.Parse(elementComps[1]) - 1;
normalIndex = int.Parse(elementComps[2]) - 1;
}
else if (!felement.Contains("/"))
{
//just vertex inedx
vertexIndex = int.Parse(felement) - 1;
}
else
{
//vertex and uv
string[] elementComps = felement.Split('/');
vertexIndex = int.Parse(elementComps[0]) - 1;
uvIndex = int.Parse(elementComps[1]) - 1;
}
string hashEntry = vertexIndex + "|" + normalIndex + "|" + uvIndex;
if (hashtable.ContainsKey(hashEntry))
{
indexes[i - 1] = hashtable[hashEntry];
}
else
{
//create a new hash entry
indexes[i - 1] = hashtable.Count;
hashtable[hashEntry] = hashtable.Count;
uvertices.Add(vertices[vertexIndex]);
if (normalIndex < 0 || (normalIndex > (normals.Count - 1)))
{
unormals.Add(Vector3.zero);
}
else
{
hasNormals = true;
unormals.Add(normals[normalIndex]);
}
if (uvIndex < 0 || (uvIndex > (uvs.Count - 1)))
{
uuvs.Add(Vector2.zero);
}
else
{
uuvs.Add(uvs[uvIndex]);
}
}
}
if (indexes.Length < 5 && indexes.Length >= 3)
{
OBJFace f1 = new OBJFace();
f1.materialName = cmaterial;
f1.indexes = new int[] { indexes[0], indexes[1], indexes[2] };
f1.meshName = (splitByMaterial) ? cmaterial : cmesh;
faceList.Add(f1);
if (indexes.Length > 3)
{
OBJFace f2 = new OBJFace();
f2.materialName = cmaterial;
f2.meshName = (splitByMaterial) ? cmaterial : cmesh;
f2.indexes = new int[] { indexes[2], indexes[3], indexes[0] };
faceList.Add(f2);
}
}
}
}
}
if (objectNames.Count == 0)
{
objectNames.Add("default");
}
//build objects
GameObject parentObject = new GameObject(meshName);
for (int objectNamesIndex = 0; objectNamesIndex < objectNames.Count; objectNamesIndex++)
{
string obj = objectNames[objectNamesIndex];
GameObject subObjectParent = new GameObject(obj);
subObjectParent.transform.parent = parentObject.transform;
GameObject subObject = new GameObject("ChildMesh");
subObject.transform.parent = subObjectParent.transform;
subObject.transform.localScale = new Vector3(-1, 1, 1);
//Create mesh
Mesh m = new Mesh();
m.name = obj;
//LISTS FOR REORDERING
List<Vector3> processedVertices = new List<Vector3>();
List<Vector3> processedNormals = new List<Vector3>();
List<Vector2> processedUVs = new List<Vector2>();
List<int[]> processedIndexes = new List<int[]>();
Dictionary<int, int> remapTable = new Dictionary<int, int>();
//POPULATE MESH
List<string> meshMaterialNames = new List<string>();
OBJFace[] ofaces = faceList.Where(x => x.meshName == obj).ToArray();
foreach (string mn in materialNames)
{
OBJFace[] faces = ofaces.Where(x => x.materialName == mn).ToArray();
if (faces.Length > 0)
{
int[] indexes = new int[0];
foreach (OBJFace f in faces)
{
int l = indexes.Length;
System.Array.Resize(ref indexes, l + f.indexes.Length);
System.Array.Copy(f.indexes, 0, indexes, l, f.indexes.Length);
}
meshMaterialNames.Add(mn);
if (m.subMeshCount != meshMaterialNames.Count)
{
m.subMeshCount = meshMaterialNames.Count;
}
for (int i = 0; i < indexes.Length; i++)
{
int idx = indexes[i];
//build remap table
if (remapTable.ContainsKey(idx))
{
//ezpz
indexes[i] = remapTable[idx];
}
else
{
processedVertices.Add(uvertices[idx]);
processedNormals.Add(unormals[idx]);
processedUVs.Add(uuvs[idx]);
remapTable[idx] = processedVertices.Count - 1;
indexes[i] = remapTable[idx];
}
}
processedIndexes.Add(indexes);
}
}
//apply stuff
m.vertices = processedVertices.ToArray();
m.normals = processedNormals.ToArray();
m.uv = processedUVs.ToArray();
for (int i = 0; i < processedIndexes.Count; i++)
{
m.SetTriangles(processedIndexes[i], i);
}
if (!hasNormals)
{
m.RecalculateNormals();
}
m.RecalculateBounds();
MeshFilter mf = subObject.AddComponent<MeshFilter>();
MeshRenderer mr = subObject.AddComponent<MeshRenderer>();
Material[] processedMaterials = new Material[meshMaterialNames.Count];
for (int i = 0; i < meshMaterialNames.Count; i++)
{
if (materialCache == null)
{
processedMaterials[i] = new Material(Shader.Find("Universal Render Pipeline/Simple Lit"));
}
else
{
Material mfn = Array.Find(materialCache, x => x.name == meshMaterialNames[i]);
if (mfn == null)
{
processedMaterials[i] = new Material(Shader.Find("Universal Render Pipeline/Simple Lit"));
}
else
{
processedMaterials[i] = mfn;
}
}
processedMaterials[i].name = meshMaterialNames[i];
}
mr.materials = processedMaterials;
mf.mesh = m;
}
return parentObject;
}
19
Source : OBJLoader.cs
with Apache License 2.0
from decentraland
with Apache License 2.0
from decentraland
public static GameObject LoadOBJFile(string filePath, bool inputIsRawOBJ = false)
{
string meshName = !inputIsRawOBJ ? Path.GetFileNameWithoutExtension(filePath) : "LoadedOBJMesh";
bool hasNormals = false;
//OBJ LISTS
List<Vector3> vertices = new List<Vector3>();
List<Vector3> normals = new List<Vector3>();
List<Vector2> uvs = new List<Vector2>();
//UMESH LISTS
List<Vector3> uvertices = new List<Vector3>();
List<Vector3> unormals = new List<Vector3>();
List<Vector2> uuvs = new List<Vector2>();
//MESH CONSTRUCTION
List<string> materialNames = new List<string>();
List<string> objectNames = new List<string>();
Dictionary<string, int> hashtable = new Dictionary<string, int>();
List<OBJFace> faceList = new List<OBJFace>();
string cmaterial = "";
string cmesh = "default";
//CACHE
Material[] materialCache = null;
//save this info for later
FileInfo OBJFileInfo = null;
string[] OBJLines;
if (!inputIsRawOBJ)
{
OBJFileInfo = new FileInfo(filePath);
OBJLines = File.ReadAllLines(filePath);
}
else
{
OBJLines = filePath.Split(new[] { "\r", "\n" }, StringSplitOptions.None);
}
foreach (string ln in OBJLines)
{
if (ln.Length > 0 && ln[0] != '#')
{
string l = ln.Trim().Replace(" ", " ");
string[] cmps = l.Split(' ');
string data = l.Remove(0, l.IndexOf(' ') + 1);
if (cmps[0] == "mtllib" && !inputIsRawOBJ && OBJFileInfo != null)
{
//load cache
string pth = OBJGetFilePath(data, OBJFileInfo.Directory.FullName + Path.DirectorySeparatorChar, meshName);
if (pth != null)
{
materialCache = LoadMTLFile(pth);
}
}
else if ((cmps[0] == "g" || cmps[0] == "o") && splitByMaterial == false)
{
cmesh = data;
if (!objectNames.Contains(cmesh))
{
objectNames.Add(cmesh);
}
}
else if (cmps[0] == "usemtl")
{
cmaterial = data;
if (!materialNames.Contains(cmaterial))
{
materialNames.Add(cmaterial);
}
if (splitByMaterial)
{
if (!objectNames.Contains(cmaterial))
{
objectNames.Add(cmaterial);
}
}
}
else if (cmps[0] == "v")
{
//VERTEX
vertices.Add(ParseVectorFromCMPS(cmps));
}
else if (cmps[0] == "vn")
{
//VERTEX NORMAL
normals.Add(ParseVectorFromCMPS(cmps));
}
else if (cmps[0] == "vt")
{
//VERTEX UV
uvs.Add(ParseVectorFromCMPS(cmps));
}
else if (cmps[0] == "f")
{
int[] indexes = new int[cmps.Length - 1];
for (int i = 1; i < cmps.Length; i++)
{
string felement = cmps[i];
int vertexIndex = -1;
int normalIndex = -1;
int uvIndex = -1;
if (felement.Contains("//"))
{
//doubleslash, no UVS.
string[] elementComps = felement.Split('/');
vertexIndex = int.Parse(elementComps[0]) - 1;
normalIndex = int.Parse(elementComps[2]) - 1;
}
else if (felement.Count(x => x == '/') == 2)
{
//contains everything
string[] elementComps = felement.Split('/');
vertexIndex = int.Parse(elementComps[0]) - 1;
uvIndex = int.Parse(elementComps[1]) - 1;
normalIndex = int.Parse(elementComps[2]) - 1;
}
else if (!felement.Contains("/"))
{
//just vertex inedx
vertexIndex = int.Parse(felement) - 1;
}
else
{
//vertex and uv
string[] elementComps = felement.Split('/');
vertexIndex = int.Parse(elementComps[0]) - 1;
uvIndex = int.Parse(elementComps[1]) - 1;
}
string hashEntry = vertexIndex + "|" + normalIndex + "|" + uvIndex;
if (hashtable.ContainsKey(hashEntry))
{
indexes[i - 1] = hashtable[hashEntry];
}
else
{
//create a new hash entry
indexes[i - 1] = hashtable.Count;
hashtable[hashEntry] = hashtable.Count;
uvertices.Add(vertices[vertexIndex]);
if (normalIndex < 0 || (normalIndex > (normals.Count - 1)))
{
unormals.Add(Vector3.zero);
}
else
{
hasNormals = true;
unormals.Add(normals[normalIndex]);
}
if (uvIndex < 0 || (uvIndex > (uvs.Count - 1)))
{
uuvs.Add(Vector2.zero);
}
else
{
uuvs.Add(uvs[uvIndex]);
}
}
}
if (indexes.Length < 5 && indexes.Length >= 3)
{
OBJFace f1 = new OBJFace();
f1.materialName = cmaterial;
f1.indexes = new int[] { indexes[0], indexes[1], indexes[2] };
f1.meshName = (splitByMaterial) ? cmaterial : cmesh;
faceList.Add(f1);
if (indexes.Length > 3)
{
OBJFace f2 = new OBJFace();
f2.materialName = cmaterial;
f2.meshName = (splitByMaterial) ? cmaterial : cmesh;
f2.indexes = new int[] { indexes[2], indexes[3], indexes[0] };
faceList.Add(f2);
}
}
}
}
}
if (objectNames.Count == 0)
{
objectNames.Add("default");
}
//build objects
GameObject parentObject = new GameObject(meshName);
for (int objectNamesIndex = 0; objectNamesIndex < objectNames.Count; objectNamesIndex++)
{
string obj = objectNames[objectNamesIndex];
GameObject subObjectParent = new GameObject(obj);
subObjectParent.transform.parent = parentObject.transform;
GameObject subObject = new GameObject("ChildMesh");
subObject.transform.parent = subObjectParent.transform;
subObject.transform.localScale = new Vector3(-1, 1, 1);
//Create mesh
Mesh m = new Mesh();
m.name = obj;
//LISTS FOR REORDERING
List<Vector3> processedVertices = new List<Vector3>();
List<Vector3> processedNormals = new List<Vector3>();
List<Vector2> processedUVs = new List<Vector2>();
List<int[]> processedIndexes = new List<int[]>();
Dictionary<int, int> remapTable = new Dictionary<int, int>();
//POPULATE MESH
List<string> meshMaterialNames = new List<string>();
OBJFace[] ofaces = faceList.Where(x => x.meshName == obj).ToArray();
foreach (string mn in materialNames)
{
OBJFace[] faces = ofaces.Where(x => x.materialName == mn).ToArray();
if (faces.Length > 0)
{
int[] indexes = new int[0];
foreach (OBJFace f in faces)
{
int l = indexes.Length;
System.Array.Resize(ref indexes, l + f.indexes.Length);
System.Array.Copy(f.indexes, 0, indexes, l, f.indexes.Length);
}
meshMaterialNames.Add(mn);
if (m.subMeshCount != meshMaterialNames.Count)
{
m.subMeshCount = meshMaterialNames.Count;
}
for (int i = 0; i < indexes.Length; i++)
{
int idx = indexes[i];
//build remap table
if (remapTable.ContainsKey(idx))
{
//ezpz
indexes[i] = remapTable[idx];
}
else
{
processedVertices.Add(uvertices[idx]);
processedNormals.Add(unormals[idx]);
processedUVs.Add(uuvs[idx]);
remapTable[idx] = processedVertices.Count - 1;
indexes[i] = remapTable[idx];
}
}
processedIndexes.Add(indexes);
}
}
//apply stuff
m.vertices = processedVertices.ToArray();
m.normals = processedNormals.ToArray();
m.uv = processedUVs.ToArray();
for (int i = 0; i < processedIndexes.Count; i++)
{
m.SetTriangles(processedIndexes[i], i);
}
if (!hasNormals)
{
m.RecalculateNormals();
}
m.RecalculateBounds();
MeshFilter mf = subObject.AddComponent<MeshFilter>();
MeshRenderer mr = subObject.AddComponent<MeshRenderer>();
Material[] processedMaterials = new Material[meshMaterialNames.Count];
for (int i = 0; i < meshMaterialNames.Count; i++)
{
if (materialCache == null)
{
processedMaterials[i] = new Material(Shader.Find("Universal Render Pipeline/Simple Lit"));
}
else
{
Material mfn = Array.Find(materialCache, x => x.name == meshMaterialNames[i]);
if (mfn == null)
{
processedMaterials[i] = new Material(Shader.Find("Universal Render Pipeline/Simple Lit"));
}
else
{
processedMaterials[i] = mfn;
}
}
processedMaterials[i].name = meshMaterialNames[i];
}
mr.materials = processedMaterials;
mf.mesh = m;
}
return parentObject;
}
19
Source : SimpleOverlappingTracker.cs
with Apache License 2.0
from decentraland
with Apache License 2.0
from decentraland
public bool RegisterPosition (Vector2 position)
{
for (var i = 0; i < positions.Count; i++)
{
Vector2 toCompare = positions[i];
if ((toCompare - position).sqrMagnitude < sqrTooCloseDistance)
return false;
}
positions.Add(position);
return true;
}
19
Source : AstrologianHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new();
List<Vector2> sizes = new();
if (Config.DrawBar.Enabled)
{
positions.Add(Config.Position + Config.DrawBar.Position);
sizes.Add(Config.DrawBar.Size);
}
if (Config.DivinationBar.Enabled)
{
positions.Add(Config.Position + Config.DivinationBar.Position);
sizes.Add(Config.DivinationBar.Size);
}
if (Config.DotBar.Enabled)
{
positions.Add(Config.Position + Config.DotBar.Position);
sizes.Add(Config.DotBar.Size);
}
if (Config.StarBar.Enabled)
{
positions.Add(Config.Position + Config.StarBar.Position);
sizes.Add(Config.StarBar.Size);
}
if (Config.LightspeedBar.Enabled)
{
positions.Add(Config.Position + Config.LightspeedBar.Position);
sizes.Add(Config.LightspeedBar.Size);
}
return (positions, sizes);
}
19
Source : BardHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new List<Vector2>();
List<Vector2> sizes = new List<Vector2>();
if (Config.SongGaugeBar.Enabled)
{
positions.Add(Config.Position + Config.SongGaugeBar.Position);
sizes.Add(Config.SongGaugeBar.Size);
}
if (Config.SoulVoiceBar.Enabled)
{
positions.Add(Config.Position + Config.SoulVoiceBar.Position);
sizes.Add(Config.SoulVoiceBar.Size);
}
if (Config.StacksBar.Enabled)
{
positions.Add(Config.Position + Config.StacksBar.Position);
sizes.Add(Config.StacksBar.Size);
}
if (Config.CausticBiteDoTBar.Enabled)
{
positions.Add(Config.Position + Config.CausticBiteDoTBar.Position);
sizes.Add(Config.CausticBiteDoTBar.Size);
}
if (Config.StormbiteDoTBar.Enabled)
{
positions.Add(Config.Position + Config.StormbiteDoTBar.Position);
sizes.Add(Config.StormbiteDoTBar.Size);
}
return (positions, sizes);
}
19
Source : BlackMageHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new List<Vector2>();
List<Vector2> sizes = new List<Vector2>();
if (Config.ManaBar.Enabled)
{
positions.Add(Config.Position + Config.ManaBar.Position);
sizes.Add(Config.ManaBar.Size);
}
if (Config.UmbralHeartBar.Enabled)
{
positions.Add(Config.Position + Config.UmbralHeartBar.Position);
sizes.Add(Config.UmbralHeartBar.Size);
}
if (Config.TriplecastBar.Enabled)
{
positions.Add(Config.Position + Config.TriplecastBar.Position);
sizes.Add(Config.TriplecastBar.Size);
}
if (Config.EnochianBar.Enabled)
{
positions.Add(Config.Position + Config.EnochianBar.Position);
sizes.Add(Config.EnochianBar.Size);
}
if (Config.PolyglotBar.Enabled)
{
positions.Add(Config.Position + Config.PolyglotBar.Position);
sizes.Add(Config.PolyglotBar.Size);
}
if (Config.ThundercloudBar.Enabled && !Config.ThundercloudBar.HideWhenInactive)
{
positions.Add(Config.Position + Config.ThundercloudBar.Position);
sizes.Add(Config.ThundercloudBar.Size);
}
if (Config.ThunderDoTBar.Enabled && !Config.ThunderDoTBar.HideWhenInactive)
{
positions.Add(Config.Position + Config.ThunderDoTBar.Position);
sizes.Add(Config.ThunderDoTBar.Size);
}
if (Config.FirestarterBar.Enabled && !Config.FirestarterBar.HideWhenInactive)
{
positions.Add(Config.Position + Config.FirestarterBar.Position);
sizes.Add(Config.FirestarterBar.Size);
}
return (positions, sizes);
}
19
Source : DancerHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new List<Vector2>();
List<Vector2> sizes = new List<Vector2>();
if (Config.StandardFinishBar.Enabled)
{
positions.Add(Config.Position + Config.StandardFinishBar.Position);
sizes.Add(Config.StandardFinishBar.Size);
}
if (Config.TechnicalFinishBar.Enabled)
{
positions.Add(Config.Position + Config.TechnicalFinishBar.Position);
sizes.Add(Config.TechnicalFinishBar.Position);
}
if (Config.DevilmentBar.Enabled)
{
positions.Add(Config.Position + Config.DevilmentBar.Position);
sizes.Add(Config.DevilmentBar.Position);
}
if (Config.EspritGauge.Enabled)
{
positions.Add(Config.Position + Config.EspritGauge.Position);
sizes.Add(Config.EspritGauge.Size);
}
if (Config.FeatherGauge.Enabled)
{
positions.Add(Config.Position + Config.FeatherGauge.Position);
sizes.Add(Config.FeatherGauge.Size);
}
if (Config.CascadeBar.Enabled)
{
positions.Add(Config.Position + Config.CascadeBar.Position);
sizes.Add(Config.CascadeBar.Position);
}
if (Config.FountainBar.Enabled)
{
positions.Add(Config.Position + Config.FountainBar.Position);
sizes.Add(Config.FountainBar.Position);
}
if (Config.WindmillBar.Enabled)
{
positions.Add(Config.Position + Config.WindmillBar.Position);
sizes.Add(Config.WindmillBar.Position);
}
if (Config.ShowerBar.Enabled)
{
positions.Add(Config.Position + Config.ShowerBar.Position);
sizes.Add(Config.ShowerBar.Position);
}
return (positions, sizes);
}
19
Source : DarkKnightHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new();
List<Vector2> sizes = new();
if (Config.ManaBar.Enabled)
{
positions.Add(Config.Position + Config.ManaBar.Position);
sizes.Add(Config.ManaBar.Size);
}
if (Config.BloodGauge.Enabled)
{
positions.Add(Config.Position + Config.BloodGauge.Position);
sizes.Add(Config.BloodGauge.Size);
}
if (Config.DarksideBar.Enabled)
{
positions.Add(Config.Position + Config.DarksideBar.Position);
sizes.Add(Config.DarksideBar.Size);
}
if (Config.BloodWeaponBar.Enabled)
{
positions.Add(Config.Position + Config.BloodWeaponBar.Position);
sizes.Add(Config.BloodWeaponBar.Size);
}
if (Config.DeliriumBar.Enabled)
{
positions.Add(Config.Position + Config.DeliriumBar.Position);
sizes.Add(Config.DeliriumBar.Size);
}
if (Config.LivingShadowBar.Enabled)
{
positions.Add(Config.Position + Config.LivingShadowBar.Position);
sizes.Add(Config.LivingShadowBar.Size);
}
return (positions, sizes);
}
19
Source : DragoonHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new List<Vector2>();
List<Vector2> sizes = new List<Vector2>();
if (Config.ChaosThrustBar.Enabled)
{
positions.Add(Config.Position + Config.ChaosThrustBar.Position);
sizes.Add(Config.ChaosThrustBar.Size);
}
if (Config.DisembowelBar.Enabled)
{
positions.Add(Config.Position + Config.DisembowelBar.Position);
sizes.Add(Config.DisembowelBar.Size);
}
if (Config.EyeOfTheDragonBar.Enabled)
{
positions.Add(Config.Position + Config.EyeOfTheDragonBar.Position);
sizes.Add(Config.EyeOfTheDragonBar.Size);
}
if (Config.BloodOfTheDragonBar.Enabled)
{
positions.Add(Config.Position + Config.BloodOfTheDragonBar.Position);
sizes.Add(Config.BloodOfTheDragonBar.Size);
}
return (positions, sizes);
}
19
Source : MachinistHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new List<Vector2>();
List<Vector2> sizes = new List<Vector2>();
if (Config.OverheatGauge.Enabled)
{
positions.Add(Config.Position + Config.OverheatGauge.Position);
sizes.Add(Config.OverheatGauge.Size);
}
if (Config.HeatGauge.Enabled)
{
positions.Add(Config.Position + Config.HeatGauge.Position);
sizes.Add(Config.HeatGauge.Size);
}
if (Config.BatteryGauge.Enabled)
{
positions.Add(Config.Position + Config.BatteryGauge.Position);
sizes.Add(Config.BatteryGauge.Size);
}
return (positions, sizes);
}
19
Source : MonkHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new List<Vector2>();
List<Vector2> sizes = new List<Vector2>();
if (Config.DemolishBar.Enabled)
{
positions.Add(Config.Position + Config.DemolishBar.Position);
sizes.Add(Config.DemolishBar.Size);
}
if (Config.ChakraBar.Enabled)
{
positions.Add(Config.Position + Config.ChakraBar.Position);
sizes.Add(Config.ChakraBar.Size);
}
if (Config.LeadenFistBar.Enabled)
{
positions.Add(Config.Position + Config.LeadenFistBar.Position);
sizes.Add(Config.LeadenFistBar.Size);
}
if (Config.TwinSnakesBar.Enabled)
{
positions.Add(Config.Position + Config.TwinSnakesBar.Position);
sizes.Add(Config.TwinSnakesBar.Size);
}
if (Config.RiddleofEarthBar.Enabled)
{
positions.Add(Config.Position + Config.RiddleofEarthBar.Position);
sizes.Add(Config.RiddleofEarthBar.Size);
}
if (Config.PerfectBalanceBar.Enabled)
{
positions.Add(Config.Position + Config.PerfectBalanceBar.Position);
sizes.Add(Config.PerfectBalanceBar.Size);
}
if (Config.TrueNorthBar.Enabled)
{
positions.Add(Config.Position + Config.TrueNorthBar.Position);
sizes.Add(Config.TrueNorthBar.Size);
}
if (Config.FormsBar.Enabled)
{
positions.Add((Config.Position + Config.FormsBar.Position));
sizes.Add(Config.FormsBar.Size);
}
return (positions, sizes);
}
19
Source : NinjaHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new List<Vector2>();
List<Vector2> sizes = new List<Vector2>();
if (Config.HutonBar.Enabled)
{
positions.Add(Config.Position + Config.HutonBar.Position);
sizes.Add(Config.HutonBar.Size);
}
if (Config.NinkiBar.Enabled)
{
positions.Add(Config.Position + Config.NinkiBar.Position);
sizes.Add(Config.NinkiBar.Size);
}
if (Config.TrickAttackBar.Enabled)
{
positions.Add(Config.Position + Config.TrickAttackBar.Position);
sizes.Add(Config.TrickAttackBar.Size);
}
if (Config.SuitonBar.Enabled)
{
positions.Add(Config.Position + Config.SuitonBar.Position);
sizes.Add(Config.SuitonBar.Size);
}
if (Config.MudraBar.Enabled)
{
positions.Add(Config.Position + Config.MudraBar.Position);
sizes.Add(Config.MudraBar.Size);
}
return (positions, sizes);
}
19
Source : PaladinHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new();
List<Vector2> sizes = new();
if (Config.ManaBar.Enabled)
{
positions.Add(Config.Position + Config.ManaBar.Position);
sizes.Add(Config.ManaBar.Size);
}
if (Config.OathGauge.Enabled)
{
positions.Add(Config.Position + Config.OathGauge.Position);
sizes.Add(Config.OathGauge.Size);
}
if (Config.FightOrFlightBar.Enabled)
{
positions.Add(Config.Position + Config.FightOrFlightBar.Position);
sizes.Add(Config.FightOrFlightBar.Size);
}
if (Config.RequiescatBar.Enabled)
{
positions.Add(Config.Position + Config.RequiescatBar.Position);
sizes.Add(Config.RequiescatBar.Size);
}
if (Config.AtonementBar.Enabled)
{
positions.Add(Config.Position + Config.AtonementBar.Position);
sizes.Add(Config.AtonementBar.Size);
}
return (positions, sizes);
}
19
Source : RedMageHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new List<Vector2>();
List<Vector2> sizes = new List<Vector2>();
if (Config.BalanceBar.Enabled)
{
positions.Add(Config.Position + Config.BalanceBar.Position);
sizes.Add(Config.BalanceBar.Size);
}
if (Config.WhiteManaBar.Enabled)
{
positions.Add(Config.Position + Config.WhiteManaBar.Position);
sizes.Add(Config.WhiteManaBar.Size);
}
if (Config.BlackManaBar.Enabled)
{
positions.Add(Config.Position + Config.BlackManaBar.Position);
sizes.Add(Config.BlackManaBar.Size);
}
if (Config.AccelerationBar.Enabled)
{
positions.Add(Config.Position + Config.AccelerationBar.Position);
sizes.Add(Config.AccelerationBar.Size);
}
if (Config.DualcastBar.Enabled)
{
positions.Add(Config.Position + Config.DualcastBar.Position);
sizes.Add(Config.DualcastBar.Size);
}
if (Config.VerstoneBar.Enabled)
{
positions.Add(Config.Position + Config.VerstoneBar.Position);
sizes.Add(Config.VerstoneBar.Size);
}
if (Config.VerfireBar.Enabled)
{
positions.Add(Config.Position + Config.VerfireBar.Position);
sizes.Add(Config.VerfireBar.Size);
}
return (positions, sizes);
}
19
Source : SamuraiHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new List<Vector2>();
List<Vector2> sizes = new List<Vector2>();
if (Config.KenkiBar.Enabled)
{
positions.Add(Config.Position + Config.KenkiBar.Position);
sizes.Add(Config.KenkiBar.Size);
}
if (Config.ShifuBar.Enabled)
{
positions.Add(Config.Position + Config.ShifuBar.Position);
sizes.Add(Config.ShifuBar.Size);
}
if (Config.JinpuBar.Enabled)
{
positions.Add(Config.Position + Config.JinpuBar.Position);
sizes.Add(Config.JinpuBar.Size);
}
if (Config.HiganbanaBar.Enabled)
{
positions.Add(Config.Position + Config.HiganbanaBar.Position);
sizes.Add(Config.HiganbanaBar.Size);
}
if (Config.SenBar.Enabled)
{
positions.Add(Config.Position + Config.SenBar.Position);
sizes.Add(Config.SenBar.Size);
}
if (Config.MeditationBar.Enabled)
{
positions.Add(Config.Position + Config.MeditationBar.Position);
sizes.Add(Config.MeditationBar.Size);
}
return (positions, sizes);
}
19
Source : ScholarHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new List<Vector2>();
List<Vector2> sizes = new List<Vector2>();
if (Config.AetherflowBar.Enabled)
{
positions.Add(Config.Position + Config.AetherflowBar.Position);
sizes.Add(Config.AetherflowBar.Size);
}
if (Config.FairyGaugeBar.Enabled)
{
positions.Add(Config.Position + Config.FairyGaugeBar.Position);
sizes.Add(Config.FairyGaugeBar.Size);
}
if (Config.BioBar.Enabled)
{
positions.Add(Config.Position + Config.BioBar.Position);
sizes.Add(Config.BioBar.Size);
}
return (positions, sizes);
}
19
Source : SummonerHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new();
List<Vector2> sizes = new();
if (Config.AetherflowBar.Enabled)
{
positions.Add(Config.Position + Config.AetherflowBar.Position);
sizes.Add(Config.AetherflowBar.Size);
}
if (Config.DemiStatusIndicatorBar.Enabled)
{
positions.Add(Config.Position + Config.DemiStatusIndicatorBar.Position);
sizes.Add(Config.DemiStatusIndicatorBar.Size);
}
if (Config.DreadwyrmAetherBar.Enabled)
{
positions.Add(Config.Position + Config.DreadwyrmAetherBar.Position);
sizes.Add(Config.DreadwyrmAetherBar.Size);
}
if (Config.TranceBar.Enabled)
{
positions.Add(Config.Position + Config.TranceBar.Position);
sizes.Add(Config.TranceBar.Size);
}
if (Config.RuinBar.Enabled)
{
positions.Add(Config.Position + Config.RuinBar.Position);
sizes.Add(Config.RuinBar.Size);
}
if (Config.MiasmaBar.Enabled)
{
positions.Add(Config.Position + Config.MiasmaBar.Position);
sizes.Add(Config.MiasmaBar.Size);
}
if (Config.BioBar.Enabled)
{
positions.Add(Config.Position + Config.BioBar.Position);
sizes.Add(Config.BioBar.Size);
}
return (positions, sizes);
}
19
Source : WhiteMageHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new();
List<Vector2> sizes = new();
if (Config.LilyBar.Enabled)
{
positions.Add(Config.Position + Config.LilyBar.Position);
sizes.Add(Config.LilyBar.Size);
}
if (Config.DiaBar.Enabled)
{
positions.Add(Config.Position + Config.DiaBar.Position);
sizes.Add(Config.DiaBar.Size);
}
if (Config.AsylumBar.Enabled)
{
positions.Add(Config.Position + Config.AsylumBar.Position);
sizes.Add(Config.AsylumBar.Size);
}
if (Config.PresenceOfMindBar.Enabled)
{
positions.Add(Config.Position + Config.PresenceOfMindBar.Position);
sizes.Add(Config.PresenceOfMindBar.Size);
}
if (Config.PlenaryBar.Enabled)
{
positions.Add(Config.Position + Config.PlenaryBar.Position);
sizes.Add(Config.PlenaryBar.Size);
}
if (Config.TemperanceBar.Enabled)
{
positions.Add(Config.Position + Config.TemperanceBar.Position);
sizes.Add(Config.TemperanceBar.Size);
}
return (positions, sizes);
}
19
Source : BlueMageHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new List<Vector2>();
List<Vector2> sizes = new List<Vector2>();
if (Config.BleedBar.Enabled)
{
positions.Add(Config.Position + Config.BleedBar.Position);
sizes.Add(Config.BleedBar.Size);
}
if (Config.WindburnBar.Enabled)
{
positions.Add(Config.Position + Config.WindburnBar.Position);
sizes.Add(Config.WindburnBar.Size);
}
if (Config.SurpanakhaBar.Enabled)
{
positions.Add(Config.Position + Config.SurpanakhaBar.Position);
sizes.Add(Config.SurpanakhaBar.Size);
}
if (Config.OffGuardBar.Enabled)
{
positions.Add(Config.Position + Config.OffGuardBar.Position);
sizes.Add(Config.OffGuardBar.Size);
}
return (positions, sizes);
}
19
Source : GunbreakerHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new List<Vector2>();
List<Vector2> sizes = new List<Vector2>();
if (Config.PowderGauge.Enabled)
{
positions.Add(Config.Position + Config.PowderGauge.Position);
sizes.Add(Config.PowderGauge.Size);
}
if (Config.NoMercy.Enabled)
{
positions.Add(Config.Position + Config.NoMercy.Position);
sizes.Add(Config.NoMercy.Size);
}
return (positions, sizes);
}
19
Source : StatusEffectsListHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
public override void DrawChildren(Vector2 origin)
{
if (!Config.Enabled)
{
return;
}
if (_fakeEffects == null && (Actor == null || Actor.ObjectKind != ObjectKind.Player && Actor.ObjectKind != ObjectKind.BattleNpc))
{
return;
}
// calculate layout
var list = StatusEffectsData();
// area
GrowthDirections growthDirections = Config.GetGrowthDirections();
Vector2 position = origin + GetAncreplaceddPosition(Config.Position, Config.Size, DrawAnchor.TopLeft);
Vector2 areaPos = CalculateStartPosition(position, Config.Size, growthDirections);
var margin = new Vector2(14, 10);
var drawList = ImGui.GetWindowDrawList();
// no need to do anything else if there are no effects
if (list.Count == 0)
{
return;
}
// calculate icon positions
var count = CalculateLayout(list);
var iconPositions = new List<Vector2>();
var minPos = new Vector2(float.MaxValue, float.MaxValue);
var maxPos = Vector2.Zero;
var row = 0;
var col = 0;
for (var i = 0; i < count; i++)
{
CalculateAxisDirections(growthDirections, row, count, out var direction, out var offset);
var pos = new Vector2(
position.X + offset.X + Config.IconConfig.Size.X * col * direction.X + Config.IconPadding.X * col * direction.X,
position.Y + offset.Y + Config.IconConfig.Size.Y * row * direction.Y + Config.IconPadding.Y * row * direction.Y
);
minPos.X = Math.Min(pos.X, minPos.X);
minPos.Y = Math.Min(pos.Y, minPos.Y);
maxPos.X = Math.Max(pos.X + Config.IconConfig.Size.X, maxPos.X);
maxPos.Y = Math.Max(pos.Y + Config.IconConfig.Size.Y, maxPos.Y);
iconPositions.Add(pos);
// rows / columns
if (Config.FillRowsFirst || (growthDirections & GrowthDirections.Centered) != 0)
{
col += 1;
if (col >= _layoutInfo.TotalColCount)
{
col = 0;
row += 1;
}
}
else
{
row += 1;
if (row >= _layoutInfo.TotalRowCount)
{
row = 0;
col += 1;
}
}
}
// window
// imgui clips the left and right borders inside windows for some reason
// we make the window bigger so the actual drawable size is the expected one
var windowPos = minPos - margin;
var windowSize = maxPos - minPos;
DrawHelper.DrawInWindow(ID, windowPos, windowSize + margin * 2, Config.ShowBuffs, false, (drawList) =>
{
// area
if (Config.Preview)
{
drawList.AddRectFilled(areaPos, areaPos + Config.Size, 0x88000000);
}
for (var i = 0; i < count; i++)
{
var iconPos = iconPositions[i];
var statusEffectData = list[i];
// icon
var cropIcon = Config.IconConfig.CropIcon;
int stackCount = cropIcon ? 1 : statusEffectData.Data.MaxStacks > 0 ? statusEffectData.Status.StackCount : 0;
DrawHelper.DrawIcon<LuminaStatus>(drawList, statusEffectData.Data, iconPos, Config.IconConfig.Size, false, cropIcon, stackCount);
// border
var borderConfig = GetBorderConfig(statusEffectData);
if (borderConfig != null && cropIcon)
{
drawList.AddRect(iconPos, iconPos + Config.IconConfig.Size, borderConfig.Color.Base, 0, ImDrawFlags.None, borderConfig.Thickness);
}
// Draw dispell indicator above dispellable status effect on uncropped icons
if (borderConfig != null && !cropIcon && statusEffectData.Data.CanDispel)
{
var dispellIndicatorColor = new Vector4(141f / 255f, 206f / 255f, 229f / 255f, 100f / 100f);
// 24x32
drawList.AddRectFilled(
iconPos + new Vector2(Config.IconConfig.Size.X * .07f, Config.IconConfig.Size.Y * .07f),
iconPos + new Vector2(Config.IconConfig.Size.X * .93f, Config.IconConfig.Size.Y * .14f),
ImGui.ColorConvertFloat4ToU32(dispellIndicatorColor),
8f
);
}
}
});
// labels need to be drawn separated since they have their own window for clipping
for (var i = 0; i < count; i++)
{
var iconPos = iconPositions[i];
var statusEffectData = list[i];
// duration
if (Config.IconConfig.DurationLabelConfig.Enabled &&
!statusEffectData.Data.IsPermanent &&
!statusEffectData.Data.IsFcBuff)
{
var duration = Math.Round(Math.Abs(statusEffectData.Status.RemainingTime));
Config.IconConfig.DurationLabelConfig.SetText(Utils.DurationToString(duration));
_durationLabel.Draw(iconPos, Config.IconConfig.Size);
}
// stacks
if (Config.IconConfig.StacksLabelConfig.Enabled &&
statusEffectData.Data.MaxStacks > 0 &&
statusEffectData.Status.StackCount > 0 &&
!statusEffectData.Data.IsFcBuff)
{
var text = $"{statusEffectData.Status.StackCount}";
Config.IconConfig.StacksLabelConfig.SetText(text);
_stacksLabel.Draw(iconPos, Config.IconConfig.Size);
}
// tooltips / interaction
if (ImGui.IsMouseHoveringRect(iconPos, iconPos + Config.IconConfig.Size))
{
// tooltip
if (Config.ShowTooltips)
{
TooltipsHelper.Instance.ShowTooltipOnCursor(
statusEffectData.Data.Description.ToDalamudString().ToString(),
statusEffectData.Data.Name,
statusEffectData.Status.StatusID,
GetStatusActorName(statusEffectData.Status)
);
}
bool leftClick = InputsHelper.Instance.HandlingMouseInputs ? InputsHelper.Instance.LeftButtonClicked : ImGui.GetIO().MouseClicked[0];
bool rightClick = InputsHelper.Instance.HandlingMouseInputs ? InputsHelper.Instance.RightButtonClicked : ImGui.GetIO().MouseClicked[1];
// remove buff on right click
bool isFromPlayer = statusEffectData.Status.SourceID == Plugin.ClientState.LocalPlayer?.ObjectId;
if (statusEffectData.Data.Category == 1 && isFromPlayer && rightClick)
{
ChatHelper.SendChatMessage("/statusoff \"" + statusEffectData.Data.Name + "\"");
}
// automatic add to black list with ctrl+alt+shift click
if (Config.BlacklistConfig.Enabled &&
ImGui.GetIO().KeyCtrl && ImGui.GetIO().KeyAlt && ImGui.GetIO().KeyShift && leftClick)
{
Config.BlacklistConfig.AddNewEntry(statusEffectData.Data);
ConfigurationManager.Instance.ForceNeedsSave();
}
}
}
}
19
Source : WarriorHud.cs
with GNU Affero General Public License v3.0
from DelvUI
with GNU Affero General Public License v3.0
from DelvUI
protected override (List<Vector2>, List<Vector2>) ChildrenPositionsAndSizes()
{
List<Vector2> positions = new();
List<Vector2> sizes = new();
if (Config.StormsEyeBar.Enabled)
{
positions.Add(Config.Position + Config.StormsEyeBar.Position);
sizes.Add(Config.StormsEyeBar.Size);
}
if (Config.BeastGauge.Enabled)
{
positions.Add(Config.Position + Config.BeastGauge.Position);
sizes.Add(Config.BeastGauge.Size);
}
return (positions, sizes);
}
19
Source : DAE_Mesh.cs
with MIT License
from dereksorensen
with MIT License
from dereksorensen
public void load(Dictionary<string, DAE_Material> material_collection, DAE_Skeleton skeleton = null)
{
// Exit if mesh doesn't have all required data sources
if (_geometry.Mesh.Source.Count() < 3)
{
throw new Exception(Debug.DebugHelper.format("\t[ FAILED ] Mesh: " + _id, "Mesh must include position/normal/texcoord)"));
}
List<Vector3> temp_position = new List<Vector3>();
List<Vector3> temp_normal = new List<Vector3>();
List<Vector2> temp_uv = new List<Vector2>();
List<Vector4> temp_bone_ids;
List<Vector4> temp_bone_weights;
if (skeleton == null)
{
temp_bone_ids = null;
temp_bone_weights = null;
}
else
{
this.skeleton = skeleton;
temp_bone_ids = new List<Vector4>();
temp_bone_weights = new List<Vector4>();
}
//------------------------------------------------------
// Load Position / Normal / UV from Mesh
//------------------------------------------------------
foreach (Grendgine_Collada_Source s in _geometry.Mesh.Source)
{
Grendgine_Collada_Accessor a = s.Technique_Common.Accessor;
uint group_count = a.Count;
uint group_stride = a.Stride;
int count = s.Float_Array.Count;
float[] temp_array = s.Float_Array.Value();
for (uint i = 0; i < count; i += group_stride)
{
int v_index = (int)i / 3;
if (s.ID.Contains("position"))
{
if (skeleton != null)
{
// Add bone ids and weights to list
Vector4 ids = new Vector4();
Vector4 weights = new Vector4();
for (int w = 0; w < Math.Min(skeleton.vertex_weights[v_index].Length, 4); w++)
{
ids[w] = skeleton.vertex_weights[v_index][w].bone_id;
weights[w] = skeleton.vertex_weights[v_index][w].vertex_weight;
}
temp_bone_ids.Add(ids);
temp_bone_weights.Add(weights);
}
// Premultiply position with BSM and add to list
Vector3 vertex_position = new Vector3(temp_array[i], temp_array[i + 1], temp_array[i + 2]);
if (skeleton != null) vertex_position = Vector4.Transform(new Vector4(vertex_position, 1.0f), skeleton.BSM).Xyz;
temp_position.Add(vertex_position);
}
else if (s.ID.Contains("normal"))
{
Vector3 vertex_normal = new Vector3(temp_array[i], temp_array[i + 1], temp_array[i + 2]);
if (skeleton != null) vertex_normal = Vector3.Transform(vertex_normal, skeleton.BSM.ExtractRotation());
temp_normal.Add(vertex_normal);
}
else if (s.ID.Contains("map"))
{
temp_uv.Add(new Vector2(temp_array[i], 1.0f - temp_array[i + 1]));
}
}
}
//------------------------------------------------------
// Load Submeshes
//------------------------------------------------------
int polylist_counter = 0;
foreach (Grendgine_Collada_Polylist p in _geometry.Mesh.Polylist)
{
// Create new polylist
DAE_Polylist temp_polylist = new DAE_Polylist(_id + "-sub" + polylist_counter);
try
{
temp_polylist.load(p, material_collection, temp_position, temp_uv, temp_normal, temp_bone_ids, temp_bone_weights);
}
catch (Exception e)
{
throw new Exception(Debug.DebugHelper.format("\t[ FAILED ] Submesh: " + temp_polylist.id, e.Message));
}
_submeshes.Add(temp_polylist);
polylist_counter++;
}
temp_position.Clear();
temp_normal.Clear();
temp_uv.Clear();
if (skeleton != null) temp_bone_ids.Clear();
if (skeleton != null) temp_bone_weights.Clear();
}
19
Source : BGGenerator.cs
with GNU General Public License v3.0
from DigiWorm0
with GNU General Public License v3.0
from DigiWorm0
public void Generate(Mapreplacedet replacedet)
{
// Array => List
List<Vector3> vertices = new List<Vector3>(bgMesh.vertices);
List<Vector2> uv = new List<Vector2>(bgMesh.uv);
List<int> triangles = new List<int>(bgMesh.triangles);
List<Color> colors = new List<Color>(bgMesh.colors);
// Iterate Colliders
foreach (MapCollider c in replacedet.colliders)
{
// Get Points
var points = c.GetPoints();
var points2 = new List<Vector3>();
if (c.isClosed)
points.RemoveAt(points._size - 1);
for (int i = 0; i < points.Count; i++)
{
points[i] = new Vector2(
(points[i].x + replacedet.x) * MinimapGenerator.MAP_SCALE,
(points[i].y - replacedet.y) * MinimapGenerator.MAP_SCALE
);
for (int o = 0; o < 5; o++)
points2.Add(new Vector3(points[i].x, points[i].y));
}
// LineRenderer
var lineObj = new GameObject(replacedet.name + "Line");
lineObj.transform.SetParent(bgObj.transform);
lineObj.transform.localPosition = new Vector3(0, 0, -1.0f);
lineObj.layer = (int)Layer.UI;
LineRenderer lineRenderer = lineObj.AddComponent<LineRenderer>();
lineRenderer.startColor = Color.white;
lineRenderer.endColor = Color.white;
lineRenderer.startWidth = 0.03f;
lineRenderer.endWidth = 0.03f;
lineRenderer.positionCount = points2.Count;
lineRenderer.useWorldSpace = false;
lineRenderer.loop = true;
lineRenderer.material = new Material(Shader.Find("Sprites/Default"));
lineRenderer.SetPositions(points2.ToArray());
// Triangulate
var triangulator = new Triangulator(points.ToArray());
var triangulation = triangulator.Triangulate();
for (int i = 0; i < triangulation.Length; i++)
{
triangulation[i] += vertices.Count;
}
// Add to Array
triangles.AddRange(triangulation);
foreach (Vector2 point in points)
{
vertices.Add(point);
uv.Add(point);
colors.Add(new Color(0, 0, 1.0f, 0.6f));
}
}
// List => Array
bgMesh.vertices = vertices.ToArray();
bgMesh.uv = uv.ToArray();
bgMesh.triangles = triangles.ToArray();
bgMesh.colors = colors.ToArray();
}
19
Source : Curve.cs
with Apache License 2.0
from dilmerv
with Apache License 2.0
from dilmerv
private void Normalize()
{
//reset lookup table:
_lengthLookup.Clear();
_lengthLookup.Add(Vector2.zero);
//create lookup values:
Vector3 previousPosition = _start;
for (int i = 0; i < _resolution; i++)
{
//non-normalized values:
float percentage = i / (float)(_resolution - 1);
Vector3 rawPosition = Evaluate(percentage);
//float oneMinusT = 1 - percentage;
//Vector3 rawPosition = oneMinusT * oneMinusT * _start + 2f * oneMinusT * percentage * _control + percentage * percentage * _end;
//log lookup values:
if (i > 0)
{
float distance = Vector3.Distance(rawPosition, previousPosition);
_lengthLookup.Add(new Vector2(percentage, distance + _lengthLookup[i - 1].y));
}
previousPosition = rawPosition;
}
}
19
Source : Curve.cs
with Apache License 2.0
from dilmerv
with Apache License 2.0
from dilmerv
private void Normalize()
{
//reset lookup table:
_lengthLookup.Clear();
_lengthLookup.Add(Vector2.zero);
//create lookup values:
Vector3 previousPosition = _start;
for (int i = 0; i < _resolution; i++)
{
//non-normalized values:
float percentage = i / (float)(_resolution - 1);
Vector3 rawPosition = Evaluate(percentage);
//float oneMinusT = 1 - percentage;
//Vector3 rawPosition = oneMinusT * oneMinusT * _start + 2f * oneMinusT * percentage * _control + percentage * percentage * _end;
//log lookup values:
if (i > 0)
{
float distance = Vector3.Distance(rawPosition, previousPosition);
_lengthLookup.Add(new Vector2(percentage, distance + _lengthLookup[i - 1].y));
}
previousPosition = rawPosition;
}
}
19
Source : WaveCircle.cs
with MIT License
from DinoChan
with MIT License
from DinoChan
private void OnSizeChanged(object sender, Windows.UI.Xaml.SizeChangedEventArgs e)
{
var length = (float)Math.Min(e.NewSize.Width, e.NewSize.Height) * 0.95;
var centerX = (float)e.NewSize.Width / 2;
var centerY = (float)e.NewSize.Height / 2;
var points = new List<Vector2>();
var r = length / 2;
var r2 = r * 1.06;
var r3 = r * 0.951;
int index = 0;
int segments = 100;
for (int i = 0; i < segments; i += 2)
{
var x = r * Math.Cos(i * 2 * Math.PI / segments) + centerX;
var y = r * Math.Sin(i * 2 * Math.PI / segments) + centerY;
points.Add(new Vector2((float)x, (float)y));
var currentR = index++ % 2 == 0 ? r2 : r3;
x = currentR * Math.Cos((i + 1) * 2 * Math.PI / segments) + centerX;
y = currentR * Math.Sin((i + 1) * 2 * Math.PI / segments) + centerY;
points.Add(new Vector2((float)x, (float)y));
}
points.Add(points[0]);
CanvasGeometry result;
using (var builder = new CanvasPathBuilder(null))
{
builder.BeginFigure(points[0]);
for (int i = 0; i < points.Count - 2; i += 2)
{
var currentPoint = points[i];
var centerPoint = points[i + 1];
var nextPoint = points[i + 2];
builder.AddCubicBezier(currentPoint, centerPoint, nextPoint);
}
builder.EndFigure(CanvasFigureLoop.Open);
result = CanvasGeometry.CreatePath(builder);
}
var compositor = Window.Current.Compositor;
var path = new CompositionPath(result);
var line3 = compositor.CreatePathGeometry();
line3.Path = path;
var shape3 = compositor.CreateSpriteShape(line3);
shape3.FillBrush = compositor.CreateColorBrush(Colors.Red);
var visual = compositor.CreateShapeVisual();
visual.Shapes.Add(shape3);
visual.Size = e.NewSize.ToVector2();
ElementCompositionPreview.SetElementChildVisual(this, visual);
}
19
Source : Helperfunctions.cs
with Apache License 2.0
from DLR-SC
with Apache License 2.0
from DLR-SC
public static Mesh convertTriangleNETMesh(TriangleNet.Meshing.IMesh tMesh)
{
List<Vector3> outVertices = new List<Vector3>();
List<int> outIndices = new List<int>();
foreach (ITriangle t in tMesh.Triangles)
{
for (int j = 2; j >= 0; j--)
{
bool found = false;
for (int k = 0; k < outVertices.Count; k++)
{
if ((outVertices[k].x == t.GetVertex(j).x) && (outVertices[k].z == t.GetVertex(j).y) && (outVertices[k].y == t.GetVertex(j).z))
{
outIndices.Add(k);
found = true;
break;
}
}
if (!found)
{
outVertices.Add(new Vector3((float)t.GetVertex(j).x, (float)t.GetVertex(j).z, (float)t.GetVertex(j).y));
outIndices.Add(outVertices.Count - 1);
}
}
}
List<Vector2> uvs = new List<Vector2>();
for (int i = 0; i < outVertices.Count; i++)
uvs.Add(new Vector2(outVertices[i].x, outVertices[i].z));
Mesh resultMesh = new Mesh();
resultMesh.SetVertices(outVertices);
resultMesh.SetTriangles(outIndices, 0);
resultMesh.SetUVs(0, uvs);
resultMesh.RecalculateBounds();
resultMesh.RecalculateNormals();
return resultMesh;
}
19
Source : OsgiProjectConstructor.cs
with Apache License 2.0
from DLR-SC
with Apache License 2.0
from DLR-SC
private List<Vector2> resolvePckgFragmentRefList( List<JSONObject> pckgFragmentRefList)
{
List<Vector2> result = new List<Vector2>();
foreach (JSONObject reference in pckgFragmentRefList)
{
string rawRefString = reference.GetField("$ref").str;
string processedString = "";
processedString = rawRefString.Replace("//@bundles.", "");
processedString = processedString.Replace("/@packageFragments.", ",");
string[] valueString = processedString.Split(',');
result.Add(new Vector2(float.Parse(valueString[0]), float.Parse(valueString[1])));
}
return result;
}
19
Source : SandboxDev.cs
with zlib License
from dotsnav
with zlib License
from dotsnav
void Awake()
{
_navmesh = Plane.GetComponent<DotsNavNavmesh>();
foreach (var obstacle in FindObjectsOfType<DotsNavObstacle>())
{
var l = new List<Vector2>();
for (int i = 0; i < obstacle.Vertices.Length; i++)
l.Add(obstacle.GetVertexWorldSpace(i).xz);
_toDump.Add(l);
}
_cameraController = FindObjectOfType<CameraController>();
_cameraController.Initialize(Plane.Size);
_lineDrawer = GetComponent<LineDrawer>();
_camera = Camera.main;
Help.gameObject.SetActive(!Application.isEditor);
_agent = FindObjectOfType<DotsNavPathFindingAgent>();
var tr = _agent.transform;
_start = tr.parent;
_goal = _start.Find("Goal");
_goal.parent = null;
if (Reverse)
{
var tempPos = _start.position;
_start.position = _goal.position;
_goal.position = tempPos;
}
var size = _start.localScale.x;
var s = new Vector3(size, size, size);
_goal.localScale = s;
_agent.GetComponent<DotsNavAgent>().Radius = size / 2;
}
19
Source : SandboxDev.cs
with zlib License
from dotsnav
with zlib License
from dotsnav
static unsafe void ClampObstacle(List<Vector2> vertices, Vector2 size)
{
var buffer = new List<Vector2>(vertices);
vertices.Clear();
var hs = size / 2;
var br = new Vector2(hs.x, -hs.y);
var tl = new Vector2(-hs.x, hs.y);
var l = stackalloc Vector2[2];
for (var i = 0; i < buffer.Count; i++)
{
var f = buffer[i];
if (DemoMath.Contains(f, -hs, hs))
vertices.Add(f);
if (i < buffer.Count - 1)
{
var next = buffer[i + 1];
var li = 0;
if (DemoMath.IntersectSegSeg(f, next, -hs, br, out var r))
l[li++] = r;
if (DemoMath.IntersectSegSeg(f, next, br, hs, out r))
l[li++] = r;
if (DemoMath.IntersectSegSeg(f, next, hs, tl, out r))
l[li++] = r;
if (DemoMath.IntersectSegSeg(f, next, tl, -hs, out r))
l[li++] = r;
switch (li)
{
case 1:
AddCorner(l[0]);
vertices.Add(l[0]);
break;
case 2 when math.lengthsq(l[0] - f) < math.lengthsq(l[1] - f):
vertices.Add(l[0]);
vertices.Add(l[1]);
break;
case 2:
vertices.Add(l[1]);
vertices.Add(l[0]);
break;
}
}
}
if (vertices.Count == 1)
vertices.Clear();
void AddCorner(Vector2 point)
{
Side a, b;
if (vertices.Count == 0 || (a = GetSide(point)) == Side.None || (b = GetSide(vertices.Last())) == Side.None || a == b)
return;
var aIsHor = a == Side.Bottom || a == Side.Top;
switch (aIsHor ? a : b)
{
case Side.Top:
switch (aIsHor ? b : a)
{
case Side.Left:
vertices.Add(tl);
return;
case Side.Right:
vertices.Add(hs);
return;
}
break;
case Side.Bottom:
switch (aIsHor ? b : a)
{
case Side.Left:
vertices.Add(-hs);
return;
case Side.Right:
vertices.Add(br);
return;
}
break;
}
throw new ArgumentOutOfRangeException();
}
Side GetSide(Vector2 p)
{
if (p.x == -hs.x)
return Side.Left;
if (p.x == hs.x)
return Side.Right;
if (p.y == -hs.y)
return Side.Bottom;
if (p.y == hs.y)
return Side.Top;
return Side.None;
}
}
19
Source : Sandbox.cs
with zlib License
from dotsnav
with zlib License
from dotsnav
void ProcessInputAndUpdateUi()
{
if (Input.GetKeyDown(KeyCode.M))
{
SceneManager.LoadScene("menu");
return;
}
if (Input.GetKeyDown(KeyCode.Escape))
{
_points.Clear();
_points.Add(new List<Vector2>());
_placingPrefab = -1;
}
var prev = _placingPrefab;
if (Input.GetKeyDown(KeyCode.Alpha1))
_placingPrefab = 0;
if (Input.GetKeyDown(KeyCode.Alpha2))
_placingPrefab = 1;
if (Input.GetKeyDown(KeyCode.Alpha3))
_placingPrefab = 2;
if (Input.GetKeyDown(KeyCode.Alpha4))
_placingPrefab = 3;
if (Input.GetKeyDown(KeyCode.Alpha5))
_placingPrefab = 4;
var mousePosRaw = Input.mousePosition;
mousePosRaw.z = _camera.nearClipPlane;
var mousePos = (Vector2) _camera.ScreenToWorldPoint(mousePosRaw).xz();
var scrollDelta = Input.mouseScrollDelta.y;
var mouseDelta = mousePos - _previousMouse;
_previousMouse = mousePos;
if (_placingPrefab != -1)
{
if (prev != _placingPrefab)
_prefabSize = _placingPrefab < 4
? _cameraController.Zoom
: Mathf.Min(1, _cameraController.Zoom * 2);
if (scrollDelta != 0 && Input.GetKey(KeyCode.LeftShift))
_prefabRotation += scrollDelta * PrefabRotationSpeed;
if (scrollDelta != 0 && Input.GetKey(KeyCode.LeftControl))
_prefabSize = math.clamp(_prefabSize + scrollDelta * PrefabSizeSpeed * _prefabSize, PrefabMinSize, PrefabMaxSize);
_points.Clear();
var start = _placingPrefab;
var end = _placingPrefab == 4 ? 14 : _placingPrefab + 1;
for (int i = start; i < end; i++)
{
var obstacle = Prefabs[i];
var verts = obstacle.Vertices;
var points = new List<Vector2>();
foreach (var vert in verts)
points.Add(DemoMath.Rotate(vert * _prefabSize, _prefabRotation) + mousePos);
_points.Add(points);
}
if (Input.GetMouseButtonDown(0))
Insert();
}
else
{
if (Input.GetMouseButtonDown(1) && _points[0].Count > 0)
{
if (_points[0].Count > 1)
{
if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) && _points[0].Count > 2)
_points[0].Add(_points[0][0]);
Insert();
}
}
if (Input.GetMouseButtonDown(0))
{
var ray = _camera.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray.origin, ray.direction * 10, out var hit))
_target = hit.collider.gameObject;
if (_target == null || _points[0].Count > 0)
_points[0].Add(mousePos);
}
if (Input.GetMouseButtonUp(0))
_target = null;
if (scrollDelta != 0 && Input.GetKey(KeyCode.LeftControl))
{
var size = _start.localScale.x;
size = math.clamp(size + scrollDelta * AgentSizeZoomSpeed * size, MinAgentSize, MaxAgentSize);
var s = new Vector3(size, size, size);
_start.localScale = s;
_goal.localScale = s;
_agent.GetComponent<DotsNavAgent>().Radius = size / 2;
}
if (_target != null && Input.GetMouseButton(0) && !Input.GetMouseButtonDown(0) && mouseDelta != Vector2.zero)
_target.transform.position += mouseDelta.ToXxY();
}
if (Input.GetKeyDown(KeyCode.E))
_navmesh.DrawMode = _navmesh.DrawMode == DrawMode.Constrained ? DrawMode.Both : DrawMode.Constrained;
if (Input.GetKeyDown(KeyCode.H))
Help.gameObject.SetActive(!Help.gameObject.activeSelf);
if ((Input.GetKey(KeyCode.T) || Input.GetKeyDown(KeyCode.R)) && _obstacles.Count > 0)
{
Plane.RemoveObstacle(_obstacles.Last());
_obstacles.RemoveAt(_obstacles.Count - 1);
}
if (Input.GetKeyDown(KeyCode.C))
_agent.DrawCorners = !_agent.DrawCorners;
foreach (var points in _points)
for (int i = 1; i < points.Count; i++)
_lineDrawer.DrawLine(points[i - 1], points[i], Color.cyan);
if (_placingPrefab == -1 && _points[0].Count > 0)
_lineDrawer.DrawLine(_points[0][_points[0].Count - 1], mousePos, Color.cyan);
}
19
Source : Sandbox.cs
with zlib License
from dotsnav
with zlib License
from dotsnav
void ProcessInputAndUpdateUi()
{
if (Input.GetKeyDown(KeyCode.M))
{
SceneManager.LoadScene("menu");
return;
}
if (Input.GetKeyDown(KeyCode.Escape))
{
_points.Clear();
_points.Add(new List<Vector2>());
_placingPrefab = -1;
}
var prev = _placingPrefab;
if (Input.GetKeyDown(KeyCode.Alpha1))
_placingPrefab = 0;
if (Input.GetKeyDown(KeyCode.Alpha2))
_placingPrefab = 1;
if (Input.GetKeyDown(KeyCode.Alpha3))
_placingPrefab = 2;
if (Input.GetKeyDown(KeyCode.Alpha4))
_placingPrefab = 3;
if (Input.GetKeyDown(KeyCode.Alpha5))
_placingPrefab = 4;
var mousePosRaw = Input.mousePosition;
mousePosRaw.z = _camera.nearClipPlane;
var mousePos = (Vector2) _camera.ScreenToWorldPoint(mousePosRaw).xz();
var scrollDelta = Input.mouseScrollDelta.y;
var mouseDelta = mousePos - _previousMouse;
_previousMouse = mousePos;
if (_placingPrefab != -1)
{
if (prev != _placingPrefab)
_prefabSize = _placingPrefab < 4
? _cameraController.Zoom
: Mathf.Min(1, _cameraController.Zoom * 2);
if (scrollDelta != 0 && Input.GetKey(KeyCode.LeftShift))
_prefabRotation += scrollDelta * PrefabRotationSpeed;
if (scrollDelta != 0 && Input.GetKey(KeyCode.LeftControl))
_prefabSize = math.clamp(_prefabSize + scrollDelta * PrefabSizeSpeed * _prefabSize, PrefabMinSize, PrefabMaxSize);
_points.Clear();
var start = _placingPrefab;
var end = _placingPrefab == 4 ? 14 : _placingPrefab + 1;
for (int i = start; i < end; i++)
{
var obstacle = Prefabs[i];
var verts = obstacle.Vertices;
var points = new List<Vector2>();
foreach (var vert in verts)
points.Add(DemoMath.Rotate(vert * _prefabSize, _prefabRotation) + mousePos);
_points.Add(points);
}
if (Input.GetMouseButtonDown(0))
Insert();
}
else
{
if (Input.GetMouseButtonDown(1) && _points[0].Count > 0)
{
if (_points[0].Count > 1)
{
if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) && _points[0].Count > 2)
_points[0].Add(_points[0][0]);
Insert();
}
}
if (Input.GetMouseButtonDown(0))
{
var ray = _camera.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray.origin, ray.direction * 10, out var hit))
_target = hit.collider.gameObject;
if (_target == null || _points[0].Count > 0)
_points[0].Add(mousePos);
}
if (Input.GetMouseButtonUp(0))
_target = null;
if (scrollDelta != 0 && Input.GetKey(KeyCode.LeftControl))
{
var size = _start.localScale.x;
size = math.clamp(size + scrollDelta * AgentSizeZoomSpeed * size, MinAgentSize, MaxAgentSize);
var s = new Vector3(size, size, size);
_start.localScale = s;
_goal.localScale = s;
_agent.GetComponent<DotsNavAgent>().Radius = size / 2;
}
if (_target != null && Input.GetMouseButton(0) && !Input.GetMouseButtonDown(0) && mouseDelta != Vector2.zero)
_target.transform.position += mouseDelta.ToXxY();
}
if (Input.GetKeyDown(KeyCode.E))
_navmesh.DrawMode = _navmesh.DrawMode == DrawMode.Constrained ? DrawMode.Both : DrawMode.Constrained;
if (Input.GetKeyDown(KeyCode.H))
Help.gameObject.SetActive(!Help.gameObject.activeSelf);
if ((Input.GetKey(KeyCode.T) || Input.GetKeyDown(KeyCode.R)) && _obstacles.Count > 0)
{
Plane.RemoveObstacle(_obstacles.Last());
_obstacles.RemoveAt(_obstacles.Count - 1);
}
if (Input.GetKeyDown(KeyCode.C))
_agent.DrawCorners = !_agent.DrawCorners;
foreach (var points in _points)
for (int i = 1; i < points.Count; i++)
_lineDrawer.DrawLine(points[i - 1], points[i], Color.cyan);
if (_placingPrefab == -1 && _points[0].Count > 0)
_lineDrawer.DrawLine(_points[0][_points[0].Count - 1], mousePos, Color.cyan);
}
19
Source : SandboxDev.cs
with zlib License
from dotsnav
with zlib License
from dotsnav
static unsafe void ClampObstacle(List<Vector2> vertices, Vector2 size)
{
var buffer = new List<Vector2>(vertices);
vertices.Clear();
var hs = size / 2;
var br = new Vector2(hs.x, -hs.y);
var tl = new Vector2(-hs.x, hs.y);
var l = stackalloc Vector2[2];
for (var i = 0; i < buffer.Count; i++)
{
var f = buffer[i];
if (DemoMath.Contains(f, -hs, hs))
vertices.Add(f);
if (i < buffer.Count - 1)
{
var next = buffer[i + 1];
var li = 0;
if (DemoMath.IntersectSegSeg(f, next, -hs, br, out var r))
l[li++] = r;
if (DemoMath.IntersectSegSeg(f, next, br, hs, out r))
l[li++] = r;
if (DemoMath.IntersectSegSeg(f, next, hs, tl, out r))
l[li++] = r;
if (DemoMath.IntersectSegSeg(f, next, tl, -hs, out r))
l[li++] = r;
switch (li)
{
case 1:
AddCorner(l[0]);
vertices.Add(l[0]);
break;
case 2 when math.lengthsq(l[0] - f) < math.lengthsq(l[1] - f):
vertices.Add(l[0]);
vertices.Add(l[1]);
break;
case 2:
vertices.Add(l[1]);
vertices.Add(l[0]);
break;
}
}
}
if (vertices.Count == 1)
vertices.Clear();
void AddCorner(Vector2 point)
{
Side a, b;
if (vertices.Count == 0 || (a = GetSide(point)) == Side.None || (b = GetSide(vertices.Last())) == Side.None || a == b)
return;
var aIsHor = a == Side.Bottom || a == Side.Top;
switch (aIsHor ? a : b)
{
case Side.Top:
switch (aIsHor ? b : a)
{
case Side.Left:
vertices.Add(tl);
return;
case Side.Right:
vertices.Add(hs);
return;
}
break;
case Side.Bottom:
switch (aIsHor ? b : a)
{
case Side.Left:
vertices.Add(-hs);
return;
case Side.Right:
vertices.Add(br);
return;
}
break;
}
throw new ArgumentOutOfRangeException();
}
Side GetSide(Vector2 p)
{
if (p.x == -hs.x)
return Side.Left;
if (p.x == hs.x)
return Side.Right;
if (p.y == -hs.y)
return Side.Bottom;
if (p.y == hs.y)
return Side.Top;
return Side.None;
}
}
19
Source : SandboxDev.cs
with zlib License
from dotsnav
with zlib License
from dotsnav
void ProcessInputAndUpdateUi()
{
if (Input.GetKeyDown(KeyCode.M))
{
SceneManager.LoadScene("menu");
return;
}
if (Input.GetKeyDown(KeyCode.Escape))
{
_points.Clear();
_points.Add(new List<Vector2>());
_placingPrefab = -1;
}
var prev = _placingPrefab;
if (Input.GetKeyDown(KeyCode.Alpha1))
_placingPrefab = 0;
if (Input.GetKeyDown(KeyCode.Alpha2))
_placingPrefab = 1;
if (Input.GetKeyDown(KeyCode.Alpha3))
_placingPrefab = 2;
if (Input.GetKeyDown(KeyCode.Alpha4))
_placingPrefab = 3;
if (Input.GetKeyDown(KeyCode.Alpha5))
_placingPrefab = 4;
var mousePosRaw = Input.mousePosition;
mousePosRaw.z = _camera.nearClipPlane;
var mousePos = (Vector2) _camera.ScreenToWorldPoint(mousePosRaw).xz();
var scrollDelta = Input.mouseScrollDelta.y;
var mouseDelta = mousePos - _previousMouse;
_previousMouse = mousePos;
if (_placingPrefab != -1)
{
if (prev != _placingPrefab)
_prefabSize = _placingPrefab < 4
? _cameraController.Zoom
: Mathf.Min(1, _cameraController.Zoom * 2);
if (scrollDelta != 0 && Input.GetKey(KeyCode.LeftShift))
_prefabRotation += scrollDelta * PrefabRotationSpeed;
if (scrollDelta != 0 && Input.GetKey(KeyCode.LeftControl))
_prefabSize = math.clamp(_prefabSize + scrollDelta * PrefabSizeSpeed * _prefabSize, PrefabMinSize, PrefabMaxSize);
_points.Clear();
var start = _placingPrefab;
var end = _placingPrefab == 4 ? 14 : _placingPrefab + 1;
for (int i = start; i < end; i++)
{
var obstacle = Prefabs[i];
var verts = obstacle.Vertices;
var points = new List<Vector2>();
foreach (var vert in verts)
points.Add(DemoMath.Rotate(vert * _prefabSize, _prefabRotation) + mousePos);
_points.Add(points);
}
if (Input.GetMouseButtonDown(0))
Insert();
}
else
{
if (Input.GetMouseButtonDown(1) && _points[0].Count > 0)
{
if (mousePos != _points[0].Last())
_points[0].Add(mousePos);
if (_points[0].Count > 1)
{
if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) && _points.Count > 2)
_points[0].Add(_points[0][0]);
Insert();
}
}
if (Input.GetMouseButtonDown(0))
{
var ray = _camera.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray.origin, ray.direction * 10, out var hit))
_target = hit.collider.gameObject;
if (_target == null || _points[0].Count > 0)
_points[0].Add(mousePos);
}
if (Input.GetMouseButtonUp(0))
_target = null;
if (scrollDelta != 0 && Input.GetKey(KeyCode.LeftControl))
{
var size = _start.localScale.x;
size = math.clamp(size + scrollDelta * AgentSizeZoomSpeed * size, MinAgentSize, MaxAgentSize);
var s = new Vector3(size, size, size);
_start.localScale = s;
_goal.localScale = s;
_agent.GetComponent<DotsNavAgent>().Radius = size / 2;
}
if (_target != null && Input.GetMouseButton(0) && !Input.GetMouseButtonDown(0) && mouseDelta != Vector2.zero)
_target.transform.position += mouseDelta.ToXxY();
}
if (Input.GetKeyDown(KeyCode.E))
_navmesh.DrawMode = _navmesh.DrawMode == DrawMode.Constrained ? DrawMode.Both : DrawMode.Constrained;
if (Input.GetKeyDown(KeyCode.H))
Help.gameObject.SetActive(!Help.gameObject.activeSelf);
if ((Input.GetKey(KeyCode.T) || Input.GetKeyDown(KeyCode.R)) && _obstacles.Count > 0)
{
Plane.RemoveObstacle(_obstacles.Last());
_obstacles.RemoveAt(_obstacles.Count - 1);
}
foreach (var points in _points)
for (int i = 1; i < points.Count; i++)
_lineDrawer.DrawLine(points[i - 1], points[i], Color.cyan);
if (_placingPrefab == -1 && _points[0].Count > 0)
_lineDrawer.DrawLine(_points[0][_points[0].Count - 1], mousePos, Color.cyan);
}
19
Source : SandboxDev.cs
with zlib License
from dotsnav
with zlib License
from dotsnav
void ProcessInputAndUpdateUi()
{
if (Input.GetKeyDown(KeyCode.M))
{
SceneManager.LoadScene("menu");
return;
}
if (Input.GetKeyDown(KeyCode.Escape))
{
_points.Clear();
_points.Add(new List<Vector2>());
_placingPrefab = -1;
}
var prev = _placingPrefab;
if (Input.GetKeyDown(KeyCode.Alpha1))
_placingPrefab = 0;
if (Input.GetKeyDown(KeyCode.Alpha2))
_placingPrefab = 1;
if (Input.GetKeyDown(KeyCode.Alpha3))
_placingPrefab = 2;
if (Input.GetKeyDown(KeyCode.Alpha4))
_placingPrefab = 3;
if (Input.GetKeyDown(KeyCode.Alpha5))
_placingPrefab = 4;
var mousePosRaw = Input.mousePosition;
mousePosRaw.z = _camera.nearClipPlane;
var mousePos = (Vector2) _camera.ScreenToWorldPoint(mousePosRaw).xz();
var scrollDelta = Input.mouseScrollDelta.y;
var mouseDelta = mousePos - _previousMouse;
_previousMouse = mousePos;
if (_placingPrefab != -1)
{
if (prev != _placingPrefab)
_prefabSize = _placingPrefab < 4
? _cameraController.Zoom
: Mathf.Min(1, _cameraController.Zoom * 2);
if (scrollDelta != 0 && Input.GetKey(KeyCode.LeftShift))
_prefabRotation += scrollDelta * PrefabRotationSpeed;
if (scrollDelta != 0 && Input.GetKey(KeyCode.LeftControl))
_prefabSize = math.clamp(_prefabSize + scrollDelta * PrefabSizeSpeed * _prefabSize, PrefabMinSize, PrefabMaxSize);
_points.Clear();
var start = _placingPrefab;
var end = _placingPrefab == 4 ? 14 : _placingPrefab + 1;
for (int i = start; i < end; i++)
{
var obstacle = Prefabs[i];
var verts = obstacle.Vertices;
var points = new List<Vector2>();
foreach (var vert in verts)
points.Add(DemoMath.Rotate(vert * _prefabSize, _prefabRotation) + mousePos);
_points.Add(points);
}
if (Input.GetMouseButtonDown(0))
Insert();
}
else
{
if (Input.GetMouseButtonDown(1) && _points[0].Count > 0)
{
if (mousePos != _points[0].Last())
_points[0].Add(mousePos);
if (_points[0].Count > 1)
{
if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) && _points.Count > 2)
_points[0].Add(_points[0][0]);
Insert();
}
}
if (Input.GetMouseButtonDown(0))
{
var ray = _camera.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray.origin, ray.direction * 10, out var hit))
_target = hit.collider.gameObject;
if (_target == null || _points[0].Count > 0)
_points[0].Add(mousePos);
}
if (Input.GetMouseButtonUp(0))
_target = null;
if (scrollDelta != 0 && Input.GetKey(KeyCode.LeftControl))
{
var size = _start.localScale.x;
size = math.clamp(size + scrollDelta * AgentSizeZoomSpeed * size, MinAgentSize, MaxAgentSize);
var s = new Vector3(size, size, size);
_start.localScale = s;
_goal.localScale = s;
_agent.GetComponent<DotsNavAgent>().Radius = size / 2;
}
if (_target != null && Input.GetMouseButton(0) && !Input.GetMouseButtonDown(0) && mouseDelta != Vector2.zero)
_target.transform.position += mouseDelta.ToXxY();
}
if (Input.GetKeyDown(KeyCode.E))
_navmesh.DrawMode = _navmesh.DrawMode == DrawMode.Constrained ? DrawMode.Both : DrawMode.Constrained;
if (Input.GetKeyDown(KeyCode.H))
Help.gameObject.SetActive(!Help.gameObject.activeSelf);
if ((Input.GetKey(KeyCode.T) || Input.GetKeyDown(KeyCode.R)) && _obstacles.Count > 0)
{
Plane.RemoveObstacle(_obstacles.Last());
_obstacles.RemoveAt(_obstacles.Count - 1);
}
foreach (var points in _points)
for (int i = 1; i < points.Count; i++)
_lineDrawer.DrawLine(points[i - 1], points[i], Color.cyan);
if (_placingPrefab == -1 && _points[0].Count > 0)
_lineDrawer.DrawLine(_points[0][_points[0].Count - 1], mousePos, Color.cyan);
}
19
Source : StressTest.cs
with zlib License
from dotsnav
with zlib License
from dotsnav
void Insert()
{
var p = Prefabs[_r.NextInt(Prefabs.Length)];
var scale = 1 - ScaleOffset + _r.NextFloat() * 2 * ScaleOffset;
var rot = _r.NextFloat(2 * math.PI);
_points.Clear();
foreach (var f in p.Vertices)
_points.Add(DemoMath.Rotate(scale * f, rot));
var min = new float2(float.MaxValue);
var max = new float2(float.MinValue);
for (var i = 0; i < _points.Count; i++)
{
min = math.min(_points[i], min);
max = math.max(_points[i], max);
}
var size = max - min;
var range = (float2) Plane.Size - size;
var offset = _r.NextFloat2(range);
for (var i = 0; i < _points.Count; i++)
_points[i] += (Vector2) (offset - min - (float2) Plane.Size / 2);
_ids.Add(Plane.InsertObstacle(_points));
}
19
Source : Sandbox.cs
with zlib License
from dotsnav
with zlib License
from dotsnav
static unsafe void ClampObstacle(List<Vector2> vertices, Vector2 size)
{
var buffer = new List<Vector2>(vertices);
vertices.Clear();
var hs = size / 2;
var br = new Vector2(hs.x, -hs.y);
var tl = new Vector2(-hs.x, hs.y);
var l = stackalloc Vector2[2];
for (var i = 0; i < buffer.Count; i++)
{
var f = buffer[i];
if (DemoMath.Contains(f, -hs, hs))
vertices.Add(f);
if (i < buffer.Count - 1)
{
var next = buffer[i + 1];
var li = 0;
if (DemoMath.IntersectSegSeg(f, next, -hs, br, out var r))
l[li++] = r;
if (DemoMath.IntersectSegSeg(f, next, br, hs, out r))
l[li++] = r;
if (DemoMath.IntersectSegSeg(f, next, hs, tl, out r))
l[li++] = r;
if (DemoMath.IntersectSegSeg(f, next, tl, -hs, out r))
l[li++] = r;
switch (li)
{
case 1:
AddCorner(l[0]);
vertices.Add(l[0]);
break;
case 2 when math.lengthsq(l[0] - f) < math.lengthsq(l[1] - f):
vertices.Add(l[0]);
vertices.Add(l[1]);
break;
case 2:
vertices.Add(l[1]);
vertices.Add(l[0]);
break;
}
}
}
if (vertices.Count == 1)
vertices.Clear();
void AddCorner(Vector2 point)
{
Side a, b;
if (vertices.Count == 0 || (a = GetSide(point)) == Side.None || (b = GetSide(vertices.Last())) == Side.None || a == b)
return;
var aIsHor = a == Side.Bottom || a == Side.Top;
switch (aIsHor ? a : b)
{
case Side.Top:
switch (aIsHor ? b : a)
{
case Side.Left:
vertices.Add(tl);
return;
case Side.Right:
vertices.Add(hs);
return;
}
break;
case Side.Bottom:
switch (aIsHor ? b : a)
{
case Side.Left:
vertices.Add(-hs);
return;
case Side.Right:
vertices.Add(br);
return;
}
break;
}
throw new ArgumentOutOfRangeException();
}
Side GetSide(Vector2 p)
{
if (p.x == -hs.x)
return Side.Left;
if (p.x == hs.x)
return Side.Right;
if (p.y == -hs.y)
return Side.Bottom;
if (p.y == hs.y)
return Side.Top;
return Side.None;
}
}
19
Source : Sandbox.cs
with zlib License
from dotsnav
with zlib License
from dotsnav
static unsafe void ClampObstacle(List<Vector2> vertices, Vector2 size)
{
var buffer = new List<Vector2>(vertices);
vertices.Clear();
var hs = size / 2;
var br = new Vector2(hs.x, -hs.y);
var tl = new Vector2(-hs.x, hs.y);
var l = stackalloc Vector2[2];
for (var i = 0; i < buffer.Count; i++)
{
var f = buffer[i];
if (DemoMath.Contains(f, -hs, hs))
vertices.Add(f);
if (i < buffer.Count - 1)
{
var next = buffer[i + 1];
var li = 0;
if (DemoMath.IntersectSegSeg(f, next, -hs, br, out var r))
l[li++] = r;
if (DemoMath.IntersectSegSeg(f, next, br, hs, out r))
l[li++] = r;
if (DemoMath.IntersectSegSeg(f, next, hs, tl, out r))
l[li++] = r;
if (DemoMath.IntersectSegSeg(f, next, tl, -hs, out r))
l[li++] = r;
switch (li)
{
case 1:
AddCorner(l[0]);
vertices.Add(l[0]);
break;
case 2 when math.lengthsq(l[0] - f) < math.lengthsq(l[1] - f):
vertices.Add(l[0]);
vertices.Add(l[1]);
break;
case 2:
vertices.Add(l[1]);
vertices.Add(l[0]);
break;
}
}
}
if (vertices.Count == 1)
vertices.Clear();
void AddCorner(Vector2 point)
{
Side a, b;
if (vertices.Count == 0 || (a = GetSide(point)) == Side.None || (b = GetSide(vertices.Last())) == Side.None || a == b)
return;
var aIsHor = a == Side.Bottom || a == Side.Top;
switch (aIsHor ? a : b)
{
case Side.Top:
switch (aIsHor ? b : a)
{
case Side.Left:
vertices.Add(tl);
return;
case Side.Right:
vertices.Add(hs);
return;
}
break;
case Side.Bottom:
switch (aIsHor ? b : a)
{
case Side.Left:
vertices.Add(-hs);
return;
case Side.Right:
vertices.Add(br);
return;
}
break;
}
throw new ArgumentOutOfRangeException();
}
Side GetSide(Vector2 p)
{
if (p.x == -hs.x)
return Side.Left;
if (p.x == hs.x)
return Side.Right;
if (p.y == -hs.y)
return Side.Bottom;
if (p.y == hs.y)
return Side.Top;
return Side.None;
}
}
19
Source : PointCloud.cs
with GNU Lesser General Public License v3.0
from Edgar077
with GNU Lesser General Public License v3.0
from Edgar077
public void InitUVsFromVectors()
{
List<Vector2> uvList = new List<Vector2>();
for (int i = 0; i < this.Vectors.Length; i++ )
{
Vector2 v = new Vector2(this.Vectors[i].X, this.Vectors[i].Y);
uvList.Add(v);
}
this.TextureUVs = uvList.ToArray();
}
19
Source : CurlParticleUtility.cs
with MIT License
from edom18
with MIT License
from edom18
static public Mesh CreateCombinedMesh(Mesh mesh, int num)
{
replacedert.IsTrue(mesh.vertexCount * num <= MAX_VERTEX_NUM);
int[] meshIndices = mesh.GetIndices(0);
int indexNum = meshIndices.Length;
// Buffer
int[] indices = new int[num * indexNum];
List<Vector2> uv0 = new List<Vector2>();
List<Vector2> uv1 = new List<Vector2>();
List<Vector3> vertices = new List<Vector3>();
List<Vector3> normals = new List<Vector3>();
List<Vector4> tangents = new List<Vector4>();
for (int id = 0; id < num; id++)
{
vertices.AddRange(mesh.vertices);
normals.AddRange(mesh.normals);
tangents.AddRange(mesh.tangents);
uv0.AddRange(mesh.uv);
// 各メッシュのIndexは、1つのモデルの頂点数 * ID分ずらす
for (int n = 0; n < indexNum; n++)
{
indices[id * indexNum + n] = id * mesh.vertexCount + meshIndices[n];
}
// 2番目のUVにIDを格納しておく
for (int n = 0; n < mesh.uv.Length; n++)
{
uv1.Add(new Vector2(id, id));
}
}
Mesh combinedMesh = new Mesh();
combinedMesh.SetVertices(vertices);
combinedMesh.SetIndices(indices, MeshTopology.Triangles, 0);
combinedMesh.SetNormals(normals);
combinedMesh.RecalculateNormals();
combinedMesh.SetTangents(tangents);
combinedMesh.SetUVs(0, uv0);
combinedMesh.SetUVs(1, uv1);
combinedMesh.RecalculateBounds();
Bounds bounds = new Bounds();
bounds.center = combinedMesh.bounds.center;
bounds.SetMinMax(Vector3.one * -100f, Vector3.one * 100f);
combinedMesh.bounds = bounds;
return combinedMesh;
}
19
Source : Mesh_Maker.cs
with MIT License
from ElasticSea
with MIT License
from ElasticSea
public void AddTriangle(
Vector3[] vertices,
Vector3[] normals,
Vector2[] uvs,
Vector4[] tangents,
int submesh){
int vertCount = _vertices.Count;
_vertices.Add(vertices[0]);
_vertices.Add(vertices[1]);
_vertices.Add(vertices[2]);
_normals.Add(normals[0]);
_normals.Add(normals[1]);
_normals.Add(normals[2]);
_uvs.Add(uvs[0]);
_uvs.Add(uvs[1]);
_uvs.Add(uvs[2]);
_tangents.Add(tangents[0]);
_tangents.Add(tangents[1]);
_tangents.Add(tangents[2]);
if(_subIndices.Count < submesh+1){
for(int i=_subIndices.Count; i<submesh+1; i++){
_subIndices.Add(new List<int>());
}
}
_subIndices[submesh].Add(vertCount);
_subIndices[submesh].Add(vertCount+1);
_subIndices[submesh].Add(vertCount+2);
}
19
Source : Mesh_Maker.cs
with MIT License
from ElasticSea
with MIT License
from ElasticSea
public void AddTriangle(
Vector3[] vertices,
Vector3[] normals,
Vector2[] uvs,
int submesh){
int vertCount = _vertices.Count;
_vertices.Add(vertices[0]);
_vertices.Add(vertices[1]);
_vertices.Add(vertices[2]);
_normals.Add(normals[0]);
_normals.Add(normals[1]);
_normals.Add(normals[2]);
_uvs.Add(uvs[0]);
_uvs.Add(uvs[1]);
_uvs.Add(uvs[2]);
if(_subIndices.Count < submesh+1){
for(int i=_subIndices.Count; i<submesh+1; i++){
_subIndices.Add(new List<int>());
}
}
_subIndices[submesh].Add(vertCount);
_subIndices[submesh].Add(vertCount+1);
_subIndices[submesh].Add(vertCount+2);
}
19
Source : SpriteBuilder.cs
with MIT License
from Elringus
with MIT License
from Elringus
private void AddVertex (Vector2 position, Vector2 uv)
{
vertices.Add(position);
uvs.Add(uv);
}
19
Source : StaticMeshIntegrator.cs
with BSD 2-Clause "Simplified" License
from emilianavt
with BSD 2-Clause "Simplified" License
from emilianavt
public void Push(Matrix4x4 localToRoot, Mesh mesh, Material[] materials)
{
var offset = m_positions.Count;
var hasNormal = m_normals.Count == m_positions.Count;
var hasUv = m_uv.Count == m_positions.Count;
// attributes
m_positions.AddRange(mesh.vertices.Select(x => localToRoot.MultiplyPoint(x)));
if(mesh.normals!=null && mesh.normals.Length == mesh.vertexCount)
{
if (!hasNormal) for (int i = m_normals.Count; i < m_positions.Count; ++i) m_normals.Add(Vector3.zero);
m_normals.AddRange(mesh.normals.Select(x => localToRoot.MultiplyVector(x)));
}
if (mesh.uv != null && mesh.uv.Length == mesh.vertexCount)
{
if (!hasUv) for (int i = m_uv.Count; i < m_positions.Count; ++i) m_uv.Add(Vector2.zero);
m_uv.AddRange(mesh.uv);
}
// indices
for (int i = 0; i < mesh.subMeshCount; ++i)
{
m_subMeshes.Add(mesh.GetIndices(i).Select(x => offset + x).ToArray());
}
// materials
m_materials.AddRange(materials);
}
19
Source : StaticMeshIntegrator.cs
with BSD 2-Clause "Simplified" License
from emilianavt
with BSD 2-Clause "Simplified" License
from emilianavt
public Mesh ToMesh()
{
var mesh = new Mesh();
mesh.name = "integrated";
mesh.vertices = m_positions.ToArray();
if (m_normals.Count > 0)
{
if (m_normals.Count < m_positions.Count) for (int i = m_normals.Count; i < m_positions.Count; ++i) m_normals.Add(Vector3.zero);
mesh.normals = m_normals.ToArray();
}
if (m_uv.Count > 0)
{
if (m_uv.Count < m_positions.Count) for (int i = m_uv.Count; i < m_positions.Count; ++i) m_uv.Add(Vector2.zero);
mesh.uv = m_uv.ToArray();
}
mesh.subMeshCount = m_subMeshes.Count;
for(int i=0; i<m_subMeshes.Count; ++i)
{
mesh.SetIndices(m_subMeshes[i], MeshTopology.Triangles, i);
}
return mesh;
}
19
Source : Love.Physics.DebugView.cs
with MIT License
from endlesstravel
with MIT License
from endlesstravel
public void Draw()
{
// draw body
{
bodyCount = world.GetBodyCount();
foreach (var body in world.GetBodies())
{
DrawBody(body);
}
}
// draw joint
{
Graphics.SetColor(0.5f, 0.8f, 0.8f, 1);
foreach (var joint in world.GetJoints())
{
DrawJoint(joint);
}
}
// draw contacts
{
Graphics.SetColor(Color.Red); // read
List<Vector2> pointList = new List<Vector2>();
var carray = world.GetContacts();
for (int cidx = 0; cidx < carray.Length; cidx++)
{
var c = carray[cidx];
foreach (var p in c.GetPositions())
{
if (p.X != 0)
{
pointList.Add(p);
}
}
}
Graphics.Points(pointList.ToArray());
}
}
19
Source : T01_Tiles.cs
with MIT License
from endlesstravel
with MIT License
from endlesstravel
public void Draw(List<KeyValuePair<Body, PolygonShape>> ddlistraw)
{
List<Vector2> list = new List<Vector2>(ddlistraw.Count);
List<RectangleF> listx = new List<RectangleF>(ddlistraw.Count);
for (int i = 0; i < ddlistraw.Count; i++)
{
var body = ddlistraw[i].Key;
var rect = ddlistraw[i].Value;
var pos = ((body.GetPosition() + rect.GetPoints()[0]));
list.Add(pos);
var size = rect.GetPoints()[2] - rect.GetPoints()[0];
var r = new RectangleF(pos, new SizeF(size));
listx.Add(r);
Graphics.SetColor(ColorByBody(body));
Graphics.Rectangle(DrawMode.Line, r);
}
}
See More Examples