当前位置: 首页>>代码示例>>C#>>正文


C# ShadingState.setModifier方法代码示例

本文整理汇总了C#中ShadingState.setModifier方法的典型用法代码示例。如果您正苦于以下问题:C# ShadingState.setModifier方法的具体用法?C# ShadingState.setModifier怎么用?C# ShadingState.setModifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ShadingState的用法示例。


在下文中一共展示了ShadingState.setModifier方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: prepareShadingState

        public void prepareShadingState(ShadingState state)
        {
            state.init();
            state.getRay().getPoint(state.getPoint());
            Instance parent = state.getInstance();
            Point3 localPoint = parent.transformWorldToObject(state.getPoint());
            state.getNormal().set(localPoint.x, localPoint.y, localPoint.z);
            state.getNormal().normalize();

            float phi = (float)Math.Atan2(state.getNormal().y, state.getNormal().x);
            if (phi < 0)
                phi += (float)(2 * Math.PI);
            float theta = (float)Math.Acos(state.getNormal().z);
            state.getUV().y = theta / (float)Math.PI;
            state.getUV().x = phi / (float)(2 * Math.PI);
            Vector3 v = new Vector3();
            v.x = -2 * (float)Math.PI * state.getNormal().y;
            v.y = 2 * (float)Math.PI * state.getNormal().x;
            v.z = 0;
            state.setShader(parent.getShader(0));
            state.setModifier(parent.getModifier(0));
            // into world space
            Vector3 worldNormal = parent.transformNormalObjectToWorld(state.getNormal());
            v = parent.transformVectorObjectToWorld(v);
            state.getNormal().set(worldNormal);
            state.getNormal().normalize();
            state.getGeoNormal().set(state.getNormal());
            // compute basis in world space
            state.setBasis(OrthoNormalBasis.makeFromWV(state.getNormal(), v));
        }
开发者ID:rzel,项目名称:sunflowsharp,代码行数:30,代码来源:Sphere.cs

示例2: prepareShadingState

 public void prepareShadingState(ShadingState state)
 {
     state.init();
     state.getRay().getPoint(state.getPoint());
     Instance parent = state.getInstance();
     Point3 n = parent.transformWorldToObject(state.getPoint());
     state.getNormal().set(n.x * (2 * n.x * n.x - 1), n.y * (2 * n.y * n.y - 1), n.z * (2 * n.z * n.z - 1));
     state.getNormal().normalize();
     state.setShader(parent.getShader(0));
     state.setModifier(parent.getModifier(0));
     // into world space
     Vector3 worldNormal = parent.transformNormalObjectToWorld(state.getNormal());
     state.getNormal().set(worldNormal);
     state.getNormal().normalize();
     state.getGeoNormal().set(state.getNormal());
     // create basis in world space
     state.setBasis(OrthoNormalBasis.makeFromW(state.getNormal()));
 }
开发者ID:rzel,项目名称:sunflowsharp,代码行数:18,代码来源:BanchoffSurface.cs

示例3: prepareShadingState

 public void prepareShadingState(ShadingState state)
 {
     state.init();
     state.getRay().getPoint(state.getPoint());
     int n = state.getPrimitiveID();
     switch (n)
     {
         case 0:
             state.getNormal().set(new Vector3(1, 0, 0));
             break;
         case 1:
             state.getNormal().set(new Vector3(-1, 0, 0));
             break;
         case 2:
             state.getNormal().set(new Vector3(0, 1, 0));
             break;
         case 3:
             state.getNormal().set(new Vector3(0, -1, 0));
             break;
         case 4:
             state.getNormal().set(new Vector3(0, 0, 1));
             break;
         case 5:
             state.getNormal().set(new Vector3(0, 0, -1));
             break;
         default:
             state.getNormal().set(new Vector3(0, 0, 0));
             break;
     }
     state.getGeoNormal().set(state.getNormal());
     state.setBasis(OrthoNormalBasis.makeFromW(state.getNormal()));
     state.setShader(state.getInstance().getShader(0));
     state.setModifier(state.getInstance().getModifier(0));
 }
开发者ID:rzel,项目名称:sunflowsharp,代码行数:34,代码来源:Box.cs

