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 - kiffa

Pages: 1 ... 5 6 [7] 8 9 ... 14
91
Support / Strange texture rendering.
« on: March 27, 2013, 10:33:24 am »
My game have a car and 2 scenes, i keep the car-Object3D in memory permanently, and unload the texture when scene changing, the problem is:

1, In scene 1, all are fine, then change to scene2, unload the texture.
2, In scene 2, reload the car-texture(which is the same as scene 1), reassign it to the car.
3, The car seems rendering with another texture. For example, there are other objects in my scene, road\sky\building\tree..., the car seems rendering with the texture of the road.
4, Chang to scene 1 again, unload\reload\reassign, the car seems rendering with the texture of the tree.
5, Chang to scene 2 again, the car seems rendering with the texture of the tree(of scene 2, which is different from the tree of scene 1).
6, Repeat changing scenes, at last, the car will be black and doesn't change any more.

scene 1:


scene 2:


scene 1:


at last:

92
Support / Re: Some issues about transparency sorting.
« on: March 27, 2013, 09:42:39 am »
Can i do like this :

1, Rendering all opacity objs.

2, Sorting all transparent objs, then rendering them by 2 pass:
 a, pass 1:
     Disable alpha blend, enable alpha test, enable zBuffer, enable zBuffer-writable, only rending the pixel with alpha>=1(means 100% opacity ).

 b, pass 2:
     Enable alpha blend, enable alpha test, enable zBuffer, disable zBuffer-writable, only rending the pixel with alpha<1

93
Support / Re: How to judge if a texture contains alpha?
« on: March 27, 2013, 04:03:03 am »
Both of the above are not easy to use(for my case). Could you add the method Texture.containsAlpha() ?

94
Support / Re: How to improve the performance of SkyBox?
« on: March 26, 2013, 02:47:20 pm »
So, the following 2 codes have the very close performance, right?:

Code: [Select]
//code 1
world1.add(obj1);
world2.add(obj2);
renderWorld1();
renderWorld2();

//code 2
world.add(obj1);
world.add(obj2);
renderWorld();

95
Support / Re: How to improve the performance of SkyBox?
« on: March 26, 2013, 09:13:21 am »
I tried to add sky to sceneWorld, but the result seems incorrect:

Code: [Select]
sceneWorld.addObject(sky);

sky.setRenderHook(new IRenderHook() {
    @Override
      public void beforeRendering(int paramInt) {
        mBackPos = sceneWorld.getCamera().getPosition();
        sceneWorld.getCamera().setPosition(0,0,0);
        GLES20.glDepthMask(false);
      }
     
      @Override
      public void afterRendering(int paramInt) {
        GLES20.glDepthMask(true);
        sceneWorld.getCamera().setPosition(mBackPos);
      }
    });
});



When does jPCT-AE calculate and upload the MVP matrix?

96
Support / Re: Some issues about transparency sorting.
« on: March 26, 2013, 09:03:33 am »
Thanks, i will try to split the buildings or make them opacity or add an opacity wall behind them.

Another question: Is there any difference of performance between one large mesh and many split ones?

97
Support / How to improve the performance of SkyBox?
« on: March 26, 2013, 08:52:34 am »
I made a skyBox, which cause a 6-9 fps dropping down。How to improve the performance? Could i use only one world and one-time rendering to make skyBox?

My codes:

Code: [Select]
World skyWorld = new world();

/ /sky is an object3D which has a center of (0,0,0);
skyWorld.add(sky). 

//set camera to the center of sky.
skyWorld.getCamera().setPosition(0,0,0);

// sceneWorld is the world of scene(the "real" world).
skyWorld.getCamera().setBack(sceneWorld.getCamera().getBack());

// don't write to zBuffer when rendering the sky, to avoid to adjust the size of sky.
sky.setRenderHook(new IRenderHook(){
 public void beforeRendering(int paramInt) {
         GLES20.glDepthMask(false);
      }

  public void afterRendering(int paramInt) {
        GLES20.glDepthMask(true);
      }

});

// onDrawFrame(), rendering sky per frame
framebuffer.clear();
skyWorld.renderScene(framebuffer);
skyWorld.draw(framebuffer);

sceneWorld.renderScene(framebuffer);
sceneWorld.draw(framebuffer);

framebuffer.display();
 

98
Support / Re: Some issues about transparency sorting.
« on: March 26, 2013, 03:01:09 am »
The road is a ring, and some roads may be too complex to split( will cause many small objs). Any other solutions?

