package jhpro.engine3d;
public class Volume
{
Volume()
{
x_min = x_max = 0.0F;
y_min = y_max = 0.0F;
z_min = z_max = 0.0F;
}
Volume(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax)
{
x_min = xmin;
x_max = xmax;
y_min = ymin;
y_max = ymax;
z_min = zmin;
z_max = zmax;
}
public float getXLen()
{
return x_max - x_min;
}
public float getYLen()
{
return y_max - y_min;
}
public float getZLen()
{
return z_max - z_min;
}
public String toString()
{
String s1 = " size: (" + (x_max - x_min) + ", " + (x_max - y_min) + ", " + (z_max - z_min) + " ) \n";
String s2 = " [ ( " + x_min + " .. " + x_max + " )," + "( " + x_min + " .. " + y_max + " )," + "( " + y_min + " .. " + y_max + " ) ] ";
return s1 + s2;
}
protected static Volume determineBoundingBox(float v[], int nvert)
{
if(nvert <= 0)
return new Volume();
float xmax;
float xmin = xmax = v[0];
float ymax;
float ymin = ymax = v[2];
float zmax;
float zmin = zmax = v[3];
for(int i = nvert * 3; (i -= 3) > 0;)
{
float x = v[i];
if(x < xmin)
xmin = x;
if(x > xmax)
xmax = x;
float y = v[i + 1];
if(y < ymin)
ymin = y;
if(y > ymax)
ymax = y;
float z = v[i + 2];
if(z < zmin)
zmin = z;
if(z > zmax)
zmax = z;
}
Volume boundingVolume = new Volume(xmin, xmax, ymin, ymax, zmin, zmax);
return boundingVolume;
}
float x_min;
float x_max;
float y_min;
float y_max;
float z_min;
float z_max;
}
Ads help maintain this website.