• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TextureLoader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.j3d.utils.image.TextureLoader的典型用法代码示例。如果您正苦于以下问题:Java TextureLoader类的具体用法?Java TextureLoader怎么用?Java TextureLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TextureLoader类属于com.sun.j3d.utils.image包,在下文中一共展示了TextureLoader类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: Earth

import com.sun.j3d.utils.image.TextureLoader; //导入依赖的package包/类
/** Creates new Earth */
public Earth(TransformGroup objTrans, BoundingSphere bounds, java.awt.Component observer)
{
  Appearance ap= new Appearance();
  Material mm = new Material();
  mm.setLightingEnable(true);
  ap.setMaterial(mm);

  TextureAttributes texAttr = new TextureAttributes();
  texAttr.setTextureMode(TextureAttributes.MODULATE);
  TextureLoader earthTex = new TextureLoader(new String("./" + texturesDirName + "/clouds.gif"), new String("RGB"), observer);
  if (earthTex != null) ap.setTexture(earthTex.getTexture());
  ap.setTextureAttributes(texAttr);

  // number of divisions - 5 is ugly, 15 OK, 25 pretty good):
  Sphere globe = new Sphere(.5f,Sphere.GENERATE_NORMALS | Sphere.GENERATE_TEXTURE_COORDS, 25, ap);

  getAttachPoint().addChild(globe);
 
  Alpha alpha = new Alpha(-1, 500000);
  RotationInterpolator ri = new RotationInterpolator(alpha, getRotation());
  //PositionPathInterpolator ri = new PositionPathInterpolator(alpha, rotation);
  ri.setSchedulingBounds(bounds);
  getRotation().addChild(ri);
}
 
开发者ID:007Style,项目名称:whiskeyDEM,代码行数:26,代码来源:Earth.java


示例2: textureLoading

import com.sun.j3d.utils.image.TextureLoader; //导入依赖的package包/类
/**
 * On tente d'initialiser une texture à partir d'un chemin. En retour on
 * obtient l'objet Texture2D correspondant à ce chemin. Si la texture n'est
 * pas chargée par le Manager, il la crée, si elle est chargée, il renvoie
 * l'instance existante. L'objet Texture2D sert aux représentations d'objets
 * texturés génériquement. Voir classe ObjetSurfaceTexture.
 * 
 * @param path le chemin de la texture
 * @return l'objet Texture2D renvoyé.
 */
public static Texture2D textureLoading(String path) {
  int nbTextures = TextureManager.lTextures.size();
  for (int i = 0; i < nbTextures; i++) {
   // System.out.println(path);
   // System.out.println("lPathTextures = " + TextureManager.lPathTextures.get(i));
    if (TextureManager.lPathTextures.get(i).equals(path)) {
     // System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
      return TextureManager.lTextures.get(i);
    }

  }
  // System.out.println("chemin = " + path);
  TextureLoader loader = new TextureLoader(path, null);
  Texture2D texture = (Texture2D) loader.getTexture();
  texture.setBoundaryModeS(Texture.WRAP);
  texture.setBoundaryModeT(Texture.WRAP);
  texture.setEnable(true);
  texture.setMagFilter(Texture.BASE_LEVEL_LINEAR);
  texture.setMinFilter(Texture.BASE_LEVEL_LINEAR);

  TextureManager.lTextures.add(texture);
  TextureManager.lPathTextures.add(path);

  return texture;

}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:37,代码来源:TextureManager.java


示例3: textureNoReapetLoading

import com.sun.j3d.utils.image.TextureLoader; //导入依赖的package包/类
/**
 * On tente d'initialiser une texture à partir d'un chemin. En retour on
 * obtient l'objet Texture2D correspondant à ce chemin. Si la texture n'est
 * pas chargée par le Manager, il la crée, si elle est chargée, il renvoie
 * l'instance existante. L'objet Texture2D sert aux représentations d'objets
 * texturés génériquement. Voir classe ObjetSurfaceTexture.
 * 
 * @param path le chemin de la texture
 * @return l'objet Texture2D renvoyé.
 */
