当前位置: 首页>>代码示例>>Java>>正文


Java Mesh.updateBound方法代码示例

本文整理汇总了Java中com.jme3.scene.Mesh.updateBound方法的典型用法代码示例。如果您正苦于以下问题:Java Mesh.updateBound方法的具体用法?Java Mesh.updateBound怎么用?Java Mesh.updateBound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jme3.scene.Mesh的用法示例。


在下文中一共展示了Mesh.updateBound方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convert

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public static Mesh convert(IndexedMesh mesh) {
    Mesh jmeMesh = new Mesh();

    jmeMesh.setBuffer(Type.Index, 3, BufferUtils.createShortBuffer(mesh.numTriangles * 3));
    jmeMesh.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(mesh.numVertices * 3));

    IndexBuffer indicess = jmeMesh.getIndexBuffer();
    FloatBuffer vertices = jmeMesh.getFloatBuffer(Type.Position);

    for (int i = 0; i < mesh.numTriangles * 3; i++) {
        indicess.put(i, mesh.triangleIndexBase.getInt(i * 4));
    }

    for (int i = 0; i < mesh.numVertices * 3; i++) {
        vertices.put(i, mesh.vertexBase.getFloat(i * 4));
    }
    jmeMesh.updateCounts();
    jmeMesh.updateBound();
    jmeMesh.getFloatBuffer(Type.Position).clear();

    return jmeMesh;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:Converter.java

示例2: generateMesh

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public void generateMesh(){
    try{
        System.out.println("Starting chunk generation: " + chunk.getChunkCoordinates());
        long startAt = System.currentTimeMillis();

        int cx, cy, cz;
        for(cy=0;cy<Chunk.CHUNK_HEIGHT;++cy){
            for(cx=0;cx<Chunk.CHUNK_SIZE;++cx){
                for(cz=0;cz<Chunk.CHUNK_SIZE;++cz){
                    generateBlock(cx, cy, cz);
                }
            }
        }

        Vector3f[] verticesArray = vertices.toArray(new Vector3f[vertices.size()]);
        Vector2f[] texCoordsArray = texCoords.toArray(new Vector2f[texCoords.size()]);
        int[] indicesArray = new int[indices.size()];
        for(int x=0;x<indicesArray.length;++x){
            indicesArray[x] = indices.get(x);
        }

        mesh = new Mesh();
        mesh.setBuffer(VertexBuffer.Type.Position, 3, BufferUtils.createFloatBuffer(verticesArray));
        mesh.setBuffer(VertexBuffer.Type.TexCoord, 2, BufferUtils.createFloatBuffer(texCoordsArray));
        mesh.setBuffer(VertexBuffer.Type.Index, 3, BufferUtils.createIntBuffer(indicesArray));
        mesh.updateBound();

        System.out.println("Finished chunk generation: " + chunk.getChunkCoordinates() + " in " + (System.currentTimeMillis() - startAt) + "ms");
    }catch(Throwable t){
        t.printStackTrace();
    }
}
 
开发者ID:DA-CS-Lab,项目名称:Victorum,代码行数:33,代码来源:ChunkMeshGenerator.java