示例4: prepareShadingState

 public void prepareShadingState(ShadingState state)
 {
     state.init();
     state.getRay().getPoint(state.getPoint());
     Instance parent = state.getInstance();
     Vector3 normal;
     switch (state.getPrimitiveID())
     {
         case 0:
             normal = new Vector3(-1, 0, 0);
             break;
         case 1:
             normal = new Vector3(1, 0, 0);
             break;
         case 2:
             normal = new Vector3(0, -1, 0);
             break;
         case 3:
             normal = new Vector3(0, 1, 0);
             break;
         case 4:
             normal = new Vector3(0, 0, -1);
             break;
         case 5:
             normal = new Vector3(0, 0, 1);
             break;
         default:
             normal = new Vector3(0, 0, 0);
             break;
     }
     state.getNormal().set(state.transformNormalObjectToWorld(normal));
     state.getGeoNormal().set(state.getNormal());
     state.setBasis(OrthoNormalBasis.makeFromW(state.getNormal()));
     state.setShader(parent.getShader(0));
     state.setModifier(parent.getModifier(0));
 }
开发者ID:,项目名称:,代码行数:36,代码来源:

示例5: prepareShadingState


//.........这里部分代码省略.........
         case ParameterList.InterpolationType.VERTEX:
             {
                 int i30 = 3 * index0;
                 int i31 = 3 * index1;
                 int i32 = 3 * index2;
                 float[] normals1 = this.normals.data;
                 state.getNormal().x = w * normals1[i30 + 0] + u * normals1[i31 + 0] + v * normals1[i32 + 0];
                 state.getNormal().y = w * normals1[i30 + 1] + u * normals1[i31 + 1] + v * normals1[i32 + 1];
                 state.getNormal().z = w * normals1[i30 + 2] + u * normals1[i31 + 2] + v * normals1[i32 + 2];
                 state.getNormal().set(parent.transformNormalObjectToWorld(state.getNormal()));
                 state.getNormal().normalize();
                 break;
             }
         case ParameterList.InterpolationType.FACEVARYING:
             {
                 int idx = 3 * tri;
                 float[] normals1 = this.normals.data;
                 state.getNormal().x = w * normals1[idx + 0] + u * normals1[idx + 3] + v * normals1[idx + 6];
                 state.getNormal().y = w * normals1[idx + 1] + u * normals1[idx + 4] + v * normals1[idx + 7];
                 state.getNormal().z = w * normals1[idx + 2] + u * normals1[idx + 5] + v * normals1[idx + 8];
                 state.getNormal().set(parent.transformNormalObjectToWorld(state.getNormal()));
                 state.getNormal().normalize();
                 break;
             }
     }
     float uv00 = 0, uv01 = 0, uv10 = 0, uv11 = 0, uv20 = 0, uv21 = 0;
     switch (uvs.interp)
     {
         case ParameterList.InterpolationType.NONE:
         case ParameterList.InterpolationType.FACE:
             {
                 state.getUV().x = 0;
                 state.getUV().y = 0;
                 break;
             }
         case ParameterList.InterpolationType.VERTEX:
             {
                 int i20 = 2 * index0;
                 int i21 = 2 * index1;
                 int i22 = 2 * index2;
                 float[] uvs1 = this.uvs.data;
                 uv00 = uvs1[i20 + 0];
                 uv01 = uvs1[i20 + 1];
                 uv10 = uvs1[i21 + 0];
                 uv11 = uvs1[i21 + 1];
                 uv20 = uvs1[i22 + 0];
                 uv21 = uvs1[i22 + 1];
                 break;
             }
         case ParameterList.InterpolationType.FACEVARYING:
             {
                 int idx = tri << 1;
                 float[] uvs1 = this.uvs.data;
                 uv00 = uvs1[idx + 0];
                 uv01 = uvs1[idx + 1];
                 uv10 = uvs1[idx + 2];
                 uv11 = uvs1[idx + 3];
                 uv20 = uvs1[idx + 4];
                 uv21 = uvs1[idx + 5];
                 break;
             }
     }
     if (uvs.interp != ParameterList.InterpolationType.NONE)
     {
         // get exact uv coords and compute tangent vectors
         state.getUV().x = w * uv00 + u * uv10 + v * uv20;
         state.getUV().y = w * uv01 + u * uv11 + v * uv21;
         float du1 = uv00 - uv20;
         float du2 = uv10 - uv20;
         float dv1 = uv01 - uv21;
         float dv2 = uv11 - uv21;
         Vector3 dp1 = Point3.sub(v0p, v2p, new Vector3()), dp2 = Point3.sub(v1p, v2p, new Vector3());
         float determinant = du1 * dv2 - dv1 * du2;
         if (determinant == 0.0f)
         {
             // create basis in world space
             state.setBasis(OrthoNormalBasis.makeFromW(state.getNormal()));
         }
         else
         {
             float invdet = 1 / determinant;
             // Vector3 dpdu = new Vector3();
             // dpdu.x = (dv2 * dp1.x - dv1 * dp2.x) * invdet;
             // dpdu.y = (dv2 * dp1.y - dv1 * dp2.y) * invdet;
             // dpdu.z = (dv2 * dp1.z - dv1 * dp2.z) * invdet;
             Vector3 dpdv = new Vector3();
             dpdv.x = (-du2 * dp1.x + du1 * dp2.x) * invdet;
             dpdv.y = (-du2 * dp1.y + du1 * dp2.y) * invdet;
             dpdv.z = (-du2 * dp1.z + du1 * dp2.z) * invdet;
             dpdv = parent.transformVectorObjectToWorld(dpdv);
             // create basis in world space
             state.setBasis(OrthoNormalBasis.makeFromWV(state.getNormal(), dpdv));
         }
     }
     else
         state.setBasis(OrthoNormalBasis.makeFromW(state.getNormal()));
     int shaderIndex = faceShaders == null ? 0 : (faceShaders[primID] & 0xFF);
     state.setShader(parent.getShader(shaderIndex));
     state.setModifier(parent.getModifier(shaderIndex));
 }
