This side effects the OpenGL context to set the view to match
        the camera.
188953
def set_gl_transform(self):
        
        tangent = np.tan(self.fov_deg / 2.0 / 180.0 * np.pi)
        vport_radius = self.near_plane * tangent
        # calculate aspect of the viewport
        if self.vport_wd_px < self.vport_ht_px:
            vport_wd = 2.0 * vport_radius
            vport_ht = vport_wd * self.vport_ht_px / float(self.vport_wd_px)

        else:
            vport_ht = 2.0 * vport_radius
            vport_wd = vport_ht * self.vport_wd_px / float(self.vport_ht_px)

        gl.glFrustum(
            -0.5 * vport_wd, 0.5 * vport_wd,    # left, right
            -0.5 * vport_ht, 0.5 * vport_ht,    # bottom, top
            self.near_plane, self.far_plane
        )

        M = Matrix4x4.look_at(self.position, self.target, self.up, False)
        gl.glMultMatrixf(M.get())
1253386
private void convertToOutput( View origin ) {
		structure = new SceneStructureMetric(false);
		observations = new SceneObservations(viewsAdded.size());

		// TODO can this be simplified?
		int idx = 0;
		for( String key : graph.cameras.keySet() ) {
			cameraToIndex.put(key,idx++);
		}

		structure.initialize(cameraToIndex.size(),viewsAdded.size(), graph.features3D.size());

		for ( String key : graph.cameras.keySet() ) {
			int i = cameraToIndex.get(key);
			structure.setCamera(i,true,graph.cameras.get(key).pinhole);
		}

		// look up table from old index to new index
		int viewOldToView[] = new int[ graph.nodes.size() ];
		Arrays.fill(viewOldToView,-1);
		for (int i = 0; i < viewsAdded.size(); i++) {
			viewOldToView[ graph.nodes.indexOf(viewsAdded.get(i))] = i;
		}

		for( int i = 0; i < viewsAdded.size(); i++ ) {
			View v = viewsAdded.get(i);
			int cameraIndex = cameraToIndex.get(v.camera.camera);
			structure.setView(i,v==origin,v.viewToWorld.invert(null));
			structure.connectViewToCamera(i,cameraIndex);
		}

		for (int indexPoint = 0; indexPoint < graph.features3D.size(); indexPoint++) {
			Feature3D f = graph.features3D.get(indexPoint);

			structure.setPoint(indexPoint,f.worldPt.x,f.worldPt.y,f.worldPt.z);

			if( f.views.size() != f.obsIdx.size )
				throw new RuntimeException("BUG!");

			for (int j = 0; j < f.views.size(); j++) {
				View view = f.views.get(j);
				int viewIndex = viewOldToView[view.index];
				structure.connectPointToView(indexPoint,viewIndex);

				Point2D_F64 pixel = viewsAdded.get(viewIndex).observationPixels.get(f.obsIdx.get(j));
				observations.getView(viewIndex).add(indexPoint,(float)(pixel.x),(float)(pixel.y));
			}
		}

	}
458438
public void setCamera2( double fx , double fy , double skew , double cx , double cy ) {
		PerspectiveOps.pinholeToMatrix(fx,fy,skew,cx,cy,K2);
		PerspectiveOps.invertPinhole(K2,K2_inv);
	}
503385
private static void checkBehindCamera(SceneStructureMetric structure, SceneObservations observations, BundleAdjustment<SceneStructureMetric> bundleAdjustment) {

		int totalBehind = 0;
		Point3D_F64 X = new Point3D_F64();
		for (int i = 0; i < structure.points.length; i++) {
			structure.points[i].get(X);
			if( X.z < 0 )
				totalBehind++;
		}
		structure.views[1].worldToView.T.print();
		if( totalBehind > structure.points.length/2 ) {
			System.out.println("Flipping because it's reversed. score = "+bundleAdjustment.getFitScore());
			for (int i = 1; i < structure.views.length; i++) {
				Se3_F64 w2v = structure.views[i].worldToView;
				w2v.set(w2v.invert(null));
			}
			triangulatePoints(structure,observations);

			bundleAdjustment.setParameters(structure,observations);
			bundleAdjustment.optimize(structure);
			System.out.println("  after = "+bundleAdjustment.getFitScore());
		} else {
			System.out.println("Points not behind camera. "+totalBehind+" / "+structure.points.length);
		}
	}
181265
def set_viewup(self, vector):
        
        if isinstance(vector, np.ndarray):
            if vector.ndim != 1:
                vector = vector.ravel()
        self.camera.SetViewUp(vector)
        self._render()
431288
public void onDrawFrame(float frameTime) {
        final GVRSceneObject owner = getOwnerObject();
        if (owner == null) {
            return;
        }

        final int size = mRanges.size();
        final GVRTransform t = getGVRContext().getMainScene().getMainCameraRig().getCenterCamera().getTransform();

        for (final Object[] range : mRanges) {
            ((GVRSceneObject)range[1]).setEnable(false);
        }

        for (int i = size - 1; i >= 0; --i) {
            final Object[] range = mRanges.get(i);
            final GVRSceneObject child = (GVRSceneObject) range[1];
            if (child.getParent() != owner) {
                Log.w(TAG, "the scene object for distance greater than " + range[0] + " is not a child of the owner; skipping it");
                continue;
            }

            final float[] values = child.getBoundingVolumeRawValues();
            mCenter.set(values[0], values[1], values[2], 1.0f);
            mVector.set(t.getPositionX(), t.getPositionY(), t.getPositionZ(), 1.0f);

            mVector.sub(mCenter);
            mVector.negate();

            float distance = mVector.dot(mVector);

            if (distance >= (Float) range[0]) {
                child.setEnable(true);
                break;
            }
        }
    }