示例3: simpleInitApp

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
    public void simpleInitApp() {
//        flyCam.setEnabled(false);

        // load material
        Material mat = (Material) assetManager.loadAsset(new AssetKey("Interface/Logo/Logo.j3m"));

        Mesh q = new Mesh();
        q.setBuffer(Type.Position, 3, new float[]
        {
            1, 0, 0,
            0, 1.5f, 0,
            -1, 0, 0
        }
        );
        q.setBuffer(Type.Index, 3, new int[]{ 0, 1, 2 });
        q.setBound(new BoundingSphere());
        q.updateBound();
//        Geometry teapot = new Geometry("MyGeom", q);

        teapot = assetManager.loadModel("Models/Teapot/Teapot.mesh.xml");
//        teapot.scale(2f, 2f, 2f);
//        teapot.move(2f, 2f, -.5f);
        teapot.rotate(FastMath.HALF_PI, FastMath.HALF_PI, FastMath.HALF_PI);
        teapot.setMaterial(mat);
        rootNode.attachChild(teapot);

//        cam.setLocation(cam.getLocation().add(0,1,0));
//        cam.lookAt(teapot.getWorldBound().getCenter(), Vector3f.UNIT_Y);

        tracer = new RayTrace(rootNode, cam, 160, 128);
        tracer.show();
        tracer.update();
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:35,代码来源:TestRayCasting.java

示例4: createTriangleStripMesh

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
private Mesh createTriangleStripMesh() {
      Mesh strip = new Mesh();
      strip.setMode(Mode.TriangleStrip);
      FloatBuffer vb = BufferUtils.createFloatBuffer(3*3*3); // 3 rows * 3 columns * 3 floats
      vb.rewind();
      vb.put(new float[]{0,2,0}); vb.put(new float[]{1,2,0}); vb.put(new float[]{2,2,0});
      vb.put(new float[]{0,1,0}); vb.put(new float[]{1,1,0}); vb.put(new float[]{2,1,0});
      vb.put(new float[]{0,0,0}); vb.put(new float[]{1,0,0}); vb.put(new float[]{2,0,0});
      FloatBuffer nb = BufferUtils.createFloatBuffer(3*3*3);
      nb.rewind();
      nb.put(new float[]{0,0,1}); nb.put(new float[]{0,0,1}); nb.put(new float[]{0,0,1});
      nb.put(new float[]{0,0,1}); nb.put(new float[]{0,0,1}); nb.put(new float[]{0,0,1});
      nb.put(new float[]{0,0,1}); nb.put(new float[]{0,0,1}); nb.put(new float[]{0,0,1});
      FloatBuffer tb = BufferUtils.createFloatBuffer(3*3*2);
      tb.rewind();
      tb.put(new float[]{0,0}); tb.put(new float[]{0.5f,0}); tb.put(new float[]{1,0});
      tb.put(new float[]{0,0.5f}); tb.put(new float[]{0.5f,0.5f}); tb.put(new float[]{1,0.5f});
      tb.put(new float[]{0,1}); tb.put(new float[]{0.5f,1}); tb.put(new float[]{1,1});
      int[] indexes = new int[]{0,3,1,4,2,5, 5,3, 3,6,4,7,5,8};
      IntBuffer ib = BufferUtils.createIntBuffer(indexes.length);
      ib.put(indexes);
      strip.setBuffer(Type.Position, 3, vb);
strip.setBuffer(Type.Normal, 3, nb);
strip.setBuffer(Type.TexCoord, 2, tb);
strip.setBuffer(Type.Index, 3, ib);
      strip.updateBound();
      return strip;
  }
 
开发者ID:mleoking,项目名称:PhET,代码行数:29,代码来源:TestTangentGen.java

示例5: createMesh

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public Mesh createMesh(Vector3f scale, Vector2f tcScale, boolean center){
    FloatBuffer pb = writeVertexArray(null, scale, center);
    FloatBuffer tb = writeTexCoordArray(null, Vector2f.ZERO, tcScale);
    FloatBuffer nb = writeNormalArray(null, scale);
    IntBuffer ib = writeIndexArray(null);
    Mesh m = new Mesh();
    m.setBuffer(Type.Position, 3, pb);
    m.setBuffer(Type.Normal, 3, nb);
    m.setBuffer(Type.TexCoord, 2, tb);
    m.setBuffer(Type.Index, 3, ib);
    m.setStatic();
    m.updateBound();
    return m;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:15,代码来源:AbstractGeomap.java

示例6: createMesh

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public Mesh createMesh(Vector3f scale, Vector2f tcScale, Vector2f tcOffset, float offsetAmount, int totalSize, boolean center, int lod, boolean rightLod, boolean topLod, boolean leftLod, boolean bottomLod) {
    FloatBuffer pb = writeVertexArray(null, scale, center);
    FloatBuffer tb = writeTexCoordArray(null, tcOffset, tcScale, offsetAmount, totalSize);
    FloatBuffer nb = writeNormalArray(null, scale);
    IntBuffer ib = writeIndexArrayLodDiff(null, lod, rightLod, topLod, leftLod, bottomLod);
    Mesh m = new Mesh();
    m.setMode(Mode.TriangleStrip);
    m.setBuffer(Type.Position, 3, pb);
    m.setBuffer(Type.Normal, 3, nb);
    m.setBuffer(Type.TexCoord, 2, tb);
    m.setBuffer(Type.Index, 3, ib);
    m.setStatic();
    m.updateBound();
    return m;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:LODGeomap.java

示例7: makeBatches

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
/**
 * Batches a collection of Geometries so that all with the same material get combined.
 * @param geometries The Geometries to combine
 * @return A List of newly created Geometries, each with a  distinct material
 */
public static List<Geometry> makeBatches(Collection<Geometry> geometries, boolean useLods) {
    ArrayList<Geometry> retVal = new ArrayList<Geometry>();
    HashMap<Material, List<Geometry>> matToGeom = new HashMap<Material, List<Geometry>>();

    for (Geometry geom : geometries) {
        List<Geometry> outList = matToGeom.get(geom.getMaterial());
        if (outList == null) {
            outList = new ArrayList<Geometry>();
            matToGeom.put(geom.getMaterial(), outList);
        }
        outList.add(geom);
    }

    int batchNum = 0;
    for (Map.Entry<Material, List<Geometry>> entry : matToGeom.entrySet()) {
        Material mat = entry.getKey();
        List<Geometry> geomsForMat = entry.getValue();
        Mesh mesh = new Mesh();
        mergeGeometries(geomsForMat, mesh);
        // lods
        if (useLods) {
            makeLods(geomsForMat, mesh);
        }
        mesh.updateCounts();
        mesh.updateBound();

        Geometry out = new Geometry("batch[" + (batchNum++) + "]", mesh);
        out.setMaterial(mat);
        retVal.add(out);
    }

    return retVal;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:39,代码来源:GeometryBatchFactory.java

示例8: optimize

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public static void optimize(Mesh mesh, boolean toFixed){
        // update any data that need updating
        mesh.updateBound();
        mesh.updateCounts();

        // set all buffers into STATIC_DRAW mode
        mesh.setStatic();

        if (mesh.getBuffer(Type.Index) != null){
            // compress index buffer from UShort to UByte (if possible)
            FloatToFixed.compressIndexBuffer(mesh);

            // generate triangle strips stitched with degenerate tris
            generateStrips(mesh, false, false, 16, 0);
        }

        IntMap<VertexBuffer> bufs = mesh.getBuffers();
        for (Entry<VertexBuffer> entry : bufs){
            VertexBuffer vb = entry.getValue();
            if (vb == null || vb.getBufferType() == Type.Index)
                continue;

             if (vb.getFormat() == Format.Float){
                if (vb.getBufferType() == Type.Color){
                    // convert the color buffer to UByte
                    vb = FloatToFixed.convertToUByte(vb);
                    vb.setNormalized(true);
                }else if (toFixed){
                    // convert normals, positions, and texcoords
                    // to fixed-point (16.16)
                    vb = FloatToFixed.convertToFixed(vb);
//                    vb = FloatToFixed.convertToFloat(vb);
                }
                mesh.clearBuffer(vb.getBufferType());
                mesh.setBuffer(vb);
            }
        }
        mesh.setInterleaved();
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:40,代码来源:ModelConverter.java

示例9: optimize

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public Mesh optimize(Mesh mesh) {
    nmgen = new NavmeshGenerator(cellSize, cellHeight, minTraversableHeight,
            maxTraversableStep, maxTraversableSlope,
            clipLedges, traversableAreaBorderSize,
            smoothingThreshold, useConservativeExpansion,
            minUnconnectedRegionSize, mergeRegionSize,
            maxEdgeLength, edgeMaxDeviation, maxVertsPerPoly,
            contourSampleDistance, contourMaxDeviation);

    FloatBuffer pb = mesh.getFloatBuffer(Type.Position);
    IndexBuffer ib = mesh.getIndexBuffer();

    // copy positions to float array
    float[] positions = new float[pb.capacity()];
    pb.clear();
    pb.get(positions);

    // generate int array of indices
    int[] indices = new int[ib.size()];
    for (int i = 0; i < indices.length; i++) {
        indices[i] = ib.get(i);
    }


    TriangleMesh triMesh = buildNavMesh(positions, indices, intermediateData);
    if (triMesh == null) {
        return null;
    }

    int[] indices2 = triMesh.indices;
    float[] positions2 = triMesh.vertices;

    Mesh mesh2 = new Mesh();
    mesh2.setBuffer(Type.Position, 3, positions2);
    mesh2.setBuffer(Type.Index, 3, indices2);
    mesh2.updateBound();
    mesh2.updateCounts();

    return mesh2;
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:41,代码来源:NavMeshGenerator.java

示例10: render

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public Spatial render( Tweed tweed ) {

			
			if (a == null  || b == null)
				return null;
			
			Mesh mesh1 = new Mesh();
			{
				Vector3f[] vertices = new Vector3f[4];
				vertices[ 0 ] = new Vector3f( a.x, heightMin, a.z );
				vertices[ 1 ] = new Vector3f( a.x, heightMax, a.z );
				vertices[ 2 ] = new Vector3f( b.x, heightMin, b.z );
				vertices[ 3 ] = new Vector3f( b.x, heightMax, b.z );

				Vector3f[] texCoord = new Vector3f[4];
				texCoord[ 0 ] = new Vector3f( 0, 0, 0 );
				texCoord[ 1 ] = new Vector3f( 1, 0, 0 );
				texCoord[ 2 ] = new Vector3f( 0, 1, 0 );
				texCoord[ 3 ] = new Vector3f( 1, 1, 0 );

				int[] indexes = { 0, 1, 3, 3, 2, 0, 3, 1, 0, 0, 2, 3 };

				mesh1.setBuffer( VertexBuffer.Type.Position, 3, BufferUtils.createFloatBuffer( vertices ) );

				mesh1.setBuffer( VertexBuffer.Type.TexCoord, 3, BufferUtils.createFloatBuffer( texCoord ) );
				mesh1.setBuffer( VertexBuffer.Type.Index, 3, BufferUtils.createIntBuffer( indexes ) );
				mesh1.updateBound();
			}
			Material mat = new Material( tweed.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md" );
			mat.getAdditionalRenderState().setBlendMode( BlendMode.Alpha );
			mat.setColor( "Color", new ColorRGBA( color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 0.5f ) );

			//		Material mat = new Material(tweed.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");

			Geometry spat = new Geometry( "Box", mesh1 );
			spat.setMaterial( mat );

			

			return spat;
		}
 
开发者ID:twak,项目名称:chordatlas,代码行数:42,代码来源:PlanesGen.java

示例11: terrain2mesh

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public Mesh terrain2mesh(Terrain terr) {
    float[] heights = terr.getHeightMap();
    int length = heights.length;
    int side = (int) FastMath.sqrt(heights.length);
    float[] vertices = new float[length * 3];
    int[] indices = new int[(side - 1) * (side - 1) * 6];

    //Vector3f trans = ((Node) terr).getWorldTranslation().clone();
    Vector3f trans = new Vector3f(0,0,0);
    trans.x -= terr.getTerrainSize() / 2f;
    trans.z -= terr.getTerrainSize() / 2f;
    float offsetX = trans.x;
    float offsetZ = trans.z;

    // do vertices
    int i = 0;
    for (int z = 0; z < side; z++) {
        for (int x = 0; x < side; x++) {
            vertices[i++] = x + offsetX;
            vertices[i++] = heights[z * side + x];
            vertices[i++] = z + offsetZ;
        }
    }

    // do indexes
    i = 0;
    for (int z = 0; z < side - 1; z++) {
        for (int x = 0; x < side - 1; x++) {
            // triangle 1
            indices[i++] = z * side + x;
            indices[i++] = (z + 1) * side + x;
            indices[i++] = (z + 1) * side + x + 1;
            // triangle 2
            indices[i++] = z * side + x;
            indices[i++] = (z + 1) * side + x + 1;
            indices[i++] = z * side + x + 1;
        }
    }

    Mesh mesh2 = new Mesh();
    mesh2.setBuffer(Type.Position, 3, vertices);
    mesh2.setBuffer(Type.Index, 3, indices);
    mesh2.updateBound();
    mesh2.updateCounts();

    return mesh2;
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:48,代码来源:NavMeshGenerator.java

示例12: createCone

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
private static Mesh createCone(int radialSamples, float radius, float height) {
    Mesh cone = new Mesh();

    float fInvRS = 1.0f / radialSamples;

    // Generate points on the unit circle to be used in computing the mesh
    // points on a dome slice.
    float[] afSin = new float[radialSamples];
    float[] afCos = new float[radialSamples];
    for (int i = 0; i < radialSamples; i++) {
        float fAngle = FastMath.TWO_PI * fInvRS * i;
        afCos[i] = FastMath.cos(fAngle);
        afSin[i] = FastMath.sin(fAngle);
    }

    FloatBuffer vb = BufferUtils.createVector3Buffer(radialSamples + 2);
    cone.setBuffer(Type.Position, 3, vb);

    TempVars vars = TempVars.get();
    Vector3f tempVa = vars.vect1;

    for (int i = 0; i < radialSamples; i++) {
        Vector3f kRadial = tempVa.set(afCos[i], 0, afSin[i]);
        kRadial.mult(radius, tempVa);
        vb.put(tempVa.x).put(tempVa.y).put(tempVa.z);

        BufferUtils.populateFromBuffer(tempVa, vb, i);

    }
    vars.release();

    // top of the cone
    vb.put(0).put(height).put(0);
    // base of the cone
    vb.put(0).put(0).put(0);

    ShortBuffer ib = BufferUtils.createShortBuffer(3 * (radialSamples) * 2);
    cone.setBuffer(Type.Index, 3, ib);

    short top = (short) radialSamples;
    short bot = (short) (radialSamples + 1);

    for (int i = 0; i < radialSamples; i++) {
        short a = (short) i;
        short b = (short) ((i + 1) % radialSamples);
        ib.put(top);
        ib.put(b);
        ib.put(a);

        ib.put(a);
        ib.put(b);
        ib.put(bot);
    }

    cone.updateBound();

    return cone;
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:59,代码来源:SceneEditTool.java

示例13: simpleInitApp

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
public final void simpleInitApp() {
	clContext = context.getOpenCLContext();
	if (debugContext) {
		clContext = DebugContextFactory.createDebugContext(clContext);
	}
	if (loggingContext) {
		clContext = LoggingContextFactory.createLoggingContext(clContext);
	}
	clCommandQueue = clContext.createQueue();
	clSettings = new OpenCLSettings(clContext, clCommandQueue, null, assetManager);
	
	solver = new FluidSolver(clSettings, resolutionX, resolutionY);
	initialized = true;
	realGrids = new ArrayList<>();
	macGrids = new ArrayList<>();
	flagGrids = new ArrayList<>();
	initSolver(solver);
	
	infoText = new BitmapText(guiFont, false);
	infoText.setSize(guiFont.getCharSet().getRenderedSize());
	infoText.setColor(ColorRGBA.White);
	guiNode.attachChild(infoText);
	
	debugTools = new DebugTools(solver);
	int size = Math.min(settings.getHeight() - 10, settings.getWidth() - X_OFFSET - 5);
	int offsetX = settings.getWidth() - size - 5;
	
	tfe = new TransferFunctionEditor(true);
	tfe.initialize(this);
	Spatial tfeNode = tfe.getView();
	guiNode.attachChild(tfeNode);
	tfeNode.setLocalScale(X_OFFSET-10, 150, 1);
	tfeNode.setLocalTranslation(5, 5, 0);
	
	Mesh boundsMesh = new Mesh();
	boundsMesh.setBuffer(VertexBuffer.Type.Position, 3, new float[]{0,0,0, 1,0,0, 1,1,0, 0,1,0});
	boundsMesh.setMode(Mesh.Mode.LineLoop);
	boundsMesh.updateCounts();
	boundsMesh.updateBound();
	boundsGeometry = new Geometry("bounds", boundsMesh);
	Material boundsMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
	boundsMat.setColor("Color", ColorRGBA.Blue);
	boundsGeometry.setMaterial(boundsMat);
	boundsGeometry.setLocalTranslation(offsetX, (settings.getHeight()-size)/2-1, 0);
	boundsGeometry.setLocalScale(size+2);
	boundsGeometry.setQueueBucket(RenderQueue.Bucket.Gui);
	guiNode.attachChild(boundsGeometry);
	
	realTexture = debugTools.createRealTexture2D(renderManager);
	realGeometry = new Geometry("realGrid", new Quad(1, 1));
	realMaterial = new Material(assetManager, "org/shaman/jmecl/test/ColorRamped.j3md");
	realMaterial.setTexture("ColorMap", realTexture.getJMETexture());
	realMaterial.setTexture("ColorRamp", tfe.getTextures()[0]);
	realMaterial.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
	realMaterial.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
	realGeometry.setMaterial(realMaterial);
	realGeometry.setLocalTranslation(offsetX, (settings.getHeight()-size)/2, 0);
	realGeometry.setLocalScale(size);
	realGeometry.setQueueBucket(RenderQueue.Bucket.Gui);
	guiNode.attachChild(realGeometry);
	
	flagTexture = debugTools.createFlagTexture2D(renderManager);
	flagGeometry = new Geometry("flagGrid", new Quad(1, 1));
	flagMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
	flagMaterial.setTexture("ColorMap", flagTexture.getJMETexture());
	flagMaterial.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
	flagMaterial.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
	flagGeometry.setMaterial(flagMaterial);
	flagGeometry.setLocalTranslation(offsetX, (settings.getHeight()-size)/2, 1);
	flagGeometry.setLocalScale(size);
	flagGeometry.setQueueBucket(RenderQueue.Bucket.Gui);
	guiNode.attachChild(flagGeometry);
	
	inputManager.setCursorVisible(true);
	inputManager.addMapping(KEY_RUN, new KeyTrigger(KeyInput.KEY_R));
	inputManager.addListener(new KeyListener(), KEY_RUN);
}
 
开发者ID:shamanDevel,项目名称:jME3-OpenCL-Library,代码行数:79,代码来源:AbstractFluidTest2D.java

示例14: initialize

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
public void initialize(AppStateManager stateManager, Application app) {
	super.initialize(stateManager, app);

	playback = (SurveyPlayback) sim;

	// ################## BEGIN Add platform, scanner and emitter nodes #################
	// Add platform node:
	platformNode = new Node("platformNode");
	mWorldNode.attachChild(platformNode);

	// Add mount node:
	mountNode = new Node("mountNode");
	platformNode.attachChild(mountNode);

	// Add scammer node:
	scannerNode = new Node("scannerNode");
	mountNode.attachChild(scannerNode);

	// Add emitter node:
	emitterNode = new Node("emitterNode");
	scannerNode.attachChild(emitterNode);

	if (mApp.chaseCam == null) {
		mApp.chaseCam = new ChaseCamera(mApp.getCamera(), rootNode.getChild("mountNode"), inputManager);
		// chaseCam = new ChaseCamera(cam, inputManager);
		mApp.chaseCam.setTrailingEnabled(false);
		mApp.chaseCam.setMaxDistance(200);
		mApp.chaseCam.setSmoothMotion(true);
	}
	// ################## END Add platform, scanner and emitter nodes #################

	// ############################ BEGIN Add laser beam geometry ################################

	Mesh beamMesh = new Mesh();

	beamMesh.setMode(Mesh.Mode.Lines);
	beamMesh.setLineWidth(cfg_laserBeamWidth_pixels);
	beamMesh.setBuffer(VertexBuffer.Type.Position, 3, new float[] { 0, 0, 0, 0, 1, 0 });
	beamMesh.setBuffer(VertexBuffer.Type.Index, 2, new short[] { 0, 1 });
	beamMesh.updateBound();
	beamMesh.updateCounts();

	beamGeometry = new Geometry("beam", beamMesh);

	Material beamMaterial = new Material(mAssetManager, "Common/MatDefs/Misc/Unshaded.j3md");
	beamMaterial.setColor("Color", new ColorRGBA(255, 0, 0, 0));
	// lineMaterial.setColor("GlowColor", ColorRGBA.Red);

	beamGeometry.setMaterial(beamMaterial);

	emitterNode.attachChild(beamGeometry);

	// Initialize beam geometry with zero y scale to make it invisible before the scanner is started:
	beamGeometry.setLocalScale(1, 0, 1);

	// ############################### END Add laser beam geometry ############################

}
 
开发者ID:GIScience,项目名称:helios,代码行数:60,代码来源:ShowPlatformAndScannerAppState.java

示例15: createCone

import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public static Mesh createCone(int radialSamples, float radius, float height) {
    Mesh cone = new Mesh();

    float fInvRS = 1.0f / radialSamples;

    // Generate points on the unit circle to be used in computing the mesh
    // points on a dome slice.
    float[] afSin = new float[radialSamples];
    float[] afCos = new float[radialSamples];
    for (int i = 0; i < radialSamples; i++) {
        float fAngle = FastMath.TWO_PI * fInvRS * i;
        afCos[i] = FastMath.cos(fAngle);
        afSin[i] = FastMath.sin(fAngle);
    }

    FloatBuffer vb = BufferUtils.createVector3Buffer(radialSamples + 2);
    cone.setBuffer(VertexBuffer.Type.Position, 3, vb);

    TempVars vars = TempVars.get();
    Vector3f tempVa = vars.vect1;

    for (int i = 0; i < radialSamples; i++) {
        Vector3f kRadial = tempVa.set(afCos[i], 0, afSin[i]);
        kRadial.mult(radius, tempVa);
        vb.put(tempVa.x).put(tempVa.y).put(tempVa.z);

        BufferUtils.populateFromBuffer(tempVa, vb, i);

    }
    vars.release();

    // top of the cone
    vb.put(0).put(height).put(0);
    // base of the cone
    vb.put(0).put(0).put(0);

    ShortBuffer ib = BufferUtils.createShortBuffer(3 * (radialSamples) * 2);
    cone.setBuffer(VertexBuffer.Type.Index, 3, ib);

    short top = (short) radialSamples;
    short bot = (short) (radialSamples + 1);

    for (int i = 0; i < radialSamples; i++) {
        short a = (short) i;
        short b = (short) ((i + 1) % radialSamples);
        ib.put(top);
        ib.put(b);
        ib.put(a);

        ib.put(a);
        ib.put(b);
        ib.put(bot);
    }

    cone.updateBound();

    return cone;
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:59,代码来源:GeometryUtils.java


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