📄 cardcloud.cpp
字号:
BYTE rows = static_cast<BYTE>(columns / spec->m_width);
columns = static_cast<BYTE>(columns - rows*spec->m_width);
//
//---------------------------
// Now compute the end points
//---------------------------
//
u += u2*columns;
v += v2*rows;
}
u2 += u;
v2 += v;
index *= 4;
m_P_uvs[index].x = u;
m_P_uvs[index].y = v2;
m_P_uvs[++index].x = u2;
m_P_uvs[index].y = v2;
m_P_uvs[++index].x = u2;
m_P_uvs[index].y = v;
m_P_uvs[++index].x = u;
m_P_uvs[index].y = v;
return true;
}
//------------------------------------------------------------------------------
//
void gosFX::CardCloud::DestroyParticle(unsigned index)
{
Check_Object(this);
m_cloudImplementation->TurnOff(index);
Verify(!m_cloudImplementation->IsOn(index));
SpinningCloud::DestroyParticle(index);
}
//------------------------------------------------------------------------------
//
void gosFX::CardCloud::Draw(DrawInfo *info)
{
Check_Object(this);
Check_Object(info);
//
//---------------------------------------------------------
// If we have active particles, set up the draw information
//---------------------------------------------------------
//
if (m_activeParticleCount)
{
MidLevelRenderer::DrawEffectInformation dInfo;
dInfo.effect = m_cloudImplementation;
Specification *spec = GetSpecification();
Check_Object(spec);
dInfo.state.Combine(info->m_state, spec->m_state);
dInfo.clippingFlags = info->m_clippingFlags;
Stuff::LinearMatrix4D local_to_world;
local_to_world.Multiply(m_localToParent, *info->m_parentToWorld);
dInfo.effectToWorld = &local_to_world;
//
//--------------------------------------------------------------
// Check the orientation mode. The first case is XY orientation
//--------------------------------------------------------------
//
unsigned i;
unsigned vert=0;
if (spec->m_alignZUsingX)
{
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 card_to_cloud;
card_to_cloud.BuildRotation(particle->m_localRotation);
card_to_cloud.AlignLocalAxisToWorldVector(
direction_in_cloud,
Stuff::Z_Axis,
Stuff::Y_Axis,
Stuff::X_Axis
);
card_to_cloud.BuildTranslation(
particle->m_localTranslation
);
//
//-------------------------------------------------
// Figure out the scale, then build the four points
//-------------------------------------------------
//
Stuff::Scalar scale = particle->m_scale;
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
scale*particle->m_halfX,
-scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
-scale*particle->m_halfX,
-scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
-scale*particle->m_halfX,
scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
scale*particle->m_halfX,
scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
}
else
vert += 4;
}
}
//
//-----------------------
// 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 card_to_cloud;
card_to_cloud.BuildRotation(particle->m_localRotation);
card_to_cloud.AlignLocalAxisToWorldVector(
direction_in_cloud,
Stuff::Z_Axis,
Stuff::X_Axis,
-1
);
card_to_cloud.BuildTranslation(particle->m_localTranslation);
//
//-------------------------------------------------
// Figure out the scale, then build the four points
//-------------------------------------------------
//
Stuff::Scalar scale = particle->m_scale;
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
scale*particle->m_halfX,
-scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
-scale*particle->m_halfX,
-scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
-scale*particle->m_halfX,
scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
scale*particle->m_halfX,
scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
}
else
vert += 4;
}
}
}
//
//-------------------------------------------------------
// 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 card_to_cloud;
card_to_cloud.BuildRotation(particle->m_localRotation);
card_to_cloud.AlignLocalAxisToWorldVector(
direction_in_cloud,
Stuff::Z_Axis,
Stuff::Y_Axis,
-1
);
card_to_cloud.BuildTranslation(particle->m_localTranslation);
//
//-------------------------------------------------
// Figure out the scale, then build the four points
//-------------------------------------------------
//
Stuff::Scalar scale = particle->m_scale;
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
scale*particle->m_halfX,
-scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
-scale*particle->m_halfX,
-scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
-scale*particle->m_halfX,
scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
scale*particle->m_halfX,
scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
}
else
vert += 4;
}
}
//
//---------------------------------------------------------------
// 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 card_to_cloud;
card_to_cloud.BuildRotation(particle->m_localRotation);
card_to_cloud.BuildTranslation(particle->m_localTranslation);
//
//-------------------------------------------------
// Figure out the scale, then build the four points
//-------------------------------------------------
//
Stuff::Scalar scale = particle->m_scale;
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
scale*particle->m_halfX,
-scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
-scale*particle->m_halfX,
-scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
-scale*particle->m_halfX,
scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
m_P_vertices[vert++].Multiply(
Stuff::Point3D(
scale*particle->m_halfX,
scale*particle->m_halfY,
0.0f
),
card_to_cloud
);
}
else
vert += 4;
}
}
//
//---------------------
// Now just do the draw
//---------------------
//
info->m_clipper->DrawEffect(&dInfo);
}
SpinningCloud::Draw(info);
}
//------------------------------------------------------------------------------
//
void
gosFX::CardCloud::TestInstance() const
{
Verify(IsDerivedFrom(DefaultData));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -