@Override
 protected void onPause() {
   super.onPause();
   if (mRajRenderer == null) return;
   mSurfaceView.onPause();
   mRajRenderer.onVisibilityChanged(false);
   mRajRenderer.onSurfaceDestroyed();
 }
Beispiel #2
0
 public LoaderFBX(RajawaliRenderer renderer, int resourceId) {
   super(renderer.getContext().getResources(), resourceId);
   mRenderer = renderer;
   mObjStack = new Stack<Object>();
   mFbx = new FBXValues();
   mObjStack.add(mFbx);
 }
 @Override
 protected void onResume() {
   super.onResume();
   if (mRajRenderer == null) return;
   mSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
   mSurfaceView.onResume();
   mRajRenderer.onVisibilityChanged(true);
 }
 @Override
 public void onDrawFrame(GL10 glUnused) {
   super.onDrawFrame(glUnused);
   getCurrentCamera().setZ(dist);
   // mObject.setRotation(mAccValues.x, mAccValues.y, mAccValues.z);
   getCurrentCamera().setZ(dist);
   if (direction == 1) mObject.setRotY(mObject.getRotY() - 2);
   else if (direction == 2) mObject.setRotY(mObject.getRotY() + 2);
   else if (direction == 3) mObject.setRotX(mObject.getRotX() - 2);
   else if (direction == 4) mObject.setRotX(mObject.getRotX() + 2);
 }
 @Override
 public void onDrawFrame(GL10 glUnused) {
   // mTexture.updateTexImage();
   super.onDrawFrame(glUnused);
   if (izLoaded == false) {
     clearScene();
     loadScene();
     izLoaded = true;
   }
   // iterate thru objects for interactivity
   if (doLoad == true) {}
 }
Beispiel #6
0
  /** {@inheritDoc} */
  void remove() {
    mModelMatrix = null;
    mModelViewMatrix = null;

    if (mLights != null) mLights.clear();
    if (mTextureList != null) mTextureList.clear();

    if (RajawaliRenderer.hasGLContext()) {
      GLES20.glDeleteShader(mVShaderHandle);
      GLES20.glDeleteShader(mFShaderHandle);
      GLES20.glDeleteProgram(mProgramHandle);
    }
  }
Beispiel #7
0
  @Override
  protected void parse(InputStream is) throws ParsingException {
    BufferedReader buffer = new BufferedReader(new InputStreamReader(is));
    String line;
    try {
      while ((line = buffer.readLine()) != null) {
        String repl = line.replaceAll(REGEX_CLEAN, REPLACE_EMPTY);
        if (repl.length() == 0 || repl.charAt(0) == COMMENT) continue;

        readLine(buffer, line);
      }
      buffer.close();
    } catch (Exception e) {
      throw new ParsingException(e);
    }

    // -- get lights

    Stack<Model> lights = mFbx.objects.getModelsByType(FBXValues.MODELTYPE_LIGHT);
    int numLights = lights.size();

    RajawaliRenderer.setMaxLights(numLights == 0 ? 1 : numLights);
    Stack<ALight> sceneLights = new Stack<ALight>();

    for (int i = 0; i < numLights; ++i) {
      Model l = lights.get(i);
      // -- really need to add more light types

      sceneLights.add(buildLight(l));
    }

    if (numLights == 0) {
      ALight light = new DirectionalLight();
      light.setPosition(2, 0, -5);
      light.setPower(1);
      sceneLights.add(light);
    }

    // -- check fog
    // TODO: add fog support
    /*
     * if(mFbx.version5.fogOptions.fogEnable != null && mFbx.version5.fogOptions.fogEnable == 1) { FogOptions
     * fogOptions = mFbx.version5.fogOptions; mRenderer.setFogEnabled(true); Camera cam = mRenderer.getCamera();
     * cam.setFogEnabled(true); cam.setFogNear(fogOptions.fogStart); cam.setFogColor(fogOptions.fogColor.color);
     * mRenderer.setBackgroundColor(fogOptions.fogColor.color); }
     */

    // -- get meshes

    Stack<Model> models = mFbx.objects.getModelsByType(FBXValues.MODELTYPE_MESH);

    try {
      for (int i = 0; i < models.size(); ++i) {
        buildMesh(models.get(i), sceneLights);
      }
    } catch (TextureException tme) {
      throw new ParsingException(tme);
    }

    // -- get cameras

    Stack<Model> cameras = mFbx.objects.getModelsByType(FBXValues.MODELTYPE_CAMERA);
    Model camera = null;

    for (int i = 0; i < cameras.size(); ++i) {
      if (cameras.get(i).hidden == null || !cameras.get(i).hidden.equals("True")) {
        camera = cameras.get(i);
        break;
      }
    }

    if (camera != null) { // TODO: FIX
      Camera cam = mRenderer.getCurrentCamera();
      cam.setPosition(camera.position);
      cam.setX(mRenderer.getCurrentCamera().getX() * -1);
      cam.setRotation(camera.properties.lclRotation);
      Vector3 lookAt = camera.lookAt;
      // lookAt.x = -lookAt.x;
      cam.setLookAt(lookAt);
      cam.setNearPlane(camera.properties.nearPlane);
      cam.setFarPlane(camera.properties.farPlane);
      cam.setFieldOfView(camera.properties.fieldOfView);
    }
  }
Beispiel #8
0
 public LoaderOBJ(RajawaliRenderer renderer, int resourceId) {
   this(renderer.getContext().getResources(), renderer.getTextureManager(), resourceId);
 }
 public void onSurfaceDestroyed() {
   mMediaPlayer.release();
   super.onSurfaceDestroyed();
 }
 @Override
 public void onSurfaceCreated(GL10 gl, EGLConfig config) {
   super.onSurfaceCreated(gl, config);
 }