private void onHit(GVRSceneObject sceneObj) { Particle particle = (Particle) sceneObj.getComponent(Particle.getComponentType()); if (particle != null) { mParticleSystem.stop(particle); } } }
public void selectObject() { GVRSwitch selector = (GVRSwitch) mObjectRot.getComponent(GVRSwitch.getComponentType()); selector.setSwitchIndex(ThumbnailSelected); }
public void onExit(GVRSceneObject sceneObj, GVRPicker.GVRPickedObject pickInfo) { if ((mSelected == sceneObj) || (mSelected == null)) { mSelectionLight.getComponent(GVRLight.getComponentType()).disable(); mSelected = null; } }
public void endTouch() { GVRPointLight light = (GVRPointLight) mSelectionLight.getComponent(GVRLight.getComponentType()); light.setDiffuseIntensity(PICKED_COLOR[0], PICKED_COLOR[1], PICKED_COLOR[1], PICKED_COLOR[2]); mSelected = null; mSelectionMode = UNTOUCHED; } }
private void onHit(GVRSceneObject sceneObj) { Particle particle = (Particle) sceneObj.getComponent(Particle.getComponentType()); if (!mGameOver && (particle != null)) { mPopSound.play(); mParticleSystem.stop(particle); mScore += Math.round(particle.Velocity); mScoreBoard.setText("Score: " + mScore.toString()); } } }
private void onHit(GVRSceneObject sceneObj) { Particle particle = (Particle) sceneObj.getComponent(Particle.getComponentType()); if (particle != null) { mPopSound.play(); mParticleSystem.stop(particle); mScore += Math.round(particle.Velocity); mScoreBoard.setText(mScore.toString()); } else if (sceneObj == mScoreBoard) { gameStart(); } } }
public void startTouch(GVRSceneObject sceneObj, float hitx, float hity, int mode) { GVRPointLight light = (GVRPointLight) mSelectionLight.getComponent(GVRLight.getComponentType()); mSelectionMode = mode; mSelected = sceneObj; if (mode == DRAG) { light.setDiffuseIntensity(DRAG_COLOR[0], DRAG_COLOR[1], DRAG_COLOR[1], DRAG_COLOR[2]); } else { light.setDiffuseIntensity(UPDATE_COLOR[0], UPDATE_COLOR[1], UPDATE_COLOR[1], UPDATE_COLOR[2]); } mHitX = hitx; mHitY = hity; }
(GVRPointLight) mSelectionLight.getComponent(GVRLight.getComponentType()); light.setDiffuseIntensity(PICKED_COLOR[0], PICKED_COLOR[1], mSelectionLight.getComponent(GVRLight.getComponentType()).enable(); mSelectionLight.getComponent(GVRLight.getComponentType()).enable(); mSelectionLight.getComponent(GVRLight.getComponentType()).enable();
private void drag(float x, float y) { GVRAnchor anchor = (GVRAnchor) mSelected.getParent().getComponent(GVRAnchor.getComponentType()); if (anchor != null) { GVRHitResult hit = mMixedReality.hitTest(x, y); if (hit != null) { // move the object to a new position mMixedReality.updateAnchorPose(anchor, hit.getPose()); } } }
GVRSceneObject andy = load3dModel(getGVRContext()); anchorObj.addChildObject(andy); GVRAnchor anchor = (GVRAnchor) anchorObj.getComponent(GVRAnchor.getComponentType()); mVirtualObjects.add(anchor); mainScene.addSceneObject(anchorObj);
private void loadModel(GVRContext context) { try { Log.d(TAG, "Absent so loading" + name); model = context.getAssetLoader().loadModel("sd:" + location); } catch (IOException e) { e.printStackTrace(); Log.e(TAG, "Unable to load model"); return; } GVRSceneObject.BoundingVolume bv = model.getBoundingVolume(); model.attachComponent(new GVRMeshCollider(context, true)); // Adding Pointee to Model bv = model.getBoundingVolume(); float originalRadius = bv.radius; Log.i(TAG, "Radius" + Float.toString(originalRadius)); // TODO Scale Appropriately if (originalRadius > 7.0f || originalRadius < 5.0f) { float scaleFactor = 7 / originalRadius; model.getTransform().setScale(scaleFactor, scaleFactor, scaleFactor); } // Make Copy of Original Render Data saveRenderData(); // Load Animations animation = (GVRAnimator) model.getComponent(GVRAnimator.getComponentType()); }
private GVRAnimator setupAnimation(GVRSceneObject root) { GVRSceneObject baseObject = mObjectRoot.getSceneObjectByName("Sloth_face"); GVRMeshMorph morph = (GVRMeshMorph)baseObject.getComponent(GVRMeshMorph.getComponentType()); int numBlendShapes = morph.getBlendShapeCount(); float [] keys = generateAnimationKeys(numBlendShapes, animDuration); GVRAnimator animator = (GVRAnimator) root.getComponent(GVRAnimator.getComponentType()); if (animator == null) { animator = new GVRAnimator(root.getGVRContext()); root.attachComponent(animator); } GVRMorphAnimation morphAnim = new GVRMorphAnimation(morph, keys, numBlendShapes + 1); animator.addAnimation(morphAnim); animator.setRepeatMode(GVRRepeatMode.PINGPONG); animator.setRepeatCount(1000); return animator; }
GVRRigidBody rigidBody = (GVRRigidBody) mCurrentBall.getComponent(GVRRigidBody.getComponentType()); rigidBody.setEnable(false); controller.getCursor().addChildObject(mCurrentBall); GVRRigidBody rigidBody = (GVRRigidBody) mCurrentBall.getComponent(GVRRigidBody.getComponentType()); Matrix4f ballMtx = ballTrans.getModelMatrix4f();
@Override public void onInit(GVRContext gvrContext) { mGVRContext = gvrContext; mAnimationEngine = gvrContext.getAnimationEngine(); GVRScene mainScene = gvrContext.getMainScene(); try { mCharacter = gvrContext.getAssetLoader().loadModel(mModelPath, mainScene); mCharacter.getTransform().setPosition(0.0f, -10.0f, -10.0f); mCharacter.getTransform().setRotationByAxis(40.0f, 1.0f, 0.0f, 0.0f); mCharacter.getTransform().setScale(1.5f, 1.5f, 1.5f); mAssimpAnimation = (GVRAnimator) mCharacter.getComponent(GVRAnimator.getComponentType()); mAssimpAnimation.setRepeatMode(GVRRepeatMode.REPEATED); mAssimpAnimation.setRepeatCount(-1); } catch (IOException e) { e.printStackTrace(); mActivity.finish(); mActivity = null; Log.e(TAG, "One or more assets could not be loaded."); } mAssimpAnimation.start(); }
private GVRScene createRenderToTextureScene() { final GVRScene newScene = new GVRScene(getGVRContext()); final GVRPerspectiveCamera centerCamera = newScene.getMainCameraRig().getCenterCamera(); centerCamera.setBackgroundColor(0.7f, 0.4f, 0, 1); try { final GVRSceneObject model = getGVRContext().getAssetLoader().loadModel("astro_boy.dae", newScene); model.getTransform() .setRotationByAxis(45.0f, 0.0f, 1.0f, 0.0f) .setScale(2, 2, 2) .setPosition(0.0f, -0.15f, -0.3f); GVRAnimator animations = (GVRAnimator) model.getComponent(GVRAnimator.getComponentType()); if (animations != null) { animations.setRepeatMode(GVRRepeatMode.REPEATED); animations.setRepeatCount(-1); animations.start(); } } catch (final IOException e) { Log.e(TAG, "Failed to load a model: %s", e); getGVRContext().getActivity().finish(); } return newScene; }
anchor = (GVRAnchor) avatarAnchor.getComponent(GVRAnchor.getComponentType()); mMixedReality.updateAnchorPose(anchor, pose);