//----------------------------------------------------------------------
 void WalkmeshFileSerializer::readObject( Ogre::DataStreamPtr &stream
                                         ,WalkmeshFileSerializer::Triangle &pDest)
 {
     readObject( stream, pDest.a );
     readObject( stream, pDest.b );
     readObject( stream, pDest.c );
 }
Ejemplo n.º 2
0
    //---------------------------------------------------------------------
    void SkeletonSerializer::readBone(DataStreamPtr& stream, Skeleton* pSkel)
    {
        // char* name
        String name = readString(stream);
        // unsigned short handle            : handle of the bone, should be contiguous & start at 0
        unsigned short handle;
        readShorts(stream, &handle, 1);

        // Create new bone
        Bone* pBone = pSkel->createBone(name, handle);

        // Vector3 position                 : position of this bone relative to parent 
        Vector3 pos;
        readObject(stream, pos);
        pBone->setPosition(pos);
        // Quaternion orientation           : orientation of this bone relative to parent 
        Quaternion q;
        readObject(stream, q);
        pBone->setOrientation(q);

#if OGRE_SERIALIZER_VALIDATE_CHUNKSIZE
        // Hack to fix chunk size validation:
        mChunkSizeStack.back() += calcStringSize(name);
#endif
        // TODO: don't depend on mCurrentstreamLen in next skeleton format!
        // Currently we use wrong chunk sizes, but we can't fix it, because we depend on mCurrentstreamLen
        // Do we have scale?
        if (mCurrentstreamLen > calcBoneSizeWithoutScale(pSkel, pBone))
        {
            Vector3 scale;
            readObject(stream, scale);
            pBone->setScale(scale);
        }
        
    }
Ejemplo n.º 3
0
core::Error readObject(const json::Object& object,
                       const std::string& name1, T1* pValue1,
                       const std::string& name2, T2* pValue2,
                       const std::string& name3, T3* pValue3,
                       const std::string& name4, T4* pValue4,
                       const std::string& name5, T5* pValue5,
                       const std::string& name6, T6* pValue6,
                       const std::string& name7, T7* pValue7,
                       const std::string& name8, T8* pValue8,
                       const std::string& name9, T9* pValue9,
                       const std::string& name10, T10* pValue10)
{
   Error error = readObject(object,
                            name1, pValue1,
                            name2, pValue2,
                            name3, pValue3,
                            name4, pValue4,
                            name5, pValue5,
                            name6, pValue6,
                            name7, pValue7,
                            name8, pValue8,
                            name9, pValue9);
   if (error)
      return error;

   return readObject(object, name10, pValue10);
}
Ejemplo n.º 4
0
void PersistEngine::read(PersistObject *&object) throw(PersistException)
{
  uint32_t id = 0;
  read(id);
  // Is the ID a NULL object?
  if (id == NullObject) {
    object = NULL;
    return;
  }

  // Do we already have this object in memory?
  if (id < myArchiveVector.size()) {
    object = myArchiveVector[id];
    return;
  }

  // Okay - read the identifier for the class in...
  std::string className = readClass();

  // is the pointer already initialized? if so then no need to reallocate
  if (object != NULL) {
    readObject(object);
    return;
  }

  // Create the object (of the relevant type)
  object = TypeManager::createInstanceOf(className.c_str());
  if (object) {
    // Okay then - we can make this object
    readObject(object);
  }
  else
    throw(PersistException(std::string("Unable to instantiate object of class ")+className));
}
    //---------------------------------------------------------------------
    void SkeletonSerializer::readBone(DataStreamPtr& stream, Skeleton* pSkel)
    {
        // char* name
        String name = readString(stream);
        // unsigned short handle            : handle of the bone, should be contiguous & start at 0
        unsigned short handle;
        readShorts(stream, &handle, 1);

        // Create new bone
        Bone* pBone = pSkel->createBone(name, handle);

        // Vector3 position                 : position of this bone relative to parent 
        Vector3 pos;
        readObject(stream, pos);
        pBone->setPosition(pos);
        // Quaternion orientation           : orientation of this bone relative to parent 
        Quaternion q;
        readObject(stream, q);
        pBone->setOrientation(q);
        // Do we have scale?
        if (mCurrentstreamLen > calcBoneSizeWithoutScale(pSkel, pBone))
        {
            Vector3 scale;
            readObject(stream, scale);
            pBone->setScale(scale);
        }
    }
    //---------------------------------------------------------------------
    void SkeletonSerializer::readKeyFrame(DataStreamPtr& stream, NodeAnimationTrack* track, 
        Skeleton* pSkel)
    {
        // float time                    : The time position (seconds)
        float time;
        readFloats(stream, &time, 1);

        TransformKeyFrame *kf = track->createNodeKeyFrame(time);

        // Quaternion rotate            : Rotation to apply at this keyframe
        Quaternion rot;
        readObject(stream, rot);
        kf->setRotation(rot);
        // Vector3 translate            : Translation to apply at this keyframe
        Vector3 trans;
        readObject(stream, trans);
        kf->setTranslate(trans);
        // Do we have scale?
        if (mCurrentstreamLen > calcKeyFrameSizeWithoutScale(pSkel, kf))
        {
            Vector3 scale;
            readObject(stream, scale);
            kf->setScale(scale);
        }
    }
