Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Cel-Shading (Dx7 and VB)

This topic is 5238 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having some trouble getting cel-shading to work in my program. I've been following the tutorial here on GameDev (the one by MENTAL). I'm using my own file format for the models, so I've altered my code sample some for here. Here's the code:
' Begin Code

Type Normal
    NormalX As Single
    NormalY As Single
    NormalZ As Single
End Type

Dim Normals(100) As Normal
Dim Vertices(100) As D3DLVERTEX

Dim g_Dx As New DirectX7
Dim g_Light As D3DVECTOR, g_Normal As D3DVECTOR
Dim iTexCoord As Single

With g_Light
    .x = 10
    .y = 10
    .z = -10
End With
g_Dx.VectorNormalize g_Light

For i = 1 To NumVertices
    With Normals(i)
        g_Normal.x = .NormalX
        g_Normal.y = .NormalY
        g_Normal.z = .NormalZ
    End With

    iTexCoord = g_Dx.VectorDotProduct(g_Light, g_Normal)

    g_Dx.CreateD3DLVertex x, y, z, Color, 1, iTexCoord, iTexCoord, Vertices(i)
Next i

' End Code
I've tried normalizing g_Normal, but for some odd reason it winds up in an overflow error when I do CreateD3DLVertex. Any help would be greatly appreciated. [edited by - dxprog on May 17, 2004 6:16:16 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!