/// <summary> /// Initializes a new instance of the <see cref="EmaModel"/> class. /// </summary> /// <param name="inscription">Inscription.</param> /// <param name="type">Type.</param> /// <param name="gameObject">Game object.</param> public EmaModel (string inscription, EmaType type, GameObject gameObject) { Inscription = inscription; Type = type; GameObject = gameObject; Position = new SerializableVector3 (gameObject.transform.position); Rotation = new SerializableQuaternion (gameObject.transform.rotation); }
public Hexagon(int i, Vector3 c, Vector3[] verts, SerializableVector3 origin) { index = i; neighbors = new int[]{-1,-1,-1,-1,-1,-1}; center = c; v1 = verts[0]; v2 = verts[1]; v3 = verts[2]; v4 = verts[3]; v5 = verts[4]; v6 = verts[5]; normal = ((Vector3)(center - origin)).normalized; foreach (Vector3 v in PolySphere.icoCoords) { if (Vector3.Angle(center, v) < 0.1f) { isPentagon = true; } } }
public static SerializableVector3 RoundOff(this SerializableVector3 vector, float roundTo) { return(new SerializableVector3((float)Math.Round(vector.X / roundTo, 0, MidpointRounding.ToEven) * roundTo, (float)Math.Round(vector.Y / roundTo, 0, MidpointRounding.ToEven) * roundTo, (float)Math.Round(vector.Z / roundTo, 0, MidpointRounding.ToEven) * roundTo)); }
private Vector3 Vec3(SerializableVector3 v) { return(new Vector3(v.x, v.y, v.z)); }
public void Generate(string playerName, SerializableVector3 position, SerializableQuaternion rotation) { PlayerName = playerName; Position = position; Rotation = rotation; }
public void UpdateColor(SerializableVector3 vector3) { Cube.ColorMaskHSV = vector3; SetColor(vector3); }
public TeleportAction(SerializableVector3 position) { this.position = position; }
public GameObject HexPlate(World world, TileSet tileSet, int i) { GameObject output = (GameObject)Instantiate(worldPrefab, Vector3.zero, Quaternion.identity); MeshFilter myFilter = output.GetComponent <MeshFilter>(); MeshCollider myCollider = output.GetComponent <MeshCollider>(); SerializableVector3 origin = world.origin; List <Vector3> vertices = new List <Vector3>(); List <int> triangles = new List <int>(); List <Vector3> normals = new List <Vector3>(); List <Vector2> uvs = new List <Vector2>(); //Switch between UV Modes if (hexagonal) //Hexagonal uvs { //Copypasta from worldrenderer float texHeight = 8192f; //tileSet.texture.height; float texWidth = 8192f; //tileSet.texture.width; //float root3 = Mathf.Sqrt(3); uvTileWidth = 1.0f / 42.0f; //tileSet.tileWidth / texWidth; uvTileHeight = 1.0f / 42.0f; //tileSet.tileHeight / texHeight; //float side = uvTileWidth / 2.0f; // float radius = Mathf.Sqrt((3.0f * side * side) / 4.0f); /* * Vector2 uv0 = new Vector2(side, side), * uv1 = new Vector2(side, side + side), * uv2 = new Vector2(side + radius, side + side / 2.0f), * uv3 = new Vector2(side + radius, side / 2.0f), * uv4 = new Vector2(side, 0), * uv5 = new Vector2(side - radius, side / 2.0f), * uv6 = new Vector2(side - radius, side + side / 2.0f); */ uv0 = new Vector2(uvTileWidth / 2.0f, uvTileHeight / 2.0f); uv1 = new Vector2(10 / texWidth, 98 / texHeight); uv2 = new Vector2(54 / texWidth, 22 / texHeight); uv3 = new Vector2(141 / texWidth, 22 / texHeight); uv4 = new Vector2(185 / texWidth, 98 / texHeight); uv5 = new Vector2(141 / texWidth, 173 / texHeight); uv6 = new Vector2(54 / texWidth, 173 / texHeight); //Debug.Log (uv0.x + " " + uv0.y); //Debug.Log(uv1.x + " " + uv1.y); //Debug.Log(uv2.x + " " + uv2.y); //Debug.Log(uv3.x + " " + uv3.y); //Debug.Log(uv4.x + " " + uv4.y); //Debug.Log(uv5.x + " " + uv5.y); //Debug.Log (uv6.x + " " + uv6.y); foreach (HexTile ht in world.tiles) { if (ht.plate == i) { IntCoord uvCoord = tileSet.GetUVForType(ht.type); //Debug.Log("xCoord: "+ uvCoord.x + " type: "+ ht.type); Vector2 uvOffset = new Vector2(uvCoord.x * uvTileWidth, ht.generation * uvTileHeight); //uvCoord.y * uvTileHeight); // Origin point, every tile unfortunately repeats origin (@TODO and one vertex) for uv purposes int originIndex = vertices.Count; vertices.Add(origin); uvs.Add(uv0 + uvOffset); normals.Add(ht.hexagon.center - origin); // Center of hexagon int centerIndex = vertices.Count; ht.hexagon.uv0i = uvs.Count; // Triangle 1 vertices.Add(ht.hexagon.center); normals.Add((origin + ht.hexagon.center)); uvs.Add(uv0 + uvOffset); ht.hexagon.uv1i = uvs.Count; vertices.Add(ht.hexagon.v1); normals.Add((origin + ht.hexagon.v1)); uvs.Add(uv1 + uvOffset); ht.hexagon.uv2i = uvs.Count; vertices.Add(ht.hexagon.v2); normals.Add((origin + ht.hexagon.v2)); uvs.Add(uv2 + uvOffset); triangles.Add(centerIndex); triangles.Add(vertices.Count - 2); triangles.Add(vertices.Count - 1); // T2 ht.hexagon.uv3i = uvs.Count; vertices.Add(ht.hexagon.v3); normals.Add((origin + ht.hexagon.v3)); uvs.Add(uv3 + uvOffset); triangles.Add(centerIndex); triangles.Add(vertices.Count - 2); triangles.Add(vertices.Count - 1); // T3 ht.hexagon.uv4i = uvs.Count; vertices.Add(ht.hexagon.v4); normals.Add((origin + ht.hexagon.v4)); uvs.Add(uv4 + uvOffset); triangles.Add(centerIndex); triangles.Add(vertices.Count - 2); triangles.Add(vertices.Count - 1); // T4 ht.hexagon.uv5i = uvs.Count; vertices.Add(ht.hexagon.v5); normals.Add((origin + ht.hexagon.v5)); uvs.Add(uv5 + uvOffset); triangles.Add(centerIndex); triangles.Add(vertices.Count - 2); triangles.Add(vertices.Count - 1); // T5 ht.hexagon.uv6i = uvs.Count; vertices.Add(ht.hexagon.v6); normals.Add((origin + ht.hexagon.v6)); uvs.Add(uv6 + uvOffset); triangles.Add(centerIndex); triangles.Add(vertices.Count - 2); triangles.Add(vertices.Count - 1); // T6 triangles.Add(centerIndex); triangles.Add(vertices.Count - 1); //1 triangles.Add(vertices.Count - 6); //6 // Side 1 triangles.Add(originIndex); triangles.Add(vertices.Count - 1); triangles.Add(vertices.Count - 2); // Side 2 triangles.Add(originIndex); triangles.Add(vertices.Count - 2); triangles.Add(vertices.Count - 3); // Side 3 triangles.Add(originIndex); triangles.Add(vertices.Count - 3); triangles.Add(vertices.Count - 4); // Side 4 triangles.Add(originIndex); triangles.Add(vertices.Count - 4); triangles.Add(vertices.Count - 5); // Side 5 triangles.Add(originIndex); triangles.Add(vertices.Count - 5); triangles.Add(vertices.Count - 6); // Side 6 extra vertex triangles.Add(originIndex); triangles.Add(vertices.Count - 6); triangles.Add(vertices.Count - 1); } } } else //Triangle, assumed that the texture's tiles have equilateral triangle dimensions { Debug.Log("triangle uvs"); float uv2x = 1.0f / tileCountW; float uv1x = uv2x / 2; float uv1y = 1.0f / tileCountH; Vector2 uv0 = Vector2.zero, uv2 = new Vector2(uv2x, 0), uv1 = new Vector2(uv1x, uv1y); //Generate quadrant foreach (HexTile ht in world.tiles) { if (ht.plate == i) { IntCoord uvCoord = tileSet.GetUVForType(ht.type); //Debug.Log("xCoord: "+ uvCoord.x + " type: "+ ht.type); Vector2 uvOffset = new Vector2((uvCoord.x * uv2.x), (uvCoord.y * uv1.y)); // Origin point int originIndex = vertices.Count; vertices.Add(origin); uvs.Add(uv1 + uvOffset); normals.Add(ht.hexagon.center - origin); // Center of hexagon int centerIndex = vertices.Count; // Triangle 1 vertices.Add(ht.hexagon.center); normals.Add((origin + ht.hexagon.center)); uvs.Add(uv1 + uvOffset); vertices.Add(ht.hexagon.v1); normals.Add((origin + ht.hexagon.v1)); uvs.Add(uv0 + uvOffset); vertices.Add(ht.hexagon.v2); normals.Add((origin + ht.hexagon.v2)); uvs.Add(uv2 + uvOffset); triangles.Add(centerIndex); triangles.Add(vertices.Count - 2); triangles.Add(vertices.Count - 1); // T2 vertices.Add(ht.hexagon.v3); normals.Add((origin + ht.hexagon.v3)); uvs.Add(uv0 + uvOffset); triangles.Add(centerIndex); triangles.Add(vertices.Count - 2); triangles.Add(vertices.Count - 1); // T3 vertices.Add(ht.hexagon.v4); normals.Add((origin + ht.hexagon.v4)); uvs.Add(uv2 + uvOffset); triangles.Add(centerIndex); triangles.Add(vertices.Count - 2); triangles.Add(vertices.Count - 1); // T4 vertices.Add(ht.hexagon.v5); normals.Add((origin + ht.hexagon.v5)); uvs.Add(uv0 + uvOffset); triangles.Add(centerIndex); triangles.Add(vertices.Count - 2); triangles.Add(vertices.Count - 1); // T5 vertices.Add(ht.hexagon.v6); normals.Add((origin + ht.hexagon.v6)); uvs.Add(uv2 + uvOffset); triangles.Add(centerIndex); triangles.Add(vertices.Count - 2); triangles.Add(vertices.Count - 1); // T6 triangles.Add(centerIndex); triangles.Add(vertices.Count - 1); triangles.Add(vertices.Count - 6); // Side 1 triangles.Add(originIndex); triangles.Add(vertices.Count - 1); triangles.Add(vertices.Count - 2); // Side 2 triangles.Add(originIndex); triangles.Add(vertices.Count - 2); triangles.Add(vertices.Count - 3); // Side 3 triangles.Add(originIndex); triangles.Add(vertices.Count - 3); triangles.Add(vertices.Count - 4); // Side 4 triangles.Add(originIndex); triangles.Add(vertices.Count - 4); triangles.Add(vertices.Count - 5); // Side 5 triangles.Add(originIndex); triangles.Add(vertices.Count - 5); triangles.Add(vertices.Count - 6); // Side 6 triangles.Add(originIndex); triangles.Add(vertices.Count - 6); triangles.Add(vertices.Count - 1); } } } //Debug.Log(uv1); //Debug.Log(uv2); //Debug.Log(uv0); //LabelCenters(sphere.finalTris); //LabelNeighbors(sphere); //GameObject centerMarker = (GameObject)GameObject.Instantiate(centerMarkerPrefab, tri.center, Quaternion.identity); Mesh m = new Mesh(); m.vertices = vertices.ToArray(); m.triangles = triangles.ToArray(); m.normals = normals.ToArray(); m.uv = uvs.ToArray(); myCollider.sharedMesh = m; myFilter.sharedMesh = m; return(output); }
public GameLevel6() { LevelDesignation = 6; Layout = new int[,] { { 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1 }, { 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1 }, { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 }, { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 }, { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 }, { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 } }; BallVelocity = 615.00f; BallAdditiveScale = new SerializableVector3(-0.25f, -0.25f, -0.25f); BallCount = 10; PaddleAdditiveScale = new SerializableVector3(-0.5f, 0.0f, 0.0f); PaddleSpeed = 1.0f; EmaCount = CountEmaInLayout(); Atmosphere = Atmosphere.Night; }
public GameLevel1() { LevelDesignation = 1; Layout = new int[,] { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 0 }, { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; BallVelocity = 500.00f; BallAdditiveScale = new SerializableVector3(1.0f, 1.0f, 1.0f); BallCount = 10; PaddleAdditiveScale = new SerializableVector3(3.0f, 0f, 0f); PaddleSpeed = 1.0f; EmaCount = CountEmaInLayout(); Atmosphere = Atmosphere.Day; }
public EnemyData() { position = Vector3.zero; rotation = Vector3.zero; }
public GravityObjectSave(GravityObject obj) : base(obj) { useGravity = obj.useGravity; gravityDirection = obj.gravityDirection; gravityMagnitude = obj.gravityMagnitude; }
public void Rotation() { var positionAndOrientation = new MyPositionAndOrientation( new SerializableVector3D(10.0d, -10.0d, -2.5d), new SerializableVector3(0.0f, 0.0f, -1.0f), new SerializableVector3(0.0f, 1.0f, 0.0f)); // -90 around Z var quaternion = Quaternion.CreateFromYawPitchRoll(0, 0, -VRageMath.MathHelper.PiOver2); var o = positionAndOrientation.ToQuaternion() * quaternion; var on = Quaternion.Normalize(o); var p = new MyPositionAndOrientation(on.ToMatrix()); var quaternion2 = QuaternionD.CreateFromYawPitchRoll(0, 0, -Math.PI / 2); var o2 = positionAndOrientation.ToQuaternionD() * quaternion2; var on2 = QuaternionD.Normalize(o2); var p2 = new MyPositionAndOrientation(on2.ToMatrixD()); var quaternion3 = new System.Windows.Media.Media3D.Quaternion(new System.Windows.Media.Media3D.Vector3D(0, 0, 1), -90d); var x3 = positionAndOrientation.ToQuaternionD(); var o3 = new System.Windows.Media.Media3D.Quaternion(x3.X, x3.Y, x3.Z, x3.W)*quaternion3; var on3 = o3; on3.Normalize(); double num = on3.X * on3.X; double num3 = on3.Z * on3.Z; double num4 = on3.X * on3.Y; double num5 = on3.Z * on3.W; double num8 = on3.Y * on3.Z; double num9 = on3.X * on3.W; var M21 = (2.0d * (num4 - num5)); var M22 = (1.0d - 2.0d * (num3 + num)); var M23 = (2.0d * (num8 + num9)); var up3 = new Vector3D(M21, M22, M23); var fwd = new SerializableVector3(0.0f, 0.0f, -1.0f); var up = new SerializableVector3(1.0f, 0.0f, 0.0f); Assert.AreEqual(fwd.X, p.Forward.X, "Forward.X Should Equal"); Assert.AreEqual(fwd.Y, p.Forward.Y, "Forward.Y Should Equal"); Assert.AreEqual(fwd.Z, p.Forward.Z, "Forward.Z Should Equal"); Assert.AreEqual(up.X, p.Up.X, "Up.X Should Equal"); Assert.AreEqual(up.Y, p.Up.Y, "Up.Y Should Equal"); Assert.AreEqual(up.Z, p.Up.Z, "Up.Z Should Equal"); }
public SaveableAgent(Vector3 position, AGENT_STATE currentState) { this.position = new SerializableVector3(position); this.currentState = currentState; }
public TeleportAction(Transform transform) { position = transform.position; rotation = transform.rotation; }
public static Vector3 ToVector3(this SerializableVector3 vector) { return(new Vector3(vector.X, vector.Y, vector.Z)); }
public void Write(SerializableVector3 writable) { Write(writable.x); Write(writable.y); Write(writable.z); }
public GameLevel9() { LevelDesignation = 9; Layout = new int[,] { { 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 2 }, { 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, { 1, 1, 2, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 } }; BallVelocity = 620.00f; BallAdditiveScale = new SerializableVector3(0.0f, 0.0f, 0.0f); BallCount = 15; PaddleAdditiveScale = new SerializableVector3(0.0f, 0.0f, 0.0f); PaddleSpeed = 1.0f; EmaCount = CountEmaInLayout(); Atmosphere = Atmosphere.Day; }
void DrawHexAxes(List<HexTile> tiles, Vector3 worldOrigin, int index, float scale = .1f, bool suppressWarnings = true) { if (index == -1) { Debug.LogError("Invalid index: -1"); return; } SerializableVector3 origin = new SerializableVector3(); try { origin = (tiles[index].hexagon.center + (SerializableVector3)worldOrigin) * 1.05f; } catch(System.Exception e) { Debug.LogError("Error accessing tile "+ index+": "+e); return; } for (int dir = 0; dir<Direction.Count && dir<tiles[index].hexagon.neighbors.Length; dir++) { int y = tiles[index].GetNeighborID(dir); if (y != -1) { Gizmos.color = Direction.ToColor(dir); SerializableVector3 direction = tiles[tiles[index].GetNeighborID(dir)].hexagon.center - tiles[index].hexagon.center; float finalScale = scale; if (dir == Direction.X || dir == Direction.Y || dir == Direction.NegXY) // Prime directions finalScale *= 2; Gizmos.DrawRay((Vector3)origin, (Vector3)direction*finalScale); } } }
public GameLevel10() { LevelDesignation = 10; Layout = new int[,] { { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 }, { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 }, { 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; BallVelocity = 700.00f; BallAdditiveScale = new SerializableVector3(2.0f, 2.0f, 2.0f); BallCount = 25; PaddleAdditiveScale = new SerializableVector3(-1.0f, 0.0f, 0.0f); PaddleSpeed = 1.0f; EmaCount = CountEmaInLayout(); Atmosphere = Atmosphere.Night; }
public GpsData() { name = "Gps"; color = Vector3.Zero; position = Vector3D.Zero; }
public GameLevel11() { LevelDesignation = 11; Layout = new int[,] { { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 }, { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 }, { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 }, { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 }, { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 }, { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 } }; BallVelocity = 720.00f; BallAdditiveScale = new SerializableVector3(2.0f, 2.0f, 2.0f); BallCount = 25; PaddleAdditiveScale = new SerializableVector3(-1.0f, 0.0f, 0.0f); PaddleSpeed = 1.0f; EmaCount = CountEmaInLayout(); Atmosphere = Atmosphere.Day; }
public SaveableAgent(Vector3 position, StateMachineEnum currentState) { this.position = new SerializableVector3(position); this.currentState = currentState; }
public Line(SerializableVector3 startPoint, SerializableVector3 endPoint) { StartPoint = startPoint; EndPoint = endPoint; }
public BuildingInternalNoWalkFloor(Vector3 position, Vector3 size) : base(position) { Size_ = size; }
public SerializableBlock(Vector3 pos, Vector3 rot, int blockIndex) { this.position = new SerializableVector3(pos); this.rotation = new SerializableVector3(rot); this.blockIndex = blockIndex; }
public ProceduralObject(ProceduralObjectContainer container, LayerManager layerManager, PropInfo[] props, BuildingInfo[] buildings) { if (container.objectType == "PROP") { PropInfo sourceProp = props.FirstOrDefault(info => info.name == container.basePrefabName); this._baseProp = sourceProp; this.id = container.id; this.basePrefabName = container.basePrefabName; this.baseInfoType = "PROP"; this.isPloppableAsphalt = sourceProp.IsPloppableAsphalt(); m_position = container.position.ToVector3(); m_rotation = container.rotation.ToQuaternion(); m_material = GameObject.Instantiate(sourceProp.m_material); // overkil ?? if (container.meshStatus == 0 && container.vertices != null) { // CHECK FOR MESH REPETITION if (ProceduralUtils.CheckMeshEquivalence(container.vertices, sourceProp.m_mesh.vertices)) { meshStatus = 1; m_mesh = sourceProp.m_mesh; vertices = Vertex.CreateVertexList(sourceProp); } else { meshStatus = 2; m_mesh = sourceProp.m_mesh.InstantiateMesh(); var vert = SerializableVector3.ToStandardVector3Array(container.vertices); if (container.scale != 0) { for (int i = 0; i < vert.Count(); i++) { vert[i] = new Vector3(vert[i].x * container.scale, vert[i].y * container.scale, vert[i].z * container.scale); } } m_mesh.SetVertices(new List <Vector3>(vert)); vertices = Vertex.CreateVertexList(this); } } else if (container.meshStatus == 1) { meshStatus = 1; m_mesh = sourceProp.m_mesh; vertices = Vertex.CreateVertexList(sourceProp); } else // meshstatus2 { meshStatus = 2; m_mesh = sourceProp.m_mesh.InstantiateMesh(); if (container.serializedMeshData != null) { container.serializedMeshData.ApplyDataToObject(this); } else if (container.vertices != null) { var vert = SerializableVector3.ToStandardVector3Array(container.vertices); if (container.scale != 0) { for (int i = 0; i < vert.Count(); i++) { vert[i] = new Vector3(vert[i].x * container.scale, vert[i].y * container.scale, vert[i].z * container.scale); } } m_mesh.SetVertices(new List <Vector3>(vert)); } else { throw new Exception("[ProceduralObjects] Loading failure : Missing mesh data !"); } vertices = Vertex.CreateVertexList(this); } if (sourceProp.m_mesh.name == "ploppableasphalt-prop" || sourceProp.m_mesh.name == "ploppableasphalt-decal") { m_color = m_material.ApplyPloppableColor(); } if (container.hasCustomTexture && TextureManager.instance != null) { var customTex = TextureManager.instance.FindTexture(container.customTextureName); m_material.mainTexture = customTex as Texture; customTexture = customTex; } } else if (container.objectType == "BUILDING")// building { BuildingInfo sourceProp = buildings.FirstOrDefault(info => info.name == container.basePrefabName); this._baseBuilding = sourceProp; this.id = container.id; this.basePrefabName = container.basePrefabName; this.baseInfoType = "BUILDING"; this.isPloppableAsphalt = false; m_position = container.position.ToVector3(); m_rotation = container.rotation.ToQuaternion(); meshStatus = 2; m_material = GameObject.Instantiate(sourceProp.m_material); // overkill ?? m_mesh = sourceProp.m_mesh.InstantiateMesh(); if (container.serializedMeshData != null) { container.serializedMeshData.ApplyDataToObject(this); } else if (container.vertices != null) { var vert = SerializableVector3.ToStandardVector3Array(container.vertices); if (container.scale != 0) { for (int i = 0; i < vert.Count(); i++) { vert[i] = new Vector3(vert[i].x * container.scale, vert[i].y * container.scale, vert[i].z * container.scale); } } m_mesh.SetVertices(new List <Vector3>(vert)); } else { throw new Exception("[ProceduralObjects] Loading failure : Missing mesh data !"); } vertices = Vertex.CreateVertexList(this); m_mesh.colors = new Color[] { }; m_mesh.colors32 = new Color32[] { }; if (container.hasCustomTexture && TextureManager.instance != null) { var customTex = TextureManager.instance.FindTexture(container.customTextureName); m_material.mainTexture = customTex as Texture; customTexture = customTex; } } m_visibility = container.visibility; renderDistance = container.renderDistance; MaterialOptions.FixDecalRenderDist(this); renderDistLocked = container.renderDistLocked; if (container.textParam != null) { m_textParameters = TextParameters.Clone(container.textParam, true); for (int i = 0; i < m_textParameters.Count(); i++) { if (m_textParameters[i].m_fontColor == null) { if (m_textParameters[i].serializableColor != null) { m_textParameters[i].m_fontColor = m_textParameters[i].serializableColor.ToColor(); } else { m_textParameters[i].m_fontColor = Color.white; } } } // m_textParameters.SetFonts(); var originalTex = new Texture2D(m_material.mainTexture.width, m_material.mainTexture.height, TextureFormat.RGBA32, false); originalTex.SetPixels(((Texture2D)m_material.mainTexture).GetPixels()); originalTex.Apply(); m_material.mainTexture = m_textParameters.ApplyParameters(originalTex) as Texture; } else { m_textParameters = null; } if (container.belongsToGroup) { if (container.groupRootId == -1) { isRootOfGroup = true; _groupRootIdData = -1; } else { _groupRootIdData = container.groupRootId; isRootOfGroup = false; } } else { _groupRootIdData = -2; group = null; isRootOfGroup = false; } disableRecalculation = container.disableRecalculation; this.normalsRecalcMode = container.normalsRecalculation; this.flipFaces = container.flipFaces; this.disableCastShadows = container.disableCastShadows; if (this.flipFaces) { VertexUtils.flipFaces(this); } historyEditionBuffer = new HistoryBuffer(this); if (container.color == null) { if (!(m_mesh.name == "ploppableasphalt-prop" || m_mesh.name == "ploppableasphalt-decal")) { m_color = Color.white; } } else { m_color = container.color; m_material.color = m_color; } if (container.layerId != 0) { if (layerManager.m_layers.Any(l => l.m_id == container.layerId)) { layer = layerManager.m_layers.Single(l => l.m_id == container.layerId); } else { Debug.LogError("[ProceduralObjects] Layer of an object not found !"); } } else { layer = null; } if (container.tilingFactor == 0) { this.tilingFactor = 8; } else { this.tilingFactor = container.tilingFactor; } m_modules = ModuleManager.LoadModulesFromData(container.modulesData, true, this); }
public CharacterServerData(int id, Quaternion playerRotation, Quaternion cameraRotation) : base(id) { this.playerRotation = new SerializableVector3(playerRotation); this.cameraRotation = new SerializableVector3(cameraRotation); }
public static System.Windows.Media.Media3D.Point3D ToPoint3D(this SerializableVector3 point) { return(new System.Windows.Media.Media3D.Point3D(point.X, point.Y, point.Z)); }
// Updates player's position from player model's transform public void UpdateCurrentPosition(Vector3 input) { currentPosition = input; }
public static System.Windows.Media.Color ToSandboxMediaColor(this SerializableVector3 hsv) { var vColor = ColorExtensions.HSVtoColor(new Vector3(hsv.X, (hsv.Y + 1f) / 2f, (hsv.Z + 1f) / 2f)); return(System.Windows.Media.Color.FromArgb(vColor.A, vColor.R, vColor.G, vColor.B)); }
public Vector3Wrapper(SerializableVector3 v) { _vector = v; }
public void AddPokemonCenter(int scene, SerializableVector3 position, int direction, SerializableVector3 fPosition, int fDirection) { pCenterScene = scene; pCenterPosition = position; pCenterDirection = direction; pCenterFposition = fPosition; pCenterFdirection = fDirection; }
private static void PermutateItems(ICSType baseBlock, Dictionary <List <BlockSide>, ICSType> cSTypes, string itemJson, List <BlockSide> connections, IConnectedBlockCalculationType connectedBlockCalculationType) { foreach (RotationAxis axis in connectedBlockCalculationType.AxisRotations) { foreach (BlockRotationDegrees rotationDegrees in _blockRotationDegrees) { var rotationEuler = new SerializableVector3(); var rotatedList = new List <BlockSide>(); var currentRotation = rotationDegrees; if (baseBlock.meshRotationEuler != null) { rotationEuler.x = baseBlock.meshRotationEuler.x; rotationEuler.y = baseBlock.meshRotationEuler.y; rotationEuler.z = baseBlock.meshRotationEuler.z; } switch (axis) { case RotationAxis.X: rotationEuler.x += (int)rotationDegrees; if (rotationEuler.x > (int)BlockRotationDegrees.TwoSeventy) { rotationEuler.x -= 360; } currentRotation = (BlockRotationDegrees)rotationEuler.x; break; case RotationAxis.Y: rotationEuler.y += (int)rotationDegrees; if (rotationEuler.y > (int)BlockRotationDegrees.TwoSeventy) { rotationEuler.y -= 360; } currentRotation = (BlockRotationDegrees)rotationEuler.x; break; case RotationAxis.Z: rotationEuler.z += (int)rotationDegrees; if (rotationEuler.z > (int)BlockRotationDegrees.TwoSeventy) { rotationEuler.z -= 360; } currentRotation = (BlockRotationDegrees)rotationEuler.x; break; } if (connections.Count() == connections.Distinct().Count()) { foreach (var side in connections) { Vector3 connectionPoint = side.GetVector(); Vector3 eulerRotation = new Vector3(rotationEuler.x, rotationEuler.y, rotationEuler.z); Vector3 rotatedConnectionPoint = Quaternion.Euler(eulerRotation) * connectionPoint; if (rotatedConnectionPoint == Vector3.zero) { rotatedConnectionPoint = connectionPoint; } rotatedList.Add(rotatedConnectionPoint.GetBlocksideFromVector()); } } rotatedList.Sort(); if (rotatedList.Count != 0 && !rotatedList.Contains(BlockSide.Invalid) && rotatedList.Count == rotatedList.Distinct().Count() && !cSTypes.ContainsKey(rotatedList) && !rotatedList.All(r => r == rotatedList.First())) { bool hasCalculationTypes = rotatedList.Count <= connectedBlockCalculationType.MaxConnections; foreach (var side in rotatedList) { if (!connectedBlockCalculationType.AvailableBlockSides.Contains(side)) { hasCalculationTypes = false; } } var newItem = JsonConvert.DeserializeObject <CSType>(itemJson); newItem.meshRotationEuler = rotationEuler; newItem.ConnectedBlock = new ConnectedBlock() { BlockType = baseBlock.ConnectedBlock.BlockType, CalculationType = baseBlock.ConnectedBlock.CalculationType, Connections = rotatedList, BlockRotationDegrees = currentRotation, RotationAxis = axis }; newItem.categories = null; newItem.name = string.Concat(newItem.name, ".", GetItemName(newItem.ConnectedBlock.Connections)); if (hasCalculationTypes) { cSTypes[newItem.ConnectedBlock.Connections] = newItem; } PermutateItems(newItem, cSTypes, itemJson, connections, connectedBlockCalculationType); } } } }
public static SerializableVector3 Mod(this SerializableVector3 v, int mod) { return(new SerializableVector3(v.x % mod, v.y % mod, v.z % mod)); }
public void RestoreState(object state) { SerializableVector3 position = (SerializableVector3)state; transform.position = position.ToVector(); }
public static System.Windows.Media.Media3D.Vector3D ToVector3D(this SerializableVector3 vector) { return(new System.Windows.Media.Media3D.Vector3D(vector.X, vector.Y, vector.Z)); }
public SerializableQuaternion(Quaternion InQuaternion) { xyz = new SerializableVector3(InQuaternion.x, InQuaternion.y, InQuaternion.z); w = InQuaternion.w; }
// Resets the contents of the container public void Reset() { // Set the name to an empty string name = string.Empty; // Set the colour to black color = InterfaceColors.Black; // Set the position to be zero. position = Vector3.zero; // Set the entity ID's to negative one merchantId = -1; allyId = -1; // Clear the list itemIds.Clear(); }
public EntityData(Vector3 position, Quaternion rotation, EntityType entityType) { this.position = position; this.rotation = rotation; this.entityType = entityType; }