1272797
def _prepare_draw(self, view=None):
        

        if self._changed['pos']:
            self.pos_buf.set_data(self._pos)
            self._changed['pos'] = False

        if self._changed['color']:
            self.color_buf.set_data(self._color)
            self._program.vert['color'] = self.color_buf
            self._changed['color'] = False

        return True
387068
public void clampTexture() {
        if (GL.canTextureMirrorClamp()) {
        	GL.glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT);
        	GL.glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_MIRROR_CLAMP_TO_EDGE_EXT);
        } else {
        	GL.glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_S, SGL.GL_CLAMP);
        	GL.glTexParameteri(SGL.GL_TEXTURE_2D, SGL.GL_TEXTURE_WRAP_T, SGL.GL_CLAMP);
        }
	}
20426
public static void fullViewLeft(CameraPinholeBrown paramLeft,
									FMatrixRMaj rectifyLeft, FMatrixRMaj rectifyRight,
									FMatrixRMaj rectifyK)
	{
		ImplRectifyImageOps_F32.fullViewLeft(paramLeft, rectifyLeft, rectifyRight, rectifyK);
	}
357849
public void connectViewToCamera( int viewIndex , int cameraIndex ) {
		if( views[viewIndex].camera != -1 )
			throw new RuntimeException("View has already been assigned a camera");
		views[viewIndex].camera = cameraIndex;
	}
1296951
public void pruneObservationsBehindCamera() {
		Point3D_F64 X = new Point3D_F64();

		for (int viewIndex = 0; viewIndex < observations.views.length; viewIndex++) {
			SceneObservations.View v = observations.views[viewIndex];
			SceneStructureMetric.View view = structure.views[viewIndex];

			for (int pointIndex = 0; pointIndex < v.point.size; pointIndex++) {
				SceneStructureMetric.Point f = structure.points[v.getPointId(pointIndex)];

				// Get feature location in world
				f.get(X);

				if( !f.views.contains(viewIndex))
					throw new RuntimeException("BUG!");

				// World to View
				view.worldToView.transform(X, X);

				// Is the feature behind this view and can't be seen?
				if( X.z <= 0 ) {
					v.set(pointIndex, Float.NaN, Float.NaN);
				}
			}
		}

		removeMarkedObservations();
	}
1370337
function( gl, v, renderer ) {

			var unit = renderer.allocTextureUnit();
			gl.uniform1i( this.addr, unit );
			renderer.setTexture2D( v || emptyTexture, unit );

		}
1144973
private void wrapAllGLViews(View decorView) {
		ArrayList<GLSurfaceView> currentViews = viewFetcher.getCurrentViews(GLSurfaceView.class, true, decorView);
		final CountDownLatch latch = new CountDownLatch(currentViews.size());

		for (GLSurfaceView glView : currentViews) {
			Object renderContainer = new Reflect(glView).field("mGLThread")
					.type(GLSurfaceView.class).out(Object.class);

			Renderer renderer = new Reflect(renderContainer).field("mRenderer").out(Renderer.class);

			if (renderer == null) {
				renderer = new Reflect(glView).field("mRenderer").out(Renderer.class);
				renderContainer = glView;
			}  
			if (renderer == null) {
				latch.countDown();
				continue;
			}
			if (renderer instanceof GLRenderWrapper) {
				GLRenderWrapper wrapper = (GLRenderWrapper) renderer;
				wrapper.setTakeScreenshot();
				wrapper.setLatch(latch);
			} else {
				GLRenderWrapper wrapper = new GLRenderWrapper(glView, renderer, latch);
				new Reflect(renderContainer).field("mRenderer").in(wrapper);
			}
		}

		try {
			latch.await();
		} catch (InterruptedException ex) {
			ex.printStackTrace();
		}
	}
770882
public synchronized void setMainCameraRig(GVRCameraRig cameraRig) {
        mMainCameraRig = cameraRig;
        NativeScene.setMainCameraRig(getNative(), cameraRig.getNative());

        final GVRContext gvrContext = getGVRContext();
        if (this == gvrContext.getMainScene()) {
            gvrContext.getApplication().setCameraRig(getMainCameraRig());
        }
    }
802857
function processCamera(camera) {
      if (!outputJSON.cameras) {
        outputJSON.cameras = [];
      }

      var isOrtho = camera.isOrthographicCamera;

      var gltfCamera = {
        type: isOrtho ? 'orthographic' : 'perspective'
      };

      if (isOrtho) {
        gltfCamera.orthographic = {
          xmag: camera.right * 2,
          ymag: camera.top * 2,
          zfar: camera.far <= 0 ? 0.001 : camera.far,
          znear: camera.near < 0 ? 0 : camera.near
        };
      } else {
        gltfCamera.perspective = {
          aspectRatio: camera.aspect,
          yfov: THREE.Math.degToRad(camera.fov) / camera.aspect,
          zfar: camera.far <= 0 ? 0.001 : camera.far,
          znear: camera.near < 0 ? 0 : camera.near
        };
      }

      if (camera.name !== '') {
        gltfCamera.name = camera.type;
      }

      outputJSON.cameras.push(gltfCamera);

      return outputJSON.cameras.length - 1;
    }
470716
public void setObservations( List<Point2D_F64> observations , List<DMatrixRMaj> cameraMatrices ) {
		if( observations.size() != cameraMatrices.size() )
			throw new IllegalArgumentException("Different size lists");

		this.observations = observations;
		this.cameraMatrices = cameraMatrices;
	}
252937
function( gl, v, renderer ) {

			var n = v.length,
				units = allocTexUnits( renderer, n );

			gl.uniform1iv( this.addr, units );

			for ( var i = 0; i !== n; ++ i ) {

				renderer.setTextureCube( v[ i ] || emptyCubeTexture, units[ i ] );

			}

		}