Esempio n. 1
0
void SkeletonDrawable::fill(DrawableStatsAttachment *pStat)
{
    if(pStat == NULL)
    {
        FINFO(("SkeletonDrawable::fill(DrawableStatsAttachment *): "
                          "No attachment given.\n"));
        return;
    }
    if(getSkeleton() == NULL)
    {
        FWARNING(("SkeletonDrawable::fill:: no skeleton!\n"));;
        return;
    }

    UInt32 NumLines(0);
    if(getDrawPose())
    {
        NumLines += getSkeleton()->getNumJoints()-1;
    }
    if(getDrawBindPose())
    {
        NumLines += getSkeleton()->getNumJoints()-1;
    }
    pStat->setLines    (NumLines);
}
Esempio n. 2
0
void SG_TextArea::UpdateRange() {
  float font_height = TTF_FontHeight(texture[state].CurrentFont());
  const TextGeometry *tgeom = texture[state].GetTextGeometry();

  if (tgeom->visible_xlines > 0) {
    SetXLimits(0.0, (float)(tgeom->text_xsize) / font_height);
    SetXSpan((float)(tgeom->visible_xlines));
  } else {
    SetXLimits(0.0, (float)(tgeom->text_xsize) / font_height);
    SetXSpan((float)(tgeom->text_xsize) / font_height);
  }

  if (tgeom->visible_ylines >
      0) {  // Allows scrolling before/after text vertically
    SetYLimits(-(float)(tgeom->visible_ylines),
               (float)(NumLines()) + (float)(tgeom->visible_ylines));
    SetYSpan((float)(tgeom->visible_ylines));
  } else {
    SetYLimits(-(float)(NumLines()), (float)(NumLines()) * 2.0);
    SetYSpan((float)(NumLines()));
  }
}
bool RedString::LineAtNum(const unsigned LineNum, RedString& Line) const
{
    unsigned iLineStartIndex, iLineLength, iCurrIndex;
    unsigned iOnLine;

    // initialise the return value
    Line = "";

    // initialise the working values
    iLineLength     = 0;
    iCurrIndex      = 0; 
    iOnLine         = 1;

    // Lines are indexed as we would want to see a position marker, from 1.
    // check we have enough lines to fullfill operation
    if ((LineNum > NumLines()) || (LineNum < 1))
        return false;

    // Loop to the first character of the line we need
    while (iOnLine < LineNum)
    {
        if ( data[iCurrIndex] == '\n' )
            iOnLine++;

         iCurrIndex++;
    }

    // mark the start of the line
    iLineStartIndex = iCurrIndex;

    // loop to the end of the line
    while ( (iCurrIndex<contentsize) && (data[iCurrIndex]!='\n') )
    {
        iCurrIndex++;
        iLineLength++;
    }

    // use the inbuilt routine to retrieve the section of line
    Line = SubStr(iLineStartIndex, iLineLength);

    return true;
}
Esempio n. 4
0
   }

   CreateHeap(&hashTableHeap,"hashTableHeap",MSTAK,1,0.5,5000,20000);

}



/* ----------- HLM Header Type and Operations -------------- */



typedef struct hdrField{

   char * name;

   char * value;

   struct hdrField * next;

} HdrField;



typedef struct lmFileHdrRec {

   MemHeap *mem;

   int numFields;

   struct hdrField *list;

}LMFileHdrRec;



/* NumLines: return num lines remaining in source and rewind it */

static int NumLines(Source *src, IOFilter filter)
Esempio n. 5
0
/**
 * Exports all geometry into a D3D .x file into the current working folder.
 * @param Filename	Desired filename (may include path)
 * @param bShow		Whether the D3D .x file viewer should be invoked. If shown, we'll block until it has been closed.
 */
