当前位置: 首页>>代码示例>>C++>>正文


C++ Sky类代码示例

本文整理汇总了C++中Sky的典型用法代码示例。如果您正苦于以下问题:C++ Sky类的具体用法?C++ Sky怎么用?C++ Sky使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Sky类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Sky

//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
SkyService::pSky_type
SkyService::createSky(config_type& _config)
{
    Sky* pRawSky = new Sky();
    pSky_type pSky = pSky_type(pRawSky, boost::bind(&SkyService::onDestroySky, this, _1));

    if (//!m_pPhysicsService.isValid() ||
        !m_pRenderingService.isValid() ||
        //!m_pPhysicsResourceService.isValid() ||
        !m_pRenderingResourceService.isValid())
    {
        // TODO error - must setup required services prior to creating sky objects.
        return pSky;
    }

    config_type renderingConfig;
    if (_config["type"] == "skybox")
    {
        renderingConfig["type"] = "skybox";
        renderingConfig["scene"] = "default";
        renderingConfig["resourceName"] = _config["resourceName"];
        renderingConfig["distance"] = _config["distance"];
        pSky->setResource(m_pRenderingResourceService->loadResource(renderingConfig));
    }
    else
    {
        std::cout << "Error: unsupported type in SkyService::createSky()" << std::endl;
    }

    wpSky_type wpSky(pSky);
    pRawSky->setSelfReference(wpSky);

    return pSky;
}
开发者ID:hatboyzero,项目名称:indiezen,代码行数:35,代码来源:SkyService.cpp

示例2: sizeof

void CubeMap::RenderScene(){

	m_d3dDeviceContext->ClearRenderTargetView(m_renderTargetView, reinterpret_cast<const float*>(&COLORS::Silver));
	m_d3dDeviceContext->ClearDepthStencilView(m_depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);

	m_d3dDeviceContext->IASetInputLayout(InputLayouts::Basic);
	m_d3dDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

	UINT stride = sizeof(Vertex::Basic);
	UINT offset = 0;

	m_camera.UpdateViewMat();

	XMMATRIX view  = m_camera.getViewMat();
	XMMATRIX proj  = m_camera.getProjMat();
	XMMATRIX viewproj = m_camera.getViewProjMat();

	float blendFactor[] = { 0.0f, 0.0f, 0.0f, 0.0f};

	//Set Per frame constants
	Effects::BasicFX->setDirLights(m_dirLights);
	Effects::BasicFX->setEyePosVec(m_camera.getPosition());
	Effects::BasicFX->setCubeMap(m_sky->CreateSkySRV());

	m_sky->Draw(m_d3dDeviceContext, m_camera);

	//restore default states, as the SkyFX changes them in the effect file.
	m_d3dDeviceContext->RSSetState(0);
	m_d3dDeviceContext->OMSetDepthStencilState(0, 0);

	HR(m_swapChain->Present(0, 0));
}
开发者ID:keyring,项目名称:whisper,代码行数:32,代码来源:CubeMapDemo.cpp

示例3: VAO

SkyVAO::SkyVAO(const ProgramSP& program, const Sky& sky) : VAO(program)
{
	generateVAO();

	glBindBuffer(GL_ARRAY_BUFFER, sky.getVboVertices());
	glVertexAttribPointer(program->getAttribLocation(a_vertex), 4, GL_FLOAT, GL_FALSE, 0, 0);
	glEnableVertexAttribArray(program->getAttribLocation(a_vertex));

	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, sky.getVboIndices());

	glEnableVertexAttribArray(0);

	unbind();
}
开发者ID:MaikKlein,项目名称:GraphicsEngine,代码行数:14,代码来源:SkyVAO.cpp

示例4: onLostDevice

void WaterDemo::onLostDevice()
{
    mGfxStats->onLostDevice();
    mSky->onLostDevice();
    mWater->onLostDevice();
    HR(mFX->OnLostDevice());
}
开发者ID:erickterri,项目名称:3dlearn,代码行数:7,代码来源:WaterDemo.cpp

示例5:

