Normand Briere
2019-09-07 3e5c2d344e04e0adb6a210c5c6302bfbfd8af102
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
class Grid extends Sphere implements java.io.Serializable
{
    static final long serialVersionUID = -1834404875956759200L;
 
    Grid()
    {
        this(36, 36);
    }
 
    Grid(int u, int v)
    {
       super(false);
       //this(true);
   //}
   
   //public Sphere(boolean recalc)
   //{
        inPnt = new cVector();
        name = "Grid";
        uDivs = u;
        vDivs = v;
        minUDivs = 1;
       minVDivs = 1;
        center = new cVector();
        radius = 1;
       //if (recalc)
       {
           retile();
           recalculate();
       }
    }
 
    Object3D deepCopy()
    {
        Grid e = new Grid();
        deepCopySelf(e);
        return e;
    }
 
    protected void deepCopyNode(Object3D other)
    {
        super.deepCopyNode(other);
        Grid e = (Grid)other;
        e.center = new cVector();
        LA.vecCopy(center, e.center);
        e.radius = radius;
    }
 
    void generatePOV(StringBuffer buffer)
    {
   /*
        generateNameComment(buffer);
        generateIndent(buffer);
        buffer.append("sphere { ");
        LA.toPOVRay(center, buffer);
        buffer.append(", ");
        buffer.append(radius);
        buffer.append("\n");
        generateTransform(buffer);
        generateIndent(buffer);
        buffer.append("}\n");
   */
    }
 
    double uStretch()
    {
        return 1;
    }
    
    double vFlip(double v)
    {
        return 1-v;
    }
    
    Vertex biparamFunction(double u, double v)
    {
        Vertex temp = new Vertex((2*v-1)*radius*4, 0 /*-radius,*/, (2*u-1)*radius*4);
        temp.norm = LA.newVector(0,1,0);
        return temp;
    }
 
    void createEditWindow(GroupEditor callee, boolean newWindow)
    {
        //editWindow = (new SphereEditor(this, deepCopy(), callee)).GetEditor(); // ????
       if (newWindow)
           objectUI = new SphereEditor(this, deepCopy(), callee);
       else
           objectUI = new SphereEditor(this, callee);
        editWindow = objectUI.GetEditor();
    }
 
// july 2014   void getBounds(cVector minima, cVector maxima, boolean xform)
//    {
//        //for (int i=0; i < 3; i++)
//        {
//            minima.x = center.x - radius;
//            minima.y = center.y; // - radius;
//            minima.z = center.z - radius;
//            //maxima[i] = center[i] + radius;
//            maxima.x = center.x + radius;
//            maxima.y = center.y; // - radius;
//            maxima.z = center.z + radius;
//        }
//
//        if (xform)
//            transformBounds(minima, maxima);
//    }
 
    boolean inside(double x, double y, double z, boolean xform)
    {
        if (xform)
            untransform(x, y, z, inPnt);
        else
            LA.setVector(inPnt, x, y, z);
        //LA.vecSub(inPnt, center, inPnt);
        //return inPnt.x * inPnt.x + inPnt.y * inPnt.y + inPnt.z * inPnt.z <= radius * radius;
        return inPnt.y < 0;
    }
 
    cVector center;
    double radius;
    protected cVector inPnt;
}