public TVector3 Copy()
    {
        TVector3 ret = new TVector3(_v.x, _v.y, _v.z, this.Tag);


        return(ret);
    }
Exemple #2
0
 public TVector3 this[int index]
 {
     get
     {
         switch (index)
         {
             case 0:
                 return this.a;
             case 1:
                 return this.b;
             case 2:
                 return this.c;
             default:
                 throw new System.IndexOutOfRangeException("Invalid Triangle3 index!");
         }
     }
     set
     {
         switch (index)
         {
             case 0:
                 this.a = value;
                 break;
             case 1:
                 this.b = value;
                 break;
             case 2:
                 this.c = value;
                 break;
             default:
                 throw new System.IndexOutOfRangeException("Invalid Triangle3 index!");
         }
     }
 }
Exemple #3
0
    public TVector3 Copy()
    {
        TVector3 ret = new TVector3(_v.x, _v.y, _v.z, this.Tag);


        return ret;
    }
Exemple #4
0
    public UnityEngine.Vector3 Center()
    {
        UnityEngine.Vector3 c = UnityEngine.Vector3.zero;

        c = new UnityEngine.Vector3((this.a.Value.x + this.b.Value.x + this.c.Value.x) / 3.0f, (this.a.Value.y + this.b.Value.y + this.c.Value.y) / 3.0f, (this.a.Value.z + this.b.Value.z + this.c.Value.z) / 3.0f);

        return(c);
    }
 public string Accept(TVector3 type)
 {
     if (DefAssemblyBase.IsUseUnityVectors)
     {
         return("UnityEngine.Vector3");
     }
     return("System.Numerics.Vector3");
 }
Exemple #6
0
    void MarchCube(int x, int y, int z, float[] cube)
    {
        int   i, j, vert, idx;
        int   flagIndex = 0;
        float offset    = 0.0f;

        for (int e = 0; e < 12; e++)
        {
            edgeVertex[e] = new TVector3();
        }

        for (i = 0; i < 8; i++)
        {
            if (cube[i] <= target)
            {
                flagIndex |= 1 << i;
            }
        }

        int edgeFlags = cubeEdgeFlags[flagIndex];

        if (edgeFlags == 0)
        {
            return;
        }

        for (i = 0; i < 12; i++)
        {
            if ((edgeFlags & (1 << i)) != 0)
            {
                offset = GetOffset(cube[edgeConnection[i, 0]], cube[edgeConnection[i, 1]]);

                edgeVertex[i].X = x + (vertexOffset[edgeConnection[i, 0], 0] + offset * edgeDirection[i, 0]);
                edgeVertex[i].Y = y + (vertexOffset[edgeConnection[i, 0], 1] + offset * edgeDirection[i, 1]);
                edgeVertex[i].Z = z + (vertexOffset[edgeConnection[i, 0], 2] + offset * edgeDirection[i, 2]);
            }
        }

        for (i = 0; i < 5; i++)
        {
            if (triangleConnectionTable[flagIndex, 3 * i] < 0)
            {
                break;
            }

            idx = mb.vertices.Count;

            for (j = 0; j < 3; j++)
            {
                vert = triangleConnectionTable[flagIndex, 3 * i + j];

                mb.triangles.Add(idx + order[j]);
                mb.vertices.Add(edgeVertex[vert]);
            }
        }
    }
        public DType Accept(TVector3 type, ExcelStream x)
        {
            var d = x.Read();

            if (CheckNull(type.IsNullable, d))
            {
                return(null);
            }
            return(DataUtil.CreateVector(type, d.ToString()));
        }
Exemple #8
0
        public DType Accept(TVector3 type, object converter, ExcelStream x, DefAssembly ass)
        {
            var d = x.Read();

            if (CheckNull(type.IsNullable, d))
            {
                return(null);
            }
            return(DataUtil.CreateVector(type, d.ToString()));
        }
Exemple #9
0
    public Triangle3()
    {
        this.a = TVector3.Tzero;
        this.b = TVector3.Tzero;
        this.c = TVector3.Tzero;

        this.Tag = "";

        this.Complement = null;
    }