public static Texture2D textureNoReapetLoading(String path) {
  int nbTextures = TextureManager.lTextures.size();

  for (int i = 0; i < nbTextures; i++) {

    if (TextureManager.lPathTextures.get(i).equals(path)) {

      return TextureManager.lTextures.get(i);
    }

  }

  TextureLoader loader = new TextureLoader(path, null);
  Texture2D texture = (Texture2D) loader.getTexture();
  texture.setBoundaryModeS(Texture.CLAMP_TO_BOUNDARY);
  texture.setBoundaryModeT(Texture.CLAMP_TO_BOUNDARY);
  texture.setEnable(true);
  texture.setMagFilter(Texture.BASE_LEVEL_LINEAR);
  texture.setMinFilter(Texture.BASE_LEVEL_LINEAR);

  TextureManager.lTextures.add(texture);
  TextureManager.lPathTextures.add(path);

  return texture;

}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:37,代码来源:TextureManager.java


示例4: getColoredImageTexture

import com.sun.j3d.utils.image.TextureLoader; //导入依赖的package包/类
/**
 * Returns a texture image of one pixel of the given <code>color</code>. 
 */
private Texture getColoredImageTexture(Color color)
{
	BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
	Graphics g = image.getGraphics();
	g.setColor(color);
	g.drawLine(0, 0, 0, 0);
	g.dispose();
	Texture texture = new TextureLoader(image).getTexture();
	texture.setCapability(Texture.ALLOW_IMAGE_READ);
	texture.setCapability(Texture.ALLOW_FORMAT_READ);
	texture.getImage(0).setCapability(ImageComponent2D.ALLOW_IMAGE_READ);
	texture.getImage(0).setCapability(ImageComponent2D.ALLOW_FORMAT_READ);
	return texture;
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:18,代码来源:TextureManager.java


示例5: createAppearance

import com.sun.j3d.utils.image.TextureLoader; //导入依赖的package包/类
private Appearance createAppearance() {
	
	Material material = new Material();
	material.setSpecularColor(.7f,.7f,.7f);
	
	if(_organism instanceof S3DOrganism) {
		float[] rgb = ((S3DOrganism)_organism).color();
		material.setDiffuseColor(rgb[0], rgb[1], rgb[2]);
	}
	else {
		material.setDiffuseColor(1, 1, 1);
	}
	
	//Load texture
	BufferedImage textureImage;
	try {
		textureImage = ImageIO.read(getClass().getResourceAsStream("checker_mask.png"));
	} catch (IOException ex) {
		// should not happen (texture should be found)
		throw new RuntimeException("Image not found", ex);
	}
	TextureLoader loader = new TextureLoader(textureImage, (Component) null);
	ImageComponent2D  image = loader.getImage();
	Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA, image.getWidth(), image.getHeight());
	texture.setImage(0, image);
	TextureAttributes ta = new TextureAttributes();
	ta.setTextureMode(TextureAttributes.DECAL);
	
	Appearance appearance = new Appearance();
	appearance.setMaterial(material);
	appearance.setTexture(texture);
	
	appearance.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0, true));
	appearance.setColoringAttributes(new ColoringAttributes(1, 1, 1, ColoringAttributes.SHADE_GOURAUD));
	appearance.setTextureAttributes(ta);
	//appearance.setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.NICEST, .3f));
	
	return appearance;
}
 
开发者ID:wolfmanstout,项目名称:jene,代码行数:40,代码来源:Surface.java


示例6: loadTexture

import com.sun.j3d.utils.image.TextureLoader; //导入依赖的package包/类
/**
 * �e�N�X�`�������[�h
 * 
 * @param filename �t�@�C����
 * @return �e�N�X�`��
 */
private Texture loadTexture(String filename) {
    Texture texture;

    texture = new TextureLoader(getClass().getResource(filename), null)
            .getTexture();

    return texture;
}
 
开发者ID:aidiary,项目名称:javagame,代码行数:15,代码来源:Ball.java


示例7: loadTexture

