Beispiel #1
0
void Rails::setupRoute(bool bitFlag, const Common::Point &srcPos, const Common::Point &destPos) {
	// Reset the nodes in as being inactive
	for (uint i = 0; i < _nodes.size(); ++i)
		_nodes[i]._active = false;

	// Set the two extra walk nodes to the start and destination positions
	setNodePosition(_nodes.size() - 2, srcPos);
	setNodePosition(_nodes.size() - 1, destPos);

	// Start constructing route node list
	_routeLength = 0x3FFF;
	_routeIndexes.clear();

	// Recursively form a route from the destination walk node back to the player's position
	setupRouteNode(&_tempRoute[0], _nodes.size() - 1, bitFlag ? 0xC000 : 0x8000, 0);

	_next = 0;
	if (_routeIndexes.size() > 0) {
		Common::Point currPos = srcPos;
		for (int routeCtr = size() - 1; (routeCtr >= 0) && !_next; --routeCtr) {
			int idx = _routeIndexes[routeCtr];
			const Common::Point &pt = _nodes[idx]._walkPos;

			_next = scanPath(currPos, pt);
			currPos = pt;
		}
	}
}
Beispiel #2
0
Human::Human(int nodeX, int nodeY)
{
    setNodePosition(nodeX, nodeY);
    iSize = _iNodeSize;
    sf::Color rgb(100,110,230);
    sfColour = rgb;
    iHealth = 100;
    iMaxHealth = 100;
}
Beispiel #3
0
void WeightEditProxy::initWE()
{
	nodeDiameter = 6;

	//    setMinimumWidth(40);
	//    setGeometry(QRectF(0,0, 40, 100));

	wg = new QWidget();

	QPalette pal;
	pal.setColor(QPalette::Background, Qt::transparent);
	setPalette(pal);

	leValue = new QLineEdit(wg);
	leValue->setValidator(new QDoubleValidator(DBL_MAX, DBL_MIN, 3));
	leValue->setGeometry(0,0,40,20);
	setNodePosition(Right);

	setWidget(wg);
	//    setVisible(false);
}//initWE
void GLC_WorldTo3ds::createNodeFromOccurrence(GLC_StructOccurence* pOcc)
{
	Lib3dsNode* p3dsNode = lib3ds_node_new_object();
	p3dsNode->node_id= m_CurrentNodeId;
	m_OccIdToNodeId.insert(pOcc->id(), m_CurrentNodeId++);

	if (pOcc->parent() == m_World.rootOccurence())
	{
		p3dsNode->parent_id= LIB3DS_NO_PARENT;
	}
	else
	{
		Q_ASSERT(m_OccIdToNodeId.contains(pOcc->parent()->id()));
		p3dsNode->parent_id= m_OccIdToNodeId.value(pOcc->parent()->id());
	}

	lib3ds_file_insert_node(m_pLib3dsFile, p3dsNode);

	GLC_StructReference* pRef= pOcc->structReference();
	if (m_UseAbsolutePosition)
	{
		if (pOcc->structReference()->hasRepresentation())
		{
			GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(pOcc->structReference()->representationHandle());
			if (NULL != pRep)
			{
				// This reference has a mesh
				const GLC_Matrix4x4 matrix= pOcc->absoluteMatrix();
				const QString meshName= pRef->name() + '_' + QString::number(++m_CurrentMeshIndex);
				QList<Lib3dsMesh*> meshes= createMeshsFrom3DRep(pRep, meshName, matrix);

				const int meshCount= meshes.count();
				for (int i= 0; i < meshCount; ++i)
				{
					lib3ds_file_insert_mesh(m_pLib3dsFile, meshes.at(i));
				}

				if (meshCount > 1)
				{
					for (int i= 0; i < meshCount; ++i)
					{

						Lib3dsNode* pCurrent3dsNode = lib3ds_node_new_object();
						pCurrent3dsNode->node_id= m_CurrentNodeId++;
						pCurrent3dsNode->parent_id= p3dsNode->node_id;

						strcpy(pCurrent3dsNode->name, meshes.at(i)->name);
						lib3ds_file_insert_node(m_pLib3dsFile, pCurrent3dsNode);
					}
				}
				else if (!meshes.isEmpty())
				{
					strcpy(p3dsNode->name, meshes.first()->name);
				}
			}
		}
	}
	else
	{
		// Node matrix
		const GLC_Matrix4x4 matrix= pOcc->structInstance()->relativeMatrix();
		setNodePosition(p3dsNode, matrix);

		// Set mesh name if necessary
		if (m_ReferenceToMesh.contains(pRef))
		{

			QList<Lib3dsMesh*> meshes= m_ReferenceToMesh.values(pRef);
			const int meshCount= meshes.count();
			if (meshCount > 1)
			{
				for (int i= 0; i < meshCount; ++i)
				{

					Lib3dsNode* pCurrent3dsNode = lib3ds_node_new_object();
					pCurrent3dsNode->node_id= m_CurrentNodeId++;
					pCurrent3dsNode->parent_id= p3dsNode->node_id;

					strcpy(pCurrent3dsNode->name, meshes.at(i)->name);
					lib3ds_file_insert_node(m_pLib3dsFile, pCurrent3dsNode);
				}
			}
			else
			{
				strcpy(p3dsNode->name, m_ReferenceToMesh.value(pRef)->name);
			}

		}
	}
}