本文整理汇总了Java中com.jme3.scene.Mesh.setMode方法的典型用法代码示例。如果您正苦于以下问题:Java Mesh.setMode方法的具体用法?Java Mesh.setMode怎么用?Java Mesh.setMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.scene.Mesh
的用法示例。
在下文中一共展示了Mesh.setMode方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculate
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
public void calculate() {
for (Spatial s : gNode.getChildren())
s.removeFromParent();
Mesh mesh = new Mesh();
mesh.setMode( Mode.Points );
Vector3f[] verts = new Vector3f[cubes.size()];
for (int i = 0; i < cubes.size(); i++) {
verts[ i ] = new com.jme3.math.Vector3f( (float)cubes.get( i ).x, (float)cubes.get( i ).y, (float)cubes.get( i ).z );
}
mesh.setBuffer( VertexBuffer.Type.Position, 3, BufferUtils.createFloatBuffer( verts ) );
Material mat1 = new Material( tweed.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md" );
mat1.setBoolean( "VertexColor", true );
Geometry depth = new Geometry( "depth", mesh );
depth.setMaterial( mat1 );
depth.updateModelBound();
depth.updateGeometricState();
gNode.attachChild(depth);
super.calculate();
}
示例2: 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;
}
示例3: 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;
}
示例4: convertToList
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public static void convertToList(Mesh mesh){
IndexBuffer inBuf = mesh.getIndicesAsList();
IndexBuffer outBuf = IndexBuffer.createIndexBuffer(mesh.getVertexCount(),
inBuf.size());
for (int i = 0; i < inBuf.size(); i++){
outBuf.put(i, inBuf.get(i));
}
mesh.clearBuffer(Type.Index);
switch (mesh.getMode()){
case LineLoop:
case LineStrip:
mesh.setMode(Mode.Lines);
break;
case TriangleStrip:
case TriangleFan:
mesh.setMode(Mode.Triangles);
break;
default:
break;
}
if (outBuf instanceof IndexIntBuffer){
mesh.setBuffer(Type.Index, 3, (IntBuffer)outBuf.getBuffer());
}else{
mesh.setBuffer(Type.Index, 3, (ShortBuffer)outBuf.getBuffer());
}
}
示例5: startSubMesh
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
private void startSubMesh(String matName, String usesharedvertices, String use32bitIndices, String opType) throws SAXException {
mesh = new Mesh();
if (opType == null || opType.equals("triangle_list")) {
mesh.setMode(Mesh.Mode.Triangles);
} else if (opType.equals("triangle_strip")) {
mesh.setMode(Mesh.Mode.TriangleStrip);
} else if (opType.equals("triangle_fan")) {
mesh.setMode(Mesh.Mode.TriangleFan);
}
usesBigIndices = parseBool(use32bitIndices, false);
usesSharedVerts = parseBool(usesharedvertices, false);
if (usesSharedVerts) {
// import vertexbuffers from shared geom
IntMap<VertexBuffer> sharedBufs = sharedMesh.getBuffers();
for (Entry<VertexBuffer> entry : sharedBufs) {
mesh.setBuffer(entry.getValue());
}
}
if (meshName == null) {
geom = new Geometry("OgreSubmesh-" + (++meshIndex), mesh);
} else {
geom = new Geometry(meshName + "-geom-" + (++meshIndex), mesh);
}
if (usesSharedVerts){
// this mesh is shared!
geom.setUserData(UserData.JME_SHAREDMESH, sharedMesh);
}
applyMaterial(geom, matName);
geoms.add(geom);
}
示例6: genNormalLines
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public static Mesh genNormalLines(Mesh mesh, float scale) {
FloatBuffer vertexBuffer = (FloatBuffer) mesh.getBuffer(Type.Position).getData();
FloatBuffer normalBuffer = (FloatBuffer) mesh.getBuffer(Type.Normal).getData();
ColorRGBA originColor = ColorRGBA.White;
ColorRGBA normalColor = ColorRGBA.Blue;
Mesh lineMesh = new Mesh();
lineMesh.setMode(Mesh.Mode.Lines);
Vector3f origin = new Vector3f();
Vector3f point = new Vector3f();
FloatBuffer lineVertex = BufferUtils.createFloatBuffer(vertexBuffer.capacity() * 2);
FloatBuffer lineColor = BufferUtils.createFloatBuffer(vertexBuffer.capacity() / 3 * 4 * 2);
for (int i = 0; i < vertexBuffer.capacity() / 3; i++) {
populateFromBuffer(origin, vertexBuffer, i);
populateFromBuffer(point, normalBuffer, i);
int index = i * 2;
setInBuffer(origin, lineVertex, index);
setInBuffer(originColor, lineColor, index);
point.multLocal(scale);
point.addLocal(origin);
setInBuffer(point, lineVertex, index + 1);
setInBuffer(normalColor, lineColor, index + 1);
}
lineMesh.setBuffer(Type.Position, 3, lineVertex);
lineMesh.setBuffer(Type.Color, 4, lineColor);
lineMesh.setStatic();
lineMesh.setInterleaved();
return lineMesh;
}
示例7: init
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
private void init(TransferFunctionEditor tfe, Node node) {
this.tfe = tfe;
buffer = new VertexBuffer(VertexBuffer.Type.Position);
buffer.setupData(VertexBuffer.Usage.Dynamic, 4, VertexBuffer.Format.Float, BufferUtils.createFloatBuffer(4 * points.size()));
this.node = new Node(name);
node.attachChild(this.node);
Mesh mesh1 = new Mesh();
mesh1.setMode(Mesh.Mode.LineStrip);
mesh1.setBuffer(buffer);
Material mat1 = new Material(tfe.app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat1.setColor("Color", color);
mat1.getAdditionalRenderState().setLineWidth(LINE_WIDTHS[0]);
Geometry geom1 = new Geometry(name, mesh1);
geom1.setMaterial(mat1);
geom1.setLocalScale(1, Y_SIZE, 1);
this.node.attachChild(geom1);
meshes[0] = mesh1;
geoms[0] = geom1;
Mesh mesh2 = new Mesh();
mesh2.setMode(Mesh.Mode.Points);
mesh2.setBuffer(buffer);
Material mat2 = new Material(tfe.app.getAssetManager(), "org/shaman/jmecl/utils/UnshadedPoint.j3md");
mat2.getAdditionalRenderState().setPointSprite(true);
mat2.setColor("Color", color);
Geometry geom2 = new Geometry(name+"_p", mesh2);
geom2.setMaterial(mat2);
geom2.setLocalScale(1, Y_SIZE, 1);
this.node.attachChild(geom2);
meshes[1] = mesh2;
geoms[1] = geom2;
}
示例8: genNormalLines
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public static Mesh genNormalLines(Mesh mesh, float scale) {
FloatBuffer vertexBuffer = (FloatBuffer) mesh.getBuffer(Type.Position).getData();
FloatBuffer normalBuffer = (FloatBuffer) mesh.getBuffer(Type.Normal).getData();
ColorRGBA originColor = ColorRGBA.White;
ColorRGBA normalColor = ColorRGBA.Blue;
Mesh lineMesh = new Mesh();
lineMesh.setMode(Mesh.Mode.Lines);
Vector3f origin = new Vector3f();
Vector3f point = new Vector3f();
FloatBuffer lineVertex = BufferUtils.createFloatBuffer(vertexBuffer.limit() * 2);
FloatBuffer lineColor = BufferUtils.createFloatBuffer(vertexBuffer.limit() / 3 * 4 * 2);
for (int i = 0; i < vertexBuffer.limit() / 3; i++) {
populateFromBuffer(origin, vertexBuffer, i);
populateFromBuffer(point, normalBuffer, i);
int index = i * 2;
setInBuffer(origin, lineVertex, index);
setInBuffer(originColor, lineColor, index);
point.multLocal(scale);
point.addLocal(origin);
setInBuffer(point, lineVertex, index + 1);
setInBuffer(normalColor, lineColor, index + 1);
}
lineMesh.setBuffer(Type.Position, 3, lineVertex);
lineMesh.setBuffer(Type.Color, 4, lineColor);
lineMesh.setStatic();
// lineMesh.setInterleaved();
return lineMesh;
}
示例9: genTangentLines
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
private static Mesh genTangentLines(Mesh mesh, float scale) {
FloatBuffer vertexBuffer = (FloatBuffer) mesh.getBuffer(Type.Position).getData();
FloatBuffer normalBuffer = (FloatBuffer) mesh.getBuffer(Type.Normal).getData();
FloatBuffer tangentBuffer = (FloatBuffer) mesh.getBuffer(Type.Tangent).getData();
FloatBuffer binormalBuffer = null;
if (mesh.getBuffer(Type.Binormal) != null) {
binormalBuffer = (FloatBuffer) mesh.getBuffer(Type.Binormal).getData();
}
ColorRGBA originColor = ColorRGBA.White;
ColorRGBA tangentColor = ColorRGBA.Red;
ColorRGBA binormalColor = ColorRGBA.Green;
ColorRGBA normalColor = ColorRGBA.Blue;
Mesh lineMesh = new Mesh();
lineMesh.setMode(Mesh.Mode.Lines);
Vector3f origin = new Vector3f();
Vector3f point = new Vector3f();
Vector3f tangent = new Vector3f();
Vector3f normal = new Vector3f();
IntBuffer lineIndex = BufferUtils.createIntBuffer(vertexBuffer.capacity() / 3 * 6);
FloatBuffer lineVertex = BufferUtils.createFloatBuffer(vertexBuffer.capacity() * 4);
FloatBuffer lineColor = BufferUtils.createFloatBuffer(vertexBuffer.capacity() / 3 * 4 * 4);
for (int i = 0; i < vertexBuffer.capacity() / 3; i++) {
populateFromBuffer(origin, vertexBuffer, i);
populateFromBuffer(normal, normalBuffer, i);
populateFromBuffer(tangent, tangentBuffer, i);
int index = i * 4;
int id = i * 6;
lineIndex.put(id, index);
lineIndex.put(id + 1, index + 1);
lineIndex.put(id + 2, index);
lineIndex.put(id + 3, index + 2);
lineIndex.put(id + 4, index);
lineIndex.put(id + 5, index + 3);
setInBuffer(origin, lineVertex, index);
setInBuffer(originColor, lineColor, index);
point.set(tangent);
point.multLocal(scale);
point.addLocal(origin);
setInBuffer(point, lineVertex, index + 1);
setInBuffer(tangentColor, lineColor, index + 1);
if (binormalBuffer == null) {
normal.cross(tangent, point);
point.normalizeLocal();
}
else {
populateFromBuffer(point, binormalBuffer, i);
}
point.multLocal(scale);
point.addLocal(origin);
setInBuffer(point, lineVertex, index + 2);
setInBuffer(binormalColor, lineColor, index + 2);
point.set(normal);
point.multLocal(scale);
point.addLocal(origin);
setInBuffer(point, lineVertex, index + 3);
setInBuffer(normalColor, lineColor, index + 3);
}
lineMesh.setBuffer(Type.Index, 1, lineIndex);
lineMesh.setBuffer(Type.Position, 3, lineVertex);
lineMesh.setBuffer(Type.Color, 4, lineColor);
lineMesh.setStatic();
lineMesh.setInterleaved();
return lineMesh;
}
示例10: 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);
}
示例11: 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 ############################
}
示例12: render
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
public void render( Tweed tweed, Node gNode, ColorRGBA color, float width ) {
Mesh m = new Mesh();
m.setMode( Mesh.Mode.Lines );
List<Float> coords = new ArrayList();
List<Integer> inds = new ArrayList();
for ( Pair<Point3d, Point3d> p : new ConsecutiveItPairs<>( get3D() ) ) {
inds.add( inds.size() );
inds.add( inds.size() );
coords.add( (float) p.first().x );
coords.add( (float) p.first().y );
coords.add( (float) p.first().z );
coords.add( (float) p.second().x );
coords.add( (float) p.second().y );
coords.add( (float) p.second().z );
}
m.setBuffer( VertexBuffer.Type.Position, 3, Arrayz.toFloatArray( coords ) );
m.setBuffer( VertexBuffer.Type.Index, 2, Arrayz.toIntArray( inds ) );
Geometry geom = new Geometry( "profile", m );
Material lineMaterial = new Material( tweed.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md" );
lineMaterial.getAdditionalRenderState().setLineWidth( Math.max (1f, width ) );
lineMaterial.setColor( "Color", color == null ? ColorRGBA.Blue : color );
geom.setMaterial( lineMaterial );
geom.updateGeometricState();
geom.updateModelBound();
gNode.attachChild( geom );
}
示例13: initialize
import com.jme3.scene.Mesh; //导入方法依赖的package包/类
@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
SebEvents.events.addListener("cmd_clear_points_buffer", this);
// ######################## BEGIN Add point cloud geometry ###########################
pointCloudMesh = new Mesh();
pointCloudMesh.setMode(Mesh.Mode.Points);
// TODO 2: Find replacements for setPointSize() and setLineWidth()
//pointCloudMesh.setPointSize(4);
clearPointCloud();
pointCloudGeometry = new Geometry("pointCloud", pointCloudMesh);
Material pointCloudMaterial = new Material(mAssetManager, "Common/MatDefs/Misc/Unshaded.j3md");
Color4f col = sim.pointCloudColor;
if (col != null) {
pointCloudMaterial.setColor("Color", new ColorRGBA(col.x, col.y, col.z, col.w));
} else {
pointCloudMaterial.setColor("Color", new ColorRGBA(1, 1, 0, 1));
}
pointCloudGeometry.setMaterial(pointCloudMaterial);
mWorldNode.attachChild(pointCloudGeometry);
// ##################### END Add point cloud geometry ###########################
inputManager.addMapping("clearPointCloud", new KeyTrigger(KeyInput.KEY_F12));
inputManager.addListener(actionListener, "clearPointCloud");
}