本文整理汇总了Java中javax.media.j3d.BoundingBox类的典型用法代码示例。如果您正苦于以下问题:Java BoundingBox类的具体用法?Java BoundingBox怎么用?Java BoundingBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoundingBox类属于javax.media.j3d包,在下文中一共展示了BoundingBox类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:valsr,项目名称:SweetHome3D,代码行数:22,代码来源:HomePieceOfFurniture3D.java
示例2: create3D
import javax.media.j3d.BoundingBox; //导入依赖的package包/类
/** Create the 3d object */
protected void create3D(EnvironmentDescription wd, Color3f color) {
// create the box using a primitive
super.create3D();
Material mat = new Material();
appearance.setMaterial(mat);
int flags = Primitive.GEOMETRY_NOT_SHARED | Primitive.ENABLE_GEOMETRY_PICKING | Primitive.GENERATE_NORMALS;
flags |= Primitive.ENABLE_APPEARANCE_MODIFY;
// com.sun.j3d.utils.geometry.Box box =new
// com.sun.j3d.utils.geometry.Box(sx,sy,sz,flags,appearance,0);
// bug in j3d api doc . must give half values.
com.sun.j3d.utils.geometry.Box box = new com.sun.j3d.utils.geometry.Box(sx / 2, sy / 2, sz / 2, flags, appearance, 0);
// Enable sensor detection
box.setPickable(true);
// define the boundsfFor collision detection
BoundingBox bounds = new BoundingBox();
bounds.setUpper(sx / 2, sy / 2, sz / 2);
bounds.setLower(-sx / 2, -sy / 2, -sz / 2);
setBounds(bounds);
setColor(color);
addChild(box);
}
开发者ID:glaudiston,项目名称:project-bianca,代码行数:27,代码来源:Box.java
示例3: intersect
import javax.media.j3d.BoundingBox; //导入依赖的package包/类
/** */
protected boolean intersect(BoundingSphere bs, BoundingBox bb) {
return (bb.intersect(bs));
/*
* double radiussq = bs.getRadius()*bs.getRadius(); bb.getLower(p1);
* bb.getUpper(p2); bs.getCenter(p3); double xmin = Math.min(p1.x,p2.x);
* double ymin = Math.min(p1.y,p2.y); double zmin = Math.min(p1.z,p2.z);
* double xmax = Math.max(p1.x,p2.x); double ymax = Math.max(p1.y,p2.y);
* double zmax = Math.max(p1.z,p2.z);
*
* double dmin = 0; if (p3.x < xmin) dmin += (p3.x - xmin)*(p3.x -
* xmin); else if (p3.x >xmax ) dmin += (p3.x - xmax)*(p3.x - xmax);
*
* if (p3.y < ymin) dmin += (p3.y - ymin)*(p3.y - ymin); else if (p3.y
* >ymax ) dmin += (p3.y - ymax)*(p3.y - ymax);
*
* if (p3.z < zmin) dmin += (p3.z - zmin)*(p3.z - zmin); else if (p3.z
* >zmax ) dmin += (p3.z - zmax)*(p3.z - zmax);
*
* return ( dmin <= radiussq );
*/
}
开发者ID:glaudiston,项目名称:project-bianca,代码行数:25,代码来源:PhysicalEngine.java
示例4: pickCube
import javax.media.j3d.BoundingBox; //导入依赖的package包/类
@Override
public Collection<RenderedManifestation> pickCube()
{
PickResult[] pickResult = null;
try {
mPickCanvas .setShapeBounds( new BoundingBox( new Point3d(0,0,-50), new Point3d(50,50,50) ), new Point3d(1d,1d,1d) );
pickResult = mPickCanvas .pickAll();
} catch( Throwable t ) {
t .printStackTrace();
}
Collection<RenderedManifestation> result = new ArrayList<>();
for ( int i = 0; i < pickResult.length; i++ )
{
Node node = pickResult[ i ] .getObject();
RenderedManifestation picked = (RenderedManifestation) node .getUserData();
result .add( picked );
}
// for scenegraph.Factory approach
// Node node = pickResult == null? null : pickResult .getNode( PickResult.BRANCH_GROUP );
return result;
}
开发者ID:vZome,项目名称:vzome-desktop,代码行数:24,代码来源:Java3dRenderingViewer.java
示例5: create3D
import javax.media.j3d.BoundingBox; //导入依赖的package包/类
/** Create the 3d object */
protected void create3D(EnvironmentDescription wd, Color3f color) {
// create the box using a primitive
super.create3D();
Material mat = new Material();
appearance.setMaterial(mat);
int flags = Primitive.GEOMETRY_NOT_SHARED | Primitive.ENABLE_GEOMETRY_PICKING | Primitive.GENERATE_NORMALS;
flags |= Primitive.ENABLE_APPEARANCE_MODIFY;
// com.sun.j3d.utils.geometry.Box box =new
// com.sun.j3d.utils.geometry.Box(sx,sy,sz,flags,appearance,0);
// bug in j3d api doc . must give half values.
com.sun.j3d.utils.geometry.Box box = new com.sun.j3d.utils.geometry.Box(sx / 2, sy / 2, sz / 2, flags, appearance, 0);
// Enable sensor detection
box.setPickable(true);
// define the boundsfFor collision detection
BoundingBox bounds = new BoundingBox();
bounds.setUpper(sx / 2, sy / 2, sz / 2);
bounds.setLower(-sx / 2, -sy / 2, -sz / 2);
setBounds(bounds);
setColor(color);
addChild(box);
}
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:27,代码来源:Box.java
示例6: intersect
import javax.media.j3d.BoundingBox; //导入依赖的package包/类
/** */
protected boolean intersect(BoundingSphere bs, BoundingBox bb) {
return (bb.intersect(bs));
/*
* double radiussq = bs.getRadius()*bs.getRadius(); bb.getLower(p1);
* bb.getUpper(p2); bs.getCenter(p3); double xmin = Math.min(p1.x,p2.x);
* double ymin = Math.min(p1.y,p2.y); double zmin = Math.min(p1.z,p2.z);
* double xmax = Math.max(p1.x,p2.x); double ymax = Math.max(p1.y,p2.y);
* double zmax = Math.max(p1.z,p2.z);
*
* double dmin = 0; if (p3.x < xmin) dmin += (p3.x - xmin)*(p3.x - xmin);
* else if (p3.x >xmax ) dmin += (p3.x - xmax)*(p3.x - xmax);
*
* if (p3.y < ymin) dmin += (p3.y - ymin)*(p3.y - ymin); else if (p3.y >ymax
* ) dmin += (p3.y - ymax)*(p3.y - ymax);
*
* if (p3.z < zmin) dmin += (p3.z - zmin)*(p3.z - zmin); else if (p3.z >zmax
* ) dmin += (p3.z - zmax)*(p3.z - zmax);
*
* return ( dmin <= radiussq );
*/
}
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:25,代码来源:PhysicalEngine.java
示例7: 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)));
}
开发者ID:valsr,项目名称:SweetHome3D,代码行数:18,代码来源:ModelManager.java
示例8: 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;
}
开发者ID:valsr,项目名称:SweetHome3D,代码行数:20,代码来源:ModelManager.java
示例9: 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;
}
开发者ID:valsr,项目名称:SweetHome3D,代码行数:45,代码来源:ModelManager.java
示例10: createBackgroundNode
import javax.media.j3d.BoundingBox; //导入依赖的package包/类
/**
* Returns a new background node.
*/
private Node createBackgroundNode(boolean listenToHomeUpdates, final boolean waitForLoading)
{
final Appearance backgroundAppearance = new Appearance();
ColoringAttributes backgroundColoringAttributes = new ColoringAttributes();
backgroundAppearance.setColoringAttributes(backgroundColoringAttributes);
// Allow background color and texture to change
backgroundAppearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
backgroundAppearance.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ);
backgroundColoringAttributes.setCapability(ColoringAttributes.ALLOW_COLOR_WRITE);
Geometry halfSphereGeometry = createHalfSphereGeometry(true);
final Shape3D halfSphere = new Shape3D(halfSphereGeometry, backgroundAppearance);
BranchGroup backgroundBranch = new BranchGroup();
backgroundBranch.addChild(halfSphere);
backgroundBranch.addChild(new Shape3D(createHalfSphereGeometry(false)));
final Background background = new Background(backgroundBranch);
updateBackgroundColorAndTexture(backgroundAppearance, this.home, waitForLoading);
background.setImageScaleMode(Background.SCALE_FIT_ALL);
background.setApplicationBounds(new BoundingBox(new Point3d(-1E7, -1E7, -1E7), new Point3d(1E7, 1E7, 1E7)));
if (listenToHomeUpdates)
{
// Add a listener on sky color and texture properties change
this.skyColorListener = new PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent ev)
{
updateBackgroundColorAndTexture(backgroundAppearance, home, waitForLoading);
}
};
this.home.getEnvironment().addPropertyChangeListener(HomeEnvironment.Property.SKY_COLOR,
this.skyColorListener);
this.home.getEnvironment().addPropertyChangeListener(HomeEnvironment.Property.SKY_TEXTURE,
this.skyColorListener);
}
return background;
}
开发者ID:valsr,项目名称:SweetHome3D,代码行数:42,代码来源:HomeComponent3D.java
示例11: computeAgentObjectImpact
import javax.media.j3d.BoundingBox; //导入依赖的package包/类
/** experimental */
private void computeAgentObjectImpact(SimpleAgent a, StaticObject o, BoundingSphere bsa) {
Vector3d n = v5;
double coefficientOfRestitution = 1.0;
// Compute normalized normal and contact point
computeContactNormal(bsa, (BoundingBox) o.getBounds(), n);
// velocity component in normal direction
double ndotva = n.dot(a.linearVelocity);
// System.out.println("ndotva " + ndotva );
if (ndotva <= 0) {
// Compute impulse magnitude in the normal direction
// j = (-(1+epsilon)vrel.n ) / (n.n (1/a_mass + 1/o_mass))
// And Va = Va + (j/a_mass)(n)
// but o_mass is infinite and o is static
// and a_mass can be canceled thus:
// j = (-(1+epsilon)avel.n )
// And Va = Va + jn
double j = -(1 + coefficientOfRestitution) * ndotva;
v2.set(n);
v2.scale(j);
a.linearVelocity.add(v2);
// System.out.println("add " + v2.toString()
// +" normal "+n.toString());
}
}
开发者ID:glaudiston,项目名称:project-bianca,代码行数:31,代码来源:PhysicalEngine.java
示例12: computeAgentObjectImpact
import javax.media.j3d.BoundingBox; //导入依赖的package包/类
/** experimental */
private void computeAgentObjectImpact(SimpleAgent a, StaticObject o, BoundingSphere bsa) {
Vector3d n = v5;
double coefficientOfRestitution = 1.0;
// Compute normalized normal and contact point
computeContactNormal(bsa, (BoundingBox) o.getBounds(), n);
// velocity component in normal direction
double ndotva = n.dot(a.linearVelocity);
// System.out.println("ndotva " + ndotva );
if (ndotva <= 0) {
// Compute impulse magnitude in the normal direction
// j = (-(1+epsilon)vrel.n ) / (n.n (1/a_mass + 1/o_mass))
// And Va = Va + (j/a_mass)(n)
// but o_mass is infinite and o is static
// and a_mass can be canceled thus:
// j = (-(1+epsilon)avel.n )
// And Va = Va + jn
double j = -(1 + coefficientOfRestitution) * ndotva;
v2.set(n);
v2.scale(j);
a.linearVelocity.add(v2);
// System.out.println("add " + v2.toString()
// +" normal "+n.toString());
}
}
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:31,代码来源:PhysicalEngine.java
示例13: getBoundingBox
import javax.media.j3d.BoundingBox; //导入依赖的package包/类
/**
*
* @return bounding box covering the whole phantom
*/
public BoundingBox getBoundingBox() {
Point3d lowerCorner = this.getPosition();
Double dx = this.getSize()[0] * this.getVoxelSize().x;
Double dy = this.getSize()[1] * this.getVoxelSize().y;
Point3d upperCorner = this.sliceSet.last().getPosition();
upperCorner.add(new Point3d(dx, dy, 0.));
return new BoundingBox(lowerCorner, upperCorner);
}
开发者ID:prehensilecode,项目名称:eclipse-plan,代码行数:14,代码来源:Phantom.java
示例14: 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();
}
开发者ID:prehensilecode,项目名称:eclipse-plan,代码行数:33,代码来源:Phantom.java
示例15: main
import javax.media.j3d.BoundingBox; //导入依赖的package包/类
/** Simple test program
* @param args
*/
public static void main(String[] args) {
CTImageList ctlist = new CTImageList("A085028");
Phantom p = new Phantom(ctlist);
System.out.println("no. of slices = " + p.getSize().toString());
NavigableSet<PhantomSlice> slices = p.getSliceSet();
System.out.println("no. of slices = " + slices.size());
System.out.println("Structures: " + p.getStructures().getStructureMap().keySet());
StructureSet structs = p.getStructures();
//System.out.println("rkidney size: " + structs.getStructureMap().get("rkidney").getBoundingBox());
try {
System.out.println("phantom sizex: " + p.getSize()[0] + ", " + p.getSize()[1] + ", " + p.getSize()[2]);
System.out.println("phantom position: " + p.getPosition());
//p.checkMaterialVoxels();
//p.resize("rkidney");
// the following bounding box is for the dental MC
// lower corner: (-7.29cm, -10.0cm, 1.03cm)
// upper corner: (-0.61cm, -0.50cm, 4.03cm)
// need it in mm.
BoundingBox bbox = new BoundingBox(new Point3d(-72.9, -100., 10.3), new Point3d(-6.1, -5.0, 40.3));
p.resize(bbox);
System.out.println("phantom size, after resize: " + p.getSize()[0] + ", " + p.getSize()[1] + ", " + p.getSize()[2]);
System.out.println("phantom position, after resize: " + p.getPosition());
//p.checkMaterialVoxels();
EgsPhant egsphant = new EgsPhant(p);
egsphant.writeFile("A085028.egsphant");
} catch (Exception ex) {
Logger.getLogger(Phantom.class.getName()).log(Level.SEVERE, null, ex);
}
}
开发者ID:prehensilecode,项目名称:eclipse-plan,代码行数:37,代码来源:Phantom.java
示例16: 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);
}
}
开发者ID:valsr,项目名称:SweetHome3D,代码行数:57,代码来源:DAELoader.java
示例17: 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);}
*/
}
开发者ID:glaudiston,项目名称:project-bianca,代码行数:42,代码来源:PhysicalEngine.java
示例18: 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);}
*/
}
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:42,代码来源:PhysicalEngine.java
示例19: 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;
}
开发者ID:jedwards1211,项目名称:breakout,代码行数:52,代码来源:J3DUtils.java
注:本文中的javax.media.j3d.BoundingBox类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论