Ejemplo n.º 1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// return:  true=math good, false=math unstable
bool
gosFX::SplineCurve::SetCurve(
							 Stuff::Scalar v0,
							 Stuff::Scalar v1
							 )
{
	Check_Object(this);
	
	m_a = 0.0f;
	m_b = 0.0f;
	m_slope = v1 - v0;
	m_value = v0;
	return Stuff::Close_Enough(m_slope + v0, v1);
}
Ejemplo n.º 2
0
//------------------------------------------------------------------------------
//
gosFX::ShapeCloud*
	gosFX::ShapeCloud::Make(
		Specification *spec,
		unsigned flags
	)
{
	Check_Object(spec);

	gos_PushCurrentHeap(Heap);
	ShapeCloud *cloud = new gosFX::ShapeCloud(spec, flags);
	gos_PopCurrentHeap();

	return cloud;
}
Ejemplo n.º 3
0
//
//#############################################################################
// GetSize
//#############################################################################
//
CollectionSize
	PlugIterator::GetSize()
{
	Check_Object(this);
	CollectionSize i = 0;

	First();
	while (GetCurrentImplementation() != NULL)
	{
		i++;
      Next();
	}
	return i;
}
Ejemplo n.º 4
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void 
gosFX::ComplexCurve::Load(
	Stuff::MemoryStream *stream,
	int gfx_version
)
{
	Check_Pointer(this);
	Check_Object(stream);

	if (gfx_version < 15)
	{
		Stuff::Scalar duration;
		*stream >> duration;
	}
Ejemplo n.º 5
0
//------------------------------------------------------------------------------
//
gosFX::CardCloud__Specification::CardCloud__Specification(
	std::iostream stream, uint32_t gfx_version)
	: SpinningCloud__Specification(gosFX::CardCloudClassID, stream, gfx_version)
{
	// Check_Pointer(this);
	Check_Object(stream);
	_ASSERT(m_class == CardCloudClassID);
	// _ASSERT(gos_GetCurrentHeap() == Heap);
	m_halfHeight.Load(stream, gfx_version);
	m_aspectRatio.Load(stream, gfx_version);
	//
	//-------------------------------------------------------------------
	// If we are reading an old version of the card cloud, ignore all the
	// animation on the UV channels
	//-------------------------------------------------------------------
	//
	if (gfx_version < 10)
	{
		m_pIndex.m_ageCurve.SetCurve(0.0f);
		m_pIndex.m_seedCurve.SetCurve(1.0f);
		m_pIndex.m_seeded = false;
		SeededCurveOf<ComplexCurve, LinearCurve, Curve::e_ComplexLinearType> temp;
		temp.Load(stream, gfx_version);
		float v = temp.ComputeValue(0.0f, 0.0f);
		m_UOffset.SetCurve(v);
		temp.Load(stream, gfx_version);
		v = temp.ComputeValue(0.0f, 0.0f);
		m_VOffset.SetCurve(v);
		m_USize.Load(stream, gfx_version);
		m_VSize.Load(stream, gfx_version);
		m_animated = false;
	}
	//
	//------------------------------
	// Otherwise, read in the curves
	//------------------------------
	//
	else
	{
		m_pIndex.Load(stream, gfx_version);
		m_UOffset.Load(stream, gfx_version);
		m_VOffset.Load(stream, gfx_version);
		m_USize.Load(stream, gfx_version);
		m_VSize.Load(stream, gfx_version);
		*stream >> m_animated;
	}
	SetWidth();
	m_totalParticleSize = gosFX::CardCloud::ParticleSize;
	m_particleClassSize = sizeof(gosFX::CardCloud::Particle);
}
Ejemplo n.º 6
0
//------------------------------------------------------------------------------
//
void gosFX::CardCloud__Specification::Save(std::iostream stream)
{
	// Check_Object(this);
	Check_Object(stream);
	SpinningCloud__Specification::Save(stream);
	m_halfHeight.Save(stream);
	m_aspectRatio.Save(stream);
	m_pIndex.Save(stream);
	m_UOffset.Save(stream);
	m_VOffset.Save(stream);
	m_USize.Save(stream);
	m_VSize.Save(stream);
	*stream << m_animated;
}
Ejemplo n.º 7
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLR_I_L_TMesh*
	MLR_I_L_TMesh::Make(
		MemoryStream *stream,
		int version
	)
{
	Check_Object(stream);

	gos_PushCurrentHeap(Heap);
	MLR_I_L_TMesh *mesh = new MLR_I_L_TMesh(DefaultData, stream, version);
	gos_PopCurrentHeap();

	return mesh;
}
Ejemplo n.º 8
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	MLR_I_C_DT_PMesh::GetColorData(
#if COLOR_AS_DWORD
		DWORD **data,
#else
		RGBAColor **data,
#endif
		int *dataSize
	)
{
	Check_Object(this); 
	*data = colors.GetData();
	*dataSize = colors.GetLength();
}
Ejemplo n.º 9
0
		virtual void SetReferenceState(const MLRState& _state, size_t pass = 0)
		{
			Check_Object(this);
			Verify((intptr_t(pass) >= 0) && pass < 2);
			if(pass == 0)
			{
				referenceState = _state;
			}
			else
			{
				passes = 2;
				referenceState2 = _state;
			}
		}
Ejemplo n.º 10
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void 
	MLRNGonCloud::Draw (DrawEffectInformation *dInfo, GOSVertexPool *allVerticesToDraw, MLRSorter *sorter)
{
	Check_Object(this);

	worldToEffect.Invert(*dInfo->effectToWorld);

	Transform(*usedNrOfNGons, numOfVertices);

	if( Clip(dInfo->clippingFlags, allVerticesToDraw) )
	{
		sorter->AddEffect(this, dInfo->state);
	}
}
Ejemplo n.º 11
0
			GOSVertex*
				GetActualVertexPool(bool db=false)
					{ 
						Check_Object(this); 

						if(db)
						{
							return verticesDB.GetData(); 
						}
						else
						{
							return (GOSVertex*)((char*)(vertices.GetData() + lastUsed)+vertexAlignment); 
						}
					}
Ejemplo n.º 12
0
		void
			SetAnimateTexture(bool yesNo)
				{
					Check_Object(this);
					if(yesNo==true)
					{
						textureMatrixIsIdentity = false;
					}
					else
					{
						textureMatrixIsIdentity = true;
						textureMatrix = Stuff::AffineMatrix4D::Identity;
					}
				}
Ejemplo n.º 13
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
bool
gosFX::Curve::IsComplex()
{
	Check_Object(this);
	return
		m_type == e_ComplexLinearType     ||
		m_type == e_ComplexComplexType	||
		m_type == e_ComplexSplineType		||
		m_type == e_ConstantComplexType	||
		m_type == e_ConstantLinearType	||
		m_type == e_ConstantSplineType	||
		m_type == e_SplineSplineType	||
		m_type == e_SplineLinearType;
}
Ejemplo n.º 14
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
Note::GetEntry(UnitQuaternion *value)
{
    Check_Object(this);
    Check_Pointer(value);

    const char *contents = NULL;
    GetEntry(&contents);
    Check_Pointer(contents);
    YawPitchRoll ypr;
    int count =
        sscanf(
            contents,
            "%f %f %f",
            &ypr.yaw,
            &ypr.pitch,
            &ypr.roll
        );
    if (count != 3)
    {
        Page *page = m_page;
        Check_Object(page);
        NotationFile *file = page->m_notationFile;
        Check_Object(file);
        STOP((
                 "%s: {[%s]%s=%s} is not a UnitQuaternion!",
                 file->GetFileName(),
                 page->m_name,
                 m_name,
                 contents
             ));
    }
    ypr.yaw *= Radians_Per_Degree;
    ypr.pitch *= Radians_Per_Degree;
    ypr.roll *= Radians_Per_Degree;
    *value = ypr;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRIndexedPrimitive::MLRIndexedPrimitive(
	ClassData *class_data,
	MemoryStream *stream,
	int version
):
	MLRPrimitive(class_data, stream, version)
{
	Check_Pointer(this);
	Check_Object(stream);

	MemoryStreamIO_Read(stream, &index);

	visibleIndexedVerticesKey = false;
	visibleIndexedVertices.SetLength(numVertices);
}
Ejemplo n.º 16
0
//
//###########################################################################
// Next
//###########################################################################
//
void
	HashIterator::Next()
{
	Check_Object(this);
	if (vchainIterator != NULL)
	{
		Check_Object(vchainIterator);

		if (vchainIterator->GetCurrentPlug() != NULL)
		{
			//
			// Try to step to the next item in this list
			//
			vchainIterator->Next();
		}
		if (vchainIterator->GetCurrentPlug() == NULL)
		{
			//
			// At end of list, step to the next list
			//
			NextSortedChainIterator(currentPosition+1);
		}
	}
}
Ejemplo n.º 17
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	MLRLookUpLight::Write(Stuff::Page *page)
{
	Check_Object(this);
	Check_Object(page);

	MLRInfiniteLight::Write(page);

	char data[256];

	sprintf(data, "%f %f %f", mapOrigin.x, mapOrigin.y, mapOrigin.z);
	Verify(strlen(data) < sizeof(data));
	page->SetEntry("MapOrigin", data);

	sprintf(data, "%d %d", mapZoneCountX, mapZoneCountZ);
	Verify(strlen(data) < sizeof(data));
	page->SetEntry("MapSize", data);

	sprintf(data, "%f %f", zoneSizeX, zoneSizeZ);
	Verify(strlen(data) < sizeof(data));
	page->SetEntry("ZoneSize", data);

	page->SetEntry("MapName", mapName);
}
Ejemplo n.º 18
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	MLR_I_L_TMesh::SetNormalData(
		const Vector3D *data,
		int dataSize
	)
{
	Check_Object(this); 
	Check_Pointer(data);

	Verify(coords.GetLength() == 0 || dataSize == coords.GetLength());
	Verify(colors.GetLength() == 0 || dataSize == colors.GetLength());
	Verify(texCoords.GetLength() == 0 || dataSize == texCoords.GetLength());

	normals.AssignData(data, dataSize);
}
Ejemplo n.º 19
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// return:  true=math good, false=math unstable
bool
gosFX::CurveKey::SetLinearKey(
	float key_time,
	float v0,
	float v1,
	float dt
)
{
	Check_Object(this);
	Verify(dt > Stuff::SMALL);
	m_time = key_time;
	m_slope = (v1 - v0) / dt;
	m_value = v0;
	return Stuff::Close_Enough(m_slope * dt + v0, v1);
}
Ejemplo n.º 20
0
//------------------------------------------------------------------------------
//
gosFX::Effect__Specification*
	gosFX::Effect__Specification::Make(
		Stuff::MemoryStream *stream,
		int gfx_version
	)
{
	Check_Object(stream);

	gos_PushCurrentHeap(Heap);
	Effect__Specification *spec =
		new gosFX::Effect__Specification(EffectClassID, stream, gfx_version);
	gos_PopCurrentHeap();

	return spec;
}
Ejemplo n.º 21
0
	void
		Spew(
			const char* group,
			const EulerAngles &angle
		)
	{
		Check_Object(&angle);
		SPEW((group, "<+"));
		Spew(group, angle.pitch);
		SPEW((group, ",+"));
		Spew(group, angle.yaw);
		SPEW((group, ",+"));
		Spew(group, angle.roll);
		SPEW((group, ">+"));
	}
Ejemplo n.º 22
0
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	//
	Trace::Trace(
		const char* name,
		Type type 
	):
		Plug(DefaultData)
	{
		traceNumber = NextTraceID++;
		traceType = (BYTE)type;
		traceName = name;
		
		lastActivity = 0.0;

		Check_Object(TraceManager::Instance);
		TraceManager::Instance->Add(this);
	}
Ejemplo n.º 23
0
//------------------------------------------------------------------------------
//
gosFX::ShapeCloud__Specification*
	gosFX::ShapeCloud__Specification::Make(
		Stuff::MemoryStream *stream,
		int gfx_version
	)
{
	Check_Object(stream);

	gos_PushCurrentHeap(Heap);
	ShapeCloud__Specification *spec =
		new gosFX::ShapeCloud__Specification(stream, gfx_version);
	gos_PopCurrentHeap();

	return spec;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	MLRIndexedPrimitive::SetIndexData(
		unsigned short *index_array,
		int index_count
	)
{
	Check_Object(this); 
	Check_Pointer(index_array);

	if(coords.GetLength() > 0)
	{
		visibleIndexedVertices.SetLength(coords.GetLength());
	}

	index.AssignData(index_array, index_count);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	MLRIndexedPrimitive::Transform(Matrix4D *mat)
{
	Check_Object(this);

	int i, len = coords.GetLength();

	for(i=0;i<len;i++)
	{
		transformedCoords[i].Multiply(coords[i], *mat);
	}
	
	#ifdef LAB_ONLY
		Statistics::MLR_TransformedVertices += len;
	#endif
}
Ejemplo n.º 26
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
bool
	MLR_I_L_TMesh::Copy(MLR_I_L_PMesh *pMesh)
{
	Check_Pointer(this);
	Check_Object(pMesh);

	int len;
	Vector3D *_normals;

	MLR_I_C_TMesh::Copy(pMesh);

	pMesh->GetNormalData(&_normals, &len);
	SetNormalData(_normals, len);

	return true;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
int
	MLRIndexedPolyMesh::FindBackFace(const Point3D& u)
{
	Check_Object(this);

	int i, numPrimitives = GetNumPrimitives();
	int ret = 0, len = lengths.GetLength();
	unsigned char *iPtr;
	Plane *p;

	if(len <= 0)
	{
		visible = 0;

		return 0;
	}

	p = &facePlanes[0];
	iPtr = &testList[0];

	if(state.GetBackFaceMode() == MLRState::BackFaceOffMode)
	{
		ResetTestList();
		ret = 1;
	}
	else
	{
		for(i=0;i<numPrimitives;i++,p++,iPtr++)
		{
//			Scalar s = p->DistanceTo(u);

//			*iPtr = !Get_Sign_Bit(s);

			*iPtr = (p->DistanceTo(u) >= 0.0f) ? (unsigned char)1: (unsigned char)0;
			
			ret += *iPtr;
		}

		visible = ret ? (unsigned char)1 : (unsigned char)0;
	}

	visible = ret ? (unsigned char)1 : (unsigned char)0;

	FindVisibleVertices();

	return ret;
}
Ejemplo n.º 28
0
//
//#############################################################################
//#############################################################################
//
Scalar
	UnitQuaternion::GetAngle()
{
	Check_Object(this);

	Scalar sine_of_half = Sqrt(x*x + y*y + z*z);
	if (Small_Enough(sine_of_half))
	{
		return 0.0f;
	}

	SinCosPair half_angle(sine_of_half, w);
	Radian angle;
	angle = half_angle;

	return angle * 2.0f;
}
Ejemplo n.º 29
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
Note::SetEntry(const RGBColor &value)
{
    Check_Object(this);

    static char
    contents[32];
    sprintf(
        contents,
        "%f %f %f",
        value.red,
        value.green,
        value.blue
    );
    Verify(strlen(contents) < sizeof(contents));
    SetEntry(contents);
}
Ejemplo n.º 30
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
Note::SetEntry(const YawPitchRoll &value)
{
    Check_Object(this);

    static char
    contents[32];
    sprintf(
        contents,
        "%f %f %f",
        value.yaw * Degrees_Per_Radian,
        value.pitch * Degrees_Per_Radian,
        value.roll * Degrees_Per_Radian
    );
    Verify(strlen(contents) < sizeof(contents));
    SetEntry(contents);
}