开发者ID:rzel,项目名称:sunflowsharp,代码行数:101,代码来源:TriangleMesh.cs

示例6: prepareShadingState

        public void prepareShadingState(ShadingState state)
        {
            state.init();
            state.getRay().getPoint(state.getPoint());
            Instance parent = state.getInstance();
            // compute local normal
            Point3 p = parent.transformWorldToObject(state.getPoint());
            float gx1w = p.x - DELTA;
            float gx1x = p.y;
            float gx1y = p.z;
            float gx1z = 0;
            float gx2w = p.x + DELTA;
            float gx2x = p.y;
            float gx2y = p.z;
            float gx2z = 0;

            float gy1w = p.x;
            float gy1x = p.y - DELTA;
            float gy1y = p.z;
            float gy1z = 0;
            float gy2w = p.x;
            float gy2x = p.y + DELTA;
            float gy2y = p.z;
            float gy2z = 0;

            float gz1w = p.x;
            float gz1x = p.y;
            float gz1y = p.z - DELTA;
            float gz1z = 0;
            float gz2w = p.x;
            float gz2x = p.y;
            float gz2y = p.z + DELTA;
            float gz2z = 0;

            for (int i = 0; i < maxIterations; i++)
            {
                {
                    // z = z*z + c
                    float nw = gx1w * gx1w - gx1x * gx1x - gx1y * gx1y - gx1z * gx1z + cw;
                    gx1x = 2 * gx1w * gx1x + cx;
                    gx1y = 2 * gx1w * gx1y + cy;
                    gx1z = 2 * gx1w * gx1z + cz;
                    gx1w = nw;
                }
                {
                    // z = z*z + c
                    float nw = gx2w * gx2w - gx2x * gx2x - gx2y * gx2y - gx2z * gx2z + cw;
                    gx2x = 2 * gx2w * gx2x + cx;
                    gx2y = 2 * gx2w * gx2y + cy;
                    gx2z = 2 * gx2w * gx2z + cz;
                    gx2w = nw;
                }
                {
                    // z = z*z + c
                    float nw = gy1w * gy1w - gy1x * gy1x - gy1y * gy1y - gy1z * gy1z + cw;
                    gy1x = 2 * gy1w * gy1x + cx;
                    gy1y = 2 * gy1w * gy1y + cy;
                    gy1z = 2 * gy1w * gy1z + cz;
                    gy1w = nw;
                }
                {
                    // z = z*z + c
                    float nw = gy2w * gy2w - gy2x * gy2x - gy2y * gy2y - gy2z * gy2z + cw;
                    gy2x = 2 * gy2w * gy2x + cx;
                    gy2y = 2 * gy2w * gy2y + cy;
                    gy2z = 2 * gy2w * gy2z + cz;
                    gy2w = nw;
                }
                {
                    // z = z*z + c
                    float nw = gz1w * gz1w - gz1x * gz1x - gz1y * gz1y - gz1z * gz1z + cw;
                    gz1x = 2 * gz1w * gz1x + cx;
                    gz1y = 2 * gz1w * gz1y + cy;
                    gz1z = 2 * gz1w * gz1z + cz;
                    gz1w = nw;
                }
                {
                    // z = z*z + c
                    float nw = gz2w * gz2w - gz2x * gz2x - gz2y * gz2y - gz2z * gz2z + cw;
                    gz2x = 2 * gz2w * gz2x + cx;
                    gz2y = 2 * gz2w * gz2y + cy;
                    gz2z = 2 * gz2w * gz2z + cz;
                    gz2w = nw;
                }
            }
            float gradX = Length(gx2w, gx2x, gx2y, gx2z) - Length(gx1w, gx1x, gx1y, gx1z);
            float gradY = Length(gy2w, gy2x, gy2y, gy2z) - Length(gy1w, gy1x, gy1y, gy1z);
            float gradZ = Length(gz2w, gz2x, gz2y, gz2z) - Length(gz1w, gz1x, gz1y, gz1z);
            Vector3 n = new Vector3((float)gradX, (float)gradY, (float)gradZ);
            state.getNormal().set(parent.transformNormalObjectToWorld(n));
            state.getNormal().normalize();
            state.getGeoNormal().set(state.getNormal());
            state.setBasis(OrthoNormalBasis.makeFromW(state.getNormal()));

            state.getPoint().x += state.getNormal().x * epsilon * 20;
            state.getPoint().y += state.getNormal().y * epsilon * 20;
            state.getPoint().z += state.getNormal().z * epsilon * 20;

            state.setShader(parent.getShader(0));
            state.setModifier(parent.getModifier(0));
//.........这里部分代码省略.........
开发者ID:rzel,项目名称:sunflowsharp,代码行数:101,代码来源:JuliaFractal.cs

示例7: prepareShadingState

        public void prepareShadingState(ShadingState state)
        {
            state.init();
            state.getRay().getPoint(state.getPoint());
            Instance parent = state.getInstance();
            // get local point
            Point3 p = parent.transformWorldToObject(state.getPoint());
            // compute local normal
            float deriv = p.x * p.x + p.y * p.y + p.z * p.z - ri2 - ro2;
            state.getNormal().set(p.x * deriv, p.y * deriv, p.z * deriv + 2 * ro2 * p.z);
            state.getNormal().normalize();

            double phi = Math.Asin(MathUtils.clamp(p.z / ri, -1, 1));
            double theta = Math.Atan2(p.y, p.x);
            if (theta < 0)
                theta += 2 * Math.PI;
            state.getUV().x = (float)(theta / (2 * Math.PI));
            state.getUV().y = (float)((phi + Math.PI / 2) / Math.PI);
            state.setShader(parent.getShader(0));
            state.setModifier(parent.getModifier(0));
            // into world space
            Vector3 worldNormal = parent.transformNormalObjectToWorld(state.getNormal());
            state.getNormal().set(worldNormal);
            state.getNormal().normalize();
            state.getGeoNormal().set(state.getNormal());
            // make basis in world space
            state.setBasis(OrthoNormalBasis.makeFromW(state.getNormal()));
        }
开发者ID:rzel,项目名称:sunflowsharp,代码行数:28,代码来源:Torus.cs

示例8: prepareShadingState

 public void prepareShadingState(ShadingState state)
 {
     state.init();
     state.getRay().getPoint(state.getPoint());
     Instance parent = state.getInstance();
     float u = state.getU();
     float v = state.getV();
     float[] bu = bernstein(u);
     float[] bdu = bernsteinDeriv(u);
     float[] bv = bernstein(v);
     float[] bdv = bernsteinDeriv(v);
     getPatchPoint(u, v, patches[state.getPrimitiveID()], bu, bv, bdu, bdv, new Point3(), state.getNormal());
     state.getNormal().set(parent.transformNormalObjectToWorld(state.getNormal()));
     state.getNormal().normalize();
     state.getGeoNormal().set(state.getNormal());
     state.getUV().set(u, v);
     state.setShader(parent.getShader(0));
     state.setModifier(parent.getModifier(0));
     // FIXME: use actual derivatives to create basis
     state.setBasis(OrthoNormalBasis.makeFromW(state.getNormal()));
 }
开发者ID:rzel,项目名称:sunflowsharp,代码行数:21,代码来源:BezierMesh.cs


注:本文中的ShadingState.setModifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。