From a 3D modeler to an iPhone app - what are best practices? - iphone

I am quite new in 3D programming on iPhone and I would like
to ask for hints about organizing a work between designers
and programmers on that platform. Most of all: what kind of
tools, libraries or plugins cooperate the best on both
sides.
Although I consider the question as looking for general
best-practices advice I would like to find a solution for
my current situation which I describe further, too.
I've already done some research and found following libraries:
SIO2
Khronos OpenGL ES 1.x SDK for PowerVR MBX
Unity3D
Oolong Game Engine
I've checked modellers or plugins to them giving output formats
readable by those tools:
obj2opengl Wavefront OBJ to plain header file converter
Blender with SIO2 exporter
iphonewavefrontloader
Cheetah3D
PVRGeoPOD for 3DS / Maya
Unfortunately I still have no clear vision how to combine
any of that tools to get a desinger's work in an application.
I look for a way of getting it in the most possible complete way:
models, lights, scenes, textures, maybe some simple animations
(but rather no game-like physics), but I still got nothing.
And here comes my situation: I would like to find right way to
present few (but quite complicated) models from a single scene.
The designers mostly use 3DS Max 9, sometimes 10 (which partly
prevents using PVRGeoPOD) and are rather reluctant to switch to
something else but if there's no other choice I suppose it would
be possible.
The basic rule I've already found in some places "use Wavefront
OBJ" not always works. I haven't got any acceptable results with
production files, actually. The only things worked fine were some
mere examples. Some of my models did imported incomplete, sometimes
exporters hung or generated enormous files not really useful on
an iPhone, sometimes enabling textures (with GL_TEXTURE_2D) just
crashed an app.
I know it might be a problem with too complicated models or my
mistakes coming from inexeperience but I am not able to find any
guidelines for that process to have streamlined cooperation with
designers.
I am even willing to write some things from scratch in pure
OpenGL-ES if it's necessary, but I would like to avoid what might
be avoided and get the most from the model files. The best would be
the effect I saw on some SIO2 tutorials: export, build & go. But
at that moment I've got only "import, wrong", "import, where are
textures?", "import, that almost looks fine, export, hang" and so
on...
Is it really so much frustrating or I am just missed something
obvious? Can anybody share his/her experience in that field and
tell what kind of software uses for "making things happen"?

Well I can't say I know the perfect way to do this but after some experimenting I did get something working doing the following:
created the model(s) in Blender, exported it to wavefront .obj format (TRIANGLE,normals,hq)
then used obj2opengl.pl script to convert the model to a header file(.h)
then added the header in the project and used it in GLGravity - which is a sample program from Apple and modified the drawView function
maybe that could be a starting point for you too, just to get something up and running?

Related

Has anyone had much success recently using the Cappuccino Framework?

