Ejemplo n.º 1
0
	void SpriteCollisionModel::ReplaceTriangle(
		const SpriteCollisionTriangle &triangle, Int index)
	{
		if (0 > index || GetNumTriangles() <= index)
			Exception::Throw(kExceptionOutOfRange, String("(%s: %d)",
				FastFunctionName, index));
		mTriangles.Replace(triangle, index);
	}
Ejemplo n.º 2
0
	const SpriteCollisionTriangle& SpriteCollisionModel::GetTriangle(
		Int index) const
	{
		if (0 > index || GetNumTriangles() <= index)
			Exception::Throw(kExceptionOutOfRange, String("(%s: %d)",
				FastFunctionName, index));
		return mTriangles[index];
	}
Ejemplo n.º 3
0
	void VulkanRenderer::OutputLog(std::ostream & fout)
	{
		fout << GetName() << "\n[" << GetNumVertices() << " vertices] [" << GetNumTriangles() << " triangles] [" << GetNumObjects() << " objects]" << std::endl;
		fout << "Threads: " << GetNumThreads() << std::endl;

		if(mUseInstancing)
			fout << "Pipeline: " << "Instancing" << std::endl;
		else if (mUseStaticCommandBuffer)
			fout << "Pipeline: " << "Static command buffers" << std::endl;
		else
			fout << "Pipeline: " << "Basic" << std::endl;
	}