Ejemplo n.º 7
0
CompareData::CompareData (SharedPtr<DataBlock> a, SharedPtr<DataBlock> b)
	: Operation	("CompareData")
	, m_a		(a)
	, m_b		(b)
{
	readObject(SharedPtr<Object>(a));
	readObject(SharedPtr<Object>(b));
}
Ejemplo n.º 8
0
core::Error readObject(const json::Object& object, 
                       const std::string& name1, T1* pValue1,
                       const std::string& name2, T2* pValue2)
{
   Error error = readObject(object, name1, pValue1);
   if (error)
      return error;
   
   return readObject(object, name2, pValue2);
}
	void LodConfigSerializer::readLodProfile()
	{
		uint32 size = 0;
		readInts(mStream, &size, 1);
		mLodConfig->advanced.profile.clear();
		while(size--){
			ProfiledEdge pv;
			readObject(mStream, pv.src);
			readObject(mStream, pv.dst);
			readFloats(mStream, &pv.cost, 1);
			mLodConfig->advanced.profile.push_back(pv);
		}
	}
Ejemplo n.º 10
0
core::Error readObject(const json::Object& object, 
                       const std::string& name1, T1* pValue1,
                       const std::string& name2, T2* pValue2,
                       const std::string& name3, T3* pValue3,
                       const std::string& name4, T4* pValue4)
{
   Error error = readObject(object, 
                            name1, pValue1, 
                            name2, pValue2,
                            name3, pValue3);
   if (error)
      return error;
   
   return readObject(object, name4, pValue4);
}
Ejemplo n.º 11
0
Archivo: Uc.cpp Proyecto: SciBoy/douml
void Uc::import(File & f) {
  for (;;) {
    Q3CString s;

    switch (f.read(s)) {
    case -1:
      f.eof();
      throw 0;
    case ')':
      return;
    case ATOM:
      if ((s == "logical_models") || 
          (s == "logical_presentations")) {
        f.read("(");
        f.read("list");
        f.read("unit_reference_list");
        readObjects(f);
      }
      else
	readObject(f, s);
      break;
    default:
      f.syntaxError(s);
    }
  }
}
Ejemplo n.º 12
0
static Obj *readDict( istream& is )
{
	string lhs;
	Obj *rhs;

	map<string,Obj*> ret;

	is.get();

	while( true ) {
		eat( is );
		if( is.peek() == '}' ) {
			is.get();
			return new DictObj( ret );
		}
		lhs = readID( is );
		eat( is );
		if( is.get() != '=' ) {
			throw ParseError( "Parse error: expected equals." );
		}
		rhs = readObject( is );
		ret[ lhs ] = rhs;
		eat( is );
		int ch = is.peek();
		if( ch == ';' ) {
			is.get();
		} else if( ch != '}' ) {
			throw ParseError( "Parse error: expected semicolon or brace." );
		}
	}
}
Ejemplo n.º 13
0
core::Error readObjectParam(const json::Array& params,
                            unsigned int index,
                            const std::string& name1, T1* pValue1,
                            const std::string& name2, T2* pValue2,
                            const std::string& name3, T3* pValue3,
                            const std::string& name4, T4* pValue4,
                            const std::string& name5, T5* pValue5,
                            const std::string& name6, T6* pValue6,
                            const std::string& name7, T7* pValue7,
                            const std::string& name8, T8* pValue8,
                            const std::string& name9, T9* pValue9,
                            const std::string& name10, T10* pValue10)
{
   json::Object object;
   Error error = json::readParam(params, index, &object);
   if (error)
      return error;

   return readObject(object,
                     name1, pValue1,
                     name2, pValue2,
                     name3, pValue3,
                     name4, pValue4,
                     name5, pValue5,
                     name6, pValue6,
                     name7, pValue7,
                     name8, pValue8,
                     name9, pValue9,
                     name10, pValue10);
}
    //---------------------------------------------------------------------
    void
    BackgroundFileSerializer::readObject( Ogre::DataStreamPtr &stream, Page &pDest )
    {
        read2ByteBool( stream, pDest.enabled );
        if( !pDest.enabled ) return;

        readShort( stream, pDest.unknown_02 );
        readShort( stream, pDest.value_size );
        if( pDest.value_size != 1 && pDest.value_size != 2 )
        {
            OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS
                ,"Page value_size other then 1 and 2 is not supported"
                ,"BackgroundFileSerializer::readObject" );
        }

        size_t color_count( BackgroundFile::PAGE_DATA_SIZE );
        pDest.colors.clear();
        pDest.data.clear();

        if( pDest.value_size == 2 )
        {
            pDest.colors.reserve( color_count );
            for( size_t i( color_count ); i--; )
            {
                Color colourDest;
                readObject( stream, colourDest );
                pDest.colors.push_back( colourDest );
            }
        }
        else
        {
            pDest.data.resize( color_count );
            stream->read( &pDest.data[0], color_count );
        }
    }
