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


C++ MatrixTransform::Set方法代码示例

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


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

示例1: GL3CalculateShadowMapMatrix

void GL3CalculateShadowMapMatrix(Vector3D viewp, Vector3D light_direction, Vector3D x_direction,
Vector3D y_direction, Vector3D dim_min, Vector3D dim_max) {
    MatrixTransform M;
    // Note that the y direction has to be negated in order to preserve the handedness of
    // triangles when rendering the shadow map.
#if 0
    M.Set(
        x_direction.x, y_direction.x, - light_direction.x, 0.0f,
	x_direction.x, y_direction.y, - light_direction.y, 0.0f,
	x_direction.z, y_direction.z, - light_direction.z, 0.0f);
#else
    M.Set(
        x_direction.x, x_direction.y, x_direction.z, 0.0f,
        - y_direction.x, - y_direction.y, - y_direction.z, 0.0f,
        - light_direction.x, - light_direction.y, - light_direction.z, 0.0f);
#endif
    MatrixTransform T;
    T.AssignTranslation(- viewp);
    // Set orthographic projection matrix.
    MatrixTransform orthographic_shadow_map_projection_matrix;
    orthographic_shadow_map_projection_matrix.Set(
        2.0f / (dim_max.x - dim_min.x), 0.0f, 0.0f, - (dim_max.x + dim_min.x) / (dim_max.x - dim_min.x),
        0.0f, 2.0f / (dim_max.y - dim_min.y), 0.0f, - (dim_max.y + dim_min.y) / (dim_max.y - dim_min.y),
        0.0f, 0.0f, - 2.0f / dim_max.z, - 1.0f);
    shadow_map_matrix = orthographic_shadow_map_projection_matrix * (M * T);
    // Calculate viewport matrix for lighting pass with shadow map.
    MatrixTransform shadow_map_viewport_matrix;
    shadow_map_viewport_matrix.Set(
        0.5f, 0.0f, 0.0f, 0.5f,
        0.0f, 0.5f, 0.0f, 0.5f,
        0.0f, 0.0f, 0.5f, 0.5f);
    shadow_map_lighting_pass_matrix = shadow_map_viewport_matrix * shadow_map_matrix;

#if 0
    char *dim_max_str = dim_max.GetString();
    sreMessage(SRE_MESSAGE_LOG, "dim_max = %s", dim_max_str);
    delete [] dim_max_str;
    Point3D P1 = viewp + light_direction * dim_max.z;
    Point3D P2 = viewp;
    Point3D P3 = viewp + x_direction * dim_max.x + y_direction * dim_max.y;
    Vector4D P1_proj = shadow_map_matrix * P1;
    Vector4D P2_proj = shadow_map_matrix * P2;
    Vector4D P3_proj = shadow_map_matrix * P3;
    Vector3D P1_norm = P1_proj.GetVector3D();
    Vector3D P2_norm = P2_proj.GetVector3D();
    Vector3D P3_norm = P3_proj.GetVector3D();
    char *P1_norm_str = P1_norm.GetString();
    char *P2_norm_str = P2_norm.GetString();
    char *P3_norm_str = P3_norm.GetString();
    sreMessage(SRE_MESSAGE_LOG, "CalculateShadowMapMatrix: Point transformations "
        "%s, %s and %s.", P1_norm_str, P2_norm_str, P3_norm_str);
    delete P1_norm_str;
    delete P2_norm_str;
    delete P3_norm_str;
#endif
}
开发者ID:hglm,项目名称:sre,代码行数:56,代码来源:shader_matrix.cpp

示例2: GL3CalculateCubeShadowMapMatrix

void GL3CalculateCubeShadowMapMatrix(Vector3D light_position, Vector3D zdir,
Vector3D cube_s_vector, Vector3D cube_t_vector, float zmin, float zmax) {
    MatrixTransform M;
    M.Set(
        cube_s_vector.x, cube_s_vector.y, cube_s_vector.z, 0.0f,
        cube_t_vector.x, cube_t_vector.y, cube_t_vector.z, 0.0f,
        - zdir.x, - zdir.y, - zdir.z, 0.0f);
    MatrixTransform T;
    T.AssignTranslation(- light_position);
    // Calculate the projection matrix with a field of view of 90 degrees.
    float aspect = 1.0;
    float e = 1 / tanf((90.0f * M_PI / 180) / 2);
    float n = zmin;
    float f = zmax;
    float l = - n / e;
    float r = n / e;
    float b = - (1.0f / aspect) * n / e;
    float t = (1.0f / aspect) * n / e;
    Matrix4D shadow_map_projection_matrix;
    shadow_map_projection_matrix.Set(
        2 * n / (r - l), 0.0f, (r + l) / (r - l), 0.0f,
        0.0f, 2 * n / (t - b), (t + b) / (t - b), 0.0f,
        0.0f, 0.0f, - (f + n) / (f - n), - 2 * n * f / (f - n),
        0.0f, 0.0f, - 1.0f, 0.0f);
    cube_shadow_map_matrix = shadow_map_projection_matrix * (M * T);
}
开发者ID:hglm,项目名称:sre,代码行数:26,代码来源:shader_matrix.cpp

示例3: sreLookAt

void sreLookAt(float viewpx, float viewpy, float viewpz, float lookx, float looky, float lookz,
float upx, float upy, float upz) {
    Vector3D F = Vector3D(lookx, looky, lookz) - Vector3D(viewpx, viewpy, viewpz);
    Vector3D Up = Vector3D(upx, upy, upz);
    Vector3D f = F.Normalize();
    sre_internal_camera_vector = f;
    Up.Normalize();
    sre_internal_up_vector = Up;
    Vector3D s = Cross(f, Up);
    Vector3D u = Cross(s, f);
    MatrixTransform M;
    M.Set(
        s.x, s.y, s.z, 0.0f,
        u.x, u.y, u.z, 0.0f,
        - f.x, - f.y, - f.z, 0.0f);
    MatrixTransform T;
    T.AssignTranslation(Vector3D(- viewpx, - viewpy, -viewpz));
    sre_internal_view_matrix = M * T;
    sre_internal_view_projection_matrix = sre_internal_projection_matrix * sre_internal_view_matrix;
//    printf("View-projection matrix:\n");
//    for (int row = 0; row < 4; row++)
//        for (int column = 0; column < 4; column++)
//            printf("%f, ", sre_internal_view_projection_matrix(row, column));
//    printf("\n");
}
开发者ID:hglm,项目名称:sre,代码行数:25,代码来源:shader_matrix.cpp

示例4: GL3CalculateShadowMapMatrixAlwaysLight

void GL3CalculateShadowMapMatrixAlwaysLight() {
    // Set a matrix that produces shadow map coordinates that are out of bounds in x and y, with w coordinate 1
    // and a z-coordinate of 0.5. In the pixel shader, this produces no shadow.
    shadow_map_lighting_pass_matrix.Set(
        0.0f, 0.0f, 0.0f, -2.0f,
        0.0f, 0.0f, 0.0f, -2.0,
        0.0f, 0.0f, 0.0f, 0.5f);
}
开发者ID:hglm,项目名称:sre,代码行数:8,代码来源:shader_matrix.cpp


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