void CMultiTexturingTerrainSceneNode::render() {
            //CTerrainSceneNode::render();
            //I learned this meshbuffer trick from Viz_Fuerte's "Simple but useful projects"
            if (!SceneManager->isCulled(this)) {
                /*setVisible(true);
                OnRegisterSceneNode();
                updateAbsolutePosition();
                setVisible(false);*/
                //Reset the transformation
                SceneManager->getVideoDriver()->setTransform(video::ETS_WORLD, core::IdentityMatrix);

                for (u32 i = 0; i < array_Passes.size(); i++) {
                    setMaterialTexture(0, array_Passes[i]->splat_texture);
                    setMaterialTexture(1, array_Passes[i]->red_texture);
                    setMaterialTexture(2, array_Passes[i]->green_texture);
                    setMaterialTexture(3, array_Passes[i]->blue_texture);

                    video::SMaterial material = getMaterial(0);
                    material.MaterialType = (video::E_MATERIAL_TYPE)shaderMaterial;
                    material.MaterialTypeParam = video::pack_textureBlendFunc(video::EBF_DST_COLOR, video::EBF_ONE);

                    SceneManager->getVideoDriver()->setMaterial(material);
                    SceneManager->getVideoDriver()->drawMeshBuffer(getRenderBuffer());
                }
            }
        }
Example #2
0
	void EngineExhaustNode::addNozzle( irr::core::vector3df offset )
	{
		auto fire = SceneManager->addParticleSystemSceneNode(false, this, 0);
		fire->setParticleBehavior( EPB_EMITTER_VECTOR_IGNORE_ROTATION | EPB_EMITTER_FRAME_INTERPOLATION);

		fire->setParticlesAreGlobal(true);

		//Emitter
		auto emitter = fire->createSphereEmitter(
				offset, mRadius, vector3df(0,0,-1), 20, 20,
				SColor(255,255,255,255), SColor(255,255,255,255),
				mParticleLifetime - 100, mParticleLifetime, 5, dimension2df(mParticleSize, mParticleSize), dimension2df( mParticleSize * 1.5, mParticleSize * 1.5));

		fire->setEmitter(emitter);

		fire->addAffector(mFadeOutAffector);
		fire->addAffector(mScaleAffector);

		fire->setMaterialFlag(EMF_LIGHTING, false);
		fire->setMaterialTexture(0, mFireTexture);
		fire->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
		//fire->setMaterialType( EMT_TRANSPARENT_ALPHA_CHANNEL );

		mFireEmitters.push_back( fire );
	}
Example #3
0
void QSGBasicInternalImageNode::setTexture(QSGTexture *texture)
{
    Q_ASSERT(texture);

    setMaterialTexture(texture);
    updateMaterialBlending();

    markDirty(DirtyMaterial);

    // Because the texture can be a different part of the atlas, we need to update it...
    m_dirtyGeometry = true;
}
	void CMazeGameEngine::addFinishPoint()
	{
		auto prizeLocation = _worldModel.getFinishPoint();
		auto prizeSceneNode = _sceneManager->addBillboardSceneNode(_mazeRootSceneNode, irr::core::dimension2df(0.5f, 0.5f),
			irr::core::vector3df(static_cast<float>(prizeLocation.first) - 0.5f, 0.75f, static_cast<float>(prizeLocation.second) - 0.5f));
		prizeSceneNode->setMaterialFlag(irr::video::EMF_LIGHTING, false);
		prizeSceneNode->setMaterialType(irr::video::EMT_TRANSPARENT_ADD_COLOR);
		prizeSceneNode->setMaterialTexture(0, _videoDriver->getTexture("../media/particle.bmp"));
		_sceneManager->addLightSceneNode(prizeSceneNode, irr::core::vector3df(), irr::video::SColorf(1.0f, 0.0f, 0.5f), 1.0f);
		auto animator = _sceneManager->createFlyCircleAnimator(
			irr::core::vector3df(static_cast<float>(prizeLocation.first) - 0.5f, 0.75f, static_cast<float>(prizeLocation.second) - 0.5f), 0.2f);
		prizeSceneNode->addAnimator(animator);
		animator->drop();
		auto miniPrizeSceneNode = _sceneManager->addBillboardSceneNode(prizeSceneNode, irr::core::dimension2df(0.3f, 0.3f));
		miniPrizeSceneNode->setMaterialFlag(irr::video::EMF_LIGHTING, false);
		miniPrizeSceneNode->setMaterialType(irr::video::EMT_TRANSPARENT_ADD_COLOR);
		miniPrizeSceneNode->setMaterialTexture(0, _videoDriver->getTexture("../media/portal2.bmp"));
		animator = _sceneManager->createFlyCircleAnimator(irr::core::vector3df(), 0.15f,0.015f);
		miniPrizeSceneNode->addAnimator(animator);
		animator->drop();

	}
