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


Java VertexBuffer.getNumComponents方法代码示例

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


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

示例1: 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++;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:MeshLoader.java

示例2: 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("------");
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:GeometryBatchFactory.java

示例3: pushTangent

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
private void pushTangent(Attributes attribs) throws SAXException {
    try {
        VertexBuffer tangentBuf = mesh.getBuffer(Type.Tangent);
        FloatBuffer buf = (FloatBuffer) tangentBuf.getData();
        buf.put(parseFloat(attribs.getValue("x"))).put(parseFloat(attribs.getValue("y"))).put(parseFloat(attribs.getValue("z")));
        if (tangentBuf.getNumComponents() == 4) {
            buf.put(parseFloat(attribs.getValue("w")));
        }
    } catch (Exception ex) {
        throw new SAXException("Failed to push attrib", ex);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:MeshLoader.java

示例4: SharedBuffer

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
/**
 * Creates a shared buffer from the specified vertex buffer
 * @param vertexBuffer the vertex buffer to use
 */
public SharedBuffer(VertexBuffer vertexBuffer) {
	this.jmeBuffer = vertexBuffer;
	this.format = vertexBuffer.getFormat();
	this.type = vertexBuffer.getBufferType();
	this.components = vertexBuffer.getNumComponents();
	this.size = vertexBuffer.getNumElements();
}
 
开发者ID:shamanDevel,项目名称:jME3-OpenCL-Library,代码行数:12,代码来源:SharedBuffer.java

示例5: getColor

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
public static ColorRGBA getColor( Geometry geom, Vector3f pt, int index, Tweed tweed ) {
		
		MatParam param = geom.getMaterial().getParam( "DiffuseMap" );
		
		ImageRaster ir = ImageRaster.create( tweed.getAssetManager().loadTexture( ((Texture2D)param.getValue()).getName() ).getImage() );
    	
		Mesh mesh = geom.getMesh();
//		geom.getMaterial().getMaterialDef().
		
        VertexBuffer pb = mesh.getBuffer(Type.Position);
        VertexBuffer tb = mesh.getBuffer( Type.TexCoord );
        
        IndexBuffer  ib = mesh.getIndicesAsList();
        
        Vector2f uva = new Vector2f(), uvb = new Vector2f(), uvc = new Vector2f();
        Vector3f la  = new Vector3f(), lb  = new Vector3f(), lc  = new Vector3f();
        
        if (pb != null && pb.getFormat() == Format.Float && pb.getNumComponents() == 3) {
        	
            FloatBuffer fpb = (FloatBuffer) pb.getData();
            FloatBuffer ftb = (FloatBuffer) tb.getData();

            // aquire triangle's vertex indices
            int vertIndex = index * 3;
            
            int va = ib.get(vertIndex);
            int vb = ib.get(vertIndex+1);
            int vc = ib.get(vertIndex+2);
            
            BufferUtils.populateFromBuffer( la, fpb, va );
            BufferUtils.populateFromBuffer( lb, fpb, vb );
            BufferUtils.populateFromBuffer( lc, fpb, vc );
            
            BufferUtils.populateFromBuffer( uva, ftb, va );
            BufferUtils.populateFromBuffer( uvb, ftb, vb );
            BufferUtils.populateFromBuffer( uvc, ftb, vc );
            
//            PaintThing.debug.put(1, new Line ( la.x, la.z, lb.x, lb.z) );
//            PaintThing.debug.put(2, new Line ( lb.x, lb.z, lc.x, lc.z) );
//            PaintThing.debug.put(3, new Line ( lc.x, lc.z, la.x, la.z) );
            
            float[] bary = barycentric( pt, la, lb, lc );
            
            int x = (int)( ( uva.x * bary[0] + uvb.x * bary[1] + uvc.x * bary[2] ) * ir.getWidth ()) ,
            	y = (int)( ( uva.y * bary[0] + uvb.y * bary[1] + uvc.y * bary[2] ) * ir.getHeight()) ;
            
            ColorRGBA out = ir.getPixel( x, y );//ir.getHeight() - y -1 );

//            for (Pair<Vector3f, Vector2f> pair : new Pair[]{ new Pair( la, uva), new Pair (lb, uvb), new Pair (lc, uvc)}) {
//            	
//            	int xx = (int)(pair.second().x * ir.getWidth () ),
//            	    yy = (int)(pair.second().y * ir.getHeight() );
//            	
//            	System.out.println("xx "+xx+" yy "+ yy );
//            	
//            	ColorRGBA o = ir.getPixel( 
//            			xx,
//            			yy );
//            	
//            	PaintThing.debug.put(1, new ColPt( pair.first().x, pair.first().z, o.r, o.g, o.b ));
//            }
            
//            System.out.println("<< "+ ((Texture2D)param.getValue()).getName());
//			System.out.println( x + " " + y + " :: " + bary[ 0 ] + " " + bary[ 1 ] + " " + bary[ 2 ] + 
//					" --> " + out.r + "," + out.g + "," + out.b );
            
            return out;
            
        }else{
        	
            throw new UnsupportedOperationException("Position buffer not set or has incompatible format");
        }
    }
 
开发者ID:twak,项目名称:chordatlas,代码行数:74,代码来源:SkelFootprint.java

示例6: setVertexAttrib

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
public void setVertexAttrib(VertexBuffer vb, VertexBuffer idb) {
    int arrayType = convertArrayType(vb.getBufferType());
    if (arrayType == -1) {
        return; // unsupported
    }
    glEnableClientState(arrayType);
    context.boundAttribs[vb.getBufferType().ordinal()] = vb;

    if (vb.getBufferType() == Type.Normal) {
        // normalize if requested
        if (vb.isNormalized() && !context.normalizeEnabled) {
            glEnable(GL_NORMALIZE);
            context.normalizeEnabled = true;
        } else if (!vb.isNormalized() && context.normalizeEnabled) {
            glDisable(GL_NORMALIZE);
            context.normalizeEnabled = false;
        }
    }

    // NOTE: Use data from interleaved buffer if specified
    Buffer data = idb != null ? idb.getData() : vb.getData();
    int comps = vb.getNumComponents();
    int type = convertVertexFormat(vb.getFormat());

    data.rewind();

    switch (vb.getBufferType()) {
        case Position:
            if (!(data instanceof FloatBuffer)) {
                throw new UnsupportedOperationException();
            }

            glVertexPointer(comps, vb.getStride(), (FloatBuffer) data);
            break;
        case Normal:
            if (!(data instanceof FloatBuffer)) {
                throw new UnsupportedOperationException();
            }

            glNormalPointer(vb.getStride(), (FloatBuffer) data);
            break;
        case Color:
            if (data instanceof FloatBuffer) {
                glColorPointer(comps, vb.getStride(), (FloatBuffer) data);
            } else if (data instanceof ByteBuffer) {
                glColorPointer(comps, true, vb.getStride(), (ByteBuffer) data);
            } else {
                throw new UnsupportedOperationException();
            }
            break;
        case TexCoord:
            if (!(data instanceof FloatBuffer)) {
                throw new UnsupportedOperationException();
            }

            glTexCoordPointer(comps, vb.getStride(), (FloatBuffer) data);
            break;
        default:
            // Ignore, this is an unsupported attribute for OpenGL1.
            break;
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:63,代码来源:LwjglGL1Renderer.java

示例7: getCapacity

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
public int getCapacity() {
	VertexBuffer vb = mesh.getBuffer(VertexBuffer.Type.Position);
	return vb.getData().capacity() / vb.getNumComponents();
}
 
开发者ID:shamanDevel,项目名称:jME3-OpenCL-Library,代码行数:5,代码来源:ParticleRenderer.java

示例8: setVertexAttribVBO

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
private void setVertexAttribVBO(VertexBuffer vb, VertexBuffer idb) {
    int arrayType = convertArrayType(vb.getBufferType());
    if (arrayType == -1) {
        return; // unsupported
    }
    if (vb.isUpdateNeeded() && idb == null) {
        updateBufferData(vb);
    }

    int bufId = idb != null ? idb.getId() : vb.getId();
    if (context.boundArrayVBO != bufId) {
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER, bufId);
        context.boundArrayVBO = bufId;
    }

    gl.glEnableClientState(arrayType);
    context.boundAttribs[vb.getBufferType().ordinal()] = vb;

    if (vb.getBufferType() == Type.Normal) {
        // normalize if requested
        if (vb.isNormalized() && !context.normalizeEnabled) {
            gl.glEnable(gl.GL_NORMALIZE);
            context.normalizeEnabled = true;
        } else if (!vb.isNormalized() && context.normalizeEnabled) {
            gl.glDisable(gl.GL_NORMALIZE);
            context.normalizeEnabled = false;
        }
    }

    int comps = vb.getNumComponents();
    int type = convertVertexFormat(vb.getFormat());

    switch (vb.getBufferType()) {
        case Position:
            gl.glVertexPointer(comps, type, vb.getStride(), vb.getOffset());
            break;
        case Normal:
            gl.glNormalPointer(type, vb.getStride(), vb.getOffset());
            break;
        case Color:
            gl.glColorPointer(comps, type, vb.getStride(), vb.getOffset());
            break;
        case TexCoord:
            gl.glTexCoordPointer(comps, type, vb.getStride(), vb.getOffset());
            break;
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:48,代码来源:JoglRenderer.java

示例9: setVertexAttrib

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
public void setVertexAttrib(VertexBuffer vb, VertexBuffer idb) {
    int arrayType = convertArrayType(vb.getBufferType());
    if (arrayType == -1) {
        return; // unsupported
    }
    gl.glEnableClientState(arrayType);
    context.boundAttribs[vb.getBufferType().ordinal()] = vb;

    if (vb.getBufferType() == Type.Normal) {
        // normalize if requested
        if (vb.isNormalized() && !context.normalizeEnabled) {
            gl.glEnable(gl.GL_NORMALIZE);
            context.normalizeEnabled = true;
        } else if (!vb.isNormalized() && context.normalizeEnabled) {
            gl.glDisable(gl.GL_NORMALIZE);
            context.normalizeEnabled = false;
        }
    }

    // NOTE: Use data from interleaved buffer if specified
    Buffer data = idb != null ? idb.getData() : vb.getData();
    int comps = vb.getNumComponents();
    int type = convertVertexFormat(vb.getFormat());
    data.clear();
    data.position(vb.getOffset());

    switch (vb.getBufferType()) {
        case Position:
            gl.glVertexPointer(comps, type, vb.getStride(), data);
            break;
        case Normal:
            gl.glNormalPointer(type, vb.getStride(), data);
            break;
        case Color:
            gl.glColorPointer(comps, type, vb.getStride(), data);
            break;
        case TexCoord:
            gl.glTexCoordPointer(comps, type, vb.getStride(), data);
            break;
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:42,代码来源:JoglRenderer.java

示例10: setVertexAttribVBO

import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
@Override
protected void setVertexAttribVBO(VertexBuffer vb, VertexBuffer idb) {
    GL gl = GLContext.getCurrentGL();
    int arrayType = convertArrayType(vb.getBufferType());
    if (arrayType == -1) {
        return; // unsupported
    }

    if (vb.isUpdateNeeded() && idb == null) {
        updateBufferData(vb);
    }

    int bufId = idb != null ? idb.getId() : vb.getId();
    if (context.boundArrayVBO != bufId) {
        gl.glBindBuffer(GL.GL_ARRAY_BUFFER, bufId);
        context.boundArrayVBO = bufId;
    }

    gl.getGL2().glEnableClientState(arrayType);
    context.boundAttribs[vb.getBufferType().ordinal()] = vb;

    if (vb.getBufferType() == Type.Normal) {
        // normalize if requested
        if (vb.isNormalized() && !context.normalizeEnabled) {
            gl.glEnable(GLLightingFunc.GL_NORMALIZE);
            context.normalizeEnabled = true;
        }
        else if (!vb.isNormalized() && context.normalizeEnabled) {
            gl.glDisable(GLLightingFunc.GL_NORMALIZE);
            context.normalizeEnabled = false;
        }
    }

    int comps = vb.getNumComponents();
    int type = convertVertexFormat(vb.getFormat());

    switch (vb.getBufferType()) {
        case Position:
            gl.getGL2().glVertexPointer(comps, type, vb.getStride(), vb.getOffset());
            break;
        case Normal:
            gl.getGL2().glNormalPointer(type, vb.getStride(), vb.getOffset());
            break;
        case Color:
            gl.getGL2().glColorPointer(comps, type, vb.getStride(), vb.getOffset());
            break;
        case TexCoord:
            gl.getGL2().glTexCoordPointer(comps, type, vb.getStride(), vb.getOffset());
            break;
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:52,代码来源:JoglRenderer.java


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