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


Java TransformGroup.addChild方法代码示例

本文整理汇总了Java中javax.media.j3d.TransformGroup.addChild方法的典型用法代码示例。如果您正苦于以下问题:Java TransformGroup.addChild方法的具体用法?Java TransformGroup.addChild怎么用?Java TransformGroup.addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.media.j3d.TransformGroup的用法示例。


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

示例1: buildScene

import javax.media.j3d.TransformGroup; //导入方法依赖的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: createCompass

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
public static Group createCompass() {
  Appearance ap = Compass.generateAppearance(Color.pink, 0.5, true);
  Cone c = new Cone(1f, 5f, ap);

  Transform3D tf = new Transform3D();
  tf.rotX(Math.PI / 2);

  Transform3D tf1 = new Transform3D();
  tf1.setTranslation(new Vector3d(10, 15, -40));

  TransformGroup tg = new TransformGroup(tf);
  tg.addChild(c);

  TransformGroup tg2 = new TransformGroup(tf1);
  tg2.addChild(tg);

  return tg2;
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:19,代码来源:Compass.java

示例3: testOBJWriter

import javax.media.j3d.TransformGroup; //导入方法依赖的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: addNode

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
 * Fuegt eine Node ein
 * 
 * @param node
 *            Die Node
 * @param x
 *            X-Koordinate
 * @param y
 *            Y-Koordinate
 * @param z
 *            Z-Achse absolut; positiv ist vom Boden Richtung Bot +
 *            Betrachter, negativ vom Boden weg vom Betrachter
 * @param bg
 *            BranchGropu, in die das Objekt rein soll
 */
public void addNode(Node node, float x, float y, float z, BranchGroup bg) {
	Transform3D translate = new Transform3D();

	translate.set(new Vector3d(x, y, z));

	TransformGroup tg = new TransformGroup(translate);
	tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
	tg.addChild(node);
	
	TransformGroup tgObject = new TransformGroup();
	tgObject.addChild(tg);
	tgObject.setCapability(Node.ENABLE_PICK_REPORTING);
	tgObject.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
	tgObject.setPickable(true);
	bg.addChild(tgObject);
}
 
开发者ID:tsandmann,项目名称:ct-sim,代码行数:32,代码来源:Parcours.java

示例5: setParcours

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
 * Erzeugt einen Szenegraphen mit Boden und Grenzen der Roboterwelt
 * @param parc Der Parcours
 */
private void setParcours(Parcours parc) {
	parcours = parc;
	// Hindernisse werden an die richtige Position geschoben

	// Zuerst werden sie gemeinsam so verschoben, dass ihre Unterkante genau
	// buendig mit der Unterkante des Bodens ist:
	Transform3D translate = new Transform3D();
	translate.set(new Vector3d(0d, 0d, 0.2d - PLAYGROUND_THICKNESS));
	TransformGroup obstTG = new TransformGroup(translate);
	obstTG.setCapability(Node.ENABLE_PICK_REPORTING);
	obstTG.setPickable(true);
	obstBG.addChild(obstTG);

    obstTG.addChild(parc.getObstBG());
    lightBG.addChild(parc.getLightBG());
    bpsBG.addChild(parc.getBpsBG());
    terrainBG.addChild(parc.getTerrainBG());

    obstBG.setCapability(Node.ENABLE_PICK_REPORTING);
    obstBG.setCapability(Node.ALLOW_PICKABLE_READ);
}
 
开发者ID:tsandmann,项目名称:ct-sim,代码行数:26,代码来源:World.java

示例6: initView

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
private static BranchGroup initView( View view, TransformGroup trans, Canvas3D canvas )
{
    ViewPlatform vp = new ViewPlatform();
    trans .setCapability( TransformGroup .ALLOW_TRANSFORM_WRITE );
    BranchGroup bg = new BranchGroup();
    bg .addChild( trans );
    trans .addChild( vp );
    view .addCanvas3D( canvas );
    view .setPhysicalBody( new PhysicalBody() );
    view .setPhysicalEnvironment( new PhysicalEnvironment() );
    view .attachViewPlatform( vp );
    view .setFrontClipPolicy( View.VIRTUAL_EYE );
    view .setBackClipPolicy( View.VIRTUAL_EYE );
    view .setScreenScalePolicy( View .SCALE_EXPLICIT );
    return bg;
}
 
开发者ID:vZome,项目名称:vzome-desktop,代码行数:17,代码来源:Java3dRenderingViewer.java

示例7: setLightingRecon

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
private void setLightingRecon(TransformGroup objMove) {
    // Set up the ambient light
    Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
    AmbientLight ambientLightNode = new AmbientLight(ambientColor);
    ambientLightNode.setInfluencingBounds(bounds);
    objMove.addChild(ambientLightNode);

    // Set up the directional lights
    Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f);
    Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f);

    //light1Direction.scale(scale * 10.0f);
    Color3f light2Color = new Color3f(1.0f, 1.0f, 1.0f);
    Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
    //light2Direction.scale(scale * 10.0f);

    DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
    light1.setInfluencingBounds(bounds);
    objMove.addChild(light1);

    DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction);
    light2.setInfluencingBounds(bounds);
    objMove.addChild(light2);
}
 
