📄 shardcloud.cpp
字号:
//-----------------------------------------
// Get the camera location into local space
//-----------------------------------------
//
Stuff::Point3D
camera_in_world(info->m_clipper->GetCameraToWorldMatrix());
Stuff::Point3D camera_in_cloud;
camera_in_cloud.MultiplyByInverse(
camera_in_world,
local_to_world
);
//
//--------------------------------------
// Spin through all the active particles
//--------------------------------------
//
for (i = 0; i < m_activeParticleCount; i++)
{
Particle *particle = GetParticle(i);
Check_Object(particle);
if (particle->m_age < 1.0f)
{
//
//--------------------------------
// Build the local to cloud matrix
//--------------------------------
//
Stuff::Vector3D direction_in_cloud;
direction_in_cloud.Subtract(
camera_in_cloud,
particle->m_localTranslation
);
Stuff::LinearMatrix4D shard_to_cloud;
shard_to_cloud.BuildRotation(particle->m_localRotation);
shard_to_cloud.AlignLocalAxisToWorldVector(
direction_in_cloud,
Stuff::Z_Axis,
Stuff::Y_Axis,
Stuff::X_Axis
);
shard_to_cloud.BuildTranslation(particle->m_localTranslation);
//
//--------------------------------------------------
// Figure out the scale, then build the three points
//--------------------------------------------------
//
Stuff::Scalar scale = particle->m_scale;
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
0.0f,
-0.5f*scale*particle->m_radius,
0.0f
),
shard_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
scale*particle->m_angle*particle->m_radius,
scale*particle->m_radius*0.5f,
0.0f
),
shard_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
-scale*particle->m_angle*particle->m_radius,
scale*particle->m_radius*0.5f,
0.0f
),
shard_to_cloud
);
}
else
vert += 3;
}
}
//
//-----------------------
// Handle X-only rotation
//-----------------------
//
else
{
//
//-----------------------------------------
// Get the camera location into local space
//-----------------------------------------
//
Stuff::Point3D
camera_in_world(info->m_clipper->GetCameraToWorldMatrix());
Stuff::Point3D camera_in_cloud;
camera_in_cloud.MultiplyByInverse(
camera_in_world,
local_to_world
);
//
//--------------------------------------
// Spin through all the active particles
//--------------------------------------
//
for (i = 0; i < m_activeParticleCount; i++)
{
Particle *particle = GetParticle(i);
Check_Object(particle);
if (particle->m_age < 1.0f)
{
//
//--------------------------------
// Build the local to cloud matrix
//--------------------------------
//
Stuff::Vector3D direction_in_cloud;
direction_in_cloud.Subtract(
camera_in_cloud,
particle->m_localTranslation
);
Stuff::LinearMatrix4D shard_to_cloud;
shard_to_cloud.BuildRotation(particle->m_localRotation);
shard_to_cloud.AlignLocalAxisToWorldVector(
direction_in_cloud,
Stuff::Z_Axis,
Stuff::X_Axis,
-1
);
shard_to_cloud.BuildTranslation(particle->m_localTranslation);
//
//--------------------------------------------------
// Figure out the scale, then build the three points
//--------------------------------------------------
//
Stuff::Scalar scale = particle->m_scale;
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
0.0f,
-0.5f*scale*particle->m_radius,
0.0f
),
shard_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
scale*particle->m_angle*particle->m_radius,
scale*particle->m_radius*0.5f,
0.0f
),
shard_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
-scale*particle->m_angle*particle->m_radius,
scale*particle->m_radius*0.5f,
0.0f
),
shard_to_cloud
);
}
else
vert += 3;
}
}
}
//
//-------------------------------------------------------
// Each matrix needs to be aligned to the camera around Y
//-------------------------------------------------------
//
else if (spec->m_alignZUsingY)
{
//
//-----------------------------------------
// Get the camera location into local space
//-----------------------------------------
//
Stuff::Point3D
camera_in_world(info->m_clipper->GetCameraToWorldMatrix());
Stuff::Point3D camera_in_cloud;
camera_in_cloud.MultiplyByInverse(
camera_in_world,
local_to_world
);
//
//--------------------------------------
// Spin through all the active particles
//--------------------------------------
//
for (i = 0; i < m_activeParticleCount; i++)
{
Particle *particle = GetParticle(i);
Check_Object(particle);
if (particle->m_age < 1.0f)
{
//
//--------------------------------
// Build the local to cloud matrix
//--------------------------------
//
Stuff::Vector3D direction_in_cloud;
direction_in_cloud.Subtract(
camera_in_cloud,
particle->m_localTranslation
);
Stuff::LinearMatrix4D shard_to_cloud;
shard_to_cloud.BuildRotation(particle->m_localRotation);
shard_to_cloud.AlignLocalAxisToWorldVector(
direction_in_cloud,
Stuff::Z_Axis,
Stuff::Y_Axis,
-1
);
shard_to_cloud.BuildTranslation(particle->m_localTranslation);
//
//--------------------------------------------------
// Figure out the scale, then build the three points
//--------------------------------------------------
//
Stuff::Scalar scale = particle->m_scale;
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
0.0f,
-0.5f*scale*particle->m_radius,
0.0f
),
shard_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
scale*particle->m_angle*particle->m_radius,
scale*particle->m_radius*0.5f,
0.0f
),
shard_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
-scale*particle->m_angle*particle->m_radius,
scale*particle->m_radius*0.5f,
0.0f
),
shard_to_cloud
);
}
else
vert += 3;
}
}
//
//---------------------------------------------------------------
// No alignment is necessary, so just multiply out all the active
// particles
//---------------------------------------------------------------
//
else
{
for (i = 0; i < m_activeParticleCount; i++)
{
Particle *particle = GetParticle(i);
Check_Object(particle);
if (particle->m_age < 1.0f)
{
//
//--------------------------------
// Build the local to cloud matrix
//--------------------------------
//
Stuff::LinearMatrix4D shard_to_cloud;
shard_to_cloud.BuildRotation(particle->m_localRotation);
shard_to_cloud.BuildTranslation(particle->m_localTranslation);
//
//--------------------------------------------------
// Figure out the scale, then build the three points
//--------------------------------------------------
//
Stuff::Scalar scale = particle->m_scale;
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
0.0f,
-0.5f*scale*particle->m_radius,
0.0f
),
shard_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
scale*particle->m_angle*particle->m_radius,
scale*particle->m_radius*0.5f,
0.0f
),
shard_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
-scale*particle->m_angle*particle->m_radius,
scale*particle->m_radius*0.5f,
0.0f
),
shard_to_cloud
);
}
else
vert += 3;
}
}
//
//---------------------
// Now just do the draw
//---------------------
//
info->m_clipper->DrawEffect(&dInfo);
}
SpinningCloud::Draw(info);
}
//------------------------------------------------------------------------------
//
void
gosFX::ShardCloud::TestInstance() const
{
Verify(IsDerivedFrom(DefaultData));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -