Ejemplo n.º 1
0
//normalized between 0.0f to 1.0f
Mesh* MeshManager::getMeshPlane2D(float left, float top, float width, float height, Shader* shader){
	if(shader == 0){
		shader = new SimplePlaneShader();
	}
	Mesh* resultPlane = new Mesh(shader, getNewId());
	SubMesh* subMesh = new SubMesh(0);
	subMesh->vertices.push_back(glm::vec3(left + width, 	top, 0.0f));
	subMesh->vertices.push_back(glm::vec3(left, 			top, 0.0f));
	subMesh->vertices.push_back(glm::vec3(left, 			top - height, 0.0f));

	subMesh->vertices.push_back(glm::vec3(left + width, 	top, 0.0f));
	subMesh->vertices.push_back(glm::vec3(left, 			top - height, 0.0f));
	subMesh->vertices.push_back(glm::vec3(left + width, 	top - height, 0.0f));

	subMesh->textureCoord.push_back(glm::vec2(1.0f, 1.0f));
	subMesh->textureCoord.push_back(glm::vec2(0.0f, 1.0f));
	subMesh->textureCoord.push_back(glm::vec2(0.0f, 0.0f));
	subMesh->textureCoord.push_back(glm::vec2(1.0f, 1.0f));
	subMesh->textureCoord.push_back(glm::vec2(0.0f, 0.0f));
	subMesh->textureCoord.push_back(glm::vec2(1.0f, 0.0f));

	resultPlane->subMeshes.push_back(subMesh);
	resultPlane->generateVBO();
	return resultPlane;
}
Ejemplo n.º 2
0
Mesh* MeshManager::getMeshPlane2D(Shader* shader){
	if(shader == 0){
		shader = new SimplePlaneShader();
	}
	Mesh* resultPlane = new Mesh(shader, getNewId());
	SubMesh* subMesh = new SubMesh(0);

	subMesh->vertices.push_back(glm::vec3(0.5f, 0.5f, 	0.0f));
	subMesh->vertices.push_back(glm::vec3(-0.5f, 0.5f, 	0.0f));
	subMesh->vertices.push_back(glm::vec3(-0.5f, -0.5f,	0.0f));

	subMesh->vertices.push_back(glm::vec3(0.5f,	0.5f,	 0.0f));
	subMesh->vertices.push_back(glm::vec3(-0.5f, -0.5f, 	0.0f));
	subMesh->vertices.push_back(glm::vec3(0.5f,	-0.5f, 	0.0f));

	subMesh->textureCoord.push_back(glm::vec2(1.0f, 1.0f));
	subMesh->textureCoord.push_back(glm::vec2(0.0f, 1.0f));
	subMesh->textureCoord.push_back(glm::vec2(0.0f, 0.0f));
	subMesh->textureCoord.push_back(glm::vec2(1.0f, 1.0f));
	subMesh->textureCoord.push_back(glm::vec2(0.0f, 0.0f));
	subMesh->textureCoord.push_back(glm::vec2(1.0f, 0.0f));

	resultPlane->subMeshes.push_back(subMesh);
	resultPlane->generateVBO();
	return resultPlane;
}
Ejemplo n.º 3
0
Imagen::Imagen(unsigned int pID_Dir,unsigned int pEspacio_Libre,unsigned int pProximo_Bit_Libre,
               string pHash_Value,unsigned int pTamanio,string pNombre, util::Date* ultimaModificacion) :
    ID_Dir(pID_Dir),espacio_libre(pEspacio_Libre),proximo_bit_libre (pProximo_Bit_Libre),
    hash_value(pHash_Value),tamanio(pTamanio),nombre(pNombre),
    fechaUltimaModificacion(ultimaModificacion) {
    this->ID = getNewId();
}
Ejemplo n.º 4
0
Mesh* MeshManager::getMesh(string name){
	std::map<string, Mesh*>::iterator it;
	it = meshMap.find(name);
	if(it != meshMap.end()){//mesh previament carregat LEAK!
		Mesh* result = new Mesh(it->second, getNewId());
		result->generateVBO();
		return result;
	}

	if(FileSystem::getInstance()->openFile(name) == -1){
		logErr("Error TextureManager::getTexture opening %s: ", name.c_str());
		return 0;
	}
	std::size_t foundMD5 = name.find(".md5");
	std::size_t foundOBJ = name.find(".obj");
	if (foundOBJ!=std::string::npos){
		meshMap[name] = parseOBJ(name, FileSystem::getInstance()->getFileData(name), FileSystem::getInstance()->getFileSize(name));
	}
	else if (foundMD5!=std::string::npos){
		meshMap[name] = parseMD5(name, FileSystem::getInstance()->getFileData(name), FileSystem::getInstance()->getFileSize(name));
	}
	else{
		FileSystem::getInstance()->destroyFileData(name);
		return 0;
	}
	FileSystem::getInstance()->destroyFileData(name);

//	printMeshData(meshMap[name]);
	meshMap[name]->generateVBO();
	return meshMap[name];
}
Ejemplo n.º 5
0
    Actor::Actor(
            const std::string& walkAnimPath,
            const std::string& idleAnimPath,
            const Position& pos,
            const std::string& dieAnimPath,
            ActorStats* stats):
        mPos(pos),
        mFrame(0),        
        mStats(stats),
        mAnimState(AnimState::idle),
        mIsEnemy(false)
    {
        if (!dieAnimPath.empty())
        {
            mDieAnim = FARender::Renderer::get()->loadImage(dieAnimPath);
        }

        if (!walkAnimPath.empty())
            mWalkAnim = FARender::Renderer::get()->loadImage(walkAnimPath);
        if (!idleAnimPath.empty())
            mIdleAnim = FARender::Renderer::get()->loadImage(idleAnimPath);
        mDestination = mPos.current();
        mAnimTimeMap[AnimState::idle] = 10;
        mAnimTimeMap[AnimState::walk] = 10;

        mId = getNewId();
    }
