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


C++ Noise::SetSeed方法代码示例

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


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

示例1: Run

void ModelViewer::Run()
{
	TreeNode root;

	// Create the environment cube map
	{
		Noise noise;
		noise.SetSeed(7654321);
		noise.SetSize(32, 32);
		noise.SetSeamless(false);
		noise.ApplyFilter("Simple");
		void* ptr = noise.GetBuffer();

		ITexture* tex = mGraphics->GetTexture("Environment Map");
		tex->Set(ptr, ptr, ptr, ptr, ptr, ptr, 32, 32, ITexture::Format::Float, ITexture::Format::Alpha);
		tex->SetWrapMode(ITexture::WrapMode::ClampToEdge);
	}

	// Create the noise map
	{
		Noise noise;
		noise.SetSeed(74625646);
		noise.SetSize(32, 32);
		noise.SetSeamless(true);
		noise.ApplyFilter("Perlin").Set(3.0f);

		ITexture* tex = mGraphics->GetTexture("Noise map");
		tex->Set(noise.GetBuffer(), 32, 32, 1, ITexture::Format::Float, ITexture::Format::Alpha);
		tex->SetWrapMode(ITexture::WrapMode::Repeat);
	}

	if (!root.Load("Config/Model Viewer.txt")) return;
	
	mCore->Lock();
	mCore->SerializeFrom(root);
	mCore->Unlock();

	// Event listeners
	mCore->AddOnKey		 ( bind(&ModelViewer::OnKeyPress,	this) );
	mCore->AddOnMouseMove( bind(&ModelViewer::OnMouseMove,	this) );
	mCore->AddOnScroll	 ( bind(&ModelViewer::OnScroll,		this) );
	mCore->AddOnDraw	 ( bind(&ModelViewer::OnDraw,		this) );

	Object* rootObj = mCore->GetRoot();

	mCam			= rootObj->FindObject<DebugCamera>	("Default Camera");
	mLight			= rootObj->FindObject<Light>		("Default Light");
	mStage			= rootObj->FindObject<Object>		("Stage");
	mInst			= rootObj->FindObject<ModelInstance>("Default Instance");
	mSbHighlight	= mUI->FindWidget<UIHighlight>		("Status Highlight");
	mSbLabel		= mUI->FindWidget<UILabel>			("Status Label");

	// Model viewer deals with only one model
	mModel = mCore->GetModel("Default Model");

	// If something wasn't found, just exit
	if (mCam == 0 || mLight == 0 || mStage == 0 || mInst == 0 || mModel == 0 || !CreateUI()) return;

	// Deferred drawing
	mDraw  = mCam->AddScript<OSDrawDeferred>();
	mScene = &mDraw->GetScene();

	// Display the current version
	ShowAboutInfo();

	// Endless loop
	while ( mCore->Update() );

#ifndef _DEBUG
	// Reset the stage's rotation before saving the scene
	mStage->SetRelativeRotation( Quaternion() );

	// Save the current scene
	root.Release();
	mCore->SerializeTo(root);
	root.Save("Config/Model Viewer.txt");
#endif
}
开发者ID:saggita,项目名称:r5ge,代码行数:78,代码来源:Model+Viewer.cpp


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