本文整理汇总了Java中javax.media.j3d.Transform3D.transform方法的典型用法代码示例。如果您正苦于以下问题:Java Transform3D.transform方法的具体用法?Java Transform3D.transform怎么用?Java Transform3D.transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.j3d.Transform3D
的用法示例。
在下文中一共展示了Transform3D.transform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeVertex
import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
* Applies to <code>vertex</code> the given transformation, and writes it in
* a line v at OBJ format, if the vertex wasn't written yet.
*/
private void writeVertex(Transform3D transformationToParent,
Point3f vertex, int index,
int [] vertexIndexSubstitutes) throws IOException {
transformationToParent.transform(vertex);
Integer vertexIndex = this.vertexIndices.get(vertex);
if (vertexIndex == null) {
vertexIndexSubstitutes [index] = this.vertexIndices.size() + 1;
this.vertexIndices.put(vertex, vertexIndexSubstitutes [index]);
// Write only once unique vertices
this.out.write("v " + format(vertex.x)
+ " " + format(vertex.y)
+ " " + format(vertex.z) + "\n");
} else {
vertexIndexSubstitutes [index] = vertexIndex;
}
}
示例2: writeVertex
import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
* Applies to <code>vertex</code> the given transformation, and writes it in
* a line v at OBJ format, if the vertex wasn't written yet.
*/
private void writeVertex(Transform3D transformationToParent, Point3f vertex, int index,
int[] vertexIndexSubstitutes) throws IOException
{
transformationToParent.transform(vertex);
Integer vertexIndex = this.vertexIndices.get(vertex);
if (vertexIndex == null)
{
vertexIndexSubstitutes[index] = this.vertexIndices.size() + 1;
this.vertexIndices.put(vertex, vertexIndexSubstitutes[index]);
// Write only once unique vertices
this.out.write("v " + format(vertex.x) + " " + format(vertex.y) + " " + format(vertex.z) + "\n");
}
else
{
vertexIndexSubstitutes[index] = vertexIndex;
}
}
示例3: RangeSensorBelt
import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
* Constructs a RangeSensorBelt. The sensor type can be either
* TYPE_BUMPER,TYPE_SONAR,TYPE_IR or TYPE_LASER. Ranges are measured from
* the belt perimeter (not from the belt center).
*
* @param radius
* - the radius of the belt.
* @param minRange
* - the minimal range of each sensor ray. Not used for
* TYPE_BUMPER.
* @param maxRange
* - the maximal range of each sensor ray. Not used for
* TYPE_BUMPER.
* @param nbsensors
* - the number of sensors in the belt (typically 4,6,12,24 or
* 36).
* @param type
* - to specify the sensor behavior
*/
public RangeSensorBelt(float radius, float minRange, float maxRange, int nbsensors, int type, int flags) {
// compute angles ,positions , directions
positions = new Vector3d[nbsensors];
directions = new Vector3d[nbsensors];
Vector3d frontPos = new Vector3d(radius, 0, 0);
Vector3d frontDir = new Vector3d(maxRange, 0, 0);
angles = new double[nbsensors];
Transform3D transform = new Transform3D();
for (int i = 0; i < nbsensors; i++) {
angles[i] = i * 2 * Math.PI / nbsensors;
transform.setIdentity();
transform.rotY(angles[i]);
Vector3d pos = new Vector3d(frontPos);
transform.transform(pos);
positions[i] = pos;
Vector3d dir = new Vector3d(frontDir);
transform.transform(dir);
directions[i] = dir;
}
initialize(radius, maxRange, nbsensors, type, flags);
}
示例4: createBounds
import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
* @param newPos
* @param newHeading
* @param dX
* @param dY
* @param radius
* @param t Transformationsmatrix (wird veraendert)
* @return erzeugte Bounds
*/
private Bounds createBounds(Point3d newPos, double newHeading, double dX, double dY, double radius, Transform3D t) {
final double dZ = - CtBotSimTcp.BOT_HEIGHT / 2;
/* Vektor fuer die Verschiebung erstellen */
Vector3d v = new Vector3d(dX, dY, dZ);
/* Transformations-Matrix fuer die Rotation erstellen */
Transform3D r = new Transform3D();
r.rotZ(newHeading);
/* Transformation um Verschiebung ergaenzen */
r.transform(v);
v.add(newPos);
t.setIdentity();
t.setTranslation(v);
/* Bounds erstellen */
Bounds bounds = new BoundingSphere(new Point3d(0, 0, 0), radius);
/* Bounds transformieren */
bounds.transform(t);
return bounds;
}
示例5: sensLight
import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
* <p>
* Liefert die Helligkeit, die auf einen Lichtsensor fällt.
* </p>
* <p>
* Da diese Methode unter Verwendung des PickConeRay implementiert ist, ist
* sie seinen Bugs unterworfen. Ausführliche Dokumentation siehe
* watchObstacle(Point3d, Vector3d, double, Shape3D).
* </p>
*
* @param pos Die Position des Lichtsensors
* @param heading Die Blickrichtung des Lichtsensors
* @param lightReach Reichweite des Lichtsensors / m
* @param openingAngle Der Oeffnungswinkel des Blickstrahls / radians
* @return Die Dunkelheit um den Sensor herum, von 1023 (100%) bis 0 (0%)
* @see PickConeRay
*/
public int sensLight(Point3d pos, Vector3d heading, double lightReach, double openingAngle) {
// Falls die Welt verschoben wurde:
Point3d relPos = new Point3d(pos);
Transform3D transform = new Transform3D();
worldTG.getTransform(transform);
transform.transform(relPos);
// oder rotiert:
Vector3d relHeading = new Vector3d(heading);
transform.transform(relHeading);
PickConeRay picky = new PickConeRay(relPos, relHeading, openingAngle);
PickInfo pickInfo;
pickInfo = lightBG.pickClosest(PickInfo.PICK_GEOMETRY, PickInfo.CLOSEST_DISTANCE, picky);
if (pickInfo == null) {
return 1023;
}
int darkness = (int) ((pickInfo.getClosestDistance() / lightReach) * 1023.0);
if (darkness > 1023) {
darkness = 1023;
}
return darkness;
}
示例6: mapWorldToScreen
import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
* Given a point in world coordinates, adjust it in place to be in
* screen coordinates (after projection).
*
* @param point
*/
public void mapWorldToScreen( Camera view, Point3f point )
{
Matrix4d viewMatrix = new Matrix4d();
this .view .getViewTransform( viewMatrix, 0d );
Transform3D viewTrans = new Transform3D( viewMatrix );
viewTrans .transform( point );
// point is now in view coordinates
Vector4f p4 = new Vector4f( point.x, point.y, point.z, 1f );
Transform3D eyeTrans = new Transform3D();
if ( ! view .isPerspective() ) {
double edge = view .getWidth() / 2;
eyeTrans .ortho( -edge, edge, -edge, edge, view .getNearClipDistance(), view .getFarClipDistance() );
}
else
eyeTrans .perspective( view .getFieldOfView(), 1.0d, view .getNearClipDistance(), view .getFarClipDistance() );
// TODO - make aspect ratio track the screen window shape
eyeTrans .transform( p4 );
point .project( new Point4f( p4 ) );
}
示例7: RangeSensorBelt
import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
* Constructs a RangeSensorBelt. The sensor type can be either
* TYPE_BUMPER,TYPE_SONAR,TYPE_IR or TYPE_LASER. Ranges are measured from the
* belt perimeter (not from the belt center).
*
* @param radius
* - the radius of the belt.
* @param minRange
* - the minimal range of each sensor ray. Not used for TYPE_BUMPER.
* @param maxRange
* - the maximal range of each sensor ray. Not used for TYPE_BUMPER.
* @param nbsensors
* - the number of sensors in the belt (typically 4,6,12,24 or 36).
* @param type
* - to specify the sensor behavior
* @param flags additional flags
*/
public RangeSensorBelt(float radius, float minRange, float maxRange, int nbsensors, int type, int flags) {
// compute angles ,positions , directions
positions = new Vector3d[nbsensors];
directions = new Vector3d[nbsensors];
Vector3d frontPos = new Vector3d(radius, 0, 0);
Vector3d frontDir = new Vector3d(maxRange, 0, 0);
angles = new double[nbsensors];
Transform3D transform = new Transform3D();
for (int i = 0; i < nbsensors; i++) {
angles[i] = i * 2 * Math.PI / nbsensors;
transform.setIdentity();
transform.rotY(angles[i]);
Vector3d pos = new Vector3d(frontPos);
transform.transform(pos);
positions[i] = pos;
Vector3d dir = new Vector3d(frontDir);
transform.transform(dir);
directions[i] = dir;
}
initialize(radius, maxRange, nbsensors, type, flags);
}
示例8: writeNormal
import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
* Applies to <code>normal</code> the given transformation, and appends to <code>normalsBuffer</code>
* its values in a line vn at OBJ format, if the normal wasn't written yet.
* @return <code>true</code> if the written normal doens't contain any NaN value
*/
private boolean writeNormal(StringBuilder normalsBuffer,
Transform3D transformationToParent, Vector3f normal,
int index,
int [] normalIndexSubstitutes,
int [] oppositeSideNormalIndexSubstitutes,
int cullFace,
boolean backFaceNormalFlip) throws IOException {
if (Float.isNaN(normal.x) || Float.isNaN(normal.y) || Float.isNaN(normal.z)) {
return false;
}
if (backFaceNormalFlip) {
normal.negate();
}
if (normal.x != 0 || normal.y != 0 || normal.z != 0) {
transformationToParent.transform(normal);
normal.normalize();
}
Integer normalIndex = this.normalIndices.get(normal);
if (normalIndex == null) {
normalIndexSubstitutes [index] = this.normalIndices.size() + 1;
this.normalIndices.put(normal, normalIndexSubstitutes [index]);
// Write only once unique normals
normalsBuffer.append("vn " + format(normal.x)
+ " " + format(normal.y)
+ " " + format(normal.z) + "\n");
} else {
normalIndexSubstitutes [index] = normalIndex;
}
// if (cullFace == PolygonAttributes.CULL_NONE) {
// Vector3f oppositeNormal = new Vector3f();
// oppositeNormal.negate(normal);
// Fill opposite side normal index substitutes array
// return writeNormal(normalsBuffer, transformationToParent, oppositeNormal, index,
// oppositeSideNormalIndexSubstitutes, null, PolygonAttributes.CULL_FRONT, false);
// } else {
return true;
// }
}
示例9: updateBounds
import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
private void updateBounds(Point3f vertex, Transform3D transformation, Point3d lower, Point3d upper)
{
transformation.transform(vertex);
if (lower.x > vertex.x)
{
lower.x = vertex.x;
}
if (lower.y > vertex.y)
{
lower.y = vertex.y;
}
if (lower.z > vertex.z)
{
lower.z = vertex.z;
}
if (upper.x < vertex.x)
{
upper.x = vertex.x;
}
if (upper.y < vertex.y)
{
upper.y = vertex.y;
}
if (upper.z < vertex.z)
{
upper.z = vertex.z;
}
}
示例10: exportVertex
import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
* Applies to <code>vertex</code> the given transformation, and stores it in <code>vertices</code>.
*/
private void exportVertex(Transform3D transformationToParent, Point3f vertex, int index, float[] vertices)
{
transformationToParent.transform(vertex);
index *= 3;
vertices[index++] = vertex.x;
vertices[index++] = vertex.y;
vertices[index] = vertex.z;
}
示例11: exportNormal
import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
* Applies to <code>normal</code> the given transformation, and stores it in <code>normals</code>.
*/
private void exportNormal(Transform3D transformationToParent, Vector3f normal, int index, float[] normals,
boolean backFaceNormalFlip)
{
if (backFaceNormalFlip)
{
normal.negate();
}
transformationToParent.transform(normal);
int i = index * 3;
normals[i++] = normal.x;
normals[i++] = normal.y;
normals[i] = normal.z;
}
示例12: addLightSensorLeft
import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
* Adds a prebuild light sensor on the left of the agent .
*
* @param agent
* @return the sensor object
*/
static public LightSensor addLightSensorLeft(Agent agent) {
Vector3d front = new Vector3d(agent.getRadius() + 0.5, 0, 0);
Transform3D t3d = new Transform3D();
t3d.rotY(Math.PI / 4);
Vector3d left = new Vector3d(front);
t3d.transform(left);
return RobotFactory.addLightSensor(agent, left, (float) Math.PI / 4, "left");
}
示例13: addLightSensorRight
import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
* Adds a prebuild light sensor on the right of the agent .
*
* @param agent
* @return the sensor object
*/
static public LightSensor addLightSensorRight(Agent agent) {
Vector3d front = new Vector3d(agent.getRadius() + 0.5, 0, 0);
Transform3D t3d = new Transform3D();
t3d.rotY(-Math.PI / 4);
Vector3d right = new Vector3d(front);
t3d.transform(right);
return RobotFactory.addLightSensor(agent, right, (float) -Math.PI / 4, "left");
}
示例14: worldCoordFromBotCoord
import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
* Rechnet Bot-Koordinaten in Welt-Koordinaten um
* @param inBotCoord Bot-Koordis als Point
* @return Welt-Koordis
*/
public Point3d worldCoordFromBotCoord(Point3d inBotCoord) {
Point3d rv = (Point3d)inBotCoord.clone();
Transform3D t = new Transform3D();
transformgrp.getTransform(t);
t.transform(rv);
return rv;
}
示例15: transformPoint
import javax.media.j3d.Transform3D; //导入方法依赖的package包/类
/**
* transformiert einen Punkt
* @param p 3D-Punkt
* @param transforms Transformierung(en)
* @return 3D-Punkt
*/
private static Point3d transformPoint(Point3d p,
Transform3D... transforms) {
Point3d rv = (Point3d)p.clone();
for (Transform3D t : transforms)
t.transform(rv);
return rv;
}