I'm just creating my first project in Cappuccino without a lot of success. Looking for examples and documentation, there isn't a lot out there...
The differences from real Objective-C and the lack of libraries mean you cannot easily convert code directly from say a OS X desktop app. to Cappuccino.
As an experienced PHP, and RoR developer (besides the Java, VB, VC.....) I can't quite see the logic of abstracting/wrapping JavaScript in another language.
Any comments or suggestions for a more efficient framework?
If you have specific questions that can't be answered in the IRC channel (it just depends who's in there) you should post the question to the mailing list and someone will help you.
As for why you would want objective-j I'll point you to this blog post which contains several reasons why objj exists. http://cappuccino.org/discuss/2008/12/08/on-leaky-abstractions-and-objective-j/
I have converted several Objective-C classes nearly line for line into Cappuccino. Mostly it's a matter of changing NS to CP and changing pointers to non-pointers. What differences between Objective-C are you thinking about?
Indeed you could even take your existing XIB files from your Cocoa desktop app and convert them to Cappuccino using nib2cib. Here's how to work with Interface Builder using XCode 4: http://groups.google.com/group/objectivej/browse_thread/thread/786331dbcbc9c7b1.
I also recently started a project in Cappuccino and what I could say is: definitely it worth it. I'm used with javascript as well as (but less) cocoa (which helps). In short, the javascript is very fine, probably one of my favorite language because of it's flexibility. But it does lack of structure. For example there is no class in javascript and you have to trick with object inheritances, prototyping and so on. By using the Cappuccino framework at first you have all those very convenient facilities but also you do not reinvent the wheel each time. This is cross browser standardized so that you only have to focus on your code and not on the IE whims. As it is based on cocoa, cappuccino also comes with the MCV scheme in mind which again let you structure your project in an efficient way.
Ok you probably already know all this. What I could tell now about the learning curve is that I had to find the right tools to really get in. i.e.Installing cappuccino (sudo Starter/bootstrap.sh), creating a simple nib application (capp gen -t NibApplication YourApplication) then using xcodecapp-cocoa to listen, convert and open the project into Xcode what probably the hardest part of this learning curve to me…
Now if you are still not satisfied with cappuccino, I can only suggest to look at another framework like http://javascriptmvc.com/ , www.grooveshark.com used it to do their amazing webapp-site but I personally would never go back to html for building a web application. (conversely I would not use cappuccino for a webpage neither, "The cobbler should stick to his last")
I began writing cappuccino a couple of months ago and had a lot of difficulty when it came to setting up the proper development environment. I also had numerous problems writing working client server code that worked well.
I eventually broke through and started doing better with Cappuccino and then I found these video tutorials that would have helped so much earlier on. They did cost me $30 but I really wished I had watched these at the start because they help you get set up properly as a developer and get you started on the right learning curve.
I actually discovered these videos when using Cappuccinos IRC which has helped me a couple of times when I couldn't find an answer.
Info on the videos here: http://cappuccino.org/discuss/2011/10/19/cappuccino-training-course-ideveloper-tv/

iPhone - Using OpenGL to create apps - What is a good wrapper or low-level engine to use?

I'm working on a couple apps which require the use of OpenGLes 2.0. I made a prototype of one starting from a simple sample project. However, I wasn't very happy with the clutter that all of the OpenGL code caused. I think that all the clutter would cause issues if I kept extending the code.
So- Is there a good solution to working with OpenGL on a slightly higher level? I don't really need all the complexity and overhead of a game engine. I just am slightly frustrated I can't deal with OpenGL like this:
ShaderProgram shader(fragmentCode, vertexCode);
RenderBuffer renderBuffer(xResolution, yResolution);
You'll have to pardon the shameless self-promotion, but I've been working on just such a framework due to the exact frustrations you've been having. I grew so tired of the nonsense of having to properly initialize resources and then clean them up. Here is a sample from my XPG framework.
XPG::Texture2D tex("texture.jpg"); // automatically cleaned up
tex.bind(); // ready for use
I have built similar objects for things like vertex buffer objects (VBO). I am still working on it, but the OpenGL tools will certainly benefit you greatly. I have yet to see another framework make things this simple. If anyone knows of one, I would love to hear about it. The one I've been working on even works in Android. It should work in iOS, but I haven't tested it there yet. It does work on OSX though. :)
To see a high level demonstration, see the test module source code: interface and implementation.
I don't think the position somewhere between raw OpenGL and a complete engine would be effective. Suppose you have the ability to manage OpenGL objects like shaders, buffers, textures and others.
You will still need a loading logic to get the input data from somewhere. Engine has it.
You'll need tools to compose shaders in and test the scenes. Engine should have it.
You'll face hidden errors about incompatible vertex attributes - shaders - uniform parameters. Engine has to check the consistency and link those instances smoothly for you.
Hence my conclusion is: once you've decided to move forward from the raw GL, you'll eventually end up in an engine. Either in a long term if you do it yourself, or in a short term if you take an existent one.
More than that, I think the engine should provide you with an ability to create shader programs and render buffers in the way you want. And I wouldn't expect much overhead from these operations.

Collada geometry and animation file loading

