Esempio n. 1
0
	bool setup() {
		win = new Engine::glfwWindow;
		DefaultGameStateManager *manager = new DefaultGameStateManager(win);

		win->setApplication(this);
		win->setState(manager);
		win->setup();
		//AssetManager::setBasePath("");

		scene = manager->sceneState->scene;

		scene->systemManager->addSystem(new PhysicsSubSystem());
		scene->systemManager->addSystem(new GenericSubSystem());
		scene->systemManager->addSystem(new Generic30fpsSubSystem());
		scene->systemManager->addSystem(new Generic60fpsSubSystem());
		scene->systemManager->addRenderSystem(new DefaultRenderSubSystem());

		DebugRenderSubSystem *dr = new DebugRenderSubSystem();
		scene->systemManager->addRenderSystem(dr);
		scene->setEffect(new PostProcessor(scene));
		mainchar = addMainActor(scene);

		scene->addActor(addModel("Data/Model/mappa4.obj", vec3(-10, 0, -10), vec3(1.5)));
		scene->addActor(addModel("Data/Model/mappa5.obj", vec3(0), vec3(1.1)));
		scene->addActor(addAxis1());
		//	addLucy(scene);
		addParticleSystem(scene,new ParticleSystem(),vec3(10,0,20));
		addParticleSystem(scene,new ParticleSystem1(),vec3(-20,0,20));
		addSun(scene);

  
		loadScene(AssetManager::getBasePath() + "Data/Level/prova/", scene);
		loadScene(AssetManager::getBasePath() + "Data/Level/handmade/", scene);
		Debug("Setup done!\n\n\n\n\nPress F1 to switch to FreeCam\nPress F2 to spawn a light sphere\nPress F3 to get the position\n\n\n\nFor any question contact me at: [email protected]\n\n\n");
	}
Esempio n. 2
0
	void updateModels()
	{
		for(auto it = loadedModels.begin(); it != loadedModels.end(); ++it)
		{
			const ModelData *data = it->second;
			
			bool xmlUpdated		= false;
			bool modelUpdated	= false;
		
			// Get Current TimeStamps
			{
				struct stat modelAttr;
				stat(data->modelFileName.c_str(), &modelAttr);
				time_t modelLastUpdated = modelAttr.st_mtime;
				
				if(modelLastUpdated != data->modelTimeStamp) { modelUpdated = true; }
				
				struct stat xmlAttr;
				stat(data->xmlFileName.c_str(), &xmlAttr);
				time_t xmlLastUpdated = xmlAttr.st_mtime;
				
				if(xmlLastUpdated != data->xmlTimeStamp) { xmlUpdated = true; }
			}
			
			// Update data
			if(modelUpdated || xmlUpdated)
			{
				CaffApp::ModelLoaderXMLFile updateModelSettings(data->xmlFileName);
				addModel(updateModelSettings);
			}
		}
	}
