manual light normal ogre

Your manual object is lacking normals. Dynamic lighting only works on models with normals, even if the objects are point or line based.

 

 lighting only works with normals

 

Your manual object has only positions, it needs a normal per vertex too.

 

I'd probably use shaders to fake the normals. I'd fake the normal as facing the camera for a point and a perpendicular to the line for a line.

 

 

normal calculate Algorithm

 

something like this, but i'm not very sure :)
denote triange vertex as a,b,c, we have:
v1 = normalize(a-b);
v2 = normalize(a-c);
normalWeight = acos(dot(v1,v2));

 

normal = 0,0,0
totalWeight = 0
foreach triangle connect to vertex a
  normal += trangleNormal * normalWeight;
  totalWeight += normalWeight;

finalNormal = normal/totalWeight;

此算法摘自

http://bbs.gameres.com/showthread.asp?threadid=126765

 

 

有关法线的问题还需要再看看

 

 void ProgressiveMesh::PMTriangle::computeNormal()

    {

        Vector3 v0=vertex[0]->commonVertex->position;

        Vector3 v1=vertex[1]->commonVertex->position;

        Vector3 v2=vertex[2]->commonVertex->position;

        // Cross-product 2 edges

        Vector3 e1 = v1 - v0; 

        Vector3 e2 = v2 - v1;



        normal = e1.crossProduct(e2);

        normal.normalise();

    }

 

dx里有现成的D3DXComputeNormals()

你可能感兴趣的:(orm)