48 |
|
|
49 |
static protected float [][] circleGL = new float[360][2]; |
static protected float [][] circleGL = new float[360][2]; |
50 |
static protected boolean circleGLReady = false; |
static protected boolean circleGLReady = false; |
51 |
static protected void prepareCircleGL() { |
static protected void prepareCircleGL(int start) { |
52 |
if (!circleGLReady) { |
if (!circleGLReady) { |
53 |
for (int i=0;i<360;i++) { |
for (int i=0;i<360;i++) { |
54 |
float a = (float)((Math.PI / 180) * (360-(i+90))); |
float a = (float)((Math.PI / 180) * (360-(i+start))); |
55 |
circleGL[i][0] = 0.5f + x(a, 0.5f); |
circleGL[i][0] = 0.5f + x(a, 0.5f); |
56 |
circleGL[i][1] = 0.5f + y(a, 0.5f); |
circleGL[i][1] = 0.5f + y(a, 0.5f); |
57 |
} |
} |
65 |
return (float)(Math.sin((double)angle) * radius); |
return (float)(Math.sin((double)angle) * radius); |
66 |
} |
} |
67 |
|
|
68 |
protected int angle = 360; |
protected int start; |
69 |
protected int step = 10; |
protected int sector; |
70 |
public ColoredSectorVob(int angle, int step) { |
protected int step; |
71 |
|
|
72 |
|
/** Creates ColoredSectorVob |
73 |
|
* @param start Start angle of the sector. 0 degree is at clock three. |
74 |
|
* 90 degrees is at clock twelve. |
75 |
|
* @param sector The angle of the sector to be drawn. Max 360 degrees. |
76 |
|
* @param step Every step:th vertex is drawn. This affects only the |
77 |
|
* GL implementation. Currently the maximum |
78 |
|
* resolution is 360 vertexes. XXX this will be removed |
79 |
|
* after DiceableMesh renderable works. |
80 |
|
*/ |
81 |
|
public ColoredSectorVob(int start, int sector, int step) { |
82 |
super(); |
super(); |
83 |
this.angle = angle; |
this.start = start; |
84 |
|
this.sector = sector; |
85 |
this.step = step; |
this.step = step; |
86 |
} |
} |
87 |
|
/* Default valus for drawing a small circle. */ |
88 |
|
public ColoredSectorVob(){ |
89 |
|
this(90, 360, 10); |
90 |
|
} |
91 |
|
|
92 |
static Rectangle rect = new Rectangle(); |
static Rectangle rect = new Rectangle(); |
93 |
int nsolids = 0; |
int nsolids = 0; |
110 |
/** Heavier border with bigger cells */ |
/** Heavier border with bigger cells */ |
111 |
if(drawBorder && mh >= 20) { |
if(drawBorder && mh >= 20) { |
112 |
g.setColor(info1.getMixedFgColor()); |
g.setColor(info1.getMixedFgColor()); |
113 |
g.fillArc(mx-1, my-1, mw+2, mh+2, 90, angle); |
g.fillArc(mx-1, my-1, mw+2, mh+2, start, sector); |
114 |
} |
} |
115 |
|
|
116 |
if(nsolids == 0) { |
if(nsolids == 0) { |
117 |
g.setColor(bg); |
g.setColor(bg); |
118 |
g.fillArc(mx, my, mw, mh, 90, angle); |
g.fillArc(mx, my, mw, mh, start, sector); |
119 |
} else { |
} else { |
120 |
// Draws multiple background colours as sectors |
// Draws multiple background colours as sectors |
121 |
int arc = angle / nsolids; |
int arc = sector / nsolids; |
122 |
for(int i=0; i<nsolids; i++) { |
for(int i=0; i<nsolids; i++) { |
123 |
g.setColor(solids[i]); |
g.setColor(solids[i]); |
124 |
g.fillArc(mx, my, mw, mh, 90 + arc * i, arc); |
g.fillArc(mx, my, mw, mh, start + arc * i, arc); |
125 |
} |
} |
126 |
} |
} |
127 |
|
|
128 |
if(drawBorder) { |
if(drawBorder) { |
129 |
g.setColor(info1.getMixedFgColor()); |
g.setColor(info1.getMixedFgColor()); |
130 |
g.drawArc(mx, my, mw, mh, 90, angle); |
g.drawArc(mx, my, mw, mh, start, sector); |
131 |
if (angle < 360) { |
if (sector < 360) { |
132 |
g.drawLine(mx+mw/2, my+mh/2, mx+mw/2, my); |
float a = (float)((Math.PI / 180f) * (360f-(start))); |
133 |
float a = (float)((Math.PI / 180f) * (360f-(angle+90f))); |
g.drawLine(mx+mw/2, my+mh/2, |
134 |
|
mx+mw/2 + (int)x(a, mw/2), |
135 |
|
my+mh/2 + (int)y(a, mh/2)); |
136 |
|
a = (float)((Math.PI / 180f) * (360f-(sector+start))); |
137 |
g.drawLine(mx+mw/2, my+mh/2, |
g.drawLine(mx+mw/2, my+mh/2, |
138 |
mx+mw/2 + (int)x(a, mw/2), |
mx+mw/2 + (int)x(a, mw/2), |
139 |
my+mh/2 + (int)y(a, mh/2)); |
my+mh/2 + (int)y(a, mh/2)); |
150 |
int coordsys2) { |
int coordsys2) { |
151 |
if(dbg) pa("Addtolistgl coloredsectorvob "+coordsys1); |
if(dbg) pa("Addtolistgl coloredsectorvob "+coordsys1); |
152 |
if(glList == null) { |
if(glList == null) { |
153 |
if (!circleGLReady) prepareCircleGL(); |
if (!circleGLReady) prepareCircleGL(start); |
154 |
String bgcall = ""; |
String bgcall = ""; |
155 |
if(nsolids > 0) { |
if(nsolids > 0) { |
156 |
int arc = angle / nsolids; |
int arc = sector / nsolids; |
157 |
for(int i=0; i<nsolids; i++) { |
for(int i=0; i<nsolids; i++) { |
158 |
Color c = solids[i]; |
Color c = solids[i]; |
159 |
bgcall += ( |
bgcall += ( |
165 |
" " + circleGL[j][1] + "\n"); |
" " + circleGL[j][1] + "\n"); |
166 |
} |
} |
167 |
int last = (i+1)*arc-1; |
int last = (i+1)*arc-1; |
168 |
if (angle == 360) last++; |
if (sector == 360) last++; |
169 |
if (last == 360) last = 0; |
if (last == 360) last = 0; |
170 |
bgcall += ("Vertex " + circleGL[last][0] + |
bgcall += ("Vertex " + circleGL[last][0] + |
171 |
" " + circleGL[last][1] + "\n" + |
" " + circleGL[last][1] + "\n" + |
175 |
bgcall = ( |
bgcall = ( |
176 |
"Color "+ColorUtil.colorGLString(bg)+" 1\n" + |
"Color "+ColorUtil.colorGLString(bg)+" 1\n" + |
177 |
"Begin POLYGON\n"); |
"Begin POLYGON\n"); |
178 |
if (angle < 360) bgcall += ("Vertex 0.5 0.5\n"); |
if (sector < 360) bgcall += ("Vertex 0.5 0.5\n"); |
179 |
for (int i=0;i<angle;i+=step) { |
for (int i=0;i<sector;i+=step) { |
180 |
bgcall += ("Vertex " + circleGL[i][0] + |
bgcall += ("Vertex " + circleGL[i][0] + |
181 |
" " + circleGL[i][1] + "\n"); |
" " + circleGL[i][1] + "\n"); |
182 |
} |
} |
183 |
bgcall += ("Vertex " + circleGL[angle-1][0] + |
bgcall += ("Vertex " + circleGL[sector-1][0] + |
184 |
" " + circleGL[angle-1][1] + "\n" + |
" " + circleGL[sector-1][1] + "\n" + |
185 |
"End\n"); |
"End\n"); |
186 |
} |
} |
187 |
|
|
188 |
bgcall += ( |
bgcall += ( |
189 |
"Color 0 0 0 1\n" + |
"Color 0 0 0 1\n" + |
190 |
"Begin LINE_LOOP\n"); |
"Begin LINE_LOOP\n"); |
191 |
if (angle < 360) bgcall += ("Vertex 0.5 0.5\n"); |
if (sector < 360) bgcall += ("Vertex 0.5 0.5\n"); |
192 |
for (int i=0;i<angle;i+=step) { |
for (int i=0;i<sector;i+=step) { |
193 |
bgcall += ("Vertex " + circleGL[i][0] + |
bgcall += ("Vertex " + circleGL[i][0] + |
194 |
" " + circleGL[i][1] + "\n"); |
" " + circleGL[i][1] + "\n"); |
195 |
} |
} |
196 |
bgcall += ("Vertex " + circleGL[angle-1][0] + |
bgcall += ("Vertex " + circleGL[sector-1][0] + |
197 |
" " + circleGL[angle-1][1] + "\n" + |
" " + circleGL[sector-1][1] + "\n" + |
198 |
"End\n"); |
"End\n"); |
199 |
|
|
200 |
glList = GLRen.createCallListBoxCoorded( |
glList = GLRen.createCallListBoxCoorded( |