OpenGL animation - opengl

If I have a human body 3d model, that I want to animate walking, what is the best way to achieve this? Here are the possible ways I see this being implemented:
Create several models with the legs in different positions and then interpolate between these models.
Load the model into openGL, and somehow figure which vertices correspond to the legs and perform the appropriate transformations.
Implement a skeleton or armature (similar to this: blender animation wiki).

Technique that you described in the first option is called morph target animation and often used for some detailes of animation like facial animation or maybe opening and closing of hands.
Second option is procedural or physical animation which works something like robotics where you give the body of your character some velocity to move forward and calculate what legs need to do for it to avoid falling. But you wouldn't do it directly on vertices, but on skeleton. See next one.
Third option is skeletal animation which animates skeleton and the vertices follow it by the set of rules. Attaching vertices to skeleton is called skinning.
I suggest that, after getting hang of opengl stuff (viewing and positioning models in space, camera, etc), you start with skeletal animation.
You will need a rigged and animated model for your 3d app of choice. Then you can write an exporter to your custom format or choose a format that you want to read from your app. That file format should contain description of the model, skeleton, skinning and key frames. Than you read and use that data from your code to build the mesh, skeleton and animate over key frames.

If I were you, I'd download Blender from http://www.blender.org and work through some animation tutorials. For example, this one:
http://wiki.blender.org/index.php/Doc:Tutorials/Animation/BSoD/Character_Animation
Having done that, you can then export your model and animations using e.g. the Ogre exporter. I think this is the latest version, but check to make sure:
http://www.ogre3d.org/tikiwiki/Blender+Exporter&structure=Tools
From there, you just need to write the C++ code to load everything in, interpolate between keyframes, etc. I have code I can show you for this if you're interested.

Related

way to have 3d animated/rigged character in Opengl

If I want a 3D animated/rigged character in OpenGL game how i would have it in OpenGL?If i make a animated/rigged character in 3Ds max is it possible to have that character in OpenGl?would be helpful if someone gives a proper way or a tutorial link to export animated model from 3d software to open GL
OpenGL is a very simple 3D framework which only offers the bare bones. OpenGL can display triangles and fill them with color and that's about it. It comes with some helper functions to manipulate point clouds but it's really very basic.
Animation and rigging are way beyond what it can do. What you need is a framework which supports animation and rigging which then uses OpenGL to display the result.
Since you don't specify any requirements, it's hard to say which one would be good for you. Blender is probably a good place to start. It's game engine runs on many platforms, supports OpenGL, animation and rigging.

3D model manipulation for a Desktop Augmented Reality application

I'm working on an Augmented Reality project that uses multiple markers to get positions for 3D models that I'm planning to overlay. (I'm doing this from scratch using OpenCV and I'm not using ARToolkit or any other off the shelf marker detection libraries).
Environment: Visual C++ 2008, Windows 7, Core2Duo 1GB ram, OpenCV 2.3
I want the 3D models to be manipulated by user so it will turn out to a sort of simulation.
For this I'm planning to use OpenGL. What are your suggestions, recommendations? Can the simulation part be done by using OpenGL itself or will i need to use something like OpenSceneGraph/ODE/Unity 3D/Ogre 3D?
This is for an academic project so better if I can produce more self-coded system rather than using off-the-shelf products.
it would seem that OpenGL is pretty enough for your needs (drawing a model with a specific colour and size).
If you're new to OpenGL, and you are not going to be using it for your future projects, it might be easier to use the old fixed-function pipeline, which already has the lighting and color system ready and doesn't require you to learn how to write shaders.
For your project, you will need a texture where you would copy the image from camera using glTexSubImage2D() which you would in turn draw to background (or you can use glDrawPixels() in case you don't require any scaling). After that, you need to have your model, complete with normals for lighting. Models can be eg. exported from Blender or 3DS Max to ascii format, which is pretty easy to parse. Then you can draw the model. Colors can be changed using glColor3f() before drawing the model (make sure you don't specify different color while drawing the model). Positioning of the models is done using matrices. The old OpenGL have some handy and easy-to-use functions for rotating and translating objects. There are also functions for scaling the objects (changing size), so that is covered pretty easy. All you need is to figure out camera position, relative to the marker (which i believe is implemented in OpenCV).
If you were to use the forward-compatible OpenGL, you would need to set up vertex buffer objects to contain model data and write vertex and fragment shaders to shade and display your model. That's kinda more work for which you get extended flexibility. But you can use shaders in the old OpenGL as well, if you decide you need them (eg. for some special effects).
Learning how to use a scenegraph or an engine (ogre) can take some time, i would not recommend it for your task.