void EnvMapper::Impl::generate(const Point &pos, const Frustum &frustum, Sky &sky, Terrain &tr) 
{
	int side = CubeMap::PosX;
	CamCont::iterator i, end;

	if(Settings::current.environment_mapping == 2) {
		i = cams.begin();
		end = cams.end();
	} else {
		static int update = 0;
		if(++update > 5) {
			update = 0;
		}
		i = cams.begin() + update;
		end = i + 1;
		side += update;
	}
	
	setup_viewport(cubemap);
	for(; i != end; ++i) {
		i->pos = pos;
		i->setup_view();
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glDisable(GL_CULL_FACE);
		glDisable(GL_DEPTH_TEST);
		sky.render(*i);
		glEnable(GL_CULL_FACE);
		glEnable(GL_DEPTH_TEST);
		tr.render(*i);
		cubemap.copy_to_texture(static_cast<CubeMap::Side>(side++));	
	}
	restore_viewport();
}
开发者ID:mikowiec,项目名称:harvest,代码行数:33,代码来源:envmapper.cpp

示例6: skyChange

// ----------------------------------------------------------------------------
void TerrPanel::skyChange(u32 id)
{
    Sky* sky = Viewport::get()->getSky();

    TexSel* ts = TexSel::getTexSel();
    switch (id)
    {
    case S_T1:
        ts->subscribe(m_sb1);
        sky->setSubIx(1);
        break;
    case S_T2:
        ts->subscribe(m_sb2);
        sky->setSubIx(2);
        break;
    case S_T3:
        ts->subscribe(m_sb3);
        sky->setSubIx(3);
        break;
    case S_T4:
        ts->subscribe(m_sb4);
        sky->setSubIx(4);
        break;
    case S_T5:
        ts->subscribe(m_sb5);
        sky->setSubIx(5);
        break;
    case S_T6:
        ts->subscribe(m_sb6);
        sky->setSubIx(6);
        break;
    }
    ts->subscribe(sky);
} // skyChange
开发者ID:pixelr0,项目名称:stk-editor,代码行数:35,代码来源:terr_panel.cpp

示例7: ZeroMemory

void Simulation::LoadAssets()
{
	ID3D11SamplerState* wrapSampler;
	D3D11_SAMPLER_DESC wsd;
	ZeroMemory(&wsd, sizeof(D3D11_SAMPLER_DESC));
	wsd.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
	wsd.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
	wsd.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
	wsd.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
	wsd.MaxAnisotropy = 0;
	wsd.ComparisonFunc = D3D11_COMPARISON_NEVER;
	wsd.MinLOD = 0;
	wsd.MaxLOD = 0;
	wsd.MipLODBias = 0;
	dev->CreateSamplerState(&wsd, &wrapSampler);

	Material* heightmap = new Material(L"Textures/grass.png", wrapSampler, dev);
	heightmap->LoadShader(L"Heightmap.cso", Vert, dev);
	heightmap->LoadShader(L"TexturedDiffuse.cso", Pixel, dev);

	Material* waterMat = new Material(L"Textures/water.png", wrapSampler, dev);
	waterMat->LoadShader(L"WaterVertex.cso", Vert, dev);
	waterMat->LoadShader(L"WaterPixel.cso", Pixel, dev);

	MeshData skySphere;
	MeshGenerator::CreateSphere(1000.0, 2, skySphere);
	Mesh* skySphereMesh = new Mesh(skySphere, dev);
	Sky* sky = new Sky(skySphereMesh, dev);
	sky->LoadCubeMap(L"Textures/oceansky.dds", dev);
	sky->SetMaterial(L"SkyVertex.cso", L"SkyPixel.cso", wrapSampler, dev);
	objects.push_back(sky);

	Terrain* terrain = new Terrain(500.0f, 500.0f, 500, 500, heightmap, L"Textures/heightmap.png", dev);
	terrain->LoadNormalMap(L"Textures/normalmap2.png", dev);
	terrain->SetBufferData(100.0, dev);
	terrain->SetTextures(L"Textures/sand.png", L"Textures/grass.png", L"Textures/cliff.png",dev);
	objects.push_back(terrain);

	Terrain* water = new Terrain(500.0f, 500.0f, 500, 500, waterMat, L"Textures/waterHeightMap.png", dev);
	water->LoadNormalMap(L"Textures/waterNormalMap.png", dev);
	water->SetBufferData(5.0, 0.0, 0.0, dev);
	water->SetPosition(XMFLOAT3(0, 27.0, 0));
	objects.push_back(water);
}
开发者ID:justinbonczek,项目名称:EnvironmentSimulation,代码行数:44,代码来源:Simulation.cpp

