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


C# ShadingState.transformVectorObjectToWorld方法代码示例

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


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

示例1: prepareShadingState


//.........这里部分代码省略.........
                        float[] normals1 = this.normals.data;
                        state.getNormal().x = k00 * normals1[i30 + 0] + k10 * normals1[i31 + 0] + k11 * normals1[i32 + 0] + k01 * normals1[i33 + 0];
                        state.getNormal().y = k00 * normals1[i30 + 1] + k10 * normals1[i31 + 1] + k11 * normals1[i32 + 1] + k01 * normals1[i33 + 1];
                        state.getNormal().z = k00 * normals1[i30 + 2] + k10 * normals1[i31 + 2] + k11 * normals1[i32 + 2] + k01 * normals1[i33 + 2];
                        state.getNormal().set(state.transformNormalObjectToWorld(state.getNormal()));
                        state.getNormal().normalize();
                        break;
                    }
                case ParameterList.InterpolationType.FACEVARYING:
                    {
                        int idx = 3 * quad;
                        float[] normals1 = this.normals.data;
                        state.getNormal().x = k00 * normals1[idx + 0] + k10 * normals1[idx + 3] + k11 * normals1[idx + 6] + k01 * normals1[idx + 9];
                        state.getNormal().y = k00 * normals1[idx + 1] + k10 * normals1[idx + 4] + k11 * normals1[idx + 7] + k01 * normals1[idx + 10];
                        state.getNormal().z = k00 * normals1[idx + 2] + k10 * normals1[idx + 5] + k11 * normals1[idx + 8] + k01 * normals1[idx + 11];
                        state.getNormal().set(state.transformNormalObjectToWorld(state.getNormal()));
                        state.getNormal().normalize();
                        break;
                    }
            }
            float uv00 = 0, uv01 = 0, uv10 = 0, uv11 = 0, uv20 = 0, uv21 = 0, uv30 = 0, uv31 = 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;
                        int i23 = 2 * index3;
                        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];
                        uv20 = uvs1[i23 + 0];
                        uv21 = uvs1[i23 + 1];
                        break;
                    }
                case ParameterList.InterpolationType.FACEVARYING:
                    {
                        int idx = quad << 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];
                        uv30 = uvs1[idx + 6];
                        uv31 = uvs1[idx + 7];
                        break;
                    }
            }
            if (uvs.interp != ParameterList.InterpolationType.NONE)
            {
                // get exact uv coords and compute tangent vectors
                state.getUV().x = k00 * uv00 + k10 * uv10 + k11 * uv20 + k01 * uv30;
                state.getUV().y = k00 * uv01 + k10 * uv11 + k11 * uv21 + k01 * uv31;
                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 = state.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:,项目名称:,代码行数:101,代码来源:


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