Idea about how to model a building using OpenGL/GLUT?

I'm new to graphics, and I have to make a model of a building for an assignment using only GLUT or OpenGL.
Basically the school building's model( only the exterior portion) is to be made, and I have no clue where to start. Upto now I have drawn polygons, other shapes using GLUT, nothing in which there are multiple shapes. All the drawing upto now is using lines, or points, or polygons and mathematics.
Could you please give me an idea of how to go about it?
Update: I just want to know what steps I can follow to get it done. Some reference links would be awesome!
You could use modeling programs to create your model, and then use tools such as COLLADA to get your model into OpenGL.
The problem with hand-coding a complex object like that is that it takes a great number of lines of code just to define the vertices of the object.
People usually use 3D modeler software to build complex 3D objects, like Maya, 3DSMax or Blender and then export them in a format to be read into your OpenGL application.
Think about what you want your building to look like, and think about what kind of triangles you need to render in order to make that. You can either draw the entire thing in some sort of modelling software, and then import it into OpenGL, or you can come up with the triangles/textures yourself and do it by hand in OpenGL.
The exterior of the building will probably have a similar texture on the whole thing (brick, etc), and then there will be windows, doors, and a roof. Maybe some sort of sign that says "School Building". Take this all into account, what exactly you want your building to look like, and then think about what textures you will need to draw these things.
For example, say you're doing a brick building that is in the shape of a box, with a door and a few windows. I'd use one texture for the brick, and first draw an entire wall of brick. Then, I'd use a grey/blue looking texture for the window, and draw it over the brick wall. Then I'd do the same (different texture) for the door.
Just think about the design, and then just try things out - experiment. Good luck!
I once had a simillar homework. I did it by creating the models with Google SketchUp, then export the models to .3ds file and use my program to render it.
I choose Google SketchUp because it's the easiest to use among those tool I tried. Plus, they had a discount for students. You could also use Blender, which is free but take too much time to learn IMHO. 3dsMax is too expensive to pay for a homework.
To load the model into my program, I used Assimp library.

Can Cocos2D handle these graphic requirements?

I'm wanting to build a game with some simple effects.
I want to add the warping effect that you see in games like geometry wars and geodefence. I know how to implement this effect in OpenGL ES. Would I be able to add this to a Cocos2D created app?
I want to have a 3D model that only moves on a 2D plane. It may rotate. First, can I add OpenGL shading to the model? Second, can I have Box2D physics applied to it like it was a 2D sprite?
That's about it. Those are the main functionality I'm hoping I can add to a Cocos2D application and am trying to figure out if I can before I spend a lot of time learning how to use the game engine.
1) Yes, you can intermix Cocos2D and OpenGL ES together - you can override the CCNode's "draw" method and do just about anything you'd like in there (such as rotating, scaling, etc in OpenGL with the texture).
2) You can add the model, and you can shade the model - yes. If you create the body fixtures for the model from Box2D, but treat the Model as if it were a '2d sprite' (has set width/height) - yes, you can use Box2D - but understand that it will only react within the 2D Physics World, and won't have any depth applied to it.
It should be noted though, that though these are possible, you will still need to implement the code to do so on your own.

Best way to render hand-drawn figures

I guess I'll illustrate with an example:
In this game you are able to draw 2D shapes using the mouse and what you draw is rendered to the screen in real-time. I want to know what the best ways are to render this type of drawing using hardware acceleration (OpenGL). I had two ideas:
Create a screen-size texture when drawing is started, update this when drawing, and blit this to the screen
Create a series of line segments to represent the drawing, and render these using either lines or thin polygons
Are there any other ideas? Which of these methods is likely to be best/most efficient/easiest? Any suggestions are welcome.
I love crayon physics (music gets me every time). Great game!
But back to the point... He has created brush sprites that follow your mouse position. He's created a few brushes that account for a little variation. Once the mouse goes down, I imagine he is adding these sprites to a data structure and sending that structure through his drawing and collision functions to loop through. Thus popping out the real-time effect. He is using Simple DirectMedia Layer library, which I give two thumbs up.
I'm pretty sure the second idea is the way to go.
First option if the player draws pure freehand (rather than lines), and what they draw doesn't need to be animated.
Second option if it is animated or is primarily lines. If you do choose this, it seems like you'd need to draw thin polygons rather than regular lines to get any kind of interesting look (as in the crayon example).