本文整理汇总了Java中com.sun.j3d.utils.geometry.GeometryInfo类的典型用法代码示例。如果您正苦于以下问题:Java GeometryInfo类的具体用法?Java GeometryInfo怎么用?Java GeometryInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GeometryInfo类属于com.sun.j3d.utils.geometry包,在下文中一共展示了GeometryInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RepresentationTin
import com.sun.j3d.utils.geometry.GeometryInfo; //导入依赖的package包/类
public RepresentationTin(ITriangulatedSurface tin, Color[] colorShade,
int method) {
super();
this.nbClasses = colorShade.length;
Box3D b = new Box3D(tin.coord());
this.zMin = b.getLLDP().getZ();
this.zMax = b.getURDP().getZ();
this.colorShade = toColor3f(colorShade);
this.method = METHOD_LINEAR;
this.tin = tin;
GeometryInfo geoInfo = fromOrientableSToTriangleArray();
Appearance app = new Appearance();
ColoringAttributes at = new ColoringAttributes();
at.setShadeModel(ColoringAttributes.NICEST);
app.setColoringAttributes(at);
this.bGRep.addChild(new Shape3D(geoInfo.getGeometryArray(), app));
}
示例2: createHorizontalPartGeometry
import com.sun.j3d.utils.geometry.GeometryInfo; //导入依赖的package包/类
/**
* Returns the geometry of an horizontal part of a wall or a baseboard at <code>y</code>.
*/
private Geometry createHorizontalPartGeometry(float[][] points, float y, boolean reverseOrder, boolean roundWall)
{
Point3f[] coords = new Point3f[points.length];
for (int i = 0; i < points.length; i++)
{
coords[i] = new Point3f(points[i][0], y, points[i][1]);
}
GeometryInfo geometryInfo = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
geometryInfo.setCoordinates(coords);
geometryInfo.setStripCounts(new int[] { coords.length });
if (reverseOrder)
{
geometryInfo.reverse();
}
// Generate normals
NormalGenerator normalGenerator = new NormalGenerator();
if (roundWall)
{
normalGenerator.setCreaseAngle(0);
}
normalGenerator.generateNormals(geometryInfo);
return geometryInfo.getIndexedGeometryArray();
}
示例3: createTopPartGeometry
import com.sun.j3d.utils.geometry.GeometryInfo; //导入依赖的package包/类
/**
* Returns the geometry of the top part of a wall or a baseboard.
*/
private Geometry createTopPartGeometry(float[][] points, double cosWallYawAngle, double sinWallYawAngle,
double topLineAlpha, double topLineBeta, boolean roundWall)
{
Point3f[] coords = new Point3f[points.length];
for (int i = 0; i < points.length; i++)
{
double xTopPointWithZeroYaw = cosWallYawAngle * points[i][0] + sinWallYawAngle * points[i][1];
float topY = (float) (topLineAlpha * xTopPointWithZeroYaw + topLineBeta);
coords[i] = new Point3f(points[i][0], topY, points[i][1]);
}
GeometryInfo geometryInfo = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
geometryInfo.setCoordinates(coords);
geometryInfo.setStripCounts(new int[] { coords.length });
// Generate normals
NormalGenerator normalGenerator = new NormalGenerator();
if (roundWall)
{
normalGenerator.setCreaseAngle(0);
}
normalGenerator.generateNormals(geometryInfo);
return geometryInfo.getIndexedGeometryArray();
}
示例4: Object3d
import com.sun.j3d.utils.geometry.GeometryInfo; //导入依赖的package包/类
/**
* créer la représentation d'un objet avec une géométrie de type solide. créer
* le lien entre la représentation et l'objet indispensable pour pouvoir
* effectuer des sélections
*
* @param feat l'entité dont la géométrie servira à créer la représentation et
* à laquelle sera attachée la représentation
* @param isClrd indique si une couleur unique sera appliquée ou non (si false
* une couleur différente par face)
* @param color couleur appliquée si isClrd == true
* @param coefOpacity coefficient d'opacité appliqué à l'objet
* @param isSolid propose un mode de représentation filaire (false) ou
* surfacique (true)
*/
public Object3d(IFeature feat, boolean isClrd, Color color,
double coefOpacity, boolean isSolid) {
// On crée le bg avec toutes les autorisations nécessaires
super(feat, isClrd, color, coefOpacity, isSolid);
// préparation de la géométrie Java3D
GeometryInfo geometryInfo = null;
if (isClrd) {
geometryInfo = this.geometryWithColor();
} else {
geometryInfo = this.geometryWithOutColor();
}
if (geometryInfo == null) {
Object3d.LOGGER.warn(Messages.getString("Representation.RepNulle"));
return;
}
// préparation de l'apparence
Appearance apparence = this.generateAppearance(isClrd, color, coefOpacity,
isSolid);
// Calcul de l'objet Shape3D
Shape3D shapepleine = new Shape3D(geometryInfo.getGeometryArray(),
apparence);
// Autorisations sur la Shape3D
shapepleine.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
shapepleine.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
shapepleine.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
shapepleine.setCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ);
shapepleine.setCapability(Node.ALLOW_LOCALE_READ);
// Ajout au BgClone les elements transformes
this.bGRep.addChild(shapepleine);
// Optimisation
this.bGRep.compile();
}
示例5: getCoordinates
import com.sun.j3d.utils.geometry.GeometryInfo; //导入依赖的package包/类
private Point3d[] getCoordinates(GeometryInfo gInfo, double z) {
GeometryArray gArray = gInfo.getGeometryArray();
final int start = gArray.getInitialVertexIndex();
final int length = gArray.getValidVertexCount();
Point3d[] points = new Point3d[length];
for (int j = start; j < length; j++) {
points[j] = new Point3d();
}
gArray.getCoordinates(start, points);
for (int j = start; j < length; j++) {
points[j].z = points[j].z + z;
}
return points;
}
示例6: addCoordinates
import com.sun.j3d.utils.geometry.GeometryInfo; //导入依赖的package包/类
/** Adds geometry from <code>GeometryInfo.QUAD_ARRAY</code>
* coordinates. */
protected GeometryInfo addCoordinates(Point3d[] coordinates) {
GeometryInfo geometryInfo = new GeometryInfo(GeometryInfo.QUAD_ARRAY);
geometryInfo.setCoordinates(coordinates);
_normalGenerator.generateNormals(geometryInfo);
if (_first) {
setGeometry(geometryInfo.getGeometryArray());
_first = false;
}
else {
addGeometry(geometryInfo.getGeometryArray());
}
return geometryInfo;
}
示例7: toGeometry
import com.sun.j3d.utils.geometry.GeometryInfo; //导入依赖的package包/类
/**
* @param geometryInfoPrimitive
* @return GeometryArray
*/
public GeometryArray toGeometry(int geometryInfoPrimitive) {
GeometryInfo gi = new GeometryInfo(geometryInfoPrimitive);
gi.setCoordinates(toArray(new Point3d[] {}));
gi.setStripCounts(new int[] { size() });
// Noch ein paar Beschwoerungsformeln, weiss der Henker warum
new NormalGenerator().generateNormals(gi);
gi.recomputeIndices();
new Stripifier().stripify(gi);
gi.recomputeIndices();
return gi.getGeometryArray();
}
示例8: createLine
import com.sun.j3d.utils.geometry.GeometryInfo; //导入依赖的package包/类
/**
* Erzeugt eine Linie auf dem Boden 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 Y-Richtung
* @param points
* Punkte der Linie
* @param appearance
* Art der Linie
*/
private void createLine(int x, int y, float[] points, Appearance appearance) {
// zwei Polygone (Deckel und Boden) mit N Ecken
float[] p = new float[points.length];
int stripCounts[] = { points.length / 3 };
// Zaehler
int n = 0;
for (n = 0; n < points.length; n++) {
p[n] = points[n] * parcours.getBlockSizeInM();
}
createFloor(x, y, getAppearance(' '));
// Polygone in darstellbare Form umwandeln
GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
gi.setCoordinates(p);
gi.setStripCounts(stripCounts);
NormalGenerator ng = new NormalGenerator();
ng.generateNormals(gi);
gi.recomputeIndices();
Stripifier st = new Stripifier();
st.stripify(gi);
gi.recomputeIndices();
// Hinzufuegen der Ober- und Unterseite des Linien-Shape3D
Shape3D ls = new Shape3D();
ls.addGeometry(gi.getGeometryArray());
ls.setAppearance(appearance);
parcours.addFloor(ls, x + 0.5f, y + 0.5f, 0.002f);
}
示例9: getBody
import com.sun.j3d.utils.geometry.GeometryInfo; //导入依赖的package包/类
private Shape3D getBody(Point3f[] pointArr) {
GeometryInfo ginfo = new GeometryInfo(GeometryInfo.QUAD_ARRAY);
ginfo.setCoordinates(pointArr);
NormalGenerator n = new NormalGenerator();
n.generateNormals(ginfo);
QuadArray quadArray = (QuadArray) ginfo.getGeometryArray();
return new Shape3D(quadArray);
}
示例10: getMassDyadic
import com.sun.j3d.utils.geometry.GeometryInfo; //导入依赖的package包/类
/**
* Not yet tested - pulls and scales model vertex values to compute
* moments of inertia. NOTE: Check orientation of model axes vs.
* body axes....
*
* @param mass Total mass of the solid model. Moments
* assume all mass is evenly distributed at
* each *vertex* point (not throughout solid).
* @return Inertia tensor based on input mass units and
* the distance units from class instatniation.
*/
public MassDyadic getMassDyadic(double mass) {
Shape3D s3d = (Shape3D) modelBG.getChild(0);
GeometryArray ga = (GeometryArray)s3d.getGeometry();
GeometryInfo geometryInfo = new GeometryInfo(ga);
Point3f[] verts = geometryInfo.getCoordinates();
double ixx = 0.0;
double iyy = 0.0;
double izz = 0.0;
double ixy = 0.0;
double ixz = 0.0;
double iyz = 0.0;
double dm = mass/verts.length;
for (int ii=0; ii<verts.length; ii++) {
verts[ii].x *= sf;
verts[ii].y *= sf;
verts[ii].z *= sf;
}
for (int ii=0; ii<verts.length; ii++) {
ixx += dm * (double) (verts[ii].y*verts[ii].y + verts[ii].z*verts[ii].z);
iyy += dm * (double) (verts[ii].x*verts[ii].x + verts[ii].z*verts[ii].z);
izz += dm * (double) (verts[ii].x*verts[ii].x + verts[ii].y*verts[ii].y);
ixy += dm * (double) (verts[ii].x*verts[ii].y);
ixz += dm * (double) (verts[ii].x*verts[ii].z);
iyz += dm * (double) (verts[ii].y*verts[ii].z);
}
MassDyadic mI = new MassDyadic();
mI.put(Basis3D.I, Basis3D.I, ixx);
mI.put(Basis3D.J, Basis3D.J, iyy);
mI.put(Basis3D.K, Basis3D.K, izz);
mI.put(Basis3D.I, Basis3D.J, ixy);
mI.put(Basis3D.I, Basis3D.K, ixz);
mI.put(Basis3D.J, Basis3D.K, iyz);
return mI;
}
示例11: Object2d
import com.sun.j3d.utils.geometry.GeometryInfo; //导入依赖的package包/类
/**
* créer la représentation d'un objet avec une géométrie de type solide. créer
* le lien entre la représentation et l'objet indispensable pour pouvoir
* effectuer des sélections
*
* @param feat l'entité dont la géométrie servira à créer la représentation et
* à laquelle sera attachée la représentation
* @param isClrd indique si une couleur unique sera appliquée ou non (si false
* une couleur différente par face)
* @param color couleur appliquée si isClrd == true
* @param coefOpacity coefficient d'opacité appliqué à l'objet
* @param isSolid propose un mode de représentation filaire (false) ou
* surfacique (true)
*/
public Object2d(IFeature feat, boolean isClrd, Color color,
double coefOpacity, boolean isSolid) {
super(feat, isClrd, color, coefOpacity, isSolid);
// On Génère la géométrie Java3D suivant le cas
GeometryInfo geometryInfo = null;
if (isClrd) {
geometryInfo = this.geometryWithColor();
} else {
geometryInfo = this.geometryWithOutColor();
}
if (geometryInfo == null) {
Object2d.logger.warn(Messages.getString("Representation.RepNulle"));
return;
}
// préparation de l'apparence
Appearance apparence = this.generateAppearance(isClrd, color, coefOpacity,
isSolid);
try {
// Calcul de l'objet Shape3D
Shape3D shapepleine = new Shape3D(geometryInfo.getGeometryArray(),
apparence);
// Autorisations sur la Shape3D
shapepleine.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
shapepleine.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
shapepleine.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
shapepleine.setCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ);
shapepleine.setCapability(Node.ALLOW_LOCALE_READ);
// Ajout au BgClone les elements transformes
this.bGRep.addChild(shapepleine);
// Optimisation
this.bGRep.compile();
} catch (Exception e) {
Object2d.logger.error(e.getMessage());
}
}
示例12: TexturedSurface
import com.sun.j3d.utils.geometry.GeometryInfo; //导入依赖的package包/类
/**
* Permet d'appliquer une texture générique à une entité
*
* @param feat L'entité utilisée pour Génèrer la représentation
* @param tex La texture que l'on souhaite appliquer
* @param imageLength la longueur que représente l'image dans le monde réel
* @param imageHeigth la hauteur que représente l'image dans le monde réel
*/
public TexturedSurface(IFeature feat, Texture2D tex, double imageLength,
double imageHeigth) {
// On créer le BranchGroup avec les autorisations ad hoc
super();
this.texture = tex;
this.feat = feat;
this.imageLength = imageLength;
this.imageHeigth = imageHeigth;
// préparation de la géométrie Java3D
GeometryInfo geometryInfo = null;
geometryInfo = Util.geometryWithTexture(feat.getGeom(), imageLength,
imageHeigth);
if (geometryInfo == null) {
TexturedSurface.logger
.warn(Messages.getString("Representation.RepNulle"));
return;
}
// préparation de l'apparence
Appearance apparence = this.generateAppearance();
// Calcul de l'objet Shape3D
Shape3D shapepleine = new Shape3D(geometryInfo.getGeometryArray(),
apparence);
// Autorisations sur la Shape3D
shapepleine.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
shapepleine.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
shapepleine.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
shapepleine.setCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ);
shapepleine.setCapability(Node.ALLOW_LOCALE_READ);
// Ajout au BgClone les elements transformes
this.bGRep.addChild(shapepleine);
// Optimisation
this.bGRep.compile();
}
示例13: addAreaGeometry
import com.sun.j3d.utils.geometry.GeometryInfo; //导入依赖的package包/类
/**
* Adds to ground shape the geometry matching the given area.
*/
private void addAreaGeometry(Shape3D groundShape, HomeTexture groundTexture, Area area, float elevation)
{
List<float[][]> areaPoints = getAreaPoints(area, 1, false);
if (!areaPoints.isEmpty())
{
int vertexCount = 0;
int[] stripCounts = new int[areaPoints.size()];
for (int i = 0; i < stripCounts.length; i++)
{
stripCounts[i] = areaPoints.get(i).length;
vertexCount += stripCounts[i];
}
Point3f[] geometryCoords = new Point3f[vertexCount];
TexCoord2f[] geometryTextureCoords = groundTexture != null ? new TexCoord2f[vertexCount] : null;
float textureWidth;
float textureHeight;
if (groundTexture != null)
{
textureWidth = TextureManager.getInstance().getRotatedTextureWidth(groundTexture);
textureHeight = TextureManager.getInstance().getRotatedTextureHeight(groundTexture);
}
else
{
textureWidth = 0;
textureHeight = 0;
}
int j = 0;
for (float[][] areaPartPoints : areaPoints)
{
for (int i = 0; i < areaPartPoints.length; i++, j++)
{
float[] point = areaPartPoints[i];
geometryCoords[j] = new Point3f(point[0], elevation, point[1]);
if (groundTexture != null)
{
geometryTextureCoords[j] = new TexCoord2f((point[0] - this.originX) / textureWidth,
(this.originY - point[1]) / textureHeight);
}
}
}
GeometryInfo geometryInfo = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
geometryInfo.setCoordinates(geometryCoords);
if (groundTexture != null)
{
geometryInfo.setTextureCoordinateParams(1, 2);
geometryInfo.setTextureCoordinates(0, geometryTextureCoords);
}
geometryInfo.setStripCounts(stripCounts);
new NormalGenerator(0).generateNormals(geometryInfo);
groundShape.addGeometry(geometryInfo.getIndexedGeometryArray());
}
}
示例14: addAreaSidesGeometry
import com.sun.j3d.utils.geometry.GeometryInfo; //导入依赖的package包/类
/**
* Adds to ground shape the geometry matching the given area sides.
*/
private void addAreaSidesGeometry(Shape3D groundShape, HomeTexture groundTexture, float[][] areaPoints,
float elevation, float sideHeight)
{
Point3f[] geometryCoords = new Point3f[areaPoints.length * 4];
TexCoord2f[] geometryTextureCoords = groundTexture != null ? new TexCoord2f[geometryCoords.length] : null;
float textureWidth;
float textureHeight;
if (groundTexture != null)
{
textureWidth = TextureManager.getInstance().getRotatedTextureWidth(groundTexture);
textureHeight = TextureManager.getInstance().getRotatedTextureHeight(groundTexture);
}
else
{
textureWidth = 0;
textureHeight = 0;
}
for (int i = 0, j = 0; i < areaPoints.length; i++)
{
float[] point = areaPoints[i];
float[] nextPoint = areaPoints[i < areaPoints.length - 1 ? i + 1 : 0];
geometryCoords[j++] = new Point3f(point[0], elevation, point[1]);
geometryCoords[j++] = new Point3f(point[0], elevation + sideHeight, point[1]);
geometryCoords[j++] = new Point3f(nextPoint[0], elevation + sideHeight, nextPoint[1]);
geometryCoords[j++] = new Point3f(nextPoint[0], elevation, nextPoint[1]);
if (groundTexture != null)
{
float distance = (float) Point2D.distance(point[0], point[1], nextPoint[0], nextPoint[1]);
geometryTextureCoords[j - 4] = new TexCoord2f(point[0] / textureWidth, elevation / textureHeight);
geometryTextureCoords[j - 3] = new TexCoord2f(point[0] / textureWidth,
(elevation + sideHeight) / textureHeight);
geometryTextureCoords[j - 2] = new TexCoord2f((point[0] - distance) / textureWidth,
(elevation + sideHeight) / textureHeight);
geometryTextureCoords[j - 1] = new TexCoord2f((point[0] - distance) / textureWidth,
elevation / textureHeight);
}
}
GeometryInfo geometryInfo = new GeometryInfo(GeometryInfo.QUAD_ARRAY);
geometryInfo.setCoordinates(geometryCoords);
if (groundTexture != null)
{
geometryInfo.setTextureCoordinateParams(1, 2);
geometryInfo.setTextureCoordinates(0, geometryTextureCoords);
}
new NormalGenerator(0).generateNormals(geometryInfo);
groundShape.addGeometry(geometryInfo.getIndexedGeometryArray());
}
示例15: createHalfSphereGeometry
import com.sun.j3d.utils.geometry.GeometryInfo; //导入依赖的package包/类
/**
* Returns a half sphere oriented inward and with texture ordinates
* that spread along an hemisphere.
*/
private Geometry createHalfSphereGeometry(boolean top)
{
final int divisionCount = 48;
Point3f[] coords = new Point3f[divisionCount * divisionCount];
TexCoord2f[] textureCoords = top ? new TexCoord2f[divisionCount * divisionCount] : null;
Color3f[] colors = top ? null : new Color3f[divisionCount * divisionCount];
for (int i = 0, k = 0; i < divisionCount; i++)
{
double alpha = i * 2 * Math.PI / divisionCount;
float cosAlpha = (float) Math.cos(alpha);
float sinAlpha = (float) Math.sin(alpha);
double nextAlpha = (i + 1) * 2 * Math.PI / divisionCount;
float cosNextAlpha = (float) Math.cos(nextAlpha);
float sinNextAlpha = (float) Math.sin(nextAlpha);
for (int j = 0; j < divisionCount / 4; j++)
{
double beta = 2 * j * Math.PI / divisionCount;
float cosBeta = (float) Math.cos(beta);
float sinBeta = (float) Math.sin(beta);
// Correct the bottom of the hemisphere to avoid seeing a bottom hemisphere at the horizon
float y = j != 0 ? (top ? sinBeta : -sinBeta) : -0.01f;
double nextBeta = 2 * (j + 1) * Math.PI / divisionCount;
if (!top)
{
nextBeta = -nextBeta;
}
float cosNextBeta = (float) Math.cos(nextBeta);
float sinNextBeta = (float) Math.sin(nextBeta);
if (top)
{
coords[k] = new Point3f(cosAlpha * cosBeta, y, sinAlpha * cosBeta);
textureCoords[k++] = new TexCoord2f((float) i / divisionCount, sinBeta);
coords[k] = new Point3f(cosNextAlpha * cosBeta, y, sinNextAlpha * cosBeta);
textureCoords[k++] = new TexCoord2f((float) (i + 1) / divisionCount, sinBeta);
coords[k] = new Point3f(cosNextAlpha * cosNextBeta, sinNextBeta, sinNextAlpha * cosNextBeta);
textureCoords[k++] = new TexCoord2f((float) (i + 1) / divisionCount, sinNextBeta);
coords[k] = new Point3f(cosAlpha * cosNextBeta, sinNextBeta, sinAlpha * cosNextBeta);
textureCoords[k++] = new TexCoord2f((float) i / divisionCount, sinNextBeta);
}
else
{
coords[k] = new Point3f(cosAlpha * cosBeta, y, sinAlpha * cosBeta);
float color1 = .9f + y * .5f;
colors[k++] = new Color3f(color1, color1, color1);
coords[k] = new Point3f(cosAlpha * cosNextBeta, sinNextBeta, sinAlpha * cosNextBeta);
float color2 = .9f + sinNextBeta * .5f;
colors[k++] = new Color3f(color2, color2, color2);
coords[k] = new Point3f(cosNextAlpha * cosNextBeta, sinNextBeta, sinNextAlpha * cosNextBeta);
colors[k++] = new Color3f(color2, color2, color2);
coords[k] = new Point3f(cosNextAlpha * cosBeta, y, sinNextAlpha * cosBeta);
colors[k++] = new Color3f(color1, color1, color1);
}
}
}
GeometryInfo geometryInfo = new GeometryInfo(GeometryInfo.QUAD_ARRAY);
geometryInfo.setCoordinates(coords);
if (textureCoords != null)
{
geometryInfo.setTextureCoordinateParams(1, 2);
geometryInfo.setTextureCoordinates(0, textureCoords);
}
if (colors != null)
{
geometryInfo.setColors(colors);
}
geometryInfo.indexify();
geometryInfo.compact();
Geometry halfSphereGeometry = geometryInfo.getIndexedGeometryArray();
return halfSphereGeometry;
}