import com.sun.j3d.utils.image.TextureLoader; //导入依赖的package包/类
/**
 * �e�N�X�`�������[�h
 * @param filename �t�@�C����
 * @return �e�N�X�`��
 */
private Texture loadTexture(String filename) {
    Texture texture;
    
    texture = new TextureLoader(getClass().getResource(filename), null).getTexture();

    return texture;
}
 
开发者ID:aidiary,项目名称:javagame,代码行数:13,代码来源:CrystalBall.java


示例8: applyBackgroundImage

import com.sun.j3d.utils.image.TextureLoader; //导入依赖的package包/类
/**
 * Paste the default background image
 * @param root root of the 3d scene
 * @param schedulingBounds bounds
 */
private void applyBackgroundImage(BranchGroup root, BoundingSphere schedulingBounds) {
    ClassLoader cl = this.getClass().getClassLoader();
    java.net.URL u = cl.getResource("org/objectweb/proactive/examples/nbody/common/fondnbody3d.jpg");
    final Image backGround = getToolkit().getImage(u);
    TextureLoader starsTexture = new TextureLoader(backGround, this);

    Dimension tailleEcran = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    double hauteur = tailleEcran.getHeight();
    double largeur = tailleEcran.getWidth();
    Background stars = new Background(starsTexture.getScaledImage((int) largeur, (int) hauteur));
    //Background stars = new Background (starsTexture.getScaledImage(10000,10000));
    stars.setApplicationBounds(schedulingBounds);
    root.addChild(stars);
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:20,代码来源:NBody3DFrame.java


示例9: getTextureAppearance

import com.sun.j3d.utils.image.TextureLoader; //导入依赖的package包/类
Appearance getTextureAppearance(String path) throws Exception {
    Appearance appearance = new Appearance();
    TextureLoader pattern = new TextureLoader(ImageIO.read(getClass().getResource(path)), "RGB", this);
    appearance.setTexture(pattern.getTexture());
    return appearance;
}
 
开发者ID:tekrei,项目名称:JavaExamples,代码行数:7,代码来源:Java3DPanel.java


示例10: update

import com.sun.j3d.utils.image.TextureLoader; //导入依赖的package包/类
@Override
void update()
{
	int newEditId;
	if ((newEditId = volume.update()) != volumeEditId)
	{
		for (int i = 0; i < 6; i++)
		{
			boxLine[i].setCoordinates(0, volume.facePoints[i], 0, 4);
			boxLine[i].setCoordinate(4, volume.facePoints[i][0]);
			imageQuad[i].setCoordinates(0, volume.facePoints[i], 0, 4);
		}

		faceCenter[PLUS_X].set(volume.maxCoord.x, 0.0, 0.0);
		faceCenter[PLUS_Y].set(0.0, volume.maxCoord.y, 0.0);
		faceCenter[PLUS_Z].set(0.0, 0.0, volume.maxCoord.z);
		faceCenter[MINUS_X].set(volume.minCoord.x, 0.0, 0.0);
		faceCenter[MINUS_Y].set(0.0, volume.minCoord.y, 0.0);
		faceCenter[MINUS_Z].set(0.0, 0.0, volume.minCoord.z);
		volCenter.x = (volume.maxCoord.x + volume.minCoord.x) / 2;
		volCenter.y = (volume.maxCoord.y + volume.minCoord.y) / 2;
		volCenter.z = (volume.maxCoord.z + volume.minCoord.z) / 2;
		volumeEditId = newEditId;
	}
	eyePtChanged();
	for (int i = 0; i < 6; i++)
	{
		if (boxAttr[i].getValue() == true)
		{
			boxSwitch[i].setWhichChild(Switch.CHILD_ALL);
		} else
		{
			boxSwitch[i].setWhichChild(Switch.CHILD_NONE);
		}
		String curImageFile = imageAttr[i].getValue();
		if (curImageFile != imageFile[i])
		{
			imageFile[i] = curImageFile;
			if (imageFile[i].length() > 0)
			{
				try
				{
					URL imageURL = new URL(context.getCodeBase().toString()
							+ imageFile[i]);
					imageTexture[i] = new TextureLoader(imageURL, null)
							.getTexture();
				} catch (Exception e)
				{
					System.err.println("Error " + e + " loading image:"
							+ imageFile[i] + ".");
				}
			}
			imageAppearance[i].setTexture(imageTexture[i]);
			if (imageTexture[i] != null)
			{
				imageSwitch[i].setWhichChild(Switch.CHILD_ALL);
			} else
			{
				imageSwitch[i].setWhichChild(Switch.CHILD_NONE);
			}
		}
	}
}
 
开发者ID:TOMIGalway,项目名称:cmoct-sourcecode,代码行数:64,代码来源:Annotations.java


示例11: addAppearance

import com.sun.j3d.utils.image.TextureLoader; //导入依赖的package包/类
/**
 * Erzeugt eine Appearnace und fuegt die der Liste hinzu

 * @param item
 *            Der Key, iunter dem diese Apperance abgelegt wird
 * @param colors
 *            HashMap mit je Farbtyp und ASCII-Represenation der Farbe
 * @param textureFile
 *            Der Name des Texture-Files
 * @param clone
 *            Referenz auf einen schon bestehenden Eintrag, der geclonet
 *            werden soll
 */
@SuppressWarnings( { "unchecked", "boxing" })
private void addAppearance(char item, HashMap colors, String textureFile, String clone) {
	if (clone != null) {
		appearances.put(item, appearances.get(clone.toCharArray()[0]));
		return;
	}

	Appearance appearance = new Appearance();

	if (colors != null) {
		Material mat = new Material();

		Iterator it = colors.keySet().iterator();
		while (it.hasNext()) {
			String colorType = (String) it.next();
			String colorName = (String) colors.get(colorType);

			if (colorType.equals("ambient")) {
				mat.setAmbientColor(new Color3f(Color.decode(colorName)));
			}
			if (colorType.equals("diffuse")) {
				mat.setDiffuseColor(new Color3f(Color.decode(colorName)));
			}
			if (colorType.equals("specular")) {
				mat.setSpecularColor(new Color3f(Color.decode(colorName)));
			}
			if (colorType.equals("emmissive")) {
				mat.setEmissiveColor(new Color3f(Color.decode(colorName)));
			}
		}
		appearance.setMaterial(mat);
	}

	if (textureFile != null) {
		TexCoordGeneration tcg = new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR, TexCoordGeneration.TEXTURE_COORDINATE_3, new Vector4f(1.0f, 
			1.0f, 0.0f, 0.0f), new Vector4f(0.0f, 1.0f, 1.0f, 0.0f), new Vector4f(1.0f, 0.0f, 1.0f, 0.0f));
		appearance.setTexCoordGeneration(tcg);

		try {
			TextureLoader loader = new TextureLoader(ClassLoader.getSystemResource(textureFile), null);
			Texture2D texture = (Texture2D) loader.getTexture();
			texture.setBoundaryModeS(Texture.WRAP);
			texture.setBoundaryModeT(Texture.WRAP);

			// mache die Textur lesbar
			texture.setCapability(Texture.ALLOW_IMAGE_READ);
			ImageComponent[] imgs = texture.getImages();
			for (int i = 0; i < imgs.length; i++) {
				imgs[i].setCapability(ImageComponent.ALLOW_IMAGE_READ);
			}

			appearance.setTexture(texture);
			appearance.setCapability(Appearance.ALLOW_TEXTURE_READ);

		} catch (Exception e) {
			lg.warn(e, "Probleme beim Laden der Texturdatei '%s'", textureFile);
		}
	}

	appearances.put(item, appearance);
}
 
