Esempio n. 1
0
    static Vector3 getConeVertex(float u, float v, GizmoCoords coords)     //Vector3 pos, Vector3 xVec, Vector3 yVec, Vector3 zVec){
    {
        var tmp = getUnitConeVertex(u, v);

        return(coords.transformPoint(tmp));
        //return pos + tmp.x * xVec + tmp.y*yVec + tmp.z*zVec;
    }
Esempio n. 2
0
    public static void processWireCone(GizmoCoords coords,
                                       int uSegments, int vSegments, float vPivot, LineCallback lineCallback)
    {
        if (lineCallback == null)
        {
            throw new System.ArgumentNullException();
        }

        var southPole = coords.pos - coords.yVec * vPivot;
        var northPole = southPole + coords.yVec;

        if (uSegments < 3)
        {
            uSegments = 3;
        }
        if (vSegments < 1)
        {
            vSegments = 1;
        }

        coords.pos = southPole;
        processUvSurface <GizmoCoords>(uSegments, vSegments, 0, uSegments, 0, vSegments,
                                       northPole, southPole, true, true,
                                       (u, v, data) => getConeVertex(u, v, data),
                                       lineCallback, coords);
    }
Esempio n. 3
0
    static Vector3 getUnitCylinderVertex(float u, float v, GizmoCoords coords)
    {
        var sinCos = getSinCos(u * Mathf.PI * 2.0f);

        var result = coords.transformPoint(new Vector3(-sinCos.y, v, sinCos.x));

        return(result);
    }
Esempio n. 4
0
    public static void drawVectorText(string text, Transform transform, float localLetterScale, TextAnchor anchor, TextAnchor alignment)
    {
        var coords = new GizmoCoords(transform);

        coords.xVec *= localLetterScale;
        coords.yVec *= localLetterScale;
        coords.zVec *= localLetterScale;
        drawVectorText(text, coords, anchor, alignment);
    }
Esempio n. 5
0
    public static void drawVectorTextLine(string text, Transform transform, float localLetterScale)
    {
        var coords = new GizmoCoords(transform);

        coords.xVec *= localLetterScale;
        coords.yVec *= localLetterScale;
        coords.zVec *= localLetterScale;
        drawVectorTextLine(text, coords);
    }
Esempio n. 6
0
    public static void processWireCube(GizmoCoords coords, bool makePivotAxes, Vector3 pivotOffset, LineCallback lineCallback)
    {
        if (lineCallback == null)
        {
            throw new System.ArgumentNullException();
        }

        var a  = coords.pos - coords.xVec * pivotOffset.x - coords.yVec * pivotOffset.y - coords.zVec * pivotOffset.z;
        var b  = a + coords.xVec;
        var c  = a + coords.yVec;
        var d  = b + coords.yVec;
        var a1 = a + coords.zVec;
        var b1 = b + coords.zVec;
        var c1 = c + coords.zVec;
        var d1 = d + coords.zVec;

        lineCallback(a, b);
        lineCallback(a, c);
        lineCallback(b, d);
        lineCallback(c, d);
        lineCallback(a1, b1);
        lineCallback(a1, c1);
        lineCallback(b1, d1);
        lineCallback(c1, d1);
        lineCallback(a, a1);
        lineCallback(b, b1);
        lineCallback(c, c1);
        lineCallback(d, d1);

        if (!makePivotAxes)
        {
            return;
        }

        var pivotX = coords.pos - pivotOffset.x * coords.xVec;
        var pivotY = coords.pos - pivotOffset.y * coords.yVec;
        var pivotZ = coords.pos - pivotOffset.z * coords.zVec;

        lineCallback(pivotX, pivotX + coords.xVec);
        lineCallback(pivotY, pivotY + coords.yVec);
        lineCallback(pivotZ, pivotZ + coords.zVec);
    }
Esempio n. 7
0
    public static void processUvSphere(GizmoCoords coords, int uSegments, int vSegments, LineCallback lineCallback)
    {
        if (lineCallback == null)
        {
            throw new System.ArgumentNullException();
        }

        if (uSegments < 3)
        {
            uSegments = 3;
        }
        if (vSegments < 2)
        {
            vSegments = 12;
        }

        Vector3 northPole = getSphereVertex(0.0f, 1.0f, coords);
        Vector3 southPole = getSphereVertex(0.0f, 0.0f, coords);

        processUvSurface <GizmoCoords>(uSegments, vSegments, 0, uSegments, 1, vSegments - 1,
                                       northPole, southPole, true, true,
                                       (u, v, data) => getSphereVertex(u, v, data),
                                       lineCallback, coords);
    }
