本文整理汇总了C++中BoundBox::expand方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundBox::expand方法的具体用法?C++ BoundBox::expand怎么用?C++ BoundBox::expand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundBox
的用法示例。
在下文中一共展示了BoundBox::expand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void Shadows::update(Settings *settings, FRMMATRIX4X4& projIn, FRMMATRIX4X4& ModelviewIn, float* fv3SunDirIn) {
direction = FRMVECTOR3(fv3SunDirIn[0], fv3SunDirIn[1], fv3SunDirIn[2]);
// update pssm matrices
float znear = 1.0f;
float zfar = 250.0f;
float shadowRange = 200.0f;
float shadow_distribute = 0.1f;//25f;
FRMMATRIX4X4 invProj;
inverse( (float *)&invProj, (float *)&projIn );
//hack in a fast inverse
FRMMATRIX4X4 imodelview;
inverse((float *)& imodelview, (float *)& ModelviewIn);//inverse(mat4(fMat4ModelviewIn));//inverse(camera->getModelview());
// ortho basis (incorrect solution for vertical direction)
FRMVECTOR3 side = FrmVector3Normalize (FrmVector3Cross ( FRMVECTOR3(0.0f,0.0f,1.0f), direction));
FRMVECTOR3 up = FrmVector3Normalize (FrmVector3Cross (direction, side));
//vec3 side = normalize(cross(direction, vec3(0.0f,0.0f,1.0f)));
//vec3 up = normalize(cross(direction, side));
// bound frustum points
FRMVECTOR3 points[8] = {
FRMVECTOR3(-1.0f,-1.0f,-1.0f), FRMVECTOR3(1.0f,-1.0f,-1.0f), FRMVECTOR3(-1.0f,1.0f,-1.0f), FRMVECTOR3(1.0f,1.0f,-1.0f),
FRMVECTOR3(-1.0f,-1.0f, 1.0f), FRMVECTOR3(1.0f,-1.0f, 1.0f), FRMVECTOR3(-1.0f,1.0f, 1.0f), FRMVECTOR3(1.0f,1.0f, 1.0f),
};
// world space bound frustum points
for(int i = 0; i < 8; i++) {
FRMVECTOR4 point = FrmVector4Transform( FRMVECTOR4( points[i].x, points[i].y, points[i].z, 1.0f), invProj );// mat4((float *)& invProj ) * vec4(points[i]);
points[i] = FRMVECTOR3( point.x, point.y, point.z ) / point.w;
}
// world space bound frustum directions
FRMVECTOR3 directions[4];
for(int i = 0; i < 4; i++) {
directions[i] = FrmVector3Normalize( points[i + 4] - points[i]);
}
// split bound frustum
for(int i = 0; i < 4; i++) {
float k0 = (float)(i + 0) / 4;
float k1 = (float)(i + 1) / 4;
float fmin = FrmLerp(shadow_distribute, znear * powf(zfar / znear,k0),znear + (zfar - znear) * k0);
float fmax = FrmLerp(shadow_distribute, znear * powf(zfar / znear,k1),znear + (zfar - znear) * k1);
// none flickering removal
if( settings->getFlickering() == Settings::FLICKERING_NONE)
{
BoundBox bb;
for(int j = 0; j < 4; j++) {
bb.expand(points[j] + (directions[j] * fmin));
bb.expand(points[j] + (directions[j] * fmax));
}
BoundSphere bs(bb);
//save out radius squared
spheres[i] = FRMVECTOR4( FrmVector3TransformCoord( bs.getCenter(), imodelview), bs.getRadius() * bs.getRadius());
FRMVECTOR3 target = FrmVector3TransformCoord( bs.getCenter(), imodelview );
// This offset is applied to prevent far-plane clipping
float zFarOffset = 10.0f;
ortho( (float*)&projections[i], bs.getRadius(),-bs.getRadius(),bs.getRadius(),-bs.getRadius(), 0.1f, shadowRange - zFarOffset);
modelviews[i] = FrmMatrixLookAtRH(target + (direction * shadowRange / 2.0f),target - (direction * shadowRange / 2.0f),up);
}
// exact flickering removal
else
{
BoundBox bb;
for(int j = 0; j < 4; j++) {
bb.expand(points[j] + (directions[j] * fmin));
bb.expand(points[j] + (directions[j] * fmax));
}
BoundSphere bs(bb);
//save out radius squared
spheres[i] = FRMVECTOR4( FrmVector3TransformCoord( bs.getCenter(), imodelview ), bs.getRadius() * bs.getRadius());
float half_size = size / 2.0f;
FRMVECTOR3 target = FrmVector3TransformCoord( bs.getCenter(), imodelview );
float x = ceilf( FrmVector3Dot(target,up) * half_size / bs.getRadius()) * bs.getRadius() / half_size;
float y = ceilf( FrmVector3Dot(target,side) * half_size / bs.getRadius()) * bs.getRadius() / half_size;
target = up * x + side * y + (direction * FrmVector3Dot(target,direction));
// This offset is applied to prevent far-plane clipping
float zFarOffset = 10.0f;
ortho( (float*)&projections[i],bs.getRadius(),-bs.getRadius(),bs.getRadius(),-bs.getRadius(), 0.1f, shadowRange - zFarOffset);
modelviews[i] = FrmMatrixLookAtRH(target + (direction * shadowRange / 2.0f), target - (direction * shadowRange / 2.0f),up);
}
// Flip the texture coordinates for D3D
//.........这里部分代码省略.........