Пример #1
0
// Count the polygons and dislpay the bar graph after every redraw views
void
PolyCountCallback::proc(Interface* ip)
{
    InitFaceCount();
    CountFaces(ip);
    thePolyCounter.DrawBars();
}
Пример #2
0
// Handler for the modeless polygon counter dialog.
static INT_PTR CALLBACK
PolyCountDlgProc(HWND hDlg, UINT msg, WPARAM wParam,
                              LPARAM lParam) 
{
    TSTR buf;
    int val;

    switch (msg) {
    case WM_INITDIALOG:
        thePolyCounter.hDlg = hDlg;
        CenterWindow(hDlg, GetParent(hDlg));
        thePolyCounter.maxPolys =
            GetISpinner(GetDlgItem(hDlg, IDC_MAX_POLY_SPIN));
        thePolyCounter.maxPolys->SetScale(10.0f);
        thePolyCounter.maxPolys->SetLimits(0, 1000000);
        thePolyCounter.maxPolys->LinkToEdit(GetDlgItem(hDlg,
                                                       IDC_MAX_POLY_EDIT),
                                            EDITTYPE_INT);
        thePolyCounter.maxPolys->SetResetValue(10000);
        GetAppData(thePolyCounter.ip, MAX_POLYS_ID, _T("10000"), buf);
        if (atoi(buf, val))
            thePolyCounter.maxPolys->SetValue(val, FALSE);

        thePolyCounter.maxSelected =
            GetISpinner(GetDlgItem(hDlg, IDC_MAX_SELECTED_SPIN));
        thePolyCounter.maxSelected->SetScale(10.0f);
        thePolyCounter.maxSelected->SetLimits(0, 1000000);
        thePolyCounter.maxSelected->LinkToEdit(GetDlgItem(hDlg,
                                                    IDC_MAX_SELECTED_EDIT),
                                               EDITTYPE_INT);
        thePolyCounter.maxSelected->SetResetValue(1000);
        GetAppData(thePolyCounter.ip, MAX_SELECTED_ID, _T("1000"), buf);
		if (atoi(buf, val))
			thePolyCounter.maxSelected->SetValue(val, FALSE);

		CheckRadioButton(hDlg, IDC_TRIANGLE, IDC_POLY, IDC_TRIANGLE);
		
		countTriangles = IsDlgButtonChecked(hDlg, IDC_TRIANGLE);

        InitFaceCount();
        CountFaces(thePolyCounter.ip);
        break;
    case CC_SPINNER_CHANGE:
    case WM_CUSTEDIT_ENTER:
        val = thePolyCounter.maxPolys->GetIVal();
        buf.printf(_T("%d"), val);
        WriteAppData(thePolyCounter.ip, MAX_POLYS_ID, buf);
        val = thePolyCounter.maxSelected->GetIVal();
        buf.printf(_T("%d"), val);
        WriteAppData(thePolyCounter.ip, MAX_SELECTED_ID, buf);
		// fall through
    case WM_PAINT:
        thePolyCounter.DrawBars();
        break;
    case WM_COMMAND:
        switch(LOWORD(wParam)) {
		case IDC_TRIANGLE:
			countTriangles = IsDlgButtonChecked(hDlg, IDC_TRIANGLE);
			InitFaceCount();
			CountFaces(thePolyCounter.ip);
			thePolyCounter.DrawBars();
			break;
		case IDC_POLY:
			countTriangles = !(IsDlgButtonChecked(hDlg, IDC_POLY));
			InitFaceCount();
			CountFaces(thePolyCounter.ip);
			thePolyCounter.DrawBars();
			break;
        case IDCANCEL:
            EndDialog(hDlg, FALSE);
            ReleaseISpinner(thePolyCounter.maxPolys);
            ReleaseISpinner(thePolyCounter.maxSelected);
            if (thePolyCounter.iu)
                thePolyCounter.iu->CloseUtility();
            thePolyCounter.hDlg = NULL;
            thePolyCounter.End();
            break;
        }
    }
    return FALSE;
        
}
Пример #3
0
// -----------------------------------------------------------------------------------
unsigned int GetAvgFacePerMesh(const aiScene* scene) {
	if (scene->mNumMeshes != 0)
		return static_cast<unsigned int>(CountFaces(scene)/scene->mNumMeshes);
}
Пример #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;
}
Пример #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;
}