Example #1
0
    void NeedCheckCubeStatus()
    {
        uint32 ClickerNum = 0;

        // now checking if every clicker has debuff from manticron
        // if not - apply mind exhaustion and delete from clicker's list
        for (CubeMap::iterator i = Cube.begin(); i != Cube.end(); ++i)
        {
            Unit *clicker = Unit::GetUnit(*m_creature, (*i).second);
            if (!clicker || !clicker->HasAura(SPELL_SHADOW_GRASP, EFFECT_INDEX_1))
            {
                DebuffClicker(clicker);
                (*i).second = 0;
            }
            else
                ++ClickerNum;
        }

        // if 5 clickers from other cubes apply shadow cage
        if (ClickerNum >= MAX_CLICK && !m_creature->HasAura(SPELL_SHADOW_CAGE, EFFECT_INDEX_0) && m_creature->HasAura(SPELL_BLASTNOVA, EFFECT_INDEX_0))
        {
            DoScriptText(SAY_BANISH, m_creature);
            m_creature->CastSpell(m_creature, SPELL_SHADOW_CAGE, true);
        }
        else
        {
            if (ClickerNum < MAX_CLICK && m_creature->HasAura(SPELL_SHADOW_CAGE, EFFECT_INDEX_0))
                m_creature->RemoveAurasDueToSpell(SPELL_SHADOW_CAGE);
        }

        if (!ClickerNum)
            m_bNeedCheckCube = false;
    }
Example #2
0
ReferenceTarget *CubeMap::Clone(RemapDir &remap)
{
	CubeMap *pnew = new CubeMap;
	pnew->ReplaceReference(0,pblock->Clone(remap));
	BaseClone(this, pnew, remap);
	return pnew;
}
Example #3
0
            void NeedCheckCubeStatus()
            {
                uint32 ClickerNum = 0;
                // now checking if every clicker has debuff from manticron(it is dispelable atm rev 6110 : S)
                // if not - apply mind exhaustion and delete from clicker's list
                for (CubeMap::iterator i = Cube.begin(); i != Cube.end(); ++i)
                {
                    Unit* clicker = Unit::GetUnit(*me, (*i).second);
                    if (!clicker || !clicker->HasAura(SPELL_SHADOW_GRASP))
                    {
                        DebuffClicker(clicker);
                        (*i).second = 0;
                    }
                    else
                        ++ClickerNum;
                }

                // if 5 clickers from other cubes apply shadow cage
                if (ClickerNum >= CLICKERS_COUNT && !me->HasAura(SPELL_SHADOW_CAGE))
                {
                    Talk(SAY_BANISH);
                    DoCast(me, SPELL_SHADOW_CAGE, true);
                }
                else
                    if (ClickerNum < CLICKERS_COUNT && me->HasAura(SPELL_SHADOW_CAGE))
                        me->RemoveAurasDueToSpell(SPELL_SHADOW_CAGE);

                if (!ClickerNum)
                    NeedCheckCube = false;
            }
Example #4
0
int main(int argc, char *argv[])
{
	QApplication a(argc, argv);
	CubeMap w;
	w.show();
	return a.exec();
}
Example #5
0
Texture<real>* SceneImporter<real>::ReadCubeMap( std::istream& stream, const std::string& name )
{
	std::string imagesPath = ReadString( stream );
	CubeMap<real>* cubeMap = new CubeMap<real>( imagesPath );

	cubeMap->SetName( name );

	return cubeMap;
}
Example #6
0
	void Set(PB2Value& v, ReferenceMaker* owner, ParamID id, int tabIndex, TimeValue t)
	{
		CubeMap *map = (CubeMap*) owner;
		switch(id)
		{
		case pb_cubemapfile: map->SetCubeMapFile(v.s); break;
		default: break;
		}
		GetCOREInterface()->RedrawViews(GetCOREInterface()->GetTime());

	}
