facial animation - opengl

I am developing a 3d facial animation application in java using opengl(jogl) i had done the animation with morph targets and now i am trying to do a parametrized facial animation .
I can't attach the vertex of the face with the appropriate parameter,for example i have the parameter eyebrow length ,how could i know wish are the vertex of the eyebrows (face features),please please could anybody help me i'm using obj file to read the face model and face gen to create it.
I appreciate your help .

For each morph target you assign each vertex a weight, how strong it is influenced by the respective morph target. There's no algorithmic way to do this, this must be done manually.
Lightwave OBJ file format may not be ideal for storing the geometry in this case, since it lacks support for storing such auxiliary data. You may extend the file format, however this will probably clash with programs expecting a "normal" OBJ.
I strongly suggest using a format that has been designed to support any number of additional attributes. You may want to look at OpenCTM.

Related

Simple 3D scene visualisation data format

My PhD project revoles around simulating the paths of photons through objects of different optical properties. My code has classes which create ccd images etc, but it would be much more useful to be able to create a simple rendering of the 3D objects and the paths the photons take through them.
I've written an opengl system for viewing such a scene, but it would be much better if I could use something much more lightweight where I could simply specify the vertices of an object, and then a photon path as a list of connected vertices.
Exporting all the data and then visualising it in another program isn't ideal, as things like mesh transformations need to be taken into account, and I'd rather avoid exporting several new mesh objects just to import them all into another program.
What I essentially need is to be able to create the three dimensional equivalent of a svg image. Does such a '3D scene' file format with a simple visualiser exist?
I write in C++ on MacOS, though I'd prefer to avoid using a visualisation library. I appreciate that what I'm asking for is rather niece and picky, but that's why I'm asking the internet as someone might have come across a similar need for such a tool.

Joining two meshes into one

