void init(IStorm3D* s3d, IStorm3D_Scene* scene) {
				
		GenParticleSystem::init(s3d, scene);
		
		std::string fileName;
		m_pb->getValue(PB_POINT_ARRAY_MODEL_FILE, fileName);
		if(fileName.empty())
			return;
		
		IStorm3D_Model* model = s3d->CreateNewModel();
		if(model->LoadS3D(fileName.c_str())) 
		{
			Iterator<IStorm3D_Model_Object*>* obj = model->ITObject->Begin();
			IStorm3D_Mesh* mesh = obj->GetCurrent()->GetMesh();
			if(mesh) {
				boost::shared_ptr<ParticleMesh> pm(new ParticleMesh());
				pm->verts.resize(mesh->GetVertexCount());
				pm->normals.resize(mesh->GetVertexCount());
				Storm3D_Vertex* v = mesh->GetVertexBuffer();
				for(int i = 0; i < mesh->GetVertexCount(); i++) {
					pm->verts[i] = v[i].position;
					pm->normals[i] = v[i].normal;
				}
				m_mesh.swap(pm);
			}
			delete obj;
		}
		delete model;

	}
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;
}
boost::shared_ptr<PhysicsMesh> ParticlePhysics::createConvexMesh(const char *filename, IStorm3D_Model_Object *object)
{
	boost::shared_ptr<PhysicsMesh> mesh(new PhysicsMesh());
	IStorm3D_Mesh *stormMesh = object->GetMesh();

	int vertexAmount = stormMesh->GetVertexCount();
	const Storm3D_Vertex *buffer = stormMesh->GetVertexBufferReadOnly();

	VC3 minValues(10000.f, 10000.f, 10000.f);
	VC3 maxValues(-10000.f, -10000.f, -10000.f);
	for(int i = 0; i < vertexAmount; ++i)
	{
		VC3 pos = buffer[i].position;

		minValues.x = std::min(minValues.x, pos.x);
		minValues.y = std::min(minValues.y, pos.y);
		minValues.z = std::min(minValues.z, pos.z);

		maxValues.x = std::max(maxValues.x, pos.x);
		maxValues.y = std::max(maxValues.y, pos.y);
		maxValues.z = std::max(maxValues.z, pos.z);
	}

	VC3 size = maxValues - minValues;
	if(size.x < MIN_BOX_SIZE)
	{
		float diff = (MIN_BOX_SIZE - size.x) * 0.5f;
		maxValues.x += diff;
		minValues.x -= diff;
	}
	if(size.y < MIN_BOX_SIZE)
	{
		float diff = (MIN_BOX_SIZE - size.y) * 0.5f;
		maxValues.y += diff;
		minValues.y -= diff;
	}
	if(size.z < MIN_BOX_SIZE)
	{
		float diff = (MIN_BOX_SIZE - size.z) * 0.5f;
		maxValues.z += diff;
		minValues.z -= diff;
	}

	mesh->size = (maxValues - minValues) * 0.5f;
	mesh->localPosition = minValues + mesh->size;
	mesh->localPosition.y -= mesh->size.y;
	mesh->volume = mesh->size.x * mesh->size.y * mesh->size.z * 2.f;

	return mesh;
}