Toanso's picture

How to draw a beauty OBJ file.

Hi every one, i want to draw a obj file as shown blow, but i donot know how to make it looks beauty as the third picture shown.
could any one give me some hits. Thanks a lot.

Images
using  Triangles mode draw result
using Line_strip  mode draw result
how to reach such effect?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

This is much more complex than it looks.

GPU Gems 3 has an article on advanced skin rendering techniques [1], but unless you know how to use shaders it won't be of much help. I'd suggest focusing on that first (learn about diffuse & specular lighting, normal mapping, shadowing and then you can move to more advanced topics such as subsurface scattering and BRDFs).

[1] Chapter 14. Advanced Techniques for Realistic Real-Time Skin Rendering

Toanso's picture

I just set light
but it does not work, just as shown in picture,
Below are my render code

Triangles[] contain the vertices' index which in triangle. and normal [] contain the vertices' normal, and texcoord [] contain the vertice's texcoord
What's wrong with me ,Thanks a lot.

      float[] mat_ambient = new float[4] { 0.0f, 0.0f, 0.0f, 0.0f };
    float[] mat_diffuse = new float[4] { 0.2f, 0.3f, 0.5f, 0.0f };
    float[] mat_specular = new float[4] { 1.0f, 0.89f, 0.55f, 0.0f };
    float shineness = 10.0f;
 
      OpenTK.Graphics.OpenGL.GL.Material(MaterialFace.Front, MaterialParameter.Ambient, mat_ambient);
        OpenTK.Graphics.OpenGL.GL.Material(MaterialFace.Front, MaterialParameter.Diffuse, mat_diffuse);
        OpenTK.Graphics.OpenGL.GL.Material(MaterialFace.Front, MaterialParameter.Specular, mat_specular);
        OpenTK.Graphics.OpenGL.GL.Material(MaterialFace.Front, MaterialParameter.Shininess, shineness);
 
        OpenTK.Graphics.OpenGL.GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.Lighting);
 
        OpenTK.Graphics.OpenGL.GL.Color3(mat_diffuse[0], mat_diffuse[1], mat_diffuse[2]);
        GL.Begin(BeginMode.Triangles);
        for (int i = 0; i< Triangles.Length; i++)
        {
            int a = Triangles[i].Index0;
            int b = Triangles[i].Index1;
            int c = Triangles[i].Index2;
 
            GL.Normal3(Vertices[a].Normal.X, Vertices[a].Normal.Y, Vertices[a].Normal.Z);
            GL.TexCoord2(Vertices[a].TexCoord.X, Vertices[a].TexCoord.Y);
            GL.Vertex3(Vertices[a].Vertex.X, Vertices[a].Vertex.Y, Vertices[a].Vertex.Z);
 
            GL.Normal3(Vertices[b].Normal.X, Vertices[b].Normal.Y, Vertices[b].Normal.Z);
            GL.TexCoord2(Vertices[b].TexCoord.X, Vertices[b].TexCoord.Y);
            GL.Vertex3(Vertices[b].Vertex.X, Vertices[b].Vertex.Y, Vertices[b].Vertex.Z);
 
            GL.Normal3(Vertices[c].Normal.X, Vertices[c].Normal.Y, Vertices[c].Normal.Z);
            GL.TexCoord2(Vertices[c].TexCoord.X, Vertices[c].TexCoord.Y);
            GL.Vertex3(Vertices[c].Vertex.X, Vertices[c].Vertex.Y, Vertices[c].Vertex.Z);
 
        }
        GL.End();
        GL.Enable(EnableCap.Lighting);
tksuoran's picture

Check http://glprogramming.com/red/chapter05.html

You don't seem to be specifying your light, so I do not know if the defaults are good for your scene. I do not even remember if any lights are enabled by default, you can individually enable/disable GL_LIGHTi, like glEnable(GL_LIGHT0);

You should check that your normals have valid values, and that they are unit length. If they seem to be otherwise valid but not unit length, you can enable GL_NORMALIZE, or normalize them yourself while you load them.