zoukankan      html  css  js  c++  java
  • Brute Force (HeightMap) For Terrain Rendering

    Triangle Num:32768

    FPS < 30

    Environment: 6G-ddr3, i5-480m

    Brute Force not very userful for nowadays game, due to its poor fps. I'm a novice for terrain rendering, maybe the "LOD" could increase the fps. 

    How to do : Here is the principle and below is the code(yes, I use Ogre O>_<O).

    void createScene()
    	{
    		// load terrain map
    		if(myTerrain.LoadHeightMap("height.dat", TERRAIN_SIZE))
    		{
    			myTerrain.SetHeightScale(0.25f);
    		}
    		else
    		{
    			return;
    		}
    
    		//config the light
    		/*Ogre::Light* light = mSceneMgr->createLight("Light1");
    		light->setType(Ogre::Light::LT_DIRECTIONAL);
    		light->setDirection(Ogre::Vector3(1,-1,0));*/
    
    		Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("myMaterialWithNoCulling",
    			Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    		mat->setCullingMode(Ogre::CULL_NONE );
    		mat->setSceneBlending(Ogre::SBT_ADD); 
    
    		Ogre::ManualObject* manual = mSceneMgr->createManualObject("MyTerrain");
    		manual->begin("myMaterialWithNoCulling", RenderOperation::OT_TRIANGLE_LIST);
    		float fColor;
    		for(int iz = 0; iz < TERRAIN_SIZE - 1; ++iz)
    		{
    			for(int ix = 0; ix < TERRAIN_SIZE - 1 ; ++ix)
    			{
    
    				fColor = myTerrain.GetTrueHeightAtPoint(ix, iz);
    				manual->position(ix, myTerrain.GetScaledHeightAtPoint(ix,iz), iz);
    				manual->colour(fColor, fColor, fColor);
    
    				fColor = myTerrain.GetTrueHeightAtPoint(ix + 1, iz);
    				manual->position(ix + 1, myTerrain.GetScaledHeightAtPoint(ix + 1,iz), iz);
    				manual->colour(fColor, fColor, fColor);
    
    				fColor = myTerrain.GetTrueHeightAtPoint(ix, iz + 1);
    				manual->position(ix, myTerrain.GetScaledHeightAtPoint(ix,iz + 1), iz + 1);
    				manual->colour(fColor, fColor, fColor);
    
    				fColor = myTerrain.GetTrueHeightAtPoint(ix, iz + 1);
    				manual->position(ix, myTerrain.GetScaledHeightAtPoint(ix,iz + 1), iz + 1);
    				manual->colour(fColor, fColor, fColor);
    
    				fColor = myTerrain.GetTrueHeightAtPoint(ix + 1, iz);
    				manual->position(ix + 1, myTerrain.GetScaledHeightAtPoint(ix + 1,iz), iz);
    				manual->colour(fColor, fColor, fColor);
    
    				fColor = myTerrain.GetTrueHeightAtPoint(ix + 1, iz + 1);
    				manual->position(ix + 1, myTerrain.GetScaledHeightAtPoint(ix + 1,iz + 1), iz + 1);
    				manual->colour(fColor, fColor, fColor);
    			}
    		}
    
    		manual->end();
    
    		/*manual->convertToMesh("bruteForceTerrain");
    
    		Ogre::Entity* terrainMesh = mSceneMgr->createEntity("bruteForceTerrain");*/
    
    		mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(manual);
    	}
    

      

  • 相关阅读:
    python实现单链表及常用方法->判空|长度|头尾及指定插入|删除|搜索|反转
    k8s v1.21.9集群安装带认证的elk 6.8.18
    docker安装Elasticsearch6.8集群并设置密码
    kubernetes v1.20.9部署keepalived-vip实现高可用pod访问
    rsync远程同步工具的使用-实现跳板机与内网数据传输
    旧金山大学 大卫 算法演示
    IO多路复用之select、poll、epoll详解-转载
    docker容器中使用systemctl命令 set-hostname
    win7 安装ss
    常用相似度语料
  • 原文地址:https://www.cnblogs.com/Baesky/p/Ogre_Brute_Terrain.html
Copyright © 2011-2022 走看看