コード例 #1
0
  @Override
  public void initScene() {
    mCameraLeft = new Camera();
    mCameraLeft.setNearPlane(.01f);
    mCameraLeft.setFieldOfView(getCurrentCamera().getFieldOfView());
    mCameraLeft.setNearPlane(getCurrentCamera().getNearPlane());
    mCameraLeft.setFarPlane(getCurrentCamera().getFarPlane());

    mCameraRight = new Camera();
    mCameraRight.setNearPlane(.01f);
    mCameraRight.setFieldOfView(getCurrentCamera().getFieldOfView());
    mCameraRight.setNearPlane(getCurrentCamera().getNearPlane());
    mCameraRight.setFarPlane(getCurrentCamera().getFarPlane());

    setPupilDistance(mPupilDistance);

    mLeftQuadMaterial = new Material();
    mLeftQuadMaterial.setColorInfluence(0);
    mRightQuadMaterial = new Material();
    mRightQuadMaterial.setColorInfluence(0);

    mSideBySideScene = new RajawaliScene(this);

    mLeftQuad = new ScreenQuad();
    mLeftQuad.setScaleX(.5);
    mLeftQuad.setX(-.25);
    mLeftQuad.setMaterial(mLeftQuadMaterial);
    mSideBySideScene.addChild(mLeftQuad);

    mRightQuad = new ScreenQuad();
    mRightQuad.setScaleX(.5);
    mRightQuad.setX(.25);
    mRightQuad.setMaterial(mRightQuadMaterial);
    mSideBySideScene.addChild(mRightQuad);

    addScene(mSideBySideScene);

    mViewportWidthHalf = (int) (mDefaultViewportWidth * .5f);

    mLeftRenderTarget = new RenderTarget("sbsLeftRT", mViewportWidthHalf, mDefaultViewportHeight);
    mLeftRenderTarget.setFullscreen(false);
    mRightRenderTarget = new RenderTarget("sbsRightRT", mViewportWidthHalf, mDefaultViewportHeight);
    mRightRenderTarget.setFullscreen(false);

    mCameraLeft.setProjectionMatrix(mViewportWidthHalf, mDefaultViewportHeight);
    mCameraRight.setProjectionMatrix(mViewportWidthHalf, mDefaultViewportHeight);

    addRenderTarget(mLeftRenderTarget);
    addRenderTarget(mRightRenderTarget);

    try {
      mLeftQuadMaterial.addTexture(mLeftRenderTarget.getTexture());
      mRightQuadMaterial.addTexture(mRightRenderTarget.getTexture());
    } catch (TextureException e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
 private Material getStandardMaterial() {
   Material newMaterial = new Material();
   newMaterial.enableLighting(true);
   //        newMaterial.setDiffuseMethod(new DiffuseMethod.Lambert());
   newMaterial.setColorInfluence(0);
   Bitmap transparentBitmap = drawTextToBitmap("");
   try {
     newMaterial.addTexture(new Texture("placeholder", transparentBitmap));
   } catch (TextureException e) {
     e.printStackTrace();
   }
   return newMaterial;
 }
コード例 #3
0
  private void createFloor() {
    //
    // -- Load a bitmap that represents the terrain. Its color values will
    //    be used to generate heights.
    //
    Plane mPlane = new Plane(500, 500, 100, 100);
    mPlane.setPosition(0, 0, 0);
    mPlane.setDoubleSided(true);
    Material material1 = new Material();
    material1.setColorInfluence(0);
    Bitmap picTexture =
        BitmapFactory.decodeResource(mContext.getResources(), R.drawable.squares_big);
    try {
      material1.addTexture(new Texture("squares", picTexture));
    } catch (TextureException e) {
      e.printStackTrace();
    }
    mPlane.setMaterial(material1);

    // Set orientation of the plane.
    Quaternion q = new Quaternion();
    q.fromAngleAxis(Vector3.Axis.X, 90);
    mPlane.setOrientation(q);
    getCurrentScene().addChild(mPlane);
    try {
      getCurrentScene()
          .setSkybox(
              R.drawable.right,
              R.drawable.left,
              R.drawable.top,
              R.drawable.bottom,
              R.drawable.front,
              R.drawable.back);
    } catch (TextureException e) {
      e.printStackTrace();
    }
  }
コード例 #4
0
ファイル: Scene.java プロジェクト: Cysion1989/Rajawali
 /**
  * Creates a skybox with the specified 6 {@link Bitmap} textures.
  *
  * @param bitmaps {@link Bitmap} array containing the cube map textures.
  */
 public boolean setSkybox(Bitmap[] bitmaps) {
   final AFrameTask task =
       new AFrameTask() {
         @Override
         protected void doTask() {
           for (int i = 0, j = mCameras.size(); i < j; ++i) mCameras.get(i).setFarPlane(1000);
         }
       };
   final Cube skybox = new Cube(700, true);
   final CubeMapTexture texture = new CubeMapTexture("bitmap_skybox", bitmaps);
   texture.isSkyTexture(true);
   final Material material = new Material();
   material.setColorInfluence(0);
   try {
     material.addTexture(texture);
   } catch (TextureException e) {
     RajLog.e(e.getMessage());
   }
   skybox.setMaterial(material);
   synchronized (mNextCameraLock) {
     mNextSkybox = skybox;
   }
   return internalOfferTask(task);
 }