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
glsurface?

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   
 http://developer.android.com/reference/android/opengl/GLU.html 



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.

-Kevin

--


Sponsored Links


Want to start building 3d games, pointers?

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


 i,

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/
android/opengl/GLU.html#gluUnProject(float,%20float,%20float,
%20float[],%20int,%20float[],%20int,%20int[],%20int,%20float[],
%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
http://www.rbgrn.net/content/54-getting-started-android-game-development.
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
http://www.badlogicgames.com
and http://code.google.com/p/libgdx/.

Hth,
Mario

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


 onnyek,

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:
http://www.rbgrn.net/content/313-light-racer-3d-days-1-2-learning-opengl-es

Animations...
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. is it ok to use key store for release as the key store for debugging android application?

ladies and gentlemen,

is it possible and ok to reconfigure eclipse ide to use the key store
for formal releasing app as the key store for debugging the app?

i am asking this because i find it very very tedious to switch between
signing my app using release and debug keys, and between change the
map keys in my app source code. what a ridiculous step to have to do
this for developing/releasing an android application!!!

please advise. thanks!
--~--~---------~--~----~------------~-------~--~----~

2. Unable to run the application even once.

Hello, when I am trying to run the application for the first time, it
is giving error in console as:

[2009-08-25 12:47:24 - temp] ------------------------------
[2009-08-25 12:47:24 - temp] Android Launch!
[2009-08-25 12:47:24 - temp] adb is running normally.
[2009-08-25 12:47:24 - temp] Launching: info.temp.temp
[2009-08-25 12:47:24 - temp] Automatic Target Mode: launching new
emulator.
[2009-08-25 12:47:24 - temp] Launching a new emulator.
[2009-08-25 12:47:24 - Emulator] invalid command-line parameter:
SDAndroid
[2009-08-25 12:47:24 - Emulator] Android Emulator usage: emulator
[options] [-qemu args]
.
.
.
.
.
[2009-08-25 12:47:24 - Emulator]      -help-keyset-file       key
bindings configuration file
[2009-08-25 12:47:24 - Emulator]      -help-all               prints
all help content
[2009-08-25 12:47:24 - Emulator]


I tried clearing windows/preferences/Android/Launch/Default Emulator
Option textbox, but no luck. Earlier 'SDAndroid' was written in this
box.

pls help.........is some setting to do?

thanks
Nitin
--~--~---------~--~----~------------~-------~--~----~

3. Detect "running in" Android and access to Command Line parameters

4. Placement of camera preview

5. resizable framelayouts possible?

6. Resuming activity occurs WindowManager$BadTokenException

7. Auto Reply from David Kang of Crucialtec