Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - smither

Pages: [1]
1
Support / Re: Is it possible to change the TextureInfo on the fly?
« on: September 28, 2010, 06:54:44 pm »
Code: [Select]
Object3D template=new Object3D(4);
TextureManager tm=TextureManager.getInstance();
TextureInfo tInfo=new TextureInfo(tm.getTextureID(Globals.TextureGoalKeeper2), 0, 0, 0, 1, 1, 0);
template.addTriangle(new SimpleVector(0,0,0), new SimpleVector(0,0,-10),new SimpleVector(10,0,0), tInfo);
tInfo=new TextureInfo(tm.getTextureID(Globals.TextureGoalKeeper2), 1, 0, 0, 1, 1, 1);
template.addTriangle(new SimpleVector(10,0,0), new SimpleVector(0,0,-10),new SimpleVector(10,0,-10), tInfo);
That's how i'm setting the texture to the object

2
Support / Is it possible to change the TextureInfo on the fly?
« on: September 28, 2010, 05:36:10 pm »
I'm trying to accomplish an animation changing the texture, I'm not using setTexture to do it, because i build the texture using TextureInfo and addTriangle..., it works fine for the initial texture, but when i try to do the same once the scene is already displayed nothing happens.

3
Support / Re: Priorities for collisions
« on: September 22, 2010, 09:21:13 pm »
With "closer" you catch me ;D.

Actually is my fault, I've forgotten the CollisionEvent return a list of Targets and I was checking just the first one of the list! Sorry

4
Support / Re: Priorities for collisions
« on: September 22, 2010, 06:57:54 pm »
I'm using the checkForCollisionEllipsoid method

5
Support / Priorities for collisions
« on: September 22, 2010, 05:03:41 pm »
I want to know if the collisions are calculated using a priority, or depends on the order of how the elements were added, set or whatever.

Maybe it's my fault and is not the engine, I have 1 Object (source) and 2 Objects (targets), everything is set properly and works as expected most of the time, but sometimes when the source will collied with both objects the engine always choose the same no matter if the non chosen is the closer one.


6
Bugs / Re: Maybe a bug? Blank screen after Home button pressed
« on: September 21, 2010, 04:56:46 pm »
I solved the problem, but i have to create a new GLSurfaceView instance and set the content with it on the onResume() method for the second time, Don't know if this is the properly approach but it's the only way I've found to do it.


7
Bugs / Re: Maybe a bug? Blank screen after Home button pressed
« on: September 21, 2010, 03:17:59 pm »
Looking at the Logcat there's no second call to the method onCreate()  ???, that's weird...

Edit: It's being called now, but i wonder what view to use to setContenView() because if i try to use the same one I have in the instance I get an exception because the view belong to it's parent,however, i try on the onPause() to remove the view from the parent but the result is the same.

8
Bugs / Re: Maybe a bug? Blank screen after Home button pressed
« on: September 21, 2010, 02:35:16 pm »
Yes, sorry about that, i'd tried with the static approach before posting and with the same results, then I tried with the non-static approach (just to test)  and that's why is posted that way  ;D.

Somehow making the _instance attribute static doesn't prevent me from getting a black screen when I return to the view.

9
Bugs / Re: Maybe a bug? Blank screen after Home button pressed
« on: September 20, 2010, 11:37:30 pm »
What's wrong about this? I can't click the home screen and go back becuase i lose the cube.


