本文整理汇总了Java中javax.media.j3d.BoundingBox.getLower方法的典型用法代码示例。如果您正苦于以下问题:Java BoundingBox.getLower方法的具体用法?Java BoundingBox.getLower怎么用?Java BoundingBox.getLower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.j3d.BoundingBox
的用法示例。
在下文中一共展示了BoundingBox.getLower方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTextureCoordinates
import javax.media.j3d.BoundingBox; //导入方法依赖的package包/类
/**
* Returns a texture coordinates generator that wraps the given texture on front face.
*/
private TexCoordGeneration getTextureCoordinates(Appearance appearance, HomeTexture texture, Vector3f pieceSize,
BoundingBox modelBounds)
{
Point3d lower = new Point3d();
modelBounds.getLower(lower);
Point3d upper = new Point3d();
modelBounds.getUpper(upper);
float minimumSize = ModelManager.getInstance().getMinimumSize();
float textureWidth = TextureManager.getInstance().getRotatedTextureWidth(texture);
float textureHeight = TextureManager.getInstance().getRotatedTextureHeight(texture);
float sx = pieceSize.x / (float) Math.max(upper.x - lower.x, minimumSize) / textureWidth;
float sw = texture.isLeftToRightOriented() ? (float) -lower.x * sx : 0;
float ty = pieceSize.y / (float) Math.max(upper.y - lower.y, minimumSize) / textureHeight;
float tz = pieceSize.z / (float) Math.max(upper.z - lower.z, minimumSize) / textureHeight;
float tw = texture.isLeftToRightOriented() ? (float) (-lower.y * ty + upper.z * tz) : 0;
return new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR, TexCoordGeneration.TEXTURE_COORDINATE_2,
new Vector4f(sx, 0, 0, sw), new Vector4f(0, ty, -tz, tw));
}
示例2: getSize
import javax.media.j3d.BoundingBox; //导入方法依赖的package包/类
/**
* Returns the size of 3D shapes of <code>node</code> after an additional <code>transformation</code>.
* This method computes the exact box that contains all the shapes,
* contrary to <code>node.getBounds()</code> that returns a bounding
* sphere for a scene.
*/
public Vector3f getSize(Node node, Transform3D transformation)
{
BoundingBox bounds = getBounds(node, transformation);
Point3d lower = new Point3d();
bounds.getLower(lower);
Point3d upper = new Point3d();
bounds.getUpper(upper);
return new Vector3f(Math.max(getMinimumSize(), (float) (upper.x - lower.x)),
Math.max(getMinimumSize(), (float) (upper.y - lower.y)),
Math.max(getMinimumSize(), (float) (upper.z - lower.z)));
}
示例3: getBounds
import javax.media.j3d.BoundingBox; //导入方法依赖的package包/类
/**
* Returns the bounds of the 3D shapes of <code>node</code> with an additional <code>transformation</code>.
* This method computes the exact box that contains all the shapes, contrary to <code>node.getBounds()</code>
* that returns a bounding sphere for a scene.
*/
public BoundingBox getBounds(Node node, Transform3D transformation)
{
BoundingBox objectBounds = new BoundingBox(
new Point3d(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY),
new Point3d(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY));
computeBounds(node, objectBounds, transformation, !isOrthogonalRotation(transformation));
Point3d lower = new Point3d();
objectBounds.getLower(lower);
if (lower.x == Double.POSITIVE_INFINITY)
{
throw new IllegalArgumentException("Node has no bounds");
}
return objectBounds;
}
示例4: getNormalizedTransform
import javax.media.j3d.BoundingBox; //导入方法依赖的package包/类
/**
* Returns a transform that will transform the model <code>node</code>
* to let it fill a box of the given <code>width</code> centered on the origin.
* @param node the root of a model with any size and location
* @param modelRotation the rotation applied to the model before normalization
* or <code>null</code> if no transformation should be applied to node.
* @param width the width of the box
*/
public Transform3D getNormalizedTransform(Node node, float[][] modelRotation, float width)
{
// Get model bounding box size
BoundingBox modelBounds = getBounds(node);
Point3d lower = new Point3d();
modelBounds.getLower(lower);
Point3d upper = new Point3d();
modelBounds.getUpper(upper);
// Translate model to its center
Transform3D translation = new Transform3D();
translation.setTranslation(new Vector3d(-lower.x - (upper.x - lower.x) / 2, -lower.y - (upper.y - lower.y) / 2,
-lower.z - (upper.z - lower.z) / 2));
Transform3D modelTransform;
if (modelRotation != null)
{
// Get model bounding box size with model rotation
modelTransform = getRotationTransformation(modelRotation);
modelTransform.mul(translation);
BoundingBox rotatedModelBounds = getBounds(node, modelTransform);
rotatedModelBounds.getLower(lower);
rotatedModelBounds.getUpper(upper);
}
else
{
modelTransform = translation;
}
// Scale model to make it fill a 1 unit wide box
Transform3D scaleOneTransform = new Transform3D();
scaleOneTransform.setScale(new Vector3d(width / Math.max(getMinimumSize(), upper.x - lower.x),
width / Math.max(getMinimumSize(), upper.y - lower.y),
width / Math.max(getMinimumSize(), upper.z - lower.z)));
scaleOneTransform.mul(modelTransform);
return scaleOneTransform;
}
示例5: resize
import javax.media.j3d.BoundingBox; //导入方法依赖的package包/类
public void resize(BoundingBox bbox) {
Point3d lower = new Point3d();
bbox.getLower(lower);
Point3d upper = new Point3d();
bbox.getUpper(upper);
Rectangle2D.Float newSize = new Rectangle2D.Float();
newSize.setRect(lower.x, lower.y, upper.x - lower.x, upper.y - lower.y);
// need to toss out slices outside the z limits
// need to crop the slices which remain
TreeSet<PhantomSlice> newSliceSet = new TreeSet<PhantomSlice>();
for (PhantomSlice slice : this.sliceSet) {
// retain slices which are within the bouding box to the new slice set
if (slice.getPosition().z >= lower.z && slice.getPosition().z <= upper.z) {
// crop them
slice.resize(newSize);
// add them to the new slice set
newSliceSet.add(slice);
}
}
this.sliceSet.clear();
this.sliceSet.addAll(newSliceSet);
// set the new size info
this.size[0] = this.sliceSet.first().getSize().width;
this.size[1] = this.sliceSet.first().getSize().height;
this.size[2] = this.sliceSet.size();
}
示例6: endDocument
import javax.media.j3d.BoundingBox; //导入方法依赖的package包/类
@Override
public void endDocument() throws SAXException
{
for (Runnable runnable : this.postProcessingBinders)
{
runnable.run();
}
if (this.visualScene != null)
{
Transform3D rootTransform = new Transform3D();
this.visualScene.getTransform(rootTransform);
BoundingBox bounds = new BoundingBox(
new Point3d(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY),
new Point3d(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY));
computeBounds(this.visualScene, bounds, new Transform3D());
// Translate model to its center
Point3d lower = new Point3d();
bounds.getLower(lower);
if (lower.x != Double.POSITIVE_INFINITY)
{
Point3d upper = new Point3d();
bounds.getUpper(upper);
Transform3D translation = new Transform3D();
translation.setTranslation(new Vector3d(-lower.x - (upper.x - lower.x) / 2,
-lower.y - (upper.y - lower.y) / 2, -lower.z - (upper.z - lower.z) / 2));
translation.mul(rootTransform);
rootTransform = translation;
}
// Scale model to cm
Transform3D scaleTransform = new Transform3D();
scaleTransform.setScale(this.meterScale * 100);
scaleTransform.mul(rootTransform);
// Set orientation to Y_UP
Transform3D axisTransform = new Transform3D();
if ("Z_UP".equals(axis))
{
axisTransform.rotX(-Math.PI / 2);
}
else if ("X_UP".equals(axis))
{
axisTransform.rotZ(Math.PI / 2);
}
axisTransform.mul(scaleTransform);
this.visualScene.setTransform(axisTransform);
BranchGroup sceneRoot = new BranchGroup();
this.scene.setSceneGroup(sceneRoot);
sceneRoot.addChild(this.visualScene);
}
}
示例7: computeContactNormal
import javax.media.j3d.BoundingBox; //导入方法依赖的package包/类
protected void computeContactNormal(BoundingSphere bs, BoundingBox bb, Vector3d n) {
// NEEDS : BB is Axis Aligned !!!!!
bb.getLower(p1);
bb.getUpper(p2);
bs.getCenter(p3);
// pour chaque face
// normal de la face
// projete centre sphere sur normale
// retourne normale ayant longueur proejectio + petite
// double sqradius = bs.getRadius() * bs.getRadius();
double p;
double min = Double.MAX_VALUE;
// six faces
p = projNormal(p1.x, p1.y, p1.z, p1.x, p2.y, p1.z, p2.x, p1.y, p1.z);
if (p < min) {
min = p;
n.set(v3);
}
p = projNormal(p2.x, p1.y, p1.z, p2.x, p2.y, p1.z, p2.x, p1.y, p2.z);
if (p < min) {
min = p;
n.set(v3);
}
/*
* p = projNormal(p2.x,p1.y,p2.z, p2.x,p2.y,p2.z, p1.x,p1.y,p2.z); if (p
* < min) { min = p; n.set(v3);}
*/
/*
* p = projNormal(p1.x,p1.y,p2.z, p1.x,p2.y,p2.z, p1.x,p1.y,p1.z); if (p
* < min) { min = p; n.set(v3);}
*/
/*
* p = projNormal(p1.x,p2.y,p1.z, p1.x,p2.y,p2.z, p2.x,p2.y,p1.z); if (p
* < min) { min = p; n.set(v3);} p = projNormal(p1.x,p1.y,p2.z,
* p1.x,p1.y,p1.z, p2.x,p1.y,p2.z); if (p < min) { min = p; n.set(v3);}
*/
}
示例8: computeContactNormal
import javax.media.j3d.BoundingBox; //导入方法依赖的package包/类
protected void computeContactNormal(BoundingSphere bs, BoundingBox bb, Vector3d n) {
// NEEDS : BB is Axis Aligned !!!!!
bb.getLower(p1);
bb.getUpper(p2);
bs.getCenter(p3);
// pour chaque face
// normal de la face
// projete centre sphere sur normale
// retourne normale ayant longueur proejectio + petite
// double sqradius = bs.getRadius() * bs.getRadius();
double p;
double min = Double.MAX_VALUE;
// six faces
p = projNormal(p1.x, p1.y, p1.z, p1.x, p2.y, p1.z, p2.x, p1.y, p1.z);
if (p < min) {
min = p;
n.set(v3);
}
p = projNormal(p2.x, p1.y, p1.z, p2.x, p2.y, p1.z, p2.x, p1.y, p2.z);
if (p < min) {
min = p;
n.set(v3);
}
/*
* p = projNormal(p2.x,p1.y,p2.z, p2.x,p2.y,p2.z, p1.x,p1.y,p2.z); if (p <
* min) { min = p; n.set(v3);}
*/
/*
* p = projNormal(p1.x,p1.y,p2.z, p1.x,p2.y,p2.z, p1.x,p1.y,p1.z); if (p <
* min) { min = p; n.set(v3);}
*/
/*
* p = projNormal(p1.x,p2.y,p1.z, p1.x,p2.y,p2.z, p2.x,p2.y,p1.z); if (p <
* min) { min = p; n.set(v3);} p = projNormal(p1.x,p1.y,p2.z,
* p1.x,p1.y,p1.z, p2.x,p1.y,p2.z); if (p < min) { min = p; n.set(v3);}
*/
}
示例9: visualizeBounds
import javax.media.j3d.BoundingBox; //导入方法依赖的package包/类
public static BranchGroup visualizeBounds( Bounds b , Transform3D xform , Appearance app )
{
final BranchGroup bg = new BranchGroup( );
bg.setCapability( BranchGroup.ALLOW_DETACH );
final TransformGroup tg = new TransformGroup( );
final Transform3D xlate = new Transform3D( );
if( b instanceof BoundingBox )
{
final BoundingBox bbox = ( BoundingBox ) b;
final Point3d lower = new Point3d( ) , upper = new Point3d( );
bbox.getLower( lower );
bbox.getUpper( upper );
xlate.set( new double[ ] { ( upper.x - lower.x ) * 0.5 , 0 , 0 , ( upper.x + lower.x ) * 0.5 , 0 , ( upper.y - lower.y ) * 0.5 , 0 , ( upper.y + lower.y ) * 0.5 , 0 , 0 , ( upper.z - lower.z ) * 0.5 , ( upper.z + lower.z ) * 0.5 , 0 , 0 , 0 , 1 } );
if( xform != null )
{
xlate.mul( xform , xlate );
}
tg.setTransform( xlate );
bg.addChild( tg );
final com.sun.j3d.utils.geometry.Box vbox = new com.sun.j3d.utils.geometry.Box( );
vbox.setAppearance( app );
tg.addChild( vbox );
}
else if( b instanceof BoundingSphere )
{
final BoundingSphere bsphere = ( BoundingSphere ) b;
final Point3d center = new Point3d( );
bsphere.getCenter( center );
final double radius = bsphere.getRadius( );
xlate.setTranslation( new Vector3d( center ) );
if( xform != null )
{
xlate.mul( xform , xlate );
}
tg.setTransform( xlate );
bg.addChild( tg );
final com.sun.j3d.utils.geometry.Sphere vsphere = new com.sun.j3d.utils.geometry.Sphere( ( float ) radius );
vsphere.setAppearance( app );
tg.addChild( vsphere );
}
return bg;
}