示例8: getFarPlane

float FlyingCamera::getFarPlane()
{
   if (manager == NULL)
      return DEFAULT_FAR_PLANE;

   Sky* pSky = (Sky*)manager->findObject(TribesSkyId);
   if (pSky != NULL) {
      // Use the sky distance, plus a tad.   
      return pSky->getDistance() * 1.1f;      
   }

   SimTerrain* pTerrain = (SimTerrain*)manager->findObject(SimTerrainId);
   if (pTerrain != NULL) {
      // Use the terrain visible distance, plus a tad
      return pTerrain->getVisibleDistance() * 1.1f;      
   }

   // else, well, crap.
   return DEFAULT_FAR_PLANE;
}
开发者ID:AltimorTASDK,项目名称:TribesRebirth,代码行数:20,代码来源:FlyingCamera.cpp

示例9: onResetDevice

void ProjTexDemo::onResetDevice()
{
	mGfxStats->onResetDevice();
	mSky->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, 2000.0f);
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:12,代码来源:ProjTexDemo.cpp

示例10: main

int main()
{


 Sky sky;
 load_all_sound();

 bgm.play();
 Player  player;
 while (window.isOpen())
    {
        window.clear();
        sky.drawsky();

       Event event;
        while (window.pollEvent(event))
        {
            if (event.type == Event::Closed)
                window.close();
            if(event.type==Event::KeyPressed&& event.key.code == Keyboard::Up)
                player.moveup();
            if(event.type==Event::KeyPressed&& event.key.code == Keyboard::Down)
                player.movedown();
            if(event.type==Event::KeyPressed&& event.key.code == Keyboard::Left)
                player.moveleft();
            if(event.type==Event::KeyPressed&& event.key.code == Keyboard::Right)
                player.moveright();
            if(event.type==Event::KeyPressed&& event.key.code == Keyboard::Space)
                player.gun();
        }
        player.bullet_refresh();
        window.display();
    }


    return 0;

}
开发者ID:STyfy,项目名称:flight1.0new,代码行数:38,代码来源:main.cpp

示例11: HR

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));
}
开发者ID:erickterri,项目名称:3dlearn,代码行数:50,代码来源:WaterDemo.cpp

示例12: GetTextureMgr

void CubeMapApp::initApp()
{
	D3DApp::initApp();

	fx::InitAll(md3dDevice);
	InputLayout::InitAll(md3dDevice);
	GetTextureMgr().init(md3dDevice);


	mTech                = fx::CubeMapFX->GetTechniqueByName("CubeMapTech");
	mfxLightVar          = fx::CubeMapFX->GetVariableByName("gLight");
	mfxEyePosVar         = fx::CubeMapFX->GetVariableByName("gEyePosW");
	mfxWVPVar            = fx::CubeMapFX->GetVariableByName("gWVP")->AsMatrix();
	mfxWorldVar          = fx::CubeMapFX->GetVariableByName("gWorld")->AsMatrix();
	mfxTexMtxVar         = fx::CubeMapFX->GetVariableByName("gTexMtx")->AsMatrix();
	mfxReflectMtrlVar    = fx::CubeMapFX->GetVariableByName("gReflectMtrl")->AsVector();
	mfxCubeMapEnabledVar = fx::CubeMapFX->GetVariableByName("gCubeMapEnabled")->AsScalar();
	mfxDiffuseMapVar     = fx::CubeMapFX->GetVariableByName("gDiffuseMap")->AsShaderResource();
	mfxSpecMapVar        = fx::CubeMapFX->GetVariableByName("gSpecMap")->AsShaderResource();
	mfxCubeMapVar        = fx::CubeMapFX->GetVariableByName("gCubeMap")->AsShaderResource();

 
	//mClearColor = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f);

	GetCamera().position() = D3DXVECTOR3(0.0f, 1.8f, -10.0f);

	mBallMapRV        = GetTextureMgr().createTex(L"blackdiffuse.dds");
	//mSpecMapRV        = GetTextureMgr().createTex(L"spec.dds");
	mDefaultSpecMapRV = GetTextureMgr().createTex(L"defaultspec.dds");
	mEnvMapRV         = GetTextureMgr().createCubeTex(L"grassenvmap1024.dds");

	mFloor.init(md3dDevice, 41, 21, 1.0f);
	mBase.init(md3dDevice, 2.0f);
	mBall.init(md3dDevice, 0.5f, 30, 30);
	mColumn.init(md3dDevice, 0.25f, 1.0f, 3.0f, 30, 30);
	mSky.init(md3dDevice, mEnvMapRV, 5000.0f);

 
	mParallelLight.dir      = D3DXVECTOR3(0.57735f, -0.57735f, 0.57735f);
	mParallelLight.ambient  = D3DXCOLOR(0.3f, 0.3f, 0.3f, 1.0f);
	mParallelLight.diffuse  = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
	mParallelLight.specular = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f);
}
开发者ID:Team306,项目名称:BigProject,代码行数:43,代码来源:main.cpp

示例13: GetTextureMgr

void TerrainApp::initApp()
{
	D3DApp::initApp();

	fx::InitAll(md3dDevice);
	InputLayout::InitAll(md3dDevice);
	GetTextureMgr().init(md3dDevice);

	mClearColor = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);

	GetCamera().position() = D3DXVECTOR3(0.0f, 10.0f, -10.0f);

	mEnvMapRV = GetTextureMgr().createCubeTex(L"grassenvmap1024.dds");
	mSky.init(md3dDevice, mEnvMapRV, 5000.0f);

	Terrain::InitInfo tii;
	tii.HeightmapFilename = L"coastMountain513.raw";
	tii.LayerMapFilename0 = L"grass.dds";
	tii.LayerMapFilename1 = L"lightdirt.dds";
	tii.LayerMapFilename2 = L"darkdirt.dds";
	tii.LayerMapFilename3 = L"stone.dds";
	tii.LayerMapFilename4 = L"snow.dds";
	tii.BlendMapFilename  = L"blend.dds";
	tii.HeightScale  = 0.35f;
	tii.HeightOffset = -20.0f;
	tii.NumRows      = 513;
	tii.NumCols      = 513;
	tii.CellSpacing  = 1.0f;

	mLand.init(md3dDevice, tii);
 
	mParallelLight.dir      = D3DXVECTOR3(0.707f, -0.707f, 0.0f);
	mParallelLight.ambient  = D3DXCOLOR(0.3f, 0.3f, 0.3f, 1.0f);
	mParallelLight.diffuse  = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
	mParallelLight.specular = D3DXCOLOR(0.5f, 0.4843f, 0.3f, 1.0f);

	mLand.setDirectionToSun(-mParallelLight.dir);
}
开发者ID:derekqian,项目名称:d3dcoder,代码行数:38,代码来源:Terrain+Demo.cpp

示例14: drawScene

void TerrainApp::drawScene()
{
	D3DApp::drawScene();
	
	// Restore default states, input layout and primitive topology 
	// because mFont->DrawText changes them.  Note that we can 
	// restore the default states by passing null.
	md3dDevice->OMSetDepthStencilState(0, 0);
	float blendFactor[] = {0.0f, 0.0f, 0.0f, 0.0f};
	md3dDevice->OMSetBlendState(0, blendFactor, 0xffffffff);
	
	md3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	mLand.draw(mLandWorld);

	// Draw sky last to save fill rate.
	mSky.draw();

	// We specify DT_NOCLIP, so we do not care about width/height of the rect.
	RECT R = {5, 5, 0, 0};
	md3dDevice->RSSetState(0);
	mFont->DrawText(0, mFrameStats.c_str(), -1, &R, DT_NOCLIP, WHITE);

	mSwapChain->Present(0, 0);
}
开发者ID:derekqian,项目名称:d3dcoder,代码行数:24,代码来源:Terrain+Demo.cpp

