import java.awt.*;
|
|
class BlobComponent extends Sphere implements java.io.Serializable
|
{
|
static final long serialVersionUID = 8329366050568734699L;
|
|
BlobComponent()
|
{
|
name = "Component";
|
//center = new cVector();
|
//radius = 1;
|
//radius2 = radius * radius;
|
strength = 100;
|
}
|
|
Object3D deepCopy()
|
{
|
BlobComponent comp = new BlobComponent();
|
deepCopySelf(comp);
|
return comp;
|
}
|
|
protected void deepCopySelf(Object3D other)
|
{
|
super.deepCopySelf(other);
|
BlobComponent b = (BlobComponent)other;
|
//b.center = new cVector();
|
//LA.vecCopy(center, b.center);
|
//b.radius = radius;
|
//b.radius2 = radius2;
|
b.strength = strength;
|
}
|
|
void generatePOV(StringBuffer buffer)
|
{
|
generateIndent(buffer);
|
buffer.append(" component ");
|
buffer.append(strength);
|
buffer.append(", ");
|
//buffer.append(radius);
|
buffer.append(", ");
|
//LA.toPOVRay(center, buffer);
|
buffer.append("\n");
|
}
|
|
double getFieldStrength(double x, double y, double z)
|
{
|
untransform(x, y, z, cStatic.point1);
|
x = cStatic.point1.x;
|
y = cStatic.point1.y;
|
z = cStatic.point1.z;
|
//untransform(inpnt.x, inpnt.y, inpnt.z, buffer);
|
|
//LA.vecSub(inpnt,center, point);
|
double rad = x*x + y*y + z*z; // LA.vecLen2(buffer); // / radius2;
|
if (rad >= 1)
|
{
|
return 0;
|
} else
|
{
|
//rad *= rad;
|
return strength * (1 - rad) * (1 - rad);
|
}
|
}
|
|
double xx[] = new double[2];
|
double yy[] = new double[2];
|
double zz[] = new double[2];
|
double x2[] = new double[2];
|
double y2[] = new double[2];
|
double z2[] = new double[2];
|
double sum[] = new double[2];
|
|
void boxFieldStrength(double x[], double y[], double z[], double range[])
|
{
|
xx[0] = x[0]; // - center.x;
|
xx[1] = x[1]; // - center.x;
|
yy[0] = y[0]; // - center.y;
|
yy[1] = y[1]; // - center.y;
|
zz[0] = z[0]; // - center.z;
|
zz[1] = z[1]; // - center.z;
|
Interval.boxSquare(xx, x2);
|
Interval.boxSquare(yy, y2);
|
Interval.boxSquare(zz, z2);
|
|
Interval.boxAdd(x2, y2, sum);
|
Interval.boxAdd(sum, z2, sum);
|
|
for (int i=0; i < 2; i++)
|
{
|
//sum[i] /= radius2;
|
if (sum[i] > 1)
|
range[i] = 0;
|
else
|
range[i] = strength * (1 - sum[i]) * (1 - sum[i]);
|
}
|
|
if (range[0] > range[1])
|
{
|
double t = range[0];
|
range[0] = range[1];
|
range[1] = t;
|
}
|
}
|
|
Point ctr = new Point(0, 0);
|
Rectangle dummy = new Rectangle();
|
|
/*
|
boolean doSelection(ClickInfo info, Rectangle r, int level)
|
{
|
calcHotSpot(center, info, ctr, dummy);
|
double x[] = new double[2];
|
double y[] = new double[2];
|
x[0] = r.x - ctr.x;
|
x[1] = x[0] + (double)r.width;
|
y[0] = r.y - ctr.y;
|
y[1] = y[0] + (double)r.height;
|
//double x2[] = new double[2];
|
//double y2[] = new double[2];
|
Interval.boxSquare(x, x2);
|
Interval.boxSquare(y, y2);
|
//double sum[] = new double[2];
|
Interval.boxAdd(x2, y2, sum);
|
//return sum[0] < radius2 && sum[1] > radius2;
|
}
|
|
void draw(ClickInfo info, int level, boolean select)
|
{
|
if (select)
|
info.g.setColor(Color.black);
|
else
|
info.g.setColor(Color.gray);
|
Rectangle spot = calcHotSpot(center, info);
|
spot.x -= (int)radius - 2;
|
spot.y -= (int)radius - 2;
|
spot.width = (int)(radius * 2);
|
spot.height = (int)(radius * 2);
|
info.g.drawArc(spot.x, spot.y, spot.width, spot.height, 0, 360);
|
info.g.drawArc(spot.x + 1, spot.y + 1, spot.width - 2, spot.height - 2, 0, 360);
|
}
|
|
void draw(iCameraPane display, boolean selected)
|
{
|
}
|
*/
|
|
/*
|
void drawEditHandles(ClickInfo info, int level)
|
{
|
Rectangle spot = calcHotSpot(center, info);
|
info.g.setColor(Color.red);
|
info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
|
}
|
|
boolean doEditClick(ClickInfo info, int level)
|
{
|
hitSomething = false;
|
Rectangle spot = calcHotSpot(center, info);
|
if (!spot.contains(info.x, info.y))
|
{
|
return false;
|
} else
|
{
|
hitSomething = true;
|
modified = (info.modifiers & CameraPane.META) != 0;
|
startX = info.x;
|
startY = info.y;
|
LA.vecCopy(center, startVec);
|
startRad = radius;
|
return true;
|
}
|
}
|
|
void doEditDrag(ClickInfo info)
|
{
|
if (!hitSomething)
|
return;
|
if (modified)
|
{
|
double deltaR = info.x - startX;
|
deltaR /= 100 * info.camera.SCALE / info.camera.Distance();
|
double newRad = startRad + deltaR;
|
if (newRad < 0)
|
newRad = 0;
|
radius = newRad;
|
//radius2 = radius*radius;
|
} else
|
{
|
cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
|
LA.xformDir(delta, info.camera.fromScreen, delta);
|
delta.x /= 100 * info.camera.SCALE / info.camera.Distance();
|
delta.y /= 100 * info.camera.SCALE / info.camera.Distance();
|
delta.z /= 100 * info.camera.SCALE / info.camera.Distance();
|
LA.vecAdd(startVec, delta, center);
|
}
|
info.pane.repaint();
|
}
|
*/
|
|
public void getBounds(cVector minima, cVector maxima, boolean xform)
|
{
|
//double rad = radius * 1.1;
|
for (int i=0; i < 3; i++)
|
{
|
//minima.set(i, center.get(i) - radius);
|
//maxima.set(i, center.get(i) + radius);
|
minima.set(i, -1);
|
maxima.set(i, 1);
|
}
|
|
if (xform)
|
transformBounds(minima, maxima);
|
}
|
|
//cVector center;
|
//double radius;
|
//double radius2;
|
double strength;
|
private static boolean hitSomething;
|
private static boolean modified;
|
private static int startX;
|
private static int startY;
|
private static cVector startVec = new cVector();
|
private static cVector point = new cVector();
|
private static double startRad;
|
}
|