Ejemplo n.º 6
0
void AmSession::setLocalTag()
{
  if (dlg->getLocalTag().empty()) {
    string new_id = getNewId();
    dlg->setLocalTag(new_id);
    DBG("AmSession::setLocalTag() - session id set to %s\n", new_id.c_str());
  }
}
Ejemplo n.º 7
0
long __vfs_createFile(redisContext *context, long parentId, const char *name, long size,
		const char *googleId, const char *webUrl, const char *apiUrl) {
	//add it to the file list of the dir
	long id = getNewId(context);
	vfs_addFileToFileList(context, parentId, id);
	__createFile(context, id, name, size, googleId, webUrl, apiUrl);
	return id;
}
Ejemplo n.º 8
0
//returns dir id
long __vfs_mkdir(redisContext *context, long parentId, const char *name) {
	long id = getNewId(context);
	redisReply *reply;
	reply = redisCommand(context, "LPUSH FOLDER_%lu_folders %lu", parentId, id);
	freeReplyObject(reply);
	__private_mkdir(context, parentId, id, name);
	return id;
}
Ejemplo n.º 9
0
Node::Node(const Node& other) :
	INode(other),
	boost::enable_shared_from_this<Node>(other),
	_state(other._state),
	_isRoot(other._isRoot),
	_id(getNewId()),	// ID is incremented on copy
	_children(*this),
	_boundsChanged(true),
	_boundsMutex(false),
	_childBoundsChanged(true),
	_childBoundsMutex(false),
	_local2world(other._local2world),
	_instantiated(false),
	_layers(other._layers)
{}
Ejemplo n.º 10
0
DataWidget *WidgetArea::addWidget(QPoint pos, quint8 type, bool show)
{
    DataWidget *w = sWidgetFactory.getWidget(type, this);
    if(!w)
        return NULL;

    quint32 id = getNewId();
    w->setId(id);

    w->setUp(m_storage);

    w->move(pos);
    if(show)
        w->show();

    m_widgets.insert(id, w);

    connect(w,          SIGNAL(removeWidget(quint32)),              SLOT(removeWidget(quint32)));
    connect(w,          SIGNAL(updateMarker(DataWidget*)),          SLOT(updateMarker(DataWidget*)));
    connect(w,          SIGNAL(clearPlacementLines()),              SLOT(clearPlacementLines()));
    connect(w,          SIGNAL(updateData()),                       SIGNAL(updateData()));
    connect(w,   SIGNAL(mouseStatus(bool,data_widget_info,qint32)), SIGNAL(mouseStatus(bool,data_widget_info,qint32)));
    connect(w,          SIGNAL(SendData(QByteArray)),   m_analyzer, SIGNAL(SendData(QByteArray)));
    connect(w,          SIGNAL(toggleSelection(bool)),              SLOT(toggleSelection(bool)));
    connect(this,       SIGNAL(setTitleVisibility(bool)),        w, SLOT(setTitleVisibility(bool)));
    connect(w,  SIGNAL(addChildTab(ChildTab*,QString)), m_analyzer, SLOT(addChildTab(ChildTab*,QString)));
    connect(w,  SIGNAL(removeChildTab(ChildTab*)),      m_analyzer, SLOT(removeChildTab(ChildTab*)));
    connect(w,          SIGNAL(addUndoAct(UndoAction*)),&m_undoStack,SLOT(addAction(UndoAction*)));
    connect(m_analyzer, SIGNAL(rawData(QByteArray)),             w, SIGNAL(rawData(QByteArray)));
    connect(this,       SIGNAL(setLocked(bool)),                 w, SLOT(setLocked(bool)));

    //events
    connect(this,       SIGNAL(onWidgetAdd(DataWidget*)),        w, SLOT(onWidgetAdd(DataWidget*)));
    connect(this,       SIGNAL(onWidgetRemove(DataWidget*)),     w, SLOT(onWidgetRemove(DataWidget*)));
    connect(this,       SIGNAL(onScriptEvent(QString)),          w, SLOT(onScriptEvent(QString)));
    connect(this,       SIGNAL(onScriptEvent(QString,QVariantList)), w, SLOT(onScriptEvent(QString, QVariantList)));
    connect(w,          SIGNAL(scriptEvent(QString)),         this, SIGNAL(onScriptEvent(QString)));
    connect(w,          SIGNAL(scriptEvent(QString, QVariantList)),this, SIGNAL(onScriptEvent(QString, QVariantList)));

    emit onWidgetAdd(w);

    m_analyzer->setDataChanged();

    w->setTitleVisibility(m_actTitleVisibility->isChecked());
    return w;
}
Ejemplo n.º 11
0
Node::Node() :
	_state(eVisible),
	_isRoot(false),
	_id(getNewId()), // Get new auto-incremented ID
	_children(*this),
	_boundsChanged(true),
	_boundsMutex(false),
	_childBoundsChanged(true),
	_childBoundsMutex(false),
	_transformChanged(true),
	_transformMutex(false),
	_local2world(Matrix4::getIdentity()),
	_instantiated(false)
{
	// Each node is part of layer 0 by default
	_layers.insert(0);
}
Ejemplo n.º 12
0
void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base)
{
    Record<Cell> cell = mCells.getRecord (cellIndex);

    Cell& cell2 = base ? cell.mBase : cell.mModified;

    CellRef ref;

    while (cell2.getNextRef (reader, ref))
    {
        /// \todo handle deleted and moved references
        ref.load (reader, cell2, getNewId());

        Record<CellRef> record2;
        record2.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
        (base ? record2.mBase : record2.mModified) = ref;

        appendRecord (record2);
    }

    mCells.setRecord (cellIndex, cell);
}
Ejemplo n.º 13
0
void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base,
    std::map<ESM::RefNum, std::string>& cache, CSMDoc::Messages& messages)
{
    Record<Cell> cell = mCells.getRecord (cellIndex);

    Cell& cell2 = base ? cell.mBase : cell.mModified;

    CellRef ref;
    ESM::MovedCellRef mref;
    bool isDeleted = false;

    // hack to initialise mindex
    while (!(mref.mRefNum.mIndex = 0) && ESM::Cell::getNextRef(reader, ref, isDeleted, true, &mref))
    {
        // Keep mOriginalCell empty when in modified (as an indicator that the
        // original cell will always be equal the current cell).
        ref.mOriginalCell = base ? cell2.mId : "";

        if (cell.get().isExterior())
        {
            // ignoring moved references sub-record; instead calculate cell from coordinates
            std::pair<int, int> index = ref.getCellIndex();

            std::ostringstream stream;
            stream << "#" << index.first << " " << index.second;

            ref.mCell = stream.str();

            if (!base &&                  // don't try to update base records
                mref.mRefNum.mIndex != 0) // MVRF tag found
            {
                // there is a requirement for a placeholder where the original object was
                //
                // see the forum discussions here for more details:
                // https://forum.openmw.org/viewtopic.php?f=6&t=577&start=30
                ref.mOriginalCell = cell2.mId;

                // It is not always possibe to ignore moved references sub-record and
                // calculate from coordinates. Some mods may place the ref in positions
                // outside normal bounds, resulting in non sensical cell id's.  This often
                // happens if the moved ref was deleted.
                //
                // Use the target cell from the MVRF tag but if different output an error
                // message
                if (index.first != mref.mTarget[0] || index.second != mref.mTarget[1])
                {
                    std::cerr << "The Position of moved ref "
                        << ref.mRefID << " does not match the target cell" << std::endl;
                    std::cerr << "Position: #" << index.first << " " << index.second
                        <<", Target #"<< mref.mTarget[0] << " " << mref.mTarget[1] << std::endl;

                    std::ostringstream stream;
                    stream << "#" << mref.mTarget[0] << " " << mref.mTarget[1];
                    ref.mCell = stream.str(); // overwrite
                }
            }
        }
        else
            ref.mCell = cell2.mId;

        // ignore content file number
        std::map<ESM::RefNum, std::string>::iterator iter = cache.begin();
        for (; iter != cache.end(); ++iter)
        {
            if (ref.mRefNum.mIndex == iter->first.mIndex)
                break;
        }

        if (isDeleted)
        {
            if (iter==cache.end())
            {
                CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Cell,
                    mCells.getId (cellIndex));

                messages.add (id, "Attempt to delete a non-existing reference");
                continue;
            }

            int index = getIndex (iter->second);

            Record<CellRef> record = getRecord (index);

            if (base)
            {
                removeRows (index, 1);
                cache.erase (iter);
            }
            else
            {
                record.mState = RecordBase::State_Deleted;
                setRecord (index, record);
            }

            continue;
        }

        if (iter==cache.end())
        {
            // new reference
            ref.mId = getNewId();

            Record<CellRef> record;
            record.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
            (base ? record.mBase : record.mModified) = ref;

            appendRecord (record);

            cache.insert (std::make_pair (ref.mRefNum, ref.mId));
        }
        else
        {
            // old reference -> merge
            ref.mId = iter->second;

            int index = getIndex (ref.mId);

            Record<CellRef> record = getRecord (index);
            record.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_Modified;
            (base ? record.mBase : record.mModified) = ref;

            setRecord (index, record);
        }
    }
}
Ejemplo n.º 14
0
	void AsteroidsManager::addAst(int min, int max, double posx, double posy) {
		addParticle(new Asteroid(getNewId(), min, max, posx, posy));
	}