I'm considering writing a Collada loader for geometry and animation. Could someone describe from a high level how this would be done? If it will take longer than a few weekends of time I may switch strategies so I'm trying to get a feel for what this involves. I tried to read the Collada spec for animation but I didn't understand once it started talking about different animation channels.
I'm not using any game engine. I'm interfacing directly with OpenGL.
I am just now learning Collada. It seems it is not impossible to get some parts up soon but to implement the entire capability set is quite a handful. There are a few libraries like OpenAsset Import Library, but for the iPhone that is somewhat heavy-weight and I haven't tested it. The code is probably portable enough that you could grab the Collada portion without too much trouble.
If you are going to parse it in yourself, I'd recommend this XML parser which I just read about from this question. It is very small, fast and works with iPhones and looks to be useful in other projects as well.

OpenGL ES and real world development

I'm trying to learn OpenGL ES quickly (I know, I know, but these are the pressures that have been thrusted upon me) and I have been read around a fair bit, which lots of success at rendering basic models, some basic lighting and 'some' texturing success too.
But this is CONSTANTLY the point at which all OpenGL ES tutorials end, they never say more of what a real life app may need. So I have a few questions that Im hoping arent too difficult.
How do people get 3d models from their favorite 3d modeling tool into the iPhone/iPad application? I have seen a couple of blog posts where people have written some python scripts for tools like Blender which create .h files that you can use, is this what people seem to do everytime? Or do the "big" tooling suites (3DS, Maya, etc...) have exporting features?
Say I have my model in a nice .h file, all the vertexes, texture points, etc.. are lined up, how to I make my model (say of a basic person) walk? Or to be more general, how do you animate "part" of a model (legs only, turn head, etc...)? Do they need to be a massive mash-up of many different tiny models, or can you pre-bake animations these days "into" models (somehow)
Truely great 3D games for the iPhone are (im sure) unbelievably complex, but how do people (game dev firms) seem to manage that designer/developer workflow? Surely not all the animations, textures, etc... are done programatically.
I hope these are not stupid questions, and in actual fact, my app that Im trying to investigate how to make is really quite simple, just a basic 3D model that I want to be able to pan/tilt around using touch. Has anyone ever done/seen anything like this that I might be able to read up on?
Thanks for any help you can give, I appreciate all types of response big or small :)
Cheers,
Mark
Trying to explain why the answer to this question always will be vague.
OpenGLES is very low level. Its all about pushing triangles to the screen and filling pixels and nothing else basicly.
What you need to create a game is, as you've realised, a lot of code for managing assets, loading objects and worlds, managing animations, textures, sound, maybe network, physics, etc.
These parts is the "game engine".
Development firms have their own preferences. Some buy their game engine, other like to develop their own. Most use some combination of bought tech, open source and inhouse built tech and tools. There are many engines on the market, and everyone have their own opinion on which is best...
Workflow and tools used vary a lot from large firms with strict roles and big budgets to small indie teams of a couple of guys and gals that do whatever is needed to get the game done :-)
For the hobbyist, and indie dev, there are several cheap and open source engines you can use of different maturity, and amount of documentation/support. Same there, you have to look around until you find one you like.
on top of the game engine, you write your game code that uses the game engine (and any other libraries you might need) to create whatever game it is you want to make.
something many people are surprised with when starting OpenGL development is that there's no such thing as a "OpenGL file format" for models, let alone animated ones. (DirectX for example comes with a .x file format supported right away). This is because OpenGL acts somewhat at a lower level. Of course, as tm1rbrt mentioned, there are plenty of libraries available. You can easily create your own file format though if you only need geometry. Things get more complex when you want to take also animation and shading into account. Take a look at Collada for that sort of things.
again, animation can be done in several ways. Characters are often animated with skeletal animation. Have a look at the cal3d library as a starting point for this.
you definitely want to spend some time creating a good pipeline for your content creation. Artist must have a set of tools to create their models and animations and to test them in the game engine. Artist must also be instructed about the limits of the engine, both in terms of polygons and of shading. Sometimes complex custom editors are coded to create levels, worlds, etc. in a way compatible with your specific needs.
Write or use a model loading library. Or use an existing graphics library; this will have routines to load models/textures already.
Animating models is done with bones in the 3d model editor. Graphics library will take care of moving the vertices etc for you.
No, artists create art and programmers create engines.
This is a link to my favourite graphics engine.
Hope that helps

