本文整理汇总了Java中com.jme3.scene.VertexBuffer类的典型用法代码示例。如果您正苦于以下问题:Java VertexBuffer类的具体用法?Java VertexBuffer怎么用?Java VertexBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VertexBuffer类属于com.jme3.scene包,在下文中一共展示了VertexBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: useStandardGenerator
import com.jme3.scene.VertexBuffer; //导入依赖的package包/类
/**
* Generate tangents using a standard algorithm.
*
* @param spatial the spatial.
* @param splitMirrored the split mirrored.
*/
public static void useStandardGenerator(@NotNull final Spatial spatial, final boolean splitMirrored) {
try {
NodeUtils.visitGeometry(spatial, geometry -> {
final Mesh mesh = geometry.getMesh();
final VertexBuffer texCoord = mesh.getBuffer(VertexBuffer.Type.TexCoord);
if (texCoord != null) {
TangentBinormalGenerator.generate(geometry, splitMirrored);
}
});
} catch (final Exception e) {
EditorUtil.handleException(LOGGER, null, e);
}
}
示例2: useMikktspaceGenerator
import com.jme3.scene.VertexBuffer; //导入依赖的package包/类
/**
* Generate tangents using a Mikktspace algorithm.
*
* @param spatial the spatial.
*/
public static void useMikktspaceGenerator(@NotNull final Spatial spatial) {
try {
NodeUtils.visitGeometry(spatial, geometry -> {
final Mesh mesh = geometry.getMesh();
final VertexBuffer texCoord = mesh.getBuffer(VertexBuffer.Type.TexCoord);
if (texCoord != null) {
MikktspaceTangentGenerator.generate(geometry);
}
});
} catch (final Exception e) {
EditorUtil.handleException(LOGGER, null, e);
}
}
示例3: updateItem
import com.jme3.scene.VertexBuffer; //导入依赖的package包/类
@Override
protected void updateItem(@Nullable final Integer level, final boolean empty) {
super.updateItem(level, empty);
final Geometry geometry = getEditObject();
final Mesh mesh = geometry.getMesh();
if (level == null || mesh == null) {
setText("None");
return;
}
int elements;
if (level < mesh.getNumLodLevels()) {
final VertexBuffer lodLevel = mesh.getLodLevel(level);
elements = lodLevel.getNumElements();
} else {
elements = mesh.getTriangleCount();
}
setText(Messages.MODEL_PROPERTY_LEVEL + ": " + level + " (" + elements + " " +
Messages.MODEL_PROPERTY_TRIANGLE_COUNT + ")");
}
示例4: createFor
import com.jme3.scene.VertexBuffer; //导入依赖的package包/类
@Override
@FXThread
public <T, V extends TreeNode<T>> @Nullable V createFor(@Nullable final T element, final long objectId) {
if (element instanceof Vector3f) {
return unsafeCast(new PositionTreeNode((Vector3f) element, objectId));
} else if (element instanceof VertexBuffer) {
return unsafeCast(new VertexBufferTreeNode((VertexBuffer) element, objectId));
} else if (element instanceof Buffer) {
return unsafeCast(new BufferTreeNode((Buffer) element, objectId));
} else if (element instanceof VehicleWheel) {
return unsafeCast(new VehicleWheelTreeNode((VehicleWheel) element, objectId));
} else if (element instanceof MotionPath) {
return unsafeCast(new MotionPathTreeNode((MotionPath) element, objectId));
}
return null;
}
示例5: Sector
import com.jme3.scene.VertexBuffer; //导入依赖的package包/类
/**
* Create a sector using the points from a specified arc.
*
* @param arc Arc to pull points from
*/
public Sector( PointArc arc ) {
this.arc = arc;
// calculate convenience numbers
int numTriangles = arc.getNumVertices() - 1;
int numEdgeVertices = numTriangles + 1;
int numVertices = numEdgeVertices + 1; // +1 for origin
positionBuffer = BufferUtils.createFloatBuffer( numVertices * 3 );
ShortBuffer indexBuffer = BufferUtils.createShortBuffer( numVertices );
setPositions();
// our shape is easy to make with the TriangleFan mode
for ( int i = 0; i < numVertices; i++ ) {
indexBuffer.put( (short) i );
}
this.setMode( Mode.TriangleFan );
this.setBuffer( VertexBuffer.Type.Position, 3, positionBuffer );
this.setBuffer( VertexBuffer.Type.Index, 3, indexBuffer );
this.updateBound();
this.updateCounts();
}
示例6: PointArc
import com.jme3.scene.VertexBuffer; //导入依赖的package包/类
/**
* Creates an Arc
*
* @param startDir Unit vector for one end of the arc
* @param endDir Unit vector for the other end of the arc
* @param radius How far from the origin should the arc be? (Radius of the circle that the arc is part of)
* @param numSegments How many line segments should the arc be approximated by
* @param lastMidpointDir The direction that the arc will point out in if it is determined to be too close to 180 degrees
*/
public PointArc( Vector3f startDir, Vector3f endDir, float radius, int numSegments, Vector3f lastMidpointDir ) {
this.radius = radius;
numVertices = numSegments + 1;
numFloats = numVertices * 3;
int numIndices = numSegments + 1;
positionBuffer = BufferUtils.createFloatBuffer( numFloats );
ShortBuffer indexBuffer = BufferUtils.createShortBuffer( numIndices );
setPositions( startDir, endDir, lastMidpointDir );
for ( short i = 0; i < numIndices; i++ ) {
indexBuffer.put( i );
}
this.setMode( Mode.LineStrip );
this.setBuffer( VertexBuffer.Type.Position, 3, positionBuffer );
this.setBuffer( VertexBuffer.Type.Index, 2, indexBuffer );
this.updateBound();
this.updateCounts();
}
示例7: resetToBind
import com.jme3.scene.VertexBuffer; //导入依赖的package包/类
void resetToBind() {
for (Mesh mesh : targets){
if (isMeshAnimated(mesh)) {
VertexBuffer bi = mesh.getBuffer(Type.BoneIndex);
ByteBuffer bib = (ByteBuffer) bi.getData();
if (!bib.hasArray()) {
mesh.prepareForAnim(true); // prepare for software animation
}
VertexBuffer bindPos = mesh.getBuffer(Type.BindPosePosition);
VertexBuffer bindNorm = mesh.getBuffer(Type.BindPoseNormal);
VertexBuffer pos = mesh.getBuffer(Type.Position);
VertexBuffer norm = mesh.getBuffer(Type.Normal);
FloatBuffer pb = (FloatBuffer) pos.getData();
FloatBuffer nb = (FloatBuffer) norm.getData();
FloatBuffer bpb = (FloatBuffer) bindPos.getData();
FloatBuffer bnb = (FloatBuffer) bindNorm.getData();
pb.clear();
nb.clear();
bpb.clear();
bnb.clear();
pb.put(bpb).clear();
nb.put(bnb).clear();
}
}
}
示例8: convertVertexFormat
import com.jme3.scene.VertexBuffer; //导入依赖的package包/类
private int convertVertexFormat(VertexBuffer.Format fmt) {
switch (fmt) {
case Byte:
return GL_BYTE;
case Float:
return GL_FLOAT;
case Int:
return GL_INT;
case Short:
return GL_SHORT;
case UnsignedByte:
return GL_UNSIGNED_BYTE;
case UnsignedInt:
return GL_UNSIGNED_INT;
case UnsignedShort:
return GL_UNSIGNED_SHORT;
default:
throw new UnsupportedOperationException("Unrecognized vertex format: " + fmt);
}
}
示例9: update
import com.jme3.scene.VertexBuffer; //导入依赖的package包/类
public void update(Vector3f[] points){
VertexBuffer vb = getBuffer(Type.Position);
if (vb == null){
setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(points));
return;
}
FloatBuffer b = BufferUtils.createFloatBuffer(points);
FloatBuffer a = (FloatBuffer) vb.getData();
b.rewind();
a.rewind();
a.put(b);
a.rewind();
vb.updateData(a);
updateBound();
}
示例10: startFaces
import com.jme3.scene.VertexBuffer; //导入依赖的package包/类
private void startFaces(String count) throws SAXException {
int numFaces = parseInt(count);
int numIndices;
if (mesh.getMode() == Mesh.Mode.Triangles) {
numIndices = numFaces * 3;
} else {
throw new SAXException("Triangle strip or fan not supported!");
}
vb = new VertexBuffer(VertexBuffer.Type.Index);
if (!usesBigIndices) {
sb = BufferUtils.createShortBuffer(numIndices);
ib = null;
vb.setupData(Usage.Static, 3, Format.UnsignedShort, sb);
} else {
ib = BufferUtils.createIntBuffer(numIndices);
sb = null;
vb.setupData(Usage.Static, 3, Format.UnsignedInt, ib);
}
mesh.setBuffer(vb);
}
示例11: pushTexCoord
import com.jme3.scene.VertexBuffer; //导入依赖的package包/类
private void pushTexCoord(Attributes attribs) throws SAXException {
if (texCoordIndex >= 8) {
return; // More than 8 not supported by ogre.
}
Type type = TEXCOORD_TYPES[texCoordIndex];
VertexBuffer tcvb = mesh.getBuffer(type);
FloatBuffer buf = (FloatBuffer) tcvb.getData();
buf.put(parseFloat(attribs.getValue("u")));
if (tcvb.getNumComponents() >= 2) {
buf.put(parseFloat(attribs.getValue("v")));
if (tcvb.getNumComponents() >= 3) {
buf.put(parseFloat(attribs.getValue("w")));
if (tcvb.getNumComponents() == 4) {
buf.put(parseFloat(attribs.getValue("x")));
}
}
}
texCoordIndex++;
}
示例12: startLodFaceList
import com.jme3.scene.VertexBuffer; //导入依赖的package包/类
private void startLodFaceList(String submeshindex, String numfaces) {
int index = Integer.parseInt(submeshindex);
int faceCount = Integer.parseInt(numfaces);
vb = new VertexBuffer(VertexBuffer.Type.Index);
sb = BufferUtils.createShortBuffer(faceCount * 3);
ib = null;
vb.setupData(Usage.Static, 3, Format.UnsignedShort, sb);
List<VertexBuffer> levels = lodLevels.get(index);
if (levels == null) {
levels = new ArrayList<VertexBuffer>();
Mesh submesh = geoms.get(index).getMesh();
levels.add(submesh.getBuffer(Type.Index));
lodLevels.put(index, levels);
}
levels.add(vb);
}
示例13: printMesh
import com.jme3.scene.VertexBuffer; //导入依赖的package包/类
public static void printMesh(Mesh mesh) {
for (int bufType = 0; bufType < Type.values().length; bufType++) {
VertexBuffer outBuf = mesh.getBuffer(Type.values()[bufType]);
if (outBuf == null) {
continue;
}
System.out.println(outBuf.getBufferType() + ": ");
for (int vert = 0; vert < outBuf.getNumElements(); vert++) {
String str = "[";
for (int comp = 0; comp < outBuf.getNumComponents(); comp++) {
Object val = outBuf.getElementComponent(vert, comp);
outBuf.setElementComponent(vert, comp, val);
val = outBuf.getElementComponent(vert, comp);
str += val;
if (comp != outBuf.getNumComponents() - 1) {
str += ", ";
}
}
str += "]";
System.out.println(str);
}
System.out.println("------");
}
}
示例14: updateGeometry
import com.jme3.scene.VertexBuffer; //导入依赖的package包/类
protected void updateGeometry() {
FloatBuffer positions = BufferUtils.createFloatBuffer(samples * 3);
FloatBuffer normals = BufferUtils.createFloatBuffer(samples * 3);
short[] indices = new short[samples * 2];
float rate = FastMath.TWO_PI / samples;
float angle = 0;
int idc = 0;
for (int i = 0; i < samples; i++) {
float x = FastMath.cos(angle) * radius.x + center.x;
float z = FastMath.sin(angle) * radius.y + center.y;
positions.put(x).put(z).put(0);
normals.put(new float[]{0, 1, 0});
indices[idc++] = (short) i;
if (i < samples - 1) {
indices[idc++] = (short) (i + 1);
} else {
indices[idc++] = 0;
}
angle += rate;
}
setBuffer(VertexBuffer.Type.Position, 3, positions);
setBuffer(VertexBuffer.Type.Normal, 3, normals);
setBuffer(VertexBuffer.Type.Index, 2, indices);
setBuffer(VertexBuffer.Type.TexCoord, 2, new float[]{0, 0, 1, 1});
updateBound();
}
示例15: setGeometryData
import com.jme3.scene.VertexBuffer; //导入依赖的package包/类
private void setGeometryData() {
setMode(Mode.Lines);
FloatBuffer posBuf = BufferUtils.createVector3Buffer(3);
FloatBuffer texBuf = BufferUtils.createVector2Buffer(3);
setBuffer(VertexBuffer.Type.Position, 3, posBuf);
setBuffer(VertexBuffer.Type.TexCoord, 2, texBuf);
posBuf.put(-width).put(0).put(0);
posBuf.put(0).put(height).put(0);
posBuf.put(width).put(0).put(0);
texBuf.put(-width).put(0);
texBuf.put(0).put(height);
texBuf.put(width).put(0);
}