Esempio n. 3
0
void QtSE::projectTreeContextMenu( QPoint point )
{
	CProjectTreeItem *item = (CProjectTreeItem*)projectTree->itemAt( point );

	if( item )
	{
		QMenu *menu = new QMenu();
		menu->setAttribute( Qt::WA_DeleteOnClose , true );

		switch( item->getPartType() )
		{
			case CProjectTreeItem::stage:
				menu->addAction( "Add Stage" , this , SLOT(addStage()) );
				break;
			case CProjectTreeItem::framebuffer:
				menu->addAction( "Add Framebuffer" , this , SLOT(addFramebuffer()) );
				break;
			case CProjectTreeItem::shader:
				menu->addAction( "Add Shader" , this , SLOT(addShader()) );
				break;
			case CProjectTreeItem::texture:
				menu->addAction( "Add Texture" , this , SLOT(addTexture()) );
				break;
			case CProjectTreeItem::model:
				menu->addAction( "Add Model" , this , SLOT(addModel()) );
				break;
			default:
				delete menu;
				return;
		}

		menu->popup( QCursor::pos() , NULL );
	}
}
Esempio n. 4
0
void addModelBezierPatch()
{
    auto mdl = addModel("BezierPatch");

    Gm::MeshGenerator::BezierPatchDescriptor desc;

    auto& p = desc.bezierPatch;
    p.SetOrder(2);

    p.SetControlPoint(0, 0, { -0.5, -0.5,    0 });
    p.SetControlPoint(1, 0, {    0, -0.5,    0 });
    p.SetControlPoint(2, 0, {  0.5, -0.5,    0 });
    p.SetControlPoint(0, 1, { -0.5,    0,    0 });
    p.SetControlPoint(1, 1, {    0,    0,   -1 });
    p.SetControlPoint(2, 1, {  0.5,    0,    0 });
    p.SetControlPoint(0, 2, { -0.5,  0.5,    0 });
    p.SetControlPoint(1, 2, {    0,  0.5,  0.5 });
    p.SetControlPoint(2, 2, {  0.5,  0.5,  0.5 });

    desc.alternateGrid  = true;
    //desc.backFacing     = true;
    //desc.segments       = { 50, 50 };

    mdl->mesh = Gm::MeshGenerator::GenerateBezierPatch(desc);
}
void Renderer::createModels()
{
	clearModels();

	//addModel( new Cube	( this ) );
	addModel( new Triangle	( this ) );
}
Esempio n. 6
0
void addModelSpiral()
{
    auto mdl = addModel("Spiral");

    Gm::MeshGenerator::SpiralDescriptor desc;

    #ifdef ENABLE_PRESENTATION
    desc.ringRadius     = { 0.4f, 0.4f };
    desc.tubeRadius     = { 0.1f, 0.1f, 0.1f };
    desc.mantleSegments = { 100, 50 };
    desc.turns          = 2;
    desc.displacement   = 0.5f;
    desc.alternateGrid  = true;
    #else
    //desc.ringRadius             = { 0.6f, 0.3f };
    //desc.tubeRadius             = { 0.2f, 0.4f, 0.1f };
    desc.tubeRadius             = { 0.2f, 0.1f, 0.2f };
    desc.turns                  = 3;
    desc.displacement           = 0.3f;
    desc.bottomCoverSegments    = 5;
    desc.topCoverSegments       = 3;
    //desc.mantleSegments         = { 0, 0 };
    desc.alternateGrid          = true;
    #endif

    mdl->mesh = Gm::MeshGenerator::GenerateSpiral(desc);
}
Esempio n. 7
0
CSMWorld::Data::Data()
{
    mGlobals.addColumn (new StringIdColumn<ESM::Global>);
    mGlobals.addColumn (new RecordStateColumn<ESM::Global>);
    mGlobals.addColumn (new FixedRecordTypeColumn<ESM::Global> (UniversalId::Type_Global));
    mGlobals.addColumn (new FloatValueColumn<ESM::Global>);

    addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
}
Esempio n. 8
0
void    ToolWidget::makeConnections()
{
    connect(_ui->editWorldName, SIGNAL(textChanged(QString)), this, SLOT(setConfName(String)));
    connect(_ui->groupTerrain, SIGNAL(buttonClicked(int)), this, SLOT(setLandType(int)));
    connect(_ui->groupClimat, SIGNAL(buttonClicked(int)), this, SLOT(setClimatType(int)));
    connect(_ui->sliderWindPower, SIGNAL(valueChanged(int)), this, SLOT(setWindPower(int)));

    connect(_ui->buttonAddModel, SIGNAL(pressed()), this, SLOT(addModel()));
    connect(_ui->buttonDelModel, SIGNAL(pressed()), this, SLOT(delModel()));
}
Esempio n. 9
0
bool Skybox::load( const string& filename )
{
	removeModels(); 

	mp_Tex = GraphicsManager::GetInstance()->getResourceManager()->loadTexture(filename, GL_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE);

	if ( ! mp_Tex )
	{
		GraphicsManager::GetInstance()->getResourceManager()->releaseTexture(mp_Tex);
		return false;
	}

	const GLfloat SKYBOX_SCALE = 1000.0f;

	vec3 skyboxVerts[24] = {
		vec3(-1.0f,  1.0f, -1.0f), vec3( 1.0f,  1.0f, -1.0f), vec3( 1.0f, -1.0f, -1.0f), vec3(-1.0f, -1.0f, -1.0f), // Front
		vec3(-1.0f,  1.0f,  1.0f), vec3(-1.0f,  1.0f, -1.0f), vec3(-1.0f, -1.0f, -1.0f), vec3(-1.0f, -1.0f,  1.0f), // Left
		vec3( 1.0f,  1.0f,  1.0f), vec3(-1.0f,  1.0f,  1.0f), vec3(-1.0f, -1.0f,  1.0f), vec3( 1.0f, -1.0f,  1.0f), // Back
		vec3( 1.0f,  1.0f, -1.0f), vec3( 1.0f,  1.0f,  1.0f), vec3( 1.0f, -1.0f,  1.0f), vec3( 1.0f, -1.0f, -1.0f), // Right
		vec3(-1.0f,  1.0f,  1.0f), vec3( 1.0f,  1.0f,  1.0f), vec3( 1.0f,  1.0f, -1.0f), vec3(-1.0f,  1.0f, -1.0f), // Top
		vec3(-1.0f, -1.0f,  1.0f), vec3( 1.0f, -1.0f,  1.0f), vec3( 1.0f, -1.0f, -1.0f), vec3(-1.0f, -1.0f, -1.0f)  // Bottom
	};

	const GLfloat ONE_FOURTH   = 0.25f;
	const GLfloat TWO_FOURTH   = 0.5f;
	const GLfloat THREE_FOURTH = 0.75f;
	const GLfloat ONE_THIRD    = 1.0f / 3.0f + 0.0015f;
	const GLfloat TWO_THIRD    = 2.0f / 3.0f - 0.0015f;

	vec2 skyboxTxcrds[24] = {
		vec2( ONE_FOURTH,   TWO_THIRD ), vec2( TWO_FOURTH,   TWO_THIRD ), vec2( TWO_FOURTH,   ONE_THIRD ), vec2( ONE_FOURTH,   ONE_THIRD ), // Front
		vec2( 0.0f,         TWO_THIRD ), vec2( ONE_FOURTH,   TWO_THIRD ), vec2( ONE_FOURTH,   ONE_THIRD ), vec2( 0.0f,         ONE_THIRD ), // Left
		vec2( THREE_FOURTH, TWO_THIRD ), vec2( 1.0f,         TWO_THIRD ), vec2( 1.0f,         ONE_THIRD ), vec2( THREE_FOURTH, ONE_THIRD ), // Back
		vec2( TWO_FOURTH,   TWO_THIRD ), vec2( THREE_FOURTH, TWO_THIRD ), vec2( THREE_FOURTH, ONE_THIRD ), vec2( TWO_FOURTH,   ONE_THIRD ), // Right
		vec2( ONE_FOURTH,   1.0f      ), vec2( TWO_FOURTH,   1.0f      ), vec2( TWO_FOURTH,   TWO_THIRD ), vec2( ONE_FOURTH,   TWO_THIRD ), // Up
		vec2( ONE_FOURTH,   0.0f      ), vec2( TWO_FOURTH,   0.0f      ), vec2( TWO_FOURTH,   ONE_THIRD ), vec2( ONE_FOURTH,   ONE_THIRD )  // Down
	};

	for (int i = 0; i < 24; ++i)
		skyboxVerts[i] *= SKYBOX_SCALE;

	Mesh* pMesh = GraphicsManager::GetInstance()->getResourceManager()->addMesh("skybox-quads");
	pMesh->begin(GL_QUADS, 24);
	pMesh->copyVertexData(skyboxVerts);
	pMesh->copyTextureCoordData(skyboxTxcrds);
	pMesh->end();

	Model* pModel = GraphicsManager::GetInstance()->getResourceManager()->addModel("skybox");
	pModel->addMesh(pMesh);

	addModel(pModel);

	return true;
}
Esempio n. 10
0
void addModelPlane()
{
    auto mdl = addModel("Plane");
    auto& m = mdl->mesh;

    m.AddVertex({ -1,  1, 0 }, { 0, 0, -1 }, { 0, 0 });
    m.AddVertex({  1,  1, 0 }, { 0, 0, -1 }, { 1, 0 });
    m.AddVertex({  1, -1, 0 }, { 0, 0, -1 }, { 1, 1 });
    m.AddVertex({ -1, -1, 0 }, { 0, 0, -1 }, { 0, 1 });

    m.AddTriangle(0, 1, 2);
    m.AddTriangle(0, 2, 3);
}
Esempio n. 11
0
/**
 * Docasna funkce pro naplneni sceny modely
 */