Exemple #10
0
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                //这里懒得写Json文本的转换方法了,所以借助了TVector3这个类型
                var      obj  = (Vector3)value;
                TVector3 tobj = new TVector3()
                {
                    x = obj.x, y = obj.y, z = obj.z
                };

                serializer.Serialize(writer, tobj);
            }
Exemple #11
0
        public Triangle3()
        {
            this.a = TVector3.Tzero;
            this.b = TVector3.Tzero;
            this.c = TVector3.Tzero;

            this.Tag = "";

            this.Complement = null;

        }
    public override bool Equals(object obj)
    {
        bool     ret  = false;
        TVector3 comp = (TVector3)obj;

        if (comp.Value.x == this.Value.x && comp.Value.y == this.Value.y && comp.Value.z == this.Value.z)
        {
            ret = true;
        }

        return(ret);
    }
Exemple #13
0
    public static TVector3 Parse(string str)
    {
        var sps  = str.Trim('(', ')').Split(',');
        var data = new TVector3
        {
            x = float.Parse(sps[0]),
            y = float.Parse(sps[1]),
            z = float.Parse(sps[2])
        };

        return(data);
    }
Exemple #14
0
    public MarchingCubes(int size, float target, int[] order)
    {
        mb = new MeshBuffer();

        this.size   = size;
        rS          = size + 1;
        this.target = target;
        this.order  = order;

        for (int e = 0; e < 12; e++)
        {
            edgeVertex[e] = new TVector3();
        }
    }
Exemple #15
0
    public          TVector3 this[int index]
    {
        get
        {
            switch (index)
            {
            case 0:
                return(this.a);

            case 1:
                return(this.b);

            case 2:
                return(this.c);

            case 3:
                return(this.d);

            default:
                throw new System.IndexOutOfRangeException("Invalid Quad3D index!");
            }
        }
        set
        {
            switch (index)
            {
            case 0:
                this.a = value;
                break;

            case 1:
                this.b = value;
                break;

            case 2:
                this.c = value;
                break;

            case 3:
                this.d = value;
                break;

            default:
                throw new System.IndexOutOfRangeException("Invalid Quad3D index!");
            }
        }
    }
Exemple #16
0
    public void ConvertMesh()
    {
        vertBuffer.Clear();
        for (int i = 0; i < marchingCubes.mb.vertices.Count; i++)
        {
            TVector3 vert = marchingCubes.mb.vertices[i];
            vertBuffer.Add(new Vector3(vert.X, vert.Y, vert.Z));
        }

        m.Clear();
        m.SetVertices(vertBuffer);
        m.SetTriangles(marchingCubes.mb.triangles, 0);
        m.RecalculateNormals();

        mf.sharedMesh = m;
        mc.sharedMesh = m;
    }
Exemple #17
0
 public string Accept(TVector3 type)
 {
     return("System.Numerics.Vector3");
 }
Exemple #18
0
 public string Accept(TVector3 type, string jsonVarName, string fieldName)
 {
     return($"{fieldName} = Vector3.fromJson({jsonVarName})");
 }
Exemple #19
0
 public string Accept(TVector3 type)
 {
     return("FJsonValueObject");
 }
Exemple #20
0
 public string Accept(TVector3 type)
 {
     return("readVector3");
 }