开发者ID:NeuroBox3D,项目名称:NeuGen,代码行数:25,代码来源:NeuGenVisualization.java

示例8: createSceneGraph

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
 * Creates a scene graph for the 3D model, translates the model on the
 * y-axis by {@code MODEL_Y_POSITION} and sets the rotation.
 * 
 * @return a BranchGroup for the 3D model.
 */
private BranchGroup createSceneGraph() {
	BranchGroup objRoot = new BranchGroup();
	TransformGroup objTrans = new TransformGroup();
	objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
	objRoot.addChild(objTrans);
	// Move the shape down on the y-axis
	TransformGroup moveDownGroup = new TransformGroup();
	Transform3D moveDownTrans = new Transform3D();
	moveDownTrans.setTranslation(new Vector3f(0, MODEL_Y_POSITION, 0));
	moveDownGroup.setTransform(moveDownTrans);
	objTrans.addChild(moveDownGroup);
	moveDownGroup.addChild(this.shape3d);
	// Rotate the shape
	Transform3D yAxis = new Transform3D();
	Alpha rotationAlpha = new Alpha(-1, ROTATION_ALPHA_DURATION);
	RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0, (float) Math.PI * 2.0f);
	BoundingSphere bounds = new BoundingSphere(new Point3d(0, 0, 0), ROTATOR_SPHERE_RADIUS);
	rotator.setSchedulingBounds(bounds);
	objRoot.addChild(rotator);
	objRoot.compile();
	return objRoot;
}
 
开发者ID:nerdouille,项目名称:silvie,代码行数:29,代码来源:ModelPreviewer.java

