예제 #1
0
void onWindowRedraw()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_DEPTH_TEST);
    glUseProgram(Prog);

    View       = glm::lookAt(
        camera,
        camera + direction,
        glm::vec3(0,1,0)
    );

    MVP        = projectionMatrix * View * Model;
    glUniformMatrix4fv(mvpUniform, 1, GL_FALSE, glm::value_ptr(MVP));

    if ( oldcamera != camera ) 
    {
        land.Reset();
        land.updateDistance();
        land.splitBasedOnDistance();
        oldcamera = camera;
    }

    land.renderBasedOnDistance();

    SDL_GL_SwapBuffers();
}
예제 #2
0
void Test::PreparePath()
{
	SettingsManager *settings = SettingsManager::Instance();

	int32 partX = settings->GetLandscapePartitioning().x;
	int32 partY = settings->GetLandscapePartitioning().y;
	
    Landscape *land = GetLandscape();
	AABBox3 boundingBox = land->GetBoundingBox();
	Vector3 min = boundingBox.min;
	Vector3 max = boundingBox.max;
	
	float32 landWidth = max.x - min.x;
	float32 landLength = max.y - min.y;
	
	Vector2 rectSize(landWidth / partX, landLength / partY);
	
	int32 x = 0;
	int32 xDir = 1;
	for(int32 y = 0; y < partY; ++y)
    {
		Rect curRect;
		for(int32 i = 0; i < partX; ++i, x += xDir)
        {
			Vector2 v;
			v.Set(min.x + x * rectSize.x, min.y + y * rectSize.y);
			curRect.SetPosition(v);
			curRect.SetSize(rectSize);
            rectSequence.push_back(curRect);
		}
		x -= xDir;
		xDir = -xDir;
	}
}
예제 #3
0
Landscape* DynamicModelNoColor::_imageToLandscape(Image* img)
{
	Landscape* land = new Landscape();	

	float begin = 0;
	bool color = img->at(0);
	uint i = 0;
	for (i = 0; i < img->size(); i++)
	{
		if ((bool)img->at(i) != color)
		{
			if (color)
			{
				land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI,
					(i - begin) / 360. * PI));
			}
			begin = i;
			color = img->at(i);
		}
	}
	if (color)
	{
				land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI,
					(i - begin) / 360. * PI));
	}

	return land;
}
예제 #4
0
void CommandCopyPasteHeightmap::UpdateLandscapeTilemap(DAVA::Image *image)
{
	Texture* texture = Texture::CreateFromData(image->GetPixelFormat(), image->GetData(), image->GetWidth(), image->GetHeight(), false);
	texture->relativePathname = tilemapSavedPathname;
	texture->GenerateMipmaps();
	texture->SetWrapMode(Texture::WRAP_REPEAT, Texture::WRAP_REPEAT);

	LandscapeEditorBase* editor = GetActiveEditor();
	if (editor)
	{
		editor->UpdateLandscapeTilemap(texture);
	}
	else
	{
		SceneEditorScreenMain *screen = dynamic_cast<SceneEditorScreenMain *>(UIScreenManager::Instance()->GetScreen());
		EditorScene* scene = screen->FindCurrentBody()->bodyControl->GetScene();
		Landscape* landscape = scene->GetLandscape(scene);

		landscape->SetTexture(Landscape::TEXTURE_TILE_MASK, texture);
		landscape->UpdateFullTiledTexture();
		ImageLoader::Save(image, tilemapSavedPathname);
	}

	SafeRelease(texture);
}
예제 #5
0
파일: ccmodel.cpp 프로젝트: ettadar/Animat
Landscape* CCmodel::_imageToLandscape(Image* img)
{
	Landscape* land = new Landscape();
	int lastPixelColor = img->at(0);
	int lastObjBegin = 0;

	uint i = 0;
	for (; i < img->size(); ++i)
	{
		if (img->at(i) == lastPixelColor)
			continue;

		if (img->at(i) != BLACK && lastPixelColor != BLACK)
		{
			lastPixelColor = img->at(i);
			continue;
		}


		LandscapeElem* object = new LandscapeElem(lastPixelColor == BLACK,
			((((lastObjBegin + i - 1) / 2.) - VIEW_ANGLE / 2)  / 360.) * 2 * PI,
			((float)(i - lastObjBegin) / 360.) * 2 * PI);
		land->push_back(object);
		lastObjBegin = i;
		lastPixelColor = img->at(i);
	}

	LandscapeElem* object = new LandscapeElem(lastPixelColor == BLACK,
		((((lastObjBegin + i - 1) / 2.) - VIEW_ANGLE / 2)  / 360.) * 2 * PI,
		((float)(i - lastObjBegin) / 360.) * 2 * PI);
	land->push_back(object);
	return land;
}
bool LandscapesController::ShowEditorLandscape(EditorLandscape *displayingLandscape)
{
	Landscape *landscape = EditorScene::GetLandscape(scene);
	if (!landscape)
    {
        Logger::Error("[LandscapesController::ShowEditorLandscape] Can be only one landscape");
        return false;
    }
	
    displayingLandscape->SetNestedLandscape(landscape);
    
    if(!landscapeRenderer)
    {
        renderedHeightmap = new EditorHeightmap(landscape->GetHeightmap());
        landscapeRenderer = new LandscapeRenderer(renderedHeightmap, landscape->GetBoundingBox());

        displayingLandscape->SetHeightmap(renderedHeightmap);
    }
    displayingLandscape->SetRenderer(landscapeRenderer);
	
	//TODO: remove SetWorldTransformPtr
	displayingLandscape->SetWorldTransformPtr(landscape->GetWorldTransformPtr());
	Entity* lanscapeNode = EditorScene::GetLandscapeNode(scene);
	
	lanscapeNode->RemoveComponent(Component::RENDER_COMPONENT);
	RenderComponent* component = new RenderComponent(displayingLandscape);
	lanscapeNode->AddComponent(component);

    currentLandscape = displayingLandscape;
    return true;
}
예제 #7
0
파일: main.cpp 프로젝트: mikedm195/Graficas
void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    //Dibuja el paisaje
    Landscape * landscape = new Landscape;
    landscape->draw();
    glFlush();
}
void EditorBodyControl::RecreteFullTilingTexture()
{
    Landscape *landscape = FindLandscape(scene);
    if (landscape)
    {
        landscape->UpdateFullTiledTexture();
    }
}
예제 #9
0
void JoinedLandscape::SubFromDistribution( string & itsConfig )
{
	unsigned short int strLength = itsConfig.length() / 2;
	d[itsConfig].SubFromDist();
	string first = itsConfig;
	first.replace ( strLength, strLength*2, strLength, '0' );
	string second = itsConfig;
	second.replace ( 0, strLength, strLength, '0' );
	LOne.SubFromDistribution(first);
	LTwo.SubFromDistribution(second);
}
예제 #10
0
Vector3 Test::GetRealPoint(const Vector2& point)
{
    Vector3 realPoint(point);

	Landscape *land = GetLandscape();
    land->PlacePoint(realPoint, realPoint);

    realPoint.z += SettingsManager::Instance()->GetCameraElevation();
    
    return realPoint;
}
예제 #11
0
bool Entity::Move( string destination, Landscape & LJoined )
{
	if ( destination == "EMPTY" ) { return 0; }
	string previous = itsPayoff.GetConfig();
	LJoined.SubFromDistribution( previous );
	// cout << "Move from " << itsPayoff.GetConfig() << ":" << itsPayoff.GetFitness() << " to ";
	itsPayoff.SetConfig( destination );
	itsPayoff.SetFitness( LJoined.d[destination].GetFitness() ) ;
	// cout << "to " << itsPayoff.GetConfig() << ":" << itsPayoff.GetFitness() << endl;
	LJoined.AddToDistribution( destination );
	movesTaken++;
	return 1;
}
void LandscapeEditorHeightmap::UpdateCursor()
{
	if(currentTool)
	{
		float32 scaleSize = (float32)((int32)currentTool->size);
		Vector2 pos = landscapePoint - Vector2(scaleSize, scaleSize)/2.f;

        Landscape *landscape = landscapesController->GetCurrentLandscape();
		landscape->SetCursorTexture(cursorTexture);
		landscape->SetBigTextureSize((float32)landscapeSize);
		landscape->SetCursorPosition(pos);
		landscape->SetCursorScale(scaleSize);
	}
}
예제 #13
0
void FoliageSystem::SyncFoliageWithLandscape()
{
    if(landscapeEntity && foliageEntity)
    {
        Landscape* landscapeRO = GetLandscape(landscapeEntity);
        VegetationRenderObject* vegetationRO = GetVegetation(foliageEntity);
        
        vegetationRO->SetHeightmap(landscapeRO->GetHeightmap());
        vegetationRO->SetHeightmapPath(landscapeRO->GetHeightmapPathname());
        vegetationRO->SetWorldSize(Vector3(landscapeRO->GetLandscapeSize(),
                                           landscapeRO->GetLandscapeSize(),
                                           landscapeRO->GetLandscapeHeight()));
    }
}
예제 #14
0
void Test::PrepareFpsStat()
{
	testData.Clear();
	fpsStatItem.rect = rectSequence[testData.GetItemCount()];

    Landscape *land = GetLandscape();
	AABBox3 boundingBox = land->GetBoundingBox();
	
	Vector2 landPos(boundingBox.min.x, boundingBox.min.y);
	Vector2 landSize((boundingBox.max - boundingBox.min).x,
					 (boundingBox.max - boundingBox.min).x);

	testData.SetLandscapeRect(Rect(landPos, landSize));
}
예제 #15
0
void SceneSaver::SaveScene(Scene *scene, const FilePath &fileName, Set<String> &errorLog)
{
    DVASSERT(0 == texturesForSave.size())
    
    String relativeFilename = fileName.GetRelativePathname(sceneUtils.dataSourceFolder);
    sceneUtils.workingFolder = fileName.GetDirectory().GetRelativePathname(sceneUtils.dataSourceFolder);
    
    FileSystem::Instance()->CreateDirectory(sceneUtils.dataFolder + sceneUtils.workingFolder, true);

    scene->Update(0.1f);

    FilePath oldPath = SceneValidator::Instance()->SetPathForChecking(sceneUtils.dataSourceFolder);
    SceneValidator::Instance()->ValidateScene(scene, errorLog);

    texturesForSave.clear();
    SceneDataManager::EnumerateTextures(scene, texturesForSave);

    CopyTextures(scene, errorLog);
	ReleaseTextures();

	Landscape *landscape = EditorScene::GetLandscape(scene);
    if (landscape)
    {
        sceneUtils.CopyFile(landscape->GetHeightmapPathname(), errorLog);
    }

	CopyReferencedObject(scene, errorLog);
	CopyEffects(scene, errorLog);
	CopyCustomColorTexture(scene, fileName.GetDirectory(), errorLog);

    //save scene to new place
    FilePath tempSceneName = sceneUtils.dataSourceFolder + relativeFilename;
    tempSceneName.ReplaceExtension(".saved.sc2");
    
    SceneFileV2 * outFile = new SceneFileV2();
    outFile->EnableSaveForGame(true);
    outFile->EnableDebugLog(false);
    
    outFile->SaveScene(tempSceneName, scene);
    SafeRelease(outFile);

    bool moved = FileSystem::Instance()->MoveFile(tempSceneName, sceneUtils.dataFolder + relativeFilename, true);
	if(!moved)
	{
		errorLog.insert(Format("Can't move file %s", fileName.GetAbsolutePathname().c_str()));
	}
    
    SceneValidator::Instance()->SetPathForChecking(oldPath);
}
예제 #16
0
void HeightmapModificationCommand::UpdateLandscapeHeightmap(String filename)
{
	SceneData *activeScene = SceneDataManager::Instance()->SceneGetActive();
	LandscapesController* landscapesController = activeScene->GetLandscapesController();
	
	Landscape* landscapeNode = landscapesController->GetCurrentLandscape();
	
	Heightmap* heightmap = new Heightmap();
	heightmap->Load(filename);
	
	landscapeNode->SetHeightmap(heightmap);
	heightmap->Save(landscapeNode->GetHeightmapPathname());

	SafeRelease(heightmap);
}
예제 #17
0
void JoinedLandscape::genDVector()
{
	int counter;
	int T = pow( 2, itsN );
	double average = 0;
	string configuration;
	string configuration2;
	for ( counter = 0 ; counter < T ; counter++ )
	{
		genConfig( counter, configuration, itsN);
		configuration2 = flipConfigString ( configuration );
		average = (LOne.GetFitness( configuration ) + LTwo.GetFitness( configuration2 ) ) / (double) 2;
		d.insert( pair<string,Payoff> ( configuration, Payoff(configuration, average) ) ); 
	}
}
예제 #18
0
void Test::LoadResources()
{
	time = 0.f;
	isFinished = false;
	skipFrames = 100;

	Scene *scene = new Scene();
	scene->AddNode(scene->GetRootNode(fullName));
	DVASSERT_MSG(scene, "Could not load the scene");

	Camera* cam = new Camera();
	scene->AddCamera(cam);

	Core* core = DAVA::Core::Instance();
	float32 aspect = core->GetVirtualScreenHeight() / core->GetVirtualScreenWidth();

	cam->Setup(70.f, aspect, 1.f, 5000.f);
	cam->SetLeft(Vector3(1, 0, 0));
	cam->SetUp(Vector3(0, 0, 1));
    
    scene->SetCurrentCamera(cam);
	SafeRelease(cam);

	UI3DView *sceneView = new UI3DView(Rect(0, 0, GetSize().x, GetSize().y));
	sceneView->SetScene(scene);
	AddControl(sceneView);
	SafeRelease(sceneView);

	Landscape* landscape = GetLandscape();
	DVASSERT_MSG(scene, "There is no landscape in a scene");
	landscape->SetTiledShaderMode(Landscape::TILED_MODE_TEXTURE);

	uint32 textureMemory = TextureHelper::GetSceneTextureMemory(scene, GetFilePath());
	testData.SetTextureMemorySize(textureMemory);

	File* file = File::Create(fullName, File::OPEN | File::READ);
	DVASSERT_MSG(file, "Could not open file scene file");
	testData.SetSceneFileSize(file->GetSize());
	SafeRelease(file);

	PreparePath();
    PrepareFpsStat();
    PrepareCameraAnimation();
    ZeroCurFpsStat();
    MoveToNextPoint();

    SafeRelease(scene);
}
예제 #19
0
void BeastAction::Finish()
{
    PackLightmaps();

    Landscape *land = FindLandscape(workingScene);
    if(land)
    {
        FilePath textureName = land->GetTextureName(DAVA::Landscape::TEXTURE_COLOR);
        textureName.ReplaceFilename("temp_beast.png");

        FileSystem::Instance()->DeleteFile(textureName);
    }

    FileSystem::Instance()->DeleteDirectory(GetLightmapDirectoryPath());
    FileSystem::Instance()->DeleteDirectory(FileSystem::Instance()->GetCurrentWorkingDirectory() + "temp_beast/");
}
예제 #20
0
파일: ccmodel.cpp 프로젝트: ettadar/Animat
void CCmodel::computeMove(Image* img)
{
	Landscape* landView = _imageToLandscape(img);

	float x = 0;
	float y = 0;
	
	int iBegin = _goalViewLand->at(0)->gap ? 0 : 1;
	int jBegin = landView->at(0)->gap ? 0 : 1;

	_gapOrLandmarkComputeMove(x, y, iBegin, jBegin, landView);
	_gapOrLandmarkComputeMove(x, y, abs(iBegin - 1), abs(jBegin - 1), landView);

	_x = x / (float)(_goalViewLand->size() * 2);
	_y = y / (float)(_goalViewLand->size() * 2);

	delete landView;
}
예제 #21
0
void GameScene::setMap(const Landscape& lc)
{
    for (int yi = 0; yi < lc.height; yi++)
    {
        for (int xi = 0; xi < lc.width; xi++)
        {
            this->addTile(QPoint(xi, yi), lc.getTile(xi, yi));
        }
    }
}
예제 #22
0
void JoinedLandscape::genJoinedKeys( Landscape &LJoin )
{
	Keymap tempKeymap(LJoin.GetN(), itsK_two, 0); // create a keymap to add to the other
	unsigned int T_one = pow (2, itsK + 1);
	unsigned int T_two = pow (2, itsK_two );
	vector < vector < string > > tempKeys ( LJoin.GetN() , vector <string>() );
	unsigned int ii, jj, ll;
	for( ii = 0 ; ii < LJoin.GetN() ; ii++ )
	{
		for( jj = 0 ; jj < T_one ; jj++ )
		{
			for( ll = 0 ; ll < T_two ; ll++ )
			{
			// Generate 2^k_2 partial keys and add them to the end of the tempKeymap
			tempKeys[ii].push_back( LJoin.getKey( ii, jj) + tempKeymap.Get( ii, ll) );
			}
		}
   	}
	LJoin.ReplaceKeys(tempKeys);
}
예제 #23
0
Matrix4 EditorBodyControl::GetLandscapeOffset(const Matrix4& transform)
{
	Matrix4 resTransform;
	resTransform.Identity();

	Landscape* landscape = FindLandscape(scene);
	if(!landscape) return resTransform;

	Vector3 p = Vector3(0, 0, 0) * transform;

	Vector3 result;
	bool res = landscape->PlacePoint(p, result);
	if (res)
	{
		Vector3 offset = result - p;
		resTransform.CreateTranslation(offset);
	}

	return resTransform;
}
예제 #24
0
testPassagesFactory::testPassagesFactory(void)
{			
		Landscape ls = Landscape();
		Map mapToTest = ls.getDungeon(0).getMap();

		RoomsFactory rF = RoomsFactory();
		rF.create(ls,0);

		Room startRoom = ls.getRoom(0,0);
		//Room endRoom = ls.getRoom(0,1);

		std::cout << "Nearest wall to 0,25(L) on room 0 is " << (startRoom.decideNearestWall(0,25)).c_str() << "\n";
		std::cout << "Nearest wall to 50,25(R) on room 0 is " << (startRoom.decideNearestWall(50,25)).c_str() << "\n";
		std::cout << "Nearest wall to 25,0(T) on room 0 is " << (startRoom.decideNearestWall(25,0)).c_str() << "\n";
		std::cout << "Nearest wall to 25,50(B) on room 0 is " << (startRoom.decideNearestWall(25,50)).c_str() << "\n";


		ls.getDungeon(0).getMap().printMap();
		std::cout << "Finished testPassagesFactory test " << std::endl;

}
예제 #25
0
Void CharEntity::StartPathTracking( const Vertex3 & vTarget )
{
    Assert( !m_bPathTrackingMode );

    // Create path-finding
    WorldPathFinder * pPathFinder = WorldFn->GetPathFinder();
    Landscape * pLandscape = (Landscape*)( WorldFn->GetWorldRoot()->GetChild(TEXT("LandscapeArea")) );

    Vertex3 vPosition = GetPosition();
    WorldOutdoorRegion * pStartRegion = pLandscape->GetRegion( vPosition );
    WorldPathTriangleNode * pStart = pStartRegion->GetGridWaypoint( vPosition );

    WorldOutdoorRegion * pTargetRegion = pLandscape->GetRegion( vTarget );
    WorldPathTriangleNode * pTarget = pTargetRegion->GetGridWaypoint( vTarget );

    m_idPathTracking = pPathFinder->StartSearch( pStart, pTarget, PATHFIND_TYPE_SIMPLE ); // PATHFIND_TYPE_HIERARCHIC_2 );

    // Extract path
    const Array<WorldPathWaypoint*> * pPath = NULL;
    pPathFinder->GetPath( m_idPathTracking, &pPath );
    Assert( pPath != NULL );

    // Test for empty / trivial path
    if ( pPath->Count() < 1 ) {
        // Destroy path-finding
        pPathFinder->EndSearch( m_idPathTracking );
        m_idPathTracking = INVALID_OFFSET;

        // Done
        return;
    }

    // Create path-tracking
    m_iLastPassedWaypoint = 0;
    m_vPathTarget = vTarget;
    _PathTracking_Start( *pPath );

    // Done
    m_bPathTrackingMode = true;
}
예제 #26
0
//--------------------------------------------------------------
// rebuild chunks of terrain
void buildThreadProc(
  mgOSThread* thread,
  void* threadArg1,
  void* threadArg2)
{
  Landscape* landscape = (Landscape*) threadArg1;

  while (!landscape->m_shutdown)
  {
    landscape->m_buildEvent->wait(100.0);  // check shutdown every 100 ms

    // while there's work
    while (!landscape->m_shutdown)
    {
      landscape->m_buildLock->lock();
      BOOL moreWork = landscape->rebuildTerrain();
      landscape->m_buildLock->unlock();

      if (!moreWork)
        break;
    }
  }
}
예제 #27
0
void FoliageSystem::AddEntity(Entity * entity)
{
    Landscape* landscapeRO = GetLandscape(entity);
    if(landscapeRO &&
        entity != landscapeEntity)
    {
        SafeRelease(landscapeEntity);
        landscapeEntity = SafeRetain(entity);
            landscapeRO->SetFoliageSystem(this);
        
        SyncFoliageWithLandscape();
    }
    
    VegetationRenderObject* vegetationRO = GetVegetation(entity);
    if(vegetationRO &&
       entity != foliageEntity)
    {
        SafeRelease(foliageEntity);
        foliageEntity = SafeRetain(entity);
        
        SyncFoliageWithLandscape();
    }
}
예제 #28
0
Landscape* DynamicModelColor::_imageToLandscape(Image* img)
{
	Landscape* land = new Landscape();	

	float begin = 0;
	int currColor = img->at(0);
	uint i = 0;
	for (i = 0; i < img->size(); i++)
	{
		if (img->at(i) != currColor)
		{
			if (currColor == RED)
			{
				land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI,
					(i - begin) / 360. * PI, HUERED, SATRED, VALUERED));
			}
			else if (currColor == BLUE)
			{
				land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI,
					(i - begin) / 360. * PI, HUEBLUE, SATBLUE, VALUEBLUE));
			}
			else if (currColor == GREEN)
			{
				land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI,
					(i - begin) / 360. * PI, HUEGREEN, SATGREEN, VALUEGREEN));
			}
			begin = i;
			currColor = img->at(i);
		}
	}
	if (currColor == RED)
	{
		land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI,
			(i - begin) / 360. * PI, HUERED, SATRED, VALUERED));
	}
	else if (currColor == BLUE)
	{
		land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI,
			(i - begin) / 360. * PI, HUEBLUE, SATBLUE, VALUEBLUE));
	}
	else if (currColor == GREEN)
	{
		land->push_back(new LandscapeElem(false, (i + begin - 1 - VIEW_ANGLE) / 2. / 360. * PI,
			(i - begin) / 360. * PI, HUEGREEN, SATGREEN, VALUEGREEN));
	}

	return land;
}
예제 #29
0
void JoinedLandscape::buildJoined( Landscape & L_Join, int k_input, int decision, vector < vector < string > > & key_new, string binaryConfig, bool * choices)
{
	string numbuf, configuration, configuration2;
	unsigned short int numbufLength = 0, X = 0, Z = 0, cc = 0, kk = 0, ii = 0, ll = 0;
	float randomTemp;
	while ( (ii < pow(2,k)) ) // loops across all T possible combinations C_i(d_i, d_!i) -- removed k > 0
		{
			numbuf.clear();
			configuration.clear();
			configuration2.clear();
			kk = 0;
			Z = 0;
			binary(X, numbuf);
			numbufLength = numbuf.length();
			binaryConfig.replace((k-numbufLength),numbufLength,numbuf);
			// cout << LOne.key[decision][ii] << endl;
			// configuration.push_back(LOne.key[decision][ii]);
			kk = 0;
			while (kk < n)
			{
				// this loop adds k chars to string key, 0 means not considered, 1 means not chosen, 2 means chosen
				if (choices[kk] == 1)
					{
						if ( binaryConfig[Z] == '1' ){ configuration.push_back('2'); Z++;}
						else { configuration.push_back('1'); Z++;}
					}
				else
					{
						configuration.push_back('0');
					}
				kk++;
			}
			ll = 0;
			while ( ll < pow(2, L_Join.GetK() + 1 ) )
				{
				configuration2.clear();
				configuration2 = L_Join.key[decision][ll+1] + configuration;
				key_new[decision].push_back(configuration2);
				ll++;
				}
			ii++;
			X++;
			}
}
예제 #30
0
void onInit()
{
    VS = compileShader(GL_VERTEX_SHADER, loadFile("terrain.vert").c_str());
    FS = compileShader(GL_FRAGMENT_SHADER, loadFile("terrain.frag").c_str());
    Prog = linkShader(2, VS, FS);

    positionAttrib = glGetAttribLocation(Prog, "position");
    colorAttrib = glGetAttribLocation(Prog, "color");
    mvpUniform = glGetUniformLocation(Prog, "mvp");

    HeightMap* terrain_map = new HeightMap(WIDTH, HEIGHT);
    heightmap = terrain_map->generateHeightMap(0.05, 20.0);
    terrain_map->interpolate(INTERPOLATION_COS);
    terrain_map->smooth(8, 1);
    terrain_map->addPerlinNoise(0.05, 0.25, 6, INTERPOLATION_COS);

    heightmap = terrain_map->enlargeHeightMap(4);

    land.Init(heightmap);
    delete terrain_map;
}