Exemple #21
0
	Triangle3[] GetStraightSpokes (string TagTop1,string TagTop2, string TagBottom1, string TagBottom2)
	{
		TVector3 origin1 = new TVector3(0,0, ((-_spokeIndent/2)), GearRenderer.VERT_origin);
        TVector3 origin2 = new TVector3(0, 0, ((-_height + _spokeIndent / 2)), GearRenderer.VERT_origin);
        System.Collections.Generic.List<Triangle3> tris = new System.Collections.Generic.List<Triangle3>();
        
        Triangle3[] p1tris = GetStraightSpokePlane(origin1.Copy(), (+_spokeIndent / 2), TagTop1, TagTop2);
        Triangle3[] p2tris = GetStraightSpokePlane(origin2.Copy(), (-_spokeIndent / 2), TagBottom1, TagBottom2);
		MirrorVertTags(p2tris);
        Triangle3 trinew;

        for (int i = 0; i < p1tris.Length; i++)  //Works since both arrays are same len.
        {
            var tri1 = p1tris[i].Copy();
            var tri2 = p2tris[i].Copy();
            trinew = new Triangle3();
            trinew.a = tri1.a;
            trinew.b = tri1.b;
            trinew.c = tri1.c;
            trinew.Tag = tri1.Tag;
			trinew.SortOrder = _triOrder;
			_triOrder += 2;
            tris.Add(trinew);

            trinew = new Triangle3();
            trinew.a = tri2.c;
            trinew.b = tri2.b;
            trinew.c = tri2.a;
            trinew.Tag = tri2.Tag;
			trinew.SortOrder = _triOrder + 1;
            trinew.Complement = tri1;

            tris.Add(trinew);

        }
		
		if(_hubRadius != 0){
        	Triangle3[] p3tris = GetHubPlane(origin1.Copy(), (+_hubHeight / 2.0f), TRI_HubTop);
        	Triangle3[] p4tris = GetHubPlane(origin2.Copy(), (-_hubHeight / 2.0f), TRI_HubBottom);
			MirrorVertTags(p4tris);
		
	        for (int i = 0; i < p3tris.Length; i++)  //Works since both arrays are same len.
	        {
	            var tri1 = p3tris[i].Copy();
	            var tri2 = p4tris[i].Copy();
	            trinew = new Triangle3();
	            trinew.a = tri1.a;
	            trinew.b = tri1.b;
	            trinew.c = tri1.c;
	            trinew.Tag = tri1.Tag;
				trinew.SortOrder = _triOrder;
				_triOrder += 2;
	            tris.Add(trinew);
	             
	            trinew = new Triangle3();
	            trinew.a = tri2.c;
	            trinew.b = tri2.b;
	            trinew.c = tri2.a;
	            trinew.Tag = tri2.Tag;
	            trinew.Complement = tri1;
				trinew.SortOrder = _triOrder + 1;
	            tris.Add(trinew);		
	
	        }
			
			
		}
			
        return tris.ToArray();
	}
Exemple #22
0
 public string Accept(TVector3 type)
 {
     return("VECTOR3");
 }
Exemple #23
0
 public override bool Accept(TVector3 type)
 {
     return(false);
 }
Exemple #24
0
	TVector3 RotatePoint(float Rotation, TVector3 pt){
		TVector3 ret;	
		float Rot = Mathf.Deg2Rad * Rotation;
		
		if (Rotation == 0 || pt.Value == Vector3.zero){
			ret = pt.Copy();	

		}else{
			
			
		
			ret = new TVector3(pt.Value.x * Mathf.Cos(Rot) - pt.Value.y * Mathf.Sin(Rot), 
				pt.Value.x * Mathf.Sin(Rot) + pt.Value.y * Mathf.Cos(Rot), pt.Value.z, pt.Tag);
			
			
			
		}
		
		
		return ret;
	}
 public virtual void Accept(TVector3 type, T x)
 {
     DoAccept(type, x);
 }
Exemple #26
0
 public string Accept(TVector3 type, string x)
 {
     throw new NotImplementedException();
 }