public class Liberable extends Activity {
   private GLSurfaceView mGLView;
   private Renderer renderer = null;
   private FrameBuffer fb = null;
   private Light sun=null;
   private World world = null;
   private Object3D cube=null;
   private boolean paused = false;
   public Liberable _instance;
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      if(_instance==null)
      {
         mGLView = new GLSurfaceView(getApplication());
         mGLView.setEGLConfigChooser(new GLSurfaceView.EGLConfigChooser() {
            public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
               // Ensure that we get a 16bit framebuffer. Otherwise, we'll fall
               // back to Pixelflinger on some device (read: Samsung I7500)
               int[] attributes = new int[] { EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE };
               EGLConfig[] configs = new EGLConfig[1];
               int[] result = new int[1];
               egl.eglChooseConfig(display, attributes, configs, 1, result);
               return configs[0];
            }
         });
         renderer = new Renderer();
         mGLView.setRenderer(renderer);
         setContentView(mGLView);
         _instance=this;
         Log.d("Liberable","0");
      }
      else
      {
         Log.d("Liberable","1");
         copy(_instance);
         renderer.reset();
      }
   }
   
   @Override
   protected void onPause() {
      _instance.paused = true;
      super.onPause();
      mGLView.onPause();
   }

   @Override
   protected void onResume() {
      if(_instance.paused)
      {
         Log.d("Liberable","2");
         copy(_instance);
         renderer.reset();
      }
      _instance.paused = false;
      super.onResume();
      mGLView.onResume();
   }

   protected void onStop() {
      renderer.stop();
      super.onStop();
   }

   private void copy(Liberable src) {
      try {
         Logger.log("Copying data from master Activity!");
         Field[] fs = src.getClass().getDeclaredFields();
         for (Field f : fs) {
            f.setAccessible(true);
            f.set(this, f.get(src));
         }
      } catch (Exception e) {
         throw new RuntimeException(e);
      }
   }
   
   class Renderer implements GLSurfaceView.Renderer {
      private boolean resetFB=false;
      private boolean stop = false;
      int w;
      int h;
      
      public Renderer()
      {
         Config.glAvoidTextureCopies=false;
      }
      @Override
      public void onDrawFrame(GL10 gl) {
         try {
            if (!stop) {
               if (paused) {
                  Thread.sleep(500);
               } else {
                  if(resetFB)
                  {
                     fb = new FrameBuffer(gl, w, h);
                     resetFB=false;
                  }
                  fb.clear();
                  world.renderScene(fb);
                  world.draw(fb);
                  fb.display();
               }
            }
            else {
               if (fb != null) {
                  fb.dispose();
                  fb = null;
               }
            }
         } catch (Exception e) {
            Logger.log("Drawing thread terminated!", Logger.MESSAGE);
         }
      }

      @Override
      public void onSurfaceChanged(GL10 gl, int w, int h) {
         if (fb != null) {
            fb.dispose();
         }
         fb = new FrameBuffer(gl, w, h);
         Log.d("Pepe", "w:"+w+",h:"+h);
         this.h=h;
         this.w=w;
         Log.d("Liberable","Changed");
      }

      @Override
      public void onSurfaceCreated(GL10 gl, EGLConfig config) {
//         if (fb != null) {
//            fb.dispose();
//         }
//         fb = new FrameBuffer(gl, w, h);
         Log.d("Liberable","Created");
         TextureManager.getInstance().flush();
         world = new World();
         Resources res = getResources();
         TextureManager tm = TextureManager.getInstance();
         Texture lineasT=new Texture(res.openRawResource(R.raw.blanco),true);
         tm.addTexture("white", lineasT);
         cube=Primitives.getCube(3);
         cube.setTexture("white");
         cube.build();
         world.addObject(cube);
         sun = new Light(world);
         Camera cam = world.getCamera();
         cam.moveCamera(Camera.CAMERA_MOVEOUT, 10);
         cam.lookAt(cube.getTransformedCenter());
         cam.setFOV(1.5f);
         sun.setIntensity(250, 250, 250);
         SimpleVector sv = new SimpleVector();
         sv.set(cube.getTransformedCenter());
         sv.y -= 300;
         sv.x -= 100;
         sv.z += 200;
         sun.setPosition(sv);
      }
   
      public void stop() {
         stop = true;
         if (fb != null) {
            fb.dispose();
            fb = null;
         }
      }
      public void reset()
      {
         resetFB=true;
         
      }
   }
}

10
Support / OutOfMemoryError Exception
« on: September 20, 2010, 09:28:07 pm »
Giving the fact the Engine destroy the glContext when the activity goes to the background I try to reload everything again for the next time but I get an OutOfMemoryError Exception.

Anyone else had run on this issue?

11
Support / Re: Collision between 2 models.
« on: September 15, 2010, 04:50:36 pm »
I'd run in the same problem, sometimes the collision worked and sometimes didn't. I was using the ellipsoid approach, I decreased the ellipse size and started to work for all the cases.  :D

12
Support / Re: How to do 2D click to 3D object picking?
« on: September 01, 2010, 08:55:35 pm »
What's more expensive in terms of performance? Call to calcMinDistanceAndObject3D or just check a collision between the position the user click on the screen?

Because if i can have a confirmation from the listener I won't have to figure out how to fix the issue unless the difference between these 2 approaches is too much.

13
Support / Re: How to do 2D click to 3D object picking?
« on: August 31, 2010, 07:11:03 pm »
I have the same problem that Ilse had, i always get 1.0E12 no matter what value i use for the last parameter.

Any idea?

Pages: [1]