Example #7
0
void CubeTexture::serialize(Archive* a) {
	a->member("filename", filename);
	a->optional("linear", linear, true);
	a->optional("mipmap", mipmap, false);

	if(a->isreading()) {
		CubeMap<Vec3f> *m = ImageIO::LoadCubeRGBF(filename);
		if(m->Resolution() == 0) cerr << "cannot load texture " << filename << endl << flush;
		map.Copy(*m);
		delete m;
		_Init();
	}
}
Example #8
0
void TerrainApp::drawSphere()
{
	Vec3f spherePos = mSphere.getCenter();
	Vec3f roomDims	= mRoom.getDims();
	float x = ( spherePos.x + roomDims.x ) / ( roomDims.x * 2.0f );
	float y = ( spherePos.z + roomDims.z ) / ( roomDims.z * 2.0f );;
	Vec2f texCoord = Vec2f( x, y );
	
	mCubeMap.bind();
	mRd.getHeightsTexture().bind( 1 );
	mRd.getNormalsTexture().bind( 2 );
	mSphereShader.bind();
	mSphereShader.uniform( "cubeMap", 0 );
	mSphereShader.uniform( "heightsTex", 1 );
	mSphereShader.uniform( "normalsTex", 2 );
	mSphereShader.uniform( "mvpMatrix", mSpringCam.mMvpMatrix );
	mSphereShader.uniform( "terrainScale", mTerrainScale );
	mSphereShader.uniform( "eyePos", mSpringCam.getEye() );
	mSphereShader.uniform( "fogColor", mFogColor );
	mSphereShader.uniform( "sandColor", mSandColor );
	mSphereShader.uniform( "power", mRoom.getPower() );
	mSphereShader.uniform( "roomDims", mRoom.getDims() );
	mSphereShader.uniform( "texCoord", texCoord );
	mSphereShader.uniform( "sphereRadius", mSphere.getRadius() * 0.45f );
	mSphereShader.uniform( "zoomMulti", mZoomMulti );
	mSphereShader.uniform( "timePer", mRoom.getTimePer() * 1.5f + 0.5f );
	gl::draw( mSphere, 128 );
	mSphereShader.unbind();
}
Example #9
0
void TerrainApp::drawIntoRoomFbo()
{
	mRoomFbo.bindFramebuffer();
	gl::clear( ColorA( 0.0f, 0.0f, 0.0f, 0.0f ), true );
	
	gl::setMatricesWindow( mRoomFbo.getSize(), false );
	gl::setViewport( mRoomFbo.getBounds() );
	gl::disableAlphaBlending();
	gl::enable( GL_TEXTURE_2D );
	glEnable( GL_CULL_FACE );
	glCullFace( GL_BACK );
	Matrix44f m;
	m.setToIdentity();
	m.scale( mRoom.getDims() );

	mCubeMap.bind();
	mRoomShader.bind();
	mRoomShader.uniform( "cubeMap", 0 );
	mRoomShader.uniform( "mvpMatrix", mSpringCam.mMvpMatrix );
	mRoomShader.uniform( "mMatrix", m );
	mRoomShader.uniform( "eyePos", mSpringCam.mEye );
	mRoomShader.uniform( "roomDims", mRoom.getDims() );
	mRoomShader.uniform( "power", mRoom.getPower() );
	mRoomShader.uniform( "lightPower", mRoom.getLightPower() );
	mRoomShader.uniform( "timePer", mRoom.getTimePer() * 1.5f + 0.5f );
	mRoom.draw();
	mRoomShader.unbind();
	
	mRoomFbo.unbindFramebuffer();
	glDisable( GL_CULL_FACE );
}
Example #10
0
	void Set(PB2Value& v, ReferenceMaker* owner, ParamID id, int tabIndex, TimeValue t)
	{
		CubeMap *map = (CubeMap*) owner;
		switch(id)
		{
		case pb_cubemapfile: 
			{
				IAssetManager* assetMgr = IAssetManager::GetInstance();
				if(assetMgr)
				{
					map->SetCubeMapFile(assetMgr->GetAsset(v.s,kBitmapAsset)); break;
				}
			}
		default: break;
		}
		GetCOREInterface()->RedrawViews(GetCOREInterface()->GetTime());

	}