Exemple #27
0
	public Triangle3[] GetStraightSpokePlane (TVector3 origin, float zOffset, string Tag1, string Tag2)
	{
		System.Collections.Generic.List<Triangle3> tris = new List<Triangle3> ();

		//Calc the angle to sweep...
		float inctheta = 2 * Mathf.PI / ((float)_spokeCount);
		float theta = 0.0f;
		float adjAngle = 0.0f;
		System.Collections.Generic.List<LineSegment2D> spokelines = new System.Collections.Generic.List<LineSegment2D> ();
		
		for (int i = 0; i < (_spokeCount + 1); i++) {
			adjAngle = inctheta;
			TVector2 pt1;
			TVector2 pt2;
			
			if(_hubRadius !=0){
	            pt1 = new TVector2((_hubRadius) * Mathf.Cos(theta) + origin.Value.x, (_hubRadius) * Mathf.Sin(theta) + origin.Value.y, VERT_SpokeEdgeTop);
	            
			}else{
				pt1 = new TVector2(origin.Value.x, origin.Value.y, VERT_SpokeEdgeTop);
				
			}
			pt2 = new TVector2(_ringRadius * Mathf.Cos(theta) + origin.Value.x, _ringRadius * Mathf.Sin(theta) + origin.Value.y, VERT_SpokeEdgeTop);
			LineSegment2D ls = new LineSegment2D ();
				
			ls.a = pt1;
			ls.b = pt2;

			spokelines.Add (ls);
			theta += (adjAngle);
		}
		theta = 0.0f;
		
		for (int i = 0; i < (_spokeCount); i++) {
			Quad3D q3;

			var q2 = CreateQuadFromLineSegment (spokelines [i], _spokeWidthInner, _spokeWidthOuter);
            

            q3 = new Quad3D().Create(q2, origin.Value.z);
			q3.Tag = Tag1;
			var qtris = q3.GetTris ();
			qtris[0].Tag = q3.Tag;
			qtris[0].SortOrder = _triOrder;
			_triOrder += 2;
			qtris[1].Tag = Tag2;
			qtris[1].SortOrder = _triOrder;
			_triOrder += 2;
			tris.AddRange (qtris);

		}	
		
		return tris.ToArray ();
	}
Exemple #28
0
	public Triangle3[] GetHubPlane(TVector3 Origin, float zOffset, string Tag){
		System.Collections.Generic.List<Triangle3> tris = new List<Triangle3> ();
		float inctheta = 2 * Mathf.PI / ((float) _hubSides);
		float theta = 0.0f;
		float adjAngle = 0.0f;
		float r = Mathf.Sqrt((_spokeWidthInner) * (_spokeWidthInner) + (_hubRadius * _hubRadius)); //Get dist to corner of spoke.
		for (int i = 0; i < (_hubSides); i++) {
			Triangle3 tri = new Triangle3();
			adjAngle = inctheta;
            tri.a = new TVector3(Origin.Value.x, Origin.Value.y, Origin.Value.z + zOffset, VERT_origin);
            tri.b = new TVector3(r * Mathf.Cos(theta) + Origin.Value.x, r * Mathf.Sin(theta) + Origin.Value.y, Origin.Value.z + zOffset, VERT_HubPerimeterTop);
            tri.c = new TVector3(r * Mathf.Cos(theta + adjAngle) + Origin.Value.x, r * Mathf.Sin(theta + adjAngle) + Origin.Value.y, Origin.Value.z + zOffset, VERT_HubPerimeterTop);
			
			tri.SortOrder = _triOrder;
			_triOrder += 2;
			
			tri.Tag = Tag;
			tris.Add(tri);
			
			theta += (adjAngle);
		}
		
		return tris.ToArray();
	}
