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


Java TransformGroup.setTransform方法代码示例

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


在下文中一共展示了TransformGroup.setTransform方法的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: updateViewPlatformTransform

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
 * Updates <code>viewPlatformTransform</code> transform from <code>camera</code> angles and location.
 */
private void updateViewPlatformTransform(TransformGroup viewPlatformTransform, Camera camera,
		boolean updateWithAnimation)
{
	if (updateWithAnimation)
	{
		// Get the camera interpolator
		CameraInterpolator cameraInterpolator = (CameraInterpolator) viewPlatformTransform
				.getChild(viewPlatformTransform.numChildren() - 1);
		cameraInterpolator.moveCamera(camera);
	}
	else
	{
		Transform3D transform = new Transform3D();
		updateViewPlatformTransform(transform, camera.getX(), camera.getY(), camera.getZ(), camera.getYaw(),
				camera.getPitch());
		viewPlatformTransform.setTransform(transform);
	}
	clearPrintedImageCache();
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:23,代码来源:HomeComponent3D.java

示例3: updateViewPlatformTransform

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
 * Updates the given view platform transformation from yaw angle, pitch angle and scale. 
 */
private void updateViewPlatformTransform(TransformGroup viewPlatformTransform, float viewYaw, float viewPitch,
		float viewScale)
{
	// Default distance used to view a 2 unit wide scene
	double nominalDistanceToCenter = 1.4 / Math.tan(Math.PI / 8);
	// We don't use a TransformGroup in scene tree to be able to share the same scene 
	// in the different views displayed by OrientationPreviewComponent class 
	Transform3D translation = new Transform3D();
	translation.setTranslation(new Vector3d(0, 0, nominalDistanceToCenter));
	Transform3D pitchRotation = new Transform3D();
	pitchRotation.rotX(viewPitch);
	Transform3D yawRotation = new Transform3D();
	yawRotation.rotY(viewYaw);
	Transform3D scale = new Transform3D();
	scale.setScale(viewScale);
	
	pitchRotation.mul(translation);
	yawRotation.mul(pitchRotation);
	scale.mul(yawRotation);
	viewPlatformTransform.setTransform(scale);
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:25,代码来源:ModelPreviewComponent.java

示例4: initPerspective

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
 * Position: X/Y: zentriert, Z: so, dass der Parcours
 * vollstaendig im Blick ist
 * @param w Welt
 */
private void initPerspective(World w) {
	double centerX = w.getWidthInM() / 2;
	double centerY = w.getHeightInM() / 2;
	double longerSide = Math.max(
		w.getWidthInM(), w.getHeightInM());
	// Winkel im Bogenmass
	double field = universe.getViewer().getView().getFieldOfView();

	Transform3D targetTfm = new Transform3D();
	TransformGroup tg =
		universe.getViewingPlatform().getViewPlatformTransform();

	tg.getTransform(targetTfm);
	targetTfm.setTranslation(new Vector3d(centerX, centerY,
		(longerSide/2) / Math.tan(field/2)));
	tg.setTransform(targetTfm);
}
 
开发者ID:tsandmann,项目名称:ct-sim,代码行数:23,代码来源:WorldViewer.java

示例5: 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

示例6: doPreview

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
@Override
public void doPreview() {
	GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
	Canvas3D canvas = new Canvas3D(config);
	canvas.setPreferredSize(new Dimension(CANVAS_PREFERRED_WIDTH, CANVAS_PREFERRED_HEIGHT));
	BranchGroup scene = createSceneGraph();
	this.universe = new SimpleUniverse(canvas);
	// Move the camera back on the z-axis
	Transform3D cameraTransform = new Transform3D();
	TransformGroup viewPlatformGroup = this.universe.getViewingPlatform().getViewPlatformTransform();
	cameraTransform.setTranslation(new Vector3f(0, 0, CAMERA_Z_POSITION));
	viewPlatformGroup.setTransform(cameraTransform);
	// Necessary to see the whole model
	this.universe.getViewer().getView().setBackClipDistance(BACK_CLIP_DISTANCE);
	this.universe.addBranchGraph(scene);
	super.preview.setCanvas(canvas, true);
}
 
开发者ID:nerdouille,项目名称:silvie,代码行数:18,代码来源:ModelPreviewer.java

示例7: initUserPosition

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
 * ���[�U�̎��_��������
 */
private void initUserPosition() {
    ViewingPlatform vp = universe.getViewingPlatform(); // SimpleUniverse�̃f�t�H���g���擾
    TransformGroup steerTG = vp.getViewPlatformTransform(); // vp��TG���擾

    Transform3D t3d = new Transform3D(); // ���_�ivp�j�ړ��p��T3D
    steerTG.getTransform(t3d); // ���݂̎��_���擾

    // �V�������_��ݒ�
    // ���[�U�̈ʒu�A������̍��W�A�������w��
    // ���_�̐�͌��_
    t3d.lookAt(USER_POS, new Point3d(0, 0, 0), new Vector3d(0, 1, 0));
    t3d.invert();

    steerTG.setTransform(t3d); // �ύX�������_��ݒ�
}
 
开发者ID:aidiary,项目名称:javagame,代码行数:19,代码来源:MainPanel.java

示例8: mulTransformGroup

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
 * Multiplies the transform at top of the transform groups stack by the 
 * given <code>transformMultiplier</code>.
 */
private void mulTransformGroup(Transform3D transformMultiplier)
{
	TransformGroup transformGroup = (TransformGroup) this.parentGroups.peek();
	Transform3D transform = new Transform3D();
	transformGroup.getTransform(transform);
	transform.mul(transformMultiplier);
	transformGroup.setTransform(transform);
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:13,代码来源:DAELoader.java

示例9: setModelRotation

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
 * Updates the rotation of the 3D model displayed by this component. 
 * The model is shown at its default size.
 */
protected void setModelRotation(float[][] modelRotation)
{
	BranchGroup modelNode = getModelNode();
	if (modelNode != null && modelNode.numChildren() > 0)
	{
		// Check rotation isn't set on model node 
		if (this.internalRotationAndSize)
		{
			throw new IllegalStateException("Can't set rotation");
		}
		// Apply model rotation
		Transform3D rotationTransform = new Transform3D();
		if (modelRotation != null)
		{
			Matrix3f modelRotationMatrix = new Matrix3f(modelRotation[0][0], modelRotation[0][1],
					modelRotation[0][2], modelRotation[1][0], modelRotation[1][1], modelRotation[1][2],
					modelRotation[2][0], modelRotation[2][1], modelRotation[2][2]);
			rotationTransform.setRotation(modelRotationMatrix);
		}
		// Scale model to make it fit in a 1.8 unit wide box      
		Transform3D modelTransform = new Transform3D();
		Vector3f size = ModelManager.getInstance().getSize(modelNode);
		modelTransform.setScale(1.8 / Math.max(Math.max(size.x, size.z), size.y));
		modelTransform.mul(rotationTransform);
		
		TransformGroup modelTransformGroup = (TransformGroup) this.sceneTree.getChild(0);
		modelTransformGroup.setTransform(modelTransform);
	}
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:34,代码来源:ModelPreviewComponent.java

示例10: setModelRotationAndSize

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
 * Updates the rotation and the size of the 3D model displayed by this component. 
 */
protected void setModelRotationAndSize(float[][] modelRotation, float width, float depth, float height)
{
	BranchGroup modelNode = getModelNode();
	if (modelNode != null && modelNode.numChildren() > 0)
	{
		// Check rotation isn't set on model node
		if (this.internalRotationAndSize)
		{
			throw new IllegalStateException("Can't set rotation and size");
		}
		Transform3D normalization = ModelManager.getInstance().getNormalizedTransform(modelNode, modelRotation, 1f);
		// Scale model to its size
		Transform3D scaleTransform = new Transform3D();
		if (width != 0 && depth != 0 && height != 0)
		{
			scaleTransform.setScale(new Vector3d(width, height, depth));
		}
		scaleTransform.mul(normalization);
		// Scale model to make it fit in a 1.8 unit wide box      
		Transform3D modelTransform = new Transform3D();
		if (width != 0 && depth != 0 && height != 0)
		{
			modelTransform.setScale(1.8 / Math.max(Math.max(width, height), depth));
		}
		else
		{
			Vector3f size = ModelManager.getInstance().getSize(modelNode);
			modelTransform.setScale(1.8 / Math.max(Math.max(size.x, size.z), size.y));
		}
		modelTransform.mul(scaleTransform);
		
		TransformGroup modelTransformGroup = (TransformGroup) this.sceneTree.getChild(0);
		modelTransformGroup.setTransform(modelTransform);
	}
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:39,代码来源:ModelPreviewComponent.java

示例11: addPointsShape

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
 * This is the only method different from the Checkers3D example in Chapter
 * 15 of "Killer Game Programming in Java"
 * (http://fivedots.coe.psu.ac.th/~ad/jg/ch8/).
 * 
 * All the hard work is done inside the PointsShape object. The transform
 * group is used to position (and perhaps scale) the points cloud.
 */
private void addPointsShape(PointsShape ptsShape) {
	// 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(-3.2f, 2.4f, 0.0f));// 6.40 / 2
	t3d.setTranslation(new Vector3d(0f, 0f, 0.0f));// 6.40 / 2
	posnTG.setTransform(t3d);
	posnTG.addChild(ptsShape);
	sceneBG.addChild(posnTG);
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:20,代码来源:Points3DPanel.java

示例12: initUserPosition

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
private void initUserPosition()
// Set the user's initial viewpoint using lookAt()
{
	ViewingPlatform vp = su.getViewingPlatform();
	TransformGroup steerTG = vp.getViewPlatformTransform();

	Transform3D t3d = new Transform3D();
	steerTG.getTransform(t3d);

	// args are: viewer posn, where looking, up direction
	t3d.lookAt(USERPOSN, new Point3d(0, 0, 0), new Vector3d(0, 1, 0));
	t3d.invert();

	steerTG.setTransform(t3d);
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:16,代码来源:Points3DPanel.java

示例13: makeText

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
private TransformGroup makeText(Vector3d vertex, String text) {
	Text2D message = new Text2D(text, white, "SansSerif", 36, Font.BOLD);
	// 36 point bold Sans Serif

	TransformGroup tg = new TransformGroup();
	Transform3D t3d = new Transform3D();
	t3d.setTranslation(vertex);
	tg.setTransform(t3d);
	tg.addChild(message);
	return tg;
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:12,代码来源:CheckerFloor.java

示例14: addLight

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
/**
 * Add a light to the 3d world. Used only in the creation phase.
 */
Light addLight(Vector3d pos, Color3f color) {
	BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), worldSize * 2);

	TransformGroup tg = new TransformGroup();
	Transform3D t3d = new Transform3D();
	t3d.set(pos);
	tg.setTransform(t3d);
	PointLight light = new PointLight();
	light.setAttenuation(0.5f, 0, 0);
	// light.setAttenuation(0f,.08f,0);
	// light.setAttenuation(1.2f,0,0);
	// note : light pos not affected by transform (but bound is).
	light.setPosition((float) pos.x, (float) pos.y, (float) pos.z);
	light.setInfluencingBounds(bounds);
	sceneTrans.addChild(light);
	// light geometry
	ColoringAttributes ca = new ColoringAttributes();
	ca.setColor(color);
	Appearance appL1 = new Appearance();
	appL1.setColoringAttributes(ca);
	Primitive s = new Sphere(0.4f, appL1);
	s.setCollidable(true);
	tg.addChild(s);
	sceneTrans.addChild(tg);
	return light;
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:30,代码来源:World.java

示例15: setViewPosition

import javax.media.j3d.TransformGroup; //导入方法依赖的package包/类
public void setViewPosition(Vector3f mov, int angle) {
    TransformGroup tg = this.simpleUniverse.getViewingPlatform().
            getViewPlatformTransform();
    Transform3D t3dTrans = new Transform3D();
    tg.getTransform(t3dTrans);
    t3dTrans.setTranslation(mov);
    tg.setTransform(t3dTrans);

    Transform3D t3dRot = new Transform3D();
    tg.getTransform(t3dRot);
    t3dRot.setRotation(
            new AxisAngle4f(1f, 0f, 0f, (float) Math.toRadians(angle)));
    //ViewT3D.setRotation(new AxisAngle4f(0, 0, 1, (float) Math.toRadians(45)));
    tg.setTransform(t3dRot);
}
 
开发者ID:NeuroBox3D,项目名称:NeuGen,代码行数:16,代码来源:VRLDensityVisualization.java


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