Ejemplo n.º 1
0
    public void RemoveGizmoSurface(Gizmo gizmo)
    {
        if (!(gizmo is GizmoSurface))
        {
            return;
        }
        GizmoSurface gizmoSurface = (GizmoSurface)gizmo;

        SurfaceBehaviour surfaceBehaviour = (SurfaceBehaviour)gizmoMap[gizmoSurface];

        Destroy(surfaceBehaviour.gameObject);

        gizmoMap.Remove(gizmoSurface);
    }
Ejemplo n.º 2
0
    public void AddGizmoSurface(Gizmo gizmo)
    {
        if (!(gizmo is GizmoSurface))
        {
            return;
        }
        GizmoSurface gizmoSurface = (GizmoSurface)gizmo;

        GameObject gizmoObject = new GameObject("surface");

        gizmoObject.transform.SetParent(gizmoWrapper.transform);

        SurfaceBehaviour surfaceBehaviour = gizmoObject.AddComponent <SurfaceBehaviour>();

        surfaceBehaviour.Init(geoCamera);

        FaceRefer face = gizmoSurface.face;

        if (face.ids.Length < 3)
        {
            return;
        }
        Vector3 center     = geometry.Center();
        Vector3 v1         = geometry.UnitVector(face.ids[0]);
        Vector3 v2         = geometry.UnitVector(face.ids[1]);
        Vector3 v3         = geometry.UnitVector(face.ids[2]);
        float   radius     = v3.z - v2.z;
        int     pointCount = 4;

        Vector3[] vectors     = new Vector3[pointCount];
        float     angledegree = 360.0f;
        float     angleRad    = Mathf.Deg2Rad * angledegree;
        float     angleCur    = angleRad;
        float     angledelta  = angleRad / pointCount;

        for (int i = 0; i < pointCount; i++)
        {
            float cosA = Mathf.Cos(angleCur);
            float sinA = Mathf.Sin(angleCur);
            vectors[i] = new Vector3(radius * cosA, v2.y, radius * sinA);
            angleCur  -= angledelta;
        }

        string area = geometry.SurfaceArea(face.ids);

        surfaceBehaviour.SetData(center, vectors, area);

        gizmoMap.Add(gizmoSurface, surfaceBehaviour);
    }
Ejemplo n.º 3
0
    public override void InitWithGeometry(Geometry geometry)
    {
        int count = face.ids.Length;

        VertexUnit[] vertexUnits = new VertexUnit[count];
        for (int i = 0; i < count; i++)
        {
            vertexUnits[i] = geometry.VertexUnit(face.ids[i]);
        }

        dependencies = new List <VertexUnit>(vertexUnits);

        GizmoSurface gizmoSurface = new GizmoSurface(face);

        gizmos = new Gizmo[] { gizmoSurface };
    }