Exemple #29
0
	public Shape3D GetRingGear()
	{
		System.Collections.Generic.List<Triangle3> tris = new List<Triangle3> ();

		float OuterWidth = 0.0f;
		float ToothBaseWidth = 0.0f;
		
		
		Shape3D ret;
		
		_origin.Tag = VERT_origin;
		
		ToothBaseWidth = (float)(_innerRadius * 2 * Mathf.PI / (((float)(_qtyTeeth)) * (_outerWidthPct + 1)));
		OuterWidth = ToothBaseWidth * _outerWidthPct;

		//Calc the angle to sweep...
		float inctheta = 2 * Mathf.PI / ((float)_qtyTeeth * (_outerWidthPct + 1));
		float theta = 0.0f;
		float ToothRotAngle = _toothRot * Mathf.PI / 360.0f;
		float phi = (inctheta *_outerRadius - OuterWidth) / (2 *_outerRadius);
		
		
		for (int i = 0; i <  _qtyTeeth * 2; i++) { 
			TVector3 a;
			TVector3 b;
			TVector3 c;
			
			TVector3 ta; 
			TVector3 tb;
			TVector3 tc;
			
			float adjAngle = 0.0f;
			float angleBuffera = 0;
            float angleBufferc = 0;
            Triangle3 t = new Triangle3();
			
			if (i % 2 == 0) {
				adjAngle = inctheta;
                angleBuffera = inctheta / 2.0f; //LargePoints
                angleBufferc = inctheta + _outerWidthPct * inctheta / 2.0f;
			} else {
				adjAngle = _outerWidthPct * inctheta;
                angleBuffera = _outerWidthPct * inctheta / 2.0f; // Small points
                angleBufferc = inctheta / 2.0f + inctheta * _outerWidthPct;
			}


			b = new TVector3 (_innerRadius * Mathf.Cos (theta) +_origin.Value.x, _innerRadius * Mathf.Sin (theta) +_origin.Value.y,_origin.Value.z, VERT_OuterRingBorderTop);
			c = new TVector3 (_innerRadius * Mathf.Cos (theta + adjAngle) +_origin.Value.x, _innerRadius * Mathf.Sin (theta + adjAngle) +_origin.Value.y,_origin.Value.z, VERT_OuterRingBorderTop);

			a =_origin.Copy();
            
			if (_ringRadius != 0) {
                if (_outerWidthPct != 0)
                {
                    a = new TVector3(_ringRadius * Mathf.Cos(theta + angleBuffera) + a.Value.x, _ringRadius * Mathf.Sin(theta + angleBuffera) + a.Value.y, a.Value.z, VERT_InnerRingBorderTop);
                }
                else
                {
                    a = new TVector3(_ringRadius * Mathf.Cos(theta + angleBuffera) + a.Value.x, _ringRadius * Mathf.Sin(theta + angleBuffera) + a.Value.y, a.Value.z, VERT_InnerRingBorderTop);
                }
                
            }
			
			t.a = a;
			t.b = b;
			t.c = c;
			t.SortOrder = _triOrder;
			_triOrder += 2;
			
			if (i % 2 == 0) {
				t.Tag = TRI_GearPlaneTopA1;
			}else{
				t.Tag = TRI_GearPlaneTopA2;
			}
            tris.Add(t);
            t = new Triangle3();

            if (_ringRadius != 0)
            {
                if (_outerWidthPct != 0)
                {
                    Triangle3 tFill = new Triangle3();
                    tFill.a = a.Copy();

                    tFill.b = c.Copy();

                    tFill.c = new TVector3(_ringRadius * Mathf.Cos(theta + angleBufferc) + _origin.Value.x, _ringRadius * Mathf.Sin(theta + angleBufferc) + _origin.Value.y, _origin.Value.z, VERT_InnerRingBorderTop);

                    tFill.Tag = TRI_GearPlaneTopB;
					tFill.SortOrder = _triOrder;
					_triOrder += 2;
                    tris.Add(tFill);

                }else{
                    Triangle3 tFill = new Triangle3();
                    tFill.a = a.Copy();

                    tFill.b = c.Copy();

                    tFill.c = new TVector3(_ringRadius * Mathf.Cos(theta + angleBufferc) + _origin.Value.x, _ringRadius * Mathf.Sin(theta + angleBufferc) + _origin.Value.y, _origin.Value.z, VERT_InnerRingBorderTop);

                    tFill.Tag = TRI_GearPlaneTopC;
					tFill.SortOrder = _triOrder;
					_triOrder += 2;
                    tris.Add(tFill);

                }
            }

            if (_outerWidthPct == 0 && i % 2 != 0)
            {
                continue; //If no 'squared' teeth, then bail quickly.
            }

			if (i % 2 == 0) {
				Triangle3 t1 = new Triangle3();
                Triangle3 t2 = new Triangle3();
				ta = b.Copy(); //First corner of tooth.

				tb = new TVector3 (_outerRadius * Mathf.Cos (theta + phi + ToothRotAngle) +_origin.Value.x,_outerRadius * Mathf.Sin (theta + phi + ToothRotAngle) +_origin.Value.y,_origin.Value.z, VERT_ToothBorderTop);
				tc = c.Copy();
					
				t1.a = ta;
				t1.b = tb;
				t1.c = tc;
				t1.Tag = TRI_GearPlaneTopD;
				t1.SortOrder = _triOrder;
				_triOrder += 2;
			    tris.Add (t1);
					
				tb = new TVector3 (_outerRadius * Mathf.Cos (theta + inctheta - phi + ToothRotAngle) +_origin.Value.x,_outerRadius * Mathf.Sin (theta + inctheta - phi + ToothRotAngle) +_origin.Value.y,_origin.Value.z, VERT_ToothBorderTop); //Second Corner of Outer Tooth.
				ta = new TVector3 (_outerRadius * Mathf.Cos (theta + phi + ToothRotAngle) +_origin.Value.x,_outerRadius * Mathf.Sin (theta + phi + ToothRotAngle) +_origin.Value.y,_origin.Value.z, VERT_ToothBorderTop); //First corner of outer tooth.
				tc = c.Copy();
				
				t2.a = ta;
				t2.b = tb;
				t2.c = tc;
				t2.Tag = TRI_GearPlaneTopE;
				t2.SortOrder = _triOrder;
				_triOrder += 2;
				tris.Add (t2);

			}

			theta += adjAngle;
			
			//If next to last tooth then set theta = 0 (for full circle...);
			if (i == (_qtyTeeth * 2 - 1)) {
				theta = 0;	
				
			}
			
			
		}
		
		
		var opptris = BuildOppositePlane(tris.ToArray(), new string[] { TRI_GearPlaneTopA1 }, TRI_GearPlaneBottomA1, _topScale, _topRotation);
        tris.AddRange(opptris);
		
		opptris = BuildOppositePlane(tris.ToArray(), new string[] { TRI_GearPlaneTopA2 }, TRI_GearPlaneBottomA2, _topScale, _topRotation);
		tris.AddRange(opptris);
		
		opptris = BuildOppositePlane(tris.ToArray(), new string[] { TRI_GearPlaneTopE }, TRI_GearPlaneBottomE, _topScale, _topRotation);
		tris.AddRange(opptris);
		
		opptris = BuildOppositePlane(tris.ToArray(), new string[] { TRI_GearPlaneTopD }, TRI_GearPlaneBottomD, _topScale, _topRotation);
		tris.AddRange(opptris);
		
		opptris = BuildOppositePlane(tris.ToArray(), new string[] { TRI_GearPlaneTopB }, TRI_GearPlaneBottomB, _topScale, _topRotation);
		tris.AddRange(opptris);
	
		opptris = BuildOppositePlane(tris.ToArray(), new string[] { TRI_GearPlaneTopC }, TRI_GearPlaneBottomC, _topScale, _topRotation);
		tris.AddRange(opptris);

		tris.AddRange(GetSpokes());
		
		//Stitch Teeth
		System.Collections.Generic.List<Triangle3> stitching = new List<Triangle3>();
		System.Collections.Generic.SortedList<int, Triangle3> sortedTris = new SortedList<int, Triangle3>();
		
		foreach (Triangle3 item in tris) {
			if(sortedTris.ContainsKey(item.SortOrder)){
				Debug.Log("Item exists: " + 	item.SortOrder.ToString() + " " + item.Tag);
			}
			sortedTris.Add(item.SortOrder, item);			
		}

		foreach (Triangle3 item in sortedTris.Values) {
			
			
			stitching.AddRange(StitchEdge(item, TRI_GearPlaneTopA2, TRI_GearPlaneBottomA2, "b", "c", "a", "b", TRI_SideOuterTop, TRI_SideOuterBottom));
			stitching.AddRange(StitchEdge(item, TRI_GearPlaneTopD, TRI_GearPlaneBottomD, "a", "b", "b", "c", TRI_SideOuterTop, TRI_SideOuterBottom));
			stitching.AddRange(StitchEdge(item, TRI_GearPlaneTopE, TRI_GearPlaneBottomE, "a", "b", "b", "c", TRI_SideOuterTop, TRI_SideOuterBottom));
			stitching.AddRange(StitchEdge(item, TRI_GearPlaneTopE, TRI_GearPlaneBottomE, "b", "c", "a", "b", TRI_SideOuterTop, TRI_SideOuterBottom));
			
			//Stitch Inner Ring.
			stitching.AddRange(StitchEdge(item, TRI_GearPlaneTopB, TRI_GearPlaneBottomB, "c", "a", "c", "a", TRI_SideInnerTop, TRI_SideInnerBottom));
			stitching.AddRange(StitchEdge(item, TRI_GearPlaneTopC, TRI_GearPlaneBottomC, "c", "a", "c", "a", TRI_SideInnerTop, TRI_SideInnerBottom));
			
			//Stitch Straight Spokes
			stitching.AddRange(StitchEdge(item, TRI_SpokeTop1, TRI_SpokeBottom1, "a", "b", "b", "c", TRI_SpokeSideTop, TRI_SpokeSideBottom));
			stitching.AddRange(StitchEdge(item, TRI_SpokeTop2, TRI_SpokeBottom2, "b", "c", "a", "b", TRI_SpokeSideTop, TRI_SpokeSideBottom));
			
			//Stitch Hub
			stitching.AddRange(StitchEdge(item, TRI_HubTop, TRI_HubBottom, "b", "c", "a", "b", TRI_HubSideTop, TRI_HubSideBottom));

		}
		tris.AddRange(stitching.ToArray());
		
		ret.UV = BuildUVs(tris);
		ret.tris = tris.ToArray();
		
		return ret;
	}
