use of org.rajawali3d.materials.Material in project Rajawali by Rajawali.
the class ObjectColorPicker method initialize.
public void initialize() {
final int size = Math.max(mRenderer.getViewportWidth(), mRenderer.getViewportHeight());
mRenderTarget = new RenderTarget("colorPickerTarget", size, size, 0, 0, false, false, GLES20.GL_TEXTURE_2D, Config.ARGB_8888, FilterType.LINEAR, WrapType.CLAMP);
mRenderer.addRenderTarget(mRenderTarget);
mPickerMaterial = new Material();
MaterialManager.getInstance().addMaterial(mPickerMaterial);
}
use of org.rajawali3d.materials.Material in project Rajawali by Rajawali.
the class Scene method setSkybox.
/**
* Creates a skybox with the specified 6 {@link Bitmap} textures.
*
* @param bitmaps {@link Bitmap} array containing the cube map textures.
*/
public boolean setSkybox(Bitmap[] bitmaps) {
final AFrameTask task = new AFrameTask() {
@Override
protected void doTask() {
for (int i = 0, j = mCameras.size(); i < j; ++i) mCameras.get(i).setFarPlane(1000);
}
};
final Cube skybox = new Cube(700, true);
final CubeMapTexture texture = new CubeMapTexture("bitmap_skybox", bitmaps);
texture.isSkyTexture(true);
final Material material = new Material();
material.setColorInfluence(0);
try {
material.addTexture(texture);
} catch (TextureException e) {
RajLog.e(e.getMessage());
}
skybox.setMaterial(material);
synchronized (mNextCameraLock) {
mNextSkybox = skybox;
}
return internalOfferTask(task);
}
use of org.rajawali3d.materials.Material in project Rajawali by Rajawali.
the class Scene method updateChildMaterialWithLights.
/**
* Update the lights on this child's material. This method should only
* be called when the lights collection is dirty. It will
* trigger compilation of all light-enabled shaders.
*
* @param child
*/
private void updateChildMaterialWithLights(Object3D child) {
Material material = child.getMaterial();
if (material != null && material.lightingEnabled())
material.setLights(mLights);
if (material != null && mFogParams != null)
material.addPlugin(new FogMaterialPlugin(mFogParams));
int numChildren = child.getNumChildren();
for (int i = 0; i < numChildren; i++) {
Object3D grandChild = child.getChildAt(i);
updateChildMaterialWithLights(grandChild);
}
}
use of org.rajawali3d.materials.Material in project Rajawali by Rajawali.
the class Scene method doColorPicking.
protected void doColorPicking(ColorPickerInfo pickerInfo) {
ObjectColorPicker picker = pickerInfo.getPicker();
picker.getRenderTarget().bind();
// Set background color (to Object3D.UNPICKABLE to prevent any conflicts)
GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
// Configure depth testing
GLES20.glEnable(GLES20.GL_DEPTH_TEST);
GLES20.glDepthFunc(GLES20.GL_LESS);
GLES20.glDepthMask(true);
GLES20.glClearDepthf(1.0f);
// Clear buffers used for color-picking
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
// Get the picking material
Material pickingMaterial = picker.getMaterial();
// Can't blend picking colors
GLES20.glDisable(GLES20.GL_BLEND);
// Render the Skybox first (no need for depth testing)
if (mSkybox != null && mSkybox.isPickingEnabled()) {
GLES20.glDisable(GLES20.GL_DEPTH_TEST);
GLES20.glDepthMask(false);
mSkybox.renderColorPicking(mCamera, pickingMaterial);
GLES20.glEnable(GLES20.GL_DEPTH_TEST);
GLES20.glDepthMask(true);
}
// Render all children using their picking colors
synchronized (mChildren) {
for (int i = 0, j = mChildren.size(); i < j; ++i) {
mChildren.get(i).renderColorPicking(mCamera, pickingMaterial);
}
}
// pickObject() unbinds the renderTarget's framebuffer...
ObjectColorPicker.pickObject(pickerInfo);
}
use of org.rajawali3d.materials.Material in project Rajawali by Rajawali.
the class VuforiaRenderer method onRenderSurfaceSizeChanged.
@Override
public void onRenderSurfaceSizeChanged(GL10 gl, int width, int height) {
RajLog.i("onRenderSurfaceSizeChanged " + width + ", " + height);
super.onRenderSurfaceSizeChanged(gl, width, height);
updateRendering(width, height);
QCAR.onSurfaceChanged(width, height);
getCurrentCamera().setProjectionMatrix(getFOV(), getVideoWidth(), getVideoHeight());
if (mBackgroundRenderTarget == null) {
mBackgroundRenderTarget = new RenderTarget("rajVuforia", width, height);
addRenderTarget(mBackgroundRenderTarget);
Material material = new Material();
material.setColorInfluence(0);
try {
material.addTexture(mBackgroundRenderTarget.getTexture());
} catch (TextureException e) {
e.printStackTrace();
}
mBackgroundQuad = new ScreenQuad();
if (mVuforiaManager.getScreenOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
mBackgroundQuad.setScaleY((float) height / (float) getVideoHeight());
else
mBackgroundQuad.setScaleX((float) width / (float) getVideoWidth());
mBackgroundQuad.setMaterial(material);
getCurrentScene().addChildAt(mBackgroundQuad, 0);
}
}
Aggregations