本文整理汇总了C++中Matrix3x4::Translation方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix3x4::Translation方法的具体用法?C++ Matrix3x4::Translation怎么用?C++ Matrix3x4::Translation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix3x4
的用法示例。
在下文中一共展示了Matrix3x4::Translation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetParent
void Node::SetParent(Node* parent)
{
if (parent)
{
Matrix3x4 oldWorldTransform = GetWorldTransform();
parent->AddChild(this);
if (parent != scene_)
{
Matrix3x4 newTransform = parent->GetWorldTransform().Inverse() * oldWorldTransform;
SetTransform(newTransform.Translation(), newTransform.Rotation(), newTransform.Scale());
}
else
{
// The root node is assumed to have identity transform, so can disregard it
SetTransform(oldWorldTransform.Translation(), oldWorldTransform.Rotation(), oldWorldTransform.Scale());
}
}
}
示例2: SetParent
void Node::SetParent(Node* parent)
{
if (parent)
{
Matrix3x4 oldWorldTransform = GetWorldTransform();
parent->AddChild(this);
Matrix3x4 newTransform = parent->GetWorldTransform().Inverse() * oldWorldTransform;
SetTransform(newTransform.Translation(), newTransform.Rotation(), newTransform.Scale());
}
}
示例3: Prepare
//.........这里部分代码省略.........
{
graphics->SetShaderParameter(VSP_SKINMATRICES, reinterpret_cast<const float*>(worldTransform_),
12 * numWorldTransforms_);
}
else
graphics->SetShaderParameter(VSP_MODEL, *worldTransform_);
// Set the orientation for billboards, either from the object itself or from the camera
if (geometryType_ == GEOM_BILLBOARD)
{
if (numWorldTransforms_ > 1)
graphics->SetShaderParameter(VSP_BILLBOARDROT, worldTransform_[1].RotationMatrix());
else
graphics->SetShaderParameter(VSP_BILLBOARDROT, cameraNode->GetWorldRotation().RotationMatrix());
}
}
// Set zone-related shader parameters
BlendMode blend = graphics->GetBlendMode();
// If the pass is additive, override fog color to black so that shaders do not need a separate additive path
bool overrideFogColorToBlack = blend == BLEND_ADD || blend == BLEND_ADDALPHA;
unsigned zoneHash = (unsigned)(size_t)zone_;
if (overrideFogColorToBlack)
zoneHash += 0x80000000;
if (zone_ && graphics->NeedParameterUpdate(SP_ZONE, reinterpret_cast<void*>(zoneHash)))
{
graphics->SetShaderParameter(VSP_AMBIENTSTARTCOLOR, zone_->GetAmbientStartColor());
graphics->SetShaderParameter(VSP_AMBIENTENDCOLOR, zone_->GetAmbientEndColor().ToVector4() - zone_->GetAmbientStartColor().ToVector4());
const BoundingBox& box = zone_->GetBoundingBox();
Vector3 boxSize = box.Size();
Matrix3x4 adjust(Matrix3x4::IDENTITY);
adjust.SetScale(Vector3(1.0f / boxSize.x_, 1.0f / boxSize.y_, 1.0f / boxSize.z_));
adjust.SetTranslation(Vector3(0.5f, 0.5f, 0.5f));
Matrix3x4 zoneTransform = adjust * zone_->GetInverseWorldTransform();
graphics->SetShaderParameter(VSP_ZONE, zoneTransform);
graphics->SetShaderParameter(PSP_AMBIENTCOLOR, zone_->GetAmbientColor());
graphics->SetShaderParameter(PSP_FOGCOLOR, overrideFogColorToBlack ? Color::BLACK : zone_->GetFogColor());
float farClip = camera_->GetFarClip();
float fogStart = Min(zone_->GetFogStart(), farClip);
float fogEnd = Min(zone_->GetFogEnd(), farClip);
if (fogStart >= fogEnd * (1.0f - M_LARGE_EPSILON))
fogStart = fogEnd * (1.0f - M_LARGE_EPSILON);
float fogRange = Max(fogEnd - fogStart, M_EPSILON);
Vector4 fogParams(fogEnd / farClip, farClip / fogRange, 0.0f, 0.0f);
Node* zoneNode = zone_->GetNode();
if (zone_->GetHeightFog() && zoneNode)
{
Vector3 worldFogHeightVec = zoneNode->GetWorldTransform() * Vector3(0.0f, zone_->GetFogHeight(), 0.0f);
fogParams.z_ = worldFogHeightVec.y_;
fogParams.w_ = zone_->GetFogHeightScale() / Max(zoneNode->GetWorldScale().y_, M_EPSILON);
}
graphics->SetShaderParameter(PSP_FOGPARAMS, fogParams);
}
// Set light-related shader parameters
if (lightQueue_)
{
if (graphics->NeedParameterUpdate(SP_VERTEXLIGHTS, lightQueue_) && graphics->HasShaderParameter(VS, VSP_VERTEXLIGHTS))
{
Vector4 vertexLights[MAX_VERTEX_LIGHTS * 3];
const PODVector<Light*>& lights = lightQueue_->vertexLights_;