Пример #1
0
Water *Water::create(const std::string& fileName, const std::string& waveFileOne, const std::string& waveFileTwo, const cocos2d::Size& size, float hSpeed, float vSpeed, float saturation)
{
	Water *water = new (std::nothrow) Water();
	if (water && water->initWithFile(fileName, cocos2d::Rect(0, 0, size.width, size.height)))
	{
		water->autorelease();

		auto TexCache = cocos2d::Director::getInstance()->getTextureCache();
		auto wave2 = TexCache->addImage(waveFileOne);
		auto wave1 = TexCache->addImage(waveFileTwo);

		cocos2d::Texture2D::TexParams wave1TexParams = { GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT };
		cocos2d::Texture2D::TexParams wave2TexParams = { GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT };
		wave1->setTexParameters(wave1TexParams);
		wave2->setTexParameters(wave2TexParams);
		auto glprogram = cocos2d::GLProgram::createWithFilenames("shader3D/water.vsh", "shader3D/water.fsh");
		auto glprogramstate = cocos2d::GLProgramState::getOrCreateWithGLProgram(glprogram);
		water->setGLProgramState(glprogramstate);

		glprogramstate->setUniformTexture("u_wave1", wave1);
		glprogramstate->setUniformTexture("u_wave2", wave2);
		glprogramstate->setUniformFloat("saturateValue", saturation);
		glprogramstate->setUniformFloat("verticalSpeed", vSpeed);
		glprogramstate->setUniformFloat("horizontalSpeed", hSpeed);


		return water;
	}
	CC_SAFE_DELETE(water);
	return nullptr;
}
Пример #2
0
// --- Methods inherited from ReferenceTarget ---
// This method is called to have the plug-in clone itself.
RefTargetHandle Water::Clone(RemapDir &remap) {
	// Create a new instance of the plug-in class
	Water *newWater = new Water();

	// Copy superclass stuff
	*((MtlBase *)newWater) = *((MtlBase *)this);

	// Clone the items we reference
	newWater->ReplaceReference(0, remap.CloneRef(xyzGen));
	newWater->ReplaceReference(1, remap.CloneRef(pblock));
	newWater->col[0] = col[0];
	newWater->col[1] = col[1];
	newWater->count = count;
	newWater->size = size;
	newWater->minperiod = minperiod;
	newWater->maxperiod = maxperiod;
	newWater->amp = amp;
	newWater->phase = phase;
	newWater->type = type;
	newWater->randSeed = randSeed;
	newWater->texValidity.SetEmpty();	
	for (int i = 0; i < NUM_SUB_TEXMAPS; i++) {
		newWater->subTex[i] = NULL;
		newWater->mapOn[i] = mapOn[i];
		if (subTex[i])
			newWater->ReplaceReference(i+2, remap.CloneRef(subTex[i]));
	}
	BaseClone(this, newWater, remap);
	// Return the new cloned texture
	return (RefTargetHandle)newWater;
}
Пример #3
0
void World::loadWater(int x, int y) {
	cout << "loading water" << endl;
	
	//copy the objects_0 array into a new array
	vector<Water> water = waterObjects;
	//clear the original object array
	waterObjects.clear();

	//loop through the new object array and then check if these objects are still in the new region
	for (int i = 0; i < water.size(); i++) {
		//if the objects are in the same region, put them back in the objects_0 array
		if (sameRegion(water.at(i).position_x / 32, water.at(i).position_y / 32, x, y)) {
			waterObjects.push_back(water.at(i));
		} else {
			//else remove the node from the game (deleting the model from memory)
			water.at(i).remove();
		}
	}

	//loop through the object index array
	for (int i = 0; i < water_index.size(); i++) {
		//if the object is in the same region then load the model
		if (sameRegion(water_index.at(i).x / 32, water_index.at(i).y / 32, x, y)) {
			//extract the object data
			WaterData data = water_index.at(i);

			bool model_exists = false;

			//DON'T LOAD OBJECTS IF THEY ARE ALREADY LOADED
			for (auto &j : waterObjects) {
				if ((j.position_x == data.x) && (j.position_y == data.y)) {
					model_exists = true;
					break;
				}
			}

			//if the model is not already in the array, load it!
			if (!model_exists) {
				Water object;
					//loading the object model
					if (data.id == 0)
						object.addWater(data.x, data.y, data.h, data.w, data.l);
					else if (data.id == 1)
						object.addLava(data.x, data.y, data.h, data.w, data.l);
					//add it to the objects_0 array
					waterObjects.push_back(object);
			}
		}
	}

	Client::sceneManager->getMeshCache()->clearUnusedMeshes();

}
Пример #4
0
void WaterDemo::onLostDevice()
{
    mGfxStats->onLostDevice();
    mSky->onLostDevice();
    mWater->onLostDevice();
    HR(mFX->OnLostDevice());
}
Пример #5
0
Water* Water::create()
{
    //Create is virtual function from CCSprite
    Water *pSprite = new Water();
    if (pSprite && pSprite->initWithFile("water_tile.png"))
    {
        // Set to autorelease
        pSprite->autorelease();
        
        //assign your attributes here!!
        
        return pSprite;
    }
    CC_SAFE_DELETE(pSprite);
    return NULL;
}
Пример #6
0
void PropsDemo::updateScene(float dt)
{
	mTime += dt;

	mGfxStats->update(dt);

	gDInput->poll();

	// Fix camera to ground or free flying camera?
	if( gDInput->keyDown(DIK_N) )
		mFreeCamera = false;
	if( gDInput->keyDown(DIK_M) )
		mFreeCamera = true;

	if( mFreeCamera )
	{
		gCamera->update(dt, 0, 0);
	}
	else
	{
		gCamera->update(dt, mTerrain, 2.5f);
	}


	mWater->update(dt);
}
Пример #7
0
void MainWindow::slotOkButton()
{
    QString tmp;

    tmp = ui->lineEdit->text();
    std::cout << "Push ok, value : " << tmp.toInt() << std::endl;
    g_water.setValueToAdd(tmp.toInt());
}
Пример #8
0
void PropsDemo::onLostDevice()
{
	mGfxStats->onLostDevice();
	mTerrain->onLostDevice();
	mWater->onLostDevice();
	HR(mFX->OnLostDevice());
	HR(mGrassFX->OnLostDevice());
}
static void idle		(void)
{
	static float cTime = 0.0;

	camera.update(mouseX, mouseY);
	water.update(cTime);

	glutPostRedisplay();
	cTime += 0.02f;
}
Пример #10
0
void WaterDemo::updateScene(float dt)
{
    mGfxStats->update(dt);

    gDInput->poll();

    gCamera->update(dt, 0, 0);

    mWater->update(dt);
}
Пример #11
0
void Level::init() {
    scheduleUpdate();
    leftDelta = new float[8];
    rightDelta = new float[8];

    waterBlock = CCArray::create();
    waterBlock->retain();

    for(int i = 0; i < 8; i++) {
        Water *w = Water::create();
        w->setPosition(ccp(100+i*50, 150));
        addChild(w);
        waterBlock->addObject(w);
    }

    Water *w = (Water *)waterBlock->objectAtIndex(0);
    //w->setPosition(ccp(100, 100));
    w->velocity = {0, 100*M_PI};

}
bool Ned3DObjectManager::interactPlaneWater(PlaneObject &plane, WaterObject &water)
{
  Water *pWater = water.getWater();
  if(pWater == NULL) return false;
  
  // Test for plane collision with water
  
  Vector3 planePos = plane.getPosition();
  EulerAngles planeOrient = plane.getOrientation();
  Vector3 disp = planePos - disp;
  RotationMatrix planeMatrix;
  planeMatrix.setup(plane.getOrientation()); // get plane's orientation
  float planeBottom = plane.getBoundingBox().min.y;
  float waterHeight = pWater->getWaterHeight();
  
  if(plane.isPlaneAlive() && planeBottom < waterHeight)
  { //collision
    Vector3 viewVector = planeMatrix.objectToInertial(Vector3(0,0,1));
    plane.killPlane();
    plane.setSpeed(0.0f);
    planePos += 2.0f * viewVector;
    planeOrient.pitch = kPi / 4.0f;
    planeOrient.bank = kPi / 4.0f;
    plane.setOrientation(planeOrient);
    plane.setPPosition(planePos);
    
    int partHndl = gParticle.createSystem("planeexplosion");
    gParticle.setSystemPos(partHndl, plane.getPosition());
    int boomHndl = gSoundManager.requestSoundHandle("Boom.wav");
    int boomInst = gSoundManager.requestInstance(boomHndl);
    if(boomInst != SoundManager::NOINSTANCE)
    {
      gSoundManager.setPosition(boomHndl,boomInst,plane.getPosition());
      gSoundManager.play(boomHndl,boomInst);
      gSoundManager.releaseInstance(boomHndl,boomInst);
    }
    return true;
  }
  return false;
}
Пример #13
0
void WaterDemo::onResetDevice()
{
    mGfxStats->onResetDevice();
    mSky->onResetDevice();
    mWater->onResetDevice();
    HR(mFX->OnResetDevice());

    // The aspect ratio depends on the backbuffer dimensions, which can
    // possibly change after a reset.  So rebuild the projection matrix.
    float w = (float)md3dPP.BackBufferWidth;
    float h = (float)md3dPP.BackBufferHeight;
    gCamera->setLens(D3DX_PI * 0.25f, w/h, 1.0f, 5000.0f);
}
Пример #14
0
void WaterDemo::drawScene()
{
    HR(gd3dDevice->BeginScene());

    mSky->draw();

    HR(mFX->SetValue(mhLight, &mLight, sizeof(DirLight)));
    HR(mFX->SetMatrix(mhWVP, &(mSceneWorld*gCamera->viewProj())));
    HR(mFX->SetValue(mhEyePosW, &gCamera->pos(), sizeof(D3DXVECTOR3)));

    UINT numPasses = 0;
    HR(mFX->Begin(&numPasses, 0));
    HR(mFX->BeginPass(0));

    for(UINT j = 0; j < mSceneMtrls.size(); ++j)
    {
        HR(mFX->SetValue(mhMtrl, &mSceneMtrls[j], sizeof(Mtrl)));

        // If there is a texture, then use.
        if(mSceneTextures[j] != 0)
        {
            HR(mFX->SetTexture(mhTex, mSceneTextures[j]));
        }

        // But if not, then set a pure white texture.  When the texture color
        // is multiplied by the color from lighting, it is like multiplying by
        // 1 and won't change the color from lighting.
        else
        {
            HR(mFX->SetTexture(mhTex, mWhiteTex));
        }

        HR(mFX->SetTexture(mhNormalMap, mSceneNormalMaps[j]));

        HR(mFX->CommitChanges());
        HR(mSceneMesh->DrawSubset(j));
    }
    HR(mFX->EndPass());
    HR(mFX->End());

    // Draw alpha blended object last.
    mWater->draw();

    mGfxStats->display();

    HR(gd3dDevice->EndScene());

    // Present the backbuffer.
    HR(gd3dDevice->Present(0, 0, 0, 0));
}
Пример #15
0
int openRankine(int np, void* p) {

    double etap = 0.6;     // pump isentropic efficiency
    double etat = 0.8;     // turbine isentropic efficiency
    double phigh = 8.0e5;  // high pressure

    Water w;

    // begin with water at 300 K, 1 atm
    w.setState_TP(300.0, OneAtm);
    saveState(w,"1");

    // pump water to 0.8 MPa
    w.setState_SP(s["1"], phigh);
    saveState(w,"2s");
    double h2 = (h["2s"] - h["1"])/etap + h["1"];
    w.setState_HP(h2, phigh);
    saveState(w,"2");

    // heat to saturated vapor
    w.setState_Psat(phigh, 1.0);
    saveState(w,"3");

    // expand to 1 atm
    w.setState_SP(s["3"], OneAtm);
    saveState(w,"4s");
    double work_s = h["3"] - h["4s"];
    double work = etat*work_s;
    w.setState_HP(h["3"] - work, OneAtm);
    saveState(w,"4");

    printStates();

    double heat_in = h["3"] - h["2"];
    double efficiency = work/heat_in;

    cout << "efficiency = " << efficiency << endl;
#ifdef WIN32
#ifndef CXX_DEMO
    cout << "press any key to end" << endl;
    char ch;
    cin >> ch;
#endif
#endif
    return 0;
}
Пример #16
0
INT_PTR WaterDlgProc::DlgProc(
		TimeValue t,IParamMap2 *map,HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
	{
	switch (msg) {
		case WM_COMMAND:
			switch (LOWORD(wParam)) 
				{
				case IDC_SWAP:
					{
					water = (Water*)map->GetParamBlock()->GetOwner(); 

					water->SwapInputs();
					}
				break;
				}
			break;
		}
	return FALSE;
	}
static void setup (void)
{
	glClearColor( 0.8,0.8,0.8,1.0 );

	// Load textures
	init_texture("Textures\\cylinderWall.bmp",	CYLINDER_WALL, textures);
	init_texture("Textures\\cylinderCap.bmp",	CYLINDER_CAP, textures);
	init_texture("Textures\\Front.bmp",			BUILD_FRONT, textures);
	init_texture("Textures\\BuildRight.bmp",	BUILD_RIGHT, textures);
	init_texture("Textures\\Concrete.bmp",		CONCRETE, textures);
	init_texture("Textures\\Skybox.bmp",		SKYBOX, textures);

	// Cylinder building
	cylinder.initialize(CYLINDER_WALL, CYLINDER_CAP);
	step1.initialize(CONCRETE, CYLINDER_CAP);
	step2.initialize(CONCRETE, CYLINDER_CAP);

	// Rectangle buildings
	build_front.initialize(BUILD_FRONT, BUILD_FRONT);
	build_right.initialize(BUILD_RIGHT, CONCRETE);
	foundation.initialize(CONCRETE, CONCRETE);

	// Water
	water.build();

	// Sky
	sky.initialize(SKYBOX);

	// Directional light
	sun.init();

	// Spot light
	spLight.init();

	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	glEnable(GL_CULL_FACE);
	glFrontFace(GL_CCW);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}
Пример #18
0
Map::Map(const int width, const int height, char* mapData)
{
	Map::map = this;
	unsigned int start = clock();

	this->Width = width;
	this->Height = height;
	Noise* noiser = new Noise((unsigned int)time(NULL));

	heightMap = new int[width];
	for (int i = 0; i < Width; i++) {
		heightMap[i] = (int) (noiser->eval(i / 20.0f) * Height);
	}

	walls = new Wall*[Width];
	for (int i = 0; i < Width; i++) {
		walls[i] = new Wall[Height];
		for (int j = 0; j < Height; j++) {
			walls[i][j].Id = 0;
		}
	}
	blocks = new Tile*[Width];
	for (int i = 0; i < Width; i++) {
		blocks[i] = new Tile[Height];
	}

	if (!Settings::Multiplayer)
	{

		for (int i = 0; i < Width; i++) {
			int top = heightMap[i];
			for (int j = 0; j < Height; j++) {
				walls[i][j].Id = Block::Dirt->Id;
				if (rand() % 101 > 50 || true || j > top && j < top + 3)
					blocks[i][j].Id = Block::Dirt->Id;
			}
		}
		for (int i = 0; i < Width; i++) {
			int top = heightMap[i];
			for (int j = 0; j <= top; j++) {
				walls[i][j].Id = 0;
				blocks[i][j].Id = 0;
			}
		}
		printf("World tiles fill: %d ms. \n", clock() - start);
		start = clock();

		/*for (int i = 0; i < 0; i++)
			CelluarAuto(Height, i);*/

		printf("Celluar Auto: %d ms. \n", clock() - start);
		start = clock();

		int k = 0;
		while (k < 100)
		{
			int i = rand() % Width;
			int j = rand() % height;
			if (GetBlock(i, j) == 0)
				continue;
			k += GenerateVein(i, j, Block::Stone->Id, 5);
		}

		printf("Veins generation: %d ms. \n", (clock() - start));
	}
	else
	{
		for (int i = 0; i < Width; i++) {
			for (int j = 0; j < Height; j++) {
				blocks[i][j].Id = mapData[i + j * width];
			}
		}
	}


	start = clock();
	
	for (int i = 0; i < Width; i++) {
		for (int j = 0; j < Height; j++) {
			if (blocks[i][j].Id != 0)
				blocks[i][j].connectionIndex = GetConnectionIndex(i, j);
		}
	}
	for (int i = 0; i < Width; i++) {
		for (int j = 0; j < Height; j++) {
			if (walls[i][j].Id != 0)
				walls[i][j].connectionIndex = GetConnectionIndex(i, j, true);
		}
	}
	printf("Tiles connections: %d ms. \n", clock() - start);
	start = clock();

	for (int i = 0; i < Width; i++) {
		for (int j = 0; j < Height; j++) {
			if (blocks[i][j].Id == 0 && walls[i][j].Id == 0)
			{
				blocks[i][j].lightSource = MAX_LIGHT;
				if (NearLive(i, j, 1) == 0)
					blocks[i][j].lightValue = MAX_LIGHT;
			}
		}
	}

	minX = 0;
	minY = 0;
	maxX = width;
	maxY = height;
	CalculateLights(true);

	printf("Lights calculations: %d ms. \n", clock() - start);
	start = clock();

	player = new Player();
	Respawn();
	entities.push_back(player);

	int water_count = 3;
	int water_x = (int)player->GetPosition().x;
	int water_y = GetTop(water_x);
	for (int i = water_x - 2; i < water_x + 2; i++)
	{
		for (int j = water_y; j < water_y + 2; j++)
		{
			SetBlock(i, j, 0);
			SetWall(i, j, 0);
			for (int k = 0; k < water_count; k++)
			{
				for (int l = 0; l < water_count; l++)
				{
					Water* water = new Water();
					water->SetPosition(glm::vec2(i + k * (1 / (float)water_count), j + l * (1 / (float)water_count)));
					waters.push_back(water);
					entities.push_back(water);
				}
			}
		}
	}
	



	skyManager = new SkyManager(this->Width);
}
Пример #19
0
void PropsDemo::drawScene()
{
	// Clear the backbuffer and depth buffer.
	HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff888888, 1.0f, 0));

	HR(gd3dDevice->BeginScene());

	HR(mFX->SetValue(mhEyePosW, &gCamera->pos(), sizeof(D3DXVECTOR3)));
	HR(mFX->SetTechnique(mhTech));
	UINT numPasses = 0;
	HR(mFX->Begin(&numPasses, 0));
	HR(mFX->BeginPass(0));

	drawObject(mCastle, mCastleWorld);

	// Use alpha test to block non leaf pixels from being rendered in the
	// trees (i.e., use alpha mask).
	HR(gd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, true));
	HR(gd3dDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL));
	HR(gd3dDevice->SetRenderState(D3DRS_ALPHAREF, 200));

	// Draw the trees: NUM_TREES/4 of each of the four types.
	for(int i = 0; i < NUM_TREES; ++i)
	{
		if( i < NUM_TREES/4 )
			drawObject(mTrees[0], mTreeWorlds[i]);
		else if( i < 2*NUM_TREES/4 )
			drawObject(mTrees[1], mTreeWorlds[i]);
		else if( i < 3*NUM_TREES/4 )
			drawObject(mTrees[2], mTreeWorlds[i]);
		else
			drawObject(mTrees[3], mTreeWorlds[i]);
	}

	HR(gd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, false));

	HR(mFX->EndPass());
	HR(mFX->End());


	HR(mGrassFX->SetValue(mhGrassEyePosW, &gCamera->pos(), sizeof(D3DXVECTOR3)));
	HR(mGrassFX->SetMatrix(mhGrassViewProj, &(gCamera->viewProj())));
	HR(mGrassFX->SetFloat(mhGrassTime, mTime));
	HR(mGrassFX->Begin(&numPasses, 0));
	HR(mGrassFX->BeginPass(0));

	// Draw to depth buffer only.
	HR(mGrassMesh->DrawSubset(0));

	HR(mGrassFX->EndPass());
	HR(mGrassFX->End());

	mTerrain->draw();

	mWater->draw(); // draw alpha blended objects last.

	mGfxStats->display();

	HR(gd3dDevice->EndScene());

	// Present the backbuffer.
	HR(gd3dDevice->Present(0, 0, 0, 0));
}
Пример #20
0
bool DirectxEngine::UpdateShader(const Water& water, 
                                 const IScene& scene, 
                                 float timer)
{
    if (UpdateShader(water, scene, true, timer))
    {
        auto& shader = m_data->shaders[water.ShaderID()];
        shader->UpdateConstantFloat("speed", &water.Speed(), 1);
        shader->UpdateConstantFloat("bumpIntensity", &water.Bump(), 1);
        shader->UpdateConstantFloat("bumpScale", &water.BumpScale().x, 2);
        shader->UpdateConstantFloat("uvScale", &water.UVScale().x, 2);
        shader->UpdateConstantFloat("deepColor", &water.Deep().r, 4);
        shader->UpdateConstantFloat("shallowColor", &water.Shallow().r, 4);
        shader->UpdateConstantFloat("reflectionTint", &water.ReflectionTint().r, 3);
        shader->UpdateConstantFloat("reflectionIntensity", &water.ReflectionIntensity(), 1);
        shader->UpdateConstantFloat("fresnal", &water.Fresnal().x, 3);

        const auto& waves = water.Waves();
        for (unsigned int i = 0; i < waves.size(); ++i)
        {
            const int offset = i*4; // Arrays pack in buffer of float4
            shader->UpdateConstantFloat("waveFrequency", &waves[i].amplitude, 1, offset);
            shader->UpdateConstantFloat("waveAmplitude", &waves[i].frequency, 1, offset);
            shader->UpdateConstantFloat("wavePhase", &waves[i].phase, 1, offset);
            shader->UpdateConstantFloat("waveDirectionX", &waves[i].directionX, 1, offset);
            shader->UpdateConstantFloat("waveDirectionZ", &waves[i].directionZ, 1, offset);
        }
        return true;
    }
    return false;
}
Пример #21
0
void ScaleRecipeTool::scale(Equipment* equip, double newEff)
{
    if( recObs == 0 || equip == 0 )
        return;

    int i, size;

    // Calculate volume ratio
    double currentBatchSize_l = recObs->batchSize_l();
    double newBatchSize_l = equip->batchSize_l();
    double volRatio = newBatchSize_l / currentBatchSize_l;

    // Calculate efficiency ratio
    double oldEfficiency = recObs->efficiency_pct();
    double effRatio = oldEfficiency / newEff;

    Database::instance().addToRecipe(recObs, equip);
    recObs->setBatchSize_l(newBatchSize_l);
    recObs->setBoilSize_l(equip->boilSize_l());
    recObs->setEfficiency_pct(newEff);
    recObs->setBoilTime_min(equip->boilTime_min());

    QList<Fermentable*> ferms = recObs->fermentables();
    size = ferms.size();
    for( i = 0; i < size; ++i )
    {
        Fermentable* ferm = ferms[i];
        // NOTE: why the hell do we need this?
        if( ferm == 0 )
            continue;

        if( !ferm->isSugar() && !ferm->isExtract() ) {
            ferm->setAmount_kg(ferm->amount_kg() * effRatio * volRatio);
        } else {
            ferm->setAmount_kg(ferm->amount_kg() * volRatio);
        }
    }

    QList<Hop*> hops = recObs->hops();
    size = hops.size();
    for( i = 0; i < size; ++i )
    {
        Hop* hop = hops[i];
        // NOTE: why the hell do we need this?
        if( hop == 0 )
            continue;

        hop->setAmount_kg(hop->amount_kg() * volRatio);
    }

    QList<Misc*> miscs = recObs->miscs();
    size = miscs.size();
    for( i = 0; i < size; ++i )
    {
        Misc* misc = miscs[i];
        // NOTE: why the hell do we need this?
        if( misc == 0 )
            continue;

        misc->setAmount( misc->amount() * volRatio );
    }

    QList<Water*> waters = recObs->waters();
    size = waters.size();
    for( i = 0; i < size; ++i )
    {
        Water* water = waters[i];
        // NOTE: why the hell do we need this?
        if( water == 0 )
            continue;

        water->setAmount_l(water->amount_l() * volRatio);
    }

    Mash* mash = recObs->mash();
    if( mash == 0 )
        return;

    QList<MashStep*> mashSteps = mash->mashSteps();
    size = mashSteps.size();
    for( i = 0; i < size; ++i )
    {
        MashStep* step = mashSteps[i];
        // NOTE: why the hell do we need this?
        if( step == 0 )
            continue;

        // Reset all these to zero so that the user
        // will know to re-run the mash wizard.
        step->setDecoctionAmount_l(0);
        step->setInfuseAmount_l(0);
    }

    // I don't think I should scale the yeasts.

    // Let the user know what happened.
    QMessageBox::information(this, tr("Recipe Scaled"),
                             tr("The equipment and mash have been reset due to the fact that mash temperatures do not scale easily. Please re-run the mash wizard.") );
}
static void draw		(void)
{
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	if(bRendered)	glEnable(GL_TEXTURE_2D);
	else			glDisable(GL_TEXTURE_2D);

	if(bWireframe)
	{
		glLineWidth( 2.0 );
		glPolygonMode(GL_FRONT, GL_LINE);
	}
	else
		glPolygonMode(GL_FRONT, GL_FILL);

	glRotatef(5, 1,0,0);
	camera.transform(sky);
	sun.transform();

	if(bDrawGrid) draw_axis();
	
	glColor3f(0.9,0.9,0.9);

	// Cylinder building
	glPushMatrix();
	glTranslatef(0, 0, -100);
	glRotatef(40, 0, 1, 0);
	spLight.transform();	// Update spot light
	cylinder.draw();
	step1.draw();
	step2.draw();
	glPopMatrix();

	// Right cuboid building
	glPushMatrix();
	glTranslatef(100, 25, 25);
	build_right.draw();
	glTranslatef(-75, 0, 150);
	glRotatef( 90, 0, 1, 0 );
	build_right.draw();
	glPopMatrix();

	// Front timber building
	glPushMatrix();
	glTranslatef(20, 15, 0);
	build_front.draw();
	glPopMatrix();

	// Foundations
	glPushMatrix();
	glTranslatef(0, -15, 0);
	foundation.draw();
	glTranslatef(-325, 0, 0);
	foundation.draw();
	glPopMatrix();

	// Water
	glPushMatrix();
	glTranslatef(-160,-10,0);
	water.draw();
	glPopMatrix();

	glPopMatrix();
	glutSwapBuffers();
	Sleep(1);	// Frame limiter
}
Пример #23
0
void MyScene::Initialise()
{
	glClearColor(0.f, 0.f, 0.f, 1.f);

	// DEMO 1
	//Triangle *t = new Triangle();
    //AddObjectToScene(t);

	// DEMO 2 (Demos / Triforce)
    //Triforce *t = new Triforce();
    // AddObjectToScene(t);
    
	// DEMO 3 (Demos/Solar System)
    // create and add a new triangle to the scene
    //Planet *sun = new Planet(30.0f, 0.0f, 12.0f, 0.0f);
    //sun->SetColour(255, 255, 0); //yellow
    //
    //Planet *mars = new Planet(6.0f, 60.0f, 150.0f, 50.0f);
    //mars->SetColour(255, 0, 0); //red
    //
    //Planet2 *earth = new Planet2(15.0f, 135.0f, 100.0f, 20.0f, 6.0f, 30.0, 100.0f, 8.0f );
    //earth->SetColour(0, 0, 255); //earth blue, moon grey
    //
    //AddObjectToScene(sun);
    //AddObjectToScene(mars);
    //AddObjectToScene(earth);

	// DEMO 4 (Demos/Animated Lamp)
	// Create and add a new lamp to the scene
	//Lamp *l = new Lamp();
	//l->size(6.f);
	//AddObjectToScene(l);

	// DEMO 5
	// Show floor and triangle
	//Floor *f = new Floor();
	//Triangle *t = new Triangle();
	//f->size(100.f);
    //t->size(0.5f);
	//AddObjectToScene(f);
	//AddObjectToScene(t);
	
	// DEMO 6 (LIGHTING)
	// Show teapot and lighting
	//Floor *f = new Floor();
	//f->size(100.f);

	//Teapot *t = new Teapot();
	//t->size(100.f);

	//Light *l = new Light();
	//
	//AddObjectToScene(l);
	//AddObjectToScene(t);
	//AddObjectToScene(f);

	// DEMO 7 (Multilights)
	//Floor *f = new Floor();
	//f->size(100.f);

	//Teapot *t = new Teapot();
	//t->size(100.f);

	//MultiLight *l = new MultiLight();

	//AddObjectToScene(l);
	//AddObjectToScene(t);
	//AddObjectToScene(f);

	// DEMO 8 (Spotlight)
	//Room *r = new Room();
	//r->size(150.f);
	//AddObjectToScene(r);

	//SpotLight *s0 = new SpotLight(GL_LIGHT0, 1);
	//s0->position(0.f, 1.f, 0.f);
	//s0->SetAmbient(0.5f, 0.0f, 0.0f, 1.0f);
	//s0->SetDiffuse(0.9f, 0.0f, 0.0f, 1.0f);
	//s0->SetSpecular(1.0f, 0.5f, 0.5f, 1.0f);
	//s0->SetAttenuation(1.0f, 0.0f, 0.0f);
	//s0->SetSpotDirection(0.0f, 0.0f, -1.0f);
	//s0->SetSpotExponent(6.0f);
	//s0->SetSpotCutOff(80.0f);
	//AddObjectToScene(s0);

	//// add a green spotlight that rotates
	//SpotLight *s1 = new SpotLight(GL_LIGHT1, 2);
	//s1->position(0.0f, -10.0f, 0.f);
	//s1->SetAmbient(0.0f, 0.5f, 0.0f, 1.0f);
	//s1->SetDiffuse(0.0f, 0.9f, 0.0f, 1.0f);
	//s1->SetSpecular(0.5f, 1.0f, 0.5f, 1.0f);
	//s1->SetAttenuation(1.0f, 0.0f, 0.000004f);
	//s1->SetSpotDirection(-1.0f, 0.0f, 0.0f);
	//s1->SetSpotExponent(10.0f);
	//s1->SetSpotCutOff(60.0f);
	//AddObjectToScene(s1);

	//// add a blue spotlight that rotates
	//SpotLight *s2 = new SpotLight(GL_LIGHT2, 3);
	//s2->position(0.0f, -30.0f, 0.f);
	//s2->SetAmbient(0.0f, 0.0f, 0.5f, 1.0f);
	//s2->SetDiffuse(0.0f, 0.0f, 0.9f, 1.0f);
	//s2->SetSpecular(0.5f, 0.5f, 1.0f, 1.0f);
	//s2->SetAttenuation(0.5f, 0.0f, 0.0f);
	//s2->SetSpotDirection(1.0f, 0.0f, 0.0f);
	//s2->SetSpotExponent(80.0f);
	//s2->SetSpotCutOff(20.0f);
	//AddObjectToScene(s2);

	//// add a white spotlight that is stationary
	//SpotLight *s3 = new SpotLight(GL_LIGHT3, 0);
	//s3->position(0.0f, 0.0f, 0.f);
	//s3->SetAmbient(0.5f, 0.5f, 0.5f, 1.0f);
	//s3->SetDiffuse(0.9f, 0.9f, 0.9f, 1.0f);
	//s3->SetSpecular(1.0f, 1.0f, 1.0f, 1.0f);
	//s3->SetAttenuation(1.0f, 0.0f, 0.0f);
	//s3->SetSpotDirection(1.0f, 1.0f, -1.0f);
	//s3->SetSpotExponent(30.0f);
	//s3->SetSpotCutOff(75.0f);
	//AddObjectToScene(s3);

	//// add a light that starts yellow and slowly gets more and less green
	//SpotLight *s4 = new SpotLight(GL_LIGHT4, 4);
	//s4->position(0.0f, -20.0f, 0.f);
	//s4->SetAmbient(0.5f, 0.5f, 0.0f, 1.0f);
	//s4->SetDiffuse(0.4f, 0.4f, 0.0f, 1.0f);
	//s4->SetSpecular(1.0f, 1.0f, 1.0f, 1.0f);
	//s4->SetAttenuation(1.0f, 0.0f, 0.0f);
	//s4->SetSpotDirection(-1.0f, -1.0f, -1.0f);
	//s4->SetSpotExponent(30.0f);
	//s4->SetSpotCutOff(60.0f);
	//AddObjectToScene(s4);

	//// add a light that gets more and less blue and rotates on all axis
	//SpotLight *s5 = new SpotLight(GL_LIGHT5, 5);
	//s5->position(0.0f, -40.0f, 0.f);
	//s5->SetAmbient(0.1f, 0.5f, 0.1f, 1.0f);
	//s5->SetDiffuse(0.2f, 0.9f, 0.2f, 1.0f);
	//s5->SetSpecular(1.0f, 1.0f, 1.0f, 1.0f);
	//s5->SetAttenuation(1.0f, 0.0f, 0.0f);
	//s5->SetSpotDirection(1.0f, -1.0f, -1.0f);
	//s5->SetSpotExponent(20.0f);
	//s5->SetSpotCutOff(80.0f);
	//AddObjectToScene(s5);

	//// DEMO 9 (TEXTURED CUBE)
	//TexturedCube *txc = new TexturedCube("./Code/Demos/Texturing/batmanlogo.bmp");
	//txc->size(200.f);
	//AddObjectToScene(txc);

	//// DEMO 10 (Animated Texturing)

	//Link *link = new Link(10.f, 25.f, "./Code/Demos/Texturing/linkSpriteSheet.bmp");
	//link->position(0.f, -99.9f, -100.f);
	//link->size(10.f);


	//Water *water = new Water(20, 20, "./Code/Demos/Texturing/water.bmp");
 //   
	//water->position(0.f, -99.9f, 100.f);
	//water->size(400.f);

	//Floor *floor = new Floor();
	//floor->size(100);

	//SunLight *sl = new SunLight();
	//sl->direction(-1.f, 1.f, 1.f);

	//AddObjectToScene(floor);
	//AddObjectToScene(water);
	//AddObjectToScene(link);
	//AddObjectToScene(sl);

//skybox
	cameraRadius();
	myStage *stage = new myStage();
	GLuint* skybox = new GLuint[6];
	skybox[0] = Scene::GetTexture("./Code/src/skybox_left.bmp");
	skybox[1] = Scene::GetTexture("./Code/src/skybox_right.bmp");
	skybox[2] = Scene::GetTexture("./Code/src/skybox_front.bmp");
	skybox[3] = Scene::GetTexture("./Code/src/skybox_back.bmp");
	skybox[4] = Scene::GetTexture("./Code/src/skybox_down.bmp");
	skybox[5] = Scene::GetTexture("./Code/src/skybox_up.bmp");
	stage->setTextures(skybox);
	stage->size(2*camrad);
	stage->position(0.f, -100.f, 0.f);
	AddObjectToScene(stage);


//buildings
	YfjBuilding *yfjBuilding = new YfjBuilding();
	GLuint* yfjbd = new GLuint[6];
	yfjbd[0] = Scene::GetTexture("./Code/src/YFJ0.bmp");
	yfjbd[1] = Scene::GetTexture("./Code/src/YFJ1.bmp");
	yfjbd[2] = Scene::GetTexture("./Code/src/YFJ2.bmp");
	yfjbd[3] = Scene::GetTexture("./Code/src/AMEN3.bmp");
	yfjbd[4] = Scene::GetTexture("./Code/src/YFJ4.bmp");
	yfjbd[5] = Scene::GetTexture("./Code/src/YFJ5.bmp");
	yfjBuilding->setTextures(yfjbd);
	yfjBuilding->size(10);
	yfjBuilding->position(-200.f,-100.f,-200.f);
	AddObjectToScene(yfjBuilding);

	AmenBuilding *amenBuilding = new AmenBuilding();
	GLuint* amenbd = new GLuint[5];
	amenbd[0] = Scene::GetTexture("./Code/src/AMEN0.bmp");
	amenbd[1] = Scene::GetTexture("./Code/src/AMEN1.bmp");	
	amenbd[2] = Scene::GetTexture("./Code/src/AMEN2.bmp");
	amenbd[3] = Scene::GetTexture("./Code/Src/AMEN3.bmp");
	amenbd[4] = Scene::GetTexture("./Code/Src/AMEN4.bmp");
	amenBuilding->setTextures(amenbd);
	amenBuilding->size(10);
	amenBuilding->position(-200.f, -100.f, 0.0f);
	AddObjectToScene(amenBuilding);


//road
	Road *road1 = new Road("./Code/src/Road1.bmp");
	road1->size(10);
	road1->setLength(9);
	road1->position(50.0f, -99.f, -480.0f);
	AddObjectToScene(road1);

	Road *road2	= new Road("./Code/src/Road1.bmp");
	road2->size(10);
	road2->setLength(8);
	road2->position(-300.0f, -99.f, -480.0f);
	AddObjectToScene(road2);

	Road *road3 = new Road("./Code/src/Road2.bmp");
	road3->size(10);
	road3->setLength(5);
	road3->position(-280.0f, -99.f, 120.0f);
	road3->orientation(0.f, 77.f, 0.f);
	AddObjectToScene(road3);

//water
	Water *water = new Water(20, 20, "./Code/Demos/Texturing/water.bmp");
	water->size(400);
	water->position(-600.f, -98.f, -150.0f);
	AddObjectToScene(water);


//tree
	Tree *tree1 = new Tree("./Code/src/bark.bmp");
	Tree *tree2 = new Tree("./Code/src/bark.bmp");
	Tree *tree3 = new Tree("./Code/src/bark.bmp");
	Tree *tree4 = new Tree("./Code/src/bark.bmp");
	Tree *tree5 = new Tree("./Code/src/bark.bmp");
	Tree *tree6 = new Tree("./Code/src/bark.bmp");

	tree1->setReplaceString('f', "ff-[-& f + ff + < + f] + [+>f--f&-f]");
	tree2->setReplaceString('f', "ff-[-& f + ff + < + f] + [+>f--f&-f]");
	tree3->setReplaceString('f', "ff-[-& f + ff + < + f] + [+>f--f&-f]");
	tree4->setReplaceString('f', "ff-[-& f + ff + < + f] + [+>f--f&-f]");
	tree5->setReplaceString('f', "ff-[-& f + ff + < + f] + [+>f--f&-f]");
	tree6->setReplaceString('f', "ff-[-& f + ff + < + f] + [+>f--f&-f]");

	tree1->size(5);
	tree2->size(5);
	tree3->size(5);
	tree4->size(5);
	tree5->size(5);
	tree6->size(5);

	tree1->position(-200.f, -98.f, 80.0f);
	tree2->position(-160.f, -98.f, 88.0f);
	tree3->position(-120.f, -98.f, 97.0f);
	tree4->position(-80.f, -98.f, 105.0f);
	tree5->position(-40.f, -98.f, 114.0f);
	tree6->position(0.f, -98.f, 123.0f);

	AddObjectToScene(tree1);
	AddObjectToScene(tree2);
	AddObjectToScene(tree3);
	AddObjectToScene(tree4);
	AddObjectToScene(tree5);
	AddObjectToScene(tree6);
//bird
	Bird *bird = new Bird(24.f, 31.4f, "./Code/src/bird.bmp");
	bird->position(0.f, -0.f, -300.f);
	bird->size(5.f);
	AddObjectToScene(bird);

//light

	mySunlight *sl = new mySunlight();
	sl->direction(-1.f, 1, 1.f);
	AddObjectToScene(sl);

	SpotLight *s0 = new SpotLight(GL_LIGHT1, 0);
	s0->size(0.1);
	s0->position(-198.f, -74.f, 132.f);
	s0->SetAmbient(0.8f, 0.8f, 0.8f, 1.0f);
	s0->SetDiffuse(0.9f, 0.9f, 0.9f, 1.0f);
	s0->SetSpecular(1.0f, 0.5f, 0.5f, 1.0f);
	s0->SetAttenuation(1.0f, 0.0f, 0.0f);
	s0->SetSpotDirection(0.0f, -1.0f, 0.0f);
	s0->SetSpotExponent(6.0f);
	s0->SetSpotCutOff(80.0f);
	AddObjectToScene(s0);

	StreetLight *stl = new StreetLight();
	stl->orientation(0.f, -13.f, 0.f);
	stl->position(-200.f, -98.f, 140.f);
	stl->size(5);
	AddObjectToScene(stl);

	SpotLight *s1 = new SpotLight(GL_LIGHT2, 0);
	s1->size(0.1);
	s1->position(-98.f, -74.f, 155.f);
	s1->SetAmbient(0.9f, 0.9f, 0.9f, 1.0f);
	s1->SetDiffuse(0.9f, 0.9f, 0.9f, 1.0f);
	s1->SetSpecular(1.0f, 0.5f, 0.5f, 1.0f);
	s1->SetAttenuation(1.0f, 0.0f, 0.0f);
	s1->SetSpotDirection(0.0f, -1.0f, 0.0f);
	s1->SetSpotExponent(6.0f);
	s1->SetSpotCutOff(80.0f);
	AddObjectToScene(s1);

	StreetLight *stl2 = new StreetLight();
	stl2->orientation(0.f, -13.f, 0.f);
	stl2->position(-100.f, -98.f, 163.f);
	stl2->size(5);
	AddObjectToScene(stl2);

	SpotLight *s2 = new SpotLight(GL_LIGHT3, 0);
	s2->size(0.1);
	s2->position(-8.f, -74.f, 175.f);
	s2->SetAmbient(0.8f, 0.8f, 0.8f, 1.0f);
	s2->SetDiffuse(0.9f, 0.9f, 0.9f, 1.0f);
	s2->SetSpecular(1.0f, 0.5f, 0.5f, 1.0f);
	s2->SetAttenuation(1.0f, 0.0f, 0.0f);
	s2->SetSpotDirection(0.0f, -1.0f, 0.0f);
	s2->SetSpotExponent(6.0f);
	s2->SetSpotCutOff(80.0f);
	AddObjectToScene(s2);
	StreetLight *stl3 = new StreetLight();
	stl3->orientation(0.f, -13.f, 0.f);
	stl3->position(-10.f, -98.f, 184.f);
	stl3->size(5);
	AddObjectToScene(stl3);
}
Пример #24
0
void Level::update(float dt) {
    float Spread = 0.1;
    for(unsigned int i = 0; i < waterBlock->count(); i++) {
        Water *w = (Water *)waterBlock->objectAtIndex(i);
        w->update(dt);
    }
    //iteration speed and position
    for(int j = 0; j < 3; j++) {
        //adjust velocity
        for(unsigned int i = 0; i < waterBlock->count(); i++) {
            Water *w = (Water*)waterBlock->objectAtIndex(i);
            if(i > 0) {
                Water *lw = (Water *)waterBlock->objectAtIndex(i-1);
                leftDelta[i] = Spread*dt*(w->getPosition().y-lw->getPosition().y);
                lw->velocity.y += leftDelta[i];
            }
            if(i < waterBlock->count()-1) {
                Water *rw = (Water*)waterBlock->objectAtIndex(i+1);
                rightDelta[i] = Spread*dt*(w->getPosition().y-rw->getPosition().y);
                rw->velocity.y += rightDelta[i];
            }
        }
        
        //adjust Height
        for(unsigned int i = 0; i < waterBlock->count(); i++) {
            if(i > 0)  {
                Water *lw = (Water*)waterBlock->objectAtIndex(i-1);
                CCPoint old = lw->getPosition();
                old.y += leftDelta[i];
                lw->setPosition(old);
            }
            if(i < waterBlock->count()-1) {
                Water *rw = (Water*)waterBlock->objectAtIndex(i+1);
                CCPoint old = rw->getPosition();
                old.y += rightDelta[i];
                rw->setPosition(old);
            }
        }
    }
}