@Override protected void animate(GVRHybridObject target, float ratio) { mMaterial.setVec4(ColorSwapShader.COLOR, mStartR + ratio * mDeltaR, mStartG + ratio * mDeltaG, mStartB + ratio * mDeltaB, 1); } }
private GVRMaterial createCustomMaterial(GVRContext context, String textureFile) throws IOException { GVRMaterial litMaterial = new GVRMaterial(context, GVRMaterial.GVRShaderType.Phong.ID); litMaterial.setVec4("diffuse_color", 1.0f, 1.0f, 1.0f, 1.0f); litMaterial.setVec4("ambient_color", 0.5f, 0.5f, 0.5f, 0.0f); litMaterial.setVec4("specular_color", 1.0f, 1.0f, 1.0f, 1.0f); litMaterial.setVec4("emissive_color", 0.0f, 0.0f, 0.0f, 0.0f); litMaterial.setFloat("specular_exponent", 10.0f); GVRTexture texture = context.getAssetLoader().loadTexture(new GVRAndroidResource(context, textureFile)); litMaterial.setTexture("diffuseTexture", texture); return litMaterial; }
public void onExit(GVRSceneObject sceneObj) { sceneObj.getRenderData().getMaterial().setVec4("u_color", UNPICKED_COLOR_R, UNPICKED_COLOR_G, UNPICKED_COLOR_B, UNPICKED_COLOR_A); } public void onNoPick(GVRPicker picker) { }
public void onEnter(GVRSceneObject sceneObj, GVRPicker.GVRPickedObject pickInfo) { sceneObj.getRenderData().getMaterial().setVec4("u_color", PICKED_COLOR_R, PICKED_COLOR_G, PICKED_COLOR_B, PICKED_COLOR_A); }
public void onEnter(GVRSceneObject sceneObj, GVRPicker.GVRPickedObject pickInfo) { sceneObj.getRenderData().getMaterial().setVec4("u_color", PICKED_COLOR_R, PICKED_COLOR_G, PICKED_COLOR_B, PICKED_COLOR_A); } public void onExit(GVRSceneObject sceneObj)
public void changeColorTo(float[] color) { apple.getRenderData().getMaterial() .setVec4(ColorSwapShader.COLOR, color[0], color[1], color[2], 1); }
public void onExit(GVRSceneObject sceneObj, GVRPicker.GVRPickedObject pickInfo) { sceneObj.getRenderData().getMaterial().setVec4("u_color", UNPICKED_COLOR_R, UNPICKED_COLOR_G, UNPICKED_COLOR_B, UNPICKED_COLOR_A); if (sceneObj == movingObject) { controller.stopDrag(); movingObject = null; } } public void onInside(GVRSceneObject sceneObj, GVRPicker.GVRPickedObject pickInfo) { }
public void onTouchEnd(GVRSceneObject sceneObj, GVRPicker.GVRPickedObject pickInfo) { sceneObj.getRenderData().getMaterial().setVec4("u_color", PICKED_COLOR_R, PICKED_COLOR_G, PICKED_COLOR_B, PICKED_COLOR_A); if (sceneObj == movingObject) { controller.stopDrag(); movingObject = null; } }
public void onTouchStart(GVRSceneObject sceneObj, GVRPicker.GVRPickedObject pickInfo) { if (movingObject == null) { sceneObj.getRenderData().getMaterial().setVec4("u_color", CLICKED_COLOR_R, CLICKED_COLOR_G, CLICKED_COLOR_B, CLICKED_COLOR_A); if (controller.startDrag(sceneObj)) { movingObject = sceneObj; } } }
private GVRSceneObject createBackdrop(GVRContext context) throws IOException { GVRTexture tex = context.getAssetLoader().loadTexture(new GVRAndroidResource(mGVRContext, "floor.jpg")); GVRSceneObject backdrop = new GVRSceneObject(context, 100.0f, 100.0f, tex); GVRRenderData rdata = backdrop.getRenderData(); GVRMaterial material = new GVRMaterial(context,new GVRShaderId(GVRPhongShader.class)); material.setVec4("diffuse_color", 0.8f, 0.8f, 0.8f, 1.0f); material.setVec4("ambient_color", 0.3f, 0.3f, 0.3f, 1.0f); material.setVec4("specular_color", 1.0f, 1.0f, 1.0f, 1.0f); material.setVec4("emissive_color", 0.0f, 0.0f, 0.0f, 0.0f); material.setFloat("specular_exponent", 10.0f); material.setTexture("diffuseTexture", tex); backdrop.setName("Backdrop"); rdata.setMaterial(material); return backdrop; }
private GVRSceneObject createBackdrop(GVRContext context) { GVRTexture tex = context.getAssetLoader().loadTexture(new GVRAndroidResource(mGVRContext, R.drawable.gearvrflogo)); GVRSceneObject backdrop = new GVRSceneObject(context, 10.0f, 4.0f, tex); GVRRenderData rdata = backdrop.getRenderData(); GVRMaterial material = new GVRMaterial(context, GVRMaterial.GVRShaderType.Phong.ID); material.setVec4("diffuse_color", 0.8f, 0.8f, 0.8f, 1.0f); material.setVec4("ambient_color", 0.3f, 0.3f, 0.3f, 1.0f); material.setVec4("specular_color", 1.0f, 1.0f, 1.0f, 1.0f); material.setVec4("emissive_color", 0.0f, 0.0f, 0.0f, 0.0f); material.setFloat("specular_exponent", 10.0f); material.setTexture("diffuseTexture", tex); backdrop.setName("Backdrop"); backdrop.getTransform().setPositionZ(-2.0f); rdata.setMaterial(material); return backdrop; }
public void updateAppleColor() { float[] color = getColor(this.getGVRContext()); this.getRenderData().getMaterial() .setVec4(ColorSwapShader.COLOR, color[0], color[1], color[2], 1); }
private GVRSceneObject getColorBoard(float width, float height) { GVRMaterial material = new GVRMaterial(mGVRContext, GVRMaterial.GVRShaderType.Color.ID); material.setVec4("u_color", UNPICKED_COLOR_R, UNPICKED_COLOR_G, UNPICKED_COLOR_B, UNPICKED_COLOR_A); GVRSceneObject board = new GVRSceneObject(mGVRContext, width, height); board.getRenderData().setMaterial(material); // material.setVec4("u_color", UNPICKED_COLOR_R, // UNPICKED_COLOR_G, UNPICKED_COLOR_B, UNPICKED_COLOR_A); return board; }
public void resetColor(Color color) { segment.getRenderData().getMaterial().setVec4( ColorSwapShader.COLOR, color.getRed(), color.getGreen(), color.getBlue(), 1); } }
private GVRSceneObject getColorBoard() { GVRMaterial material = new GVRMaterial(mGVRContext, GVRShaderType.Color.ID); material.setVec4("u_color", UNPICKED_COLOR_R, UNPICKED_COLOR_G, UNPICKED_COLOR_B, UNPICKED_COLOR_A); GVRCubeSceneObject board = new GVRCubeSceneObject(mGVRContext); board.getRenderData().setMaterial(material); board.getRenderData().setRenderingOrder(GVRRenderData.GVRRenderingOrder.GEOMETRY); return board; }
private GVRSceneObject getColorMesh(float scale, GVRMesh mesh) { GVRMaterial material = new GVRMaterial(mGVRContext, GVRMaterial.GVRShaderType.Color.ID); material.setVec4("u_color", UNPICKED_COLOR_R, UNPICKED_COLOR_G, UNPICKED_COLOR_B, UNPICKED_COLOR_A); GVRSceneObject meshObject = null; meshObject = new GVRSceneObject(mGVRContext, mesh); meshObject.getTransform().setScale(scale, scale, scale); meshObject.getRenderData().setMaterial(material); // material.setVec4("u_color", UNPICKED_COLOR_R, // UNPICKED_COLOR_G, UNPICKED_COLOR_B, UNPICKED_COLOR_A); return meshObject; }
private GVRSceneObject getColorMesh(float scale, GVRMesh mesh) { GVRMaterial material = new GVRMaterial(mGVRContext, GVRShaderType.Color.ID); material.setVec4("u_color", UNPICKED_COLOR_R, UNPICKED_COLOR_G, UNPICKED_COLOR_B, UNPICKED_COLOR_A); GVRSceneObject meshObject = new GVRSceneObject(mGVRContext, mesh); meshObject.getTransform().setScale(scale, scale, scale); meshObject.getRenderData().setMaterial(material); meshObject.getRenderData().setRenderingOrder(GVRRenderData.GVRRenderingOrder.GEOMETRY); return meshObject; }
private GVRSceneObject createCursor() { GVRSceneObject cursor = new GVRSphereSceneObject(context); GVRRenderData cursorRenderData = cursor.getRenderData(); mShaderID = new GVRShaderId(CustomShaderManager.class); mShaderMaterial = new GVRMaterial(getGVRContext(), mShaderID); mShaderMaterial.setVec4(CustomShaderManager.COLOR_KEY, 1.0f, 0.0f, 0.0f, 0.5f); cursor.getTransform().setScale(-0.015f, -0.015f, -0.015f); cursorRenderData.setMaterial(mShaderMaterial); cursorRenderData.setDepthTest(false); cursorRenderData.setRenderingOrder(GVRRenderData.GVRRenderingOrder.OVERLAY); cursorModel = cursor; return cursor; }
private void applyShader(GVRContext gvrContext, GVRSceneObject wormPiece, Color color) { GVRTexture texture = gvrContext.getAssetLoader().loadTexture(new GVRAndroidResource(gvrContext, R.drawable.wormy_diffuse_light)); wormPiece.getRenderData().getMaterial() .setTexture(ColorSwapShader.TEXTURE_GRAYSCALE, texture); texture = gvrContext.getAssetLoader().loadTexture(new GVRAndroidResource(gvrContext, R.drawable.wormy_diffuse_2)); wormPiece.getRenderData().getMaterial() .setTexture(ColorSwapShader.TEXTURE_DETAILS, texture); wormPiece .getRenderData() .getMaterial() .setVec4(ColorSwapShader.COLOR, color.getRed(), color.getGreen(), color.getBlue(), 1); }
private void setTextures(GVRContext gvrContext) { GVRTexture texture = gvrContext.getAssetLoader().loadTexture(new GVRAndroidResource(gvrContext, R.drawable.grayscale_circle)); getRenderData().getMaterial().setTexture(ColorSwapShader.TEXTURE_GRAYSCALE, texture); texture = gvrContext.getAssetLoader().loadTexture(new GVRAndroidResource(gvrContext, R.raw.empty)); getRenderData().getMaterial().setTexture(ColorSwapShader.TEXTURE_DETAILS, texture); getRenderData().getMaterial().setVec4(ColorSwapShader.COLOR, this.color.getRed(), this.color.getGreen(), this.color.getBlue(), 1); getRenderData().setRenderingOrder(RenderingOrder.MENU_GRID_BUTTON); }