Exemple #30
0
	public GearRenderer(){
		_origin = TVector3.Tzero.Copy();	
		
		_VertMap.Clear();
		_VertMap.Add(VERT_HubPerimeterBottom, VERT_HubPerimeterTop);
		_VertMap.Add(VERT_HubPerimeterTop, VERT_HubPerimeterBottom);
		_VertMap.Add(VERT_InnerRingBorderBottom, VERT_InnerRingBorderTop);
		_VertMap.Add(VERT_InnerRingBorderTop, VERT_InnerRingBorderBottom);
		_VertMap.Add(VERT_OuterRingBorderBottom, VERT_OuterRingBorderTop);
		_VertMap.Add(VERT_OuterRingBorderTop, VERT_OuterRingBorderBottom);
		_VertMap.Add(VERT_SpokeEdgeBottom, VERT_SpokeEdgeTop);
		_VertMap.Add(VERT_SpokeEdgeTop, VERT_SpokeEdgeBottom);
		_VertMap.Add(VERT_SpokePerimeterBottom, VERT_SpokePerimeterTop);
		_VertMap.Add(VERT_SpokePerimeterTop, VERT_SpokePerimeterBottom);
		_VertMap.Add(VERT_ToothBorderBottom, VERT_ToothBorderTop);
		_VertMap.Add(VERT_ToothBorderTop, VERT_ToothBorderBottom);
		_VertMap.Add(VERT_origin, VERT_origin);
	}