Game programming - How to avoid reinventing the wheel [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed last month.
Improve this question
Summary:
Can I program a "thick
client" game in C without reinventing
wheels, or should I just bite the
bullet and use some library or SDK?
I'm a moderate C programmer and am not
afraid to work with pointers, data
structures, memory locations, etc. if
it will give me the control I need to
make a great "thick-client" game.
However, I'm thinking of eschewing
high-level languages & frameworks for
the sake of power and control, not
ease of use.
I'm interesting in tinkering with a 2D fighting/platforming game as a side project sometime. I'm primarily a Linux server-side programmer with experience in Python, Ruby and PHP. I know that there are excellent frameworks in some of these languages, like PyGame. I am also aware of the success people have had with stuff like Air and .NET... but I have some concerns:
Performance: Scripting languages are notoriously slow. If I'm making a real-time game, I want it to be as snappy as possible.
Huge binaries: Using frameworks like .NET or scripting languages like Ruby often result in big CLRs or libraries that you wouldn't otherwise need. The game I want to make will be small and simple--I don't want its CLR to be bigger than the game itself!
Extra stuff: Honestly, I just don't like the idea of inheriting some big game library's baggage if I can wrap my head around my own code better.
I'm asking this question because I know I'm very susceptible to Not Invented Here Syndrome. I always want to program it myself, and I'm sure it wastes a lot of time. However, this works out for me remarkably often--for example, instead of using Rails (a very big web project framework with an ORM and GUI toolkit baked in), I used an array of smaller Ruby tools like rack and sequel that fit together beautifully.
So, I turn to you, SO experts. Am I being naive? Here's how I see it:
Use C
Cons
Will probably make me hate programming
High risk of reinventing wheels
High risk of it taking so long that I lose interest
Pros
Tried & true - most A-list games are done in C (is this still true today?)
High level of control over memory management, speed, asset management, etc., which I trust myself to learn to handle
No cruft
Use framework or SDK
Cons
Risk of oversized deliverable
Dependent on original library authors for all facets of game development--what if there isn't a feature I want? I'll have to program it myself, which isn't bad, but partially defeats the purpose of using a high-level framework in the first place
High risk of performance issues
Pros
MUCH faster development time
Might be easier to maintain
No time wasted reinventing common paradigms
What else can I add to this list? Is it a pure judgment call, or can someone seal the deal for me? Book suggestions welcome.
I believe you are working under a fallacy.
There are several frameworks out there specifically for game programming --- written by people with much experience with the complication of game design, almost certainly more tha you do.
In other words, you have a "High risk of performance issues" if you DON'T use a framework.
My current thinking is:
If you want to learn to program, start making the game engine from the base elements upwards (even implementing basic data structures - lists, maps, etc). I've done this once, and while it was a learning experience, I made many mistakes, and I wouldn't do this a second time around. However for learning how to program as well as making something cool and seeing results I'd rate this highly.
If you want to make a proper game, use whatever libraries that you want and design all of the game infrastructure yourself. This is what I'm doing now, and I'm using all of the nice things like STL, ATL/WTL, Boost, SQLite, DirectX, etc. So far I've learnt a lot about the middle/game logic aspect of the code and design.
If you just want to make a game with artists and other people collaborating to create a finished product, use one of the existing engines (OGRE, Irrlicht, Nebula, Torque, etc) and just add in your game logic and art.
One final bit of wisdom I've learnt is that don't worry about the Not Invented Here syndrome. As I've come to realise that other libraries (such as STL, Boost, DirectX, etc) have an order of magnitude (or three) more man-hours of development time in them, far more than I could ever spend on that portion of the game/engine. Therefore the only reason to implement these things yourself is if you want to learn about them.
I would recomend you try pyglet.
It has good performance, as it utilizes opengl
Its a compact all-in-one library
It has no extra dependencies besides python
Do some tests, see if you can make it fast enough for you. Only if you prove to yourself that it's not move to a lower level. Although, I'm fairly confident that python + pyglet can handle it... at worst you'll have to write a few C extensions.
Today, I believe you are at a point where you can safely ignore the performance issue unless you're specifically trying to do something that pushes the limits. If your game is, say, no more complicated than Quake II, then you should choose tools and libraries that let you do the most for your time.
Why did I choose Quake II? Because running in a version compiled for .NET, it runs with a software renderer at a more than acceptable frame rate on a current machine. (If you like - compare MAME which emulates multiple processors and graphics hardware at acceptable rates)
You need to ask yourself if you are in this to build an engine or to build a game. If your purpose is to create a game, you should definitely look at an established gaming engine. For 2D game development, look at Torque Game Builder. It is a very powerful 2D gaming engine/SDK that will put you into production from day 1. They have plenty of tools that integrate with it, content packs, and you get the full source code if you want to make changes and/or learn how it works. It is also Mac OSX compatible and has Linux versions in the community.
If you are looking for something on the console side, they have that too.
I'm surprised nobody has mentioned XNA. Its a framework built around DirectX for doing managed DirectX programming while removing a lot of the fluff and verbosity of lower level DirectX programming.
Performance-wise, for most 2D and 3D game tasks, especially building something like a fighting game, this platform works very well. Its not as fast as if you were doing bare metal DirectX programming, but it gets you very close, and in a managed environment, no less.
Another cool benefit of XNA is that most of the code can be run on an Xbox 360 and can even be debugged over the network connection was the game runs on the Xbox. XNA games are now allowed to be approved by the Xbox Live team for distribution and sale on Xbox Live Arcade as well. So if you're looking to take the project to a commercial state, you might have am available means of distribution at your disposal.
Like all MS development tools, the documentation and support is first rate, and there is a large developer community with plenty of tutorials, existing projects, etc.
Do you want to be able to play your game on a console? Do you want to do it as a learning experience? Do you want the final product to be cross platform? Which libraries have you looked into so far?
For a 2d game I don't think performance will be a problem, I recommend going with something that will get you results on screen in the shortest amount of time. If you have a lot of experience doing Python then pyGame is a good choice.
If you plan on doing some 3d games in the future, I would recommend taking a look at Ogre (http://www.ogre3d.org). It's a cross platform 3d graphics engine that abstracts away the graphics APIs. However for a 2d project it's probably overkill.
The most common implementation language for A-list games today is C++, and a lot of games embed a scripting language (such as Python or Lua) for game event scripting.
The tools you'd use to write a game have a lot to do with your reasons for writing it, and with your requirements. This is no different from any other programming project, really. If it's a side project, and you're doing it on your own, then only you can assess how much time you have to spend on this and what your performance requirements are.
Generally speaking, today's PCs are fast enough to run 2D platformers written in scripting languages. Using a scripting language will allow you to prototype things faster and you'll have more time to tweak the gameplay. Again, this is no different than with any other project.
If you go with C++, and your reasons don't have to be more elaborate than "because I want to," I would suggest that you look at SDL for rendering and audio support. It will make things a little bit easier.
If you want to learn the underlying technologies (DirectX, or you want to write optimized blitters for some perverse reason) then by all means, use C++.
Having said all that, I would caution you against premature optimization. For a 2D game, you'll probably be better off going with Python and PyGame first. I'd be surprised if those tools will prove to be inadequate on modern PCs.
As to what people have said about C/C++/Python, I'm a game developer and my company encourages C. Not b/c C++ is bad, but because badly written C++ is poison for game development due to it's difficulty to read/debug compared to C. (C++ gives benefits when used properly, but let a junior guy make some mistakes with it and your time sink is huge)
As to the actual question:
If your purpose is to just get something working, use a library.
Otherwise, code it yourself for a very important reason: Practice
Practice in manipulating data structures. There WILL be times you need to manage your own data. Practice in debugging utility code.
Often libs do just what you want and are great, but sometimes YOUR specific use case is handled very badly by the lib and you will gain big benefits from writing you own. This is especially on consoles compared to PCs
(edit:) Regarding script and garbage collection: it will kill you on a console, on a recent game I had to rewrite major portions of the garbage collection on Unreal just to fill our needs in the editor portion. Even more had to be done in the actual game (not just by me) (to be fair though we were pushing beyond Unreal's original specs)
Scripting often good, but it is not an "I win" button. In general the gains disappear if you are pushing against the limits of your platform. I would use "percent of platforms CPU that I have to spare" as my evaluation function in deciding how appropriate script is
One consideration in favor of C/C++/obj-C is that you can mix and match various libraries for different areas of concern. In other words, you are not stuck with the implementation of a feature in a framework.
I use this approach in my games; using chipmunk for 2D physics, Lua as an embedded scripting language, and an openGL ES implementation from Apple. I write the glue to tie all of these together in a C language. The final product being the ability to define game objects, create instances of them, and handle events as they interact with each other in C functions exposed to Lua. This approach is used in many high performance games to much success.
If you don't already know C++, I would definitely recommend you go forward with a scripting language. Making a game from start to finish takes a lot of motivation, and forcing yourself to learn a new language at the same time is a good way to make things go slowly enough that you lose interest (although it IS a good way to learn a new language...).
Most scripting languages will be compiled to byte code anyway, so their biggest performance hit will be the garbage collection. I'm not experienced enough to give a definite description of how big a hit garbage collection would be, but I would be inclined to think that it shouldn't be too bad in a small game.
Also, if you use an existing scripting language library to make your game, most of the performance critical areas (like graphics) can be written in C++ anyway (hopefully by the game libraries). So 80% of the CPU might actually be spent in C++ code anyway, despite the fact that most of your project is written in, say Python.
I would say, ask yourself what you want more: To write a game from start to finish and learn about game development, or to learn a new language (C++). If you want to write a game, do it in a scripting language. If you want to learn a new language, do it in C++.
Yeah unless you just want to learn all of the details of the things that go into making a game, you definitely want to go with a game engine and just focus on building your game logic rather than the details of graphics, audio, resource management, etc.
Personally I like to recommend the Torque Game Builder (aka Torque 2D) from GarageGames. But you can probably find some free game engines out there that will suit your needs as well.
I'm pretty sure most modern games are done in C++, not C. (Every gaming company I ever interviewed with asked C++ questions.)
Why not use C++ and existing libraries for physics + collisions, sound, graphics engine etc. You still write the game, but the mundane stuff is taken care of.
There are alot of different solutions to the issue of abstracting and each deals with it in different ways.
My current project uses C#, DirectX 9, HLSL and SlimDX. Each of these offers a carefully calibrated level of abstraction. HLSL allows me to actually read the shader code I'm writing and SlimDX/C# allows me to ignore pointers, circular dependencies and handling unmanaged code.
That said, none of these technologies has any impact on the ease of developing my AI, lighting or physics! I still have to break out my textbooks in a way that I wouldn't with a higher-level framework.
Even using a framework like XNA, if most video games development concepts are foreign to you there's a hell of a lot still to take in and learn. XNA will allow you to neatly sidestep gimbal lock, but woe betide those who don't understand basic shading concepts. On the other hand, something like DarkBASIC won't solve your gimbal lock problem, but shading is mostly handled for you.
It's a sufficiently big field that your first engine will never be the one you actually use. If you write it yourself, you won't write it well enough. If you use third party libraries, there's certainly aspects that will annoy you and you'll want to replace.
As an idea, it might be worth taking various libraries/frameworks (definately make XNA one of your stops, even if you decide you don't want to use it, it's a great benchmark) and trying to build various prototypes. Perhaps a landscape (with a body of water) or a space physics demo.