Ejemplo n.º 1
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);
}
Ejemplo n.º 2
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);
}