void ModelContainer::load() {	

	if (1) {
		Model* room = new PrimitiveModel( PrimitiveModel::ROOM );
		Model* cube = new PrimitiveModel( PrimitiveModel::CUBE );
		Model* block = new PrimitiveModel( PrimitiveModel::BLOCK );

		Model* roomClosure = new PrimitiveModel( PrimitiveModel::ROOMCLOSURE );

		addModel(room);
		addModel(roomClosure);
		addModel(cube);
		addModel(block);
	}

	else {
		//Model* test = new WaveFrontModel("../models/simple_box.obj");
		//Model* test = new WaveFrontModel("../models/chair.obj");
		Model* test = new WaveFrontModel("../models/VUT_final.obj");
		addModel(test);
	}
}
Esempio n. 12
0
void Model::loadAll()
{
    SimpleActionsView *v;
    setSettings(Settings::getInstance());

    SimpleActionsModel *m;

    v = new SimpleActionsView(QString::fromUtf8("Next &Actions"), view_);
    view_->addCategory(v);
    m = new SimpleActionsModel(v, v);
    addModel(m);

    v = new ProjectsView(QString::fromUtf8("&Projects"), view_);
    view_->addCategory(v);
    m = new SimpleActionsModel(v, v);
    addModel(m);

    v = new SimpleActionsView(QString::fromUtf8("&Someday/Maybe"),view_);
    view_->addCategory(v);
    m = new SimpleActionsModel(v, v);
    addModel(m);

    QFile file(filename_);

    if (!file.exists())
        return;

    file.open(QIODevice::ReadOnly);
    QDataStream in(&file);

    settings_->loadContents(in);

    QList<SimpleActionsModel*>::iterator it;
    for (it = models_.begin(); it != models_.end(); it++) {
        (*it)->loadContents(in);
    }

    file.close();
}
Esempio n. 13
0
PreviewWindow::PreviewWindow(QWidget *proxyParent, MainWindow *parent, const QGLFormat &format)
: QGLWidget(new CoreProfileContext(format), proxyParent),
  _parent(*parent),
  _scene(parent->scene()),
  _selection(parent->selection()),
  _mousePriorities(DefaultPriorities),
  _rebuildMeshes(false)
{
    setMouseTracking(true);
    setFocusPolicy(Qt::ClickFocus);

    new QShortcut(QKeySequence("A"), this, SLOT(toggleSelectAll()));
    new QShortcut(QKeySequence("G"), this, SLOT(grabGizmo()));
    new QShortcut(QKeySequence("Ctrl+C"), this, SLOT(recomputeCentroids()));
    new QShortcut(QKeySequence("Ctrl+R"), this, SLOT(computeSmoothNormals()));
    new QShortcut(QKeySequence("Ctrl+Shift+R"), this, SLOT(computeHardNormals()));
    new QShortcut(QKeySequence("Ctrl+F"), this, SLOT(freezeTransforms()));
    new QShortcut(QKeySequence("Ctrl+D"), this, SLOT(duplicateSelection()));
    new QShortcut(QKeySequence("Ctrl+A"), this, SLOT(addModel()));
    new QShortcut(QKeySequence("Delete"), this, SLOT(deleteSelection()));
    new QShortcut(QKeySequence("Ctrl+Tab"), this, SLOT(togglePreview()));

    QShortcut *tShortcut = new QShortcut(QKeySequence("W"), this);
    QShortcut *rShortcut = new QShortcut(QKeySequence("E"), this);
    QShortcut *sShortcut = new QShortcut(QKeySequence("R"), this);
    QShortcut *xShortcut = new QShortcut(QKeySequence("X"), this);
    QShortcut *yShortcut = new QShortcut(QKeySequence("Y"), this);
    QShortcut *zShortcut = new QShortcut(QKeySequence("Z"), this);
    QShortcut *lShortcut = new QShortcut(QKeySequence("Q"), this);

    QSignalMapper *gizmoMapper = new QSignalMapper();
    connect(tShortcut, SIGNAL(activated()), gizmoMapper, SLOT(map()));
    connect(rShortcut, SIGNAL(activated()), gizmoMapper, SLOT(map()));
    connect(sShortcut, SIGNAL(activated()), gizmoMapper, SLOT(map()));
    gizmoMapper->setMapping(tShortcut, 0);
    gizmoMapper->setMapping(rShortcut, 1);
    gizmoMapper->setMapping(sShortcut, 2);
    connect(gizmoMapper, SIGNAL(mapped(int)), &_gizmo, SLOT(setMode(int)));

    gizmoMapper = new QSignalMapper();
    connect(xShortcut, SIGNAL(activated()), gizmoMapper, SLOT(map()));
    connect(yShortcut, SIGNAL(activated()), gizmoMapper, SLOT(map()));
    connect(zShortcut, SIGNAL(activated()), gizmoMapper, SLOT(map()));
    gizmoMapper->setMapping(xShortcut, 0);
    gizmoMapper->setMapping(yShortcut, 1);
    gizmoMapper->setMapping(zShortcut, 2);
    connect(gizmoMapper, SIGNAL(mapped(int)), &_gizmo, SLOT(fixAxis(int)));
    connect(lShortcut, SIGNAL(activated()), &_gizmo, SLOT(toggleTranslateLocal()));
    connect(&_gizmo, SIGNAL(redraw()), this, SLOT(updateGL()));
    connect(&_gizmo, SIGNAL(transformFinished(Mat4f)), this, SLOT(transformFinished(Mat4f)));
}
Esempio n. 14
0
void addModelEllipsoid()
{
    auto mdl = addModel("Ellipsoid");

    Gm::MeshGenerator::EllipsoidDescriptor desc;

    #ifdef ENABLE_PRESENTATION
    desc.segments       = { 40, 20 };
    desc.alternateGrid  = true;
    #else
    desc.radius         = Gs::Vector3(1, 1.25f, 0.75f)*0.5f;
    desc.segments       = { 20, 20 };
    desc.alternateGrid  = true;
    #endif

    mdl->mesh = Gm::MeshGenerator::GenerateEllipsoid(desc);
}
Esempio n. 15
0
void addModelCuboid()
{
    auto mdl = addModel("Cuboid");

    Gm::MeshGenerator::CuboidDescriptor desc;

    #ifdef ENABLE_PRESENTATION
    desc.segments       = { 4, 4, 2 };
    desc.alternateGrid  = true;
    #else
    desc.size           = { 1, 0.75f, 1.25f };
    desc.segments       = { 1, 2, 3 };
    desc.alternateGrid  = true;
    #endif

    mdl->mesh = Gm::MeshGenerator::GenerateCuboid(desc);
}
Esempio n. 16
0
void ModelMapper::updateModelConfig(QString path)
{
	QFileInfo dirFI(path);
	if (dirFI.isDir())
	{
		QDir dir(path);
		QStringList entryFilter;
		entryFilter << "*.json";
		QStringList entries = dir.entryList(entryFilter, QDir::Files);
		foreach(const QString entry, entries)
		{
			if (!m_modelFileMap.values().contains(entry))
			{
				if (addModel(entry)) m_watcher.addPath(entry);
			}
		}
	} else {
Esempio n. 17
0
void Scene::setProxySceneObject(const std::wstring &modelPath, float scale, const Float3 &pos, const Quaternion &rot)
{
	Model *m = addModel(modelPath);
	_objectBases[_numObjectBases] = createBase(scale, pos, rot);
	_prevWVPs[_numPrevWVPs] = _objectBases[_numObjectBases];

	SceneObject &obj = _proxySceneObject;
	obj.base = &_objectBases[_numObjectBases];
	obj.model = m;
	obj.bound = nullptr;
	obj.prevWVP = &_prevWVPs[_numPrevWVPs];
	obj.id = _highestSceneObjId++;

	_numObjectBases++;
	_numPrevWVPs++;

	_hasProxySceneObject = true;
}
Esempio n. 18
0
void addModelTorus()
{
    auto mdl = addModel("Torus");

    Gm::MeshGenerator::TorusDescriptor desc;

    #ifdef ENABLE_PRESENTATION
    desc.segments       = { 100, 50 };
    desc.alternateGrid  = true;
    #else
    desc.ringRadius     = { 0.3f, 0.6f };
    desc.tubeRadius     = { 0.2f, 0.4f, 0.1f };
    //desc.segments       = { 100, 50 };
    desc.alternateGrid  = true;
    #endif

    mdl->mesh = Gm::MeshGenerator::GenerateTorus(desc);
}
Esempio n. 19
0
void Facade::uploadModelFromFile(StreamInfo streamInfo)
{
    try
    {
        processStream(&streamInfo);

        AddModel addModel(this->action, &streamInfo);
        addModel.execute();

        DrawScene drawScene(this->action);
        drawScene.execute();
    }
    catch(BaseException& exc)
    {
        qDebug()<<exc.what();
        this->alertWindowService->showErrorMessage(exc.what());
    }
}
Esempio n. 20
0
void addModelCone()
{
    auto mdl = addModel("Cone");

    Gm::MeshGenerator::ConeDescriptor desc;

    #ifdef ENABLE_PRESENTATION
    desc.mantleSegments = { 40, 10 };
    desc.alternateGrid          = true;
    #else
    desc.radius         = Gs::Vector2{ 1, 0.5f }*0.5f;
    desc.height         = 1.0f;
    desc.mantleSegments = { 20, 5 };
    desc.coverSegments  = 3;
    desc.alternateGrid  = true;
    #endif

    mdl->mesh = Gm::MeshGenerator::GenerateCone(desc);
}
Esempio n. 21
0
ModelMapper::ModelMapper(QObject *parent) :
	QObject(parent)
{
	m_watcher.addPath(QDir::currentPath());
	qDebug() << Q_FUNC_INFO << "watching" << QDir::currentPath();
	QDir dir;
	QStringList entryFilter;
	entryFilter << "*.json";
	QStringList entries = dir.entryList(entryFilter, QDir::Files);
	foreach (const QString entry, entries){
		if (addModel(entry)) {
			m_watcher.addPath(entry);
			qDebug() << Q_FUNC_INFO << "watching" << entry;
		}
	}
	connect(&m_watcher, SIGNAL(directoryChanged(QString)), this, SLOT(updateModelConfig(QString)));
	connect(&m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateModelConfig(QString)));

}
Esempio n. 22
0
void addModelCylinder()
{
    auto mdl = addModel("Cylinder");

    Gm::MeshGenerator::CylinderDescriptor desc;

    #ifdef ENABLE_PRESENTATION
    desc.mantleSegments         = { 40, 5 };
    desc.alternateGrid          = true;
    #else
    desc.radius                 = Gs::Vector2{ 1, 0.5f }*0.5f;
    desc.height                 = 1.0f;
    desc.mantleSegments         = { 20, 3 };
    desc.topCoverSegments       = 3;
    desc.bottomCoverSegments    = 1;
    desc.alternateGrid          = true;
    #endif

    mdl->mesh = Gm::MeshGenerator::GenerateCylinder(desc);
}
Esempio n. 23
0
QAbstractItemModel *CSMWorld::Data::getTableModel (const CSMWorld::UniversalId& id)
{
    std::map<UniversalId::Type, QAbstractItemModel *>::iterator iter = mModelIndex.find (id.getType());

    if (iter==mModelIndex.end())
    {
        // try creating missing (secondary) tables on the fly
        //
        // Note: We create these tables here so we don't have to deal with them during load/initial
        // construction of the ESX data where no update signals are available.
        if (id.getType()==UniversalId::Type_RegionMap)
        {
            RegionMap *table = 0;
            addModel (table = new RegionMap (*this), UniversalId::Type_RegionMap, false);
            return table;
        }
        throw std::logic_error ("No table model available for " + id.toString());
    }

    return iter->second;
}
Esempio n. 24
0
void WalkmeshWidget::openModels()
{
//	if(thread)	thread->deleteLater();
	if(!this->fieldModels.isEmpty() || !field || !scripts) {
		return;
	}
	int modelCount = scripts->modelCount();
	QList<int> modelIds;
	for(int modelId=0 ; modelId<modelCount ; ++modelId) {
		modelIds.append(modelId);
	}
//	if(field->isPC()) {
//		thread = new FieldModelThread(this);
//		thread->setField(field);
//		connect(thread, SIGNAL(modelLoaded(Field*,FieldModelFile*,int,int,bool)), SLOT(addModel(Field*,FieldModelFile*,int)));
//		thread->setModels(modelIds);
//		thread->start();
//	} else {
		foreach(int modelId, modelIds) {
			addModel(field, field->fieldModel(modelId), modelId);
		}
Esempio n. 25
0
void addModelPipe()
{
    auto mdl = addModel("Pipe");

    Gm::MeshGenerator::PipeDescriptor desc;

    #ifdef ENABLE_PRESENTATION
    desc.mantleSegments         = { 40, 5 };
    desc.alternateGrid          = true;
    #else
    desc.innerRadius            = Gs::Vector2{ 0.75f, 0.35f }*0.5f;
    desc.outerRadius            = Gs::Vector2{ 1, 1 }*0.5f;
    desc.height                 = 1.0f;
    desc.mantleSegments         = { 20, 3 };
    desc.topCoverSegments       = 3;
    desc.bottomCoverSegments    = 1;
    desc.alternateGrid          = true;
    #endif

    mdl->mesh = Gm::MeshGenerator::GeneratePipe(desc);
}
Esempio n. 26
0
void addModelCurve()
{
    auto mdl = addModel("Curve");

    Gm::MeshGenerator::CurveDescriptor desc;

    desc.curveFunction  = [](Gs::Real t)
    {
        auto f = t;
        t = std::sin(t*Gs::pi);
        return Gs::Vector3(
            (t-0.5f)*2,
            std::sqrt(t*2)*0.5f + std::sin(std::pow(t, 2.0f)*Gs::pi*7)*0.2f,
            std::sin(f*Gs::pi*2)
        );
    };

    desc.segments       = { 200, 20 };
    desc.radius         = 0.05f;
    desc.alternateGrid  = true;

    mdl->mesh = Gm::MeshGenerator::GenerateCurve(desc);
}
Esempio n. 27
0
void QtSE::fsProjectTreeContextMenu( QPoint point )
{
	activeProjectItem = (CProjectTreeItem*)fsProjectTree->itemAt( point );

	if( activeProjectItem )
	{
		QMenu *menu = new QMenu();
		menu->setAttribute( Qt::WA_DeleteOnClose , true );

		switch( activeProjectItem->getPartType() )
		{
			case CProjectTreeItem::dir:
			{
				//activeFilePath.clear();
				//activeProjectItem->getRelativePath( activeFilePath );
				//activeFilePath.prepend( projectPath.getPath( true ) );

				menu->addAction( "Add Folder" , this , SLOT(addFolder()) );
				menu->addSeparator();
				menu->addAction( "Add Stage" , this , SLOT(addStage()) );
				menu->addAction( "Add Framebuffer" , this , SLOT(addFramebuffer()) );
				menu->addAction( "Add Shader" , this , SLOT(addShader()) );
				menu->addAction( "Add Model" , this , SLOT(addModel()) );
				menu->addAction( "Add Texture" , this , SLOT(addTexture()) );
				menu->addSeparator();
				menu->addAction( "Delete Folder" , this , SLOT(deleteItem()) );
				break;
			}
			default:
				delete menu;
				return;
		}

		menu->popup( QCursor::pos() , NULL );
	}
}
Esempio n. 28
0
void addModelTorusKnot()
{
    auto mdl = addModel("TorusKnot");

    Gm::MeshGenerator::TorusKnotDescriptor desc;

    #ifdef ENABLE_PRESENTATION
    desc.ringRadius     = { 0.2f, 0.2f, 0.2f };
    desc.segments       = { 200, 50 };
    desc.alternateGrid  = true;
    #else
    desc.ringRadius     = { 0.25f, 0.25f, 0.25f };
    desc.tubeRadius     = 0.1f;
    desc.loops          = 2;
    desc.turns          = 3;
    //desc.innerRadius    = 1.5f;
    desc.segments       = { 200, 20 };
    //desc.segments       = { 2, 5 };
    desc.alternateGrid  = true;
    //desc.vertexModifier = [](Gs::Real u, Gs::Real v) { return 0.6f + std::sin(u*Gs::pi*20)*0.4f; };
    #endif

    mdl->mesh = Gm::MeshGenerator::GenerateTorusKnot(desc);
}
bool Cterrain::init(const string&heightMapFileName,const Cc3dRect&rect,float heightScale,int quadtreeDepth,
                   Cc3dTexture*texture){
    assert(rect.getWidth()==rect.getHeight());
    m_heightScale=heightScale;
    m_quadtreeDepth=quadtreeDepth;
    m_heightMapFileName=heightMapFileName;
    //生成model
    Cc3dModel*model=new Cc3dModel();
    model->init();
    model->autorelease();
    addModel(model);
    //读取高程数据
    readLandMat();
    //求高度范围
    float Hmin=c3d_INF;
    float Hmax=-c3d_INF;
    for(int i=0;i<(int)landMat.size();i++){//倒序
        for(int j=0;j<(int)landMat[i].size();j++){//正序
            if(landMat[i][j]>Hmax){
                Hmax=landMat[i][j];
            }
            if(landMat[i][j]<Hmin){
                Hmin=landMat[i][j];
            }
        }
    }//得到Hmin和Hmax
    //设置m_range
    m_range.init(rect.getMinX(), rect.getMaxX(), Hmin, Hmax, rect.getMinY(), rect.getMaxY());
    //计算步长
    int markMatSideLength=pow(2,m_quadtreeDepth-1)+1;
    gridSize=m_range.getSpanX()/(markMatSideLength-1);
    //填充法向数据
    fillNormalMat();
    //markmat开辟空间
    markmat.resize(markMatSideLength);
    for(int i=0;i<(int)markmat.size();i++){
        markmat[i].resize(markMatSideLength);
        for(int j=0;j<(int)markmat[i].size();j++){
            markmat[i][j]=0;
        }
    }
    //制作ground mesh
    Cc3dMesh*mesh=new Cc3dMesh();
    mesh->autorelease();
    mesh->init();
    mesh->setTexture(texture);
    mesh->getIndexVBO()->genBuffers();
    this->getModel()->addMesh(mesh);
    //make mesh
    makeMesh();
    
    //xxxx下面要去掉
    
    //申请空间不光要考虑矩形,还要考虑三角形
    //另外注意一个矩形要拆成两个三角形,所以是六个顶点(而非四个)
    //矩形最大数量:BMPHEIGHT*BMPWIDTH
    //矩形分裂出的最大三角形数量:BMPHEIGHT*BMPWIDTH*2
    //补洞三角形最大数量:等于mesh网格的非边缘边个数,等于BMPHEIGHT*(BMPWIDTH-1)+BMPWIDTH*(BMPHEIGHT-1)
    //所以总共有BMPHEIGHT*BMPWIDTH*2+(BMPHEIGHT*(BMPWIDTH-1)+BMPWIDTH*(BMPHEIGHT-1))个三角形
    int bmpHeight=(int)landMat.size();
    int bmpWidth=(int)landMat[0].size();
    this->getModel()->getMeshByIndex(0)->getMeshData()->IDtriList.reserve(bmpHeight*bmpWidth*2+(bmpHeight*(bmpWidth-1)+bmpWidth*(bmpHeight-1)));
    return true;
    
}
Esempio n. 30
0
	inline void addLight(Light *light) {
		__lights.push_back(light);
		addModel(light);
	}