I am using AndEngine GLES2 anchor center. I am trying to create a simple Polygon without using any physics engine (because i don't need physics). However, I can't find how to do this. I did find some extensions for GLES2 (https://github.com/recastrodiaz/AndEngine) but these are not supported by the anchor center branch.
This seems like a very basic thing that should be possible. Anybody that can tell me how to draw a simple polygon in AndEngine?
I decided it was a better idea to just create a rectangle (for registering the touch events) and just add a sprite (which was a polygon) to this rectangle. It did not provide me any benefit by creating a touch area that was exactly the size and shape of the sprite, hence this method is the right solution for me. This would be a different story if I used physics, but I am not.
Related
I have a challenge where I have to implement a sample apps on Android. This app allows user draw some shapes on the screen (by finger) and then optimize it to vertex based shapes. I am thinking about Opencv but I don't know what function/feature can help me detect a shape and optimize it. I need some hints or recommendations.
Update: User can draw any type of shapes such as: Circle, ellipse, rectangle, line, curve, polygon, ... So I think it should have an general algorithm for all kind of shapes.
Thanks.
I m working on canvas. Here I just want to draw some geometric figures on canvas which may be resized according to the touch_move positions. By figures , I just meant triangle,rectangle,circle and some polygons. Is there a way to achieve this? . I haven't seen such apps which can draw these figures over canvas. So this seems to be complicated.. Thanks in advance
See this link.
If your application does not require a significant amount of processing or frame-rate speed (perhaps for a chess game, a snake game, or another slowly-animated application), then you should consider creating a custom View component and drawing with a Canvas in View.onDraw(). The most convenient aspect of doing so is that the Android framework will provide you with a pre-defined Canvas to which you will place your drawing calls.
I'm sure you can find some open-sourced out-of-the-box solutions for this if you tried a little.
If you actually want to learn something you should read the tutorials of per example;
-Custom Views
-OpenGL
After doing the tutorials, you'll have 2 ways to draw basic shapes, a triangle and a circle I believe, already done.
I'm looking to map an ImageView drawing rect to a quadrilateral.
I was hoping I could do this by overriding ViewGroup.getChildStaticTransformation (View child, Transformation t) and messing around with the Matrix with and without a Camera, but its not as simple as I would like.
I want be able to take a bitmap and project it onto a 3d plane / surface.
I thought I had found a nice and easy solution with Matrix.setRectToRect(...) but not quite there. As RectF only allows the edges to be specified rather than the corners I cannot use to map to a trapezium. I would like to just be able to specify my destination shape rather than mess around with 3D animation classes or manually rotating a Camera.
I know i need to brush up on my Linear Algebra but I'm hoping someone can give me some pointers :)
Thanks!
EDIT: looking around I see I want to use a Projective Transformation
EDIT: I'm going to test out this solution
Doh, its Matrix.setPolyToPoly() that i was looking for! It was there the whole time, since API level 1 (thank god!)
I have a need to define a polygon that would be the "legal" area, and allow a user to move a rectangle around within that polygon, preventing them from moving the rectangle anywhere where its points venture outside the polygon.
The polygon is a fixed shape, so, I was thinking it may be easiest to import a PNG of that shape and pull the points in that way, somehow? But I'm still at a loss as to the math involved in checking the coordinates of the rectangle as the user drags it, and testing at what point they have moved the shape to the edge of the bounding polygon.
Unfortunately the bounding polygon is a fairly complex shape. I'm hoping someone can point me at a tutorial that shows what the best way to run such a collision detection is.
Metanet's excellent collision detection tutorial has a good section on how to do swept collision with axis-aligned bounding boxes (AABB) and arbitrary "walls."
If your polygon is concave, you'll probably find it easiest to first decompose it into multiple convex polygons, which will simplify the available collision detection algorithms.
If you only looking to check the corners of the rectangle, you can do a "inside" test for each of them.
http://en.wikipedia.org/wiki/Point_in_polygon
And if you also want to make sure that no pointy part of the polygon "punctures" your rectangle you could do a test for each of the 4 lines in the rectangle against all the lines in the polygon to see if they are intersecting.
http://en.wikipedia.org/wiki/Line-line_intersection
I have a 3D cube created using GL_TRIANGLE_STRIP.Is it possible to draw points(using GL_POINTS) or a triangle (using GL_TRIANGLE) on/inside my 3D Cube?How could that be achieved?
If you want to draw something directly of the face of another object (by using the exact same vertex coordinates), you will need to use glPolygonOffset to prevent stitching. There is a chapter in the Red Book that explains it.
If by inside you mean to draw something in the volume of the cube, than there is nothing stopping you. You just need to get the alpha values and blending right to actually see through the cube. Look for some generic tutorial on transparency in OpenGL.
But maybe I'm horribly mistaken and what you are looking for a textures.
If I understand you correctly you could just generate the appropriate texture with the points and apply it to the cube.