code
stringlengths
73
34.1k
label
stringclasses
1 value
protected void AddLODSceneObject(GVRSceneObject currentSceneObject) { if (this.transformLODSceneObject != null) { GVRSceneObject levelOfDetailSceneObject = null; if ( currentSceneObject.getParent() == this.transformLODSceneObject) { levelOfDetailSceneObject = currentSceneObject; } el...
java
@Override public boolean applyLayout(Layout itemLayout) { boolean applied = false; if (itemLayout != null && mItemLayouts.add(itemLayout)) { // apply the layout to all visible pages List<Widget> views = getAllViews(); for (Widget view: views) { vi...
java
public LayoutScroller.ScrollableList getPageScrollable() { return new LayoutScroller.ScrollableList() { @Override public int getScrollingItemsCount() { return MultiPageWidget.super.getScrollingItemsCount(); } @Override public float g...
java
public void startAnimation() { Date time = new Date(); this.beginAnimation = time.getTime(); this.endAnimation = beginAnimation + (long) (animationTime * 1000); this.animate = true; }
java
public void updateAnimation() { Date time = new Date(); long currentTime = time.getTime() - this.beginAnimation; if (currentTime > animationTime) { this.currentQuaternion.set(endQuaternion); for (int i = 0; i < 3; i++) { this.currentPos[i] = this.endPos[i]; } thi...
java
public int[] getDefalutValuesArray() { int[] defaultValues = new int[5]; defaultValues[0] = GLES20.GL_LINEAR_MIPMAP_NEAREST; // MIN FILTER defaultValues[1] = GLES20.GL_LINEAR; // MAG FILTER defaultValues[2] = 1; // ANISO FILTER defaultValues[3] = GLES20.GL_CLAMP_TO_EDGE; // WRAP...
java
public int[] getCurrentValuesArray() { int[] currentValues = new int[5]; currentValues[0] = getMinFilterType().getFilterValue(); // MIN FILTER currentValues[1] = getMagFilterType().getFilterValue(); // MAG FILTER currentValues[2] = getAnisotropicValue(); // ANISO FILTER currentV...
java
public boolean hasProperties(Set<PropertyKey> keys) { for (PropertyKey key : keys) { if (null == getProperty(key.m_key)) { return false; } } return true; }
java
public Integer getTextureMagFilter(AiTextureType type, int index) { checkTexRange(type, index); Property p = getProperty(PropertyKey.TEX_MAG_FILTER.m_key); if (null == p || null == p.getData()) { return (Integer) m_defaults.get(PropertyKey.TEX_MAG_FILTER); } Object ...
java
public float getMetallic() { Property p = getProperty(PropertyKey.METALLIC.m_key); if (null == p || null == p.getData()) { throw new IllegalArgumentException("Metallic property not found"); } Object rawValue = p.getData(); if (rawValue instanceof java.nio...
java
public AiTextureInfo getTextureInfo(AiTextureType type, int index) { return new AiTextureInfo(type, index, getTextureFile(type, index), getTextureUVIndex(type, index), getBlendFactor(type, index), getTextureOp(type, index), getTextureMapModeW(type, index), getT...
java
private void checkTexRange(AiTextureType type, int index) { if (index < 0 || index > m_numTextures.get(type)) { throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + m_numTextures.get(type)); } }
java
@SuppressWarnings("unused") private void setTextureNumber(int type, int number) { m_numTextures.put(AiTextureType.fromRawValue(type), number); }
java
public void setFrustum(float[] frustum) { Matrix4f projMatrix = new Matrix4f(); projMatrix.setFrustum(frustum[0], frustum[3], frustum[1], frustum[4], frustum[2], frustum[5]); setFrustum(projMatrix); }
java
public void setFrustum(float fovy, float aspect, float znear, float zfar) { Matrix4f projMatrix = new Matrix4f(); projMatrix.perspective((float) Math.toRadians(fovy), aspect, znear, zfar); setFrustum(projMatrix); }
java
public void setFrustum(Matrix4f projMatrix) { if (projMatrix != null) { if (mProjMatrix == null) { mProjMatrix = new float[16]; } mProjMatrix = projMatrix.get(mProjMatrix, 0); mScene.setPickVisible(false); if (mC...
java
public static final GVRPickedObject[] pickVisible(GVRScene scene) { sFindObjectsLock.lock(); try { final GVRPickedObject[] result = NativePicker.pickVisible(scene.getNative()); return result; } finally { sFindObjectsLock.unlock(); } }
java
public void setShortVec(char[] data) { if (data == null) { throw new IllegalArgumentException("Input data for indices cannot be null"); } if (getIndexSize() != 2) { throw new UnsupportedOperationException("Cannot update integer indices with char array"...
java
public void setShortVec(CharBuffer data) { if (data == null) { throw new IllegalArgumentException("Input data for indices cannot be null"); } if (getIndexSize() != 2) { throw new UnsupportedOperationException("Cannot update integer indices with char ar...
java
public void setIntVec(int[] data) { if (data == null) { throw new IllegalArgumentException("Input data for indices cannot be null"); } if (getIndexSize() != 4) { throw new UnsupportedOperationException("Cannot update short indices with int array"); ...
java
public void setIntVec(IntBuffer data) { if (data == null) { throw new IllegalArgumentException("Input buffer for indices cannot be null"); } if (getIndexSize() != 4) { throw new UnsupportedOperationException("Cannot update integer indices with short ar...
java
protected void emitWithBurstCheck(float[] particlePositions, float[] particleVelocities, float[] particleTimeStamps) { if ( burstMode ) { if ( executeOnce ) { emit(particlePositions, particleVelocities, particleTimeStamps); ...
java
private void emit(float[] particlePositions, float[] particleVelocities, float[] particleTimeStamps) { float[] allParticlePositions = new float[particlePositions.length + particleBoundingVolume.length]; System.arraycopy(particlePositions, 0, allParticlePositions, 0, particlePos...
java
public void setVelocityRange( final Vector3f minV, final Vector3f maxV ) { if (null != mGVRContext) { mGVRContext.runOnGlThread(new Runnable() { @Override public void run() { minVelocity = minV; maxVelocity = maxV; ...
java
public static void logLong(String TAG, String longString) { InputStream is = new ByteArrayInputStream( longString.getBytes() ); @SuppressWarnings("resource") Scanner scan = new Scanner(is); while (scan.hasNextLine()) { Log.v(TAG, scan.nextLine()); } }
java
public static String readTextFile(Context context, String asset) { try { InputStream inputStream = context.getAssets().open(asset); return org.gearvrf.utility.TextFile.readTextFile(inputStream); } catch (FileNotFoundException f) { Log.w(TAG, "readTextFile(): asset fil...
java
public static boolean equal(Vector3f v1, Vector3f v2) { return equal(v1.x, v2.x) && equal(v1.y, v2.y) && equal(v1.z, v2.z); }
java
public static int getId(Context context, String id) { final String defType; if (id.startsWith("R.")) { int dot = id.indexOf('.', 2); defType = id.substring(2, dot); } else { defType = "drawable"; } Log.d(TAG, "getId(): id: %s, extracted type: ...
java
public static int getId(Context context, String id, String defType) { String type = "R." + defType + "."; if (id.startsWith(type)) { id = id.substring(type.length()); } Resources r = context.getResources(); int resId = r.getIdentifier(id, defType, con...
java
public String generateSignature(HashMap<String, Integer> defined, GVRLight[] lightlist) { return getClass().getSimpleName(); }
java
public int bindShader(GVRContext context, IRenderable rdata, GVRScene scene, boolean isMultiview) { String signature = getClass().getSimpleName(); GVRShaderManager shaderManager = context.getShaderManager(); GVRMaterial mtl = rdata.getMaterial(); synchronized (shaderManager) ...
java
public int bindShader(GVRContext context, GVRShaderData material, String vertexDesc) { String signature = getClass().getSimpleName(); GVRShaderManager shaderManager = context.getShaderManager(); synchronized (shaderManager) { int nativeShader = shaderManager.getShader(si...
java
public GVRSceneObject startDrag(GVRSceneObject dragMe, float relX, float relY, float relZ) { synchronized (mLock) { if (mCursorController == null) { Log.w(TAG, "Physics drag failed: Cursor controller not found!"); return null; } if (mDragMe !=...
java
public void setTexCoord(String texName, String texCoordAttr, String shaderVarName) { synchronized (textures) { GVRTexture tex = textures.get(texName); if (tex != null) { tex.setTexCoord(texCoordAttr, shaderVarName); } else ...
java
public String getTexCoordAttr(String texName) { GVRTexture tex = textures.get(texName); if (tex != null) { return tex.getTexCoordAttr(); } return null; }
java
public String getTexCoordShaderVar(String texName) { GVRTexture tex = textures.get(texName); if (tex != null) { return tex.getTexCoordShaderVar(); } return null; }
java
public String getProperty(String key, String defaultValue) { return mProperties.getProperty(key, defaultValue); }
java
public synchronized void hide() { if (focusedQuad != null) { mDefocusAnimationFactory.create(focusedQuad) .setRequestLayoutOnTargetChange(false) .start().finish(); focusedQuad = null; } Log.d(Log.SUBSYSTEM.WIDGET, TAG, "hide Picke...
java
public void set1Value(int index, String newValue) { try { value.set( index, newValue ); } catch (IndexOutOfBoundsException e) { Log.e(TAG, "X3D MFString set1Value(int index, ...) out of bounds." + e); } catch (Exception e) { Log.e(TAG, "X3D MFS...
java
public void setValue(int numStrings, String[] newValues) { value.clear(); if (numStrings == newValues.length) { for (int i = 0; i < newValues.length; i++) { value.add(newValues[i]); } } else { Log.e(TAG, "X3D MFString setValue() numStri...
java
public void update(int width, int height, byte[] grayscaleData) { NativeBitmapImage.updateFromMemory(getNative(), width, height, grayscaleData); }
java
public static void start(final GVRContext context, final String appId, final ResultListener listener) { if (null == listener) { throw new IllegalArgumentException("listener cannot be null"); } final Activity activity = context.getActivity(); final long result = create(activi...
java
public synchronized void tick() { long currentTime = GVRTime.getMilliTime(); long cutoffTime = currentTime - BUFFER_SECONDS * 1000; ListIterator<Long> it = mTimestamps.listIterator(); while (it.hasNext()) { Long timestamp = it.next(); if (timestamp < cutoffTime) {...
java
public void addControllerType(GVRControllerType controllerType) { if (cursorControllerTypes == null) { cursorControllerTypes = new ArrayList<GVRControllerType>(); } else if (cursorControllerTypes.contains(controllerType)) { return; } cu...
java
public static void checkStringNotNullOrEmpty(String parameterName, String value) { if (TextUtils.isEmpty(value)) { throw Exceptions.IllegalArgument("Current input string %s is %s.", parameterName, value == null ? "null" : "empty"); } }
java
public static void checkArrayLength(String parameterName, int actualLength, int expectedLength) { if (actualLength != expectedLength) { throw Exceptions.IllegalArgument( "Array %s should have %d elements, not %d", parameterName, expectedLength, act...
java
public static void checkMinimumArrayLength(String parameterName, int actualLength, int minimumLength) { if (actualLength < minimumLength) { throw Exceptions .IllegalArgument( "Array %s should have at least %d elements, but it only has %d", ...
java
public static void checkFloatNotNaNOrInfinity(String parameterName, float data) { if (Float.isNaN(data) || Float.isInfinite(data)) { throw Exceptions.IllegalArgument( "%s should never be NaN or Infinite.", parameterName); } }
java
public void transformPose(Matrix4f trans) { Bone bone = mBones[0]; bone.LocalMatrix.set(trans); bone.WorldMatrix.set(trans); bone.Changed = WORLD_POS | WORLD_ROT; mNeedSync = true; sync(); }
java
public void inverse(GVRPose src) { if (getSkeleton() != src.getSkeleton()) throw new IllegalArgumentException("GVRPose.copy: input pose is incompatible with this pose"); src.sync(); int numbones = getNumBones(); Bone srcBone = src.mBones[0]; Bone dstBone = mBones...
java
protected void calcWorld(Bone bone, int parentId) { getWorldMatrix(parentId, mTempMtxB); // WorldMatrix (parent) TempMtxB mTempMtxB.mul(bone.LocalMatrix); // WorldMatrix = WorldMatrix(parent) * LocalMatrix bone.WorldMatrix.set(mTempMtxB); }
java
protected void calcLocal(Bone bone, int parentId) { if (parentId < 0) { bone.LocalMatrix.set(bone.WorldMatrix); return; } /* * WorldMatrix = WorldMatrix(parent) * LocalMatrix * LocalMatrix = INVERSE[ WorldMatrix(parent) ] * WorldMatrix */ getWorldMatri...
java
public void setVec3(String key, float x, float y, float z) { checkKeyIsUniform(key); NativeLight.setVec3(getNative(), key, x, y, z); }
java
public void setVec4(String key, float x, float y, float z, float w) { checkKeyIsUniform(key); NativeLight.setVec4(getNative(), key, x, y, z, w); }
java
public void setMat4(String key, float x1, float y1, float z1, float w1, float x2, float y2, float z2, float w2, float x3, float y3, float z3, float w3, float x4, float y4, float z4, float w4) { checkKeyIsUniform(key); NativeLight.setMat4(getNative(), k...
java
public void onDrawFrame(float frameTime) { if (!isEnabled() || (owner == null) || (getFloat("enabled") <= 0.0f)) { return; } float[] odir = getVec3("world_direction"); float[] opos = getVec3("world_position"); GVRSceneObject parent = owner; Matrix4...
java
public void setProjectionMatrix(float x1, float y1, float z1, float w1, float x2, float y2, float z2, float w2, float x3, float y3, float z3, float w3, float x4, float y4, float z4, float w4) { NativeCustomCamera.setProjectionMatrix(getNative(), x1, y1, z1, w1, x2, y2, z2...
java
private void loadCadidateString() { volumeUp = mGvrContext.getActivity().getResources().getString(R.string.volume_up); volumeDown = mGvrContext.getActivity().getResources().getString(R.string.volume_down); zoomIn = mGvrContext.getActivity().getResources().getString(R.string.zoom_in); zoo...
java
public void findMatch(ArrayList<String> speechResult) { loadCadidateString(); for (String matchCandidate : speechResult) { Locale localeDefault = mGvrContext.getActivity().getResources().getConfiguration().locale; if (volumeUp.equals(matchCandidate)) { startVol...
java
private void enableTalkBack() { GVRSceneObject[] sceneObjects = mGvrContext.getMainScene().getWholeSceneObjects(); for (GVRSceneObject sceneObject : sceneObjects) { if (sceneObject instanceof GVRAccessiblityObject) if (((GVRAccessiblityObject) sceneObject).getTalkBack() != nu...
java
private void disableTalkBack() { GVRSceneObject[] sceneObjects = mGvrContext.getMainScene().getWholeSceneObjects(); for (GVRSceneObject sceneObject : sceneObjects) { if (sceneObject instanceof GVRAccessiblityObject) if (((GVRAccessiblityObject) sceneObject).getTalkBack() != n...
java
private void startInvertedColors() { if (managerFeatures.getInvertedColors().isInverted()) { managerFeatures.getInvertedColors().turnOff(mGvrContext.getMainScene()); } else { managerFeatures.getInvertedColors().turnOn(mGvrContext.getMainScene()); } }
java
public static void dumpTexCoords(AiMesh mesh, int coords) { if (!mesh.hasTexCoords(coords)) { System.out.println("mesh has no texture coordinate set " + coords); return; } for (int i = 0; i < mesh.getNumVertices(); i++) { int numComponents = mesh.getN...
java
public static void dumpMaterialProperty(AiMaterial.Property property) { System.out.print(property.getKey() + " " + property.getSemantic() + " " + property.getIndex() + ": "); Object data = property.getData(); if (data instanceof ByteBuffer) { ByteBuffer buf ...
java
public static void dumpMaterial(AiMaterial material) { for (AiMaterial.Property prop : material.getProperties()) { dumpMaterialProperty(prop); } }
java
public static void dumpNodeAnim(AiNodeAnim nodeAnim) { for (int i = 0; i < nodeAnim.getNumPosKeys(); i++) { System.out.println(i + ": " + nodeAnim.getPosKeyTime(i) + " ticks, " + nodeAnim.getPosKeyVector(i, Jassimp.BUILTIN)); } }
java
public static String joinStrings(List<String> strings, boolean fixCase, char withChar) { if (strings == null || strings.size() == 0) { return ""; } StringBuilder result = null; for (String s : strings) { if (fixCase) { s = fixCase(s); }...
java
public int addCollidable(GVRSceneObject sceneObj) { synchronized (mCollidables) { int index = mCollidables.indexOf(sceneObj); if (index >= 0) { return index; } mCollidables.add(sceneObj); return mCollidables.size...
java
public static GVRCameraRig makeInstance(GVRContext gvrContext) { final GVRCameraRig result = gvrContext.getApplication().getDelegate().makeCameraRig(gvrContext); result.init(gvrContext); return result; }
java
public void removeAllChildren() { for (final GVRSceneObject so : headTransformObject.getChildren()) { final boolean notCamera = (so != leftCameraObject && so != rightCameraObject && so != centerCameraObject); if (notCamera) { headTransformObject.removeChildObject(so); ...
java
public void setNearClippingDistance(float near) { if(leftCamera instanceof GVRCameraClippingDistanceInterface && centerCamera instanceof GVRCameraClippingDistanceInterface && rightCamera instanceof GVRCameraClippingDistanceInterface) { ((GVRCameraClippingDistanceInterface)leftC...
java
public void setFarClippingDistance(float far) { if(leftCamera instanceof GVRCameraClippingDistanceInterface && centerCamera instanceof GVRCameraClippingDistanceInterface && rightCamera instanceof GVRCameraClippingDistanceInterface) { ((GVRCameraClippingDistanceInterface)leftCam...
java
public static String readTextFile(File file) { try { return readTextFile(new FileReader(file)); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } }
java
public static String readTextFile(Context context, int resourceId) { InputStream inputStream = context.getResources().openRawResource( resourceId); return readTextFile(inputStream); }
java
public static String readTextFile(InputStream inputStream) { InputStreamReader streamReader = new InputStreamReader(inputStream); return readTextFile(streamReader); }
java
private static Future<?> spawn(final int priority, final Runnable threadProc) { return threadPool.submit(new Runnable() { @Override public void run() { Thread current = Thread.currentThread(); int defaultPriority = current.getPriority(); ...
java
public static void assertUnlocked(Object object, String name) { if (RUNTIME_ASSERTIONS) { if (Thread.holdsLock(object)) { throw new RuntimeAssertion("Recursive lock of %s", name); } } }
java
public void enableUniformSize(final boolean enable) { if (mUniformSize != enable) { mUniformSize = enable; if (mContainer != null) { mContainer.onLayoutChanged(this); } } }
java
public void setDividerPadding(float padding, final Axis axis) { if (axis == getOrientationAxis()) { super.setDividerPadding(padding, axis); } else { Log.w(TAG, "Cannot apply divider padding for wrong axis [%s], orientation = %s", axis, getOrientation()); ...
java
protected boolean isValidLayout(Gravity gravity, Orientation orientation) { boolean isValid = true; switch (gravity) { case TOP: case BOTTOM: isValid = (!isUnlimitedSize() && orientation == Orientation.VERTICAL); break; case LEFT: ...
java
protected float getLayoutOffset() { //final int offsetSign = getOffsetSign(); final float axisSize = getViewPortSize(getOrientationAxis()); float layoutOffset = - axisSize / 2; Log.d(LAYOUT, TAG, "getLayoutOffset(): dimension: %5.2f, layoutOffset: %5.2f", axisSize, layoutOf...
java
protected float getStartingOffset(final float totalSize) { final float axisSize = getViewPortSize(getOrientationAxis()); float startingOffset = 0; switch (getGravityInternal()) { case LEFT: case FILL: case TOP: case FRONT: starting...
java
@Override protected boolean changeDirection(int currentIndex, int centerIndex, boolean inBounds) { boolean changed = false; if (getGravityInternal() == Gravity.CENTER && currentIndex <= centerIndex && currentIndex == 0 || !inBounds) { changed = true; ...
java
protected int getCenterChild(CacheDataSet cache) { if (cache.count() == 0) return -1; int id = cache.getId(0); switch (getGravityInternal()) { case TOP: case LEFT: case FRONT: case FILL: break; case BOTTOM: ...
java
protected boolean computeOffset(final int dataIndex, CacheDataSet cache) { float layoutOffset = getLayoutOffset(); int pos = cache.getPos(dataIndex); float startDataOffset = Float.NaN; float endDataOffset = Float.NaN; if (pos > 0) { int id = cache.getId(pos - 1); ...
java
protected boolean computeOffset(CacheDataSet cache) { // offset computation: update offset for all items in the cache float startDataOffset = getStartingOffset((cache.getTotalSizeWithPadding())); float layoutOffset = getLayoutOffset(); boolean inBounds = startDataOffset < -layoutOffset;...
java
protected float computeUniformPadding(final CacheDataSet cache) { float axisSize = getViewPortSize(getOrientationAxis()); float totalPadding = axisSize - cache.getTotalSize(); float uniformPadding = totalPadding > 0 && cache.count() > 1 ? totalPadding / (cache.count() - 1) : 0; ...
java
public String[] getString() { String[] valueDestination = new String[ string.size() ]; this.string.getValue(valueDestination); return valueDestination; }
java
public void setString(String[] newValue) { if ( newValue != null ) { this.string.setValue(newValue.length, newValue); } }
java
public int findAnimation(GVRAnimation findme) { int index = 0; for (GVRAnimation anim : mAnimations) { if (anim == findme) { return index; } ++index; } return -1; }
java
public void setDuration(float start, float end) { for (GVRAnimation anim : mAnimations) { anim.setDuration(start,end); } }
java
public static void init(Context cx, Scriptable scope, boolean sealed) throws RhinoException { JSAdapter obj = new JSAdapter(cx.newObject(scope)); obj.setParentScope(scope); obj.setPrototype(getFunctionPrototype(scope)); obj.isPrototype = true; ScriptableObject.defineProperty(...
java
private Object mapToId(Object tmp) { if (tmp instanceof Double) { return new Integer(((Double)tmp).intValue()); } else { return Context.toString(tmp); } }
java
public void setList(List<T> list) { if (list != mList) { mList = list; if (mList == null) { notifyInvalidated(); } else { notifyChanged(); } } }
java
public void register() { synchronized (loaders) { loaders.add(this); maximumHeaderLength = 0; for (GVRCompressedTextureLoader loader : loaders) { int headerLength = loader.headerLength(); if (headerLength > maximumHeaderLength) { ...
java
public static GVRSceneObject loadModel(final GVRContext gvrContext, final String modelFile) throws IOException { return loadModel(gvrContext, modelFile, new HashMap<String, Integer>()); }
java
public int getFaceNumIndices(int face) { if (null == m_faceOffsets) { if (face >= m_numFaces || face < 0) { throw new IndexOutOfBoundsException("Index: " + face + ", Size: " + m_numFaces); } return 3; } else { ...
java
public float getPositionX(int vertex) { if (!hasPositions()) { throw new IllegalStateException("mesh has no positions"); } checkVertexIndexBounds(vertex); return m_vertices.getFloat(vertex * 3 * SIZEOF_FLOAT); }
java
public float getPositionY(int vertex) { if (!hasPositions()) { throw new IllegalStateException("mesh has no positions"); } checkVertexIndexBounds(vertex); return m_vertices.getFloat((vertex * 3 + 1) * SIZEOF_FLOAT); }
java
public float getPositionZ(int vertex) { if (!hasPositions()) { throw new IllegalStateException("mesh has no positions"); } checkVertexIndexBounds(vertex); return m_vertices.getFloat((vertex * 3 + 2) * SIZEOF_FLOAT); }
java