//------------------------------------------------------------------------------
//
void gosFX::ShapeCloud::Draw(DrawInfo *info)
{
	Check_Object(this);
	Check_Object(info);
	Check_Object(info->m_parentToWorld);

	//
	//----------------------------
	// Set up the common draw info
	//----------------------------
	//
	if (m_activeParticleCount)
	{
		MidLevelRenderer::DrawScalableShapeInformation dinfo;
		MidLevelRenderer::MLRShape *shape = GetSpecification()->m_shape;
		dinfo.clippingFlags.SetClippingState(0x3f);
		dinfo.worldToShape = NULL;
		Specification *spec = GetSpecification();
		Check_Object(spec);
		dinfo.state.Combine(info->m_state, spec->m_state);
		dinfo.activeLights = NULL;
		dinfo.nrOfActiveLights = 0;
		dinfo.shape = shape;
		Stuff::LinearMatrix4D local_to_world;
		local_to_world.Multiply(m_localToParent, *info->m_parentToWorld);

		//
		//--------------------------------------------------------------
		// Check the orientation mode.  The first case is XY orientation
		//--------------------------------------------------------------
		//
		unsigned i;
		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
				);
				for (unsigned i = 0; i < m_activeParticleCount; i++)
				{
					Particle *particle = GetParticle(i);
					Check_Object(particle);

					//
					//-----------------------------------------------------------------
					// If the particle is still alive, concatenate into world space and
					// issue the draw command
					//-----------------------------------------------------------------
					//
					if (particle->m_age < 1.0f)
					{
						Stuff::Vector3D direction_in_cloud;
						direction_in_cloud.Subtract(
							camera_in_cloud,
							particle->m_localTranslation
						);
						Stuff::LinearMatrix4D shape_to_cloud;
						shape_to_cloud.BuildRotation(particle->m_localRotation);
						shape_to_cloud.AlignLocalAxisToWorldVector(
							direction_in_cloud,
							Stuff::Z_Axis,
							Stuff::Y_Axis,
							Stuff::X_Axis
						);
						shape_to_cloud.BuildTranslation(particle->m_localTranslation);
						Stuff::LinearMatrix4D shape_to_world;
						shape_to_world.Multiply(
							shape_to_cloud,
							local_to_world
						);
						dinfo.shapeToWorld = &shape_to_world;
						Stuff::Vector3D
							scale(
								particle->m_scale,
								particle->m_scale,
								particle->m_scale
							);
						dinfo.scaling = &scale;
						dinfo.paintMe = &particle->m_color;
		 				info->m_clipper->DrawScalableShape(&dinfo);
						//magic 28112011 begin
						dinfo.shapeToWorld = NULL;
						dinfo.scaling = NULL;
						//magic 28112011 end
					}
				}
			}

			//
			//-----------------------
			// 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
				);
				for (unsigned i = 0; i < m_activeParticleCount; i++)
				{
					Particle *particle = GetParticle(i);
					Check_Object(particle);

					//
					//-----------------------------------------------------------------
					// If the particle is still alive, concatenate into world space and
					// issue the draw command
					//-----------------------------------------------------------------
					//
					if (particle->m_age < 1.0f)
					{
						Stuff::Vector3D direction_in_cloud;
						direction_in_cloud.Subtract(
							camera_in_cloud,
							particle->m_localTranslation
						);
						Stuff::LinearMatrix4D shape_to_cloud;
						shape_to_cloud.BuildRotation(particle->m_localRotation);
						shape_to_cloud.AlignLocalAxisToWorldVector(
							direction_in_cloud,
							Stuff::Z_Axis,
							Stuff::X_Axis,
							-1
						);
						shape_to_cloud.BuildTranslation(particle->m_localTranslation);
						Stuff::LinearMatrix4D shape_to_world;
						shape_to_world.Multiply(
							shape_to_cloud,
							local_to_world
						);
						dinfo.shapeToWorld = &shape_to_world;
						Stuff::Vector3D
							scale(
								particle->m_scale,
								particle->m_scale,
								particle->m_scale
							);
						dinfo.scaling = &scale;
						dinfo.paintMe = &particle->m_color;
		 				info->m_clipper->DrawScalableShape(&dinfo);
						//magic 28112011 begin
						dinfo.shapeToWorld = NULL;
						dinfo.scaling = NULL;
						//magic 28112011 end
					}
				}
			}
		}

		//
		//-------------------------------------------------------
		// 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
			);
			for (unsigned i = 0; i < m_activeParticleCount; i++)
			{
				Particle *particle = GetParticle(i);
				Check_Object(particle);

				//
				//-----------------------------------------------------------------
				// If the particle is still alive, concatenate into world space and
				// issue the draw command
				//-----------------------------------------------------------------
				//
				if (particle->m_age < 1.0f)
				{
					Stuff::Vector3D direction_in_cloud;
					direction_in_cloud.Subtract(
						camera_in_cloud,
						particle->m_localTranslation
					);
					Stuff::LinearMatrix4D shape_to_cloud;
					shape_to_cloud.BuildRotation(particle->m_localRotation);
					shape_to_cloud.AlignLocalAxisToWorldVector(
						direction_in_cloud,
						Stuff::Z_Axis,
						Stuff::Y_Axis,
						-1
					);
					shape_to_cloud.BuildTranslation(particle->m_localTranslation);
					Stuff::LinearMatrix4D shape_to_world;
					shape_to_world.Multiply(
						shape_to_cloud,
						local_to_world
					);
					dinfo.shapeToWorld = &shape_to_world;
					Stuff::Vector3D
						scale(
							particle->m_scale,
							particle->m_scale,
							particle->m_scale
						);
					dinfo.scaling = &scale;
					dinfo.paintMe = &particle->m_color;
		 			info->m_clipper->DrawScalableShape(&dinfo);
						//magic 28112011 begin
						dinfo.shapeToWorld = NULL;
						dinfo.scaling = NULL;
						//magic 28112011 end
				}
			}
		}

		//
		//---------------------------------------------------------------
		// 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 the particle is still alive, concatenate into world space and
				// issue the draw command
				//-----------------------------------------------------------------
				//
				if (particle->m_age < 1.0f)
				{
					Stuff::LinearMatrix4D shape_to_cloud;
					shape_to_cloud.BuildTranslation(particle->m_localTranslation);
					shape_to_cloud.BuildRotation(particle->m_localRotation);
					Stuff::LinearMatrix4D shape_to_world;
					shape_to_world.Multiply(
						shape_to_cloud,
						local_to_world
					);
					dinfo.shapeToWorld = &shape_to_world;
					Stuff::Vector3D
						scale(
							particle->m_scale,
							particle->m_scale,
							particle->m_scale
						);
					dinfo.scaling = &scale;
					dinfo.paintMe = &particle->m_color;
		 			info->m_clipper->DrawScalableShape(&dinfo);
						//magic 28112011 begin
						dinfo.shapeToWorld = NULL;
						dinfo.scaling = NULL;
						//magic 28112011 end
				}
			}
		}
	}

	//
	//----------------------------
	// Let our parent do its thing
	//----------------------------
	//
	SpinningCloud::Draw(info);
}
Esempio n. 2
0
//------------------------------------------------------------------------------
//
void gosFX::Shape::Draw(DrawInfo *info)
{
	Check_Object(this);
	Check_Object(info);
	Check_Object(info->m_parentToWorld);

	//
	//----------------------------
	// Set up the common draw info
	//----------------------------
	//
	MidLevelRenderer::DrawScalableShapeInformation dinfo;
	MidLevelRenderer::MLRShape *shape = GetSpecification()->m_shape;
	dinfo.clippingFlags.SetClippingState(0x3f);
	dinfo.worldToShape = NULL;
	Specification *spec = GetSpecification();
	Check_Object(spec);
	dinfo.state.Combine(info->m_state, spec->m_state);
	dinfo.activeLights = NULL;
	dinfo.nrOfActiveLights = 0;
	dinfo.shape = shape;
	Stuff::Vector3D scale(m_scale, m_scale, m_scale);
	dinfo.scaling = &scale;
	dinfo.paintMe = &m_color;
	Stuff::LinearMatrix4D local_to_world;
	local_to_world.Multiply(m_localToParent, *info->m_parentToWorld);
	dinfo.shapeToWorld = &local_to_world;

	//
	//--------------------------------------------------------------
	// Check the orientation mode.  The first case is XY orientation
	//--------------------------------------------------------------
	//
	if (spec->m_alignZUsingX)
	{
		Stuff::Point3D
			camera_in_world(info->m_clipper->GetCameraToWorldMatrix());
		Stuff::Point3D card_in_world(local_to_world);
		Stuff::Vector3D look_at;
		look_at.Subtract(camera_in_world, card_in_world);
		if (spec->m_alignZUsingY)
			local_to_world.AlignLocalAxisToWorldVector(
				look_at,
				Stuff::Z_Axis,
				Stuff::Y_Axis,
				Stuff::X_Axis
			);
		else
			local_to_world.AlignLocalAxisToWorldVector(
				look_at,
				Stuff::Z_Axis,
				Stuff::X_Axis,
				-1
			);
	}

	//
	//-------------------------------------------------------
	// Each matrix needs to be aligned to the camera around Y
	//-------------------------------------------------------
	//
	else if (spec->m_alignZUsingY)
	{
		Stuff::Point3D
			camera_in_world(info->m_clipper->GetCameraToWorldMatrix());
		Stuff::Point3D card_in_world(local_to_world);
		Stuff::Vector3D look_at;
		look_at.Subtract(camera_in_world, card_in_world);
		local_to_world.AlignLocalAxisToWorldVector(
			look_at,
			Stuff::Z_Axis,
			Stuff::Y_Axis,
			-1
		);
	}

	//
	//----------------------------
	// Let our parent do its thing
	//----------------------------
	//
	info->m_clipper->DrawScalableShape(&dinfo);
	Singleton::Draw(info);
}
Esempio n. 3
0
//------------------------------------------------------------------------------
//
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
		//--------------------------------------------------------------
		//
		uint32_t i;
		uint32_t 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
						//-------------------------------------------------
						//
						float 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
						//-------------------------------------------------
						//
						float 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
					//-------------------------------------------------
					//
					float 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
					//-------------------------------------------------
					//
					float 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);
}
Esempio n. 4
0
//------------------------------------------------------------------------------
//
void gosFX::Card::Draw(DrawInfo *info)
{
    Check_Object(this);
    Check_Object(info);

    //
    //----------------------------
    // Set up the common draw info
    //----------------------------
    //
    MidLevelRenderer::DrawEffectInformation dInfo;
    dInfo.effect = m_cardCloud;
    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
    //--------------------------------------------------------------
    //
    if (spec->m_alignZUsingX)
    {
        Stuff::Point3D
        camera_in_world(info->m_clipper->GetCameraToWorldMatrix());
        Stuff::Point3D card_in_world(local_to_world);
        Stuff::Vector3D look_at;
        look_at.Subtract(camera_in_world, card_in_world);
        if (spec->m_alignZUsingY)
            local_to_world.AlignLocalAxisToWorldVector(
                look_at,
                Stuff::Z_Axis,
                Stuff::Y_Axis,
                Stuff::X_Axis
            );
        else
            local_to_world.AlignLocalAxisToWorldVector(
                look_at,
                Stuff::Z_Axis,
                Stuff::X_Axis,
                -1
            );
    }

    //
    //-------------------------------------------------------
    // Each matrix needs to be aligned to the camera around Y
    //-------------------------------------------------------
    //
    else if (spec->m_alignZUsingY)
    {
        Stuff::Point3D
        camera_in_world(info->m_clipper->GetCameraToWorldMatrix());
        Stuff::Point3D card_in_world(local_to_world);
        Stuff::Vector3D look_at;
        look_at.Subtract(camera_in_world, card_in_world);
        local_to_world.AlignLocalAxisToWorldVector(
            look_at,
            Stuff::Z_Axis,
            Stuff::Y_Axis,
            -1
        );
    }

    //
    //---------------------
    // Now just do the draw
    //---------------------
    //
    info->m_clipper->DrawEffect(&dInfo);
    Singleton::Draw(info);
}