本文整理汇总了C++中kvs::Vector3f::dot方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector3f::dot方法的具体用法?C++ Vector3f::dot怎么用?C++ Vector3f::dot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kvs::Vector3f
的用法示例。
在下文中一共展示了Vector3f::dot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*==========================================================================*/
inline float Shader::Phong::attenuation( const kvs::Vector3f& vertex, const kvs::Vector3f& gradient ) const
{
// Light vector L, normal vector N and reflection vector R.
const kvs::Vector3f L = ( light_position - vertex ).normalized();
const kvs::Vector3f N = gradient.normalized();
const kvs::Vector3f R = 2.0f * N.dot( L ) * N - L;
const float dd = Math::Max( N.dot( L ), 0.0f );
const float ds = Math::Max( N.dot( R ), 0.0f );
/* I = Ia + Id + Is
*
* Is = Ip * Ks * cos^s(B) = Ip * Ks * ( R dot N )^s
*/
const float Ia = Ka;
const float Id = Kd * dd;
const float Is = Ks * std::pow( ds, S );
return Ia + Id + Is;
}
示例2: kvsShaderAmbientTerm
/*===========================================================================*/
const kvs::RGBColor Shader::Phong::shadedColor(
const kvs::RGBColor& color,
const kvs::Vector3f& vertex,
const kvs::Vector3f& normal ) const
{
// Light vector L, normal vector N and reflection vector R.
const kvs::Vector3f V = ( camera_position - vertex ).normalized();
const kvs::Vector3f L = ( light_position - vertex ).normalized();
const kvs::Vector3f N = normal.normalized();
const kvs::Vector3f R = 2.0f * N.dot( L ) * N - L;
// Intensity values.
const float Ia = kvsShaderAmbientTerm( Ka );
const float Id = kvsShaderDiffuseTerm( Kd, N, L );
const float Is = kvsShaderSpecularTerm( ks, S, R, V );
return ::Shade( color, Ia, Id, Is );
}