Suppose I have two meshes stored in any sane format (e.g. wavefront .obj or collada .dae), and I want to combine them into one mesh programmatically. More precise, I have a landscape and an object as two meshes. I want to put object into landscape after performing transformation to it, so it gets on the right place, and export this as result model.
As far as I understood, in assimp there is something similar named SceneCombiner, yet it seems that this is internal structure and has no interface (even though here https://github.com/assimp/assimp/issues/584 the ticket concerning it is closed, I couldn't find out how to use it).
Maybe I should use CGAL or something like that? I don't have very much experience in CG libraries, so any advice will be really useful!
You can do that with CGAL. You would read two meshes, and the call copy_face_graph(), and then write the mesh back.

The best way to export 3d mesh animation in order to use it in OpenGL

Suppose that I have a 3d model with animation in, say, Blender. I need to export this model to some file and then use it in OpenGL app, i.e. without hardcoding animations, but reading them from file. What format is the best solution?
OpenGL doesn't support any format directly, but the classic OBJ file format lines up very well with drawing with vertex arrays. Basically, OBJ lists all vertices independently of the geometry. This way, several objects can share the same points. All kinds of groupings are also possible.
Also, it is one of the earliest formats to support a wide range of spline curves & surfaces, including Bezier, B-Splines & NURBS.
A basic decription can be found here:
http://en.wikipedia.org/wiki/Wavefront_.obj_file
The complete OBJ spec can be found here:
http://www.martinreddy.net/gfx/3d/OBJ.spec
It's not as modern as WebGL, but it's simple, human readable and widely supported.
What format is the best solution?
OpenGL doesn't care about file formats. So feel free to choose whatever suits your needs best. Due to the rise of WebGL I started dumping whole Blender scenes into collections of JSON formated files.

how to draw pool table pockets opengl c++

hey
i am creating a pool table simulator in opengl written in c++
i have the basic table drawn but now i need to add some pockets
i want the pockets to be a basic curve like a C shape
im not quite sure how to do this
i have experimented with trianglefan but iv had no luck
can anyone help please?
also i must add this is part of a university project therefore i will only be using the core opengl and c++....no other tools
thanks in advance
When I use OpenGL, I usually build the models in something like Blender.
Blender is free and allows export to WaveFront obj - an easy format to read in to your program. Or you can use the simple text WaveFront obj with a little scripted editing will produce a list of vertices that you can use in arrays for vertex buffer objects.
I couldn't imagine trying to build objects for a 3D scene using only discrete values and discrete math like (I think?) you're describing.
Do you have access to glu.lib?
http://en.wikipedia.org/wiki/OpenGL_Utility_Library
http://www.opengl.org/resources/faq/technical/glu.htm
That would easily make cylinders or NURBS curves for the pockets. Sample use of it is here: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=18
There is also lots of code from the "Graphics Gems" series available - you can dig through the early books for something suitable if GLU isn't an option.
http://www.graphicsgems.org/
Start with a cube and slice off the bottom corners. Refine as necessary.

Using Blender/SketchUp Models in OpenGL

I'm making a renderer using OpenGL. I have textured models in Blender / Sketchup (I can exchange between the two easily), and I'd like to be able to export those files into my renderer. My initial idea was to simply export the raw faces and render those triangles, but I'd like to easily slice my texture files into texture coordinates as well.
By that, I mean that my model faces get carved into triangles. You can see in this image (reproduced below) that my curve becomes 24 triangles. I would like to know what texture coordinates to use for each triangle.
Would a DAE file be the easiest way to do that? I've been reading the specs for the format and it looks easy enough. I think I could parse the XML and faithfully recreate the models in OpenGL. I'm wondering if there is an easier way (i.e. one that doesn't reinvent the wheel).
If you're comfortable with parsing the .dae-format, sure use it. However, if you're only interested in exporting textured triangle meshes I would consider using the .obj format which is much more simple to parse. From what I can tell both Sketchup and Blender can export this format.
If binary formats don't scare you, I'd suggest writing a Blender & Sketchup plug-in and exporting the geometry pre-baked into packed vertex arrays.
The beautiful thing about this method is that there's no parsing or type conversion in your app. Everything is ready to be sent to the GPU in simple contiguous memory copies. Great for static geometry.
A stripped down blender exporter looks something like this:
#!BPY
import bpy, struct
from Blender import *
self.fh = open("MyFileName", "w")
m = bpy.data.meshes["MyMeshName"]
faces = m.faces
for face in faces:
for (vertex, uv) in zip(face.verts, face.uv):
self.fh.write(struct.pack('<fff', *vertex.co)) # coords
self.fh.write(struct.pack('<fff', *vertex.no)) # normals
self.fh.write(struct.pack('<ff', uv.x, uv.y)) # uvs
self.fh.close()
If you wish to parse .dae files, i would suggest to look into Collada parsers.
.dae is actually the extension for Collada files, the latest effort from the Khronos group (maintainers of OpenGL) to have a single unified file format for 3D data exchange.
As for the existing parsers, here is what I've come across:
collada-dom, the reference implementation. As the name suggests, it is just an abstraction of the XML tree.
FCollada, a nicer abstraction. However, this project has been dead for almost two years, and, from what I've gathered, it is unlikely that we'll see any update in the future.
OpenCollada, a recent new effort. Haven't tried it, but there is an active community behind it.
That being said, if your only goal is loading a simple piece of geometry with vertices, normals and texture coordinates, going with the .obj file format might be a quicker way.
Any decent file format used by modeling programs (such as Blender or Sketchup) will include all information necessary to recreate the geometry you see. This should include the geometry type (e.g. triangle strips, individual triangles, etc), the vertices and normals for the geometry, the material properties used, and also the textures used along with the appropriate texture coordinates. If anything is lacking from a potential file format, choose another one.
If you think that parsing XML is simple, then I hope you're planning on using existing libraries to do this, such as expat, Xerces, or some other language specific implementation.
When considering import/export, first try to find an open source library that can handle the import for you and make the data available to your program in a reasonable format. If that's not available, and you must write your own importer, then try to find a simple ASCII (not XML-based) or binary format that fits your needs. PLY might be suitable. Only as a a last resort, would I recommend trying to implement an importer for an XML-based format.
There's also:
Lib3DS - http://www.lib3ds.org/
LibOBJ (won't let me post link)
You should take a look at:
http://sketchup.google.com/community/developers.html
The sketchup team provides a C++ COM server for free. Using this, you can get access to lots of information about a .skp file.
You should be able to use this COM server to write a .skp importer for your application.
You should try to get the .tlb file if you can. This will give you access to smart pointers, which will simplify your importer (COM client)
I used the version 6 SDK (which included the tlb file). The current version of the SDK does not appear to include this file.
Someone posted a solution (for the missing tlb file) on the developer forums:
http://groups.google.com/group/su-sdk-fileshare/topics