Ejemplo n.º 15
0
void OperatingSystem::addProcess(std::string process_description) {
	int id = getNewId();
	processes_.insert(std::pair<int, Process*>(id, new Process(id, process_description, this)));
}
Ejemplo n.º 16
0
Mesh* MeshManager::parseOBJ(string filename, char* buffer, int lenght){
//	logInf("parse OBJ file with name %s lenght %i", filename.c_str(),lenght);
    //logInf("buffer:\n%s",buffer);
	elementOffsetOBJ = 0;
    resultMesh = new Mesh(filename, getNewId());
    int idSubMesh = 0;
	SubMesh* auxSubMesh = new SubMesh(idSubMesh);
	int i = 0;
	while (buffer[i] != '\0')
	{
	switch (buffer[i]){
	case 'v': // Parse a vertex texture coordinate
		++i;
		if (buffer[i] == ' '){
			// Read in vertex definition
			getVector3(&(auxSubMesh->vertices), buffer, &i);
		}
		else if (buffer[i] == 't'){
			// Read in texture coordinate (2D)
			i++;
			getVector2(&(auxSubMesh->textureCoord), buffer, &i);
		}
		else if (buffer[i] == 'n'){
			// Read in normal vector definition
			i++;
			getVector3(&(auxSubMesh->normals), buffer, &i);
		}
		break;
	case 'f': // Parse a face
		i++;
		getFace(&(auxSubMesh->elements), buffer, &i);
		//skipLine(buffer, &i);
		break;
	case '#': // Parse a comment
		//getComment();
		skipLine(buffer, &i);
		break;
	case 'u': // Parse a material desc. setter
		//getMaterialDesc();
		skipLine(buffer, &i);
		break;
	case 'm': // Parse a material library
		//getMaterialLib();
		skipLine(buffer, &i);
		break;
	case 'g': // Parse group name
		//getGroupName();
		skipLine(buffer, &i);
		break;
	case 's': // Parse group number
		//getGroupNumber();
		skipLine(buffer, &i);
		break;
	case 'o': // Parse object name
		//getObjectName();
		if (idSubMesh != 0) {
			elementOffsetOBJ += auxSubMesh->vertices.size();
			resultMesh->subMeshes.push_back(auxSubMesh);
		}
		idSubMesh++;
	    auxSubMesh = new SubMesh(idSubMesh);
		skipLine(buffer, &i);
		break;
	default:
		skipLine(buffer, &i);
		break;
	}
	}

	resultMesh->subMeshes.push_back(auxSubMesh);

    for (int t = 0; t < resultMesh->subMeshes.size(); t++) {
        auxSubMesh = resultMesh->subMeshes.at(t);

        //logInf("calculating normals auxSubMesh->vertices.size() %lu", auxSubMesh->vertices.size());
		//logInf("calculating normals auxSubMesh->elements.size() %lu", auxSubMesh->elements.size());

        auxSubMesh->normals.resize(auxSubMesh->vertices.size(), glm::vec3(0.0, 0.0, 0.0));
        vector<int> nb_seen;
        nb_seen.clear();
        nb_seen.resize(auxSubMesh->vertices.size(), 0);
        for (int i = 0; i < auxSubMesh->elements.size(); i++) {
        	int ia, ib, ic;
        	glm::vec3 normal;
        	int current;
        	int v[3];
            ia = auxSubMesh->elements.at(i).x;
            ib = auxSubMesh->elements.at(i).y;
            ic = auxSubMesh->elements.at(i).z;
            //logInf("a %i, b %i, c %i",ia,ib,ic);
            normal = glm::normalize(glm::cross(
                        auxSubMesh->vertices.at(ib) - auxSubMesh->vertices.at(ia),
                        auxSubMesh->vertices.at(ic) - auxSubMesh->vertices.at(ia)));
            v[0] = ia;
            v[1] = ib;
            v[2] = ic;
            for (int j = 0; j < 3; j++) {
                current = v[j];
                //logInf("current %i", current);
                nb_seen[current]++;
                if(nb_seen[current] == 1){
                    auxSubMesh->normals[current] = normal;
                }else{
                    auxSubMesh->normals[current].x = auxSubMesh->normals[current].x * (1.0f - 1.0f/(float)nb_seen[current]) + normal.x * 1.0f/(float)nb_seen[current];
                    auxSubMesh->normals[current].y = auxSubMesh->normals[current].y * (1.0f - 1.0f/(float)nb_seen[current]) + normal.y * 1.0f/(float)nb_seen[current];
                    auxSubMesh->normals[current].z = auxSubMesh->normals[current].z * (1.0f - 1.0f/(float)nb_seen[current]) + normal.z * 1.0f/(float)nb_seen[current];
                    auxSubMesh->normals[current] = glm::normalize(auxSubMesh->normals[current]);
                }
            }
        }
    }

	return resultMesh;
}
Ejemplo n.º 17
0
Mesh* MeshManager::parseMD5(string filename, char* buffer, int lenght){
    Mesh* resultMesh = new Mesh(filename, getNewId());
	int numJoints = 0;
	int numMeshes = 0;
	int numVerts = 0;
	int numTris = 0;
	int numWeights = 0;
	unsigned int idSubMesh = 0;
	int n = 0;
	copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//autoincrease i
	while (buffer[n] != '\0'){
		if(strncmp(tempBuffer, "MD5Version", 10) == 0){
			copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
			//resultMesh->versionMD5 = (int) atoi(tempBuffer);
			//logInf("md5 version %s", tempBuffer);
		}
		else if(strncmp(tempBuffer, "commandline", 11) == 0){
			skipLine(buffer, &n);
		}
		else if(strncmp(tempBuffer, "numJoints", 9) == 0){
			copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
			numJoints = (int) atoi(tempBuffer);
			resultMesh->joints.reserve(numJoints);
		}
		else if(strncmp(tempBuffer, "numMeshes", 9) == 0){
			copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
			numMeshes = (int) atoi(tempBuffer);
			resultMesh->subMeshes.reserve(numMeshes);
		}
		else if(strncmp(tempBuffer, "joints", 6) == 0){
			copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n); //read the '{' character
			Mesh::Joint auxJoint;
			for(int i = 0; i < numJoints; i++){
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointName = tempBuffer;
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointParentID = (int) atoi(tempBuffer);
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);// '(' char
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointPos.x = (float) fast_atof(tempBuffer);
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointPos.y = (float) fast_atof(tempBuffer);
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointPos.z = (float) fast_atof(tempBuffer);
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);// ')' char
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);// '(' char
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointOrient.x = (float) fast_atof(tempBuffer);
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointOrient.y = (float) fast_atof(tempBuffer);
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointOrient.z = (float) fast_atof(tempBuffer);
				skipLine(buffer, &n);

				removeQuotes(&(auxJoint.jointName));
				computeQuaternionW(&(auxJoint.jointOrient));

				resultMesh->joints.push_back(auxJoint);
			}
		}
		else if(strncmp(tempBuffer, "mesh", 4) == 0){
			SubMesh* auxSubMesh = new SubMesh(idSubMesh);
			idSubMesh++;
			copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);// char {
			copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
			while(strncmp(tempBuffer, "}", 1) != 0){
				if(strncmp(tempBuffer, "shader", 6) == 0){
					///////////////TODO
					//shader factory
					//used to set the texture!! be careful
					copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
					auxSubMesh->setSubMeshTextureName(tempBuffer);
					skipLine(buffer, &n);
				}
				else if(strncmp(tempBuffer, "numverts", 8) == 0){
					copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
					numVerts = (int) atoi(tempBuffer);
					glm::vec2 textCoord;
					glm::i32vec2 weightStartAndCount;
					for(int i = 0; i < numVerts; ++i){
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//"vert"
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//id (sorted)
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//'('

						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						textCoord.x = (float) fast_atof(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						textCoord.y = (float) fast_atof(tempBuffer);

						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//')'

						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						weightStartAndCount.x = (int) atoi(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						weightStartAndCount.y = (int) atoi(tempBuffer);

						auxSubMesh->textureCoord.push_back(textCoord);
						auxSubMesh->weightsIndex.push_back(weightStartAndCount);
					}
				}
				else if(strncmp(tempBuffer, "numtris", 7) == 0){
					copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
					numTris = (int) atoi(tempBuffer);
					glm::i32vec3 tri;
					auxSubMesh->elements.reserve(numTris);
					for (int i = 0; i < numTris; ++i){
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						tri.x = (int) atoi(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						tri.z = (int) atoi(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						tri.y = (int) atoi(tempBuffer);
						auxSubMesh->elements.push_back(tri);
					}
				}
				else if(strncmp(tempBuffer, "numweights", 10) == 0){
					copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
					numWeights = (int) atoi(tempBuffer);
					SubMesh::Weight auxWeight;
					auxSubMesh->weights.reserve(numWeights);
					for (int i = 0; i < numWeights; ++i){
						//logInf("Weight[%i]",i);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//weight
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//id (sorted)
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//id joint
						auxWeight.weightJointID = (int) atoi(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//bias
						auxWeight.weightBias = (float) fast_atof(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//'('
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						auxWeight.weightPos.x = (float) fast_atof(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						auxWeight.weightPos.y = (float) fast_atof(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						auxWeight.weightPos.z = (float) fast_atof(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//')'

						auxSubMesh->weights.push_back(auxWeight);
						//logInf("Weight[%i]",i);
					}
				}
				else if(strncmp(tempBuffer, "//", 2) == 0){
					skipLine(buffer, &n);
				}
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);

			}
			prepareSubMeshVertex(resultMesh, auxSubMesh);
			prepareSubMeshNormals(resultMesh, auxSubMesh);
			resultMesh->subMeshes.push_back(auxSubMesh);
		}

		copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//autoincrease i
        if(n>=lenght)break;

	}
	return resultMesh;
}
Ejemplo n.º 18
0
void ofxCvBlobFinder::matchExistingBlobs(){
    int i;
    int paramIndex = -1;
    
    if(blobz.size() < 1) blobParams.clear();
    
    //Create and delete notes based on blob detection outcome
    
    if(blobz.size() > blobParams.size() )  //Create new notes
    {
        for(i = 0; i < blobz.size(); i++)
        {
            ofxCvComplexBlob& tempBlob = blobz[i];
            
            paramIndex = getParamIndexFromBlob(tempBlob);
           
            if(paramIndex < 0 ){
                BlobParam blobParam;
                blobParam.id = getNewId();
                blobParam.isDirty = true;
                blobParam.area = 0;
                blobParam.position = ofPoint(0,0);
                blobParam.curvature = 0;
                blobParams.push_back(blobParam);
            }
        }
    }
    
    //Flag expired blobs
    else if( blobz.size() < blobParams.size() )     
    {
        for(i = 0; i < blobParams.size(); i++){
            int blobIndex = 0;
            while( blobIndex < blobz.size() )
            {
                ofxCvComplexBlob& tempBlob = blobz[blobIndex];
 
                paramIndex = getParamIndexFromBlob(tempBlob);
                
                if(paramIndex < 0){
                    blobParams.erase(blobParams.begin() + i);
                    break;
                }
                
                blobIndex++;
            }
        }
    }
    
    //Update blobparam properties
    if(blobz.size() == blobParams.size() )
    {
        for(i = 0; i < blobParams.size(); i++)
        {
            paramIndex = getParamIndexFromBlob(blobz[i], true);
            
            float area = blobz[i].getArea() / MAX_BLOB_AREA;
            ofPoint position(blobz[i].getBoundingBox().getCenter().x / _width, blobz[i].getBoundingBox().getCenter().y / _height);
            
            vector<ofxCvConvexityDefect> cd = blobz[i].getConvexityDefects();
            float curvature = 0.0f;
            float largestDefect;
            float smallestDefect;
            for(int j=0; j < cd.size(); j++){
                curvature += cd[j].length;
            }
            
            curvature = CLAMP(1.0f - ((MAX_CURVATURE - (curvature / cd.size() + 1)) / MAX_CURVATURE), 0.0f, 1.0f);
            
            if(area != blobParams[paramIndex].area || blobParams[paramIndex].position != position || blobParams[paramIndex].curvature != curvature){
                blobParams[paramIndex].isDirty = true;
                blobParams[paramIndex].position = position;
                blobParams[paramIndex].area = area;
                blobParams[paramIndex].curvature = curvature;                
            }
        }
    }
}
Ejemplo n.º 19
0
	void AsteroidsManager::addAst(int min, int max) {
		addParticle(new Asteroid(getNewId(), min, max));
	}
Ejemplo n.º 20
0
Note* DocumentFactory::buildNewNote(const QString& titre, const QString& path){
    QString id;
    id=getNewId();
    return buildNote(id, titre);
}
Ejemplo n.º 21
0
Label* Win32Window::addLabel(std::string text, int x, int y, int width, int height)
{
    Label *label = new Label(text, x, y, width, height, getNewId());
    m_labels.push_back(label);
}
Ejemplo n.º 22
0
Button* Win32Window::addButton(std::string text, int x, int y, int width, int height, PTRFUN call_func, bool defaultButton)
{
    Button *but = new Button(text, x, y, width, height, getNewId(), call_func, defaultButton);
    m_buttons.push_back(but);
}
Ejemplo n.º 23
0
	ThrustJet::ThrustJet(std::string id, cg::Vector2d position, cg::Vector2d velocity, double angle) : ParticlesManager<ThrustParticle>(id, "Thrust") {
		_thrustManager = (ThrustManager*)cg::Registry::instance()->get("ThrustManager");
		int i = 0;
		for (i = 0; i < 10; i++)
			addParticle(new ThrustParticle(getNewId(), position, velocity, angle, this));
	}
Ejemplo n.º 24
0
	void ExplosionManager::explosion(double posx, double posy) {
		addParticle(new Explosion(getNewId(), posx, posy));
	}
Ejemplo n.º 25
0
TextBox* Win32Window::addTextbox(std::string text, int x, int y, int width, int height)
{
    TextBox *tb = new TextBox(text, x, y, width, height, getNewId());
    m_textboxs.push_back(tb);
}
Ejemplo n.º 26
0
RTPSParticipant* RTPSDomain::createParticipant(RTPSParticipantAttributes& PParam,
		RTPSParticipantListener* listen)
{
	const char* const METHOD_NAME = "createParticipant";
	logInfo(RTPS_PARTICIPANT,"");

	if(PParam.builtin.leaseDuration < c_TimeInfinite && PParam.builtin.leaseDuration <= PParam.builtin.leaseDuration_announcementperiod) //TODO CHeckear si puedo ser infinito
	{
		logError(RTPS_PARTICIPANT,"RTPSParticipant Attributes: LeaseDuration should be >= leaseDuration announcement period");
		return nullptr;
	}
	if(PParam.use_IP4_to_send == false && PParam.use_IP6_to_send == false)
	{
		logError(RTPS_PARTICIPANT,"Use IP4 OR User IP6 to send must be set to true");
		return nullptr;
	}
	uint32_t ID;
	if(PParam.participantID < 0)
	{
		ID = getNewId();
		while(m_RTPSParticipantIDs.insert(ID).second == false)
			ID = getNewId();
	}
	else
	{
		ID = PParam.participantID;
		if(m_RTPSParticipantIDs.insert(ID).second == false)
		{
			logError(RTPS_PARTICIPANT,"RTPSParticipant with the same ID already exists");
			return nullptr;
		}
	}
	if(!PParam.defaultUnicastLocatorList.isValid())
	{
		logError(RTPS_PARTICIPANT,"Default Unicast Locator List contains invalid Locator");
		return nullptr;
	}
	if(!PParam.defaultMulticastLocatorList.isValid())
	{
		logError(RTPS_PARTICIPANT,"Default Multicast Locator List contains invalid Locator");
		return nullptr;
	}
	PParam.participantID = ID;
	int pid;
#if defined(_WIN32)
	pid = (int)_getpid();
#else
	pid = (int)getpid();
#endif
	GuidPrefix_t guidP;
	LocatorList_t loc;
	IPFinder::getIP4Address(&loc);
	if(loc.size()>0)
	{
		guidP.value[0] = c_VendorId_eProsima[0];
		guidP.value[1] = c_VendorId_eProsima[1];
		guidP.value[2] = loc.begin()->address[14];
		guidP.value[3] = loc.begin()->address[15];
	}
	else
	{
		guidP.value[0] = c_VendorId_eProsima[0];
		guidP.value[1] = c_VendorId_eProsima[1];
		guidP.value[2] = 127;
		guidP.value[3] = 1;
	}
	guidP.value[4] = ((octet*)&pid)[0];
	guidP.value[5] = ((octet*)&pid)[1];
	guidP.value[6] = ((octet*)&pid)[2];
	guidP.value[7] = ((octet*)&pid)[3];
	guidP.value[8] = ((octet*)&ID)[0];
	guidP.value[9] = ((octet*)&ID)[1];
	guidP.value[10] = ((octet*)&ID)[2];
	guidP.value[11] = ((octet*)&ID)[3];

	RTPSParticipant* p = new RTPSParticipant(nullptr);
	RTPSParticipantImpl* pimpl = new RTPSParticipantImpl(PParam,guidP,p,listen);
	m_maxRTPSParticipantID = pimpl->getRTPSParticipantID();

	m_RTPSParticipants.push_back(t_p_RTPSParticipant(p,pimpl));
	return p;
}