示例15: sizeof

void ColoredCubeApp::drawScene()
{
	D3DApp::drawScene();

	//Step through animation frame
	animationTimeElapsed += mTimer.getGameTime() - animationTimePrev;
	animationTimePrev = mTimer.getGameTime();
	if(animationTimeElapsed > 0.0666f)
	{
		animationTimeElapsed = 0.0f;
		frameOfAnimation++;
		if(frameOfAnimation > fireFrameCount-1)
		{
			frameOfAnimation = 0;
		}
	}

	// Restore default states, input layout and primitive topology 
	// because mFont->DrawText changes them.  Note that we can 
	// restore the default states by passing null.
	md3dDevice->OMSetDepthStencilState(0, 0);
	float blendFactors[] = {0.0f, 0.0f, 0.0f, 0.0f};
	md3dDevice->OMSetBlendState(0, blendFactors, 0xffffffff);
    md3dDevice->IASetInputLayout(mVertexLayout);
    md3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

	// Set per frame constants
	mfxEyePosVar->SetRawValue(&mCameraPos, 0, sizeof(D3DXVECTOR3));
	mfxLightVar->SetRawValue(&mLights[0], 0, sizeof(Light));
	mfxLightVar2->SetRawValue(&mLights[1], 0, sizeof(Light));

	mfxCubeMapVR->SetResource(mCubeMapRV);
   
	// set constants
	mWVP = mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP); //set gWVP in color.fx to mWVP

	mTree.setEyePos(mCameraPos);
	mTree.setLights(mLights, 2);
	mTree.draw(mView, mProj);
	mObjBox.setEyePos(mCameraPos);
	mObjBox.setLights(mLights, 2);
	mObjBox.draw(mView, mProj);

    D3D10_TECHNIQUE_DESC techDesc;
    mTech->GetDesc( &techDesc );
    for(UINT p = 0; p < techDesc.Passes; ++p)
    {
        ID3D10EffectPass* pass = mTech->GetPassByIndex( p ); //zero is always used in D3D10
		D3DXMATRIX texMtx;
        
		mWVP = mBoxWorld*mView*mProj;
		mfxWVPVar->SetMatrix((float*)&mWVP);
		mfxWorldVar->SetMatrix((float*)&mBoxWorld);
		mfxDiffuseMapVar->SetResource(mCrateMapRV);
		//mfxDiffuseMapVar->SetResource(mFireAnimationMapRVs[frameOfAnimation]);
		mfxSpecularMapVar->SetResource(mSpecularMapRV);
		mfxNormalMapVR->SetResource(mDefaultNormalMapRV);
		mfxReflectEnabledVar->SetBool(false);
		D3DXMatrixIdentity(&texMtx);
		mfxTexMtxVar->SetMatrix((float*)&texMtx);
		pass->Apply(0);
		mBox.draw();

		mWVP = mPlaneWorld*mView*mProj;
		mfxWVPVar->SetMatrix((float*)&mWVP);
		mfxWorldVar->SetMatrix((float*)&mPlaneWorld);
		mfxDiffuseMapVar->SetResource(mGrassMapRV);
		mfxNormalMapVR->SetResource(mBrickNormalMapRV);
		mfxReflectEnabledVar->SetBool(true);
		D3DXMATRIX s;
		D3DXMatrixScaling(&s, 5.0f, 5.0f, 1.0f);
		texMtx = s;
		D3DXMatrixIdentity(&texMtx);
		mfxTexMtxVar->SetMatrix((float*)&texMtx);
		pass->Apply(0);
		mPlane.draw();
    }

	mSky.draw(mWVP);

	// We specify DT_NOCLIP, so we do not care about width/height of the rect.
	RECT R = {5, 5, 0, 0};
	md3dDevice->RSSetState(0);
	mFont->DrawText(0, mFrameStats.c_str(), -1, &R, DT_NOCLIP, BLACK);

	mSwapChain->Present(0, 0);
}
开发者ID:ashkanhoss29,项目名称:Resume,代码行数:88,代码来源:Colored+Cube+App.cpp


注:本文中的Sky类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。