本文整理汇总了C++中Matrix4::Scaling方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4::Scaling方法的具体用法?C++ Matrix4::Scaling怎么用?C++ Matrix4::Scaling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4
的用法示例。
在下文中一共展示了Matrix4::Scaling方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawGridScene
void DrawGridScene( std::shared_ptr<RenderingContext> context, const Matrix4& matWorld )
{
Assert( context );
ConstantBuffer& cbuffer = context->GetSharedConstantBuffer();
float scale = model_scale.Float();
size_t columns = grid_size.Int();
float rowFactor = 1.0f / grid_size.Int();
float colFactor = 1.0f / columns;
for ( int row = 0; row < grid_size.Int(); ++row )
{
for ( size_t col = 0; col < columns; ++col )
{
// world transform
Matrix4 matTrans;
matTrans.Translate( ( ( col + 1 ) * colFactor - colFactor * ( columns * 0.5f ) ) * columns,
( ( row + 1 ) * rowFactor - rowFactor * ( columns * 0.5f ) ) * columns,
( ( row + 1 ) * rowFactor - rowFactor * ( columns * 0.5f ) ) * columns );
Matrix4 matScale;
matScale.Scaling( scale, scale, scale );
Matrix4 matNewWorld = matScale * matWorld * matTrans;
cbuffer.SetMatrix4( ConstantBuffer::WorldMatrix, matNewWorld );
// various color
cbuffer.SetVector4( ConstantBuffer::DiffuseColor, Vector4( max( 0.2f, matTrans.A41 * 0.5f + 0.8f ), max( 0.4f, matTrans.A42 * 0.5f + 0.6f ), matTrans.A43 * 0.5f + 1.0f, 1.0f ) );
context->Draw( GetMeshes()[row * columns + col] );
}
}
}
示例2: DrawGridSceneInParallel
void DrawGridSceneInParallel( StlVector<std::shared_ptr<RenderingContext>>& contexts, const Matrix4& matWorld )
{
float scale = model_scale.Float();
size_t rows = grid_size.Int();
size_t columns = grid_size.Int();
float rowFactor = 1.0f / grid_size.Int();
float colFactor = 1.0f / columns;
//using FuncPreRender = std::function<void( std::shared_ptr<RenderingContext> context, const std::shared_ptr<IMesh>& mesh, size_t index )>;
RenderingContext::FuncPreRender funcPreRender(
[=]( std::shared_ptr<RenderingContext> context, size_t index )
{
ConstantBuffer& cbuffer = context->GetSharedConstantBuffer();
// world transform
size_t row = kih::Clamp<size_t>( index / rows, 0, rows - 1 );
size_t col = kih::Clamp<size_t>( index - row * columns, 0, columns - 1 );
Matrix4 matTrans;
matTrans.Translate( ( ( col + 1 ) * colFactor - colFactor * ( columns * 0.5f ) ) * columns,
( ( row + 1 ) * rowFactor - rowFactor * ( columns * 0.5f ) ) * columns,
( ( row + 1 ) * rowFactor - rowFactor * ( columns * 0.5f ) ) * columns );
Matrix4 matScale;
matScale.Scaling( scale, scale, scale );
Matrix4 matNewWorld = matScale * matWorld * matTrans;
cbuffer.SetMatrix4( ConstantBuffer::WorldMatrix, matNewWorld );
// various color
cbuffer.SetVector4( ConstantBuffer::DiffuseColor, Vector4( max( 0.2f, matTrans.A41 * 0.5f + 0.8f ), max( 0.4f, matTrans.A42 * 0.5f + 0.6f ), matTrans.A43 * 0.5f + 1.0f, 1.0f ) );
}
);
RenderingContext::DrawInParallel( contexts, GetMeshes(), grid_size.Int() * grid_size.Int(), funcPreRender );
}