当前位置: 首页>>代码示例>>Java>>正文


Java Box类代码示例

本文整理汇总了Java中com.sun.j3d.utils.geometry.Box的典型用法代码示例。如果您正苦于以下问题:Java Box类的具体用法?Java Box怎么用?Java Box使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Box类属于com.sun.j3d.utils.geometry包,在下文中一共展示了Box类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildScene

import com.sun.j3d.utils.geometry.Box; //导入依赖的package包/类
@Override
void buildScene(TransformGroup transformGroup) {
    transformGroup.addChild(getColorBackground(new Color(.905f, .905f, 0.95f)));
    Appearance appearance = new Appearance();
    Material mat = new Material();
    mat.setAmbientColor(0.5f, 0.5f, 0.5f);
    mat.setDiffuseColor(1.0f, 1.0f, 1.0f);
    mat.setEmissiveColor(0.0f, 0.0f, 0.0f);
    mat.setSpecularColor(1.0f, 1.0f, 1.0f);
    mat.setShininess(80.0f);
    appearance.setMaterial(mat);

    TransparencyAttributes ta = new TransparencyAttributes();
    ta.setTransparency(0.5f);
    ta.setTransparencyMode(TransparencyAttributes.BLENDED);
    appearance.setTransparencyAttributes(ta);

    transformGroup.addChild(new Box(0.6f, 0.5f, 0.4f, appearance));

    transformGroup.addChild(getPointLight(new Color(1.0f, 1.0f, 1.0f), new Point3f(2.0f, 2.0f, 2.0f)));
    transformGroup.addChild(getAmbientLight(new Color(0.1f, 0.1f, 0.1f)));
    transformGroup.setTransform(getTransform(new Vector3f(0.3f, 0.3f, 0.3f), 0.75, -1, Math.PI / 4.0d));
}
 
开发者ID:tekrei,项目名称:JavaExamples,代码行数:24,代码来源:LightningExample.java

示例2: buildScene

import com.sun.j3d.utils.geometry.Box; //导入依赖的package包/类
@Override
void buildScene(TransformGroup transformGroup) {
    Background background = new Background(new Color3f(.905f, .905f, 0.95f));
    background.setApplicationBounds(BOUNDS);
    transformGroup.addChild(background);

    Appearance appearance = new Appearance();
    ColoringAttributes ca = new ColoringAttributes();
    ca.setColor(1.0f, 0.0f, 1.0f);
    ca.setShadeModel(ColoringAttributes.SHADE_GOURAUD);
    appearance.setColoringAttributes(ca);
    transformGroup.addChild(new Box(0.6f, 0.5f, 0.4f, appearance));

    Transform3D transform3D = new Transform3D();
    transform3D.setTranslation(new Vector3f(0.3f, 0.3f, 0.3f));
    transform3D.setScale(0.75);
    Transform3D t = new Transform3D();
    t.rotY(Math.PI / 4.0d);
    transform3D.mul(t);
    transformGroup.setTransform(transform3D);
}
 
开发者ID:tekrei,项目名称:JavaExamples,代码行数:22,代码来源:ColoredBoxExample.java

示例3: testOBJWriter

import com.sun.j3d.utils.geometry.Box; //导入依赖的package包/类
/**
 * Simple test of OBJWriter class with Java 3D objects.
 */