。。。。。。
。            。
。A          。    <--- look at
。。。。。。
building-ring

Could i discard the "A" by Z-buffer?



99
Support / Some issues about transparency sorting.
« on: March 25, 2013, 11:12:47 am »
I 'am making a car-racing game. I made a road with some buildings, these buildings are just planes with alpha textures(png), and all the buildings are combinded to one mesh. The problem is: i could see the far buildings through the near buildings.

。。。。。。。。。。。。。。。。。。。
。                                                   。
。(far building)        (near building)。   <----- look at
。                                                   。
。。。。。。。。。。。。。。。。。。。
               



100
Support / Re: How to move a car upon the ground of the ups and downs?
« on: March 23, 2013, 03:58:54 am »
           ^ +Y
            |
            |
+Z <---- (Out screen = +X)
           。。。。。           
           。。。。。
           。。。。。
。。。。。。。。。
。。。。。。。。。
F。。。。。。。R
       car

In my codes, the orgs are "F" and "R"(front and rear), they cast rays to ground. Maybe the org and the ground are too close, i will try to adjust them.

101
Support / How to judge if a texture contains alpha?
« on: March 22, 2013, 12:40:29 pm »
I'm writing a SceneLoader which has a feature: auto setting Object3D's transparency by it's texture. Codes may like that:

Code: [Select]
Texture texture = TextureManager.getInstance().getTexture(name);
object3d.setTexture(name);

if(texture.containsAlpha()){
  object3d.setTransparency(0xff);
}

But there isn't a method like texture.containsAlpha().

102
Support / Re: How to move a car upon the ground of the ups and downs?
« on: March 22, 2013, 04:22:25 am »
Thanks for the car-example, it helps much. But i also have some problems:

1, When the car moving down or up, the camera will shake —— not smooth.
2,Sometimes, the car will run into the ground.

My question:

1, Object3D.calcMinDistance(org, dir): Does the method mean this: From "org", castting a ray along the "dir", if the ray hits the "Object3D", return the length of the ray(segment).

。。。。。|<--return--->|
。。。。。<-------------- 。
。。。。。
Object3D        dir       org

2, If the org is located into the object3D, then what happen? Return what?

There are my codes, could you point out the problems(camera-shaking and running into ground), thanks:

1, Update the camera per frame, the camera will be located behind and above the car, look at the car-direction(z-axis) :

                            <----- 。camera
         。。。。         
。。。。。。。
。。。。。。。
     car

Code: [Select]

// I use a GL-like coordinate system: up(+y),right(+x), out(+z)
private void updateCamera() {
    if (mCombinedObj == null)   // mCominedObj means the car
      return;

    SimpleVector camPos = mCombinedObj.getTransformedCenter();
    camPos.y += mUpOffset;  // mUpOffset == 20, move up the camera
   
    SimpleVector up = mCombinedObj.getYAxis();
    SimpleVector direction = mCombinedObj.getZAxis();
    mCamera.setOrientation(direction, up);
   
    direction.scalarMul(mDirOffset);  // mDirOffset == -20
    camPos.add(direction);
   
    mCamera.setPosition(camPos);
  }


2, Moving the car:
 My car is just one .obj model which has no wheels, i assume the front-bottom-middle as the front wheel, the rear-bottom-middle as the rear wheel, using the two "wheels" to calculate the angle between ground and car-direction(rotate around x-axis), and simply ignore the rotating around z-axis.
 
