本文整理汇总了Java中org.rajawali3d.materials.Material.useProgram方法的典型用法代码示例。如果您正苦于以下问题:Java Material.useProgram方法的具体用法?Java Material.useProgram怎么用?Java Material.useProgram使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.rajawali3d.materials.Material
的用法示例。
在下文中一共展示了Material.useProgram方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderColorPicking
import org.rajawali3d.materials.Material; //导入方法依赖的package包/类
/**
* Renders the object for color-picking
*
* @param camera The camera
* @param pickingMaterial The color-picking Material
*/
public void renderColorPicking(final Camera camera, final Material pickingMaterial) {
if (!mIsVisible && !mRenderChildrenAsBatch)
// Neither the object nor any of its children are visible
return;
// Color-picking assumes much of the object state set in the prior frame is intact:
// No need to prerender (color-picking always runs before any children changes)
// All matrices already updated during prior frame
// Bounding box already transformed
mIsInFrustum = true; // only if mFrustrumTest == true it check frustum
if (mFrustumTest && mGeometry.hasBoundingBox()) {
BoundingBox bbox = mGeometry.getBoundingBox();
if (!camera.getFrustum().boundsInFrustum(bbox)) {
mIsInFrustum = false;
}
}
// Render this object only if it has visible geometry and didn't fail frustum test
if (!mIsContainerOnly && mIsInFrustum && mIsVisible) {
// Render same faces as visible render
if (mDoubleSided) {
GLES20.glDisable(GLES20.GL_CULL_FACE);
} else {
GLES20.glEnable(GLES20.GL_CULL_FACE);
if (mBackSided) {
GLES20.glCullFace(GLES20.GL_FRONT);
} else {
GLES20.glCullFace(GLES20.GL_BACK);
GLES20.glFrontFace(GLES20.GL_CCW);
}
}
// Blending and depth testing are set up globally in Scene.doColorPicking()
// Material setup is independent of batching, and has no need for
// shader params, textures, normals, vertex colors, or current object...
pickingMaterial.useProgram();
pickingMaterial.setVertices(mGeometry.getVertexBufferInfo());
pickingMaterial.setColor(mPickingColor);
pickingMaterial.applyParams();
// Unbind the array buffer
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
// Apply this object's matrices to the pickingMaterial
pickingMaterial.setMVPMatrix(mMVPMatrix);
pickingMaterial.setModelMatrix(mMMatrix);
pickingMaterial.setModelViewMatrix(mMVMatrix);
// Draw the object using its picking color
int bufferType = mGeometry.getIndexBufferInfo().bufferType == Geometry3D.BufferType.SHORT_BUFFER ? GLES20.GL_UNSIGNED_SHORT : GLES20.GL_UNSIGNED_INT;
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, mGeometry.getIndexBufferInfo().bufferHandle);
GLES20.glDrawElements(mDrawingMode, mGeometry.getNumIndices(), bufferType, 0);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
// Only need to undo face culling
if (mDoubleSided) {
GLES20.glEnable(GLES20.GL_CULL_FACE);
} else if (mBackSided) {
GLES20.glCullFace(GLES20.GL_BACK);
}
}
// No need to draw bounding volumes..
// Draw children without frustum test
for (int i = 0, j = mChildren.size(); i < j; i++) {
// Child rendering is independent of batching, and matrices already updated
mChildren.get(i).renderColorPicking(camera, pickingMaterial);
}
// No textures to unbind, all done
}