示例9: createHeadlight

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
protected void createHeadlight( )
{
	final Color3f lightColor = new Color3f( 0.9f , 0.9f , 0.9f );
	final DirectionalLight light = new DirectionalLight( );
	light.setCapability( Light.ALLOW_STATE_WRITE );
	light.setColor( lightColor );
	
	final BoundingSphere worldBounds = new BoundingSphere( new Point3d( 0.0 , 0.0 , 0.0 ) , 100000.0 ); // Center, Extent
	light.setInfluencingBounds( worldBounds );
	
	m_headlight = light;
	final BranchGroup bg = new BranchGroup( );
	m_lightGroup = new TransformGroup( );
	m_lightGroup.setCapability( TransformGroup.ALLOW_TRANSFORM_WRITE );
	bg.addChild( m_lightGroup );
	m_lightGroup.addChild( m_headlight );
	m_transformGroup.addChild( bg );
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:19,代码来源:Camera3D.java

示例10: createPlaneteTraces

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
 * Called to create ghosts of the body
 * Ghost are the ancien position of a body
 * (slows down the java3D tree creation)
 * @param root where to add these ghost
 * @param i body to be ghosted
 * @param a appearance of the ghosts
 */
private void createPlaneteTraces(BranchGroup root, int i, Appearance a) {
    for (int j = 0; j < (this.MAX_HISTO_SIZE - 1); j++) {
        // Trace Transformation Group
        TransformGroup traceGroup = new TransformGroup();
        traceGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        this.tracesGroup[i][j] = traceGroup;

        // Trace Transformation (place and direction)
        Transform3D traceTransformation = new Transform3D();
        this.tracesTransformation[i][j] = traceTransformation;

        // Cylinder representing a segment
        //Cylinder(float radius, float height, Appearance ap)
        Sphere ghost = new Sphere(0.005f, a);

        //Assembling group
        traceGroup.addChild(ghost);
        //traceGroup.setTransform(traceTransformation);
        root.addChild(traceGroup);
    }
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:30,代码来源:NBody3DFrame.java

示例11: buildScene

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
@Override
void buildScene(TransformGroup transformGroup) {
    transformGroup.addChild(getColorBackground(Color.CYAN));
    transformGroup.addChild(loadObject("/galleon.obj"));
    transformGroup.addChild(getAmbientLight(new Color(1.0f, 1.0f, 0.9f)));
    transformGroup.addChild(getDirectionalLight(new Color(1.0f, 1.0f, 0.9f), new Vector3f(1.0f, 1.0f, 1.0f)));
    transformGroup.addChild(getDirectionalLight(new Color(1.0f, 1.0f, 1.0f), new Vector3f(-1.0f, -1.0f, -1.0f)));
}
 
开发者ID:tekrei,项目名称:JavaExamples,代码行数:9,代码来源:ObjectLoadingExample.java

示例12: addElementAt

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
public static BranchGroup addElementAt(Node aShape, Vector3f aTranslation, float aScale) {

        BranchGroup theGroup = new BranchGroup();
        theGroup.setCapability(BranchGroup.ALLOW_DETACH);

        Transform3D theTransform = new Transform3D();
        theTransform.setTranslation(aTranslation);
        theTransform.setScale(aScale);
        TransformGroup theTransformGroup = new TransformGroup(theTransform);
        theTransformGroup.addChild(aShape);

        theGroup.addChild(theTransformGroup);

        return theGroup;
    }
 
开发者ID:mirkosertic,项目名称:ERDesignerNG,代码行数:16,代码来源:Helper.java

示例13: createUniverse

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
 * Returns a new 3D universe that displays <code>home</code> objects.
 */
private SimpleUniverse createUniverse(boolean displayShadowOnFloor, boolean listenToHomeUpdates,
		boolean waitForLoading)
{
	// Create a universe bound to no canvas 3D
	ViewingPlatform viewingPlatform = new ViewingPlatform();
	// Add an interpolator to view transform to get smooth transition 
	TransformGroup viewPlatformTransform = viewingPlatform.getViewPlatformTransform();
	CameraInterpolator cameraInterpolator = new CameraInterpolator(viewPlatformTransform);
	cameraInterpolator.setSchedulingBounds(new BoundingSphere(new Point3d(), 1E7));
	viewPlatformTransform.addChild(cameraInterpolator);
	viewPlatformTransform.setCapability(TransformGroup.ALLOW_CHILDREN_READ);
	
	Viewer viewer = new Viewer(new Canvas3D[0]);
	SimpleUniverse universe = new SimpleUniverse(viewingPlatform, viewer);
	
	View view = viewer.getView();
	view.setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY);
	
	// Update field of view from current camera
	updateView(view, this.home.getCamera(), this.home.getTopCamera() == this.home.getCamera());
	
	// Update point of view from current camera
	updateViewPlatformTransform(viewPlatformTransform, this.home.getCamera(), false);
	
	// Add camera listeners to update later point of view from camera
	if (listenToHomeUpdates)
	{
		addCameraListeners(view, viewPlatformTransform);
	}
	
	// Link scene matching home to universe
	universe.addBranchGraph(createSceneTree(displayShadowOnFloor, listenToHomeUpdates, waitForLoading));
	
	return universe;
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:39,代码来源:HomeComponent3D.java

示例14: setBackFaceShown

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
 * Sets the back face visibility of the children nodes of the displayed 3D model.
 */
protected void setBackFaceShown(boolean backFaceShown)
{
	if (this.previewedPiece != null)
	{
		// Create a new piece from the existing one with an updated backFaceShown flag 
		this.previewedPiece = new HomePieceOfFurniture(new CatalogPieceOfFurniture(null, null,
				this.previewedPiece.getModel(), this.previewedPiece.getWidth(), this.previewedPiece.getDepth(),
				this.previewedPiece.getHeight(), 0, false, this.previewedPiece.getColor(),
				this.previewedPiece.getModelRotation(), backFaceShown, 0, false));
		this.previewedPiece.setX(0);
		this.previewedPiece.setY(0);
		this.previewedPiece.setElevation(-previewedPiece.getHeight() / 2);
		
		TransformGroup modelTransformGroup = (TransformGroup) this.sceneTree.getChild(0);
		HomePieceOfFurniture3D piece3D = new HomePieceOfFurniture3D(previewedPiece, null, true, true);
		if (OperatingSystem.isMacOSX())
		{
			this.pieceTextures.clear();
			cloneTextures(piece3D, this.pieceTextures);
		}
		modelTransformGroup.addChild(piece3D);
		if (modelTransformGroup.numChildren() > 1)
		{
			modelTransformGroup.removeChild(0);
		}
	}
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:31,代码来源:ModelPreviewComponent.java

示例15: createPillar

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
	 * Erzeugt eine Saeule, auch mit Lichtquelle obendrauf moeglich
	 * 
	 * @param x			X-Koordinate (bewegliches Objekt) oder X-Achse im Parcours (unbewegliches Objekt)
	 * @param y			Y-Koordinate (bewegliches Objekt) oder Y-Achse im Parcours (unbewegliches Objekt)
	 * @param diameter	Durchmesser der Saeule
	 * @param height	Hoehe der Saeule
	 * @param bodyAppearance	Saeulen-Appearance
	 * @param lightAppearance	Licht-Appearance oder null
	 * @param moveable			Soll das Objekt bewegbar sein?
	 */
	private void createPillar(float x, float y, float diameter, float height, Appearance bodyAppearance, Appearance lightAppearance, boolean moveable) {
		Cylinder pillar = new Cylinder(diameter / 2.0f, height, bodyAppearance);
//		pillar.setName("Object");
		pillar.setCapability(javax.media.j3d.Node.ALLOW_PICKABLE_WRITE);
		
		TransformGroup tg = new TransformGroup();
		tg.addChild(pillar);
		
		Transform3D translate = new Transform3D();
		
		/* Drehen auf vertikal */
		Transform3D rot = new Transform3D();
		rot.rotX(0.5 * Math.PI);
		translate.mul(rot);
		
		/* unteres Ende auf Fussboden "hochschieben" */
		translate.setTranslation(new Vector3f(0, 0, + height / 2.0f - 0.2f));
		tg.setTransform(translate);
		
		if (moveable) {
			parcours.addMoveableObstacle(tg, x, y);
		} else {
			parcours.addObstacle(tg, x + 0.5f, y + 0.5f);
		}
		if (lightAppearance != null) {
			createLight(new BoundingSphere(new Point3d(0d, 0d, 0d), 10d), new Color3f(1.0f, 1.0f, 0.9f), (int) x, (int) y, lightAppearance);
		}
	}
 
开发者ID:tsandmann,项目名称:ct-sim,代码行数:40,代码来源:ParcoursLoader.java


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