Code: [Select]
private boolean placeOnGround(Object3D road) {

    SimpleVector step = mCar.getZAxis();
    step.scalarMul(mCurrentSpeed);
    mCar.translate(step);

    SimpleVector dropDown = new SimpleVector(0, -1, 0);

    /**
     * To cast the rays, the car will be rotated in horizontal position first,
     * rotated around the y-axis according to the cars direction and moved 10
     * units up.
     */
    mCar.clearRotation();
    mCar.rotateY(mTurnY);
    mCar.translate(0, 10, 0);

    /**
     * Cast the rays...
     */
    SimpleVector front = mCar.getCenter().calcAdd(
        SimpleVector.create(0, -mHeight / 2 + 1, mLenth / 2));   // mHeight meas the height of the car(AABB, y-axis),  mLenth means the lenth of the car(AABB, z-axis).

    SimpleVector rear = mCar.getCenter().calcAdd(
        SimpleVector.create(0, -mHeight / 2 + 1, -mLenth / 2));
   

    Matrix m = mCar.getWorldTransformation();
    front.matMul(m);
    rear.matMul(m);

    float frontHeight = road.calcMinDistance(front, dropDown, 4 * 30);
    float rearHeight = road.calcMinDistance(rear, dropDown, 4 * 30);

    /**
     * Correct the movement we did above.
     */
    mCar.translate(0, -10, 0);
    mCar.clearRotation();

    /**
     * The rays all hit the ground, the car can be placed
     */
    if(frontHeight != Object3D.COLLISION_NONE && rearHeight != Object3D.COLLISION_NONE){

      /**
       * Correct the values (see translation above)
       */
     
      frontHeight -= 10;
      rearHeight -= 10;

      /**
       * Calculate the angles between the wheels and the ground.
       */
      double angle= frontHeight - rearHeight;
      double as = (angle/ (mLenth));
      float rot = (float) Math.atan(as);
     
      WLog.d("rotateX: " + rot);
      mCar.rotateX(-rot);

      /**
       * The car is correctly rotated now. But we still have to adjust the
       * height. We are simply taking the minimum distance from all wheels to
       * the ground as the new height.
       */
     
      float down = frontHeight;
      if(frontHeight > rearHeight)
        down = rearHeight;

      dropDown.scalarMul(down);
      WLog.d("car down: " + down);
      WLog.d("car updown: " + dropDown);
      mCar.translate(dropDown);
      step.add(dropDown);
    }
    /**
     * And finally, rotate the car around Y (that's the car's direction)
     */
    mCar.rotateY(mTurnY);
}


103
Support / How to move a car upon the ground of the ups and downs?
« on: March 20, 2013, 01:33:42 pm »
I'm making a car-racing game, the road is undulate, how to moving the car? Some sample codes will be very helpful, thanks!

104
Support / Re: Some issues abuout rendering when camera moving out.
« on: February 27, 2013, 10:48:29 am »
Thanks, and i found the extension(EGL_NV_depth_nonlinear) spec(include the magic num) in khronos:

http://www.khronos.org/registry/egl/extensions/NV/EGL_NV_depth_nonlinear.txt

The last question: Could you plan to support OpenGL ES 3.0?

105
Support / Re: Some issues abuout rendering when camera moving out.
« on: February 27, 2013, 04:15:40 am »
Some info about egl extension:

02-27 10:42:12.270: D/Woo3d(3944): egl vendor: Android
02-27 10:42:12.270: D/Woo3d(3944): egl version: 1.4 Android META-EGL
02-27 10:42:12.270: D/Woo3d(3944): egl extension: EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_gl_renderbuffer_image EGL_ANDROID_image_native_buffer EGL_ANDROID_swap_rectangle

And i didn't use the AAConfigChooser, but a custom ConfigChooser like that:

Code: [Select]
int[] configSpec = new int[] {
        EGL10.EGL_RED_SIZE, mRedSize,
        EGL10.EGL_GREEN_SIZE, mGreenSize,
        EGL10.EGL_BLUE_SIZE, mBlueSize,
        EGL10.EGL_ALPHA_SIZE, mAlphaSize,
        EGL10.EGL_DEPTH_SIZE, mDepthSize,
        EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
        12512, 1, // EGL_COVERAGE_BUFFERS_NV
        12513, 2, // EGL_COVERAGE_SAMPLES_NV
        EGL10.EGL_NONE };

Using NVDepthConfigChooser, the appearance seems much better! Log:

02-27 10:46:59.190: I/jPCT-AE(4917): Nonlinear depth buffer enabled!
02-27 10:46:59.190: I/jPCT-AE(4917): Unable to find a matching config...using default!
02-27 10:46:59.200: I/jPCT-AE(4917): Initializing GL20 render pipeline...


Using AAConfigChooser, the appearance is as good as using NVDepthConfigChooser!

Thanks, i will use AAConfigChooser by default. I used  a custom ConfigChooser before, because i want to print some info to study.

Another question, where can i get the doc of EGL/GL extensions? The home page of GPU-vendor?

I print the EGL extensions of Tegra(above), why there is no extension like EGL_NV_XXXX? My printing code:
Code: [Select]
    String extension = egl.eglQueryString(display, EGL10.EGL_EXTENSIONS);
    WLog.d("egl extension: " + extension);


Pages: 1 ... 5 6 [7] 8 9 ... 14