Example #11
0
CubeMap gen_cube_map(const GLsizei size, spherical_function fn,
    GLint internalFormat, GLenum format, GLenum type)
{
  float ** data = new float*[6];
  for (int i = 0; i < 6; i++)
    data[i] = new float[size*size];

  fill_cube_map(data, size, fn);

  CubeMap map;
  map.build();
  map.load_cube(data, size, internalFormat, format, type);

  for (int i = 0; i < 6; i++)
    delete [] data[i];
  delete [] data;

  return map;
}
Example #12
0
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE, LPSTR, int)
{
	//PrimitiveRestart pr = PrimitiveRestart();
	//pr.Start("OGLPractice");
	//Instanced instance = Instanced();
	//instance.Start("Instanced");
	//Gouraud gouraud = Gouraud();
	//gouraud.Start("Gouraud");
	//LoadTexture loadTexture = LoadTexture();
	//loadTexture.Start("LoadTexture");
	CubeMap cubeMap = CubeMap();
	cubeMap.Start("CubeMap");
	
	/*
	WNDCLASSW wc;
	memset(&wc, 0, sizeof(wc));
	wc.style = CS_CLASSDC;
	wc.lpfnWndProc = WindowProc;
	wc.cbWndExtra = sizeof(struct OGL *);
	wc.hInstance = GetModuleHandleW(NULL);
	wc.lpszClassName = L"ORT";
	RegisterClassW(&wc);

	// adjust the window size and show at InitDevice time
	hwnd = CreateWindowW(wc.lpszClassName, L"OGLPractice", WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, 0, 0, hinst, 0);
	if (!hwnd) return false;

	SetWindowLongPtr(hwnd, 0, NULL);

	hdc = GetDC(hwnd);

	initDevice();

	initSomthings2();
	Run(MainLoop);
	*/
	
	return (0);
}
Example #13
0
void ShadedSphereApp::drawSphere()
{
	gl::color( ColorA( 1, 1, 1, 1 ) );
	gl::disable( GL_TEXTURE_2D );
	mCubeMap.bind();
	mSphereShader.bind();
	mSphereShader.uniform( "cubeMap", 0 );
	mSphereShader.uniform( "radius", 70.0f );
	mSphereShader.uniform( "mvpMatrix", mSpringCam.mMvpMatrix );
	mSphereShader.uniform( "eyePos", mSpringCam.getEye() );
	mSphereShader.uniform( "power", mRoom.getPower() );
	mSphereShader.uniform( "roomDim", mRoom.getDims() );
	gl::drawSphere( Vec3f::zero(), 1.0f, 128 );
	mSphereShader.unbind();
}
Example #14
0
int main (int argc, char *argv[])
{
    QApplication app(argc, argv);
    handleCmdParams(argc, argv);
    std::cout << "Loading " << image_path << "... ";
    cv::Mat original_cross = cv::imread(image_path);
    if(!original_cross.data)
    {
        std::cout << "Error" << std::endl;
        return -1;
    }
    //convert to 32 Float for homogeinize formats
    original_cross.convertTo(original_cross, CV_32F, 1.0f/255.0f);

    //resize the image if it's needed
    if(out_face_size != 0)
    {
        //image.resize(image, cv::Size2f(out_face_size*3, out_face_size*4));
        cv::resize(original_cross, original_cross, cv::Size(out_face_size*3, out_face_size*4));

    }
    std::cout << "...Loaded" << std::endl;

    if(show_orig_cross)
    {
        cv::namedWindow("Original Cross", CV_WINDOW_FLAGS);
        cv::imshow("Original Cross", original_cross);
        cv::waitKey();
        cv::destroyWindow("Original Cross");
    }

    ////Filtering
    std::vector<CubeMap> filtered_cubes;
    std::vector<float> pows;
    std::vector<std::vector<cv::Mat> > filtered_face_images;
    std::vector<cv::Mat> filtered_cross_images;

    //Load cubemap
    CubeMap cube;
    cube.loadCubeCross(original_cross);
    if(!mipmaps)
    {
//        //Load cubemap
//        CubeMap cube;
//        cube.loadCubeCross(original_cross);

        int len = (pow_max - pow_min)/pow_step;
        pows = std::vector<float> (len+1);
        for(unsigned int i = 0; i < unsigned(len + 1); ++i)
        {
            pows[i] = pow_min + pow_step*i;
            std::cout << "pows[" << i << "] --> " << pows[i] << std::endl;
        }
        filtered_cubes = CubeMapFilter::cosinePowFilterArrayCube(cube, filter_angle, pows);
        cv::waitKey();
//filtered_cross_images = cubeMapsArrayToCrosses(filtered_cubes);
//cv::namedWindow("Bu", CV_WINDOW_FLAGS);
//cv::imshow("Bu", filtered_cross_images[0]);
//cv::waitKey();

        //filtered_cubes[0].resizeCube(int(4));
        filtered_cubes[0] = CubeMapFilter::edgePullFixup(filtered_cubes[0], fixup_band);
        //filtered_cubes.push_back(CubeMapFilter::cosinePowFilterCube(cube, filter_angle, pows[0]));
    }
    else
    {
        //load cube and get cube size and steps
//        CubeMap cube;
//        cube.loadCubeCross(original_cross);
        int face_size = cube.getFaceSize();
        unsigned int steps = std::log2(face_size)+1;
        std::cout << "Steps: " << steps << std::endl;

        //initialize pow
        float step = (pow_max - pow_min)/float(steps-1);
        std::cout << "Step: " << step << std::endl;
        pows = std::vector<float> (steps);
        for(unsigned int i = 0; i < steps; ++i)
        {
            pows[i] = pow_min + step*float(steps - i - 1);
            std::cout << "pows[" << i << "] --> " << pows[i] << std::endl;
        }
//exit(0);
        filtered_cubes = std::vector<CubeMap> (steps);
        cv::Size cross_size = original_cross.size();
        std::cout << "Original size: (" << cross_size.height << ", " << cross_size.width << ")" << std::endl;
        cv::Mat aux_cross;
        std::cout << "aux_cross" << std::endl;
        for(unsigned int i = 0; i < steps; ++i)
        {
//            CubeMap cube_aux;
//            std::cout << "compute step" << std::endl;
            unsigned int step = std::pow(2,i);
//            std::cout << "Compute new size" << std::endl;
            cv::Size new_size(int(cross_size.width/step), int(cross_size.height/step));
            std::cout << "New size: (" << new_size.height << ", " << new_size.width << ")" << std::endl;
//            std::cout << "Resize" << std::endl;
            #ifdef RESIZE_BEFORE
                cv::resize(original_cross, aux_cross, new_size);
            #endif
//            std::cout << "Load aux cross" << std::endl;
            CubeMap aux_cube;
            #ifdef RESIZE_BEFORE
                aux_cube.loadCubeCross(aux_cross);
            #else
                aux_cube.loadCubeCross(original_cross);
            #endif
//            aux_cube.loadCubeCross(original_cross);
//            std::cout << "Filter!!" << std::endl;
            filtered_cubes[i] = CubeMapFilter::cosinePowFilterCube(aux_cube, filter_angle, pows[i]);
            std::cout << "---Face Size: " << int((cross_size.width/step)/3) << std::endl;
            #ifndef RESIZE_BEFORE
                filtered_cubes[i].resizeCube(int((cross_size.width/step)/3));
            #endif
            std::cout << "---Cube Resized." << std::endl;
            std::cout << "Fixup Band!!!!!" << std::endl;
            filtered_cubes[i] = CubeMapFilter::edgePullFixup(filtered_cubes[i], fixup_band);
        }
    }
std::cout << "Cube Filtered!" << std::endl;
    if(show_filt_faces || export_faces) filtered_face_images = cubeMapsArrayToImages(filtered_cubes);
std::cout << "Cube Images!" << std::endl;
    if(show_filt_cross || export_cross) filtered_cross_images = cubeMapsArrayToCrosses(filtered_cubes);
std::cout << "Cube Crosses!" << std::endl;

////Filtering
    if(show_filt_faces)
    {
        for(unsigned int i = 0; i < filtered_face_images.size(); ++i)
        {
            std::string window_name = "Faces from level "+std::to_string(i);
            cv::namedWindow(window_name, CV_WINDOW_FLAGS);
            for(unsigned int j = 0; j < filtered_face_images[0].size(); ++j)
            {
                cv::imshow(window_name, filtered_face_images[i][j]);
                cv::waitKey();
            }
            cv::destroyWindow(window_name);
        }
    }

    if(show_filt_cross)
    {
        for(unsigned int i = 0; i < filtered_cross_images.size(); ++i)
        {
            std::string window_name = "Cross from level "+std::to_string(i);
            cv::namedWindow(window_name, CV_WINDOW_FLAGS);
            cv::imshow(window_name, filtered_cross_images[i]);
            cv::waitKey();
            cv::destroyWindow(window_name);
        }
    }

    if(export_cross)
    {
        cv::Mat export_cross;
        QString dir = QFileDialog::getExistingDirectory(0, QObject::tr("Save Cube Cross"), "./", QFileDialog::ShowDirsOnly);
        if(!dir.isEmpty())
        {
            std::cout << "Saving crosses into: " << dir.toStdString() << std::endl;
            //QString path = QFileDialog::getSaveFileName(0, QObject::tr("Save cube cross"), "./", QObject::tr("PNG Files (*.png);;All files (*)"));
            for(unsigned int i = 0; i < filtered_cross_images.size(); ++i)
            {
                ///FIXME
                //convert format to be RGB this must be modified if the image was hdr
                filtered_cross_images[i].convertTo(export_cross, CV_8U, 255.0f);
                try {
                    cv::imwrite(dir.toStdString()+"/filtered_cross_level_"+std::to_string(i)+".png", export_cross);
                }
                catch (std::runtime_error& ex) {
                    std::cerr << "Exception exporting cross image: %s\n" <<  ex.what();
                    return 1;
                }
            }
        }
        else std::cout << "Not selected Directory" << std::endl;
    }

    if(export_faces)
    {
        cv::Mat export_face;
        QString dir = QFileDialog::getExistingDirectory(0, QObject::tr("Save Cube Faces"), "./", QFileDialog::ShowDirsOnly);
        std::cout << "Saving faces into: " << dir.toStdString() << std::endl;
        for(unsigned int i = 0; i < filtered_face_images.size(); ++i)
        {
            std::string aux = dir.toStdString()+"/faces_level"+std::to_string(i);
//            std::cout << "Saving faces into: " << aux << std::endl;
            QDir faces_dir(QString::fromStdString(aux));
            if (!faces_dir.exists()) faces_dir.mkpath(".");

            for(unsigned int j = 0; j < filtered_face_images[0].size(); ++j)
            {
//                std::cout << "Exporting: " << faces_dir.absolutePath().toStdString()+"/i_c0"+std::to_string(j)+".png" << std::endl;
                ///FIXME
                //convert format to be RGB this must be modified if the image was hdr
                filtered_face_images[i][j].convertTo(export_face, CV_8U, 255.0f);
//                if(j == 5) cv::flip(export_face, export_face, 0);
                cv::imwrite(faces_dir.absolutePath().toStdString()+"/i_c0"+std::to_string(j)+".png", export_face);

            }
        }
    }

////Show import and export
//    std::vector<cv::Mat> images = cube.exportIntoImages();
//    for(unsigned int i = 0; i < images.size(); ++i)
//    {
//        cv::imshow("Image win", images[i]);
//        cv::waitKey();
//    }

//    cv::Mat cross = cube.exportCubeCross();
//    cv::imshow("Image win", cross);
//    cv::waitKey();

//////Test accessors
//    for(int face = 0; face < 6; ++face)
//    {
//        std::cout << "FACE " << face << std::endl;
//        for(int i = 0; i < 4; ++i)
//        {
//            for(int j = 0; j < 4; ++j)
//            {
//                cv::Vec3f face_coords = cv::Vec3f(face, i, j);
//                cv::Vec3f aux_v = cube.getCubeCoords(face_coords);
//                std::cout << "Face Coords: " << face_coords << ", Cube coords: " << aux_v << std::endl;
//            }
//        }
//    }

//////Cross load and export
//        std::vector<cv::Mat> images = cube.exportIntoImages();
//        for(unsigned int i = 0; i < images.size(); ++i)
//        {
//            cv::imshow("Image win", images[i]);
//            cv::waitKey();
//        }

//        cv::Mat cross = cube.exportCubeCross();
//        cv::imshow("Image win", cross);
//        cv::waitKey();

////Black square
    //    int face_size = cube.getFaceSize();
    //    for(int i = 0; i < 6; ++i)
    //    {
    //        for(int j = 0; j < 50; ++j )
    //        {
    //            for(int k = 0; k < 20; ++k)
    //            {
    //                cube(cv::Vec3f(i, j, k)) = cv::Vec3f(0,0,0);
    //            }
    //        }
    //    }
}
Example #15
0
int main()
{
	/* Create GL Window */
	if (!initWindow())
		return -1;

	/* Initialise vertex buffers for cube */
	CubeMap cubeMap;
	cubeMap.loadCubeMap("../textures/cubemaps/Yokohama/");


	/* Load shaders needed */

	Entity* box = new Entity(glm::vec3(0));
	box->setShader(ShaderManager::loadShader("simpleReflect"));
	box->loadFromFile("../models/Cube.3ds");
	rigidBodies.push_back(new RigidBody(box));

	box = new Entity(glm::vec3(0,2,0));
	box->setShader(ShaderManager::loadShader("simpleReflect"));
	box->loadFromFile("../models/Cube.3ds");
	rigidBodies.push_back(new RigidBody(box));

	std::cout << "some amazing feature has been added";


	glEnable(GL_DEPTH_TEST);
	while (!glfwWindowShouldClose(window))
	{
		/* Rendering Code */

		// Calculate deltatime of current frame
       GLfloat currentFrame = glfwGetTime();
        deltaTime = currentFrame - lastFrame;
        lastFrame = currentFrame;

		
        // Check if any events have been activiated (key pressed, mouse moved etc.) and call corresponding response functions
        glfwPollEvents();
       do_movement();
		//do_rotation();

		glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);



		glm::mat4 viewMatrix = glm::lookAt (
		cameraPos,  //where you are
		cameraPos + cameraFront, // what you are looking at, however we move, the camera keeps looking at the target direction
		cameraUp 
		);

	

		glm::mat4 projectionMatrix = glm::perspective(
		fov,
		(GLfloat)WIDTH/(GLfloat)HEIGHT,
		0.1f,
		1000.0f
		);


		for(int i =0; i < rigidBodies.size(); i++)
		{
			//for(int j = 0; j < rigidBodies.size(); j++)
			//{
			//	if (i ==j)
			//		continue;

			//	//if(rigidBodies[i]->aabb->collies(rigidBodies[j]->aabb))
			//		//do something with shaders to indicate collision in broadphase
			//}


			rigidBodies[i]->Update(deltaTime);
		
			rigidBodies[i]->entity->getShader()->setUniformMatrix4fv("projectionMat", projectionMatrix);
			//cubeMap.getShader()->setUniformMatrix4fv("projectionMat", projectionMatrix);
			rigidBodies[i]->entity->getShader()->setUniformMatrix4fv("viewMat", viewMatrix);
			//cubeMap.getShader()->setUniformMatrix4fv("viewMat", viewMatrix);
			//dragonModel.getShader()->setUniformMatrix4fv("viewMat", view_mat);
			rigidBodies[i]->entity->getShader()->setUniformVector4fv("camPos", glm::vec4(cameraPos, 1.0f));
			//glm:: vec3 cam_pos= glm::vec3 (cam_pos);
			//dragonModel.getShader()->setUniformVector4fv("camPos", glm::vec4(cam_pos, 1.0f));

			//rigidBodies[i]->entity->getShader()->setUniformVector4fv("modelMat", rigidBodies[i]->entity->getModelMat());
		
			rigidBodies[i]->entity->draw();

			//rigidBodies[i]->ApplyGravity();
		}
		
		glDisable(GL_TEXTURE_GEN_S);
		glDisable(GL_TEXTURE_GEN_T);
		glDisable(GL_TEXTURE_GEN_R);

		
		//cubeMap.drawSkyBox();

		glEnable(GL_TEXTURE_GEN_S);
		glEnable(GL_TEXTURE_GEN_T);
		glEnable(GL_TEXTURE_GEN_R);

		glfwSwapBuffers(window);
		glfwPollEvents();

		

}
	glfwTerminate();
	return 0;

}