本文整理汇总了C++中FileSystem::GetModelsFolder方法的典型用法代码示例。如果您正苦于以下问题:C++ FileSystem::GetModelsFolder方法的具体用法?C++ FileSystem::GetModelsFolder怎么用?C++ FileSystem::GetModelsFolder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::GetModelsFolder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exception
//--------------------------------------------------------------------------------
GeometryPtr GeometryLoaderDX11::loadStanfordPlyFile( std::wstring filename, bool withAdjacency )
{
// Get the file path to the models
FileSystem fs;
filename = fs.GetModelsFolder() + filename;
// Load the contents of the file
std::ifstream fin;
// Open the file and read the MS3D header data
fin.open( filename.c_str(), std::ios::in );
if(!fin.is_open())
{
// signal error - bad filename?
throw new std::exception( "Could not open file" );
}
// Parse the input
std::string txt;
// Read in header
std::getline(fin, txt);
if( 0 != txt.compare( "ply" ) )
{
// signal error - not a PLY format file
throw new std::exception( "File does not contain the correct header - 'PLY' expected." );
}
std::getline(fin, txt);
if( 0 != txt.compare( "format ascii 1.0" ) )
{
// signal error - not a format of PLY that this code supports
throw new std::exception( "File is not correct format - ASCII 1.0 expected." );
}
std::vector< PlyElementDesc > elements;
// Read in the rest of the header
while(fin.is_open() && !fin.eof())
{
// Grab the next line of the header
std::getline(fin, txt);
// If we're at the end then stop processing
if(0 == txt.compare("end_header"))
{
break;
}
// If this line is a comment, skip to the next line
else if(0 == txt.compare(0, 7, "comment"))
{
continue;
}
// If this line is an element, process it
else if(0 == txt.compare(0, 7, "element"))
{
elements.push_back(ParsePLYElementHeader( txt, fin ));
}
// Otherwise, wtf?
else
{
throw new std::exception("File header contains unexpected line beginning");
}
}
// Read all the raw data
for( std::vector< PlyElementDesc >::iterator it = elements.begin(); it != elements.end(); ++it)
{
(*it).data = ReadPLYElementData(fin, *it);
}
// Create a resource to contain the geometry
GeometryPtr MeshPtr = GeometryPtr( new GeometryDX11() );
// Convert data to D3D11 format
int elemIdx = -1;
// Pull out all the vertex data
if(-1 < (elemIdx = FindPlyElementIndex(elements, "vertex")))
{
PlyElementDesc d = elements.at( elemIdx );
// Has positions?
int xIdx = FindPlyElementPropertyIndex( d.dataFormat, "x" );
int yIdx = FindPlyElementPropertyIndex( d.dataFormat, "y" );
int zIdx = FindPlyElementPropertyIndex( d.dataFormat, "z" );
if ((-1 != xIdx) && (-1 != yIdx) && (-1 != zIdx))
{
VertexElementDX11 *pPositions = new VertexElementDX11( 3, d.elementCount );
pPositions->m_SemanticName = VertexElementDX11::PositionSemantic;
pPositions->m_uiSemanticIndex = 0;
pPositions->m_Format = DXGI_FORMAT_R32G32B32_FLOAT;
pPositions->m_uiInputSlot = 0;
pPositions->m_uiAlignedByteOffset = 0;
pPositions->m_InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
//.........这里部分代码省略.........
示例2: sizeof
//--------------------------------------------------------------------------------
GeometryPtr GeometryLoaderDX11::loadMS3DFileWithAnimation( std::wstring filename, SkinnedActor* pActor )
{
// Get the file path to the models
FileSystem fs;
filename = fs.GetModelsFolder() + filename;
// Temporary Milkshape structures
unsigned short usVertexCount = 0;
unsigned short usTriangleCount = 0;
unsigned short usGroupCount = 0;
unsigned short usMaterialCount = 0;
MS3DVertex* pMS3DVertices = NULL;
MS3DTriangle* pMS3DTriangles = NULL;
MS3DGroup* pMS3DGroups = NULL;
MS3DMaterial* pMS3DMaterials = NULL;
int i;
std::ifstream fin;
MS3DHeader header;
// Open the file and read the MS3D header data
fin.open( filename.c_str(),std::ios::binary );
fin.read((char*)(&(header.id)), sizeof(header.id));
fin.read((char*)(&(header.version)), sizeof(header.version));
if (header.version!=3 && header.version!=4)
return NULL;
// Load all the vertices
fin.read((char*)(&usVertexCount), sizeof(unsigned short));
pMS3DVertices = new MS3DVertex[usVertexCount];
for (i=0; i < usVertexCount; i++)
{
fin.read((char*)&(pMS3DVertices[i].flags), sizeof(unsigned char));
fin.read((char*)&(pMS3DVertices[i].vertex[0]), sizeof(float));
fin.read((char*)&(pMS3DVertices[i].vertex[1]), sizeof(float));
fin.read((char*)&(pMS3DVertices[i].vertex[2]), sizeof(float));
fin.read((char*)&(pMS3DVertices[i].boneId), sizeof(char));
fin.read((char*)&(pMS3DVertices[i].referenceCount), sizeof(unsigned char));
}
// Load all the triangle indices
fin.read((char*)(&usTriangleCount), sizeof(unsigned short));
pMS3DTriangles = new MS3DTriangle[usTriangleCount];
for (i=0; i < usTriangleCount; i++)
{
fin.read((char*)&(pMS3DTriangles[i].flags),sizeof(unsigned short));
fin.read((char*)&(pMS3DTriangles[i].vertexIndices[0]), sizeof(unsigned short)); //3*sizeof(unsigned short));
fin.read((char*)&(pMS3DTriangles[i].vertexIndices[1]), sizeof(unsigned short)); //3*sizeof(unsigned short));
fin.read((char*)&(pMS3DTriangles[i].vertexIndices[2]), sizeof(unsigned short)); //3*sizeof(unsigned short));
fin.read((char*)&(pMS3DTriangles[i].vertexNormals[0]), 3*sizeof(float));
fin.read((char*)&(pMS3DTriangles[i].vertexNormals[1]), 3*sizeof(float));
fin.read((char*)&(pMS3DTriangles[i].vertexNormals[2]), 3*sizeof(float));
fin.read((char*)&(pMS3DTriangles[i].s), 3*sizeof(float));
fin.read((char*)&(pMS3DTriangles[i].t), 3*sizeof(float));
fin.read((char*)&(pMS3DTriangles[i].smoothingGroup), sizeof(unsigned char));
fin.read((char*)&(pMS3DTriangles[i].groupIndex), sizeof(unsigned char));
}
// Load all the group information
fin.read((char*)(&usGroupCount), sizeof(unsigned short));
pMS3DGroups = new MS3DGroup[usGroupCount];
for (i=0; i < usGroupCount; i++)
{
fin.read((char*)&(pMS3DGroups[i].flags), sizeof(unsigned char));
fin.read((char*)&(pMS3DGroups[i].name), sizeof(char[32]));
fin.read((char*)&(pMS3DGroups[i].numtriangles), sizeof(unsigned short));
unsigned short triCount = pMS3DGroups[i].numtriangles;
pMS3DGroups[i].triangleIndices = new unsigned short[triCount];
fin.read((char*)(pMS3DGroups[i].triangleIndices), sizeof(unsigned short) * triCount);
fin.read((char*)&(pMS3DGroups[i].materialIndex), sizeof(char));
}
// Load all the material information
fin.read((char*)(&usMaterialCount),sizeof(unsigned short));
pMS3DMaterials = new MS3DMaterial[usMaterialCount];
for (i=0; i < usMaterialCount; i++)
{
fin.read((char*)&(pMS3DMaterials[i].name), sizeof(char[32]));
fin.read((char*)&(pMS3DMaterials[i].ambient), 4 * sizeof(float));
fin.read((char*)&(pMS3DMaterials[i].diffuse), 4 * sizeof(float));
fin.read((char*)&(pMS3DMaterials[i].specular), 4 * sizeof(float));
fin.read((char*)&(pMS3DMaterials[i].emissive), 4 * sizeof(float));
fin.read((char*)&(pMS3DMaterials[i].shininess), sizeof(float));
fin.read((char*)&(pMS3DMaterials[i].transparency), sizeof(float));
fin.read((char*)&(pMS3DMaterials[i].mode), sizeof(char));
fin.read((char*)&(pMS3DMaterials[i].texture), sizeof(char[128]));
fin.read((char*)&(pMS3DMaterials[i].alphamap), sizeof(char[128]));
}
float fAnimationFPS; // 4 bytes
float fCurrentTime; // 4 bytes
int iTotalFrames; // 4 bytes
unsigned short nNumJoints; // 2 bytes
fin.read((char*)&(fAnimationFPS), sizeof(float));
fin.read((char*)&(fCurrentTime), sizeof(float));
fin.read((char*)&(iTotalFrames), sizeof(int));
fin.read((char*)&(nNumJoints), sizeof(unsigned short));
//.........这里部分代码省略.........
示例3: Initialize
//--------------------------------------------------------------------------------
void App::Initialize()
{
// Create the camera, and the render view that will produce an image of the
// from the camera's point of view of the scene.
m_pCamera->Spatial().SetRotation( Vector3f( 0.5f, 0.3f, 0.0f ) );
m_pCamera->Spatial().SetTranslation( Vector3f( -3.0f, 12.0f, -15.0f ) );
m_pRenderView->SetBackColor( Vector4f( 0.2f, 0.2f, 0.4f, 0.0f ) );
// Create the actor to hold the immediate geometry.
m_pIndexedActor = new GeometryActor();
m_pScene->AddActor( m_pIndexedActor );
m_pIndexedActor->GetNode()->Transform.Position() = Vector3f( 3.0, 0.0f, 0.0f );
m_pIndexedActor->SetColor( Vector4f( 1.0f, 1.0f, 1.0f, 1.0f ) );
m_pIndexedActor->UseTexturedMaterial( m_pRenderer11->LoadTexture( L"EyeOfHorus_128.png" ) );
// Throw a rotation onto the actor to slowly rotate it about the Y-axis.
RotationController<Node3D>* pIndexedRotController = new RotationController<Node3D>( Vector3f( 0.0f, 1.0f, 0.0f ), -0.1f );
m_pIndexedActor->GetNode()->Controllers.Attach( pIndexedRotController );
m_pGeometryActor = new GeometryActor();
m_pScene->AddActor( m_pGeometryActor );
m_pGeometryActor->GetNode()->Transform.Position() = Vector3f( 0.0f, 2.5f, 0.0f );
m_pGeometryActor->SetColor( Vector4f( 1.0f, 0.0f, 0.0f, 1.0f ) );
m_pGeometryActor->DrawSphere( Vector3f( 2.5f, 2.0f, 0.0f ), 1.5f, 16, 24 );
m_pGeometryActor->SetColor( Vector4f( 0.0f, 1.0f, 0.0f, 1.0f ) );
m_pGeometryActor->DrawCylinder( Vector3f( -1.5f, -1.0f, 0.0f ), Vector3f( -1.5f, 3.0f, 0.0f ), 1.5f, 0.0f, 8, 24 );
m_pGeometryActor->SetColor( Vector4f( 1.0f, 1.0f, 0.0f, 1.0f ) );
m_pGeometryActor->DrawDisc( Vector3f( 0.0f, -3.0f, 0.0f ), Vector3f( 1.0f, 1.0f, 1.0f ), 2.0f, 12 );
m_pGeometryActor->SetColor( Vector4f( 0.0f, 0.0f, 1.0f, 1.0f ) );
m_pGeometryActor->DrawBox( Vector3f( 0.0f, 3.0f, 0.0f ), Vector3f( 1.0f, 1.0f, 1.0f ) );
RotationController<Node3D>* pGeometryRotController = new RotationController<Node3D>( Vector3f( 0.0f, 1.0f, 0.0f ), 0.4f );
m_pGeometryActor->GetNode()->Controllers.Attach( pGeometryRotController );
m_pTextActor = new TextActor();
m_pTextActor->SetTextOrientation( Vector3f( 1.0f, 0.0f, 0.0f ), Vector3f( 0.0f, 1.0f, 0.0f ) );
m_pTextActor->SetText( std::wstring( L"Hello World! This is some \nsample text!" ) );
m_pTextActor->SetColor( Vector4f( 0.0f, 1.0f, 0.0f, 0.5f ) );
m_pTextActor->NewLine();
m_pTextActor->SetCharacterHeight( 2.0f );
m_pTextActor->AppendText( L"Text is colored, scaled, and alpha blended..." );
m_pTextActor->GetNode()->Transform.Position() = Vector3f( 0.0f, 7.0f, 0.0f );
m_pScene->AddActor( m_pTextActor );
// Add a single point light to the scene.
m_pLight = new PointLight();
m_pScene->AddLight( m_pLight );
m_pLight->GetNode()->Controllers.Attach( new RotationController<Node3D>( Vector3f( 0.0f, 1.0f, 0.0f ), -1.0f ) );
m_pLight->GetNode()->Transform.Position() = Vector3f( 0.0f, 50.0f, 0.0f );
m_pLight->GetBody()->Transform.Position() = Vector3f( 50.0f, 0.0f, 0.0f );
// Load an STL file and configure an actor to use it.
FileSystem fs;
STL::MeshSTL stl( fs.GetModelsFolder() + L"MeshedReconstruction.stl" );
OBJ::MeshOBJ obj( fs.GetModelsFolder() + L"Capsule.obj" );
m_pMeshActor = new Actor();
m_pScene->AddActor( m_pMeshActor );
m_pMeshActor->GetBody()->Controllers.Attach( new RotationController<Entity3D>( Vector3f( 0.0f, 1.0f, 0.0f ), -1.0f ) );
m_pMeshActor->GetNode()->Transform.Position() = Vector3f( 5.0f, 5.0f, 0.0f );
m_pMeshActor->GetBody()->Visual.SetMaterial( MaterialGeneratorDX11::GenerateImmediateGeometrySolidMaterial( *m_pRenderer11) );
auto pMeshExecutor = std::make_shared<DrawExecutorDX11<BasicVertexDX11::Vertex>>();
pMeshExecutor->SetLayoutElements( BasicVertexDX11::GetElementCount(), BasicVertexDX11::Elements );
pMeshExecutor->SetPrimitiveType( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
pMeshExecutor->SetMaxVertexCount( 3 * stl.faces.size() );
m_pMeshActor->GetBody()->Visual.SetGeometry( pMeshExecutor );
BasicVertexDX11::Vertex vertex;
vertex.color = Vector4f( 0.0f, 1.0f, 0.0f, 0.0f );
for ( auto& face : stl.faces )
{
vertex.normal = face.normal;
vertex.position = face.v0;
pMeshExecutor->AddVertex( vertex );
vertex.position = face.v1;
pMeshExecutor->AddVertex( vertex );
vertex.position = face.v2;
pMeshExecutor->AddVertex( vertex );
}
//.........这里部分代码省略.........