コード例 #1
0
ファイル: PhysicObject.cpp プロジェクト: muhaos/MHEngine
void PhysicObject::savePhysProperties(FILE* f) {
	writeChar(isEnabledPhysics(), f);
	if (!isEnabledPhysics())
		return;
	writeFloat(getMass(), f);
	writeVector(getAngularFactor(), f);
	writeVector(getLinearFactor(), f);
	//writeVector(getLinearVelocity(), f);
	writeChar(isTrigger(), f);
	writeChar(getCollisionShapeType(), f);
	writeChar(isEnableDeactivation(), f);
	writeFloat(getFriction(), f);
	writeFloat(getRestitution(), f);
	writeFloat(getLinearDumping(), f);
	writeFloat(getAngularDumping(), f);

	// save custom collision shape
	if (getCollisionShapeType() == CST_CUSTOM) {
		if (getCollisionShape() == NULL)
			Log::error("Can't save custom col. shape. (shape is NULL) id=%s", objectID.c_str());
		writeChar(getCollisionShape()->getCollisionShapeType() , f);
		getCollisionShape()->save(f);
	}

	// save constraints
	writeChar(getConstrains().size(), f);
	for (unsigned int i = 0; i < getConstrains().size(); i++) {
		writeChar(getConstrains().at(i)->getType(), f);
		getConstrains().at(i)->save(f);
	}
}
コード例 #2
0
ファイル: ProcFile.cpp プロジェクト: BielBdeLuna/DarkRadiant
std::ostream& ProcFile::writeOutputPortals(std::ostream& str, ProcEntity& entity)
{
	str << (boost::format("interAreaPortals { /* numAreas = */ %i /* numIAP = */ %i") % entity.numAreas % interAreaPortals.size()) 
		<< std::endl << std::endl;

	str << "/* interAreaPortal format is: numPoints positiveSideArea negativeSideArea ( point) ... */" << std::endl;

	for (std::size_t i = 0; i < interAreaPortals.size(); ++i)
	{
		const ProcInterAreaPortal& iap = interAreaPortals[i];
		const ProcWinding& w = iap.side->winding;

		str << (boost::format("/* iap %i */ %i %i %i ") % i % w.size() % iap.area0 % iap.area1);

		str << "( ";

		for (std::size_t j = 0; j < w.size(); ++j)
		{
			writeFloat(str, w[j].vertex[0]);
			writeFloat(str, w[j].vertex[1]);
			writeFloat(str, w[j].vertex[2]);
		}

		str << ") ";

		str << std::endl;
	}

	str << "}" << std::endl<< std::endl;

	return str;
}
コード例 #3
0
void DataOutputStream::writeVec4(const osg::Vec4& v){
    writeFloat(v.x());
    writeFloat(v.y());
    writeFloat(v.z());
    writeFloat(v.w());

    if (_verboseOutput) std::cout<<"read/writeVec4() ["<<v<<"]"<<std::endl;
}
コード例 #4
0
void DataOutputStream::writeQuat(const osg::Quat& q){
    writeFloat(q.x());
    writeFloat(q.y());
    writeFloat(q.z());
    writeFloat(q.w());

    if (_verboseOutput) std::cout<<"read/writeQuat() ["<<q<<"]"<<std::endl;
}
コード例 #5
0
OGRGTMDataSource::~OGRGTMDataSource()
{
    if (fpTmpTrackpoints != NULL)
        VSIFCloseL( fpTmpTrackpoints );
       
    if (fpTmpTracks != NULL)
        VSIFCloseL( fpTmpTracks );
       
    WriteWaypointStyles();
    AppendTemporaryFiles();  
  
    if( fpOutput != NULL )
    { 
        /* Adjust header counters */
        VSIFSeekL(fpOutput, NWPTS_OFFSET, SEEK_SET);
        writeInt(fpOutput, numWaypoints);
        writeInt(fpOutput, numTrackpoints);

        VSIFSeekL(fpOutput, NTK_OFFSET, SEEK_SET);
        writeInt(fpOutput, numTracks);

        /* Adjust header bounds */
        VSIFSeekL(fpOutput, BOUNDS_OFFSET, SEEK_SET);
        writeFloat(fpOutput, maxlon);
        writeFloat(fpOutput, minlon);
        writeFloat(fpOutput, maxlat);
        writeFloat(fpOutput, minlat);
        VSIFCloseL( fpOutput );
    }

 
    if (papoLayers != NULL)
    {
        for( int i = 0; i < nLayers; i++ )
            delete papoLayers[i];
        CPLFree( papoLayers );
    }

    if (pszName != NULL)
        CPLFree( pszName );
  
    if (pszTmpTracks != NULL)
    {
        VSIUnlink( pszTmpTracks );
        CPLFree( pszTmpTracks );
    }

    if (pszTmpTrackpoints != NULL)
    {
        VSIUnlink( pszTmpTrackpoints );
        CPLFree( pszTmpTrackpoints );
    }

    if (poGTMFile != NULL)
        delete poGTMFile;
}
コード例 #6
0
void DataOutputStream::writeVec3(const osg::Vec3& v){

//	std::cout << "write " << _ostream->tellp() << std::endl;

    writeFloat(v.x());
    writeFloat(v.y());
    writeFloat(v.z());

    if (_verboseOutput) std::cout<<"read/writeVec3() ["<<v<<"]"<<std::endl;
}
コード例 #7
0
void writeViewBox(const char* value, FILE* out) {
	float x, y, w, h;
	if (sscanf(value, "%f %f %f %f", &x, &y, &w, &h) != 4) {
		fprintf(stderr, "Unable to parse \"%s\" as a viewBox value\n", value);
		throw ErrBadAttribute;
	}
	writeFloat(x, out);
	writeFloat(y, out);
	writeFloat(w, out);
	writeFloat(h, out);
}
コード例 #8
0
ファイル: ProcFile.cpp プロジェクト: BielBdeLuna/DarkRadiant
std::ostream& ProcFile::writeShadowTriangles(std::ostream& str, const Surface& tri)
{
	// emit this chain
	str << (boost::format("/* numVerts = */ %i /* noCaps = */ %i /* noFrontCaps = */ %i /* numIndexes = */ %i /* planeBits = */ %i")
		% tri.vertices.size() % tri.numShadowIndicesNoCaps % tri.numShadowIndicesNoFrontCaps % tri.indices.size() % tri.shadowCapPlaneBits);

	str << std::endl;

	// verts
	std::size_t col = 0;

	for (std::size_t i = 0 ; i < tri.vertices.size(); ++i)
	{
		str << "( ";
		writeFloat(str, tri.shadowVertices[i][0]);
		writeFloat(str, tri.shadowVertices[i][1]);
		writeFloat(str, tri.shadowVertices[i][2]);
		str << " )";
		
		if (++col == 5)
		{
			col = 0;
			str << std::endl;
		}
	}

	if (col != 0)
	{
		str << std::endl;
	}

	// indexes
	col = 0;

	for (std::size_t i = 0 ; i < tri.indices.size(); ++i)
	{
		str << (boost::format("%i ") % (str, tri.indices[i]));

		if (++col == 18 )
		{
			col = 0;
			str << std::endl;
		}
	}

	if (col != 0)
	{
		str << std::endl;
	}

	return str;
}
コード例 #9
0
ファイル: ProcFile.cpp プロジェクト: BielBdeLuna/DarkRadiant
std::ostream& ProcFile::writeOutputNodeRecursively(std::ostream& str, const BspTreeNodePtr& node)
{
	if (node->planenum == PLANENUM_LEAF)
	{
		// we shouldn't get here unless the entire world
		// was a single leaf
		str << "/* node 0 */ ( 0 0 0 0 ) -1 -1" << std::endl;
		return str;
	}

	int child[2];

	for (std::size_t i = 0; i < 2; ++i)
	{
		if (node->children[i]->planenum == PLANENUM_LEAF)
		{
			child[i] = static_cast<int>(-1 - node->children[i]->area);
		}
		else 
		{
			child[i] = node->children[i]->nodeNumber;
		}
	}

	const Plane3& plane = planes.getPlane(node->planenum);

	str << (boost::format("/* node %i */ ") % node->nodeNumber);

	str << "( ";
	writeFloat(str, plane.normal()[0]);
	writeFloat(str, plane.normal()[1]);
	writeFloat(str, plane.normal()[2]);
	writeFloat(str, -plane.dist());
	str << ") ";
	str << (boost::format("%i %i") % child[0] % child[1]) << std::endl;

	if (child[0] > 0)
	{
		writeOutputNodeRecursively(str, node->children[0]);
	}

	if (child[1] > 0)
	{
		writeOutputNodeRecursively(str, node->children[1]);
	}

	return str;
}
コード例 #10
0
ファイル: SE_Buffer.cpp プロジェクト: huhuhu1092/test-server
void SE_BufferOutput::writeFloatArray(float* fa, int count)
{
    for(int i = 0 ; i < count ; i++)
    {
        writeFloat(fa[i]);
    }
}
コード例 #11
0
ファイル: BranchState.cpp プロジェクト: jsvennevid/openvcl
void BranchState::writeFloat( Token::Argument& argument )
{
	assert( argument.type() == Token::Argument::FLOAT_REGISTER );

	if( argument.content() == Token::Argument::REGISTER )
	{
		writeFloat( argument.regNumber(), argument.fields() );
	}
	else if( argument.content() == Token::Argument::ALIAS )
	{
		std::map< std::string, State >::iterator i = m_floats.find( argument.alias() );

		if( i == m_floats.end() )
		{
			State newState;

			m_floats[ argument.alias() ] = newState;
			i = m_floats.find( argument.alias() ); // this could be retrieved directly, but I've had issues with inserting into maps and retrieving the iterator in the same operation

			assert( i != m_floats.end() );
		}

		updateDependency( argument, i->second, Alias::FLOAT, i->first, ((i->second.fields() & ~argument.fields()) != 0) );

		i->second.setFields( i->second.fields() | argument.fields() );
	}
}
コード例 #12
0
ファイル: SE_Buffer.cpp プロジェクト: huhuhu1092/test-server
void SE_BufferOutput::writeVector4f(const SE_Vector4f& v)
{
    for(int i = 0 ; i < 4 ; i++)
    {
        writeFloat(v.d[i]);
    }
}
コード例 #13
0
ファイル: hyper_agent.c プロジェクト: levenkov/olver
static TACommandVerdict acoshf_cmd(TAThread thread,TAInputStream stream)
{
    float x, res;

    // Prepare

    x = readFloat(&stream);
    errno = 0;
    
    START_TARGET_OPERATION(thread);
    
    // Execute

    res = acoshf(x);
    
    END_TARGET_OPERATION(thread);
    
    // Response
    
    writeFloat(thread, res);
    writeInt(thread, errno);

    sendResponse(thread);
    return taDefaultVerdict;
}
コード例 #14
0
ファイル: SE_Buffer.cpp プロジェクト: huhuhu1092/test-server
void SE_BufferOutput::writeMatrix3f(const SE_Matrix3f& m)
{
    for(int i = 0 ; i < 3 ; i++)
    {
        for(int j = 0 ; j < 3 ; j++)
            writeFloat(m.get(i, j));
    }
}
コード例 #15
0
void writeFixed(const char* value, FILE* out) {
	float f;
	if (sscanf(value, "%f", &f) != 1) {
		fprintf(stderr, "Unable to parse \"%s\" as a floating point value\n", value);
		throw ErrBadAttribute;
	}
	writeFloat(f, out);
}
コード例 #16
0
ファイル: DataStream.cpp プロジェクト: kyuu/azura
    //--------------------------------------------------------------
    void
    DataStream::writeFloatBE(float n)
    {
#ifdef AZURA_LITTLE_ENDIAN
        _s4((_4*)&n);
#endif
        writeFloat(n);
    }