Ejemplo n.º 4
0
void TTriGridVel::DrawContourLine(short *ix, short *iy, double** contourValue,Boolean showvals,double level)
{
	long i,j,k,p,p1,p2,p3,count=0;
	long x0,y0,xold,yold;
	long miny0, maxy0, avex0, avey0, ave;
	float trival[3];
	float max,min,diff;
	long ntri = GetNumTriangles();
	TopologyHdl topH = 0;
	if (!contourValue) return;
	if (!fDagTree) return;

	topH = fDagTree->GetTopologyHdl();
	if (!topH) return;

	miny0 = 500;
	maxy0 = -500;
	avey0 = 500;
	for(i=0;i< ntri;i++)
	{
		p1 = (*topH)[i].vertex1;
		p2 = (*topH)[i].vertex2;
		p3 = (*topH)[i].vertex3;
		//GetTriVertices(i,&p1,&p2,&p3);
		trival[0]=(*contourValue)[p1];trival[1]=(*contourValue)[p2];trival[2]=(*contourValue)[p3];
		for(;;)
		{
			if((trival[0]>=trival[1])&&(trival[0]>=trival[2]))
			{
				max=trival[0];
				if(trival[1]<=trival[2]){min=trival[1];}else{min=trival[2];}
				break;
			}
			if((trival[1]>=trival[2])&&(trival[1]>=trival[0]))
			{
				max=trival[1];
				if(trival[2]<=trival[0]){min=trival[2];}else{min=trival[0];}
				break;
			}
			if((trival[2]>=trival[0])&&(trival[2]>=trival[0]))
			{
				max=trival[2];
				if(trival[0]<=trival[1]){min=trival[0];}else{min=trival[1];}
				break;
			}
		}
		if(level<min)continue;
		if(level>max)continue;
		if(max==min){// Don't draw constant contour
			//MyMoveTo(ix[p1],iy[p1]);
			//MyLineTo(ix[p2],iy[p2]);
			//MyLineTo(ix[p3],iy[p3]);
			//MyLineTo(ix[p1],iy[p1]);
			//DrawContourLevelValue((ix[p1]+ix[p2])>>1,(iy[p1]+iy[p2])>>1,level);
		}
		else
		{
			j=0;
			for(k=0;k<3;k++)
			{ 
				trival[0]=(*contourValue)[p1];trival[1]=(*contourValue)[p2];trival[2]=(*contourValue)[p3];
				if(trival[0]>trival[1])
				{
					max=trival[0];min=trival[1];
				}
				else
				{
					max=trival[1];	min=trival[0];
				}
				
				diff=trival[0]-trival[1];
				if((diff==0)&&(max==level))
				{
					MyMoveTo(ix[p1],iy[p1]); MyLineTo(ix[p2],iy[p2]);
					xold = ix[p1]; yold = iy[1]; x0 = ix[2]; y0 = iy[p2];
					avex0=(ix[p1]+ix[p2])>>1;  avey0=(iy[p1]+iy[p2])>>1;
					break;
				}
				if((level<=max)&&(level>min))
				{
					x0=(short)(((float)ix[p1])*(level-trival[1])/diff+((float)ix[p2])*(trival[0]-level)/diff);
					y0=(short)(((float)iy[p1])*(level-trival[1])/diff+((float)iy[p2])*(trival[0]-level)/diff);
					if(y0<miny0) miny0 = y0;
					if(y0>maxy0) maxy0 = y0;
					ave = (maxy0 - miny0)/2 + miny0;
					if(fabs((float)(y0 - ave)) < fabs((float)(avey0 - ave)))
					//if(fabs(y0 - ave) < fabs(avey0 - ave))	// new Windows compiler stricter
					{
						avex0 = x0;avey0 = y0;
					}
					j++;  
					if(j==1)
					{
						MyMoveTo(x0,y0);
						xold = x0;yold = y0;
						if(showvals)
						{
						//	DrawContourLevelValue((xold+x0)>>1, (yold+y0)>>1,level);
						}
					}
					else
					{						
						// may want to be able to set number of labels
						MyLineTo(x0,y0);
						// we are using a legend instead of the labels
						/*if(showvals && (++count % 12 == 0))
						{
							count = 0;
							DrawContourLevelValue((xold+x0)>>1, (yold+y0)>>1,level);

						}*/
						break;
					}
				}
				p=p1;p1=p2;p2=p3;p3=p;
			}
		}
	}
Ejemplo n.º 5
0
  void Mesh::AddData(const Mesh& mesh, const ezTransform& transform)
  {
    ezMat4 transformMat = transform.GetAsMat4();
    ezMat4 normalTransformMat = transformMat.GetInverse(0.0f).GetTranspose();

    // Create new triangles.
    ezUInt32 oldTriangleCount = GetNumTriangles();
    AddTriangles(mesh.GetNumTriangles());

    ezArrayPtr<const Mesh::Triangle> sourceTriangles = mesh.GetTriangles();
    ezArrayPtr<const Mesh::Triangle> targetTriangles = GetTriangles().GetSubArray(oldTriangleCount);
    EZ_ASSERT_DEBUG(sourceTriangles.GetCount() == targetTriangles.GetCount(), "Something is wrong with triangle allocation!");

    for (auto it = mesh.m_VertexDataStreams.GetIterator(); it.IsValid(); ++it)
    {
      const VertexDataStream* sourceStream = it.Value();
      VertexDataStream* targetStream = AddDataStream(static_cast<ezGALVertexAttributeSemantic::Enum>(it.Key()),
                                                     sourceStream->GetNumElementsPerVertex(), sourceStream->GetElementType());
      if (!targetStream)
      {
        ezLog::SeriousWarning("Cannot merge mesh {0} properly since it has a vertex data stream with semantic {1} that uses {2} elements "
                              "instead of 'unkown' which is used by the merge target. Skipping this data stream.",
                              mesh.m_Name, it.Key(), sourceStream->GetNumElementsPerVertex());
        continue;
      }

      // Copy data.
      ezUInt32 targetBaseDataIndex = targetStream->m_Data.GetCount();
      targetStream->m_Data.PushBackRange(sourceStream->m_Data);

      // Transform data.
      if (!transform.IsIdentical(ezTransform::IdentityTransform()))
      {
        const ezUInt32 attributeSize = targetStream->GetAttributeSize();

        // Positions
        if (it.Key() == ezGALVertexAttributeSemantic::Position)
        {
          for (ezUInt32 i = targetBaseDataIndex; i < targetStream->m_Data.GetCount(); i += attributeSize)
          {
            ezVec3& pos = *reinterpret_cast<ezVec3*>(&targetStream->m_Data[i]);
            pos = transformMat.TransformPosition(pos);
          }
        }
        // Directions
        else if (it.Key() == ezGALVertexAttributeSemantic::Normal || it.Key() == ezGALVertexAttributeSemantic::Tangent ||
                 it.Key() == ezGALVertexAttributeSemantic::BiTangent)
        {
          for (ezUInt32 i = targetBaseDataIndex; i < targetStream->m_Data.GetCount(); i += attributeSize)
          {
            ezVec3& dir = *reinterpret_cast<ezVec3*>(&targetStream->m_Data[i]);
            dir = normalTransformMat.TransformDirection(dir);
          }
        }
      }

      // Set mapping
      for (ezUInt32 tri = 0; tri < sourceTriangles.GetCount(); ++tri)
      {
        for (int v = 0; v < 3; ++v)
        {
          VertexDataIndex sourceDataIndex = sourceStream->GetDataIndex(sourceTriangles[tri].m_Vertices[v]);
          if (sourceDataIndex.IsValid())
            targetStream->SetDataIndex(targetTriangles[tri].m_Vertices[v], targetBaseDataIndex + sourceDataIndex.GetValue());
        }
      }
    }

    // Add submeshes.
    ezUInt32 oldSubMeshCount = m_SubMeshes.GetCount();
    m_SubMeshes.PushBackRange(mesh.m_SubMeshes);
    for (ezUInt32 i = oldSubMeshCount; i < m_SubMeshes.GetCount(); ++i)
    {
      m_SubMeshes[i].m_uiFirstTriangle += oldTriangleCount;
    }

    // Add skeleton if existent
    // TODO: What if multiple, incompatible skeletons are found(?)
    // For now: Remove skeleton and import unskinned
    // if (mesh.m_pSkeleton)
    //{
    //  if (m_pSkeleton)
    //  {
    //    if (!m_pSkeleton->IsCompatibleWith(mesh.m_pSkeleton.Borrow()))
    //    {
    //      ezLog::Warning("Found incompatible skeletons during mesh merging in mesh '{0}', import will be without skeletons!",
    //      m_Name.GetData()); m_pSkeleton.Reset();
    //    }
    //  }
    //  else
    //  {
    //    m_pSkeleton = EZ_DEFAULT_NEW(ezSkeleton, *mesh.m_pSkeleton);
    //  }
    //}
  }
Ejemplo n.º 6
0
	void SpriteCollisionModel::ClearTriangles() {
		for (Int i = GetNumTriangles() - 1; i >= 0; i--)
			EraseTriangle(i);
	}
Ejemplo n.º 7
0
	void SpriteCollisionModel::EraseTriangle(Int index) {
		if (0 > index || GetNumTriangles() <= index)
			Exception::Throw(kExceptionOutOfRange, String("(%s: %d)",
				FastFunctionName, index));
		mTriangles.Erase(index);
	}