vec3_t *G2Exporter_Surface_GetVertNormal(int iSurfaceIndex, int iVertIndex, int iLODIndex)
{
	static vec3_t v3={0};
	memset(v3,0,sizeof(v3));

	if (iLODIndex == giNumLODs-1)
	{
		// q3data surface...
		//
		if (iSurfaceIndex < giNumSurfaces)
		{
			// standard surface...
			//
			md3SurfaceData_t *pSurfaceData = GetMD3SurfaceData(iSurfaceIndex);
			if (pSurfaceData)
			{
				// this logic is kinda gay, not sure why the *6 etc, but that's how other q3data code works, so...
				//
				float **ppVerts = pSurfaceData->verts;
				memcpy(v3,(vec3_t*) &ppVerts[0][iVertIndex*6+3], sizeof(v3));

				{		
					Matrix4 Swap;
							Swap.Identity();
					
					if (1)
					{
						Swap.SetRow(0,Vect3(0.0f,-1.0f,0.0f));
						Swap.SetRow(1,Vect3(1.0f,0.0f,0.0f));
					}
					Swap.CalcFlags();

					Vect3 v3In((const float *)v3);
					static Vect3 v3Out;
					Swap.XFormVect(v3Out,v3In);
					return (vec3_t*) &v3Out;
				}
			}
		}
		else
		{
			// tag surface...
			//
			// I don't think tag-surfaces normals have any meaning for ghoul2, so...
			//		
			return &v3;
		}
	}
	else
	{
		// imported surface...
		//
		vec3_t &v3Src = ImportedModel.ImportedLODs[iLODIndex].ImportedSurfaces[ImportedModel.SurfaceIndexRemaps[iSurfaceIndex]].ImportedVerts[iVertIndex].normal;
		memcpy(v3,v3Src,sizeof(v3));
		return &v3;
	}

	assert(0);	
	return &v3;
}
Beispiel #2
0
void SbTrail::Update()
{
	const BtFloat tick = BtTime::GetTick();

	BtCollectionIterator< MuTrailBit, MaxTrail > iterator(m_trail);

	for(MuTrailBit* pTrail = iterator.GetFirstElement(); pTrail; pTrail = iterator.GetNextElement())
	{
		pTrail->m_tick++;

		if(((BtFloat)pTrail->m_tick) * tick > TrailDuration)
		{
			iterator.DeleteElement();
		}
	}

	m_points.Empty();

	MuTrailBit *pTrail = iterator.GetTailElement();

	if(pTrail != BtNull)
	{
		// Cache the last point
		MtVector3 v3Last = pTrail->m_v3Position;

		const BtFloat width = 0.1f;

		// Extract the points to an array
		for(; pTrail; pTrail = iterator.GetPreviousElement())
		{
			MtVector3 v3Position = pTrail->m_v3Position;

			BtFloat alpha = 1.0f - (((BtFloat)pTrail->m_tick) * BtTime::GetTick() / TrailDuration);

			MuTrailBit trail;
			trail.m_alpha = alpha;

			MtVector3 v3In(0, 0, 1);

			MtVector3 v3Result = pTrail->m_v3Cross.GetNormalise();

			v3Result = v3Result * width;

			trail.m_v3Left = v3Position - v3Result;
			trail.m_v3Right = v3Position + v3Result;
			trail.m_id = pTrail->m_id;
			trail.m_colour = pTrail->m_colour;
			trail.m_colour.Alpha(alpha * 0.5f);

			m_points.Add(trail);

			v3Last = v3Position;
		}
	}
}
vec3_t *G2Exporter_Surface_GetVertCoords(int iSurfaceIndex, int iVertIndex, int iLODIndex)
{
	static vec3_t v3={0};
	memset(&v3,0,sizeof(v3));

	if (iLODIndex == giNumLODs-1)
	{
		// q3data surface...
		//
		if (iSurfaceIndex < giNumSurfaces)
		{
			// standard surface...
			//
			md3SurfaceData_t *pSurfaceData = GetMD3SurfaceData(iSurfaceIndex);
			if (pSurfaceData)
			{
				// this logic is kinda gay, not sure why the *6 etc, but that's how other q3data code works, so...
				//
				float **ppVerts = pSurfaceData->verts;
				static vec3_t v3;
				for (int i=0; i<3; i++)
				{
					v3[i] = ppVerts[0][iVertIndex*6+i];// /MD3_XYZ_SCALE;
				}
				// return &v3;
					
				Matrix4 Swap;
						Swap.Identity();
				
				if (1)
				{
					Swap.SetRow(0,Vect3(0.0f,-1.0f,0.0f));
					Swap.SetRow(1,Vect3(1.0f,0.0f,0.0f));
				}
				Swap.CalcFlags();

				Vect3 v3In((const float *)v3);
				static Vect3 v3Out;
				Swap.XFormVect(v3Out,v3In);
				return (vec3_t*) &v3Out;
			}
		}
		else
		{
			// tag surface...
			//
			assert(iVertIndex<3);

			md3Tag_t *pTag = &g_data.tags[0][iSurfaceIndex - giNumSurfaces];			
			vec3_t v3New;

	//#ifdef PERFECT_CONVERSION
			
			v3New[0] = pTag->axis[0][iVertIndex] ;
			v3New[1] = pTag->axis[1][iVertIndex] ;
			v3New[2] = pTag->axis[2][iVertIndex] ;

			// don't worry about how this crap works, it just does (arrived at by empirical methods... :-)
			//
			//  (mega-thanks to Gil as usual)
			//
			if (iVertIndex==2)
			{
				VectorCopy(pTag->origin,v3);
			}
			else
			if (iVertIndex==1)
			{
				v3New[0] =   2.0f * pTag->axis[1][iG2_TRISIDE_MIDDLE];
				v3New[1] = -(2.0f * pTag->axis[0][iG2_TRISIDE_MIDDLE]);
				v3New[2] =   2.0f * pTag->axis[2][iG2_TRISIDE_MIDDLE];
				
				VectorSubtract(pTag->origin,v3New,v3);
			}
			else
			{					
				v3New[0] =  pTag->axis[1][iG2_TRISIDE_LONGEST];
				v3New[1] = -pTag->axis[0][iG2_TRISIDE_LONGEST];
				v3New[2] =  pTag->axis[2][iG2_TRISIDE_LONGEST];
				
				VectorSubtract(pTag->origin,v3New,v3);
			}

	//		return (vec3_t*) &v3;

			Matrix4 Swap;
					Swap.Identity();
			
			if (1)
			{
				Swap.SetRow(0,Vect3(0.0f,-1.0f,0.0f));
				Swap.SetRow(1,Vect3(1.0f,0.0f,0.0f));
			}
			Swap.CalcFlags();

			Vect3 v3In((const float *)v3);
			static Vect3 v3Out;
			Swap.XFormVect(v3Out,v3In);

			return (vec3_t*) &v3Out;
		}
	}
	else
	{
		// imported surface...
		//
		vec3_t &v3Src = ImportedModel.ImportedLODs[iLODIndex].ImportedSurfaces[ImportedModel.SurfaceIndexRemaps[iSurfaceIndex]].ImportedVerts[iVertIndex].vertCoords;
		memcpy(v3,v3Src,sizeof(v3));
		return &v3;
	}

	assert(0);
	return &v3;
}