/** * Get the depth of the touch screen in the 3D world * and give it to the cursor controller so touch * events will be handled properly. */ @Override public void onStartPlaneDetection(IMixedReality mr) { float screenDepth = mr.getScreenDepth(); mr.getPassThroughObject().getEventReceiver().addListener(mTouchHandler); helper.initCursorController(mGVRContext, mTouchHandler, screenDepth); }
/** * Loads a 3D model using the asset loaqder and attaches * a collider to it so it can be picked. * If you are using phone AR, the touch screen can * be used to drag, rotate or scale the object. * If you are using a headset, the controller * is used for picking and moving. */ private GVRSceneObject load3dModel(final GVRContext gvrContext) throws IOException { final GVRSceneObject sceneObject = gvrContext.getAssetLoader().loadModel("objects/andy.obj"); sceneObject.attachComponent(new GVRBoxCollider(gvrContext)); sceneObject.getEventReceiver().addListener(mSelector); return sceneObject; }
SpaceObject(CursorManager cursorMgr, GVRSceneObject asset, String name, Vector3f position, float scale, float rotationX, float rotationY, float orientationX, float orientationY, float orientationZ) { this.x = position.x; this.y = position.y; this.z = position.z; this.rotationX = rotationX; this.rotationY = rotationY; this.orientationX = orientationX; this.orientationY = orientationY; this.orientationZ = orientationZ; mainObject = asset; mainObject.setName(name); mainObject.getTransform().setScale(scale, scale, scale); reset(); mainObject.getEventReceiver().addListener(this); mainObject.attachComponent(new SelectableBehavior(cursorMgr, true)); }
private void addSphere(GVRScene scene, float radius, float x, float y, float z, float mass) { GVRSceneObject sphereObject = meshWithTexture("sphere.obj", "sphere.jpg"); sphereObject.getTransform().setPosition(x, y, z); // Collider GVRSphereCollider sphereCollider = new GVRSphereCollider(mGVRContext); sphereCollider.setRadius(1.0f); sphereObject.attachCollider(sphereCollider); // Physics body mSphereRigidBody = new GVRRigidBody(mGVRContext, mass); mSphereRigidBody.setRestitution(1.5f); mSphereRigidBody.setFriction(0.5f); sphereObject.getEventReceiver().addListener(mCollisionHandler); sphereObject.attachComponent(mSphereRigidBody); scene.addSceneObject(sphereObject); }
avatarModel.attachComponent(new GVRBoxCollider(mContext)); mScene.addSceneObject(avatarAnchor); avatarModel.getEventReceiver().addListener(mSelector);