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


Java Transform3D.mul方法代码示例

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


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

示例1: updateViewPlatformTransform

import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
 * Updates <code>viewPlatformTransform</code> transform from camera angles and location.
 */
private void updateViewPlatformTransform(Transform3D transform, float cameraX, float cameraY, float cameraZ,
		float cameraYaw, float cameraPitch)
{
	Transform3D yawRotation = new Transform3D();
	yawRotation.rotY(-cameraYaw + Math.PI);
	
	Transform3D pitchRotation = new Transform3D();
	pitchRotation.rotX(-cameraPitch);
	yawRotation.mul(pitchRotation);
	
	transform.setIdentity();
	transform.setTranslation(new Vector3f(cameraX, cameraZ, cameraY));
	transform.mul(yawRotation);
	
	this.camera = new Camera(cameraX, cameraY, cameraZ, cameraYaw, cameraPitch, 0);
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:20,代码来源:HomeComponent3D.java

示例2: updateViewPlatformTransform

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

示例3: lookupTransform

import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
public Transform lookupTransform(String target_frame, long target_time,
		String source_frame, long source_time, String fixed_frame)
		throws TransformerException {

	validateFrameId("lookupTransform argument target_frame", target_frame);
	validateFrameId("lookupTransform argument source_frame", source_frame);
	validateFrameId("lookupTransform argument fixed_frame", fixed_frame);

	Transform temp1 = lookupTransform(fixed_frame, source_frame,
			source_time);
	Transform temp2 = lookupTransform(target_frame, fixed_frame,
			target_time);

	Transform3D t = new Transform3D();
	t.mul(temp2.getTransform(), temp1.getTransform());

	return new Transform(t, target_frame, source_frame, temp2.getTime());
}
 
开发者ID:leonziegler,项目名称:rct-java,代码行数:19,代码来源:TransformerCoreDefault.java

示例4: getNormalizedTransform

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

示例5: getPieceOFFurnitureNormalizedModelTransformation

import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
 * Returns a transformation able to place in the scene the normalized model 
 * of the given <code>piece</code>.
 */
Transform3D getPieceOFFurnitureNormalizedModelTransformation(HomePieceOfFurniture piece)
{
	// Set piece size
	Transform3D scale = new Transform3D();
	float pieceWidth = piece.getWidth();
	// If piece model is mirrored, inverse its width
	if (piece.isModelMirrored())
	{
		pieceWidth *= -1;
	}
	scale.setScale(new Vector3d(pieceWidth, piece.getHeight(), piece.getDepth()));
	// Change its angle around y axis
	Transform3D orientation = new Transform3D();
	orientation.rotY(-piece.getAngle());
	orientation.mul(scale);
	// Translate it to its location
	Transform3D pieceTransform = new Transform3D();
	float z = piece.getElevation() + piece.getHeight() / 2;
	if (piece.getLevel() != null)
	{
		z += piece.getLevel().getElevation();
	}
	pieceTransform.setTranslation(new Vector3f(piece.getX(), z, piece.getY()));
	pieceTransform.mul(orientation);
	return pieceTransform;
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:31,代码来源:ModelManager.java

示例6: mulTransformGroup

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

示例7: setModelRotation

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

示例8: setModelRotationAndSize

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

示例9: createPillar

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

示例10: createSceneGraph

import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
public BranchGroup createSceneGraph() {
    BranchGroup bg = new BranchGroup();

    // �L���[�u���X����
    Transform3D rotate = new Transform3D();
    Transform3D tempRotate = new Transform3D();

    rotate.rotX(Math.PI / 4.0);
    tempRotate.rotY(Math.PI / 4.0);
    rotate.mul(tempRotate);

    TransformGroup rotateTG = new TransformGroup(rotate);

    // �L���[�u����]����
    TransformGroup spinTG = new TransformGroup();
    spinTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    // �J���[�L���[�u���쐬����spinTG�ɒlj�
    ColorCube cube = new ColorCube(0.4);
    spinTG.addChild(cube);

    // ��]�^��
    Alpha rotationAlpha = new Alpha(-1, 4000);
    RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, spinTG);
    // �͈͂��w��
    BoundingSphere bounds = new BoundingSphere();
    rotator.setSchedulingBounds(bounds);
    spinTG.addChild(rotator);

    rotateTG.addChild(spinTG);
    bg.addChild(rotateTG);

    return bg;
}
 
开发者ID:aidiary,项目名称:javagame,代码行数:34,代码来源:RotatingCube.java

示例11: endDocument

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

示例12: changeViewPoint

import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
 * Change the user view Point . Note that we modify the ViewBranch transform
 * not the scene transform.
 * 
 * @param type
 *            can be VIEW_FROM_TOP,VIEW_FROM_EAST,VIEW_BEHIND_AGENT
 * @param agent
 *            : specify the agent if VIEW_BEHIND_AGENT
 * 
 *            The VIEW_BEHIND_AGENT case has to be called regularly because
 *            of the agent displacement.
 */

public void changeViewPoint(int type, SimpleAgent agent) {
	Point3d p1 = new Point3d();
	Point3d p2 = new Point3d();

	Transform3D t1 = new Transform3D();
	Transform3D t2 = new Transform3D();
	t1.setIdentity();
	t2.setIdentity();
	mouseOrbiter.resetView();
	switch (type) {
	case VIEW_FROM_TOP:
		t1.lookAt(new Point3d(0, worldSize * 1.2, 0), new Point3d(0, 0, 0), new Vector3d(0, 0, -1));
		t1.invert();
		viewTransformGroup.setTransform(t1);
		break;
	case VIEW_FROM_EAST:
		t1.lookAt(new Point3d(worldSize, worldSize, 0), new Point3d(0, 0, 0), new Vector3d(-1, 0, 0));
		t1.invert();
		viewTransformGroup.setTransform(t1);
		break;
	case VIEW_BEHIND_AGENT:
		t1.setTranslation(new Vector3d(-agent.getRadius() * 2, 0, 0));
		agent.getGroup().getLocalToVworld(t2);
		t1.mul(t2);
		viewTransformGroup.setTransform(t1);
		break;
	case VIEW_ABOVE_AGENT:
		agent.getRotationTransformGroup().getLocalToVworld(t1);
		t1.transform(p1);
		t1.transform(p2);
		p2.y = worldSize * .8;
		t1.lookAt(p2, p1, new Vector3d(0, 0, -1));
		t1.invert();
		viewTransformGroup.setTransform(t1);
		break;

	case VIEW_ABOVE_AGENT_NEAR:
		agent.getRotationTransformGroup().getLocalToVworld(t1);
		t1.transform(p1);
		t1.transform(p2);
		p2.y = agent.getHeight() * worldSize * 0.5;
		// avoid front clipping
		if (p2.y < 0.2)
			p2.y = 0.2;
		t1.lookAt(p2, p1, new Vector3d(0, 0, -1));
		t1.invert();
		viewTransformGroup.setTransform(t1);

		break;
	case VIEW_AGENT_SIDE:

		agent.getRotationTransformGroup().getLocalToVworld(t1);
		t1.transform(p1);
		t1.transform(p2);
		agent.rotation.transform(p2);
		t2.setTranslation(new Vector3d(0, agent.getHeight() * 2, agent.getRadius() * 10));
		t2.transform(p2);
		t1.lookAt(p2, p1, new Vector3d(0, 1, 0));
		t1.invert();
		viewTransformGroup.setTransform(t1);

		break;
	}
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:78,代码来源:World.java

示例13: createSceneGraph

import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
private BranchGroup createSceneGraph() {
	BranchGroup objRoot = new BranchGroup();
	
	//Set up node for rotating the surface based on mouse drags
	TransformGroup objTransform = new TransformGroup();
	objTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
	objTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
	
	//Set up node for translating and scaling the surface
	TransformGroup surfaceTranslate = new TransformGroup();
	TransformGroup surfaceScale = new TransformGroup();
	surfaceTranslate.setBoundsAutoCompute(true);
	surfaceScale.setBoundsAutoCompute(true);
	
	surfaceTranslate.addChild(new Surface(_organism, 32, 32));
	BoundingSphere bSphere = new BoundingSphere(surfaceTranslate.getBounds());
	Point3d center = new Point3d();
	bSphere.getCenter(center);
	double radius = bSphere.getRadius();
	
	Matrix3d rotate = new Matrix3d();
	rotate.setIdentity();
	Vector3d translate = new Vector3d(center);
	translate.negate();
	double scale = 1/radius;
	
	surfaceTranslate.setTransform(new Transform3D(rotate,translate,1.0));
	surfaceScale.setTransform(new Transform3D(rotate,new Vector3d(),scale));
	surfaceScale.addChild(surfaceTranslate);
	
	//random rotation
	Transform3D rotX = new Transform3D();
	Transform3D rotY = new Transform3D();
	Transform3D rotZ = new Transform3D();
	rotX.rotX(2*Math.PI*Math.random());
	rotY.rotY(2*Math.PI*Math.random());
	rotZ.rotZ(2*Math.PI*Math.random());
	
	rotX.mul(rotY);
	rotX.mul(rotZ);
	
	TransformGroup randRot = new TransformGroup(rotX);
	randRot.addChild(surfaceScale);
	
	//Add nodes to root tree
	objTransform.addChild(randRot);
	objRoot.addChild(objTransform);
	
	//Set up lights
	DirectionalLight dirLight = 
		new DirectionalLight(new Color3f(.9f,.9f,.9f),new Vector3f(0,0,-1));
	dirLight.setInfluencingBounds(surfaceScale.getBounds());
	objRoot.addChild(dirLight);
	
	AmbientLight ambLight = new AmbientLight(new Color3f(.3f,.3f,.3f));
	ambLight.setInfluencingBounds(surfaceScale.getBounds());
	objRoot.addChild(ambLight);
	
	//Set up mouse interactions
	MouseRotate myMouseRotate = new MouseRotate();
	myMouseRotate.setTransformGroup(objTransform);
	myMouseRotate.setSchedulingBounds(surfaceScale.getBounds());
	objRoot.addChild(myMouseRotate);
    
	MouseZoom myMouseZoom = new MouseZoom();
	myMouseZoom.setTransformGroup(objTransform);
	myMouseZoom.setSchedulingBounds(surfaceScale.getBounds());
	objRoot.addChild(myMouseZoom);
	
	MouseTranslate myMouseTranslate = new MouseTranslate();
	myMouseTranslate.setTransformGroup(objTransform);
	myMouseTranslate.setSchedulingBounds(surfaceScale.getBounds());
	objRoot.addChild(myMouseTranslate);
	
    objRoot.compile();
    
	return objRoot;
}
 
开发者ID:wolfmanstout,项目名称:jene,代码行数:79,代码来源:SurfacePanel.java

示例14: changeViewPoint

import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
 * Change the user view Point . Note that we modify the ViewBranch transform
 * not the scene transform.
 * 
 * @param type
 *          can be VIEW_FROM_TOP,VIEW_FROM_EAST,VIEW_BEHIND_AGENT
 * @param agent
 *          : specify the agent if VIEW_BEHIND_AGENT
 * 
 *          The VIEW_BEHIND_AGENT case has to be called regularly because of
 *          the agent displacement.
 */

public void changeViewPoint(int type, SimpleAgent agent) {
  Point3d p1 = new Point3d();
  Point3d p2 = new Point3d();

  Transform3D t1 = new Transform3D();
  Transform3D t2 = new Transform3D();
  t1.setIdentity();
  t2.setIdentity();
  mouseOrbiter.resetView();
  switch (type) {
    case VIEW_FROM_TOP:
      t1.lookAt(new Point3d(0, worldSize * 1.2, 0), new Point3d(0, 0, 0), new Vector3d(0, 0, -1));
      t1.invert();
      viewTransformGroup.setTransform(t1);
      break;
    case VIEW_FROM_EAST:
      t1.lookAt(new Point3d(worldSize, worldSize, 0), new Point3d(0, 0, 0), new Vector3d(-1, 0, 0));
      t1.invert();
      viewTransformGroup.setTransform(t1);
      break;
    case VIEW_BEHIND_AGENT:
      t1.setTranslation(new Vector3d(-agent.getRadius() * 2, 0, 0));
      agent.getGroup().getLocalToVworld(t2);
      t1.mul(t2);
      viewTransformGroup.setTransform(t1);
      break;
    case VIEW_ABOVE_AGENT:
      agent.getRotationTransformGroup().getLocalToVworld(t1);
      t1.transform(p1);
      t1.transform(p2);
      p2.y = worldSize * .8;
      t1.lookAt(p2, p1, new Vector3d(0, 0, -1));
      t1.invert();
      viewTransformGroup.setTransform(t1);
      break;

    case VIEW_ABOVE_AGENT_NEAR:
      agent.getRotationTransformGroup().getLocalToVworld(t1);
      t1.transform(p1);
      t1.transform(p2);
      p2.y = agent.getHeight() * worldSize * 0.5;
      // avoid front clipping
      if (p2.y < 0.2)
        p2.y = 0.2;
      t1.lookAt(p2, p1, new Vector3d(0, 0, -1));
      t1.invert();
      viewTransformGroup.setTransform(t1);

      break;
    case VIEW_AGENT_SIDE:

      agent.getRotationTransformGroup().getLocalToVworld(t1);
      t1.transform(p1);
      t1.transform(p2);
      agent.rotation.transform(p2);
      t2.setTranslation(new Vector3d(0, agent.getHeight() * 2, agent.getRadius() * 10));
      t2.transform(p2);
      t1.lookAt(p2, p1, new Vector3d(0, 1, 0));
      t1.invert();
      viewTransformGroup.setTransform(t1);

      break;
  }
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:78,代码来源:World.java

示例15: visualizeBounds

import javax.media.j3d.Transform3D; //导入方法依赖的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.Transform3D.mul方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。