Пример #1
0
int SectorLoadLightFix::ReadLightFromDiff(TioFile* file, SectorLight** lightOut) {

	auto& particles = gameSystems->GetParticleSys();

	/*
		ToEE would let the light read from the original sector file leak,
		so we take care of it here and destroy the light and the particle
		systems that might have been created.
	*/
	auto lightOrg = *lightOut;
	if (lightOrg) {
		if (lightOrg->flags & 0x50) {
			auto partSys1 = lightOrg->partSys;
			if (partSys1.handle) {
				particles.Remove(partSys1.handle);
			}
		}
		if (lightOrg->flags & 0x40) {
			auto partSys2 = lightOrg->light2.partSys;
			if (partSys2.handle) {
				particles.Remove(partSys2.handle);
			}
		}

		free(lightOrg);
	}

	return ReadLight(file, lightOut);
}
Пример #2
0
bool SceneReader::readScene(std::istream &in, Camera& cam, Scene& scene) {
    std::string line;
    while (std::getline(in, line)){
	std::istringstream is(line);
	std::string type;
	is >> type;
	if (readFuncs.find(type) != readFuncs.end()) {
	    SPSceneObject newObj;
	    newObj = readFuncs[type](is);
	    scene.addObject(newObj);
	} else if (type == "light") {
	    SPLight newLight;
	    newLight = ReadLight(is);
	    scene.addLight(newLight);
	} else if (type == "camera") {
	    is >> cam;
	} else if (type == "" || type == "#" || type == "//") {
Пример #3
0
bool L3DS::Read3DS()
{
    LChunk mainchunk;
    LChunk edit;
    edit.id = EDIT3DS;
    mainchunk = ReadChunk();
    if (mainchunk.id != MAIN3DS)
    {
        fprintf(stderr, "L3DS::Read3DS - wrong file format");
        return false;
    }
    if (!FindChunk(edit, mainchunk))
        return false;
    LChunk obj;
    LChunk ml;

    GotoChunk(edit);
    obj.id = MAT_ENTRY;
    while (FindChunk(obj, edit))
    {
        ReadMaterial(obj);
        SkipChunk(obj);
    }
    GotoChunk(edit);

    obj.id = EDIT_OBJECT;
    {
        while (FindChunk(obj, edit))
        {
            ReadASCIIZ(m_objName, 99);
            ml = ReadChunk();
            if (ml.id == OBJ_TRIMESH)
                ReadMesh(ml);
            else
            if (ml.id == OBJ_LIGHT)
                ReadLight(ml);
            else
            if (ml.id == OBJ_CAMERA)
                ReadCamera(ml);
            SkipChunk(obj);
        }
    }

    // read the keyframer data here to find out correct object orientation

    LChunk keyframer;
    keyframer.id = KFDATA;

    LChunk objtrack;
    objtrack.id = OBJECT_NODE_TAG;

    GotoChunk(mainchunk);
    if (FindChunk(keyframer, mainchunk))
    {   // keyframer chunk is present
        GotoChunk(keyframer);
        while (FindChunk(objtrack, keyframer))
        {
            ReadKeyframeData(objtrack);
            SkipChunk(objtrack);
        }
    }

    for (uint i=0; i<m_meshes.size(); i++)
        m_meshes[i].Optimize(m_optLevel);
    m_pos = 0;
    strcpy(m_objName, "");
    return true;
}