code
stringlengths
73
34.1k
label
stringclasses
1 value
public float getNormalX(int vertex) { if (!hasNormals()) { throw new IllegalStateException("mesh has no normals"); } checkVertexIndexBounds(vertex); return m_normals.getFloat(vertex * 3 * SIZEOF_FLOAT); }
java
public float getNormalY(int vertex) { if (!hasNormals()) { throw new IllegalStateException("mesh has no normals"); } checkVertexIndexBounds(vertex); return m_normals.getFloat((vertex * 3 + 1) * SIZEOF_FLOAT); }
java
public float getNormalZ(int vertex) { if (!hasNormals()) { throw new IllegalStateException("mesh has no normals"); } checkVertexIndexBounds(vertex); return m_normals.getFloat((vertex * 3 + 2) * SIZEOF_FLOAT); }
java
public float getTangentY(int vertex) { if (!hasTangentsAndBitangents()) { throw new IllegalStateException("mesh has no bitangents"); } checkVertexIndexBounds(vertex); return m_tangents.getFloat((vertex * 3 + 1) * SIZEOF_FLOAT); }
java
public float getBitangentY(int vertex) { if (!hasTangentsAndBitangents()) { throw new IllegalStateException("mesh has no bitangents"); } checkVertexIndexBounds(vertex); return m_bitangents.getFloat((vertex * 3 + 1) * SIZEOF_FLOAT); }
java
public float getColorR(int vertex, int colorset) { if (!hasColors(colorset)) { throw new IllegalStateException("mesh has no colorset " + colorset); } checkVertexIndexBounds(vertex); /* bound checks for colorset are done by java for us */ return m_col...
java
public float getTexCoordU(int vertex, int coords) { if (!hasTexCoords(coords)) { throw new IllegalStateException( "mesh has no texture coordinate set " + coords); } checkVertexIndexBounds(vertex); /* bound checks for coords are done by java for us...
java
@SuppressWarnings("WeakerAccess") public String getProperty(Enum<?> key, boolean lowerCase) { final String keyName; if (lowerCase) { keyName = key.name().toLowerCase(Locale.ENGLISH); } else { keyName = key.name(); } return getProperty(keyName); }
java
public JSONObject toJSON() { try { return new JSONObject(properties).putOpt("name", getName()); } catch (JSONException e) { e.printStackTrace(); Log.e(TAG, e, "toJSON()"); throw new RuntimeAssertion("NodeEntry.toJSON() failed for '%s'", this); } ...
java
@Override public void onRotationSensor(long timeStamp, float rotationW, float rotationX, float rotationY, float rotationZ, float gyroX, float gyroY, float gyroZ) { GVRCameraRig cameraRig = null; if (mMainScene != null) { cameraRig = mMainScene.getMainCame...
java
protected synchronized void setStream(InputStream s) { if (stream != null) { throw new UnsupportedOperationException("Cannot set the stream of an open resource"); } stream = s; streamState = StreamStates.OPEN; }
java
public synchronized final void closeStream() { try { if ((stream != null) && (streamState == StreamStates.OPEN)) { stream.close(); stream = null; } streamState = StreamStates.CLOSED; } catch (IOException e) { e.printStackTra...
java
public String getResourcePath() { switch (resourceType) { case ANDROID_ASSETS: return assetPath; case ANDROID_RESOURCE: return resourceFilePath; case LINUX_FILESYSTEM: return filePath; case NETWORK: return url.getPath(); case INPUT_STRE...
java
public String getResourceFilename() { switch (resourceType) { case ANDROID_ASSETS: return assetPath .substring(assetPath.lastIndexOf(File.separator) + 1); case ANDROID_RESOURCE: return resourceFilePath.substring( resourceFilePath.l...
java
public void loadModel(GVRAndroidResource avatarResource) { EnumSet<GVRImportSettings> settings = GVRImportSettings.getRecommendedSettingsWith(EnumSet.of(GVRImportSettings.OPTIMIZE_GRAPH, GVRImportSettings.NO_ANIMATION)); GVRContext ctx = mAvatarRoot.getGVRContext(); GVRResourceVolume volume ...
java
public void loadModel(GVRAndroidResource avatarResource, String attachBone) { EnumSet<GVRImportSettings> settings = GVRImportSettings.getRecommendedSettingsWith(EnumSet.of(GVRImportSettings.OPTIMIZE_GRAPH, GVRImportSettings.NO_ANIMATION)); GVRContext ctx = mAvatarRoot.getGVRContext(); GVRRes...
java
public void loadAnimation(GVRAndroidResource animResource, String boneMap) { String filePath = animResource.getResourcePath(); GVRContext ctx = mAvatarRoot.getGVRContext(); GVRResourceVolume volume = new GVRResourceVolume(ctx, animResource); if (filePath.endsWith(".bvh")) { ...
java
public void start(String name) { GVRAnimator anim = findAnimation(name); if (name.equals(anim.getName())) { start(anim); return; } }
java
public GVRAnimator findAnimation(String name) { for (GVRAnimator anim : mAnimations) { if (name.equals(anim.getName())) { return anim; } } return null; }
java
public GVRAnimator start(int animIndex) { if ((animIndex < 0) || (animIndex >= mAnimations.size())) { throw new IndexOutOfBoundsException("Animation index out of bounds"); } GVRAnimator anim = mAnimations.get(animIndex); start(anim); return anim; }
java
public GVRAnimator animate(int animIndex, float timeInSec) { if ((animIndex < 0) || (animIndex >= mAnimations.size())) { throw new IndexOutOfBoundsException("Animation index out of bounds"); } GVRAnimator anim = mAnimations.get(animIndex); anim.animate(timeInSec);...
java
public void stop() { synchronized (mAnimQueue) { if (mIsRunning && (mAnimQueue.size() > 0)) { mIsRunning = false; GVRAnimator animator = mAnimQueue.get(0); mAnimQueue.clear(); animator.stop(); } ...
java
public GVRTexture getSplashTexture(GVRContext gvrContext) { Bitmap bitmap = BitmapFactory.decodeResource( // gvrContext.getContext().getResources(), // R.drawable.__default_splash_screen__); GVRTexture tex = new GVRTexture(gvrContext); tex.setImage(new GVRBitmapIm...
java
public void onSplashScreenCreated(GVRSceneObject splashScreen) { GVRTransform transform = splashScreen.getTransform(); transform.setPosition(0, 0, DEFAULT_SPLASH_Z); }
java
public void setPosition(float x, float y, float z) { if (isActive()) { mIODevice.setPosition(x, y, z); } }
java
void close() { mIODevice = null; GVRSceneObject owner = getOwnerObject(); if (owner.getParent() != null) { owner.getParent().removeChildObject(owner); } }
java
public GVRMesh findMesh(GVRSceneObject model) { class MeshFinder implements GVRSceneObject.ComponentVisitor { private GVRMesh meshFound = null; public GVRMesh getMesh() { return meshFound; } public boolean visit(GVRComponent comp) { GVR...
java
@Override public boolean invokeFunction(String funcName, Object[] params) { // Run script if it is dirty. This makes sure the script is run // on the same thread as the caller (suppose the caller is always // calling from the same thread). checkDirty(); // Skip bad functions...
java
private boolean isInInnerCircle(float x, float y) { return GearWearableUtility.isInCircle(x, y, CENTER_X, CENTER_Y, INNER_RADIUS); }
java
@SuppressWarnings("unchecked") public <V3, M4, C, N, Q> V3 getUp(AiWrapperProvider<V3, M4, C, N, Q> wrapperProvider) { return (V3) m_up; }
java
public void dispatchKeyEvent(int code, int action) { int keyCode = 0; int keyAction = 0; if (code == BUTTON_1) { keyCode = KeyEvent.KEYCODE_BUTTON_1; } else if (code == BUTTON_2) { keyCode = KeyEvent.KEYCODE_BUTTON_2; } if (action == ACTION_DOWN) ...
java
void setState(final WidgetState.State state) { Log.d(TAG, "setState(%s): state is %s, setting to %s", mWidget.getName(), mState, state); if (state != mState) { final WidgetState.State nextState = getNextState(state); Log.d(TAG, "setState(%s): next state '%s'", mWidget.getName(), ...
java
public void setEnable(boolean flag) { if (mEnabled == flag) { return; } mEnabled = flag; if (flag) { mContext.registerDrawFrameListener(this); mContext.getApplication().getEventReceiver().addListener(this); mAudioEngine....
java
public void addSource(GVRAudioSource audioSource) { synchronized (mAudioSources) { if (!mAudioSources.contains(audioSource)) { audioSource.setListener(this); mAudioSources.add(audioSource); } } }
java
public void removeSource(GVRAudioSource audioSource) { synchronized (mAudioSources) { audioSource.setListener(null); mAudioSources.remove(audioSource); } }
java
public void clearSources() { synchronized (mAudioSources) { for (GVRAudioSource source : mAudioSources) { source.setListener(null); } mAudioSources.clear(); } }
java
private float[] generateParticleTimeStamps(float totalTime) { float timeStamps[] = new float[mEmitRate * 2]; if ( burstMode ) { for (int i = 0; i < mEmitRate * 2; i += 2) { timeStamps[i] = totalTime; timeStamps[i + 1] = 0; } } ...
java
private float[] generateParticleVelocities() { float [] particleVelocities = new float[mEmitRate * 3]; Vector3f temp = new Vector3f(0,0,0); for ( int i = 0; i < mEmitRate * 3 ; i +=3 ) { temp.x = mParticlePositions[i]; temp.y = mParticlePositions[i+1]; ...
java
public static void launchPermissionSettings(Activity activity) { Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData(Uri.fromParts("package", activity.getPackageName(), null)); activity.startActivity(intent); }
java
public void setFromJSON(Context context, JSONObject properties) { String backgroundResStr = optString(properties, Properties.background); if (backgroundResStr != null && !backgroundResStr.isEmpty()) { final int backgroundResId = getId(context, backgroundResStr, "drawable"); setBa...
java
public void onLayoutApplied(final WidgetContainer container, final Vector3Axis viewPortSize) { mContainer = container; mViewPort.setSize(viewPortSize); if (mContainer != null) { mContainer.onLayoutChanged(this); } }
java
public void invalidate() { synchronized (mMeasuredChildren) { Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "invalidate all [%d]", mMeasuredChildren.size()); mMeasuredChildren.clear(); } }
java
public void invalidate(final int dataIndex) { synchronized (mMeasuredChildren) { Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "invalidate [%d]", dataIndex); mMeasuredChildren.remove(dataIndex); } }
java
public float getChildSize(final int dataIndex, final Axis axis) { float size = 0; Widget child = mContainer.get(dataIndex); if (child != null) { switch (axis) { case X: size = child.getLayoutWidth(); break; case ...
java
public float getSize(final Axis axis) { float size = 0; if (mViewPort != null && mViewPort.isClippingEnabled(axis)) { size = mViewPort.get(axis); } else if (mContainer != null) { size = getSizeImpl(axis); } return size; }
java
public void setDividerPadding(float padding, final Axis axis) { if (!equal(mDividerPadding.get(axis), padding)) { mDividerPadding.set(padding, axis); if (mContainer != null) { mContainer.onLayoutChanged(this); } } }
java
public void setOffset(float offset, final Axis axis) { if (!equal(mOffset.get(axis), offset)) { mOffset.set(offset, axis); if (mContainer != null) { mContainer.onLayoutChanged(this); } } }
java
public synchronized Widget measureChild(final int dataIndex, boolean calculateOffset) { Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "measureChild dataIndex = %d", dataIndex); Widget widget = mContainer.get(dataIndex); if (widget != null) { synchronized (mMeasuredChildren) { mMe...
java
public boolean measureAll(List<Widget> measuredChildren) { boolean changed = false; for (int i = 0; i < mContainer.size(); ++i) { if (!isChildMeasured(i)) { Widget child = measureChild(i, false); if (child != null) { if (measuredChildren !...
java
public void layoutChildren() { Set<Integer> copySet; synchronized (mMeasuredChildren) { Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "layoutChildren [%d] layout = %s", mMeasuredChildren.size(), this); copySet = new HashSet<>(mMeasuredChildren); } for (int...
java
protected float getViewPortSize(final Axis axis) { float size = mViewPort == null ? 0 : mViewPort.get(axis); Log.d(Log.SUBSYSTEM.LAYOUT, TAG, "getViewPortSize for %s %f mViewPort = %s", axis, size, mViewPort); return size; }
java
protected void layoutChild(final int dataIndex) { Widget child = mContainer.get(dataIndex); if (child != null) { float offset = mOffset.get(Axis.X); if (!equal(offset, 0)) { updateTransform(child, Axis.X, offset); } offset = mOffset.get(Ax...
java
protected void postLayoutChild(final int dataIndex) { if (!mContainer.isDynamic()) { boolean visibleInLayout = !mViewPort.isClippingEnabled() || inViewPort(dataIndex); ViewPortVisibility visibility = visibleInLayout ? ViewPortVisibility.FULLY_VISIBLE : ViewPortVisibil...
java
static GVRCollider lookup(long nativePointer) { synchronized (sColliders) { WeakReference<GVRCollider> weakReference = sColliders.get(nativePointer); return weakReference == null ? null : weakReference.get(); } }
java
private void createSimpleCubeSixMeshes(GVRContext gvrContext, boolean facingOut, String vertexDesc, ArrayList<GVRTexture> textureList) { GVRSceneObject[] children = new GVRSceneObject[6]; GVRMesh[] meshes = new GVRMesh[6]; GVRVertexBuffer vbuf = new GVRVertexBuffer(gvrContext, ve...
java
protected void update(float scale) { GVRSceneObject owner = getOwnerObject(); if (isEnabled() && (owner != null) && owner.isEnabled()) { float w = getWidth(); float h = getHeight(); mPose.update(mARPlane.getCenterPose(), scale); Matrix4f m = new Ma...
java
public void setValue(Vector3f pos) { mX = pos.x; mY = pos.y; mZ = pos.z; }
java
public void getKey(int keyIndex, float[] values) { int index = keyIndex * mFloatsPerKey; System.arraycopy(mKeys, index + 1, values, 0, values.length); }
java
public void setKey(int keyIndex, float time, final float[] values) { int index = keyIndex * mFloatsPerKey; Integer valSize = mFloatsPerKey-1; if (values.length != valSize) { throw new IllegalArgumentException("This key needs " + valSize.toString() + " float per value"); ...
java
public void resizeKeys(int numKeys) { int n = numKeys * mFloatsPerKey; if (mKeys.length == n) { return; } float[] newKeys = new float[n]; n = Math.min(n, mKeys.length); System.arraycopy(mKeys, 0, newKeys, 0, n); mKeys = newKeys; mF...
java
public void setEnable(boolean flag) { if (flag == mIsEnabled) return; mIsEnabled = flag; if (getNative() != 0) { NativeComponent.setEnable(getNative(), flag); } if (flag) { onEnable(); } else { ...
java
public void registerDatatype(Class<? extends GVRHybridObject> textureClass, AsyncLoaderFactory<? extends GVRHybridObject, ?> asyncLoaderFactory) { mFactories.put(textureClass, asyncLoaderFactory); }
java
public void assertGLThread() { if (Thread.currentThread().getId() != mGLThreadID) { RuntimeException e = new RuntimeException( "Should not run GL functions from a non-GL thread!"); e.printStackTrace(); throw e; } }
java
public void logError(String message, Object sender) { getEventManager().sendEvent(this, IErrorEvents.class, "onError", new Object[] { message, sender }); }
java
public synchronized void stopDebugServer() { if (mDebugServer == null) { Log.e(TAG, "Debug server is not running."); return; } mDebugServer.shutdown(); mDebugServer = null; }
java
public void showToast(final String message, float duration) { final float quadWidth = 1.2f; final GVRTextViewSceneObject toastSceneObject = new GVRTextViewSceneObject(this, quadWidth, quadWidth / 5, message); toastSceneObject.setTextSize(6); toastSceneObject.setTextColor...
java
public void append(float[] newValue) { if ( (newValue.length % 2) == 0) { for (int i = 0; i < (newValue.length/2); i++) { value.add( new SFVec2f(newValue[i*2], newValue[i*2+1]) ); } } else { Log.e(TAG, "X3D MFVec3f append set with array length ...
java
public void insertValue(int index, float[] newValue) { if ( newValue.length == 2) { try { value.add( index, new SFVec2f(newValue[0], newValue[1]) ); } catch (IndexOutOfBoundsException e) { Log.e(TAG, "X3D MFVec2f get1Value(index) out of bounds....
java
public void setOuterConeAngle(float angle) { setFloat("outer_cone_angle", (float) Math.cos(Math.toRadians(angle))); mChanged.set(true); }
java
public void setCastShadow(boolean enableFlag) { GVRSceneObject owner = getOwnerObject(); if (owner != null) { GVRShadowMap shadowMap = (GVRShadowMap) getComponent(GVRRenderTarget.getComponentType()); if (enableFlag) { if (shadowMap != null...
java
public GVRCursorController findCursorController(GVRControllerType type) { for (int index = 0, size = cache.size(); index < size; index++) { int key = cache.keyAt(index); GVRCursorController controller = cache.get(key); if (controller.getControllerType().equals(type)) ...
java
public int clear() { int n = 0; for (GVRCursorController c : controllers) { c.stopDrag(); removeCursorController(c); ++n; } return n; }
java
public void close() { inputManager.unregisterInputDeviceListener(inputDeviceListener); mouseDeviceManager.forceStopThread(); gamepadDeviceManager.forceStopThread(); controllerIds.clear(); cache.clear(); controllers.clear(); }
java
private GVRCursorController getUniqueControllerId(int deviceId) { GVRCursorController controller = controllerIds.get(deviceId); if (controller != null) { return controller; } return null; }
java
private int getCacheKey(InputDevice device, GVRControllerType controllerType) { if (controllerType != GVRControllerType.UNKNOWN && controllerType != GVRControllerType.EXTERNAL) { // Sometimes a device shows up using two device ids // here we try to show both devices as one us...
java
private GVRCursorController addDevice(int deviceId) { InputDevice device = inputManager.getInputDevice(deviceId); GVRControllerType controllerType = getGVRInputDeviceType(device); if (mEnabledControllerTypes == null) { return null; } if (controllerType == GVR...
java
public List<GVRAtlasInformation> getAtlasInformation() { if ((mImage != null) && (mImage instanceof GVRImageAtlas)) { return ((GVRImageAtlas) mImage).getAtlasInformation(); } return null; }
java
public void setImage(final GVRImage imageData) { mImage = imageData; if (imageData != null) NativeTexture.setImage(getNative(), imageData, imageData.getNative()); else NativeTexture.setImage(getNative(), null, 0); }
java
public static void sendEvent(Context context, Parcelable event) { Intent intent = new Intent(EventManager.ACTION_ACCESSORY_EVENT); intent.putExtra(EventManager.EXTRA_EVENT, event); context.sendBroadcast(intent); }
java
public static AiScene importFile(String filename) throws IOException { return importFile(filename, EnumSet.noneOf(AiPostProcessSteps.class)); }
java
public void addChannel(String boneName, GVRAnimationChannel channel) { int boneId = mSkeleton.getBoneIndex(boneName); if (boneId >= 0) { mBoneChannels[boneId] = channel; mSkeleton.setBoneOptions(boneId, GVRSkeleton.BONE_ANIMATE); Log.d("BONE", "Adding anim...
java
public GVRAnimationChannel findChannel(String boneName) { int boneId = mSkeleton.getBoneIndex(boneName); if (boneId >= 0) { return mBoneChannels[boneId]; } return null; }
java
public void animate(float timeInSec) { GVRSkeleton skel = getSkeleton(); GVRPose pose = skel.getPose(); computePose(timeInSec,pose); skel.poseToBones(); skel.updateBonePose(); skel.updateSkinPose(); }
java
public void put(GVRAndroidResource androidResource, T resource) { Log.d(TAG, "put resource %s to cache", androidResource); super.put(androidResource, resource); }
java
public void removeControl(String name) { Widget control = findChildByName(name); if (control != null) { removeChild(control); if (mBgResId != -1) { updateMesh(); } } }
java
public void addControl(String name, JSONObject properties, Widget.OnTouchListener listener) { final JSONObject allowedProperties = new JSONObject(); put(allowedProperties, Widget.Properties.name, optString(properties, Widget.Properties.name)); put(allowedProperties, Widget.Properties.size, new P...
java
public Widget addControl(String name, int resId, Widget.OnTouchListener listener) { return addControl(name, resId, null, listener, -1); }
java
public Widget addControl(String name, int resId, String label, Widget.OnTouchListener listener) { return addControl(name, resId, label, listener, -1); }
java
public Widget addControl(String name, int resId, Widget.OnTouchListener listener, int position) { Widget control = findChildByName(name); if (control == null) { control = createControlWidget(resId, name, null); } setupControl(name, control, listener, position); return...
java
public void setMesh(GVRMesh mesh) { mMesh = mesh; NativeMeshCollider.setMesh(getNative(), mesh.getNative()); }
java
public void setLinearLowerLimits(float limitX, float limitY, float limitZ) { Native3DGenericConstraint.setLinearLowerLimits(getNative(), limitX, limitY, limitZ); }
java
public void setLinearUpperLimits(float limitX, float limitY, float limitZ) { Native3DGenericConstraint.setLinearUpperLimits(getNative(), limitX, limitY, limitZ); }
java
public void setAngularLowerLimits(float limitX, float limitY, float limitZ) { Native3DGenericConstraint.setAngularLowerLimits(getNative(), limitX, limitY, limitZ); }
java
public void setAngularUpperLimits(float limitX, float limitY, float limitZ) { Native3DGenericConstraint.setAngularUpperLimits(getNative(), limitX, limitY, limitZ); }
java
GVRSceneObject makeParticleMesh(float[] vertices, float[] velocities, float[] particleTimeStamps ) { mParticleMesh = new GVRMesh(mGVRContext); //pass the particle positions as vertices, velocities as normals, and //spawning times as texture coordin...
java
public void setFilePath(String filePath) throws IOException, GVRScriptException { GVRResourceVolume.VolumeType volumeType = GVRResourceVolume.VolumeType.ANDROID_ASSETS; String fname = filePath.toLowerCase(); mLanguage = FileNameUtils.getExtension(fname); if (fname.st...
java
public void setScriptText(String scriptText, String language) { GVRScriptFile newScript = new GVRJavascriptScriptFile(getGVRContext(), scriptText); mLanguage = GVRScriptManager.LANG_JAVASCRIPT; setScriptFile(newScript); }
java
public boolean invokeFunction(String funcName, Object[] args) { mLastError = null; if (mScriptFile != null) { if (mScriptFile.invokeFunction(funcName, args)) { return true; } } mLastError = mScriptFile.getLastError(); ...
java
public void setTextureBufferSize(final int size) { mRootViewGroup.post(new Runnable() { @Override public void run() { mRootViewGroup.setTextureBufferSize(size); } }); }
java
public void setBackgroundColor(int color) { setBackgroundColorR(Colors.byteToGl(Color.red(color))); setBackgroundColorG(Colors.byteToGl(Color.green(color))); setBackgroundColorB(Colors.byteToGl(Color.blue(color))); setBackgroundColorA(Colors.byteToGl(Color.alpha(color))); }
java