コード例 #17
0
void
RemotePluginClient::setParameter(int p, float v)
{
    writeOpcode(&m_shmControl->ringBuffer, RemotePluginSetParameter);
    writeInt(&m_shmControl->ringBuffer, p);
    writeFloat(&m_shmControl->ringBuffer, v);
    commitWrite(&m_shmControl->ringBuffer);
}
コード例 #18
0
ファイル: wstrreal_agent.c プロジェクト: levenkov/olver
static TACommandVerdict __wcstof_internal_cmd(TAThread thread,TAInputStream stream)
{
    wchar_t* st, *endptr;

    size_t size;

    float res;



    size = readInt(&stream);

    st = (wchar_t*)ta_alloc_memory(size * sizeof(wchar_t) + 1);



    readWCharArray(&stream, st, &size);



    st[size] = '\0';



    START_TARGET_OPERATION(thread);



    errno = 0;

    res = __wcstof_internal(st, &endptr, 0);



    END_TARGET_OPERATION(thread);



    writeFloat(thread, res);

    writeInt(thread, (int)( endptr - st));

    writeInt(thread, errno);



    ta_dealloc_memory(st);



    sendResponse(thread);



    return taDefaultVerdict;


}
コード例 #19
0
ファイル: bonevertex.cpp プロジェクト: philippedax/vreng
void BoneVertex::writeToFile(FILE *fp)
{
  if (! childListCompiled) compileChildList();

  writeString(fp, getName());

  float posx, posy, posz;
  float angle;
  float axisx, axisy, axisz;

  posx = initialPosition.x;
  posy = initialPosition.y;
  posz = initialPosition.z;
  angle = initialAngle;
  axisx = initialAxis.x;
  axisy = initialAxis.y;
  axisz = initialAxis.z;

  writeFloat(fp, posx);
  writeFloat(fp, posy);
  writeFloat(fp, posz);
  writeFloat(fp, angle);
  writeFloat(fp, axisx);
  writeFloat(fp, axisy);
  writeFloat(fp, axisz);

  writeInt(fp, children);

  for (int i=0; i<children; i++)
    child[i]->writeToFile(fp);
}
コード例 #20
0
ファイル: trig_agent.c プロジェクト: levenkov/olver
static TACommandVerdict sincosf_cmd(TAThread thread,TAInputStream stream)
{
    float x, s, c;

    x = readFloat(&stream);

    START_TARGET_OPERATION(thread);

    sincosf(x, &s, &c);

    END_TARGET_OPERATION(thread);

    writeFloat(thread, s);
    writeFloat(thread, c);
    sendResponse(thread);

    return taDefaultVerdict;
}
コード例 #21
0
void EntityTemplateInterpreter::generateTestByteCode() {
	std::ofstream out("autoGenerated.tpl", std::ofstream::binary);

    writeByte(0xB0, out);
    writeByte(0x01, out);writeString("size", out);
    writeByte(0x02, out);writeString("testFloat", out);
    writeByte(0x03, out);writeString("testString", out);
    writeByte(0x04, out);writeString("I AM SUCH A STRING", out);
    writeByte(0x05, out);writeString("testInt", out);
    writeByte(0x06, out);writeString("ball.png", out);
    writeByte(0x07, out);writeString("fancy", out);

    writeByte(0xB1, out);

    writeVec2(glm::vec2(100,100), out);                 //Size
    writeByte(0x01, out);
    writeFloat(33.544f, out);                           //testFloat
    writeByte(0x02, out);
    writeByte(0xD5, out);writeByte(0x04, out);               //testString
    writeByte(0x03, out);
    writeVec3(glm::vec3(349,43,435), out);                                     //testInt
    writeByte(0x05, out);

    writeByte(0xB2, out);

    writeByte(0xC0, out);               //TextureComponent
    writeByte(0xD5, out); writeByte(0x06, out);
    writeUint16(5, out);
    writeUint16(1, out);
    writeUint16(3, out);
    writeUint16(1, out);

    writeByte(0xC1, out);               //ScriptComponent
    writeByte(0xD5, out); writeByte(0x07, out);

	writeByte(0xC2, out);               //MoveComponent
	writeFloat(20.f, out);	//Acc
	writeFloat(4.f, out);	//Damping
	writeFloat(20.f, out);	//Mass
	writeFloat(4.f, out);	//Deacc

	writeByte(0xC3, out);               //CollisionComponent
	writeUint16(1, out);	//Box Count
	writeFloat(20.f, out);	//x
	writeFloat(4.f, out);	//y
	writeFloat(20.f, out);	//w
	writeFloat(4.f, out);	//h
	writeByte(0xD5, out); writeByte(0xA7, out);	//Trigger Name
}
コード例 #22
0
void BaseSerializedObj::writeFloatArray(float array[], uint64_t s)
{
    writeUInt64(s);
    uint64_t i = 0;
    while ( i!=s )
    {
        writeFloat(array[i]);
        i++;
    }
}
コード例 #23
0
void DataOutputStream::writeFloatArray(const osg::FloatArray* a)
{
    int size = a->getNumElements();
    writeInt(size);
    for(int i =0; i<size ;i++){
        writeFloat((*a)[i]);
    }

    if (_verboseOutput) std::cout<<"read/writeFloatArray() ["<<size<<"]"<<std::endl;
}
コード例 #24
0
	// ----------------------------------------------------------------------
	std::vector<char>*
	PolygonTopologyPacket::
	serialize( void ) 
	throw()
	{
		 std::vector<char> *b = (static_cast<SpyglassPacket*>(this))->serialize();
		 int standardsize = b->size()-1;
		 length_ = get_size();
		 b->resize(length_+1);
		 writeChar( length_, b, 0);
		 writeChar( polType_, b, standardsize+1 );
		 int size = polygon_.size();
		 for (int i=0; i<size; ++i)
		 {
			 shawn::Vec pos = polygon_.front();
			 writeFloat(pos.x(), b, standardsize+2+i*8);
			 writeFloat(pos.y(), b, standardsize+6+i*8);
			 polygon_.pop_front();
		 } 
		 return b;
     }