Exemple #31
0
		public UnityEngine.Vector3 Center(){
			UnityEngine.Vector3 c = UnityEngine.Vector3.zero;
		
			c = new UnityEngine.Vector3((this.a.Value.x + this.b.Value.x + this.c.Value.x) / 3.0f, (this.a.Value.y + this.b.Value.y + this.c.Value.y) / 3.0f, (this.a.Value.z + this.b.Value.z + this.c.Value.z) / 3.0f);
		
			return c;
		
		}
 public void Accept(TVector3 type, Dictionary <string, DefTypeBase> x)
 {
 }
Exemple #33
0
 public string Accept(TVector3 type, string bufName, string fieldName)
 {
     return($"if(!{bufName}.readVector3({fieldName})) return false;");
 }
Exemple #34
0
 public DType Accept(TVector3 type, XElement x, DefAssembly ass)
 {
     return(DataUtil.CreateVector(type, x.Value));
 }
Exemple #35
0
	public Triangle3[] GetSolidSpokePlane (TVector3 origin, string Tag, float scale)
	{
		System.Collections.Generic.List<Triangle3> tris = new List<Triangle3> ();

		//Calc the angle to sweep...
		float inctheta = 2 * Mathf.PI / ((float)_qtyTeeth * 2.0f);
		float theta = 0.0f;
		_origin.Tag = VERT_origin;
        float width = _ringRadius * 1.05f;
		for (int i = 0; i < (_qtyTeeth * 2); i++) {
			TVector3 a;
			TVector3 b;
			TVector3 c;
			
			float adjAngle = 0.0f;

            Triangle3 t = new Triangle3();

 
			adjAngle = inctheta;
			a =origin.Copy();
			
			
			
            b = new TVector3(width * Mathf.Cos(theta) + origin.Value.x, width * Mathf.Sin(theta) + origin.Value.y, a.Value.z, VERT_SpokePerimeterTop);
			
 			b = new TVector3(b.Value.x * scale, b.Value.y * scale, b.Value.z, b.Tag);
			
            c = new TVector3(width * Mathf.Cos(theta + adjAngle) + origin.Value.x, width * Mathf.Sin(theta + adjAngle) + origin.Value.y, a.Value.z, VERT_SpokePerimeterTop);
            
 			c = new TVector3(c.Value.x * scale, c.Value.y * scale, c.Value.z, c.Tag);
			
			t.a = a;
			t.b = b;
			t.c = c;
			t.Tag = Tag;
			t.SortOrder = _triOrder;
			_triOrder += 2;
			tris.Add (t);

			theta += adjAngle;
			
			//If next to last tooth then set theta = 0 (for full circle...);
			if (i == (_qtyTeeth * 2 - 1)) {
				theta = 0;	
				
			}

		}
		
		return tris.ToArray ();
	}
 public string Accept(TVector3 type, string json, string field)
 {
     return(DefaultLoad(json, field));
 }
 public string Accept(TVector3 type)
 {
     return($"serialization.Vector3");
 }
 public string Accept(TVector3 type, string fieldName, string tablesName)
 {
     throw new NotImplementedException();
 }
