画布像素为opengles坐标

时间:2013-06-01 16:01:18

标签: android opengl-es

我在找到屏幕的opengles 3d坐标时遇到了问题。我搜索了很多,但我没有得到任何确切的解决方案。我可以使用(event.getX()和event.getY())找到屏幕的触摸像素。但我想要屏幕的3d协调。我按照rajawali(https://github.com/MasDennis/Rajawali)库在opengl中制作livewallpaper。

这是我放置那条五颜六色的鱼的代码,我只是把我用来画彩色鱼的代码: -

 final Bitmap generatedBitmap2 = Bitmap.createBitmap(128, 128,Bitmap.Config.ARGB_8888);
 Bitmap colorful_fish = BitmapFactory.decodeResource(mContext.getResources(),R.drawable.colorful_fish);

// Create a canvas to do the drawing
final Canvas canvas2 = new Canvas(generatedBitmap2);
//canvas.drawColor(Color.TRANSPARENT);
canvas2.drawBitmap(colorful_fish, 0, 0, null);
 final SimpleMaterial simpleMaterial2 = new SimpleMaterial();
 simpleMaterial2.addTexture(mTextureManager.addTexture(generatedBitmap2));
 largeCanvasPlane2 = new Plane(1, 1, 1, 1);
 largeCanvasPlane2.setTransparent(true);
 largeCanvasPlane2.setScale(.2f);
 **largeCanvasPlane2.setPosition(.2f, -.5f,0f);**
 largeCanvasPlane2.setMaterial(simpleMaterial2);
 addChild(largeCanvasPlane2);

因为我在触摸时敬酒像素值,但我需要3d坐标。

@Override
public void onTouchEvent(MotionEvent event) {
Toast.makeText(getContext(), ""+event.getX()+"   "+event.getY(),Toast.LENGTH_SHORT).show();
  super.onTouchEvent(event);
}

enter image description here

0 个答案:

没有答案