GVRSceneObject makeEnvironment(GVRContext context) { GVRTexture tex = context.getAssetLoader().loadCubemapTexture(new GVRAndroidResource(context, R.raw.lycksele3)); GVRMaterial material = new GVRMaterial(context, GVRMaterial.GVRShaderType.Cubemap.ID); material.setMainTexture(tex); GVRSphereSceneObject environment = new GVRSphereSceneObject(context, 18, 36, false, material, 4, 4); environment.getTransform().setScale(20.0f, 20.0f, 20.0f); if (!GVRShader.isVulkanInstance()) { GVRDirectLight sunLight = new GVRDirectLight(context); sunLight.setAmbientIntensity(0.4f, 0.4f, 0.4f, 1.0f); sunLight.setDiffuseIntensity(0.6f, 0.6f, 0.6f, 1.0f); environment.attachComponent(sunLight); } return environment; }
@Override public void onInit(GVRContext gvrContext) { GVRScene scene = gvrContext.getMainScene(); GVRSphereSceneObject sphere = new GVRSphereSceneObject(gvrContext, 72, 144, false); GVRMesh mesh = sphere.getRenderData().getMesh(); GVRVideoSceneObject video = new GVRVideoSceneObject( gvrContext, mesh, mPlayer, GVRVideoSceneObject.GVRVideoType.MONO ); video.getTransform().setScale(100f, 100f, 100f); video.setName( "video" ); scene.addSceneObject( video ); video.getMediaPlayer().start(); }
private void addSkyBoxSphere() { // Select a skybox int availableSkyboxes[] = {R.raw.skybox_a, R.raw.skybox_b, R.raw.skybox_c}; int selectedSkybox = availableSkyboxes[new SecureRandom().nextInt(2)]; GVRTexture texture = mContext.getAssetLoader().loadTexture(new GVRAndroidResource(mContext, selectedSkybox)); mSkybox = new GVRSphereSceneObject(mContext, 72, 144, false, texture); mSkybox.setName("sphere"); mSkybox.getTransform().setScale(SCALE, SCALE, SCALE); mScene.addSceneObject(mSkybox); }
private GVRSphereSceneObject loadSkyBoxModel(GVRContext gvrContext, String skyBoxPath, String skyBoxName) { GVRSphereSceneObject sphereObject = null; // load texture GVRTexture texture = null; try { texture = gvrContext.getAssetLoader().loadTexture(new GVRAndroidResource(gvrContext, skyBoxPath + skyBoxName)); } catch (Exception e) { e.printStackTrace(); } // create a sphere scene object with the specified texture and triangles facing inward (the 'false' argument) sphereObject = new GVRSphereSceneObject(gvrContext, false, texture); sphereObject.getTransform().setScale(100, 100, 100); return sphereObject; }
@Override public void onInit(GVRContext gvrContext) { // get a handle to the scene GVRScene scene = gvrContext.getMainScene(); GVRSphereSceneObject sphereObject = null; // load texture GVRTexture texture = gvrContext.getAssetLoader().loadTexture(new GVRAndroidResource(gvrContext, R.raw.photosphere)); // create a sphere scene object with the specified texture and triangles facing inward (the 'false' argument) sphereObject = new GVRSphereSceneObject(gvrContext, 72, 144, false, texture); // add the scene object to the scene graph scene.addSceneObject(sphereObject); }
new GVRAndroidResource(gvrContext, R.drawable.skybox_gridroom)); GVRMaterial material = new GVRMaterial(gvrContext); GVRSphereSceneObject skyBox = new GVRSphereSceneObject(gvrContext, false, material); skyBox.getTransform().setScale(SCALE, SCALE, SCALE); skyBox.getRenderData().getMaterial().setMainTexture(texture); mainScene.addSceneObject(skyBox);
GVRSceneObject root = new GVRSceneObject(gvrContext); GVRCubeSceneObject cube = new GVRCubeSceneObject(gvrContext, true, red); GVRSphereSceneObject sphere = new GVRSphereSceneObject(gvrContext, true, blue); GVRCylinderSceneObject cylinder = new GVRCylinderSceneObject(gvrContext, true, red); GVRConeSceneObject cone = new GVRConeSceneObject(gvrContext, true, blue); blue.setDiffuseColor(0, 0, 1, 1); cube.setName("cube"); sphere.setName("sphere"); cylinder.setName("cylinder"); cone.setName("cone");
void addSkyBox(int index, GVRScene scene) { Log.d(TAG, "Adding SkyBox"); GVRSphereSceneObject current = null; if (currentSkyBox != null) scene.removeSceneObject(currentSkyBox); int count = aODefaultSkyBox.size(); if (index < count) { current = aODefaultSkyBox.get(index).getSkyBox(context, sDefaultSkyBoxDirectory + "/"); } else { current = aOSDSkyBox.get(index - count).getSkyBoxFromSD(context, sEnvironmentPath + "/" + sSDSkyBoxDirectory + "/"); } if (current != null) { scene.addSceneObject(current); currentSkyBox = current; current.getTransform().setPosition(defaultCenterPosition.x, defaultCenterPosition.y, defaultCenterPosition.z); } else { Log.d(TAG, "SkyBox is null"); } enableDisableLightOnModel(current, false); }
@Override public void onPrepareFile(String title, long duration) { mVideoPlayer.show(new OnFadeFinish() { @Override public void onFadeFinished() { mVideoPlayer.play(); } }); mSkybox.getRenderData().getMaterial().setColor(0.6f, 0.6f, 0.6f); } };
private GVRSphereSceneObject loadSkyBoxModelFromSD(GVRContext gvrContext, String skyBoxPath, String skyBoxName) { GVRSphereSceneObject sphereObject = null; // load texture GVRTexture texture = null; try { texture = gvrContext.getAssetLoader().loadTexture(new GVRAndroidResource(skyBoxPath + skyBoxName)); } catch (Exception e) { e.printStackTrace(); } // create a sphere scene object with the specified texture and triangles facing inward (the 'false' argument) sphereObject = new GVRSphereSceneObject(gvrContext, false, texture); sphereObject.getTransform().setScale(100, 100, 100); return sphereObject; }
private void addSphere(GVRScene scene, float radius, float x, float y, float z) throws IOException { GVRSceneObject sphereObject = new GVRSphereSceneObject(mGVRContext, true, createCustomMaterial(mGVRContext, "sphere.jpg")); sphereObject.setName("sphere"); sphereObject.getTransform().setPosition(x, y, z); sphereObject.getTransform().setScale(radius, radius, radius); scene.addSceneObject(sphereObject); }
@Override public void onClick(View v) { mVideoPlayer.hide(new OnFadeFinish() { @Override public void onFadeFinished() { mGallery.setEnable(true); mGallery.fadeIn(); mCurrentContainer = mGallery; mParentCursor.setEnable(true); } }); mSkybox.getRenderData().getMaterial().setColor(1.0f, 1.0f, 1.0f); } };
GVRSceneObject makeEnvironment(GVRContext context) { GVRTexture tex = context.getAssetLoader().loadCubemapTexture(new GVRAndroidResource(context, R.raw.lycksele3)); GVRMaterial material = new GVRMaterial(context, GVRMaterial.GVRShaderType.Cubemap.ID); material.setMainTexture(tex); GVRSphereSceneObject environment = new GVRSphereSceneObject(context, 18, 36, false, material, 4, 4); environment.getTransform().setScale(20.0f, 20.0f, 20.0f); if (!GVRShader.isVulkanInstance()) { GVRDirectLight sunLight = new GVRDirectLight(context); sunLight.setAmbientIntensity(0.4f, 0.4f, 0.4f, 1.0f); sunLight.setDiffuseIntensity(0.6f, 0.6f, 0.6f, 1.0f); environment.attachComponent(sunLight); } return environment; }
GVRCubeSceneObject cubeObject = new GVRCubeSceneObject(gvrContext, true, material); GVRSphereSceneObject sphereObject = new GVRSphereSceneObject( gvrContext, true, material); GVRCylinderSceneObject cylinderObject = new GVRCylinderSceneObject( cylinderObject.getTransform().setPosition(0.0f, 0.0f, -3.0f); coneObject.getTransform().setPosition(0.0f, 0.0f, -3.0f); sphereObject.getTransform().setPosition(0.0f, -1.0f, -3.0f); if (cameraObject != null) cameraObject.getTransform().setPosition(0.0f, 0.0f, -4.0f);
private void createVideoSceneObject() { GVRExternalTexture texture = new GVRExternalTexture(mGvrContext); SurfaceTexture surfaceTexture = new SurfaceTexture(texture.getId()); Surface surface = new Surface(surfaceTexture); mMediaPlayer = new DefaultExoPlayer(ExoPlayerFactory.newSimpleInstance(mGvrContext.getContext(), new DefaultTrackSelector())); mMediaPlayer.getPlayer().addListener(mPlayerListener); mFlatVideo = new GVRVideoSceneObject(mGvrContext, mGvrContext.createQuad(1, .6f), mMediaPlayer, texture, GVRVideoType.MONO); mFlatVideo.attachCollider(new GVRMeshCollider(getGVRContext(), true)); mFlatVideo.getTransform().setScale(10, 10, 1); mFlatVideo.getTransform().setPositionZ(-8.1f); addChildObject(mFlatVideo); GVRSphereSceneObject sphere = new GVRSphereSceneObject(mGvrContext, 72, 144, false); m360Video = new GVRVideoSceneObject(mGvrContext, sphere.getRenderData().getMesh(), mMediaPlayer, texture, GVRVideoType.MONO); m360Video.getTransform().setScale(100f, 100f, 100f); addChildObject(m360Video); setFlatPlayer(); }
GVRSceneObject makeBalloon(GVRContext context) { GVRSceneObject sphere = new GVRSphereSceneObject(context, true); GVRRenderData rdata = sphere.getRenderData(); GVRMaterial mtl = new GVRMaterial(context, GVRMaterial.GVRShaderType.Phong.ID); mtl.setDiffuseColor(1.0f, 0.0f, 1.0f, 0.5f); sphere.setName("balloon"); rdata.setAlphaBlend(true); rdata.setMaterial(mtl); rdata.setRenderingOrder(GVRRenderingOrder.TRANSPARENT); sphere.getTransform().setPositionZ(-3.0f); return sphere; }
GVRSceneObject makeEnvironment(GVRContext context) { GVRTexture tex = context.getAssetLoader().loadCubemapTexture(new GVRAndroidResource(context, R.raw.lycksele3)); GVRMaterial material = new GVRMaterial(context, GVRMaterial.GVRShaderType.Cubemap.ID); material.setMainTexture(tex); GVRSphereSceneObject environment = new GVRSphereSceneObject(context, 18, 36, false, material, 4, 4); environment.getTransform().setScale(20.0f, 20.0f, 20.0f); if (!GVRShader.isVulkanInstance()) { GVRDirectLight sunLight = new GVRDirectLight(context); sunLight.setAmbientIntensity(0.4f, 0.4f, 0.4f, 1.0f); sunLight.setDiffuseIntensity(0.6f, 0.6f, 0.6f, 1.0f); environment.attachComponent(sunLight); } return environment; }
GVRSphereSceneObject mSphereEvironment = new GVRSphereSceneObject( mGVRContext, 18, 36, false, mCubemapMaterial, 4, 4); mSphereEvironment.getTransform().setScale(CUBE_WIDTH, CUBE_WIDTH, CUBE_WIDTH); scene.addSceneObject(mSphereEvironment); sphere = new GVRSphereSceneObject(mGVRContext, 18, 36, true, cubemapReflectionMaterial); break;
mSphereMesh = new GVRSphereSceneObject(context, true).getRenderData().getMesh();
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; }