Ejemplo n.º 15
0
Archivo: IFile.cpp Proyecto: Jon0/genie
//------------------------------------------------------------------------------
void IFile::load(const char *fileName) throw (std::ios_base::failure)
{
  if (loaded_)
  {
    unload();
    loaded_ = false;
  }

  fileName_ = std::string(fileName);

  fileIn_.close(); //TODO: necessary?

  fileIn_.open(fileName, std::ios::binary | std::ios::in);

  if (fileIn_.fail())
  {
    fileIn_.close();
    throw std::ios_base::failure("Cant read file: \"" + fileName_ + "\"");
  }
  else
  {
    readObject(fileIn_);
    loaded_ = true;
  }
}
Ejemplo n.º 16
0
bool SceneTutorial27::InitObjects()
{
    if( ! readObject("Data/Object2.txt", obj) ) {
        return false;
    }
    
    return true;
}
Ejemplo n.º 17
0
static std::vector<readObject> createCondensedObjects(std::vector<T> reads) {
  std::vector<readObject> ans;
  readVec::allSetCondensedSeq(reads);
  for (const auto& read : reads) {
    ans.emplace_back(readObject(seqInfo(read.seqBase_.name_, read.condensedSeq,
                                        read.condensedSeqQual)));
  }
  return ans;
}
 //---------------------------------------------------------------------
 void
 BackgroundFileSerializer::readTexture( Ogre::DataStreamPtr &stream
                                       ,BackgroundFile *pDest )
 {
     readSectionHeader( stream, SECTION_NAME_TEXTURE );
     for (auto& page : pDest->getPages())
     {
         readObject(stream, page);
     }
 }
