本文整理汇总了Java中com.sun.j3d.utils.geometry.GeometryInfo.getGeometryArray方法的典型用法代码示例。如果您正苦于以下问题:Java GeometryInfo.getGeometryArray方法的具体用法?Java GeometryInfo.getGeometryArray怎么用?Java GeometryInfo.getGeometryArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.j3d.utils.geometry.GeometryInfo
的用法示例。
在下文中一共展示了GeometryInfo.getGeometryArray方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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;
}
示例3: 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();
}
示例4: 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);
}
示例5: 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());
}
}
示例6: 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();
}
示例7: createTerrain
import com.sun.j3d.utils.geometry.GeometryInfo; //导入方法依赖的package包/类
/**
* Create a java3d Shape for the terrain
* @param inModel threedModel
* @param inHelper terrain helper
* @param inBaseImage base image for shape, or null for no image
* @return Shape3D object
*/
private static Shape3D createTerrain(ThreeDModel inModel, TerrainHelper inHelper, GroutedImage inBaseImage)
{
final int numNodes = inHelper.getGridSize();
final int RESULT_SIZE = numNodes * (numNodes * 2 - 2);
int[] stripData = inHelper.getStripLengths();
// Get the scaled terrainTrack coordinates (or just heights) from the model
final int nSquared = numNodes * numNodes;
Point3d[] rawPoints = new Point3d[nSquared];
for (int i=0; i<nSquared; i++)
{
double height = inModel.getScaledTerrainValue(i) * MODEL_SCALE_FACTOR;
rawPoints[i] = new Point3d(inModel.getScaledTerrainHorizValue(i) * MODEL_SCALE_FACTOR,
Math.max(height, 0.05), // make sure it's above the box
-inModel.getScaledTerrainVertValue(i) * MODEL_SCALE_FACTOR);
}
GeometryInfo gi = new GeometryInfo(GeometryInfo.TRIANGLE_STRIP_ARRAY);
gi.setCoordinates(inHelper.getTerrainCoordinates(rawPoints));
gi.setStripCounts(stripData);
Appearance tAppearance = new Appearance();
if (inBaseImage != null)
{
gi.setTextureCoordinateParams(1, 2); // one coord set of two dimensions
gi.setTextureCoordinates(0, inHelper.getTextureCoordinates());
Texture mapImage = new TextureLoader(inBaseImage.getImage()).getTexture();
tAppearance.setTexture(mapImage);
TextureAttributes texAttr = new TextureAttributes();
texAttr.setTextureMode(TextureAttributes.MODULATE);
tAppearance.setTextureAttributes(texAttr);
}
else
{
Color3f[] colours = new Color3f[RESULT_SIZE];
Color3f terrainColour = new Color3f(0.1f, 0.2f, 0.2f);
for (int i=0; i<RESULT_SIZE; i++) {colours[i] = terrainColour;}
gi.setColors(colours);
}
new NormalGenerator().generateNormals(gi);
Material terrnMat = new Material(new Color3f(0.4f, 0.4f, 0.4f), // ambient colour
new Color3f(0f, 0f, 0f), // emissive (none)
new Color3f(0.8f, 0.8f, 0.8f), // diffuse
new Color3f(0.2f, 0.2f, 0.2f), //specular
30f); // shinyness
tAppearance.setMaterial(terrnMat);
return new Shape3D(gi.getGeometryArray(), tAppearance);
}
示例8: extract
import com.sun.j3d.utils.geometry.GeometryInfo; //导入方法依赖的package包/类
@Override
public void extract() throws Exception {
/*
* Some models don't work at all (LIFT.CHR and ITEMS.CHR). They seem to
* be incomplete/garbage files that were probably included by mistake
*/
super.extract();
int rootChunkDataSize = super.resourceBytes.length - 2 * DataReader.INT_SIZE;
byte[] rootChunkData = new byte[rootChunkDataSize];
System.arraycopy(super.resourceBytes, 2 * DataReader.INT_SIZE, rootChunkData, 0, rootChunkDataSize);
AbstractChunk rootChunk = new Chunk0x8000(ROOT_CHUNK_ID, rootChunkData);
rootChunk.readContents();
Chunk0x7f01 textureOffsetsChunk = (Chunk0x7f01) rootChunk.getChunksById(TEXTURE_OFFSETS_CHUNK_ID).get(0);
List<AbstractChunk> shapeChunks = rootChunk.getChunksById(SHAPE_CHUNK_ID);
Chunk0x7f04 textureChunk = (Chunk0x7f04) rootChunk.getChunksById(TEXTURE_CHUNK_ID).get(0);
Chunk0x7f05 shapePositionsChunk = (Chunk0x7f05) rootChunk.getChunksById(SHAPE_POSITIONS_CHUNK_ID).get(0);
Chunk0x7f06 shapePositionIdsChunk = (Chunk0x7f06) rootChunk.getChunksById(SHAPE_POSITION_IDS_CHUNK_ID).get(0);
shapePositionIdsChunk.mapPositions(shapePositionsChunk);
List<Point3f> vertexList = new ArrayList<>();
List<Integer> stripCountList = new ArrayList<>();
List<TexCoord2f> texCoordList = new ArrayList<>();
int[] textureOffsets = textureOffsetsChunk.getTextureOffsets();
short[] texturePixelIndices = textureChunk.getTexturePixelIndices();
int textureWidth = textureChunk.getWidth();
int textureHeight = textureChunk.getHeight();
for (AbstractChunk chunk : shapeChunks) {
Chunk0x7f02 shape = (Chunk0x7f02) chunk;
int shapeId = shape.getShapeId();
Polygon[] polygons = shape.getPolygons();
Point3f[] shapeVertices = shape.getVertices();
for (Polygon polygon : polygons) {
int textureOffsetIndex = polygon.getTextureOffsetIndex();
int textureStartPixel = textureOffsets[textureOffsetIndex];
polygon.setPixelSearchStart(textureStartPixel);
polygon.setTexturePixelIndices(texturePixelIndices);
polygon.setTextureWidth(textureWidth);
polygon.decode();
int[] vertexIndices = polygon.getShapeVertexIndices();
// Going backwards, otherwise faces are inside out
for (int i = vertexIndices.length - 1; i >= 0; i--) {
Point3f vertex = (Point3f) shapeVertices[vertexIndices[i]].clone();
vertex.add(shapePositionIdsChunk.getShapePosition(shapeId));
vertexList.add(vertex);
}
Point[] relativeUVs = polygon.getRelativeUVs();
for (int i = relativeUVs.length - 1; i >= 0; i--) {
int texOriginX = textureStartPixel % textureWidth;
int texOriginY = textureStartPixel / textureWidth;
float u = (float) (relativeUVs[i].getX() + texOriginX);
u /= textureWidth;
float v = (float) (relativeUVs[i].getY() + texOriginY);
// The UV 0,0 is at the bottom left
v = textureHeight - v;
v /= textureHeight;
texCoordList.add(new TexCoord2f(u, v));
}
stripCountList.add(polygon.getVerticeCount());
}
}
Point3f[] vertices = vertexList.toArray(new Point3f[vertexList.size()]);
int[] stripCounts = stripCountList.stream().mapToInt(i -> i).toArray();
TexCoord2f[] texCoords = texCoordList.toArray(new TexCoord2f[texCoordList.size()]);
GeometryInfo geometryInfo = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
geometryInfo.setCoordinates(vertices);
geometryInfo.setStripCounts(stripCounts);
geometryInfo.setTextureCoordinateParams(1, 2);
geometryInfo.setTextureCoordinates(0, texCoords);
Appearance appearence = new Appearance();
TextureLoader textureLoader = new TextureLoader((BufferedImage) textureChunk.getTexture());
appearence.setTexture(textureLoader.getTexture());
NormalGenerator normalGenerator = new NormalGenerator();
normalGenerator.generateNormals(geometryInfo);
Stripifier stripifier = new Stripifier();
stripifier.stripify(geometryInfo);
GeometryArray geometryArray = geometryInfo.getGeometryArray();
this.shape3d = new Shape3D(geometryArray);
this.shape3d.setAppearance(appearence);
}