public void testOBJWriter() throws IOException {
  // 1. Open the OBJ file "Test.obj"
  OBJWriter writer = new OBJWriter("[email protected]#.obj", "Test", 3);
  assertTrue("[email protected]#.obj not created", new File("[email protected]#.obj").exists());
  
  // 2. Write a box at center 
  writer.writeNode(new Box());
  
  // Write a sphere centered at (2, 0, 2) 
  Transform3D translation = new Transform3D();
  translation.setTranslation(new Vector3f(2f, 0, 2f));
  TransformGroup translationGroup = new TransformGroup(translation);
  
  translationGroup.addChild(new Sphere());
  writer.writeNode(translationGroup);
  
  // 3. Close file
  writer.close();
  assertTrue("[email protected]#.mtl not created", new File("[email protected]#.mtl").exists());
  
  if (!new File("[email protected]#.obj").delete()
      || !new File("[email protected]#.mtl").delete()) {
    fail("Couldn't delete test files");
  }
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:29,代码来源:OBJWriterTest.java

示例4: createBox

import com.sun.j3d.utils.geometry.Box; //导入依赖的package包/类
private Box createBox() {
    // ��
    Appearance app = new Appearance();
    Material mat = new Material();
    mat.setAmbientColor(new Color3f(0.0f, 0.0f, 1.0f));
    mat.setSpecularColor(new Color3f(1.0f, 1.0f, 1.0f));
    app.setMaterial(mat);

    // �����ɂ���
    TransparencyAttributes transAttr = new TransparencyAttributes(
            TransparencyAttributes.BLENDED, 0.5f);
    app.setTransparencyAttributes(transAttr);

    Box box = new Box(0.5f, 0.5f, 0.5f, app);

    return box;
}
 
开发者ID:aidiary,项目名称:javagame,代码行数:18,代码来源:Main.java

示例5: Floor

import com.sun.j3d.utils.geometry.Box; //导入依赖的package包/类
public Floor() {
    floorBG = new BranchGroup();

    Appearance app = new Appearance();
    
    // ��
    Material mat = new Material();
    mat.setAmbientColor(new Color3f(1.0f, 1.0f, 0.0f));  // ���F
    mat.setSpecularColor(new Color3f(1.0f, 1.0f, 1.0f));
    app.setMaterial(mat);

    // �����쐬
    Box floor = new Box(10.0f, 0.001f, 10.0f, app);

    floorBG.addChild(floor);
}
 
开发者ID:aidiary,项目名称:javagame,代码行数:17,代码来源:Floor.java

示例6: getModelBox

import com.sun.j3d.utils.geometry.Box; //导入依赖的package包/类
/**
 * Returns a box that may replace model. 
 */
private Node getModelBox(Color color)
{
	Material material = new Material();
	material.setDiffuseColor(new Color3f(color));
	material.setAmbientColor(new Color3f(color.darker()));
	
	Appearance boxAppearance = new Appearance();
	boxAppearance.setMaterial(material);
	return new Box(0.5f, 0.5f, 0.5f, boxAppearance);
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:14,代码来源:HomePieceOfFurniture3D.java

示例7: getCubeAsBox

import com.sun.j3d.utils.geometry.Box; //导入依赖的package包/类
public TransformGroup getCubeAsBox(float x, float y, float z) {
    Transform3D translate = new Transform3D();
    translate.set(new Vector3f(x + 0.5f * cubeLength, y + 0.5f * cubeWidth, z + 0.5f * cubeHeight));
    TransformGroup translateBox = new TransformGroup(translate);

    Box cube = new Box(0.5f * cubeLength, 0.5f * cubeWidth, 0.5f * cubeHeight, cubeAppearance);
    translateBox.addChild(cube);
    return translateBox;
}
 
开发者ID:NeuroBox3D,项目名称:NeuGen,代码行数:10,代码来源:Cube3dCreator.java

示例8: showDebugBox

import com.sun.j3d.utils.geometry.Box; //导入依赖的package包/类
/**
 * Zeichnet eine Box zu Debug-Zwecken, indem sie zu TestBG hinzugefuegt wird
 * @param x Groesse in X-Richtung
 * @param y Groesse in Y-Richtung
 * @param z Groesse in Z-Richtung
 * @param transform Transformation, die auf die Box angewendet werden soll
 * @param angle Winkel, um den die Box gedreht werden soll
 */
public void showDebugBox(final double x, final double y, final double z, Transform3D transform, double angle) {
	final Box box = new Box((float) x, (float) y, (float) z, null);
	transform.setRotation(new AxisAngle4d(0, 0, 1, angle));
	TransformGroup tg = new TransformGroup();
	tg.setTransform(transform);
	tg.addChild(box);
	BranchGroup bg = new BranchGroup();
	bg.setCapability(BranchGroup.ALLOW_DETACH);
	bg.addChild(tg);
	testBG.addChild(bg);
}
 
开发者ID:tsandmann,项目名称:ct-sim,代码行数:20,代码来源:ThreeDBot.java

示例9: buildScene

import com.sun.j3d.utils.geometry.Box; //导入依赖的package包/类
@Override
void buildScene(TransformGroup transformGroup) throws Exception {
    transformGroup.addChild(new Box(0.7f, 0.5f, 0.5f, Box.GENERATE_TEXTURE_COORDS | Box.GENERATE_NORMALS, getTextureAppearance("/sky.jpg")));
}
 
开发者ID:tekrei,项目名称:JavaExamples,代码行数:5,代码来源:TexturedBox.java

示例10: addKinectShape

import com.sun.j3d.utils.geometry.Box; //导入依赖的package包/类
public void addKinectShape() {
	// create an appearance
	Appearance ap = new Appearance();

	// render as a wireframe
	PolygonAttributes polyAttrbutes = new PolygonAttributes();
	polyAttrbutes.setPolygonMode(PolygonAttributes.POLYGON_LINE);
	polyAttrbutes.setCullFace(PolygonAttributes.CULL_NONE);
	ap.setPolygonAttributes(polyAttrbutes);

	Box kinect = new Box(0.6f, 0.1f, 0.2f, ap);

	// scale and move start position to (-4,0,0) // change later
	TransformGroup posnTG = new TransformGroup();
	Transform3D t3d = new Transform3D();
	// t3d.setScale(0.5);
	t3d.setTranslation(new Vector3d(0f, 2.4f, 6.0f));
	posnTG.setTransform(t3d);
	posnTG.addChild(kinect);

	Color3f red = new Color3f(1.0f, 0.0f, 0.0f);

	// line pattern dot-dash
	ColoringAttributes ca = new ColoringAttributes(red, ColoringAttributes.NICEST);
	Point3f[] dotDashPts = new Point3f[2];
	dotDashPts[0] = new Point3f(0.0f, 0.0f, 0.0f);
	dotDashPts[1] = new Point3f(4.9f, 4.7f, -5.0f);
	LineArray dotDash = new LineArray(2, GeometryArray.COORDINATES);
	dotDash.setCoordinates(0, dotDashPts);
	LineAttributes dotDashLa = new LineAttributes();
	dotDashLa.setLineWidth(4.0f);
	dotDashLa.setLinePattern(LineAttributes.PATTERN_DASH);
	Appearance dotDashApp = new Appearance();
	dotDashApp.setLineAttributes(dotDashLa);
	dotDashApp.setColoringAttributes(ca);
	Shape3D dotDashShape = new Shape3D(dotDash, dotDashApp);
	posnTG.addChild(dotDashShape);

	// Shape3D pyramid = createPyramid();
	// posnTG.addChild(pyramid);

	sceneBG.addChild(posnTG);
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:44,代码来源:Points3DPanel.java

示例11: Histogram3D

import com.sun.j3d.utils.geometry.Box; //导入依赖的package包/类
public Histogram3D(int nProton, int nNeutron, float nFactor, int nTimeStep)
   {
   float shiftX, shiftY, shiftZ, maxZ;
   float fillScaleFactor;
   normalizationFactor = nFactor;
   timeIndex = 0;
   
   // Initialization
   abundance = new float[nTimeStep];
   protonNumber = nProton;
   neutronNumber = nNeutron;
   
   
   // Shift the histogram in Y axes so that it's below the surface initially
   shiftY = -normalizationFactor;
   
   // Scaling factor for the filling so that it does not overlap with border
   fillScaleFactor = 0.01f;
   
   // Calculate the position based on neutron and proton number
   shiftX = (float)nNeutron;
   shiftZ = -(float)nProton;
   
   
   // Create Border Box
   
   ColoringAttributes ca = new ColoringAttributes();
   ca.setColor(white);
   PolygonAttributes pa = new PolygonAttributes();
   pa.setPolygonMode(PolygonAttributes.POLYGON_LINE);
   LineAttributes la = new LineAttributes();
   la.setLineWidth(1.0f);
   
   borderAppearance = new Appearance();
   borderAppearance.setColoringAttributes(ca);
   borderAppearance.setPolygonAttributes(pa);
   borderAppearance.setLineAttributes(la);
   
   BoxFrame borderBoxFrame = new BoxFrame(0.5f, normalizationFactor, 0.5f);
   border = new Shape3D(borderBoxFrame, borderAppearance); 
   
   
   // Now Create Filled Box
   ColoringAttributes ca2 = new ColoringAttributes();
   ca2.setCapability(ColoringAttributes.ALLOW_COLOR_WRITE);
   ca2.setCapability(ColoringAttributes.ALLOW_COLOR_READ);
   ca2.setColor(red);
   
   fillingAppearance = new Appearance();
   fillingAppearance.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
   fillingAppearance.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ);
   fillingAppearance.setColoringAttributes(ca2);

// ni's input for transparency
  TransparencyAttributes ta = new TransparencyAttributes();
  ta.setTransparency (0.1f);
  ta.setTransparencyMode(TransparencyAttributes.NICEST);
  fillingAppearance.setTransparencyAttributes(ta);
   //
   filling  = new Box(0.5f-fillScaleFactor, normalizationFactor-fillScaleFactor, 
                             0.5f-fillScaleFactor, fillingAppearance);
   
   Transform3D shiftT3 = new Transform3D();
   Vector3d shiftVector = new Vector3d(shiftX, shiftY, shiftZ);
   shiftT3.set(shiftVector);
   
   tg = new TransformGroup(shiftT3);
   tg.addChild(filling);
   tg.addChild(border);
   }
 
开发者ID:jayjaybillings,项目名称:fern,代码行数:71,代码来源:Histogram3D.java

示例12: addKinectShape

import com.sun.j3d.utils.geometry.Box; //导入依赖的package包/类
public void addKinectShape() {
  // create an appearance
  Appearance ap = new Appearance();

  // render as a wireframe
  PolygonAttributes polyAttrbutes = new PolygonAttributes();
  polyAttrbutes.setPolygonMode(PolygonAttributes.POLYGON_LINE);
  polyAttrbutes.setCullFace(PolygonAttributes.CULL_NONE);
  ap.setPolygonAttributes(polyAttrbutes);

  Box kinect = new Box(0.6f, 0.1f, 0.2f, ap);

  // scale and move start position to (-4,0,0) // change later
  TransformGroup posnTG = new TransformGroup();
  Transform3D t3d = new Transform3D();
  // t3d.setScale(0.5);
  t3d.setTranslation(new Vector3d(0f, 2.4f, 6.0f));
  posnTG.setTransform(t3d);
  posnTG.addChild(kinect);

  Color3f red = new Color3f(1.0f, 0.0f, 0.0f);

  // line pattern dot-dash
  ColoringAttributes ca = new ColoringAttributes(red, ColoringAttributes.NICEST);
  Point3f[] dotDashPts = new Point3f[2];
  dotDashPts[0] = new Point3f(0.0f, 0.0f, 0.0f);
  dotDashPts[1] = new Point3f(4.9f, 4.7f, -5.0f);
  LineArray dotDash = new LineArray(2, GeometryArray.COORDINATES);
  dotDash.setCoordinates(0, dotDashPts);
  LineAttributes dotDashLa = new LineAttributes();
  dotDashLa.setLineWidth(4.0f);
  dotDashLa.setLinePattern(LineAttributes.PATTERN_DASH);
  Appearance dotDashApp = new Appearance();
  dotDashApp.setLineAttributes(dotDashLa);
  dotDashApp.setColoringAttributes(ca);
  Shape3D dotDashShape = new Shape3D(dotDash, dotDashApp);
  posnTG.addChild(dotDashShape);

  // Shape3D pyramid = createPyramid();
  // posnTG.addChild(pyramid);

  sceneBG.addChild(posnTG);
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:44,代码来源:Points3DPanel.java

示例13: createWholeFloor

import com.sun.j3d.utils.geometry.Box; //导入依赖的package包/类
/**
 * Erzeugt einen Fussboden aus einem Stueck Alle Postionen sind keine
 * Weltkoordinaten, sondern ganzen Einheiten, wie sie aus dem ASCII-File
 * kommen
 * 
 * @param app
 *            Aussehen des Bodens
 */
private void createWholeFloor(Appearance app) {
	Box box = new Box(parcours.getWidthInBlocks() * parcours.getBlockSizeInM() * 0.5f,
		parcours.getHeightInBlocks() * parcours.getBlockSizeInM() * 0.5f, World.PLAYGROUND_THICKNESS, app);
	parcours.addFloor(box, ((float) parcours.getWidthInBlocks()) / 2, ((float) parcours.getHeightInBlocks()) / 2,
		- World.PLAYGROUND_THICKNESS - 0.005f);
}
 
开发者ID:tsandmann,项目名称:ct-sim,代码行数:15,代码来源:ParcoursLoader.java

示例14: createWall

import com.sun.j3d.utils.geometry.Box; //导入依赖的package包/类
/**
 * Erzeugt ein Wandsegment Alle Postionen sind keine Weltkoordinaten,
 * sondern ganzen Einheiten, wie sie aus dem ASCII-File kommen
 * 
 * @param x
 *            Position in X-Richtung
 * @param y
 *            Position in X-Richtung
 * @param lengthX
 *            Laenge der Wand in X-Richtung
 * @param lengthY
 *            Laenge der Wand in Y-Richtung
 * @param appearance
 *            Die Appearance
 */
private void createWall(int x, int y, int lengthX, int lengthY, Appearance appearance) {
	Box box = new Box(parcours.getBlockSizeInM() / 2 * lengthX, parcours.getBlockSizeInM() / 2 * lengthY, WALL_HEIGHT, appearance);
	parcours.addObstacle(box, x + lengthX / 2.0f, y + lengthY / 2.0f);
}
 
开发者ID:tsandmann,项目名称:ct-sim,代码行数:20,代码来源:ParcoursLoader.java

示例15: createFloor

import com.sun.j3d.utils.geometry.Box; //导入依赖的package包/类
/**
 * Erzeugt ein Stueck Fussboden Alle Postionen sind keine Weltkoordinaten,
 * sondern ganzen Einheiten, wie sie aus dem ASCII-File kommen
 * 
 * @param x
 *            Position in X-Richtung
 * @param y
 *            Position in X-Richtung
 * @param lengthX
 *            Laenge der Flaeche in X-Richtung
 * @param lengthY
 *            Laenge der Flaeche in Y-Richtung
 * @param app
 *            Aussehen des Bodens
 */
@SuppressWarnings("unused")
private void createFloor(int x, int y, int lengthX, int lengthY, Appearance app) {
	Box box = new Box(parcours.getBlockSizeInM() / 2 * lengthX, parcours.getBlockSizeInM() / 2 * lengthY, World.PLAYGROUND_THICKNESS, app);
	parcours.addFloor(box, x + lengthX / 2.0f, y + lengthY / 2.0f, - World.PLAYGROUND_THICKNESS + 0.001f);
}
 
开发者ID:tsandmann,项目名称:ct-sim,代码行数:21,代码来源:ParcoursLoader.java


注:本文中的com.sun.j3d.utils.geometry.Box类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。