QVariantMap TimelineModelAggregator::nextItem(int selectedModel, int selectedItem,
                                              qint64 time) const
{
    if (selectedItem != -1)
        time = model(selectedModel)->startTime(selectedItem);

    QVarLengthArray<int> itemIndexes(modelCount());
    for (int i = 0; i < modelCount(); i++) {
        const TimelineModel *currentModel = model(i);
        if (currentModel->count() > 0) {
            if (selectedModel == i) {
                itemIndexes[i] = (selectedItem + 1) % currentModel->count();
            } else {
                if (currentModel->startTime(0) > time)
                    itemIndexes[i] = 0;
                else
                    itemIndexes[i] = (currentModel->lastIndex(time) + 1) % currentModel->count();
            }
        } else {
            itemIndexes[i] = -1;
        }
    }

    int candidateModelIndex = -1;
    qint64 candidateStartTime = std::numeric_limits<qint64>::max();
    for (int i = 0; i < modelCount(); i++) {
        if (itemIndexes[i] == -1)
            continue;
        qint64 newStartTime = model(i)->startTime(itemIndexes[i]);
        if (newStartTime > time && newStartTime < candidateStartTime) {
            candidateStartTime = newStartTime;
            candidateModelIndex = i;
        }
    }

    int itemIndex;
    if (candidateModelIndex != -1) {
        itemIndex = itemIndexes[candidateModelIndex];
    } else {
        itemIndex = -1;
        candidateStartTime = std::numeric_limits<qint64>::max();
        for (int i = 0; i < modelCount(); i++) {
            const TimelineModel *currentModel = model(i);
            if (currentModel->count() > 0 && currentModel->startTime(0) < candidateStartTime) {
                candidateModelIndex = i;
                itemIndex = 0;
                candidateStartTime = currentModel->startTime(0);
            }
        }
    }

    QVariantMap ret;
    ret.insert(QLatin1String("model"), candidateModelIndex);
    ret.insert(QLatin1String("item"), itemIndex);
    return ret;
}
Пример #2
0
void FieldModelLoaderPC::swapModel(int oldModelID, int newModelID)
{
	if(oldModelID != newModelID
			&& oldModelID >= 0 && oldModelID < modelCount()
			&& newModelID >= 0 && newModelID < modelCount()) {
		model_unknown.swap(oldModelID, newModelID);
		model_nameChar.swap(oldModelID, newModelID);
		model_nameHRC.swap(oldModelID, newModelID);
		model_typeHRC.swap(oldModelID, newModelID);
		colors.swap(oldModelID, newModelID);

		model_anims.swap(oldModelID, newModelID);
		model_anims_unknown.swap(oldModelID, newModelID);

		setModified(true);
	}
}
Пример #3
0
void FieldModelLoaderPC::removeAnim(int modelID, int numA)
{
	if(modelID >= 0 && modelID < modelCount()
			&& numA >= 0 && numA < animCount(modelID)) {
		model_anims[modelID].removeAt(numA);
		model_anims_unknown[modelID].removeAt(numA);
		setModified(true);
	}
}
Пример #4
0
bool FieldModelLoaderPC::insertAnim(int modelID, int numA, const QString &name)
{
	if(modelID >= 0 && modelID < modelCount() && animCount(modelID) < maxAnimCount()) {
		model_anims[modelID].insert(numA, name);
		model_anims_unknown[modelID].insert(numA, 1);
		setModified(true);
		return true;
	}
	return false;
}
Пример #5
0
void FieldModelLoaderPC::swapAnim(int modelID, int oldNumA, int newNumA)
{
	if(modelID >= 0 && modelID < modelCount()
			&& oldNumA != newNumA
			&& oldNumA >= 0 && oldNumA < animCount(modelID)
			&& newNumA >= 0 && newNumA < animCount(modelID)) {
		model_anims[modelID].swap(oldNumA, newNumA);
		model_anims_unknown[modelID].swap(oldNumA, newNumA);
		setModified(true);
	}
}
Пример #6
0
//--------------------------------------------------------------------------------------------------
/// Get all pars in all models in the scene
//--------------------------------------------------------------------------------------------------
void Scene::allParts(Collection<Part>* partCollection)
{
    uint numModels = modelCount();
    uint i;
    for (i = 0; i < numModels; i++)
    {
        Model* model = m_models.at(i);
        CVF_ASSERT(model);

        model->allParts(partCollection);
    }
}
Пример #7
0
void FieldModelLoaderPC::removeModel(int modelID)
{
	if(modelID >= 0 && modelID < modelCount()) {
		model_unknown.removeAt(modelID);
		model_nameChar.removeAt(modelID);
		model_nameHRC.removeAt(modelID);
		model_typeHRC.removeAt(modelID);
		colors.removeAt(modelID);

		model_anims.removeAt(modelID);
		model_anims_unknown.removeAt(modelID);

		setModified(true);
	}
}
Пример #8
0
//--------------------------------------------------------------------------------------------------
/// Compute the visible parts of all models in the scene
//--------------------------------------------------------------------------------------------------
void Scene::findVisibleParts(PartRenderHintCollection* visibleParts, const Camera& camera, const CullSettings& cullSettings, unsigned int enableMask)
{
    visibleParts->setCountZero();

    uint i;
    for (i = 0; i < modelCount(); i++)
    {
        Model* model = m_models[i].p();
        if (model) 
        {
            if ((enableMask & model->partEnableMask()) != 0)
            {
                model->findVisibleParts(visibleParts, camera, cullSettings, enableMask);
            }
        }
    }
}
Пример #9
0
bool FieldModelLoaderPC::insertModel(int modelID, const QString &hrcName)
{
	if(modelCount() < maxModelCount()) {
		QList<QRgb> color;
		if(!colors.isEmpty())
			color = colors.first();

		model_unknown.insert(modelID, (quint16)0);
		model_nameChar.insert(modelID, QString());
		model_nameHRC.insert(modelID, hrcName);
		model_typeHRC.insert(modelID, field()->scriptsAndTexts()->scale());
		colors.insert(modelID, color);

		model_anims.insert(modelID, QStringList());
		model_anims_unknown.insert(modelID, QList<quint16>());

		setModified(true);
		return true;
	}
	return false;
}
Пример #10
0
bool Sky::hasModel(int index) const
{
    return index >= 0 && index < modelCount();
}