Graphics Question from a Novice

Started by
6 comments, last by JNT 12 years, 9 months ago
I've been programming for about a decade now, but have just recently made the step from 2D software rendering to 3D hardware accelerated graphics. My current project is still a 2D game, but done with a 3D engine (Ogre) to take advantage of GPUs and all the other beautiful effects that are impractical otherwise.

Since I am new to 3D graphics programming, a great deal of the common terminology and techniques are still unknown to me, despite extensive reading on the (vast) subject, so my question may seem naive and simple to all of you advanced individuals. Basically, what I'm hoping to do, is create a character editor in-game, so that users can draw their own characters to play with. I want it to be easy and intuitive to use, and hide the complex inner workings from the user, so that even a child could draw out a new character. Forcing the player to use an external program is very unappealing to me, since that will discourage many players from bothering at all.

So, what I'd like, is for the character editor to allow the player to draw the character outline, just as if they were using any normal image editor. For internal representation, I'd then like to convert their outline into a mesh of polygons dynamically. Ideally, this would be done in such a way that the polygon count can be altered based on the user's video settings in-game, to optimize performance.

I have a feeling that this is not only very possible, but probably somewhat common, only I haven't come across it yet in my readings, so I don't know what the proper term would be. Alright, now here are my questions:

What is this technique called?
How can I implement this, ideally with an existing library (that is free for commercial use, under LGPL, zlib, MIT, or whatever license (oh, and must be crossplatform) ) ?
What particulars should I be aware of, and what issues might I have implementing this?

Thanks to anyone who took the time to read this, and extra thanks to anyone who has an answer to any of the above questions.
Advertisement
[color=#1C2837][size=2]So, what I'd like, is for the character editor to allow the player to draw the character outline, just as if they were using any normal image editor. For internal representation, I'd then like to convert their outline into a mesh of polygons dynamically.[/quote]
Let's assume that you have a drawing of the front side of a character.

male_figure_drawing_front_view_01.jpg

It would take a pretty advanced algorithm to interpret this image as it is now. How do you handle what is part of a character and what isn't, such as that red line? If you remove needless elements, how will it affect the model? What do you do with a scribble?


The big problem is how you determine the topology of polygons with just an outline. You could probably get just a little more info to work with if you got a side view of a character, but then there comes the problem of where geometry that transitions between front and side views need to go. You could continue to add images to describe different perspectives of a character, but then you have to wonder if a child is willing to draw 8 or 9 images to model something.


I won't say the process is impossible, but you would certainly need to give the relevant software more to work with than just an outline. But, if you ask for anything more complicated such as a Normal Map, you ask for images no inexperienced (or sane) person would draw in an image editor.


I recommend that you take the approach of creating a base mesh on your own and allowing various attributes of said mesh to be changed by the player. Wrestling games take this to a serious extreme.

Huh.
I personally would rather say that this is not a common thing but rather a very advanced.
Let´s just say - if it were that easy to model a character, 3D-artists wouldn´t bother with Z-Brush & Co. anymore. ;-)
I think I have an idea though how this could be made possible more easily.
If I´ve understood you correctly, this is for a 2D game.
So question would be if you wanted threedimensional characters with a volumetric mesh, or if it would suffice to have a flat mesh that would only have the (2D) form of what the player draw.
In the latter case you could leave out all "different perspectives" stuff and just stick with your twodimensional projection.
You could then perhaps use a system where the player has to mark the different bodyparts of his character, perhaps by just filling them with a certain color after he has drawn the outlines in the same color.
So the computer would know that everything that is e.g. red is the characters head, everything blue is his arms, everything green is his neck, etc..
You could then go and let the computer sort out which were the biggest contiguous masses of a certain color, and use that respective masses as the bodyparts.
You probably would need to ask the player to clarify - say you would expect two big contiguous masses for the legs and someone painted the legs so that they would touch and would be read as only one mass, the player would have to clarify where this mass would have to be cut in half to get to the two masses that form the two legs.
And of course you would have to think about how to handle configurations like two heads, four arms, only one leg, etc..

But say you would have that sorted out and would have your algorithm to get to the point where the computer knows which part of the painting is what bodypart.
You could then go up (or down, or whatever) the picture, line by line or probably rather every 5 or 10 or 20 lines, and look for an intersection with the respective bodyparts outline. This intersection would mark the first vertex, the second intersection (hitting the second outline or leaving the inside of the bodypart respectively) would mark the second vertex.
This way you could then construct your mesh by connecting these vertices, although this in reality would be a lot more complicated then it is just sketching the idea. ;-)
This would leave you with a set of flat meshes that you could connect and animate, texture and light in the engine.
You could of course even just take the picture that the player drew as the texture of this mesh.
And you should even be able to construct a very simple volumetric mesh, or at least a protruding mesh without a backside, basically using kind of a heightfield - if you got your two vertices resembling the boundaries of a bodypart on that line on screen, than you could create new vertices between those two points (perhaps based on a cosine function or something like that), more points when near to the edge, less when nearing the mid of the bodypart, gradually moving outer points back on the z-axis.

