Example #1
0
void GSDevice9::ForceValidMsaaConfig()
{
	if(0 == GetMaxDepth(theApp.GetConfig("UserHacks_MSAA", 0)))
	{
		theApp.SetConfig("UserHacks_MSAA", 0); // replace invalid msaa value in ini file with 0.
	}
};
Example #2
0
MStatus Trimmer::compute( const MPlug& plug, MDataBlock& data )
//
//	Description:
//		This method computes the value of the given output plug based
//		on the values of the input attributes.
//
//	Arguments:
//		plug - the plug to compute
//		data - object that provides access to the attributes for this node
//
{
    if ( plug == outputData ) {
        MStatus stat;

        MDataHandle inDataHandle = data.inputValue( Trimmer::inputData, &stat );
        MDataHandle outDataHandle = data.outputValue( Trimmer::outputData, &stat );

        GrowerData* growerData = static_cast< GrowerData* >( inDataHandle.asPluginData() );
        if ( growerData == NULL ) {
            cerr << "Trimmer: error retrieving data" << endl;
            return MS::kFailure;
        }

        int maxDepth = GetMaxDepth( growerData->nodes );
        int length = (int)ceilf( (float)maxDepth * data.inputValue( Trimmer::maxLength ).asFloat() ) + 1;

        Trim( growerData->nodes, length );

        outDataHandle.setMPxData( growerData );
        data.setClean( plug );
        return MS::kSuccess;
    }

    return MS::kUnknownParameter;
}
Example #3
0
// -----------------------------------------------------------------------------------
unsigned int GetMaxDepth(const aiNode* root)
{
	unsigned int cnt = 0;
	for (unsigned int i = 0; i < root->mNumChildren; ++i ) {
		cnt = std::max(cnt,GetMaxDepth(root->mChildren[i]));
	}
	return cnt+1;
}
Example #4
0
// -----------------------------------------------------------------------------------
// Implementation of the assimp info utility to print basic file info
int Assimp_Info (const char* const* params, unsigned int num)
{
	if (num < 1) {
		printf("assimp info: Invalid number of arguments. "
			"See \'assimp info --help\'\n");
		return 1;
	}

	// --help
	if (!strcmp( params[0],"-h")||!strcmp( params[0],"--help")||!strcmp( params[0],"-?") ) {
		printf("%s",AICMD_MSG_INFO_HELP_E);
		return 0;
	}

	// asssimp info <file> [-r]
	if (num < 1) {
		printf("assimp info: Invalid number of arguments. "
			"See \'assimp info --help\'\n");
		return 1;
	}

	const std::string in  = std::string(params[0]);

	// do maximum post-processing unless -r was specified
	ImportData import;
	import.ppFlags = num>1&&(!strcmp(params[1],"--raw")||!strcmp(params[1],"-r")) ? 0
		: aiProcessPreset_TargetRealtime_MaxQuality;

	// import the main model
    import.log = true;
    import.showLog = true;
	const aiScene* scene = ImportModel(import,in);
	if (!scene) {
		printf("assimp info: Unable to load input file %s\n",
			in.c_str());
		return 5;
	}

	aiMemoryInfo mem;
	globalImporter->GetMemoryRequirements(mem);


	static const char* format_string = 
		"Memory consumption: %i B\n"
		"Nodes:              %i\n"
		"Maximum depth       %i\n"
		"Meshes:             %i\n"
		"Animations:         %i\n"
		"Textures (embed.):  %i\n"
		"Materials:          %i\n"
		"Cameras:            %i\n"
		"Lights:             %i\n"
		"Vertices:           %i\n"
		"Faces:              %i\n"
		"Bones:              %i\n"
		"Animation Channels: %i\n"
		"Primitive Types:    %s\n"
		"Average faces/mesh  %i\n"
		"Average verts/mesh  %i\n"
		"Minimum point      (%f %f %f)\n"
		"Maximum point      (%f %f %f)\n"
		"Center point       (%f %f %f)\n"

		;

	aiVector3D special_points[3];
	FindSpecialPoints(scene,special_points);
	printf(format_string,
		mem.total,
		CountNodes(scene->mRootNode),
		GetMaxDepth(scene->mRootNode),
		scene->mNumMeshes,
		scene->mNumAnimations,
		scene->mNumTextures,
		scene->mNumMaterials,
		scene->mNumCameras,
		scene->mNumLights,
		CountVertices(scene),
		CountFaces(scene),
		CountBones(scene),
		CountAnimChannels(scene),
		FindPTypes(scene).c_str(),
		GetAvgFacePerMesh(scene),
		GetAvgVertsPerMesh(scene),
		special_points[0][0],special_points[0][1],special_points[0][2],
		special_points[1][0],special_points[1][1],special_points[1][2],
		special_points[2][0],special_points[2][1],special_points[2][2]
		)
	;
	unsigned int total=0;
	for(unsigned int i = 0;i < scene->mNumMaterials; ++i) {
		aiString name;
		if (AI_SUCCESS==aiGetMaterialString(scene->mMaterials[i],AI_MATKEY_NAME,&name)) {
			printf("%s\n    \'%s\'",(total++?"":"\nNamed Materials:" ),name.data);
		}
	}
	if(total) {
		printf("\n");
	}

	total=0;
	for(unsigned int i = 0;i < scene->mNumMaterials; ++i) {
		aiString name;
		static const aiTextureType types[] = {
			aiTextureType_NONE,
			aiTextureType_DIFFUSE,
			aiTextureType_SPECULAR,
			aiTextureType_AMBIENT,
			aiTextureType_EMISSIVE,
			aiTextureType_HEIGHT,
			aiTextureType_NORMALS,
			aiTextureType_SHININESS,
			aiTextureType_OPACITY,
			aiTextureType_DISPLACEMENT,
			aiTextureType_LIGHTMAP,
			aiTextureType_REFLECTION,
			aiTextureType_UNKNOWN
		};
		for(unsigned int type = 0; type < sizeof(types)/sizeof(types[0]); ++type) {
			for(unsigned int idx = 0;AI_SUCCESS==aiGetMaterialString(scene->mMaterials[i],
				AI_MATKEY_TEXTURE(types[type],idx),&name); ++idx) {
				printf("%s\n    \'%s\'",(total++?"":"\nTexture Refs:" ),name.data);
			}
		}
	}
	if(total) {
		printf("\n");
	}

	total=0;
	for(unsigned int i = 0;i < scene->mNumAnimations; ++i) {
		if (scene->mAnimations[i]->mName.length) {
			printf("%s\n     \'%s\'",(total++?"":"\nNamed Animations:" ),scene->mAnimations[i]->mName.data);
		}
	}
	if(total) {
		printf("\n");
	}

	printf("\nNode hierarchy:\n");
	unsigned int cline=0;
	PrintHierarchy(scene->mRootNode,20,1000,cline);

	printf("\n");
	return 0;
}
Example #5
0
// -----------------------------------------------------------------------------------
// Implementation of the assimp info utility to print basic file info
int Assimp_Info(const aiScene* scene, Assimp::Importer *globalImporter)
{


    aiMemoryInfo mem;
    globalImporter->GetMemoryRequirements(mem);


    static const char* format_string =
        "Memory consumption: %i B\n"
        "Nodes:              %i\n"
        "Maximum depth       %i\n"
        "Meshes:             %i\n"
        "Animations:         %i\n"
        "Textures (embed.):  %i\n"
        "Materials:          %i\n"
        "Cameras:            %i\n"
        "Lights:             %i\n"
        "Vertices:           %i\n"
        "Faces:              %i\n"
        "Bones:              %i\n"
        "Animation Channels: %i\n"
        "Primitive Types:    %s\n"
        "Average faces/mesh  %i\n"
        "Average verts/mesh  %i\n"
        "Minimum point      (%f %f %f)\n"
        "Maximum point      (%f %f %f)\n"
        "Center point       (%f %f %f)\n"

        ;

    aiVector3D special_points[3];
    FindSpecialPoints(scene, special_points);
    fprintf(stderr, format_string,
            mem.total,
            CountNodes(scene->mRootNode),
            GetMaxDepth(scene->mRootNode),
            scene->mNumMeshes,
            scene->mNumAnimations,
            scene->mNumTextures,
            scene->mNumMaterials,
            scene->mNumCameras,
            scene->mNumLights,
            CountVertices(scene),
            CountFaces(scene),
            CountBones(scene),
            CountAnimChannels(scene),
            FindPTypes(scene).c_str(),
            GetAvgFacePerMesh(scene),
            GetAvgVertsPerMesh(scene),
            special_points[0][0], special_points[0][1], special_points[0][2],
            special_points[1][0], special_points[1][1], special_points[1][2],
            special_points[2][0], special_points[2][1], special_points[2][2]
           )
    ;
#define FULLLOG
#ifdef FULLLOG
    unsigned int total = 0;
    for (unsigned int i = 0; i < scene->mNumMaterials; ++i) {
        aiString name;
        if (AI_SUCCESS == aiGetMaterialString(scene->mMaterials[i], AI_MATKEY_NAME, &name)) {
            fprintf(stderr, "%s\n    \'%s\'", (total++ ? "" : "\nNamed Materials:"), name.data);
        }
    }
    if (total) {
        fprintf(stderr, "\n");
    }

    total = 0;
    for (unsigned int i = 0; i < scene->mNumMaterials; ++i) {
        aiString name;
        static const aiTextureType types[] = {
            aiTextureType_NONE,
            aiTextureType_DIFFUSE,
            aiTextureType_SPECULAR,
            aiTextureType_AMBIENT,
            aiTextureType_EMISSIVE,
            aiTextureType_HEIGHT,
            aiTextureType_NORMALS,
            aiTextureType_SHININESS,
            aiTextureType_OPACITY,
            aiTextureType_DISPLACEMENT,
            aiTextureType_LIGHTMAP,
            aiTextureType_REFLECTION,
            aiTextureType_UNKNOWN
        };
        for (unsigned int type = 0; type < sizeof(types) / sizeof(types[0]); ++type) {
            for (unsigned int idx = 0; AI_SUCCESS == aiGetMaterialString(scene->mMaterials[i],
                    AI_MATKEY_TEXTURE(types[type], idx), &name); ++idx) {
                fprintf(stderr, "%s\n    \'%s\'", (total++ ? "" : "\nTexture Refs:"), name.data);
            }
        }
    }
    if (total) {
        fprintf(stderr, "\n");
    }

    total = 0;
    for (unsigned int i = 0; i < scene->mNumAnimations; ++i) {
        if (scene->mAnimations[i]->mName.length) {
            fprintf(stderr, "%s\n     \'%s\'", (total++ ? "" : "\nNamed Animations:"), scene->mAnimations[i]->mName.data);
        }
    }
    if (total) {
        fprintf(stderr, "\n");
    }

 /*
   fprintf(stderr, "\nNode hierarchy:\n");
    unsigned int cline = 0;
    PrintHierarchy(scene->mRootNode, 20, 1000, cline);
    */
#endif
    fprintf(stderr, "\n");
    return 0;
}
Example #6
0
HOM *BuildHOM( Scene &scene, int width, int height )
{
  HOM *hom = new HOM( width / 10, height / 10 );

  BeginDraw( scene, width, height );

  // get level 0 map
  glViewport( 0, 0, hom->width, hom->height );
  glColor3f( 1.f, 1.f, 1.f );
  glEnable( GL_DEPTH_TEST );
  glDisable( GL_LIGHTING );
  glClearColor( 0.f, 0.f, 0.f, 0.f );
  glClear( GL_COLOR_BUFFER_BIT );

  float depth = 0.f;
  size_t nObjs = scene.objects.size();
  for ( size_t i = 0; i < nObjs; ++i )
  {
    if ( scene.objects[i].occluder )
    {
      DrawObject( scene.objects[i] );
      depth = GetMaxDepth( scene.objects[i], scene, width, height );
    }
  }

  glReadPixels( 0, 0, hom->width, hom->height, GL_RED, GL_FLOAT, hom->map );

  // Assumes only 1 occluder
  glReadPixels( 0, 0, hom->width, hom->height, GL_DEPTH_COMPONENT, GL_FLOAT, hom->depth );
  for ( int y = 0; y < hom->height; ++y )
  {
    for ( int x = 0; x < hom->width; ++x )
    {
      float &val = hom->Depth( x, y );
      if ( val != 1.0f )
        val = depth;
    }
  }

  HOM *pCurHOM = hom;
  // build remaining maps
  while ( pCurHOM->width > 4 && pCurHOM->height > 4 )
  {
    pCurHOM->next = new HOM( pCurHOM->width / 2, pCurHOM->height / 2, pCurHOM );
    pCurHOM = pCurHOM->next;
    for ( int y = 0; y < pCurHOM->height; ++y )
    {
      int j = y * 2;
      for ( int x = 0; x < pCurHOM->width; ++x )
      {
        int i = x * 2;
        pCurHOM->Map( x, y ) = ( pCurHOM->prev->Map( i, j ) + pCurHOM->prev->Map( i + 1, j ) 
                               + pCurHOM->prev->Map( i, j + 1 ) + pCurHOM->prev->Map( i + 1, j + 1 ) ) / 4.f;
        pCurHOM->Depth( x, y ) = ( pCurHOM->prev->Depth( i, j ) + pCurHOM->prev->Depth( i + 1, j ) 
                                 + pCurHOM->prev->Depth( i, j + 1 ) + pCurHOM->prev->Depth( i + 1, j + 1 ) ) / 4.f;
      }
    }
  }

  return hom;
}