开发者ID:tsandmann,项目名称:ct-sim,代码行数:75,代码来源:ParcoursLoader.java


示例12: createTerrain

import com.sun.j3d.utils.image.TextureLoader; //导入依赖的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);
}
 
开发者ID:activityworkshop,项目名称:GpsPrune,代码行数:56,代码来源:Java3DWindow.java


示例13: extract

import com.sun.j3d.utils.image.TextureLoader; //导入依赖的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);
}
 
开发者ID:nerdouille,项目名称:silvie,代码行数:79,代码来源:CHRModel.java


示例14: createEnvironment

import com.sun.j3d.utils.image.TextureLoader; //导入依赖的package包/类
private void createEnvironment() {
    BranchGroup group = new BranchGroup();
    // Sky
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 1000.0);
    Background bg = new Background();
    bg.setApplicationBounds(bounds);
    BranchGroup backGeoBranch = new BranchGroup();
    Sphere skySphere = new Sphere(1.0f,
            Sphere.GENERATE_NORMALS | Sphere.GENERATE_NORMALS_INWARD | Sphere.GENERATE_TEXTURE_COORDS, 32);
    //        Sphere.GENERATE_NORMALS | Sphere.GENERATE_NORMALS_INWARD | Sphere.GENERATE_TEXTURE_COORDS, 32);
    Texture texSky = new TextureLoader("environment/sky.jpg", null).getTexture();
    skySphere.getAppearance().setTexture(texSky);
    Transform3D transformSky = new Transform3D();
    //transformSky.setTranslation(new Vector3d(0.0, 0.0, -0.5));
    Matrix3d rot = new Matrix3d();
    rot.rotX(Math.PI / 2);
    transformSky.setRotation(rot);
    TransformGroup tgSky = new TransformGroup(transformSky);
    tgSky.addChild(skySphere);
    backGeoBranch.addChild(tgSky);
    bg.setGeometry(backGeoBranch);
    group.addChild(bg);
    //group.addChild(tgSky);
    // Ground
    QuadArray polygon1 = new QuadArray(4, QuadArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2);
    polygon1.setCoordinate(0, new Point3f(-1000f, 1000f, 0f));
    polygon1.setCoordinate(1, new Point3f(1000f, 1000f, 0f));
    polygon1.setCoordinate(2, new Point3f(1000f, -1000f, 0f));
    polygon1.setCoordinate(3, new Point3f(-1000f, -1000f, 0f));
    polygon1.setTextureCoordinate(0, 0, new TexCoord2f(0.0f, 0.0f));
    polygon1.setTextureCoordinate(0, 1, new TexCoord2f(10.0f, 0.0f));
    polygon1.setTextureCoordinate(0, 2, new TexCoord2f(10.0f, 10.0f));
    polygon1.setTextureCoordinate(0, 3, new TexCoord2f(0.0f, 10.0f));
    Texture texGround = new TextureLoader("environment/grass2.jpg", null).getTexture();
    Appearance apGround = new Appearance();
    apGround.setTexture(texGround);
    Shape3D ground = new Shape3D(polygon1, apGround);
    Transform3D transformGround = new Transform3D();
    transformGround.setTranslation(
            new Vector3d(0.0, 0.0, 0.005 + world.getEnvironment().getGroundLevel(new Vector3d(0.0, 0.0, 0.0))));
    TransformGroup tgGround = new TransformGroup(transformGround);
    tgGround.addChild(ground);
    group.addChild(tgGround);

    // Light
    DirectionalLight light1 = new DirectionalLight(white, new Vector3f(4.0f, 7.0f, 12.0f));
    light1.setInfluencingBounds(sceneBounds);
    group.addChild(light1);
    AmbientLight light2 = new AmbientLight(new Color3f(0.5f, 0.5f, 0.5f));
    light2.setInfluencingBounds(sceneBounds);
    group.addChild(light2);

    // Update behavior
    Behavior b = new UpdateBehavior();
    b.setSchedulingBounds(bounds);
    group.addChild(b);
    universe.addBranchGraph(group);
}
 
开发者ID:DrTon,项目名称:jMAVSim,代码行数:59,代码来源:Visualizer3D.java



注:本文中的com.sun.j3d.utils.image.TextureLoader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Event类代码示例发布时间:2022-05-21
下一篇:
Java ProjectChooser类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap