Want to start building 3d games, pointers?

by Ronnyek » Tue, 16 Mar 2010 00:50:46 GMT

Sponsored Links
 Hi, I'd like to just start off by saying I've done a bit of research
into 3d development, and am confident in simple lets build some simple
3d objects, and render them... would be easy.

I also have a very long history writing software, understand how games
work internally etc. I understand 3d concepts, 3d space, shapes,
camera, lighting etc... but I do have a couple questions.  (and no I
dont expect anyone to hold my hand through it, more than happy to put
the work in)

1) Initially I wont need it, but how do you handle for touch
interactions with a given 3d object on screen? I've heard of doing
things like mapping screen vertices to objects and when you touch in x
region, you are touching x object. Is there an easier way?

2) I intend to take a 3d format and import into my app, and there is
plenty of documentation on the formats I intend to use, so I can write
an importer... but does android 2.1 support anything out of box?

3) For basic menus and screen overlays, are those typically drawn with
opengl stuff too? Or a diff sort of view layed over the top of

4) I don't know if I'd say I want to build a 3d engine for android,
but I definitely think writing some useful utilities and wrappers and
converters to simplify some of the most common bits, and perhaps
document my efforts in blog, might be helpful to others. These bits
I'd like to make opensource.. any recommendations on features you'd
all like to see? (or maybe this is reinventing the wheel)

I appreciate everyone's time,  I assure you I've done some research...
and want to help prevent future newbies from running up against the
same problems I am. (trying to build wrappers and helpers and
converters etc)


Want to start building 3d games, pointers?

by Kevin S. » Tue, 16 Mar 2010 01:55:43 GMT

 > 1) Initially I wont need it, but how do you handle for touch

Android is using OpenGL ES   See   http://www.khronos.org/opengles/ 

Sounds like what you are interested in is gluProject() and
gluUnProject()   see   

It's openGl ES, so you can draw Lines, Points and Triangles.
 AFAIK there is no built in calls for drawing higher level structures.
   For my app I wrote a parser which could take files exported from
Blender and generated Java source code which then calls
the OpenGL functions to draw the triangles.

In my app I used the standard Android menu and preference stuff.  It
seems to work ok.  I had to pause the rendering when the menu
comes up, or else it was not as responsive as it should be.



Sponsored Links

Want to start building 3d games, pointers?

by Mario Zechner » Tue, 16 Mar 2010 02:00:12 GMT


let me start by answering your questions:

1) What you refer to is usually called picking and involves a bit of
math. Your initial goal is to get a ray (defined by a starting point
and a unit length direction) from your touch coordinates. This can be
done via GLU.gluUnProject (http://developer.android.com/reference/
%20int)). With this ray you can now check wheter an object in your
world has been hit. Usually your objects will have something called a
bounding volume like a sphere or an axis aligned bounding box (nice
keywords for google). All you then have to implement is a ray/bounding
volume intersection test which tests the ray against all your objects'
bounding volumes. Among the objects that intersect with your ray the
one nearest to the ray's starting position will be you touched object.
Simple eh? :)

2) There's no support for any 3d formats in Android out of the box and
i guess that will stay this way for good reasons.

3) That's a matter of taste i guess. I myself use OpenGL for
everything. Others add standard GUI widgets on top of the
GLSurfaceView. The later is a bit easier while the former is more
flexible. Chose your poison.

4) That would be cool, maybe we can collaborate :)

Additionally i want to link to Robert's great introductionary text on
Android game programming you can find at
Make sure to also check out the other articles on his blog.
Furthermore i'm currently writting a small and hopefully easy to use
game programming library for cross plattform development myself. It's
called libgdx allows you to code up your games on the desktop with
standard Java emulating OpenGL ES via Jogl and seamlessly deploy them
to an Android device without changing a line of code. I'm currently
giving it the finishing touches, the only thing missing is the OpenGL
based GUI system i rewrote from scratch as well as the Audio classes.
If you want to collaborate just drop me a line, the more hands the
faster the lib grows. You can find info on the lib at
and http://code.google.com/p/libgdx/.


On 15 Mrz., 17:28, Ronnyek <wwe...@gmail.com> wrote:


Want to start building 3d games, pointers?

by Robert Green » Tue, 16 Mar 2010 04:04:45 GMT


There are a few methods of picking a 3D object from a 2D coordinate.
The ones I know of are (in order of popularity):
1) gluUnProject to get a ray, then use a collision detection
algorithm to check against your object bounds
2) Use the color/depth buffer
-- This involves a special little bit of work.
-- When a touch comes in, on the next draw, you render the pickable
objects without textures, lights, etc, each with a unique color. Keep
your Z-Buffer on and you will have colors that represent the objects
which are ordered front to back. You then check the framebuffer to
see which color is at the touch point and you will then know your
object. Erase and do your normal rendering after.
3) You can implement something like gluUnProject yourself if you
create your modelview matrix look-at in a separate matrix. It's not
as hard as it sounds. You can create your vector starting with 0,0,1
then translating based on the touch x,y and field of view, then
finally multiply it by that matrix and you've got it. I'd rather just
use unproject, though.

As far as loading models and 3D data...
The fact of the matter is that there are so many different file
formats, each with its own tradeoffs. If you want static geometry,
you can just write an OBJ loader. It's not very hard and I actually
posted code to my first one:

If you want animations, things get harder. You have to pick a tool to
use to make your animations, then you have to figure out if that tool
exports a format that you can find or write importing code for. Good
engines write their own importer/exporters for their own formats. Why
no universal format? Different formats allow for different features.
Since each game specializes in some way, it's hard to make it
universal. It gets worse - you can't just "import into opengl."
Opengl is great, but it deals with primitives. If you want to
animate, you need to understand some 3D geometry foundation because
you have to know how your animations really work, down to the vertex.

I ended up using Blender/MD2 as my tool and animation format. You'll
see all of this in our upcoming game next month. MD2 is nice because
it's very easy on the CPU if you write an interpolator in C and use
fixed point math for it. The loader took a few days to figure out but
there are docs online that go over the file format in detail. The
problem with it is that since it doesn't use bones, you can't combine
top/bottom animations and you can't just reskin. You also can't mount
weapons easily (though we did it with some nasty hacks).

As for levels.. I haven't found an optimal solution yet. We used
blender and manually partitioned out space into visible areas,
separated by visibility portals. I wrote a visibility portal
occlusion algorithm so that we only draw the areas that are currently
visible. We create a separate collision mesh which I load into an
octree (native code is a must for this stuff) and perform collision
tests on (also always in native code). The advantage to this is that
it uses off-the-shelf tools and formats. The downside is that since
we don't use a proper level editor, we don't get nice things like
built in entities, surface types, etc. We had to hack it all in.

How long did all of this take us to learn and do? I started learning
OpenGL ES last september and r

Other Threads

1. Even with Min SDK version, building app against 2.2 breaks 1.5?

Yeah that was what I tried before posting. I did that like 3 times.
The same APK works on 2.1 devices so it cannot be an inlining issue.

I am sorry I know it's a vague error. The drawable in question is just
a selector with dither equals true with 4 states inside of it. Nothing
complicated but maybe it helps somewhere.



2. Nexus One for developers

Does anyone know when will be possible to buy the Nexus One from the
market as a registered developer?


3. UPDATE & SOLD : WTTuker Guling : motodroid froyo dengan droid yg msh perawan

4. Android virus protectio

5. Apps using permission

6. Emulator, forcing portrait mode

7. TabView and other content in the same activity?