2011-12-29

Now my turn is coming again!

This week I released a new version of JyoyaBell.
https://market.android.com/details?id=jp.ideadepot.JyoyaBell
This version features Facebook connection and mixi (a famous SNS in Japan) connection with using Facebook SDK for Android and mixi SDK, furthermore, contains complex shape buttons which I put it practical use what I posted here before. I plan to post here new tips I got in developing this app sooner or later.

JyoyaBell(in Japan, they call it "Jyoya No Kane") is a traditional Japanese ceremony on new year's eve. If you get interested in it, please try from the Android Market.

2011-11-23

Drawable#getTransparentRegion on Android (in case of BitmapDrawable)

Drawable#getTransparentRegion is not implemented at all in Android SDK. So we have to override and implement all by my self.

Here is an altenative answer with overriding Button class to avoid firing onClick method when tap transparent regions of a background image.

Strategy Overview


The code of TransparentImageButton


class TransparentImageButton extends Button{

 private View mCovering;

 public void setCoveringView(View cListener){
  mCovering = cListener;
 }

 /**
  * - Call onClick indirectly(super.onTouchEvent()->(in super class) performClick())
  * - In some cases, this may throw StackOverflowException.
  */
 @Override
 public boolean onTouchEvent(MotionEvent cEvent){
  switch(cEvent.getAction()){
   case MotionEvent.ACTION_DOWN:{
    // obtain the current background drawable
    Drawable cCurrentDrawable = super.getBackground().getCurrent();
    if(cCurrentDrawable instanceof BitmapDrawable){
     
     Bitmap cBmp = null;
     
     if(cCurrentDrawable instanceof BitmapDrawable){
      // cast the BitmapDrawable data into cBmp
      cBmp = ((BitmapDrawable) cCurrentDrawable).getBitmap();
     }

     // check whether the dot in drawable at the touched point is transparent or not
     if(null != cBmp && cBmp.getPixel((int)cEvent.getX(), (int)cEvent.getY()) != 0){
      // if not
      mIsPreviousTarget = true;
      return super.onTouchEvent(cEvent);
     }else{
      // if transparent
      mIsPreviousTarget = false;
      if(null != mCovering){
       return mCovering.onTouchEvent(cEvent);
      }
     }
    }
    break;
   }
   default:
    if(mIsPreviousTarget){
     super.onTouchEvent(cEvent);
    }else{
     if(null != mCovering){
      return mCovering.onTouchEvent(cEvent);
     }
    }
    break;
  }
  return false;
 }
 private boolean mIsPreviousTarget = false;

}

2011-09-24

First release of ‘Stand by The Trans-Siberian Railway (Trial Run)’

Solving the headaches posted here before, today I released an android app ‘Stand by The Trans-Siberian Railway (Trial Run)’. It aims that you can feel as if you are standing by the train track.

This app is the first using 3D system (OpenGL) program for me, so some problems are still left unsolved. If you find any inconvinience, please let me know. I will fix them as best as I can.

Have big worlds in the small screen!
Stand by The Transsib Railway - Android Market
https://market.android.com/details?id=jp.ideadepot.sbtsr.tr

The following screen is what it was 8 months ago.

2011-07-16

another flipped normals problem

Despite normals are shown faced outside correctly in 3D view, sometimes specific normals are exported flip. This nuisance occurs in some objects.

The problem could be fix if you try this.
1. Select the object in 3D view.
2. Object > Clear/Apply > Apply Scale/Rotation to ObData (in Object Mode).
3. With Ctrl + N, fix normals again.

These kind of situations are happen when I rotate, scale, transform an object a lot.

2011-07-10

fix exported vertex normals (on Blender 2.49)

While surface normals show vertical to face correctly in 3D view, the blender .obj exporter sometimes uses another normal data. The normal data seem to not surface normals but vertex normals.

To fix them, in 3D view select the face exported with unwilling normal data and run command Mesh > Faces > Set solid. After setting faces solid, the exporter would not use vertex normals.

2011-04-30

an attempt to accelerate processing of vertices

I got a wonderful idea on OpenGL with Java.

To render real objects with OpenGL, it's necessary to process a great amount of vertices or normals. So I would like skip processing, like reading from external files and generate arrays with so much elements dynamically, on running.

I found that it is possible. The concept is following using Java static variables.
a class defining vertices data:
public class ComplexObject {
 public static FloatBuffer vertexBuffer;
 static{
  ByteBuffer vbb = ByteBuffer.allocateDirect(74 * 3 * 4);
  vbb.order(ByteOrder.nativeOrder());
  vertexBuffer = vbb.asFloatBuffer();

  vertexBuffer.put(new float[]{
    0.53f, 0.3f, 3.55f,
    /* definitions of vertices go on */
  });
  vertexBuffer.position(0);
 }
}
To call the defined data:
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, ComplexObject.vertexBuffer);

What I did next is scratched a Java program to convert Wavefront .obj files into Java code. This worked fine, and generated codes so easily.

It is when I compile one of generated so long Java code. I encountered a problem that Java compiler alerts following:
The code for the static initializer is exceeding the 65535 bytes limit

In Java, many part of source code elements is limited to 65536 bytes:
http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html

It's been hard. To do next is implementing split method into converter or look for another solution.