Ejemplo n.º 19
0
void Save::readBullet(Bullet* mBullet, string& property, string& value)
{
	if (!readObject(mBullet, property, value))
	{
		if (!property.compare("speedXY"))
		{
			mBullet->setSpeedXY(stof(value));
			mBullet->getEntity2d()->setBoundingAreas("../SpaceGame/resources/green_beam_collisions.xml");
		}
	}
}
Ejemplo n.º 20
0
void Save::readSatellite(Satellite* mSatellite, string& property, string& value)
{
	if (!readObject(mSatellite, property, value))
	{
		if (!property.compare("orbitRadius"))
		{
			mSatellite->setOrbitRadius(stof(value));
			mSatellite->getEntity2d()->setBoundingCircle("satellite", mSatellite->getSurface()->getWidth() / 2.0f, mSatellite->getSurface()->getWidth() / 2.0f, mSatellite->getSurface()->getWidth() / 2.0f);
			getMI()->_animationManager->addToSurface(mSatellite->getAnimationDust(), "../SpaceGame/resources/animations/dust.xml", IND_ALPHA, IND_32, 255, 0, 255);
		}
	}
}
Ejemplo n.º 21
0
core::Error readObjectParam(const json::Array& params, 
                            unsigned int index,
                            const std::string& name1, T1* pValue1,
                            const std::string& name2, T2* pValue2)
{
   json::Object object;
   Error error = json::readParam(params, index, &object);
   if (error)
      return error;
   
   return readObject(object, name1, pValue1, name2, pValue2);
}
Ejemplo n.º 22
0
void Save::readPlanet(Planet* mPlanet, string& property, string& value)
{
	if (!readObject(mPlanet, property, value))
	{
		
		if (!property.compare("circleTrajectory"))
		{
			mPlanet->setCircleTrajectory(stoi(value));
		}
		if (!property.compare("orbitRadius"))
		{
			mPlanet->setOrbitRadius(stof(value));
			mPlanet->getEntity2d()->setBoundingCircle("planet", mPlanet->getSurface()->getWidth() / 2.0f, mPlanet->getSurface()->getWidth() / 2.0f, mPlanet->getSurface()->getWidth() / 2.0f);
		}
		if (!property.compare("timer"))
		{
			mPlanet->setTimer(stof(value));
		}
		if (!property.compare("shootingFrequency"))
		{
			mPlanet->setShootingFrequency(stof(value));
		}
		if (!property.compare(0, 6, "bullet"))
		{
			// extract the serial number of the bullet
			int id = std::stoi(property.substr(6, property.find_first_of("-") - 6));
			if (mPlanet->getBullets().size() <= id)
			{
				mPlanet->getBullets().push_back(new Bullet());
				mPlanet->getBullets().back()->setMI(getMI());
			}

			// change property so that it contains only the actual property of the bullet
			property = property.substr(property.find_first_of("-") + 1, property.find_first_of("]") - property.find_first_of("-") - 1);
			readBullet(mPlanet->getBullets().back(), property, value);
		}
		if (!property.compare(0, 9, "satellite"))
		{
			// extract the serial number of the satellite
			int id = std::stoi(property.substr(9, 1));
			if (mPlanet->getSatellites().size() <= id)
			{
				mPlanet->getSatellites().push_back(new Satellite());
				mPlanet->getSatellites().back()->setMI(getMI());
			}

			// change property so that it contains only the actual property of the satellite
			property = property.substr(property.find_first_of("-") + 1, property.find_first_of("]") - property.find_first_of("-") - 1);
			readSatellite(mPlanet->getSatellites().back(), property, value);
		}
	}
}
Ejemplo n.º 23
0
 void
 WalkmeshFileSerializer::readVector( Ogre::DataStreamPtr &stream
                                    ,std::vector<ValueType> &pDest
                                    ,size_t count )
 {
     pDest.clear();
     pDest.reserve( count );
     for( size_t i( count ); i--; )
     {
         ValueType in_tmp;
         readObject( stream, in_tmp );
         pDest.push_back( in_tmp );
     }
 }
Ejemplo n.º 24
0
bool
Reader::readValue()
{
   Token token;
   skipCommentTokens( token );
   bool successful = true;

   if ( collectComments_  &&  !commentsBefore_.empty() )
   {
      currentValue().setComment( commentsBefore_, commentBefore );
      commentsBefore_ = "";
   }


   switch ( token.type_ )
   {
   case tokenObjectBegin:
      successful = readObject( token );
      break;
   case tokenArrayBegin:
      successful = readArray( token );
      break;
   case tokenNumber:
      successful = decodeNumber( token );
      break;
   case tokenString:
      successful = decodeString( token );
      break;
   case tokenTrue:
      currentValue() = true;
      break;
   case tokenFalse:
      currentValue() = false;
      break;
   case tokenNull:
      currentValue() = Value();
      break;
   default:
      return addError( "Syntax error: value, object or array expected.", token );
   }

   if ( collectComments_ )
   {
      lastValueEnd_ = current_;
      lastValue_ = &currentValue();
   }

   return successful;
}
bool ProceduralTerrainAppearance::load(IffStream* iffStream) {
	waterBoundaries.removeAll();

	delete terrainGenerator;
	delete terrainMaps;

	terrainGenerator = new TerrainGenerator(this);
	terrainMaps = new TerrainMaps();

	readObject(iffStream);

	terrainGenerator->processLayers();

	return true;
}
Ejemplo n.º 26
0
osgDB::ReaderWriter::ReadResult ReaderWriterCURLEX::readObject(const std::string& fileName,
	const osgDB::ReaderWriter::Options* options) const
{
	std::string ext = osgDB::getFileExtension(fileName);
	if (options != NULL && acceptsExtension(options->getPluginStringData("VIRTUALDATASCENE_DEFINE_PLUGIN")) && acceptsExtension(ext))
	{
		std::string sFileName = fileName;
#if _WIN32
		tryConvertStringFromUTF8ToGB2312(fileName, sFileName);
#endif
		std::ifstream fin(sFileName.c_str(), std::ios::binary | std::ios::in);
		return readObject(fin, options);
	}
	return osgDB::ReaderWriter::ReadResult::FILE_NOT_HANDLED;
}
Ejemplo n.º 27
0
        virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options =NULL) const
        {
            if (file=="ScriptEngine.python") return new python::PythonScriptEngine();

            std::string ext = osgDB::getLowerCaseFileExtension(file);
            if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;

            std::string fileName = osgDB::findDataFile( file, options );
            if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;

            osgDB::ifstream istream(fileName.c_str(), std::ios::in);
            if(!istream) return ReadResult::FILE_NOT_HANDLED;

            return readObject(istream, options);
        }