Exemple #39
0
 public void Accept(TVector3 type, HashSet <DefTypeBase> x)
 {
 }
Exemple #40
0
	Triangle3[] GetSolidSpokes (string TagTop, string TagBottom)
	{
		TVector3 origin1 = new TVector3(0,0, ((-_spokeIndent/2)), GearRenderer.VERT_origin);
		TVector3 origin2 = new TVector3(0,0, ((-_height + _spokeIndent/2)), GearRenderer.VERT_origin);
        System.Collections.Generic.List<Triangle3> tris = new System.Collections.Generic.List<Triangle3>();
        Triangle3 newtri;

		Triangle3[] p1tris = GetSolidSpokePlane(origin1, TagTop, 1.0f);
		Triangle3[] p2tris = GetSolidSpokePlane(origin2, TagBottom,1.0f);
		MirrorVertTags(p2tris);
		
		foreach(var tri in p1tris){
			var t1 = tri.Copy();
            newtri = new Triangle3();
            newtri.a = t1.a;
            newtri.b = t1.b;
            newtri.c = t1.c;
            newtri.Tag = TagTop;
			newtri.SortOrder = _triOrder;
			_triOrder += 2;
            tris.Add(newtri);
		}
		
		foreach(var tri in p2tris){
			var t2 = tri.Copy();
            newtri = new Triangle3();
            newtri.a = t2.c;
            newtri.b = t2.b;
            newtri.c = t2.a;
            newtri.Tag = TagBottom;
			newtri.SortOrder = tri.SortOrder + 1;
            tris.Add(newtri);


		}

		return tris.ToArray();
		
	}
 public string Accept(TVector3 type, string bufName, string fieldName)
 {
     return($"{fieldName} = {bufName}.ReadVector3();");
 }
 public string Accept(TVector3 type)
 {
     return("writeVector3");
 }