本文整理汇总了Java中javax.media.j3d.Shape3D.addGeometry方法的典型用法代码示例。如果您正苦于以下问题:Java Shape3D.addGeometry方法的具体用法?Java Shape3D.addGeometry怎么用?Java Shape3D.addGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.j3d.Shape3D
的用法示例。
在下文中一共展示了Shape3D.addGeometry方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateRoomPartGeometry
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
private void updateRoomPartGeometry(int roomPart, HomeTexture texture)
{
Shape3D roomShape = (Shape3D) getChild(roomPart);
int currentGeometriesCount = roomShape.numGeometries();
Room room = (Room) getUserData();
if (room.getLevel() == null || room.getLevel().isViewableAndVisible())
{
for (Geometry roomGeometry : createRoomGeometries(roomPart, texture))
{
roomShape.addGeometry(roomGeometry);
}
}
for (int i = currentGeometriesCount - 1; i >= 0; i--)
{
roomShape.removeGeometry(i);
}
}
示例2: addCubeToContainer
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
private void addCubeToContainer(Shape3D container, float x, float y, float z) {
// float test = -100.0f;
// x=x-100;
// y=y-100;
// z=z+test;
// System.out.println("!!!!!!!!!!!!!!!!!!!");
//System.out.println("cube point: " + x + " " + y + " " + z);
//System.out.println("!!!!!!!!!!!!!!!!!!!");
Point3f p1 = new Point3f(x, y, z);
Point3f p2 = new Point3f(x + cubeLength, y, z);
Point3f p3 = new Point3f(x + cubeLength, y + cubeWidth, z);
Point3f p4 = new Point3f(x, y + cubeWidth, z);
Point3f p5 = new Point3f(x, y, z + cubeHeight);
Point3f p6 = new Point3f(x + cubeLength, y, z + cubeHeight);
Point3f p7 = new Point3f(x + cubeLength, y + cubeWidth, z + cubeHeight);
Point3f p8 = new Point3f(x, y + cubeWidth, z + cubeHeight);
container.addGeometry(createQuadArrayFromPoints(p1, p4, p3, p2)); // bottom
// face
container.addGeometry(createQuadArrayFromPoints(p5, p6, p7, p8)); // up
// face
container.addGeometry(createQuadArrayFromPoints(p1, p2, p6, p5)); // front
// face
container.addGeometry(createQuadArrayFromPoints(p2, p3, p7, p6)); // right
// face
container.addGeometry(createQuadArrayFromPoints(p3, p4, p8, p7)); // back
// face
container.addGeometry(createQuadArrayFromPoints(p4, p1, p5, p8)); // left
// face
}
示例3: buildRightCheek
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
/**
* Seite bauen
* @return 3D-Shape
*/
protected static Shape3D buildRightCheek() {
// Shape (= Backe) besteht aus 3 Teilen: Boden, Decke, Mantel
Shape3D rv = new Shape3D();
PointList floor = buildCheekArc(- BOT_HEIGHT / 2);
rv.addGeometry(floor.toFanGeometry()); // ausliefern
PointList ceil = buildCheekArc(+ BOT_HEIGHT / 2);
/*
* reverse() um Backface-Culling auszutricksen; "richtiger" waere, in
* den PolygonAttributes der Appearance setCullFace(FRONT) zu setzen,
* aber das wuerde die Appearance der gesamten Shape beeinflussen, und
* die soll hier nicht veraendert werden
*/
ceil.reverse();
rv.addGeometry(ceil.toFanGeometry()); // ausliefern
// Mantel aussen (vom Botzentrum weg gewandt); das ist ein Teil eines
// Zylindermantels
PointList arcBottom = buildCheekArc(- BOT_HEIGHT / 2);
PointList arcTop = buildCheekArc(+ BOT_HEIGHT / 2);
PointList lateralSurface = arcBottom.interleave(arcTop);
// Mantel innen (zum Botzentrum gewandt; d.h. Innenwand Mund); wir
// schliessen einfach den Zylindermantel-Abschnitt
lateralSurface.add(arcBottom.get(0));
lateralSurface.add(arcTop.get(0));
// Gesamtmantel ausliefern
rv.addGeometry(lateralSurface.toStripGeometry());
return rv;
}
示例4: createLine
import javax.media.j3d.Shape3D; //导入方法依赖的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);
}
示例5: addAreaGeometry
import javax.media.j3d.Shape3D; //导入方法依赖的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());
}
}
示例6: addAreaSidesGeometry
import javax.media.j3d.Shape3D; //导入方法依赖的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());
}
示例7: addAxons
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
private void addAxons(TransformGroup objRoot) {
ngView.outPrintln(" processing axons geometry\n");
task.setMyProgress(0.3f);
Appearance appearance = new Appearance();
/*
float width = 1.0f;
boolean antialias = false;
appearance.setLineAttributes(new LineAttributes(width, LineAttributes.PATTERN_SOLID, antialias));
*/
TransparencyAttributes myTA = new TransparencyAttributes();
myTA.setTransparency(0.2f);
myTA.setTransparencyMode(TransparencyAttributes.NICEST);
appearance.setTransparencyAttributes(myTA);
axonsShape3D = new Shape3D();
//axonsShape3D.removeGeometry(0);
axonsShape3D.removeAllGeometries();
axonsShape3D.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
axonsShape3D.setAppearance(appearance);
int cAx = 0, totalNumberOfAxonalSegments;
totalNumberOfAxonalSegments = net.getTotalNumOfAxonalSegments();
//logger.debug("totalNumberOfAxonalSegments: " + totalNumberOfAxonalSegments);
for (Neuron neuron : net.getNeuronList()) {
if (!neuron.collide() && collide) {
continue;
}
Section firstSection = neuron.getAxon().getFirstSection();
if (firstSection != null) {
Section.Iterator secIterator = firstSection.getIterator();
while (secIterator.hasNext()) {
Section section = secIterator.next();
Section.SectionType secType = section.getSectionType();
for (Segment segment : section.getSegments()) {
Point3f segStart = new Point3f(segment.getStart());
segStart.scale(scale);
Point3f segEnd = new Point3f(segment.getEnd());
segEnd.scale(scale);
LineArray la = new LineArray(2, LineArray.COORDINATES | LineArray.COLOR_3);
la.setCoordinate(0, segStart);
la.setCoordinate(1, segEnd);
/* old color
la.setColor(0, new Color3f(0.25f, 0.41f, 0.88f));
la.setColor(1, new Color3f(0.25f, 0.41f, 0.88f));
*/
Color3f color;// = Utils3D.darkgreyblue;
if (secType == Section.SectionType.MYELINIZED) {
//color = Utils3D.darkgreyblue;
color = Utils3D.darkOrange;
} else {
//color = Utils3D.turquoise1;
color = Utils3D.darkSalmon;
}
la.setColor(0, color);
la.setColor(1, color);
//lineArrayList.add(la);
axonsShape3D.addGeometry(la);
cAx++;
if (totalNumberOfAxonalSegments > 0) {
task.setMyProgress(0.3f + cAx * 0.2f / totalNumberOfAxonalSegments);
}
}
}
}
}
objRoot.addChild(axonsShape3D);
}
示例8: addDendrites
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
private void addDendrites(TransformGroup objRoot) {
ngView.outPrintln(" processing dendrites geometry\n");
Appearance appearance = new Appearance();
//float width = 1.0f * scale;
//boolean antialias = true;
//appearance.setLineAttributes(new LineAttributes(width, LineAttributes.PATTERN_SOLID, antialias));
dendritesShape3D = new Shape3D();
dendritesShape3D.removeAllGeometries();
dendritesShape3D.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
//dendritesShape3D.removeGeometry(0);
//dendritesShape3D.setAppearance(appearance);
TransparencyAttributes myTA = new TransparencyAttributes();
myTA.setTransparency(0.2f);
myTA.setTransparencyMode(TransparencyAttributes.NICEST);
appearance.setTransparencyAttributes(myTA);
dendritesShape3D.setAppearance(appearance);
int cDen = 0, totalNumberOfDenSegments;
totalNumberOfDenSegments = net.getTotalNumOfDenSegments();
//logger.info("total number of dendrite segments: " + totalNumberOfDenSegments);
task.setMyProgress(0.5f);
for (Neuron neuron : net.getNeuronList()) {
if (!neuron.collide() && collide) {
continue;
}
for (Dendrite dendrite : neuron.getDendrites()) {
Section firstSection = dendrite.getFirstSection();
if (firstSection != null) {
Section.Iterator secIterator = firstSection.getIterator();
while (secIterator.hasNext()) {
Section section = secIterator.next();
Section.SectionType secType = section.getSectionType();
for (Segment segment : section.getSegments()) {
Point3f segStart = new Point3f(segment.getStart());
segStart.scale(scale);
Point3f segEnd = new Point3f(segment.getEnd());
segEnd.scale(scale);
LineArray la = new LineArray(2, LineArray.COORDINATES | LineArray.COLOR_3);
la.setCoordinate(0, segStart);
la.setCoordinate(1, segEnd);
Color3f denColor = Utils3D.darkOliveGreen3;
if (secType != null) {
if (secType.equals(Section.SectionType.APICAL)) {
//logger.info("this is an apical section");
denColor = Utils3D.magenta;
} else if (secType.equals(Section.SectionType.BASAL)) {
//logger.info("this is a basal section");
//denColor = Utils3D.mediumSpringGreen;
denColor = Utils3D.yellow;
} else if (secType.equals(Section.SectionType.OBLIQUE)) {
//logger.info("this is an oblique section");
denColor = Utils3D.brown1;
}
}
la.setColor(0, denColor);
la.setColor(1, denColor);
//lineArrayList.add(la);
/* old color
la.setColor(0, new Color3f(0.93f, 0.87f, 0.51f));
la.setColor(1, new Color3f(0.93f, 0.87f, 0.51f));
*/
dendritesShape3D.addGeometry(la);
cDen++;
if (totalNumberOfDenSegments > 0 && !Float.isInfinite(totalNumberOfDenSegments)) {
task.setMyProgress(0.5f + cDen * 0.3f / totalNumberOfDenSegments);
}
}
}
}
}
}
objRoot.addChild(dendritesShape3D);
}
示例9: addLineToContainer
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
private void addLineToContainer(Shape3D container, Point3d p1, Point3d p2) {
container.addGeometry(createLineArrayFromPoints(p1, p2));
}
示例10: addTriangleToContainer
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
private void addTriangleToContainer(Shape3D container, Point3f p1, Point3f p2, Point3f p3) {
container.addGeometry(createTriangleArrayFromPoints(p1, p2, p3));
}
示例11: buildMiddle
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
/**
* Mitte bauen
* @return 3D-Shape
*/
protected static Shape3D buildMiddle() {
// Shape (= Mittelteil) besteht aus 5 Teilen: Zylinderboden, Zyl.-Decke,
// Abschnitt eines Zyl.-Mantel, 1. Quaderviertel, 2. Quaderviertel
Shape3D rv = new Shape3D();
PointList floor = buildStern(- BOT_HEIGHT / 2);
rv.addGeometry(floor.toFanGeometry());
PointList ceil = buildStern(+ BOT_HEIGHT / 2);
ceil.reverse(); // wegen Backface-Culling; siehe buildRightCheek()
rv.addGeometry(ceil.toFanGeometry());
// Zylindermantel-Abschnitt
PointList bottomArc = buildStern(- BOT_HEIGHT / 2);
PointList topArc = buildStern(+ BOT_HEIGHT / 2);
PointList lateralSurface = bottomArc.interleave(topArc);
rv.addGeometry(lateralSurface.toStripGeometry());
// Quaderviertel
PointList cuboidQuarter = new PointList();
cuboidQuarter.add((Point3d)topArc.last().clone()); // 0
cuboidQuarter.add((Point3d)topArc.get(0).clone()); // 1
Transform3D moveDown = new Transform3D();
moveDown.setTranslation(new Vector3d(0, - MOUTH_DEPTH_IN_M, 0));
cuboidQuarter.add( // 2
transformPoint(topArc.get(0), z180aboutCenter(), moveDown));
cuboidQuarter.add( // 3
transformPoint(topArc.last(), z180aboutCenter(), moveDown));
cuboidQuarter.add( // 4
transformPoint(bottomArc.last(), z180aboutCenter(), moveDown));
rv.addGeometry(cuboidQuarter.toStripGeometry()); // ausliefern
// Quaderviertel transformieren und nochmal verwenden
Transform3D y180 = new Transform3D();
y180.rotY(PI);
cuboidQuarter.transform(y180);
rv.addGeometry(cuboidQuarter.toStripGeometry()); // 2. Mal ausliefern
return rv;
}