bool VoxelSceneNode::Initialize()
{
	printf("Loading Terrain Document\n");

	noiseTree.loadFile("basicTerrain.xml");

	printf("Terrain Loaded\n");

	if(IRR.gpu)
	{
		vsFileName = "./shaders/terrain.vert.glsl";
		psFileName = "./shaders/terrain.frag.glsl";
		
	    ShaderCallback * shaderCallback = new ShaderCallback();

	    terrainMaterial = IRR.gpu->addHighLevelShaderMaterialFromFiles(
	        vsFileName, "vertexMain", irr::video::EVST_VS_3_0,
	        psFileName, "pixelMain", irr::video::EPST_PS_3_0,
	        shaderCallback, irr::video::EMT_SOLID);

	    shaderCallback->drop();
	}

	Material.setFlag(irr::video::EMF_BACK_FACE_CULLING, false);
	Material.setFlag(irr::video::EMF_WIREFRAME, false);
	Material.setFlag(irr::video::EMF_LIGHTING, false);

	Material.MaterialType = (video::E_MATERIAL_TYPE) terrainMaterial;  

    setMaterialTexture(1, IRR.driver->getTexture("./resources/UV_mapper.jpg"));
    setMaterialTexture(2, IRR.driver->getTexture("./resources/UV_mapper.jpg"));

	dirty = true;

	return true;
}
Example #6
0
void Material::setNormalTexture(const char *filename) {
  setMaterialTexture(NORMAL_TEX, filename);
}
Example #7
0
void Material::setEmissiveTexture(const char *filename) {
  setMaterialTexture(EMISSIVE_TEX, filename);
}
Example #8
0
void Material::setSpecularTexture(const char *filename) {
  setMaterialTexture(SPECULAR_TEX, filename);
}
Example #9
0
void Material::setDiffuseTexture(const char *filename) {
  setMaterialTexture(DIFFUSE_TEX, filename);
}
Example #10
0
void MaterialInfo::on_imgTexture2_clicked()
{
    setMaterialTexture(1);
}
Example #11
0
void MaterialInfo::on_imgTexture1_clicked()
{
    setMaterialTexture(0);
}
Example #12
0
int main(int argc, char* argv[]){
    // Check fullscreen
    for (int i=1;i<argc;i++) fullscreen |= !strcmp("-f", argv[i]);

    MyEventReceiver receiver;
    std::shared_ptr<irr::IrrlichtDevice> device(
            createDevice(irr::video::EDT_OPENGL, 
                irr::core::dimension2d<irr::u32>(SCREEN_WIDTH, SCREEN_HEIGHT), 
                16, fullscreen, false, vsync, &receiver),
            [](irr::IrrlichtDevice *p){ p->drop(); }
            );
    receiver.device = device.get();
	auto cursor=device->getCursorControl();
    receiver.cursor = cursor;

    irr::video::IVideoDriver* driver = device->getVideoDriver();
    irr::scene::ISceneManager* smgr = device->getSceneManager();
    irr::gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
    irr::video::IGPUProgrammingServices* gpu = driver->getGPUProgrammingServices();

    HMDDescriptor HMD;
    // Parameters from the Oculus Rift DK1
    HMD.hResolution = 1280;
    HMD.vResolution = 800;
    HMD.hScreenSize = 0.14976;
    HMD.vScreenSize = 0.0936;
    HMD.interpupillaryDistance = 0.064;
    HMD.lensSeparationDistance = 0.064;
    HMD.eyeToScreenDistance = 0.041;
    HMD.distortionK[0] = 1.0;
    HMD.distortionK[1] = 0.22;
    HMD.distortionK[2] = 0.24;
    HMD.distortionK[3] = 0.0;

    HMDStereoRender renderer(device.get(), HMD, 10);

    // load the quake map
    device->getFileSystem()->addFileArchive("../../media/map-20kdm2.pk3");

    irr::scene::IAnimatedMesh* q3levelmesh = smgr->getMesh("20kdm2.bsp");
    irr::scene::IMeshSceneNode* q3node = 0;

    if (q3levelmesh){
        q3node = smgr->addOctreeSceneNode(q3levelmesh->getMesh(0), 0, -1);
	}
	if(!q3node){
		return 1;
	}

    irr::scene::ITriangleSelector* selector = 0;

    if (q3node)
    {
        q3node->setPosition(irr::core::vector3df(-1350,-130,-1400));

        selector = smgr->createOctreeTriangleSelector(
                q3node->getMesh(), q3node, 128);
		if(!selector){
			return 2;
		}
        q3node->setTriangleSelector(selector);
        // We're not done with this selector yet, so don't drop it.
    }

    // Create world
    irr::core::array<irr::SKeyMap> keymaps;
    keymaps.push_back(irr::SKeyMap(irr::EKA_MOVE_FORWARD, irr::KEY_KEY_W));
    keymaps.push_back(irr::SKeyMap(irr::EKA_MOVE_BACKWARD, irr::KEY_KEY_S));
    keymaps.push_back(irr::SKeyMap(irr::EKA_STRAFE_LEFT, irr::KEY_KEY_A));
    keymaps.push_back(irr::SKeyMap(irr::EKA_STRAFE_RIGHT, irr::KEY_KEY_D));
    keymaps.push_back(irr::SKeyMap(irr::EKA_JUMP_UP, irr::KEY_SPACE));
    auto camera= irr::scene::CSceneNodeAnimatorCameraOculusOnFPS::addCameraSceneNodeOclusOnFPS(
            smgr, cursor,
			0, 
                80.0f, .1f, -1, 
                keymaps.pointer(), keymaps.size(), 
                true, .5f, false, true);
    camera->setPosition(irr::core::vector3df(50,50,-60));
    camera->setTarget(irr::core::vector3df(-70,30,-60));
    {
        irr::scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
                selector, camera, 
                irr::core::vector3df(30,50,30),
                irr::core::vector3df(0,-10,0), 
                irr::core::vector3df(0,30,0));
        selector->drop(); // As soon as we're done with the selector, drop it.
        camera->addAnimator(anim);
        anim->drop();  // And likewise, drop the animator when we're done referring to it.
    }

    // load a faerie 
    auto faerie = smgr->getMesh(MEDIA_PATH "faerie.md2");
    auto faerieNode = smgr->addAnimatedMeshSceneNode(faerie);
    faerieNode->setMaterialTexture(0, driver->getTexture(MEDIA_PATH "faerie2.bmp"));
    faerieNode->setMaterialFlag(irr::video::EMF_LIGHTING, false);
    faerieNode->setPosition(irr::core::vector3df(40,190,-1030));
    faerieNode->setRotation(irr::core::vector3df(0,-90,0));
    faerieNode->setMD2Animation(irr::scene::EMAT_SALUTE);

    // load a dwarf
    auto dwarf = smgr->getMesh(MEDIA_PATH "dwarf.x");
    auto dwarfNode = smgr->addAnimatedMeshSceneNode(dwarf);
    dwarfNode->setPosition(irr::core::vector3df(40,-25,20));

    device->getCursorControl()->setVisible(false);

    // Render loop
    irr::core::vector3df rot;
    while(device->run()){
        driver->beginScene(true,true,irr::video::SColor(0,100,100,100));

        renderer.drawAll(smgr);

        // end scene
        driver->endScene();
    }

    return 0;
}