Ejemplo n.º 28
0
void Picture::render(Pixel* pix)
{
	double eX, eY, eZ, aX, aY, aZ, fov, zMin, zMax;
	Vector *vUp;
	vUp = readCamera(&eX, &eY, &eZ, &aX, &aY, &aZ);
	readFOV(&zMax, &zMin, &fov);
	BasicObject* obj = readObject("sphere.txt");
	InstanceObject* io = buildInstanceObject("trs.txt", obj);
	Scene *sc;
	Matrix *windowTransform = AffineTransforms::getWindowTransform(pix->getWidth(), pix->getHeight());
	Matrix *aspectRatioTransform = AffineTransforms::getAspectTransform(pix->getWidth(), pix->getHeight(), fov);
	Matrix *normalTransform = AffineTransforms::getNormalTransform(zMin, zMax);
	Matrix *cameraTransform = AffineTransforms::getCameraTransform(eX, eY, eZ, aX, aY, aZ, vUp);
	Matrix *WNAC;

	/*printf("\nCamera: \n");
	cameraTransform->printMatrix();
	printf("\nNormal: \n");
	normalTransform->printMatrix();
	printf("\nAspect Ratio: \n");
	aspectRatioTransform->printMatrix();
	printf("\nWindow: \n");
	windowTransform->printMatrix();*/
	
	Matrix *temp = aspectRatioTransform->multiply(cameraTransform);
	Matrix *temp2 = normalTransform->multiply(temp);
	WNAC = windowTransform->multiply(temp2);

	
	//WNAC->printMatrix();

	delete temp;
	delete temp2;
	delete cameraTransform;
	delete normalTransform;
	delete windowTransform;
	delete aspectRatioTransform;
	
	sc = new Scene(WNAC);


	sc->addNode(io);

	sc->render(pix);

	delete sc;
	printf("\n\n");
}
Ejemplo n.º 29
0
static void readData(const uint8_t* ptr, a3dsDataT* a3ds) {
    chunkT* chunk = (chunkT*)ptr;
    ptr = chunk->data;

    assert(chunk->id == 0x3d3d);

    void* chunk_end = (uint8_t*)chunk + chunk->length;
    while (ptr < chunk_end) {
        chunk = (chunkT*)ptr;

                  if (chunk->id == 0x4000) readObject (ptr, a3ds);
             else if (chunk->id == 0xafff) readMaterial(ptr, a3ds);

        ptr = (uint8_t*)chunk + chunk->length;
    }
}
Ejemplo n.º 30
0
vector<Objet3D> ObjParser::readFile (const char * filename, vector<Objet3D> pObjets) {

	FILE* fichier;
	char ligne[255];
	
	objets = pObjets;
	cptFaces = 0;
	cptObjects = 0;
	vObj = new Objet3D(); //Un objet par fichier
	vObj->setNom(filename);
	
	fichier = fopen(filename, "r");
	
	while(!feof(fichier)) {
		ligne[0] = '\0';
		fscanf(fichier, "%s", ligne);

		if(strcmp((const char*)ligne, (char*)"v") == 0)
			readVertex(fichier);

		if(strcmp((const char*)ligne, (char*)"vn") == 0)
			readVertexNormal(fichier);

		if(strcmp((const char*)ligne, (char*)"o") == 0)
			readObject(fichier);

		if(strcmp((const char*)ligne, (char*)"f") == 0)
			readFace(fichier);
		
		if(strcmp((const char*)ligne, (char*)"mtllib") == 0) {
			readMaterialLibrary(fichier);
			char mtlfilename[50];
			sprintf(mtlfilename, ".\\ressources\\%s", nomMtlLib);
			readMtlFile(mtlfilename);
		}
		
		if(strcmp((const char*)ligne, (char*)"usemtl") == 0)
			readMaterialUsed(fichier);
	}
	
	//ASCH 02/08/15 - Insère le dernier objet lu en mémoire.
	insertObject();
	cptFaces = 0;	
	fclose(fichier);
	return objets;
}