I am developing in android 2.1 framework.
According to Opengles's doc, we should call glEnableClientState(GL_VERTEX_ARRAY) to make glVertexPointer used by glDrawElements. But I didn't see that from my tutorial, could anybody tells my why, any clue?
My tutorial is:
I try to create a 3d application that display a simple cube, I found that whether I use
glEnableClientState(GL_VERTEX_ARRAY)
glDisableClientState(GL_VERTEX_ARRAY)
//glEnableClientState(GL_VERTEX_ARRAY)
It makes nothing different of result, a cube was displayed normally.
IMHO, if you'll use the several cubes, one with color array and another without color array, you'll need to disable (GL_COLOR_ARRAY) color array before drawing a cube without color array
Related
The sample project that is available with openCV SDK named "OpenCV Sample - color-blob-detection" identifies the area according to the color of the object you select. It then draws contours around that object. It is possible to extract/highlight that particular area? Since there may also be some other object in the background with the same color, however that is not my desired object.
I know this maybe tricky and involves lot of processing, but some guidance on this will help. How can this be achieved?
Note :-
The reason I am asking this, is later we want to model a temporary 3D object on the selected real time object. So differentiating it from the background objects is necessary.
You should use pointPolygonTest(). In the process() function you should add to mContours only one contour, the one that pointPolygonTest returns true, using the coordinates of the touch.
You will need to pass the coordinates to the process() method.
im new to this android things. And i have to develop an application that can help an autism to learn numbers. I have a few ideas and I've been trying to learn and implement the code. But it's failed. The question is how can i apply the motion code or sprite to draw a numbers or letter? For example like this, i wanna make the penguin move through the line and draw a number nine.
There is example from mybringback.com which is the image move to draw a rectangle. How can i implement it to draw a number? Im sorry if i asking too much, i just trying to get some ideas.
I think that you should first build an utility program, in order to create the "path vector".
What I mean by path vector is simply a vector of Points (where a point has x value, and y value). And your utility should let you draw whatever you want, with a simple pen. You should draw on surface and store points when mouse is down, and ignore points when mouse is up.
Then, in the main program, you will just have to read at the path of your number/letter.
I've tried to implement something like this for the Sugar OLPC platform, without serializing path into files : I was able to draw, and to view the animation. And I used the process I've just described you.
Hope it can help you.
P.S : I used the word mouse, but you guessed that I talk about finger ...
There are various ways to achieve animation effects. One approach that is quite versatile involves creating a custom View or SurfaceView in which you Override the onDraw method. Various tutorials can be found on this; the official Android discussion of it is here:
http://developer.android.com/guide/topics/graphics/2d-graphics.html#on-view
Your implementation will look something like this:
// Find elapsed time since previous draw
// Compute new position of drawable/bitmap along figure
// Draw bitmap in appropriate location
// Add line to buffer containing segments of curve drawn so far
// Render all segments in curve buffer
// Take some action to call for the rendering of the next frame (this may be done in another thread)
Obviously a simplification. For a very simplistic tutorial, see here:
http://www.techrepublic.com/blog/software-engineer/bouncing-a-ball-on-androids-canvas/1733/
Note that different implementations of this technique will require different levels of involvement by you; for example, if you use a SurfaceView, you are in charge of calling the onDraw method, whereas subclassing the normal View lets you leave Android in charge of redrawing (at the expense of limiting your ability to draw on a different thread). In this respect, Google remains your friend =]
I'd like to make an Android app that will display a drawing of lines and I'd like to make something beautiful (big challenge).
Basically the app will show a drawing based on x y coordinates. The result must be identical to another drawing in a web based app. For the web based app, we'll be using this library.
I know how to draw paths on a canvas in an Android app but I don't know how to apply a custom effect on it. I've noticed I could use a PathEffect with this method:
paint.setPathEffect(myEffect);
but I'm not sure how to create another effect than the available ones (ComposePathEffect, CornerPathEffect, DashPathEffect, DiscretePathEffect, PathDashPathEffect, SumPathEffect).
Any tips and help would be much appreciated!!
An option would be to look in the source code of these path effects and understand how do they work, what's the idea, and derive how you could make your own path effect.
I,m using min3d framework on my device to make some car game, so i created some simple car model and simple and its moving, but i want to create ''physics'' and i need the collision detection which isn't provided in min3d (i won't change framework because i have android 2.1 without possibility to upgrade) i want to create it by my self but the problem is that i don,t know how to check if the plane collides with anything what i want to do is:
-create simple flat rectangle (not cube) and i want to place it in front of ''car'' and check if something gets inside of this rectangle and something does i want the car to bounce of it in reversed direction (the problem isn't to bounce but: how to check if something gets through my rectangle)
I have some other problem too:/
When i enclose my ''game''(haha) with a LinearLayout in xml everythong is going fine till i use the command to set the text with the value of rotation of a car for example -then is force close:/ I'm doing it form my class from which i load my objects (i'm providing my classes too)
I was searching for tutorials on the web but none of them was tlaking about 3d collision and even if it was about 3d there was too much code that wasnt need and i was loast in it so i dont get anything
I ask you royal users from stackoverflow to provide me example for creating the rectangle(if needed, because i can laod model from .3ds and .obj)and check if something gets through it(intersects?) not for entire code but just for the method how to do that, and how to refrsh the value of a car, in layout without a crash
By the way: my ''game'' is using qwerty keyboard as input (i,o,p,l keys)
Wanted to post my class here but its to much of lines and was getting erros so grab it on free hosting site, its scanned by avast already on my pc, it contains my entire project with min3d too.
My sources ready to compile and run are(with min3d -which isn't mine):
http://odsiebie.pl/ax1v1p5tam8i/KRL044.7z.html
thanks in advice:)
an approach is to break it down to two dimensions (xy). imagine that your cars are 2D-Rectangles. in the moment you want to check collision, just check if any of the four corners of your "car" is within the rectangle of another car. might be not best practise but works for me.
instead of this you could use r-tree sqlite to check collision.
I have already implemented a cube which can rotate by gestures in Android OpenGL ES. Now I want to implement that when I click somewhere on the cube, it can tell which face has been touched and make some response.
I searched the Internet and find color picking a good way, here are some tutorials: http://www.lighthouse3d.com/opengl/picking/index.php?color1
But I still find it difficult for me.
How to assigned each face a different color?
How to read the pixel where the mouse was clicked from the back buffer?
Can anyone show me some more details? Thanks a lot!
If you don't mind, leave me an email address and I can send you the work I have done. Thanks :)
The first comment is that it's almost always faster to do this analytically — by casting a ray into the world. That comment aside...
You'd assign each face a different colour for picking just like for any other sort of rendering, whether by changing what you pass to glColorPointer (if using ES 1) or by switching to a single pixel, single coloured texture or by any other means. If you have lighting enabled, be sure to disable it.
You can use glReadPixels to read a colour back from a frame buffer. On a touch-screen device you probably want to grab, say, a 20x20 pixel area and pick whichever colour appears most often in it, or something like, that because fingers aren't very precise.