Esempio n. 8
0
 public static void processWireCube(GizmoCoords coords, bool makePivotAxes = false)
 {
     processWireCube(coords, makePivotAxes, new Vector3(0.5f, 0.5f, 0.5f), gizmoLine);
 }
Esempio n. 9
0
 public static void drawVectorTextLine(string text, GizmoCoords coords)
 {
     VectorText.processTextLine(text, (a, b, crd) =>
                                gizmoLine(crd.transformPoint(new Vector3(-a.x, a.y, 0.0f)), crd.transformPoint(new Vector3(-b.x, b.y, 0.0f))),
                                coords);
 }
Esempio n. 10
0
    public static void drawVectorTextLine(string text, Vector3 pos, Quaternion rotation, float letterScale)
    {
        var coords = new GizmoCoords(pos, rotation, new Vector3(letterScale, letterScale, letterScale));

        drawVectorTextLine(text, coords);
    }
Esempio n. 11
0
    static Vector3 getSphereVertex(float u, float v, GizmoCoords coords)
    {
        var unitVert = getUnitSphereVertex(u, v);

        return(coords.transformPoint(unitVert));
    }
Esempio n. 12
0
 public static void drawVectorText(string text, GizmoCoords coords, TextAnchor anchor, TextAnchor alignment)
 {
     VectorText.processText(text, anchor, alignment, (a, b, crd) => {
         gizmoLine(crd.transformPoint(new Vector3(-a.x, a.y, 0.0f)), crd.transformPoint(new Vector3(-b.x, b.y, 0.0f)));
     }, coords);
 }
Esempio n. 13
0
    public static void drawVectorText(string text, Vector3 pos, Quaternion rotation, float letterScale, TextAnchor anchor, TextAnchor alignment)
    {
        var coords = new GizmoCoords(pos, rotation, new Vector3(letterScale, letterScale, letterScale));

        drawVectorText(text, coords, anchor, alignment);
    }
Esempio n. 14
0
    public static void drawWireCone(Vector3 position, float radius, float height, Quaternion rotation, float vPivot = 0.0f, int uSegments = 8, int vSegments = 1)
    {
        GizmoCoords coords = new GizmoCoords(position, rotation, new Vector3(radius, height, radius));

        processWireCone(coords, uSegments, vSegments, vPivot, gizmoLine);
    }
Esempio n. 15
0
    public static void drawWireCube(Transform transform, Vector3 size, Vector3 pivot, bool pivotAxes = false)
    {
        var coords = new GizmoCoords(transform, size);

        processWireCube(coords, pivotAxes, pivot);
    }
Esempio n. 16
0
 public static void processWireCube(GizmoCoords coords, bool makePivotAxes, Vector3 pivotOffset)
 {
     processWireCube(coords, makePivotAxes, pivotOffset, gizmoLine);
 }
Esempio n. 17
0
    public static void drawWireSphere(Transform transform, float localRadius, int uSegments = 8, int vSegments = 4)
    {
        var coords = new GizmoCoords(transform, new Vector3(localRadius, localRadius, localRadius));

        drawWireSphere(coords, uSegments, vSegments);
    }
Esempio n. 18
0
 public static void drawWireSphere(GizmoCoords coords, int uSegments, int vSegments)
 {
     processUvSphere(coords, uSegments, vSegments, gizmoLine);
 }
Esempio n. 19
0
    public static void drawWireSphere(Vector3 position, float radius, int uSegments, int vSegments, Quaternion rotation)
    {
        var coords = new GizmoCoords(position, rotation, new Vector3(radius, radius, radius));

        drawWireSphere(coords, uSegments, vSegments);
    }
Esempio n. 20
0
    public static void drawWireCone(Transform transform, float localRadius, float localHeight, float vPivot = 0.0f, int uSegments = 8, int vSegments = 1)
    {
        GizmoCoords coords = new GizmoCoords(transform, new Vector3(localRadius, localHeight, localRadius));

        processWireCone(coords, uSegments, vSegments, vPivot, gizmoLine);
    }
Esempio n. 21
0
    public static void drawWireCube(Vector3 position, Vector3 size, Quaternion rotation, Vector3 pivot, bool pivotAxes = false)
    {
        var coords = new GizmoCoords(position, rotation, size);

        processWireCube(coords, pivotAxes, pivot);
    }