void F3DVisualizer::Export( const TCHAR* Filename, bool bShow/*=false*/ )
{
	ID3DXMesh* Mesh;
	Mesh = NULL;
	int32 NumPrimitives = NumTriangles() + NumLines()*2;
	int32 NumVertices = NumTriangles()*3 + NumLines()*4;
	HRESULT Result = D3DXCreateMeshFVF( NumPrimitives, NumVertices, D3DXMESH_32BIT, D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_SPECULAR, D3D->D3DDevice, &Mesh );
	void* VertexBuffer = NULL;
	void* IndexBuffer = NULL;
	Result = Mesh->LockVertexBuffer(D3DLOCK_DISCARD, &VertexBuffer);
	Result = Mesh->LockIndexBuffer(D3DLOCK_DISCARD, &IndexBuffer);

	D3DXVertex* Vertices = (D3DXVertex*)VertexBuffer;
	uint32* Indices = (uint32*) IndexBuffer;
	int32 NumVerticesStored = 0;
	int32 NumIndicesStored = 0;

	// Add the triangles to the vertexbuffer and indexbuffer.
	for ( int32 TriangleIndex=0; TriangleIndex < NumTriangles(); ++TriangleIndex )
	{
		const FVector4& P1 = Triangles[TriangleIndex].Vertices[0];
		const FVector4& P2 = Triangles[TriangleIndex].Vertices[1];
		const FVector4& P3 = Triangles[TriangleIndex].Vertices[2];
		const FColor& Color = Triangles[TriangleIndex].Color;
		Vertices[NumVerticesStored+0].Pos[0] = P1[0];
		Vertices[NumVerticesStored+0].Pos[1] = P1[1];
		Vertices[NumVerticesStored+0].Pos[2] = P1[2];
		Vertices[NumVerticesStored+0].Color1 = Color.DWColor();
		Vertices[NumVerticesStored+0].Color2 = 0;
		Vertices[NumVerticesStored+1].Pos[0] = P2[0];
		Vertices[NumVerticesStored+1].Pos[1] = P2[1];
		Vertices[NumVerticesStored+1].Pos[2] = P2[2];
		Vertices[NumVerticesStored+1].Color1 = Color.DWColor();
		Vertices[NumVerticesStored+1].Color2 = 0;
		Vertices[NumVerticesStored+2].Pos[0] = P3[0];
		Vertices[NumVerticesStored+2].Pos[1] = P3[1];
		Vertices[NumVerticesStored+2].Pos[2] = P3[2];
		Vertices[NumVerticesStored+2].Color1 = Color.DWColor();
		Vertices[NumVerticesStored+2].Color2 = 0;

		// Reverse triangle winding order for the .x file.
		Indices[NumIndicesStored+0] = NumVerticesStored + 0;
		Indices[NumIndicesStored+1] = NumVerticesStored + 2;
		Indices[NumIndicesStored+2] = NumVerticesStored + 1;

		NumVerticesStored += 3;
		NumIndicesStored += 3;
	}

	// Add the lines to the vertexbuffer and indexbuffer.
	for ( int32 LineIndex=0; LineIndex < NumLines(); ++LineIndex )
	{
		const FVector4& P1 = Lines[LineIndex].Vertices[0];
		const FVector4& P2 = Lines[LineIndex].Vertices[1];
		const FColor& Color = Lines[LineIndex].Color;
		Vertices[NumVerticesStored+0].Pos[0] = P1[0];
		Vertices[NumVerticesStored+0].Pos[1] = P1[1] - 5.0f;
		Vertices[NumVerticesStored+0].Pos[2] = P1[2];
		Vertices[NumVerticesStored+0].Color1 = 0;
		Vertices[NumVerticesStored+0].Color2 = Color.DWColor();
		Vertices[NumVerticesStored+1].Pos[0] = P1[0];
		Vertices[NumVerticesStored+1].Pos[1] = P1[1] + 5.0f;
		Vertices[NumVerticesStored+1].Pos[2] = P1[2];
		Vertices[NumVerticesStored+1].Color1 = 0;
		Vertices[NumVerticesStored+1].Color2 = Color.DWColor();
		Vertices[NumVerticesStored+2].Pos[0] = P2[0];
		Vertices[NumVerticesStored+2].Pos[1] = P2[1] - 5.0f;
		Vertices[NumVerticesStored+2].Pos[2] = P2[2];
		Vertices[NumVerticesStored+2].Color1 = 0;
		Vertices[NumVerticesStored+2].Color2 = Color.DWColor();
		Vertices[NumVerticesStored+3].Pos[0] = P2[0];
		Vertices[NumVerticesStored+3].Pos[1] = P2[1] + 5.0f;
		Vertices[NumVerticesStored+3].Pos[2] = P2[2];
		Vertices[NumVerticesStored+3].Color1 = 0;
		Vertices[NumVerticesStored+3].Color2 = Color.DWColor();

		Indices[NumIndicesStored+0] = NumVerticesStored+0;
		Indices[NumIndicesStored+1] = NumVerticesStored+2;
		Indices[NumIndicesStored+2] = NumVerticesStored+1;
		Indices[NumIndicesStored+3] = NumVerticesStored+2;
		Indices[NumIndicesStored+4] = NumVerticesStored+3;
		Indices[NumIndicesStored+5] = NumVerticesStored+1;

		NumVerticesStored += 4;
		NumIndicesStored += 6;
	}

	Mesh->UnlockVertexBuffer();
	Mesh->UnlockIndexBuffer();
	Result = D3DXComputeNormals( Mesh, NULL );
	D3DXMATERIAL MeshMaterial;
	MeshMaterial.MatD3D.Ambient.r = 0.1f;
	MeshMaterial.MatD3D.Ambient.g = 0.1f;
	MeshMaterial.MatD3D.Ambient.b = 0.1f;
	MeshMaterial.MatD3D.Ambient.a = 0.0f;
	MeshMaterial.MatD3D.Diffuse.r = 1.0f;
	MeshMaterial.MatD3D.Diffuse.g = 1.0f;
	MeshMaterial.MatD3D.Diffuse.b = 1.0f;
	MeshMaterial.MatD3D.Diffuse.a = 1.0f;
	MeshMaterial.MatD3D.Emissive.r = 1.0f;
	MeshMaterial.MatD3D.Emissive.g = 1.0f;
	MeshMaterial.MatD3D.Emissive.b = 1.0f;
	MeshMaterial.MatD3D.Emissive.a = 1.0f;
	MeshMaterial.MatD3D.Specular.r = 1.0f;
	MeshMaterial.MatD3D.Specular.g = 1.0f;
	MeshMaterial.MatD3D.Specular.b = 1.0f;
	MeshMaterial.MatD3D.Specular.a = 1.0f;
	MeshMaterial.MatD3D.Power = 16.0f;
	MeshMaterial.pTextureFilename = NULL;

	D3DXEFFECTINSTANCE EffectInstance;
	EffectInstance.pEffectFilename = "D3DExport.fx";
	EffectInstance.NumDefaults = 0;
	EffectInstance.pDefaults = NULL;

	// Write out the .x file.
	D3DXSaveMeshToX( Filename, Mesh, NULL, &MeshMaterial, &EffectInstance, 1, D3DXF_FILEFORMAT_BINARY );
	Mesh->Release();

	// Write out the .fx file, if it doesn't always exist.
	HANDLE ShaderFile = CreateFile( TEXT("D3DExport.fx"), GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
	if (ShaderFile != INVALID_HANDLE_VALUE)
	{
		::DWORD BytesWritten;
		WriteFile(ShaderFile, ShaderFxFile, (uint32)FCStringAnsi::Strlen(ShaderFxFile), &BytesWritten, NULL);
		CloseHandle( ShaderFile );
	}

	// If specified, run the default viewer for .x files and block until it's closed.
	if ( bShow )
	{
		system( TCHAR_TO_ANSI(Filename) );
	}
}
Esempio n. 6
0
BOOL SaveChart (HWND hWndGraph, HANDLE hInputFile, BOOL bGetFileName)
   {
   PGRAPHSTRUCT   pGraph ;
   PLINE          pLine ;
   HANDLE         hFile ;
   DISKCHART      DiskChart ;
   PERFFILEHEADER FileHeader ;
   TCHAR          szFileName [256] ;
   BOOL           newFileName = FALSE ;

   if (hInputFile)
      {
      // use the input file handle if it is available
      // this is the case for saving workspace data
      hFile = hInputFile ;
      }
   else
      {
      if (pChartFullFileName)
         {
         lstrcpy (szFileName, pChartFullFileName) ;
         }
      if (bGetFileName || pChartFullFileName == NULL)
         {
//         if (!pChartFullFileName)
//            {
//            StringLoad (IDS_GRAPH_FNAME, szFileName) ;
//            }

         if (!FileGetName (hWndGraph, IDS_CHARTFILE, szFileName))
            {
            return (FALSE) ;
            }
         newFileName = TRUE ;
         }

      hFile = FileHandleCreate (szFileName) ;

      if (hFile && newFileName)
         {
         ChangeSaveFileName (szFileName, IDM_VIEWCHART) ;
         }
      else if (!hFile)
         {
         DlgErrorBox (hWndGraph, ERR_CANT_OPEN, szFileName) ;
         }
      }

   if (!hFile)
      return (FALSE) ;

   pGraph = pGraphs ;
   if (!pGraph)
      {
      if (!hInputFile)
         {
         CloseHandle (hFile) ;
         }
      return (FALSE) ;
      }

   if (!hInputFile)
      {
      // only need to write file header if not workspace 
      memset (&FileHeader, 0, sizeof (FileHeader)) ;
      lstrcpy (FileHeader.szSignature, szPerfChartSignature) ;
      FileHeader.dwMajorVersion = ChartMajorVersion ;
      FileHeader.dwMinorVersion = ChartMinorVersion ;
   
      if (!FileWrite (hFile, &FileHeader, sizeof (PERFFILEHEADER)))
         {
         goto Exit0 ;
         }
      }

   DiskChart.Visual = pGraph->Visual ;
   DiskChart.gOptions = pGraph->gOptions ;
   DiskChart.gMaxValues = pGraph->gMaxValues ;
   DiskChart.dwNumLines = NumLines (pGraph->pLineFirst) ;
   DiskChart.bManualRefresh = pGraph->bManualRefresh ;
   DiskChart.perfmonOptions = Options ;

   if (!FileWrite (hFile, &DiskChart, sizeof (DISKCHART)))
      {
      goto Exit0 ;
      }

   for (pLine = pGraph->pLineFirst ;
        pLine ;
        pLine = pLine->pLineNext)
      {  // for
      if (!WriteLine (pLine, hFile))
         {
         goto Exit0 ;
         }
      }  // for

   if (!hInputFile)
      {
      CloseHandle (hFile) ;
      }

   return (TRUE) ;

Exit0:
   if (!hInputFile)
      {
      CloseHandle (hFile) ;

      // only need to report error if not workspace 
      DlgErrorBox (hWndGraph, ERR_SETTING_FILE, szFileName) ;
      }
   return (FALSE) ;

   }  // SaveChart
Esempio n. 7
0
int LabelNode::GetHeight() {
	return m_nLineHeight*NumLines();
}