_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q5300 | GVRFrustumPicker.setFrustum | train | public void setFrustum(Matrix4f projMatrix)
{
if (projMatrix != null)
{
if (mProjMatrix == null)
{
mProjMatrix = new float[16];
}
mProjMatrix = projMatrix.get(mProjMatrix, 0);
mScene.setPickVisible(false);
if (mCuller != null)
{
mCuller.set(projMatrix);
}
else
{
mCuller = new FrustumIntersection(projMatrix);
}
}
mProjection = projMatrix;
} | java | {
"resource": ""
} |
q5301 | GVRFrustumPicker.pickVisible | train | public static final GVRPickedObject[] pickVisible(GVRScene scene) {
sFindObjectsLock.lock();
try {
final GVRPickedObject[] result = NativePicker.pickVisible(scene.getNative());
return result;
} finally {
sFindObjectsLock.unlock();
}
} | java | {
"resource": ""
} |
q5302 | GVRIndexBuffer.setShortVec | train | 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");
}
if (!NativeIndexBuffer.setShortArray(getNative(), data))
{
throw new UnsupportedOperationException("Input array is wrong size");
}
} | java | {
"resource": ""
} |
q5303 | GVRIndexBuffer.setShortVec | train | 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 array");
}
if (data.isDirect())
{
if (!NativeIndexBuffer.setShortVec(getNative(), data))
{
throw new UnsupportedOperationException("Input buffer is wrong size");
}
}
else if (data.hasArray())
{
if (!NativeIndexBuffer.setShortArray(getNative(), data.array()))
{
throw new UnsupportedOperationException("Input buffer is wrong size");
}
}
else
{
throw new UnsupportedOperationException(
"CharBuffer type not supported. Must be direct or have backing array");
}
} | java | {
"resource": ""
} |
q5304 | GVRIndexBuffer.setIntVec | train | 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");
}
if (!NativeIndexBuffer.setIntArray(getNative(), data))
{
throw new UnsupportedOperationException("Input array is wrong size");
}
} | java | {
"resource": ""
} |
q5305 | GVRIndexBuffer.setIntVec | train | 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 array");
}
if (data.isDirect())
{
if (!NativeIndexBuffer.setIntVec(getNative(), data))
{
throw new UnsupportedOperationException("Input array is wrong size");
}
}
else if (data.hasArray())
{
if (!NativeIndexBuffer.setIntArray(getNative(), data.array()))
{
throw new IllegalArgumentException("Data array incompatible with index buffer");
}
}
else
{
throw new UnsupportedOperationException("IntBuffer type not supported. Must be direct or have backing array");
}
} | java | {
"resource": ""
} |
q5306 | GVREmitter.emitWithBurstCheck | train | protected void emitWithBurstCheck(float[] particlePositions, float[] particleVelocities,
float[] particleTimeStamps)
{
if ( burstMode )
{
if ( executeOnce )
{
emit(particlePositions, particleVelocities, particleTimeStamps);
executeOnce = false;
}
}
else
{
emit(particlePositions, particleVelocities, particleTimeStamps);
}
} | java | {
"resource": ""
} |
q5307 | GVREmitter.emit | train | private void emit(float[] particlePositions, float[] particleVelocities,
float[] particleTimeStamps)
{
float[] allParticlePositions = new float[particlePositions.length + particleBoundingVolume.length];
System.arraycopy(particlePositions, 0, allParticlePositions, 0, particlePositions.length);
System.arraycopy(particleBoundingVolume, 0, allParticlePositions,
particlePositions.length, particleBoundingVolume.length);
float[] allSpawnTimes = new float[particleTimeStamps.length + BVSpawnTimes.length];
System.arraycopy(particleTimeStamps, 0, allSpawnTimes, 0, particleTimeStamps.length);
System.arraycopy(BVSpawnTimes, 0, allSpawnTimes, particleTimeStamps.length, BVSpawnTimes.length);
float[] allParticleVelocities = new float[particleVelocities.length + BVVelocities.length];
System.arraycopy(particleVelocities, 0, allParticleVelocities, 0, particleVelocities.length);
System.arraycopy(BVVelocities, 0, allParticleVelocities, particleVelocities.length, BVVelocities.length);
Particles particleMesh = new Particles(mGVRContext, mMaxAge,
mParticleSize, mEnvironmentAcceleration, mParticleSizeRate, mFadeWithAge,
mParticleTexture, mColor, mNoiseFactor);
GVRSceneObject particleObject = particleMesh.makeParticleMesh(allParticlePositions,
allParticleVelocities, allSpawnTimes);
this.addChildObject(particleObject);
meshInfo.add(Pair.create(particleObject, currTime));
} | java | {
"resource": ""
} |
q5308 | GVREmitter.setVelocityRange | train | 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 | {
"resource": ""
} |
q5309 | Log.logLong | train | 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 | {
"resource": ""
} |
q5310 | Utility.readTextFile | train | 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 file '%s' doesn't exist", asset);
} catch (IOException e) {
e.printStackTrace();
Log.e(TAG, e, "readTextFile()");
}
return null;
} | java | {
"resource": ""
} |
q5311 | Utility.equal | train | 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 | {
"resource": ""
} |
q5312 | Utility.getId | train | 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: %s", id, defType);
return getId(context, id, defType);
} | java | {
"resource": ""
} |
q5313 | Utility.getId | train | 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,
context.getPackageName());
if (resId > 0) {
return resId;
} else {
throw new RuntimeAssertion("Specified resource '%s' could not be found", id);
}
} | java | {
"resource": ""
} |
q5314 | GVRShader.generateSignature | train | public String generateSignature(HashMap<String, Integer> defined, GVRLight[] lightlist)
{
return getClass().getSimpleName();
} | java | {
"resource": ""
} |
q5315 | GVRShader.bindShader | train | 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)
{
int nativeShader = shaderManager.getShader(signature);
if (nativeShader == 0)
{
nativeShader = addShader(shaderManager, signature, mtl);
}
if (nativeShader > 0)
{
rdata.setShader(nativeShader, isMultiview);
}
return nativeShader;
}
} | java | {
"resource": ""
} |
q5316 | GVRShader.bindShader | train | public int bindShader(GVRContext context, GVRShaderData material, String vertexDesc)
{
String signature = getClass().getSimpleName();
GVRShaderManager shaderManager = context.getShaderManager();
synchronized (shaderManager)
{
int nativeShader = shaderManager.getShader(signature);
if (nativeShader == 0)
{
nativeShader = addShader(shaderManager, signature, material);
}
return nativeShader;
}
} | java | {
"resource": ""
} |
q5317 | PhysicsDragger.startDrag | train | 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 != null) {
Log.w(TAG, "Physics drag failed: Previous drag wasn't finished!");
return null;
}
if (mPivotObject == null) {
mPivotObject = onCreatePivotObject(mContext);
}
mDragMe = dragMe;
GVRTransform t = dragMe.getTransform();
/* It is not possible to drag a rigid body directly, we need a pivot object.
We are using the pivot object's position as pivot of the dragging's physics constraint.
*/
mPivotObject.getTransform().setPosition(t.getPositionX() + relX,
t.getPositionY() + relY, t.getPositionZ() + relZ);
mCursorController.startDrag(mPivotObject);
}
return mPivotObject;
} | java | {
"resource": ""
} |
q5318 | GVRShaderData.setTexCoord | train | public void setTexCoord(String texName, String texCoordAttr, String shaderVarName)
{
synchronized (textures)
{
GVRTexture tex = textures.get(texName);
if (tex != null)
{
tex.setTexCoord(texCoordAttr, shaderVarName);
}
else
{
throw new UnsupportedOperationException("Texture must be set before updating texture coordinate information");
}
}
} | java | {
"resource": ""
} |
q5319 | GVRShaderData.getTexCoordAttr | train | public String getTexCoordAttr(String texName)
{
GVRTexture tex = textures.get(texName);
if (tex != null)
{
return tex.getTexCoordAttr();
}
return null;
} | java | {
"resource": ""
} |
q5320 | GVRShaderData.getTexCoordShaderVar | train | public String getTexCoordShaderVar(String texName)
{
GVRTexture tex = textures.get(texName);
if (tex != null)
{
return tex.getTexCoordShaderVar();
}
return null;
} | java | {
"resource": ""
} |
q5321 | GVRPreference.getProperty | train | public String getProperty(String key, String defaultValue) {
return mProperties.getProperty(key, defaultValue);
} | java | {
"resource": ""
} |
q5322 | PickerWidget.hide | train | public synchronized void hide() {
if (focusedQuad != null) {
mDefocusAnimationFactory.create(focusedQuad)
.setRequestLayoutOnTargetChange(false)
.start().finish();
focusedQuad = null;
}
Log.d(Log.SUBSYSTEM.WIDGET, TAG, "hide Picker!");
} | java | {
"resource": ""
} |
q5323 | MFString.set1Value | train | 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 MFString set1Value(int index, ...) exception " + e);
}
} | java | {
"resource": ""
} |
q5324 | MFString.setValue | train | 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() numStrings not equal total newValues");
}
} | java | {
"resource": ""
} |
q5325 | GVRBitmapImage.update | train | public void update(int width, int height, byte[] grayscaleData)
{
NativeBitmapImage.updateFromMemory(getNative(), width, height, grayscaleData);
} | java | {
"resource": ""
} |
q5326 | PlatformEntitlementCheck.start | train | 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(activity, appId);
if (0 != result) {
throw new IllegalStateException("Could not initialize the platform sdk; error code: " + result);
}
context.registerDrawFrameListener(new GVRDrawFrameListener() {
@Override
public void onDrawFrame(float frameTime) {
final int result = processEntitlementCheckResponse();
if (0 != result) {
context.unregisterDrawFrameListener(this);
final Runnable runnable;
if (-1 == result) {
runnable = new Runnable() {
@Override
public void run() {
listener.onFailure();
}
};
} else {
runnable = new Runnable() {
@Override
public void run() {
listener.onSuccess();
}
};
}
activity.runOnUiThread(runnable);
}
}
});
} | java | {
"resource": ""
} |
q5327 | GVRFPSTracer.tick | train | 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) {
it.remove();
} else {
break;
}
}
mTimestamps.add(currentTime);
mStatColumn.addValue(((float)mTimestamps.size()) / BUFFER_SECONDS);
} | java | {
"resource": ""
} |
q5328 | VrAppSettings.addControllerType | train | public void addControllerType(GVRControllerType controllerType)
{
if (cursorControllerTypes == null)
{
cursorControllerTypes = new ArrayList<GVRControllerType>();
}
else if (cursorControllerTypes.contains(controllerType))
{
return;
}
cursorControllerTypes.add(controllerType);
} | java | {
"resource": ""
} |
q5329 | Assert.checkStringNotNullOrEmpty | train | 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 | {
"resource": ""
} |
q5330 | Assert.checkArrayLength | train | 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, actualLength);
}
} | java | {
"resource": ""
} |
q5331 | Assert.checkMinimumArrayLength | train | 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",
parameterName, minimumLength, actualLength);
}
} | java | {
"resource": ""
} |
q5332 | Assert.checkFloatNotNaNOrInfinity | train | 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 | {
"resource": ""
} |
q5333 | GVRPose.transformPose | train | 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 | {
"resource": ""
} |
q5334 | GVRPose.inverse | train | 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[0];
mNeedSync = true;
srcBone.WorldMatrix.invertAffine(dstBone.WorldMatrix);
srcBone.LocalMatrix.set(dstBone.WorldMatrix);
if (sDebug)
{
Log.d("BONE", "invert: %s %s", mSkeleton.getBoneName(0), dstBone.toString());
}
for (int i = 1; i < numbones; ++i)
{
srcBone = src.mBones[i];
dstBone = mBones[i];
srcBone.WorldMatrix.invertAffine(dstBone.WorldMatrix);
dstBone.Changed = WORLD_ROT | WORLD_POS;
if (sDebug)
{
Log.d("BONE", "invert: %s %s", mSkeleton.getBoneName(i), dstBone.toString());
}
}
sync();
} | java | {
"resource": ""
} |
q5335 | GVRPose.calcWorld | train | 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 | {
"resource": ""
} |
q5336 | GVRPose.calcLocal | train | 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
*/
getWorldMatrix(parentId, mTempMtxA); // WorldMatrix(par)
mTempMtxA.invert(); // INVERSE[ WorldMatrix(parent) ]
mTempMtxA.mul(bone.WorldMatrix, bone.LocalMatrix); // LocalMatrix = INVERSE[ WorldMatrix(parent) ] * WorldMatrix
} | java | {
"resource": ""
} |
q5337 | GVRLight.setVec3 | train | public void setVec3(String key, float x, float y, float z)
{
checkKeyIsUniform(key);
NativeLight.setVec3(getNative(), key, x, y, z);
} | java | {
"resource": ""
} |
q5338 | GVRLight.setVec4 | train | public void setVec4(String key, float x, float y, float z, float w)
{
checkKeyIsUniform(key);
NativeLight.setVec4(getNative(), key, x, y, z, w);
} | java | {
"resource": ""
} |
q5339 | GVRLight.setMat4 | train | 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(), key, x1, y1, z1, w1, x2, y2,
z2, w2, x3, y3, z3, w3, x4, y4, z4, w4);
} | java | {
"resource": ""
} |
q5340 | GVRLight.onDrawFrame | train | 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;
Matrix4f worldmtx = parent.getTransform().getModelMatrix4f();
mOldDir.x = odir[0];
mOldDir.y = odir[1];
mOldDir.z = odir[2];
mOldPos.x = opos[0];
mOldPos.y = opos[1];
mOldPos.z = opos[2];
mNewDir.x = 0.0f;
mNewDir.y = 0.0f;
mNewDir.z = -1.0f;
worldmtx.getTranslation(mNewPos);
worldmtx.mul(mLightRot);
worldmtx.transformDirection(mNewDir);
if ((mOldDir.x != mNewDir.x) || (mOldDir.y != mNewDir.y) || (mOldDir.z != mNewDir.z))
{
setVec4("world_direction", mNewDir.x, mNewDir.y, mNewDir.z, 0);
}
if ((mOldPos.x != mNewPos.x) || (mOldPos.y != mNewPos.y) || (mOldPos.z != mNewPos.z))
{
setPosition(mNewPos.x, mNewPos.y, mNewPos.z);
}
} | java | {
"resource": ""
} |
q5341 | GVRCustomCamera.setProjectionMatrix | train | 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, w2, x3, y3, z3, w3, x4, y4, z4, w4);
} | java | {
"resource": ""
} |
q5342 | AccessibilityFeature.loadCadidateString | train | 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);
zoomOut = mGvrContext.getActivity().getResources().getString(R.string.zoom_out);
invertedColors = mGvrContext.getActivity().getResources().getString(R.string.inverted_colors);
talkBack = mGvrContext.getActivity().getResources().getString(R.string.talk_back);
disableTalkBack = mGvrContext.getActivity().getResources().getString(R.string.disable_talk_back);
} | java | {
"resource": ""
} |
q5343 | AccessibilityFeature.findMatch | train | public void findMatch(ArrayList<String> speechResult) {
loadCadidateString();
for (String matchCandidate : speechResult) {
Locale localeDefault = mGvrContext.getActivity().getResources().getConfiguration().locale;
if (volumeUp.equals(matchCandidate)) {
startVolumeUp();
break;
} else if (volumeDown.toLowerCase(localeDefault).equals(matchCandidate.toLowerCase(localeDefault))) {
startVolumeDown();
break;
} else if (zoomIn.toLowerCase(localeDefault).equals(matchCandidate.toLowerCase(localeDefault))) {
startZoomIn();
break;
} else if (zoomOut.toLowerCase(localeDefault).equals(matchCandidate.toLowerCase(localeDefault))) {
startZoomOut();
break;
} else if (invertedColors.toLowerCase(localeDefault).equals(matchCandidate.toLowerCase(localeDefault))) {
startInvertedColors();
break;
} else if (talkBack.toLowerCase(localeDefault).equals(matchCandidate.toLowerCase(localeDefault))) {
enableTalkBack();
} else if (disableTalkBack.toLowerCase(localeDefault).equals(matchCandidate.toLowerCase(localeDefault))) {
disableTalkBack();
}
}
} | java | {
"resource": ""
} |
q5344 | AccessibilityFeature.enableTalkBack | train | private void enableTalkBack() {
GVRSceneObject[] sceneObjects = mGvrContext.getMainScene().getWholeSceneObjects();
for (GVRSceneObject sceneObject : sceneObjects) {
if (sceneObject instanceof GVRAccessiblityObject)
if (((GVRAccessiblityObject) sceneObject).getTalkBack() != null)
((GVRAccessiblityObject) sceneObject).getTalkBack().setActive(true);
}
} | java | {
"resource": ""
} |
q5345 | AccessibilityFeature.disableTalkBack | train | private void disableTalkBack() {
GVRSceneObject[] sceneObjects = mGvrContext.getMainScene().getWholeSceneObjects();
for (GVRSceneObject sceneObject : sceneObjects) {
if (sceneObject instanceof GVRAccessiblityObject)
if (((GVRAccessiblityObject) sceneObject).getTalkBack() != null)
((GVRAccessiblityObject) sceneObject).getTalkBack().setActive(false);
}
} | java | {
"resource": ""
} |
q5346 | AccessibilityFeature.startInvertedColors | train | private void startInvertedColors() {
if (managerFeatures.getInvertedColors().isInverted()) {
managerFeatures.getInvertedColors().turnOff(mGvrContext.getMainScene());
} else {
managerFeatures.getInvertedColors().turnOn(mGvrContext.getMainScene());
}
} | java | {
"resource": ""
} |
q5347 | JaiDebug.dumpTexCoords | train | 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.getNumUVComponents(coords);
System.out.print("[" + mesh.getTexCoordU(i, coords));
if (numComponents > 1) {
System.out.print(", " + mesh.getTexCoordV(i, coords));
}
if (numComponents > 2) {
System.out.print(", " + mesh.getTexCoordW(i, coords));
}
System.out.println("]");
}
} | java | {
"resource": ""
} |
q5348 | JaiDebug.dumpMaterialProperty | train | 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 = (ByteBuffer) data;
for (int i = 0; i < buf.capacity(); i++) {
System.out.print(Integer.toHexString(buf.get(i) & 0xFF) + " ");
}
System.out.println();
}
else {
System.out.println(data.toString());
}
} | java | {
"resource": ""
} |
q5349 | JaiDebug.dumpMaterial | train | public static void dumpMaterial(AiMaterial material) {
for (AiMaterial.Property prop : material.getProperties()) {
dumpMaterialProperty(prop);
}
} | java | {
"resource": ""
} |
q5350 | JaiDebug.dumpNodeAnim | train | 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 | {
"resource": ""
} |
q5351 | Strings.joinStrings | train | 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);
}
if (result == null) {
result = new StringBuilder(s);
} else {
result.append(withChar);
result.append(s);
}
}
return result.toString();
} | java | {
"resource": ""
} |
q5352 | GVRBoundsPicker.addCollidable | train | public int addCollidable(GVRSceneObject sceneObj)
{
synchronized (mCollidables)
{
int index = mCollidables.indexOf(sceneObj);
if (index >= 0)
{
return index;
}
mCollidables.add(sceneObj);
return mCollidables.size() - 1;
}
} | java | {
"resource": ""
} |
q5353 | GVRCameraRig.makeInstance | train | public static GVRCameraRig makeInstance(GVRContext gvrContext) {
final GVRCameraRig result = gvrContext.getApplication().getDelegate().makeCameraRig(gvrContext);
result.init(gvrContext);
return result;
} | java | {
"resource": ""
} |
q5354 | GVRCameraRig.removeAllChildren | train | public void removeAllChildren() {
for (final GVRSceneObject so : headTransformObject.getChildren()) {
final boolean notCamera = (so != leftCameraObject && so != rightCameraObject && so != centerCameraObject);
if (notCamera) {
headTransformObject.removeChildObject(so);
}
}
} | java | {
"resource": ""
} |
q5355 | GVRCameraRig.setNearClippingDistance | train | public void setNearClippingDistance(float near) {
if(leftCamera instanceof GVRCameraClippingDistanceInterface &&
centerCamera instanceof GVRCameraClippingDistanceInterface &&
rightCamera instanceof GVRCameraClippingDistanceInterface) {
((GVRCameraClippingDistanceInterface)leftCamera).setNearClippingDistance(near);
centerCamera.setNearClippingDistance(near);
((GVRCameraClippingDistanceInterface)rightCamera).setNearClippingDistance(near);
}
} | java | {
"resource": ""
} |
q5356 | GVRCameraRig.setFarClippingDistance | train | public void setFarClippingDistance(float far) {
if(leftCamera instanceof GVRCameraClippingDistanceInterface &&
centerCamera instanceof GVRCameraClippingDistanceInterface &&
rightCamera instanceof GVRCameraClippingDistanceInterface) {
((GVRCameraClippingDistanceInterface)leftCamera).setFarClippingDistance(far);
centerCamera.setFarClippingDistance(far);
((GVRCameraClippingDistanceInterface)rightCamera).setFarClippingDistance(far);
}
} | java | {
"resource": ""
} |
q5357 | TextFile.readTextFile | train | public static String readTextFile(File file) {
try {
return readTextFile(new FileReader(file));
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
}
} | java | {
"resource": ""
} |
q5358 | TextFile.readTextFile | train | public static String readTextFile(Context context, int resourceId) {
InputStream inputStream = context.getResources().openRawResource(
resourceId);
return readTextFile(inputStream);
} | java | {
"resource": ""
} |
q5359 | TextFile.readTextFile | train | public static String readTextFile(InputStream inputStream) {
InputStreamReader streamReader = new InputStreamReader(inputStream);
return readTextFile(streamReader);
} | java | {
"resource": ""
} |
q5360 | Threads.spawn | train | 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();
try {
current.setPriority(priority);
/*
* We yield to give the foreground process a chance to run.
* This also means that the new priority takes effect RIGHT
* AWAY, not after the next blocking call or quantum
* timeout.
*/
Thread.yield();
try {
threadProc.run();
} catch (Exception e) {
logException(TAG, e);
}
} finally {
current.setPriority(defaultPriority);
}
}
});
} | java | {
"resource": ""
} |
q5361 | Threads.assertUnlocked | train | public static void assertUnlocked(Object object, String name) {
if (RUNTIME_ASSERTIONS) {
if (Thread.holdsLock(object)) {
throw new RuntimeAssertion("Recursive lock of %s", name);
}
}
} | java | {
"resource": ""
} |
q5362 | LinearLayout.enableUniformSize | train | public void enableUniformSize(final boolean enable) {
if (mUniformSize != enable) {
mUniformSize = enable;
if (mContainer != null) {
mContainer.onLayoutChanged(this);
}
}
} | java | {
"resource": ""
} |
q5363 | LinearLayout.setDividerPadding | train | 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 | {
"resource": ""
} |
q5364 | LinearLayout.isValidLayout | train | protected boolean isValidLayout(Gravity gravity, Orientation orientation) {
boolean isValid = true;
switch (gravity) {
case TOP:
case BOTTOM:
isValid = (!isUnlimitedSize() && orientation == Orientation.VERTICAL);
break;
case LEFT:
case RIGHT:
isValid = (!isUnlimitedSize() && orientation == Orientation.HORIZONTAL);
break;
case FRONT:
case BACK:
isValid = (!isUnlimitedSize() && orientation == Orientation.STACK);
break;
case FILL:
isValid = !isUnlimitedSize();
break;
case CENTER:
break;
default:
isValid = false;
break;
}
if (!isValid) {
Log.w(TAG, "Cannot set the gravity %s and orientation %s - " +
"due to unlimited bounds or incompatibility", gravity, orientation);
}
return isValid;
} | java | {
"resource": ""
} |
q5365 | LinearLayout.getLayoutOffset | train | 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, layoutOffset);
return layoutOffset;
} | java | {
"resource": ""
} |
q5366 | LinearLayout.getStartingOffset | train | protected float getStartingOffset(final float totalSize) {
final float axisSize = getViewPortSize(getOrientationAxis());
float startingOffset = 0;
switch (getGravityInternal()) {
case LEFT:
case FILL:
case TOP:
case FRONT:
startingOffset = -axisSize / 2;
break;
case RIGHT:
case BOTTOM:
case BACK:
startingOffset = (axisSize / 2 - totalSize);
break;
case CENTER:
startingOffset = -totalSize / 2;
break;
default:
Log.w(TAG, "Cannot calculate starting offset: " +
"gravity %s is not supported!", mGravity);
break;
}
Log.d(LAYOUT, TAG, "getStartingOffset(): totalSize: %5.4f, dimension: %5.4f, startingOffset: %5.4f",
totalSize, axisSize, startingOffset);
return startingOffset;
} | java | {
"resource": ""
} |
q5367 | LinearLayout.changeDirection | train | @Override
protected boolean changeDirection(int currentIndex, int centerIndex, boolean inBounds) {
boolean changed = false;
if (getGravityInternal() == Gravity.CENTER &&
currentIndex <= centerIndex &&
currentIndex == 0 || !inBounds) {
changed = true;
}
return changed;
} | java | {
"resource": ""
} |
q5368 | LinearLayout.getCenterChild | train | 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:
case RIGHT:
case BACK:
id = cache.getId(cache.count() - 1);
break;
case CENTER:
int i = cache.count() / 2;
while (i < cache.count() && i >= 0) {
id = cache.getId(i);
if (cache.getStartDataOffset(id) <= 0) {
if (cache.getEndDataOffset(id) >= 0) {
break;
} else {
i++;
}
} else {
i--;
}
}
break;
default:
break;
}
Log.d(LAYOUT, TAG, "getCenterChild = %d ", id);
return id;
} | java | {
"resource": ""
} |
q5369 | LinearLayout.computeOffset | train | 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);
if (id != -1) {
startDataOffset = cache.getEndDataOffset(id);
if (!Float.isNaN(startDataOffset)) {
endDataOffset = cache.setDataAfter(dataIndex, startDataOffset);
}
}
} else if (pos == 0) {
int id = cache.getId(pos + 1);
if (id != -1) {
endDataOffset = cache.getStartDataOffset(id);
if (!Float.isNaN(endDataOffset)) {
startDataOffset = cache.setDataBefore(dataIndex, endDataOffset);
}
} else {
startDataOffset = getStartingOffset((cache.getTotalSizeWithPadding()));
endDataOffset = cache.setDataAfter(dataIndex, startDataOffset);
}
}
Log.d(LAYOUT, TAG, "computeOffset [%d, %d]: startDataOffset = %f endDataOffset = %f",
dataIndex, pos, startDataOffset, endDataOffset);
boolean inBounds = !Float.isNaN(cache.getDataOffset(dataIndex)) &&
endDataOffset > layoutOffset &&
startDataOffset < -layoutOffset;
return inBounds;
} | java | {
"resource": ""
} |
q5370 | LinearLayout.computeOffset | train | 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;
for (int pos = 0; pos < cache.count(); ++pos) {
int id = cache.getId(pos);
if (id != -1) {
float endDataOffset = cache.setDataAfter(id, startDataOffset);
inBounds = inBounds &&
endDataOffset > layoutOffset &&
startDataOffset < -layoutOffset;
startDataOffset = endDataOffset;
Log.d(LAYOUT, TAG, "computeOffset [%d] = %f" , id, cache.getDataOffset(id));
}
}
return inBounds;
} | java | {
"resource": ""
} |
q5371 | LinearLayout.computeUniformPadding | train | 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;
return uniformPadding;
} | java | {
"resource": ""
} |
q5372 | Text.getString | train | public String[] getString() {
String[] valueDestination = new String[ string.size() ];
this.string.getValue(valueDestination);
return valueDestination;
} | java | {
"resource": ""
} |
q5373 | Text.setString | train | public void setString(String[] newValue) {
if ( newValue != null ) {
this.string.setValue(newValue.length, newValue);
}
} | java | {
"resource": ""
} |
q5374 | GVRAnimator.findAnimation | train | public int findAnimation(GVRAnimation findme)
{
int index = 0;
for (GVRAnimation anim : mAnimations)
{
if (anim == findme)
{
return index;
}
++index;
}
return -1;
} | java | {
"resource": ""
} |
q5375 | GVRAnimator.setDuration | train | public void setDuration(float start, float end)
{
for (GVRAnimation anim : mAnimations)
{
anim.setDuration(start,end);
}
} | java | {
"resource": ""
} |
q5376 | JSAdapter.init | train | 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(scope, "JSAdapter", obj,
ScriptableObject.DONTENUM);
} | java | {
"resource": ""
} |
q5377 | JSAdapter.mapToId | train | private Object mapToId(Object tmp) {
if (tmp instanceof Double) {
return new Integer(((Double)tmp).intValue());
} else {
return Context.toString(tmp);
}
} | java | {
"resource": ""
} |
q5378 | ListDataSet.setList | train | public void setList(List<T> list) {
if (list != mList) {
mList = list;
if (mList == null) {
notifyInvalidated();
} else {
notifyChanged();
}
}
} | java | {
"resource": ""
} |
q5379 | GVRCompressedTextureLoader.register | train | public void register() {
synchronized (loaders) {
loaders.add(this);
maximumHeaderLength = 0;
for (GVRCompressedTextureLoader loader : loaders) {
int headerLength = loader.headerLength();
if (headerLength > maximumHeaderLength) {
maximumHeaderLength = headerLength;
}
}
}
} | java | {
"resource": ""
} |
q5380 | WidgetFactory.loadModel | train | public static GVRSceneObject loadModel(final GVRContext gvrContext,
final String modelFile) throws IOException {
return loadModel(gvrContext, modelFile, new HashMap<String, Integer>());
} | java | {
"resource": ""
} |
q5381 | AiMesh.getFaceNumIndices | train | 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 {
/*
* no need to perform bound checks here as the array access will
* throw IndexOutOfBoundsExceptions if the index is invalid
*/
if (face == m_numFaces - 1) {
return m_faces.capacity() / 4 - m_faceOffsets.getInt(face * 4);
}
return m_faceOffsets.getInt((face + 1) * 4) -
m_faceOffsets.getInt(face * 4);
}
} | java | {
"resource": ""
} |
q5382 | AiMesh.getPositionX | train | 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 | {
"resource": ""
} |
q5383 | AiMesh.getPositionY | train | 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 | {
"resource": ""
} |
q5384 | AiMesh.getPositionZ | train | 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 | {
"resource": ""
} |
q5385 | AiMesh.getNormalX | train | 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 | {
"resource": ""
} |
q5386 | AiMesh.getNormalY | train | 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 | {
"resource": ""
} |
q5387 | AiMesh.getNormalZ | train | 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 | {
"resource": ""
} |
q5388 | AiMesh.getTangentY | train | 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 | {
"resource": ""
} |
q5389 | AiMesh.getBitangentY | train | 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 | {
"resource": ""
} |
q5390 | AiMesh.getColorR | train | 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_colorsets[colorset].getFloat(vertex * 4 * SIZEOF_FLOAT);
} | java | {
"resource": ""
} |
q5391 | AiMesh.getTexCoordU | train | 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 */
return m_texcoords[coords].getFloat(
vertex * m_numUVComponents[coords] * SIZEOF_FLOAT);
} | java | {
"resource": ""
} |
q5392 | NodeEntry.getProperty | train | @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 | {
"resource": ""
} |
q5393 | NodeEntry.toJSON | train | 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 | {
"resource": ""
} |
q5394 | MonoscopicViewManager.onRotationSensor | train | @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.getMainCameraRig();
}
if (cameraRig != null) {
cameraRig.setRotationSensorData(timeStamp, rotationW, rotationX, rotationY, rotationZ, gyroX, gyroY, gyroZ);
updateSensoredScene();
}
} | java | {
"resource": ""
} |
q5395 | GVRAndroidResource.setStream | train | 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 | {
"resource": ""
} |
q5396 | GVRAndroidResource.closeStream | train | public synchronized final void closeStream() {
try {
if ((stream != null) && (streamState == StreamStates.OPEN)) {
stream.close();
stream = null;
}
streamState = StreamStates.CLOSED;
} catch (IOException e) {
e.printStackTrace();
}
} | java | {
"resource": ""
} |
q5397 | GVRAndroidResource.getResourcePath | train | 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_STREAM: return inputStreamName;
default: return null;
}
} | java | {
"resource": ""
} |
q5398 | GVRAndroidResource.getResourceFilename | train | public String getResourceFilename() {
switch (resourceType) {
case ANDROID_ASSETS:
return assetPath
.substring(assetPath.lastIndexOf(File.separator) + 1);
case ANDROID_RESOURCE:
return resourceFilePath.substring(
resourceFilePath.lastIndexOf(File.separator) + 1);
case LINUX_FILESYSTEM:
return filePath.substring(filePath.lastIndexOf(File.separator) + 1);
case NETWORK:
return url.getPath().substring(url.getPath().lastIndexOf("/") + 1);
case INPUT_STREAM:
return inputStreamName;
default:
return null;
}
} | java | {
"resource": ""
} |
q5399 | GVRAvatar.loadModel | train | public void loadModel(GVRAndroidResource avatarResource)
{
EnumSet<GVRImportSettings> settings = GVRImportSettings.getRecommendedSettingsWith(EnumSet.of(GVRImportSettings.OPTIMIZE_GRAPH, GVRImportSettings.NO_ANIMATION));
GVRContext ctx = mAvatarRoot.getGVRContext();
GVRResourceVolume volume = new GVRResourceVolume(ctx, avatarResource);
GVRSceneObject modelRoot = new GVRSceneObject(ctx);
mAvatarRoot.addChildObject(modelRoot);
ctx.getAssetLoader().loadModel(volume, modelRoot, settings, false, mLoadModelHandler);
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.