void PointArrayParticleSystem::init(IStorm3D* s3d, IStorm3D_Scene* scene)
{
    defaultInit(s3d, scene, *m_eds);

    std::string fileName = m_eds->modelFile;
    if(fileName.empty())
        return;

    Matrix sm;
    Matrix rm;
    QUAT q;
    q.MakeFromAngles(m_eds->rotation.x, m_eds->rotation.y, m_eds->rotation.z);
    rm.CreateRotationMatrix(q);
    sm.CreateScaleMatrix(m_eds->scale);
    sm.Multiply(rm);
    IStorm3D_Model* model = s3d->CreateNewModel();
    assert(model != NULL);

    if(model->LoadS3D(fileName.c_str()))
    {
        Iterator<IStorm3D_Model_Object*>* obj = model->ITObject->Begin();
        assert(obj != NULL);

        boost::shared_ptr<PointArray> pm(new PointArray());
        for(; !obj->IsEnd(); obj->Next())
        {
            IStorm3D_Mesh* mesh = obj->GetCurrent()->GetMesh();
            VC3 opos = obj->GetCurrent()->GetPosition();

            if(mesh)
            {
                int base = pm->verts.size();
                pm->verts.resize(base + mesh->GetVertexCount());
                pm->normals.resize(base + mesh->GetVertexCount());

                Storm3D_Vertex *v = mesh->GetVertexBuffer();
                for(int i = 0; i < mesh->GetVertexCount(); i++)
                {
                    Vector pos = v[i].position + opos;
                    Vector nor = v[i].normal;
                    sm.TransformVector(pos);
                    rm.RotateVector(nor);

                    pm->verts[base + i] = pos;
                    pm->normals[base + i] = nor;
                }
            }
        }

        m_parray.swap(pm);
        if(m_eds->firstVertex < 0)
            m_eds->firstVertex = 0;
        if(m_eds->lastVertex >= (int)m_parray->verts.size())
            m_eds->lastVertex = m_parray->verts.size()-1;

        delete obj;
    }
    delete model;
}
示例#2
0
btRaycastVehicle::btRaycastVehicle(const btVehicleTuning& tuning,btRigidBody* chassis,	btVehicleRaycaster* raycaster )
    :m_vehicleRaycaster(raycaster),
     m_pitchControl(btScalar(0.))
{
    m_chassisBody = chassis;
    m_indexRightAxis = 0;
    m_indexUpAxis = 2;
    m_indexForwardAxis = 1;
    defaultInit(tuning);
}
	LoadSBMLOptions::LoadSBMLOptions(const Dictionary* dict)
	{
		defaultInit();

		const LoadSBMLOptions *opt = dynamic_cast<const LoadSBMLOptions*>(dict);

		if (opt) {
			version = opt->version;
			size = opt->size;
			modelGeneratorOpt = opt->modelGeneratorOpt;
			loadFlags = opt->loadFlags;
			this->items = opt->items;
		}
		else if (dict) {
			std::vector<std::string> keys = dict->getKeys();
			for (std::vector<std::string>::const_iterator k = keys.begin(); k != keys.end(); ++k) {
				setItem(*k, dict->getItem(*k));
			}
		}
	}
示例#4
0
/// Main function for ADC test firmware
int main(void) {
	uint8_t debugAdc, i;
	FunctionalState led = DISABLE;
	defaultInit();
	debugAdc = debugNewSource("ADC");
	debugSourceEnable(debugAdc, ENABLE);
	debugPrintln(debugAdc, "test start");
	timerStartMs(100);
	for (;;) {
		adcLoop();
		if (timerEnd()) {
			timerStartMs(500);
			ledCmd(0, led);
			led = !led;
			debugPrintRaw(debugAdc, "ADC:");
			for (i = 0; i < ADC_NUMBER; i++) {
				debugPrintRaw(debugAdc, " %u", adcRead(i));
			}
			debugPrintRaw(debugAdc, "\r\n");
		}
	}
}
示例#5
0
GFXFontEdit::GFXFontEdit(GFXOldFont *oldFont) : GFXFont()
{
	// Create a font from an old font
	defaultInit();			 

	memcpy(&fi, &oldFont->fi, sizeof(oldFont->fi));
	fi.numChars = 0;

	GFXBitmap      *bitmap;
	GFXOldCharInfo *oldCharInfo;

	pPal = oldFont->pPal;
	oldFont->pPal = NULL;

	for (int i = 0; i < MAX_CHARS; i++)
	{
		oldFont->getCharInfo(i, &bitmap, &oldCharInfo);
		if (bitmap != oldFont->missing)
			insertBitmap(i, bitmap, oldCharInfo->baseline);
	}
	computeUsefulInformation();
}
示例#6
0
void GFXFontEdit::unpack(GFXFont *font)
{
	// In order to allow easy editing of a font, we generate extra space
	// in the arrays for copying/pasting, etc.

	// if "font" is null then we are unpacking the current object
	// (this), so we need to make a copy of ourselves:
	if (font == NULL)
	{
		font = new GFXFont;
		font->bma.numBitmaps        = bma.numBitmaps;
		font->bma.array             = bma.array;
		font->fi                    = fi;
		font->charTable             = charTable;
		font->charTableLookup       = charTableLookup;
		font->charTableLookupOffset = charTableLookupOffset;
		font->charTableLookupSize   = charTableLookupSize;
		font->pPal                  = pPal;
	}

	// if "font" is non-null then we are unpacking a font that was
	// just read from a file.
	
	// defaultInit() will attempt to delete these arrays before it creates
	// the new ones, we want to keep our copies of them, and they'll be
	// deleted at the bottom
	bma.array       = NULL;  
	charTable       = NULL;
	charTableLookup = NULL;

	// now clobber everyting, create the unpacked space
	defaultInit();

	// now copy packed to unpacked
	fi = font->fi;
	int i;
	bma.numBitmaps = font->bma.numBitmaps;
	for (i = 0; i < bma.numBitmaps; i++)
	{
		bma.array[i]       = font->bma.array[i];
		font->bma.array[i] = NULL;  // so it doesn't get deleted immediately
	}
	font->bma.numBitmaps = 0;

	int index;
	int count = font->charTableLookupSize + font->charTableLookupOffset;

	for (i = 0; i < count; i++)
	{
		index = i - font->charTableLookupOffset;
		if (index >= 0)
			charTableLookup[i] = font->charTableLookup[index];
	}

	for (i = 0; i < fi.numChars; i++)
		charTable[i] = font->charTable[i];

	computeUsefulInformation();

	if (font->pPal)
	{
		pPal = font->pPal;
		font->pPal = NULL;       // so it doesn't get deleted immediately
	}
	fi.scale.x = 1<<16;
	fi.scale.y = 1<<16;
	
	delete font;
}
	LoadSBMLOptions::LoadSBMLOptions()
	{
		defaultInit();
	}
示例#8
0
WalkBalanceConfig::WalkBalanceConfig():
detX(0.015),detY(0.02)
{
	defaultInit();
}
示例#9
0
//const int NaoConfig::LegIDRight = 1;
//const int NaoConfig::LegIDLeft = -1;
NaoConfig::NaoConfig()
{
	theNaoCfg = this;
	defaultInit();
}