1
Support / Re: How to Draw a circle?
« on: February 20, 2012, 03:49:06 pm »
Thanks a lot. I will try it.
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.
skyBox = new SkyBox(10);
world = skyBox.getWorld();
world.setAmbientLight(255, 255, 255);
plane = Primitives.getPlane(10, 2);
plane.strip();
plane.build();
world.addObject(plane );
// 获得相机
cam = world.getCamera();
// 设置相机的位置,在中心的位置
cam.setPosition(plane.getTransformedCenter());
cam.lookAt(new SimpleVector(0, 0, -1));
What android device/phone are you using? (please don't say the Android Emulator :p)
Have a read of this article: http://blog.javia.org/how-to-work-around-androids-24-mb-memory-limit/
I don't know how accurate that article is, but it mentions that you can get around the 24MB memory limit by using OpenGL textures, apparently textures are not limited to 24MB.
Also, what is your android:minSdkVersion value in the AndroidManifest.xml file? Increasing it to say "9" (gingerbread) may help relieve limitations.
Each type/model of Graphics Chip (GPU) has it's own maximum texture size, so you should check the size before creating large textures.
To query the texture size, call glGetIntegerv() in your main Activity's GLSurfaceView.Renderer class. You need a pointer to GL10 so you could place it in onSurfaceCreated().Code: [Select]public void onSurfaceCreated(GL10 gl, EGLConfig config) {
// Do nothing special.
int[] maxTextureSize = new int[1];
gl.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxTextureSize, 0);
Log.v("Log", "Max texture size = " + maxTextureSize[0]);
}
Bitmap bitmap = BitmapHelper.rescale(BitmapFactory
.decodeFile("/sdcard/jpct/hd.jpg"), 1024, 1024);
// Bitmap bitmap = BitmapFactory.decodeFile("/sdcard/jpct/hd.jpg");
Texture texture = new Texture(bitmap);
bitmap.recycle();
TextureManager.getInstance().addTexture("texture", texture);
and what you have in AppConfig.screenX?
you compare Object and Object3D...
...
judgePicking((Object3D)res[1]);
...
public void judgePicking(Object3D object){...}
try {
cube = Loader.load3DS(
new FileInputStream("/sdcard/jpct/sphere.3ds"), 1);
Loader.clearCache();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cube[0].setTexture("texture");
cube[0].strip();
cube[0].build();
world.addObject(cube[0]);
cube[1].setTexture("mark");
cube[1].strip();
cube[1].build();
world.addObject(cube[1]);
cube[1].setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
SimpleVector dir=Interact2D.reproject2D3DWS(world.getCamera(), fb, (int)AppConfig.screenX, (int)AppConfig.screenY ).normalize();;
Object[] res = world.calcMinDistanceAndObject3D(world.getCamera().getPosition(), dir, 10000 /*or whatever*/);
judgePicking(res[1]);
public void judgePicking(Object object)
{
if(object.equal(cube[1]))
{
Log.i("Path", "Picking");
}
else {
Log.i("Path", "NULL");
}
}
Remove that line. You shouldn't create texture coordinates on objects that already have some:Code: [Select]cube.calcTextureWrapSpherical();
ERROR/AndroidRuntime(13590): java.lang.RuntimeException: [ 1312968646623 ] - ERROR: A texture with the name 'texture' has been declared twice!
Objects genearted by Primitives have no proper uv-mapping. If you want that, you have to load a "real" model. For a sphere, you might want to try this one: http://www.jpct.net/download/misc/terra.asc
try {
cube = Loader.loadASC(new FileInputStream("/sdcard/terra.asc"), 4, true);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cube.calcTextureWrapSpherical();
cube.strip();
cube.build();