Пример #1
0
    static private CSGVertex cylinderPoint(CSGVector3 s, CSGVector3 ray, float r, CSGVector3 axisX, CSGVector3 axisY, CSGVector3 axisZ, float stack, float slice, float normalBlend)
    {
        float      angle  = slice * ((float)Math.PI) * 2;
        CSGVector3 outv   = axisX.times((float)Math.Cos(angle)).plus(axisY.times((float)Math.Sin(angle)));
        CSGVector3 pos    = s.plus(ray.times(stack)).plus(outv.times(r));
        CSGVector3 normal = outv.times(1 - Math.Abs(normalBlend)).plus(axisZ.times(normalBlend));

        return(new CSGVertex(pos, normal));
    }
Пример #2
0
    static private void sphereVertex(CSGVector3 center, float radius, float theta, float phi, List <CSGVertex> vertices)
    {
        theta *= ((float)Math.PI) * 2;
        phi   *= ((float)Math.PI);
        CSGVector3 dir = new CSGVector3(
            (float)Math.Cos(theta) * (float)Math.Sin(phi),
            (float)Math.Cos(phi),
            (float)Math.Sin(theta) * (float)Math.Sin(phi)
            );

        vertices.Add(new CSGVertex(center.plus(dir.times(radius)), dir));
    }