コード例 #25
0
ファイル: DataStorage.cpp プロジェクト: IHA-Quadro/Drone
void storeSensorsZeroToEEPROM() {
  
  // Store accel data to EEPROM
  writeFloat(accelOneG, ACCEL_1G_ADR);
  // Accel Cal
  writeFloat(accelScaleFactor[XAXIS], XAXIS_ACCEL_SCALE_FACTOR_ADR);
  writeFloat(runTimeAccelBias[XAXIS], XAXIS_ACCEL_BIAS_ADR);
  writeFloat(accelScaleFactor[YAXIS], YAXIS_ACCEL_SCALE_FACTOR_ADR);
  writeFloat(runTimeAccelBias[YAXIS], YAXIS_ACCEL_BIAS_ADR);
  writeFloat(accelScaleFactor[ZAXIS], ZAXIS_ACCEL_SCALE_FACTOR_ADR);
  writeFloat(runTimeAccelBias[ZAXIS], ZAXIS_ACCEL_BIAS_ADR);
}
コード例 #26
0
void DataOutputStream::writeMatrixf(const osg::Matrixf& mat)
{

    for(int r=0;r<4;r++)
    {
        for(int c=0;c<4;c++)
        {
            writeFloat(mat(r,c));
        }
    }

    if (_verboseOutput) std::cout<<"read/writeMatrix() ["<<mat<<"]"<<std::endl;

}
コード例 #27
0
ファイル: tcpRemote.cpp プロジェクト: RaymondLiao/elektronika
EDLL int AoscMessage::getBytes(byte *data, int sizemax)
{
    int size=0;
    memset(data, 0, sizemax);
    size+=writeString(pattern, data, sizemax);
    format[0]=',';
    {
        Anode	*n=lchild;
        char	*f=&format[1];
        while(n)
        {
            if(n->isCI(&AoscString::CI))
                *(f++)='s';
            else if(n->isCI(&AoscInteger::CI))
                *(f++)='i';
            else if(n->isCI(&AoscFloat::CI))
                *(f++)='f';
            else if(n->isCI(&AoscColor::CI))
                *(f++)='r';
            else if(n->isCI(&AoscBitmap::CI))
                *(f++)='j';
            n=n->prev;
        }
        *f=0;
    }
    size+=writeString(format, data+size, sizemax-size);
    {
        Anode	*n=lchild;
        while(n)
        {
            if(n->isCI(&AoscString::CI))
                size+=writeString(((AoscString *)n)->value, data+size, sizemax-size);
            else if(n->isCI(&AoscInteger::CI))
                size+=writeInt(((AoscInteger *)n)->value, data+size, sizemax-size);
            else if(n->isCI(&AoscFloat::CI))
                size+=writeFloat(((AoscFloat *)n)->value, data+size, sizemax-size);
            else if(n->isCI(&AoscColor::CI))
                size+=writeInt(((AoscColor *)n)->value, data+size, sizemax-size);
            else if(n->isCI(&AoscBitmap::CI))
                size+=writeBitmap(((AoscBitmap *)n)->value, data+size, sizemax-size);
            n=n->prev;
        }
    }
    return size;
}
コード例 #28
0
ファイル: trig_agent.c プロジェクト: levenkov/olver
static TACommandVerdict tanf_cmd(TAThread thread,TAInputStream stream)
{
    float x, res;

    x = readFloat(&stream);

    START_TARGET_OPERATION(thread);

    errno = 0;
    res = tanf(x);

    END_TARGET_OPERATION(thread);

    writeInt(thread, errno);
    writeFloat(thread, res);
    sendResponse(thread);

    return taDefaultVerdict;
}
コード例 #29
0
ファイル: gamma_agent.c プロジェクト: levenkov/olver
static TACommandVerdict lgammaf_r_cmd(TAThread thread,TAInputStream stream)
{
    float x, res;
    int signp;

    x = readFloat(&stream);

    START_TARGET_OPERATION(thread);

    errno = 0;
    res = lgammaf_r(x, &signp);

    END_TARGET_OPERATION(thread);

    writeInt(thread, errno);
    writeFloat(thread, res);
    writeInt(thread, signp);
    sendResponse(thread);

    return taDefaultVerdict;
}
コード例 #30
0
ファイル: sumf2.c プロジェクト: michaelatremblay/school
int main(void)
{
  // create memory system with 256 words and a direct-mapped cache
  // with 8 sets and a block size of 4 words.
  void *a = initializeMemorySystem(SIZE, 1, 4, 8, 1, 1);
  if (a == NULL)
  {
    fprintf(stderr, "initializeMemorySystem failed!\n");
    exit(-1);
  }

  int i;

  // initialize the array
  for (i = 0; i < SIZE; i++)
  {
    writeFloat(a, 0, i, ((float) i) + .5);
  }

  // now sum it
  float sum = 0.0;
  float sum2 = 0.0;
  for (i = 0; i < SIZE; i++)
  {
    float tmp = readFloat(a, 0, i);
    //printf("%d %f\n", i, tmp);
    sum += tmp;
    sum2 += (((float) i) + .5);
  }
  printf("sum is %f (should be %f)\n", sum, sum2);

  // print stats
  printf("\n");
  printStatistics(a);
  printf("\n");


  return 0;
}