This in practice could prove pretty tricky though.
Especially I´m thinking of the intersection-algorithm - when you got bodyparts that wouldn´t be aligned orthogonally to the axis that you use for your intersection test, you would get really bad results, so you would have to automatically adjust your reference-axis.
You probably should go look and learn more about triangulation (this could be a start: http://en.wikipedia.org/wiki/Delaunay_triangulation ), cause it could be real tricky to work out the details even for my suggested simple form above.
And of course, if you wanted to take the mesh to 3D as written above, this would result in only a rough approximation that probably wouldn´t even be acceptable at all.
I think that I forgot to clarify a rather important point in my design, which I think simplifies the problem. Characters will be constructed by separate limbs, each of which would be drawn individually, and then connected to each other via joints, to allow for easier animation. I imagine this makes things a bit easier, since most limbs wouldn't be of a very complex shape, typically. So, let me rephrase my question. How would I "flesh out" a shape drawn through an outline, to fill it in with polygons?
A quick Google turned up this paper. The paper describes a technique of converting a sketched closed shape to a piecewise linear curve, then adapting a seed path to fit the curve, and generating a mesh from the grown seed curve. Seems interesting enough, and I think the cited references might also be useful in generating the mesh from the path, although I haven't combed through them to verify that.

I think that I forgot to clarify a rather important point in my design, which I think simplifies the problem. Characters will be constructed by separate limbs, each of which would be drawn individually, and then connected to each other via joints, to allow for easier animation. I imagine this makes things a bit easier, since most limbs wouldn't be of a very complex shape, typically. So, let me rephrase my question. How would I "flesh out" a shape drawn through an outline, to fill it in with polygons?


Again, an outline is insufficient data for creating a "fleshed out" character unless you want something paper thin or as low res as the original Star Fox models. That is, they will be like that if you do not keep checking with the player to see if your results match their expectations and having the program adapt to each answer.

If you start working on this as a project, I promise that the time it will take for someone to work on a post explaining everything involved in one possible implementation is time you could spend studying and experimenting with results. I would be interested in what you come up with if you made progress. JTippetts link should prove pretty interesting, too.

[quote name='linux_junkie' timestamp='1310313643' post='4833367']
I think that I forgot to clarify a rather important point in my design, which I think simplifies the problem. Characters will be constructed by separate limbs, each of which would be drawn individually, and then connected to each other via joints, to allow for easier animation. I imagine this makes things a bit easier, since most limbs wouldn't be of a very complex shape, typically. So, let me rephrase my question. How would I "flesh out" a shape drawn through an outline, to fill it in with polygons?


Again, an outline is insufficient data for creating a "fleshed out" character unless you want something paper thin or as low res as the original Star Fox models. That is, they will be like that if you do not keep checking with the player to see if your results match their expectations and having the program adapt to each answer.

If you start working on this as a project, I promise that the time it will take for someone to work on a post explaining everything involved in one possible implementation is time you could spend studying and experimenting with results. I would be interested in what you come up with if you made progress. JTippetts link should prove pretty interesting, too.
[/quote]

Well, it's a completely 2D game, so being paper thin is actually all I need. Visually, I'm looking to create a "collage" type feel, kind of like South Park used in the early seasons, although with a different stylistic direction. Characters will be composed of (typically) simple shapes, representing the different limbs, and then attached by joints. Again, I am a complete novice in regards to 3D graphics, but this doesn't seem like it would be impossible or impractical to resolve, I'm just not quite sure how to go about it.

My first idea was to break down the outlines by filling them in with rough quads, and then filling in the edges with triangles to give a less blocky shape. Afterwards, I'd just convert the quads into individual triangles to speed up rendering. The outline doesn't have to be perfect in its polygon form, since applying a curved texture with alpha transparency around the borders would make up for any blockiness along the outline. The only problem is that I ran into some issues with special case scenarios, where it just plain didn't work, especially if the outline was highly irregular and extremely concave, but this was probably more to do with a naive implementation.

Thanks for the link JTippets, I'm going to read that now, since that sounds like exactly the solution I need. If I manage to get this working, I'll be sure to post the code, even though the majority of coders here will have little use for it, due to the 2D nature of the game.

Well, it's a completely 2D game, so being paper thin is actually all I need. Visually, I'm looking to create a "collage" type feel, kind of like South Park used in the early seasons, although with a different stylistic direction. Characters will be composed of (typically) simple shapes, representing the different limbs, and then attached by joints.


By the sound of it, you are looking to do something like this, only with a "tighter" fit around the joints for, what I can only assume to be, 2D physics purposes. I'm afraid I cannot contribute to the discussion, but hopefully this will clarify your intentions to the people on this forum who can.


This topic is closed to new replies.

Advertisement