示例#1
0
Sky::Sky( DBCFile::Iterator data )
{
	pos = Vec3D( data->getFloat( LightDB::PositionX ) / skymul, data->getFloat( LightDB::PositionY ) / skymul, data->getFloat( LightDB::PositionZ ) / skymul );
	r1 = data->getFloat( LightDB::RadiusInner ) / skymul;
	r2 = data->getFloat( LightDB::RadiusOuter ) / skymul;
	//gLog( "New sky (%i) at (%f,%f,%f) with (%f > %f).\n", data->getInt( LightDB::ID ), pos.x, pos.y, pos.z, r1, r2 );

	for (int i=0; i<36; i++) 
		mmin[i] = -2;

	global = ( pos.x == 0.0f && pos.y == 0.0f && pos.z == 0.0f );

	int FirstId = data->getInt( LightDB::DataIDs ) * 18;

	for( int i = 0; i < 18; i++ ) 
	{
		try {
			DBCFile::Record rec = gLightIntBandDB.getByID( FirstId + i );
			int entries = rec.getInt( LightIntBandDB::Entries );

			if ( entries == 0 ) 
				mmin[i] = -1;
			else 
			{
				mmin[i] = rec.getInt( LightIntBandDB::Times );
				for( int l = 0; l < entries; l++ ) 
				{
					SkyColor sc( rec.getInt( LightIntBandDB::Times + l ), rec.getInt( LightIntBandDB::Values + l ) );
					colorRows[i].push_back( sc );
				}
			}
		} catch (LightIntBandDB::NotFound) {
		}
	}
}
示例#2
0
Skies::Skies( int mapid )
{
	gLog( "Skies::Skies( %i );\n", mapid );

	numSkies = 0;
	cs = -1;
	stars = 0;

	for( DBCFile::Iterator i = gLightDB.begin(); i != gLightDB.end(); ++i )
	{
		if( mapid == i->getUInt( LightDB::Map ) )
		{
			Sky s( i );
			skies.push_back( s );
			numSkies++;
		}
	}

	// sort skies from smallest to largest; global last.
	// smaller skies will have precedence when calculating weights to achieve smooth transitions etc.
	std::sort( skies.begin( ), skies.end( ) );

	stars = new Model( "Environments\\Stars\\Stars.mdx", true );

}
void ExtractGameobjectModels()
{
    printf("Extracting GameObject models...");
    DBCFile dbc(LocaleMpq, "DBFilesClient\\GameObjectDisplayInfo.dbc");
    if(!dbc.open())
    {
        printf("Fatal error: Invalid GameObjectDisplayInfo.dbc file format!\n");
        exit(1);
    }

    std::string basepath = szWorkDirWmo;
    basepath += "/";
    std::string path;

    FILE * model_list = fopen((basepath + "temp_gameobject_models").c_str(), "wb");

    for (DBCFile::Iterator it = dbc.begin(); it != dbc.end(); ++it)
    {
        path = it->getString(1);

        if (path.length() < 4)
            continue;

        FixNameCase((char*)path.c_str(), path.size());
        char * name = GetPlainName((char*)path.c_str());
        FixNameSpaces(name, strlen(name));

        char * ch_ext = GetExtension(name);
        if (!ch_ext)
            continue;

        strToLower(ch_ext);

        bool result = false;
        if (!strcmp(ch_ext, ".wmo"))
            result = ExtractSingleWmo(path);
        else if (!strcmp(ch_ext, ".mdl"))   // TODO: extract .mdl files, if needed
            continue;
        else //if (!strcmp(ch_ext, ".mdx") || !strcmp(ch_ext, ".m2"))
            result = ExtractSingleModel(path);

        if (result)
        {
            uint32 displayId = it->getUInt(0);
            uint32 path_length = strlen(name);
            fwrite(&displayId, sizeof(uint32), 1, model_list);
            fwrite(&path_length, sizeof(uint32), 1, model_list);
            fwrite(name, sizeof(char), path_length, model_list);
        }
    }

    fclose(model_list);

    printf("Done!\n");
}
示例#4
0
void Menu::createMapList()
{
	for (DBCFile::Iterator i = gMapDB.begin(); i != gMapDB.end(); ++i)
	{
		MapEntry e;
		e.mapID = i->getInt(MapDB::MapID);
		e.name = i->getLocalizedString(MapDB::Name);
		e.areaType = i->getUInt(MapDB::AreaType);
		if (e.areaType == 3) e.name = i->getString(MapDB::InternalName);

		if (e.areaType < 0 || e.areaType > 3 || !World::IsEditableWorld(e.mapID))
			continue;

		mMaps.push_back(e);
	}
}
示例#5
0
void Menu::loadMap(int mapID)
{
	delete gWorld;
	gWorld = NULL;

	for (DBCFile::Iterator it = gMapDB.begin(); it != gMapDB.end(); ++it)
	{
		if (it->getInt(MapDB::MapID) == mapID)
		{
			gWorld = new World(it->getString(MapDB::InternalName));
			mGUIMinimapWindow->show();
			return;
		}
	}

	LogError << "Map with ID " << mapID << " not found. Failed loading." << std::endl;
}
示例#6
0
文件: Sky.cpp 项目: vienis/noggit
Skies::Skies(unsigned int mapid)
{
    numSkies = 0;
    cs = -1;
    stars = 0;

    for (DBCFile::Iterator i = gLightDB.begin(); i != gLightDB.end(); ++i)
    {
        if (mapid == i->getUInt(LightDB::Map))
        {
            Sky s(i);
            skies.push_back(s);
            numSkies++;
        }
    }

    if (numSkies == 0)
    {
        for (DBCFile::Iterator i = gLightDB.begin(); i != gLightDB.end(); ++i)
        {
            if (0 == i->getUInt(LightDB::Map))
            {
                Sky s(i);
                skies.push_back(s);
                numSkies++;
                break;
            }
        }
    }



    // sort skies from smallest to largest; global last.
    // smaller skies will have precedence when calculating weights to achieve smooth transitions etc.
    std::sort(skies.begin(), skies.end());

    stars = ModelManager::add("Environments\\Stars\\Stars.mdx");
}
示例#7
0
void UIWaterTypeBrowser::buildTypeList()
{
  removeChild( WaterTypeList );
  WaterTypeList = new UIListView(4,24,width() - 8,height() - 28,20);
  WaterTypeList->clickable( true );
  addChild(WaterTypeList);
 
 
  
  
  //LiquidTypeDB::getLiquidName(gWorld->getWaterType(tileX, tileY));

  for( DBCFile::Iterator i = gLiquidTypeDB.begin(); i != gLiquidTypeDB.end(); ++i )
  {

          UIFrame *curFrame = new UIFrame(1,1,1,1);
          std::stringstream ss;
          ss << i->getInt(LiquidTypeDB::ID) << "-" << LiquidTypeDB::getLiquidName(i->getInt(LiquidTypeDB::ID));
          UIButton *tempButton = new UIButton(0.0f,
                                              0.0f,
                                              200.0f,
                                              28.0f,
                                              ss.str(),
                                              "Interface\\DialogFrame\\UI-DialogBox-Background-Dark.blp",
                                              "Interface\\DialogFrame\\UI-DialogBox-Background-Dark.blp",
                                              boost::bind(&UIWaterTypeBrowser::setWaterTypeID, this, _1, _2), //steff: kidding me? we talked about this some h before u did this
                                              i->getInt(LiquidTypeDB::ID)
                                              );
          tempButton->setLeft();
          curFrame->addChild(tempButton);
          WaterTypeList->addElement(curFrame);
       
  }

  WaterTypeList->recalcElements(1);
}
示例#8
0
文件: Sky.cpp 项目: vienis/noggit
Sky::Sky(DBCFile::Iterator data)
{
    pos = Vec3D(data->getFloat(LightDB::PositionX) / skymul, data->getFloat(LightDB::PositionY) / skymul, data->getFloat(LightDB::PositionZ) / skymul);
    r1 = data->getFloat(LightDB::RadiusInner) / skymul;
    r2 = data->getFloat(LightDB::RadiusOuter) / skymul;

    for (int i = 0; i<36; ++i)
        mmin[i] = -2;

    global = (pos.x == 0.0f && pos.y == 0.0f && pos.z == 0.0f);

    int FirstId = data->getInt(LightDB::DataIDs) * 18 - 17; // cromons light fix ;) Thanks

    for (int i = 0; i < 18; ++i)
    {
        try
        {
            DBCFile::Record rec = gLightIntBandDB.getByID(FirstId + i);
            int entries = rec.getInt(LightIntBandDB::Entries);

            if (entries == 0)
                mmin[i] = -1;
            else
            {
                mmin[i] = rec.getInt(LightIntBandDB::Times);
                for (int l = 0; l < entries; l++)
                {
                    SkyColor sc(rec.getInt(LightIntBandDB::Times + l), rec.getInt(LightIntBandDB::Values + l));
                    colorRows[i].push_back(sc);
                }
            }
        }
        catch (...)
        {
            LogError << "When trying to intialize sky " << data->getInt(LightDB::ID) << ", there was an error with getting an entry in a DBC (" << i << "). Sorry." << std::endl;
            DBCFile::Record rec = gLightIntBandDB.getByID(i);
            int entries = rec.getInt(LightIntBandDB::Entries);

            if (entries == 0)
                mmin[i] = -1;
            else
            {
                mmin[i] = rec.getInt(LightIntBandDB::Times);
                for (int l = 0; l < entries; l++)
                {
                    SkyColor sc(rec.getInt(LightIntBandDB::Times + l), rec.getInt(LightIntBandDB::Values + l));
                    colorRows[i].push_back(sc);
                }
            }
        }
    }



    /*
    unsigned int SKYFOG = data->getInt( LightDB::DataIDs );
    unsigned int ID = data->getInt( LightDB::ID );
    DBCFile::Record rec = gLightParamsDB.getByID( SKYFOG );
    unsigned int skybox = rec.getInt( LightParamsDB::skybox);


    if ( skybox == 0 )
    alt_sky=NULL;
    else{
    DBCFile::Record rec = gLightSkyboxDB.getByID(skybox);
    std::string skyname= rec.getString(LightSkyboxDB::filename);
    alt_sky=new Model(skyname); // if this is ever uncommented, use ModelManager::
    Log << "Loaded sky " << skyname << std::endl;
    }

    */

}
void ExtractGameobjectModels()
{
    printf("\n");
    printf("Extracting GameObject models...\n");
    DBCFile dbc("DBFilesClient\\GameObjectDisplayInfo.dbc");
    if (!dbc.open())
    {
        printf("Fatal error: Invalid GameObjectDisplayInfo.dbc file format!\n");
        exit(1);
    }

    std::string basepath = szWorkDirWmo;
    basepath += "/";
    std::string path;
    StringSet failedPaths;

    FILE* model_list = fopen((basepath + "temp_gameobject_models").c_str(), "wb");

    for (DBCFile::Iterator it = dbc.begin(); it != dbc.end(); ++it)
    {
        path = it->getString(1);

        if (path.length() < 4)
            continue;

        fixnamen((char*)path.c_str(), path.size());
        char* name = GetPlainName((char*)path.c_str());
        fixname2(name, strlen(name));

        char* ch_ext = GetExtension(name);
        if (!ch_ext)
            continue;

        strToLower(ch_ext);

        bool result = false;
        if (!strcmp(ch_ext, ".wmo"))
        {
            result = ExtractSingleWmo(path);
        }
        else if (!strcmp(ch_ext, ".mdl"))
        {
            // TODO: extract .mdl files, if needed
            continue;
        }
        else //if (!strcmp(ch_ext, ".mdx") || !strcmp(ch_ext, ".m2"))
        {
            result = ExtractSingleModel(path, failedPaths);
        }

        if (result)
        {
            uint32 displayId = it->getUInt(0);
            uint32 path_length = strlen(name);
            fwrite(&displayId, sizeof(uint32), 1, model_list);
            fwrite(&path_length, sizeof(uint32), 1, model_list);
            fwrite(name, sizeof(char), path_length, model_list);
        }
    }

    fclose(model_list);

    if (!failedPaths.empty())
    {
        printf("Warning: Some models could not be extracted, see below\n");
        for (StringSet::const_iterator itr = failedPaths.begin(); itr != failedPaths.end(); ++itr)
            printf("Could not find file of model %s\n", itr->c_str());
        printf("A few of these warnings are expected to happen, so be not alarmed!\n");
    }

    printf("Done!\n");
}
示例#10
0
int main()
{
    InitMPQs();
    FILE* fo = fopen("display_bounding_boxes.sql", "w");
    DBCFile displayInfo("DBFilesClient\\CreatureDisplayInfo.dbc");
    DBCFile modelInfo("DBFilesClient\\CreatureModelData.dbc");
    displayInfo.open();
    modelInfo.open();

    std::map<uint32, DBCFile::Record> modelInfoEntries;
    std::map<std::string, ModelCache> modelCache;

    for (DBCFile::Iterator itr = modelInfo.begin(); itr != modelInfo.end(); ++itr)
    {
        unsigned int entry = itr->getInt(0);
        modelInfoEntries.insert(std::make_pair(entry, *itr));
    }

    for (DBCFile::Iterator itr = displayInfo.begin(); itr != displayInfo.end(); ++itr)
    {
        unsigned int displayid = itr->getInt(0);
        unsigned int modelentry = itr->getInt(1);
        float modelscale = itr->getFloat(4);

        std::map<uint32, DBCFile::Record>::iterator  modelitr = modelInfoEntries.find(modelentry);

        if (modelitr == modelInfoEntries.end())
        {
            printf("Cannot find model entry for display %u (entry %u)\n", displayid, modelentry);
            continue;
        }

        DBCFile::Record modelrec = modelitr->second;

        const char* modelname = modelrec.getString(2);

        std::string strmodelname(modelname);

        replace(strmodelname, ".mdx", ".m2", 0);
        replace(strmodelname, ".MDX", ".m2", 0);

        M2Header* header;
        M2Attachment* attachments;
        M2Bone* bones;
        uint16* bonelookups;

        std::map<std::string, ModelCache>::iterator cacheitr = modelCache.find(modelname);

        if (cacheitr == modelCache.end())
        {

            MPQFile modelf(strmodelname.c_str());

            if (modelf.isEof())
            {
                printf("Error: cannot open %s\n", strmodelname.c_str());
                continue;
            }

            printf("Processing %u", displayid);

            header = (M2Header*)malloc(sizeof(M2Header));
            modelf.read(header, sizeof(M2Header));

            printf(" %u attachments %u bone lookups %u bones\n", header->nAttachments, header->nBoneLookupTable, header->nBones);

            attachments = (M2Attachment*)malloc(header->nAttachments * sizeof(M2Attachment));
            modelf.seek(header->ofsAttachments);
            modelf.read(attachments, header->nAttachments * sizeof(M2Attachment));

            bonelookups = (uint16*)malloc(header->nBoneLookupTable * sizeof(uint16));
            modelf.seek(header->ofsBoneLookupTable);
            modelf.read(bonelookups, header->nBoneLookupTable * sizeof(uint16));

            bones = (M2Bone*)malloc(header->nBones * sizeof(M2Bone));
            modelf.seek(header->ofsBones);
            modelf.read(bones, header->nBones * sizeof(M2Bone));

            ModelCache cacheentry;
            cacheentry.attachments = attachments;
            cacheentry.bones = bones;
            cacheentry.bonelookups = bonelookups;
            cacheentry.header = header;
            modelCache.insert(std::make_pair(modelname, cacheentry));
        }
        else
        {
            header = cacheitr->second.header;
            bones = cacheitr->second.bones;
            bonelookups = cacheitr->second.bonelookups;
            attachments = cacheitr->second.attachments;
        }

        //try and get the bone
        for (uint32 i = 0; i < header->nAttachments; ++i)
        {
            if (attachments[i].bone > header->nBoneLookupTable)
            {
                printf("Attachment %u requests bonelookup %u (too large, bonelookup table is only %u entries)\n", i, attachments[i].bone, header->nBoneLookupTable);
                continue;
            }
            uint16 boneindex = bonelookups[attachments[i].bone];
            if (boneindex > header->nBones)
            {
                printf("Attachment %u requests bone %u (too large, bone table is only %u entries)\n", i, boneindex, header->nBones);
                continue;
            }
            M2Bone & bone = bones[boneindex];
            //printf("Attachment %u (bone pivot %f %f %f offset %f %f %f)\n", attachments[i].id, bone.pivotpoint[0], bone.pivotpoint[1], bone.pivotpoint[2], attachments[i].pos[0],  attachments[i].pos[1],  attachments[i].pos[2]);

            float realpos[3];
            realpos[0] = (/*bone.pivotpoint[0] +*/ attachments[i].pos[0]) * modelscale;
            realpos[1] = (/*bone.pivotpoint[1] +*/ attachments[i].pos[1]) * modelscale;
            realpos[2] = (/*bone.pivotpoint[2] +*/ attachments[i].pos[2]) * modelscale;

            //fix coord system
            //             float tmp = realpos[2];
            //             realpos[2] = realpos[1];
            //             realpos[1] = -tmp;
            //fprintf(fo, "insert into `display_attachment_points` VALUES (%u, %u, %f, %f, %f);\n", displayid, attachments[i].id, attachments[i].pos[0], attachments[i].pos[1], attachments[i].pos[2]);
            //printf("Attachmnent %u point %f %f %f pivot %f %f %f\n", attachments[i].id, realpos[0], realpos[1], realpos[2], bone.pivotpoint[0], bone.pivotpoint[1], bone.pivotpoint[2]);
        }

        float boundlow[3];
        boundlow[0] = header->boundingbox1[0] * modelscale;
        boundlow[1] = header->boundingbox1[1] * modelscale;
        boundlow[2] = header->boundingbox1[2] * modelscale;
        float boundhigh[3];
        boundhigh[0] = header->boundingbox2[0] * modelscale;
        boundhigh[1] = header->boundingbox2[1] * modelscale;
        boundhigh[2] = header->boundingbox2[2] * modelscale;
        float boundradius = header->boundingradius * modelscale;
        fprintf(fo, "insert into `display_bounding_boxes` VALUES (%u, %f, %f, %f, %f, %f, %f, %f);\n", displayid, boundlow[0], boundlow[1], boundlow[2], boundhigh[0], boundhigh[1], boundhigh[2], boundradius);
    }
    fclose(fo);
    return 0;
}
示例#11
0
void ExtractGameobjectModels(int iCoreNumber, const void *szRawVMAPMagic)
{
    printf("\n");
    printf("Extracting GameObject models...\n");
    DBCFile dbc("DBFilesClient\\GameObjectDisplayInfo.dbc");
    if (!dbc.open())
    {
        printf("Fatal error: Invalid GameObjectDisplayInfo.dbc file format!\n");
        exit(1);
    }

    std::string basepath = szWorkDirWmo;
    basepath += "/";
    std::string path;
    StringSet failedPaths;

    FILE* model_list = fopen((basepath + "temp_gameobject_models").c_str(), "wb");

    for (DBCFile::Iterator it = dbc.begin(); it != dbc.end(); ++it)
    {
        path = it->getString(1);

        if (path.length() < 4)
            { continue; }

        string name;

        string ch_ext = GetExtension(path);
        if (ch_ext.empty())
            { continue; }

        bool result = false;
        if (ch_ext == "wmo")
        {
            name = GetUniformName(path);
            result = ExtractSingleWmo(path, iCoreNumber, szRawVMAPMagic);
        }
        else
        {
            result = ExtractSingleModel(path, name, failedPaths, iCoreNumber, szRawVMAPMagic);
        }

        if (result && FileExists((basepath + name).c_str()))
        {
            uint32 displayId = it->getUInt(0);
            uint32 path_length = name.length();
            fwrite(&displayId, sizeof(uint32), 1, model_list);
            fwrite(&path_length, sizeof(uint32), 1, model_list);
            fwrite(name.c_str(), sizeof(char), path_length, model_list);
        }
    }

    fclose(model_list);

    if (!failedPaths.empty())
    {
        printf("\n Warning: Some models could not be extracted, see below\n");
        for (StringSet::const_iterator itr = failedPaths.begin(); itr != failedPaths.end(); ++itr)
            { printf(" Could not find file of model %s\n", itr->c_str()); }
        printf("\n A few of these warnings are expected to happen, so be not alarmed!\n");
    }

    printf("\n Asset Extraction Complete !\n");
}
void ExtractGameobjectModels(char* input_path)
{
    HANDLE localeFile;
    char localMPQ[512];

    sprintf(localMPQ, "%smisc.MPQ", input_path);
    if (FileExists(localMPQ)==false)
    {   // Use misc.mpq
        printf(localMPQ, "%s/Data/%s/locale-%s.MPQ", input_path);
    }
        
    if (!SFileOpenArchive(localMPQ, 0, MPQ_OPEN_READ_ONLY, &localeFile))
    {
        exit(1);
    }

    printf("Extracting GameObject models...");
    DBCFile dbc(localeFile, "DBFilesClient\\GameObjectDisplayInfo.dbc");
    if(!dbc.open())
    {
        printf("Fatal error: Invalid GameObjectDisplayInfo.dbc file format!\n");
        exit(1);
    }

    std::string basepath = szWorkDirWmo;
    basepath += "/";
    std::string path;

    FILE * model_list = fopen((basepath + "temp_gameobject_models").c_str(), "wb");

    for (DBCFile::Iterator it = dbc.begin(); it != dbc.end(); ++it)
    {
        path = it->getString(1);

        if (path.length() < 4)
            continue;

        FixNameCase((char*)path.c_str(), path.size());
        char * name = GetPlainName((char*)path.c_str());
        FixNameSpaces(name, strlen(name));

        char * ch_ext = GetExtension(name);
        if (!ch_ext)
            continue;

        strToLower(ch_ext);

        bool result = false;
        if (!strcmp(ch_ext, ".wmo"))
            result = ExtractSingleWmo(path);
        else if (!strcmp(ch_ext, ".mdl"))   // TODO: extract .mdl files, if needed
            continue;
        else //if (!strcmp(ch_ext, ".mdx") || !strcmp(ch_ext, ".m2"))
            result = ExtractSingleModel(path);

        if (result)
        {
            uint32 displayId = it->getUInt(0);
            uint32 path_length = strlen(name);
            fwrite(&displayId, sizeof(uint32), 1, model_list);
            fwrite(&path_length, sizeof(uint32), 1, model_list);
            fwrite(name, sizeof(char), path_length, model_list);
        }
    }

    fclose(model_list);

    printf("Done!\n");
}