本文整理汇总了C++中MakeLeftHandedProcess::Execute方法的典型用法代码示例。如果您正苦于以下问题:C++ MakeLeftHandedProcess::Execute方法的具体用法?C++ MakeLeftHandedProcess::Execute怎么用?C++ MakeLeftHandedProcess::Execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MakeLeftHandedProcess
的用法示例。
在下文中一共展示了MakeLeftHandedProcess::Execute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateDataRepresentationFromImport
// ------------------------------------------------------------------------------------------------
// Constructs the return data structure out of the imported data.
void XFileImporter::CreateDataRepresentationFromImport( aiScene* pScene, XFile::Scene* pData)
{
// Read the global materials first so that meshes referring to them can find them later
ConvertMaterials( pScene, pData->mGlobalMaterials);
// copy nodes, extracting meshes and materials on the way
pScene->mRootNode = CreateNodes( pScene, nullptr, pData->mRootNode);
// extract animations
CreateAnimations( pScene, pData);
// read the global meshes that were stored outside of any node
if( !pData->mGlobalMeshes.empty() ) {
// create a root node to hold them if there isn't any, yet
if( pScene->mRootNode == nullptr ) {
pScene->mRootNode = new aiNode;
pScene->mRootNode->mName.Set( "$dummy_node");
}
// convert all global meshes and store them in the root node.
// If there was one before, the global meshes now suddenly have its transformation matrix...
// Don't know what to do there, I don't want to insert another node under the present root node
// just to avoid this.
CreateMeshes( pScene, pScene->mRootNode, pData->mGlobalMeshes);
}
if (!pScene->mRootNode) {
throw DeadlyImportError( "No root node" );
}
// Convert everything to OpenGL space... it's the same operation as the conversion back, so we can reuse the step directly
MakeLeftHandedProcess convertProcess;
convertProcess.Execute( pScene);
FlipWindingOrderProcess flipper;
flipper.Execute(pScene);
// finally: create a dummy material if not material was imported
if( pScene->mNumMaterials == 0) {
pScene->mNumMaterials = 1;
// create the Material
aiMaterial* mat = new aiMaterial;
int shadeMode = (int) aiShadingMode_Gouraud;
mat->AddProperty<int>( &shadeMode, 1, AI_MATKEY_SHADING_MODEL);
// material colours
int specExp = 1;
aiColor3D clr = aiColor3D( 0, 0, 0);
mat->AddProperty( &clr, 1, AI_MATKEY_COLOR_EMISSIVE);
mat->AddProperty( &clr, 1, AI_MATKEY_COLOR_SPECULAR);
clr = aiColor3D( 0.5f, 0.5f, 0.5f);
mat->AddProperty( &clr, 1, AI_MATKEY_COLOR_DIFFUSE);
mat->AddProperty( &specExp, 1, AI_MATKEY_SHININESS);
pScene->mMaterials = new aiMaterial*[1];
pScene->mMaterials[0] = mat;
}
}
示例2: Export
// ------------------------------------------------------------------------------------------------
aiReturn Exporter :: Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing )
{
ASSIMP_BEGIN_EXCEPTION_REGION();
pimpl->mError = "";
for (size_t i = 0; i < pimpl->mExporters.size(); ++i) {
const Exporter::ExportFormatEntry& exp = pimpl->mExporters[i];
if (!strcmp(exp.mDescription.id,pFormatId)) {
try {
// Always create a full copy of the scene. We might optimize this one day,
// but for now it is the most pragmatic way.
aiScene* scenecopy_tmp;
SceneCombiner::CopyScene(&scenecopy_tmp,pScene);
std::auto_ptr<aiScene> scenecopy(scenecopy_tmp);
const ScenePrivateData* const priv = ScenePriv(pScene);
// steps that are not idempotent, i.e. we might need to run them again, usually to get back to the
// original state before the step was applied first. When checking which steps we don't need
// to run, those are excluded.
const unsigned int nonIdempotentSteps = aiProcess_FlipWindingOrder | aiProcess_FlipUVs | aiProcess_MakeLeftHanded;
// Erase all pp steps that were already applied to this scene
unsigned int pp = (exp.mEnforcePP | pPreprocessing) & ~(priv
? (priv->mPPStepsApplied & ~nonIdempotentSteps)
: 0u);
// If no extra postprocessing was specified, and we obtained this scene from an
// Assimp importer, apply the reverse steps automatically.
if (!pPreprocessing && priv) {
pp |= (nonIdempotentSteps & priv->mPPStepsApplied);
}
// If the input scene is not in verbose format, but there is at least postprocessing step that relies on it,
// we need to run the MakeVerboseFormat step first.
if (scenecopy->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) {
bool verbosify = false;
for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) {
BaseProcess* const p = pimpl->mPostProcessingSteps[a];
if (p->IsActive(pp) && p->RequireVerboseFormat()) {
verbosify = true;
break;
}
}
if (verbosify || (exp.mEnforcePP & aiProcess_JoinIdenticalVertices)) {
DefaultLogger::get()->debug("export: Scene data not in verbose format, applying MakeVerboseFormat step first");
MakeVerboseFormatProcess proc;
proc.Execute(scenecopy.get());
}
}
if (pp) {
// the three 'conversion' steps need to be executed first because all other steps rely on the standard data layout
{
FlipWindingOrderProcess step;
if (step.IsActive(pp)) {
step.Execute(scenecopy.get());
}
}
{
FlipUVsProcess step;
if (step.IsActive(pp)) {
step.Execute(scenecopy.get());
}
}
{
MakeLeftHandedProcess step;
if (step.IsActive(pp)) {
step.Execute(scenecopy.get());
}
}
// dispatch other processes
for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) {
BaseProcess* const p = pimpl->mPostProcessingSteps[a];
if (p->IsActive(pp)
&& !dynamic_cast<FlipUVsProcess*>(p)
&& !dynamic_cast<FlipWindingOrderProcess*>(p)
&& !dynamic_cast<MakeLeftHandedProcess*>(p)) {
p->Execute(scenecopy.get());
}
}
ScenePrivateData* const privOut = ScenePriv(scenecopy.get());
ai_assert(privOut);
privOut->mPPStepsApplied |= pp;
}
exp.mExportFunction(pPath,pimpl->mIOSystem.get(),scenecopy.get());
//.........这里部分代码省略.........
示例3: sprintf
//.........这里部分代码省略.........
if( !_meshes.size() ) Fail( "No meshes" );
//Fix nodes/meshes/bones
for(size_t i=0;i<_nodes.size();++i ){
aiNode *node=_nodes[i];
for( size_t j=0;j<node->mNumMeshes;++j ){
aiMesh *mesh=_meshes[node->mMeshes[j]];
int n_tris=mesh->mNumFaces;
int n_verts=mesh->mNumVertices=n_tris * 3;
aiVector3D *mv=mesh->mVertices=new aiVector3D[ n_verts ],*mn=0,*mc=0;
if( _vflags & 1 ) mn=mesh->mNormals=new aiVector3D[ n_verts ];
if( _tcsets ) mc=mesh->mTextureCoords[0]=new aiVector3D[ n_verts ];
aiFace *face=mesh->mFaces;
vector< vector<aiVertexWeight> > vweights( _nodes.size() );
for( int i=0;i<n_verts;i+=3 ){
for( int j=0;j<3;++j ){
Vertex &v=_vertices[face->mIndices[j]];
*mv++=v.vertex;
if( mn ) *mn++=v.normal;
if( mc ) *mc++=v.texcoords;
face->mIndices[j]=i+j;
for( int k=0;k<4;++k ){
if( !v.weights[k] ) break;
int bone=v.bones[k];
float weight=v.weights[k];
vweights[bone].push_back( aiVertexWeight(i+j,weight) );
}
}
++face;
}
vector<aiBone*> bones;
for(size_t i=0;i<vweights.size();++i ){
vector<aiVertexWeight> &weights=vweights[i];
if( !weights.size() ) continue;
aiBone *bone=new aiBone;
bones.push_back( bone );
aiNode *bnode=_nodes[i];
bone->mName=bnode->mName;
bone->mNumWeights=weights.size();
bone->mWeights=to_array( weights );
aiMatrix4x4 mat=bnode->mTransformation;
while( bnode->mParent ){
bnode=bnode->mParent;
mat=bnode->mTransformation * mat;
}
bone->mOffsetMatrix=mat.Inverse();
}
mesh->mNumBones=bones.size();
mesh->mBones=to_array( bones );
}
}
//nodes
scene->mRootNode=_nodes[0];
//material
if( !_materials.size() ){
_materials.push_back( new aiMaterial );
}
scene->mNumMaterials=_materials.size();
scene->mMaterials=to_array( _materials );
//meshes
scene->mNumMeshes=_meshes.size();
scene->mMeshes=to_array( _meshes );
//animations
if( _animations.size()==1 && _nodeAnims.size() ){
aiAnimation *anim=_animations.back();
anim->mNumChannels=_nodeAnims.size();
anim->mChannels=to_array( _nodeAnims );
scene->mNumAnimations=_animations.size();
scene->mAnimations=to_array( _animations );
}
// convert to RH
MakeLeftHandedProcess makeleft;
makeleft.Execute( scene );
FlipWindingOrderProcess flip;
flip.Execute( scene );
}
示例4: InternReadFile
//.........这里部分代码省略.........
else {
tri.matIndex = static_cast<unsigned int>(nt-materials.begin());
++nt->numFaces;
}
}
if (!pScene->mNumMeshes) {
throw DeadlyImportError("UNREAL: Unable to find valid mesh data");
}
// allocate meshes and bind them to the node graph
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials = pScene->mNumMeshes];
nd->mNumMeshes = pScene->mNumMeshes;
nd->mMeshes = new unsigned int[nd->mNumMeshes];
for (unsigned int i = 0; i < pScene->mNumMeshes;++i) {
aiMesh* m = pScene->mMeshes[i] = new aiMesh();
m->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
const unsigned int num = materials[i].numFaces;
m->mFaces = new aiFace [num];
m->mVertices = new aiVector3D [num*3];
m->mTextureCoords[0] = new aiVector3D [num*3];
nd->mMeshes[i] = i;
// create materials, too
aiMaterial* mat = new aiMaterial();
pScene->mMaterials[i] = mat;
// all white by default - texture rulez
aiColor3D color(1.f,1.f,1.f);
aiString s;
::sprintf(s.data,"mat%i_tx%i_",i,materials[i].tex);
// set the two-sided flag
if (materials[i].type == Unreal::MF_NORMAL_TS) {
const int twosided = 1;
mat->AddProperty(&twosided,1,AI_MATKEY_TWOSIDED);
::strcat(s.data,"ts_");
}
else ::strcat(s.data,"os_");
// make TRANS faces 90% opaque that RemRedundantMaterials won't catch us
if (materials[i].type == Unreal::MF_NORMAL_TRANS_TS) {
const float opac = 0.9f;
mat->AddProperty(&opac,1,AI_MATKEY_OPACITY);
::strcat(s.data,"tran_");
}
else ::strcat(s.data,"opaq_");
// a special name for the weapon attachment point
if (materials[i].type == Unreal::MF_WEAPON_PLACEHOLDER) {
s.length = ::sprintf(s.data,"$WeaponTag$");
color = aiColor3D(0.f,0.f,0.f);
}
// set color and name
mat->AddProperty(&color,1,AI_MATKEY_COLOR_DIFFUSE);
s.length = ::strlen(s.data);
mat->AddProperty(&s,AI_MATKEY_NAME);
// set texture, if any
const unsigned int tex = materials[i].tex;
for (std::vector< std::pair< unsigned int, std::string > >::const_iterator it = textures.begin();it != textures.end();++it) {
if ((*it).first == tex) {
s.Set((*it).second);
mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(0));
break;
}
}
}
// fill them.
for (std::vector<Unreal::Triangle>::iterator it = triangles.begin(), end = triangles.end();it != end; ++it) {
Unreal::Triangle& tri = *it;
Unreal::TempMat mat(tri);
std::vector<Unreal::TempMat>::iterator nt = std::find(materials.begin(),materials.end(),mat);
aiMesh* mesh = pScene->mMeshes[nt-materials.begin()];
aiFace& f = mesh->mFaces[mesh->mNumFaces++];
f.mIndices = new unsigned int[f.mNumIndices = 3];
for (unsigned int i = 0; i < 3;++i,mesh->mNumVertices++) {
f.mIndices[i] = mesh->mNumVertices;
mesh->mVertices[mesh->mNumVertices] = vertices[ tri.mVertex[i] ];
mesh->mTextureCoords[0][mesh->mNumVertices] = aiVector3D( tri.mTex[i][0] / 255.f, 1.f - tri.mTex[i][1] / 255.f, 0.f);
}
}
// convert to RH
MakeLeftHandedProcess hero;
hero.Execute(pScene);
FlipWindingOrderProcess flipper;
flipper.Execute(pScene);
}
示例5: Export
// ------------------------------------------------------------------------------------------------
aiReturn Exporter::Export( const aiScene* pScene, const char* pFormatId, const char* pPath,
unsigned int pPreprocessing, const ExportProperties* pProperties) {
ASSIMP_BEGIN_EXCEPTION_REGION();
// when they create scenes from scratch, users will likely create them not in verbose
// format. They will likely not be aware that there is a flag in the scene to indicate
// this, however. To avoid surprises and bug reports, we check for duplicates in
// meshes upfront.
const bool is_verbose_format = !(pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) || IsVerboseFormat(pScene);
pimpl->mProgressHandler->UpdateFileWrite(0, 4);
pimpl->mError = "";
for (size_t i = 0; i < pimpl->mExporters.size(); ++i) {
const Exporter::ExportFormatEntry& exp = pimpl->mExporters[i];
if (!strcmp(exp.mDescription.id,pFormatId)) {
try {
// Always create a full copy of the scene. We might optimize this one day,
// but for now it is the most pragmatic way.
aiScene* scenecopy_tmp = nullptr;
SceneCombiner::CopyScene(&scenecopy_tmp,pScene);
pimpl->mProgressHandler->UpdateFileWrite(1, 4);
std::unique_ptr<aiScene> scenecopy(scenecopy_tmp);
const ScenePrivateData* const priv = ScenePriv(pScene);
// steps that are not idempotent, i.e. we might need to run them again, usually to get back to the
// original state before the step was applied first. When checking which steps we don't need
// to run, those are excluded.
const unsigned int nonIdempotentSteps = aiProcess_FlipWindingOrder | aiProcess_FlipUVs | aiProcess_MakeLeftHanded;
// Erase all pp steps that were already applied to this scene
const unsigned int pp = (exp.mEnforcePP | pPreprocessing) & ~(priv && !priv->mIsCopy
? (priv->mPPStepsApplied & ~nonIdempotentSteps)
: 0u);
// If no extra post-processing was specified, and we obtained this scene from an
// Assimp importer, apply the reverse steps automatically.
// TODO: either drop this, or document it. Otherwise it is just a bad surprise.
//if (!pPreprocessing && priv) {
// pp |= (nonIdempotentSteps & priv->mPPStepsApplied);
//}
// If the input scene is not in verbose format, but there is at least post-processing step that relies on it,
// we need to run the MakeVerboseFormat step first.
bool must_join_again = false;
if (!is_verbose_format) {
bool verbosify = false;
for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) {
BaseProcess* const p = pimpl->mPostProcessingSteps[a];
if (p->IsActive(pp) && p->RequireVerboseFormat()) {
verbosify = true;
break;
}
}
if (verbosify || (exp.mEnforcePP & aiProcess_JoinIdenticalVertices)) {
ASSIMP_LOG_DEBUG("export: Scene data not in verbose format, applying MakeVerboseFormat step first");
MakeVerboseFormatProcess proc;
proc.Execute(scenecopy.get());
if(!(exp.mEnforcePP & aiProcess_JoinIdenticalVertices)) {
must_join_again = true;
}
}
}
pimpl->mProgressHandler->UpdateFileWrite(2, 4);
if (pp) {
// the three 'conversion' steps need to be executed first because all other steps rely on the standard data layout
{
FlipWindingOrderProcess step;
if (step.IsActive(pp)) {
step.Execute(scenecopy.get());
}
}
{
FlipUVsProcess step;
if (step.IsActive(pp)) {
step.Execute(scenecopy.get());
}
}
{
MakeLeftHandedProcess step;
if (step.IsActive(pp)) {
step.Execute(scenecopy.get());
}
}
bool exportPointCloud(false);
if (nullptr != pProperties) {
exportPointCloud = pProperties->GetPropertyBool(AI_CONFIG_EXPORT_POINT_CLOUDS);
}
//.........这里部分代码省略.........