예제 #1
0
CTopsManager::CTopsManager(std::shared_ptr<CTask> task) :
CPage(task, Page)
{
	Float2 PlacementPos[MaxNum];
	const float PosX = 550;
	const float PosY = CPageManager::PartsPosY;
	const float SpaceX = 132;
	const float SpaceY = 120;

	for (int i = 0; i < 4; i++)
	{
		PlacementPos[i] = Float2(PosX + (i * SpaceX), PosY);
		PlacementPos[i + 4] = Float2(PosX + (i * SpaceX), PosY + SpaceY * 1);
		PlacementPos[i + 4 * 2] = Float2(PosX + (i * SpaceX), PosY + SpaceY * 2);
		PlacementPos[i + 4 * 3] = Float2(PosX + (i * SpaceX), PosY + SpaceY * 3);
	}

	for (int i = 0; i < Page; i++)
	{
		for (auto& it : PlacementPos)
		{
			parts.push_back(std::make_unique<CTops>(task, it,i,Float2(0,-70)));
		}
	}

}
예제 #2
0
	inline std::basic_ostream<CharType>& operator << (std::basic_ostream<CharType>& os, const Mat3x2& mat)
	{
		return os << CharType('(')
			<< Float2(mat._11, mat._12) << CharType(',')
			<< Float2(mat._21, mat._22) << CharType(',')
			<< Float2(mat._31, mat._32) << CharType(')');
	}
예제 #3
0
//----------------------------------------------------------------------------
void BouncingBall::CreateFloor ()
{
    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);
    int vstride = vformat->GetStride();

    VertexBuffer* vbuffer = new0 VertexBuffer(4, vstride);
    VertexBufferAccessor vba(vformat, vbuffer);

    const float xExtent = 8.0f;
    const float yExtent = 16.0f;
    const float zValue = 0.0f;
    vba.Position<Float3>(0) = Float3(-xExtent, -yExtent, zValue);
    vba.Position<Float3>(1) = Float3(+xExtent, -yExtent, zValue);
    vba.Position<Float3>(2) = Float3(+xExtent, +yExtent, zValue);
    vba.Position<Float3>(3) = Float3(-xExtent, +yExtent, zValue);
    vba.TCoord<Float2>(0, 0) = Float2(0.0f, 0.0f);
    vba.TCoord<Float2>(0, 1) = Float2(1.0f, 0.0f);
    vba.TCoord<Float2>(0, 2) = Float2(1.0f, 1.0f);
    vba.TCoord<Float2>(0, 3) = Float2(0.0f, 1.0f);

    IndexBuffer* ibuffer = new0 IndexBuffer(6, sizeof(int));
    int* indices = (int*)ibuffer->GetData();
    indices[0] = 0;  indices[1] = 1;  indices[2] = 2;
    indices[3] = 0;  indices[4] = 2;  indices[5] = 3;

    mFloor = new0 TriMesh(vformat, vbuffer, ibuffer);

    std::string path = Environment::GetPathR("Floor.wmtf");
    Texture2D* texture = Texture2D::LoadWMTF(path);
    mFloor->SetEffectInstance(Texture2DEffect::CreateUniqueInstance(texture,
        Shader::SF_LINEAR, Shader::SC_REPEAT, Shader::SC_REPEAT));
}
예제 #4
0
void CParts::Draw()
{
	TextureAsset(CResource::GetInstance().GetGraphic(CResource::GraphicType::PartsBackGraohic_1)).
		resize(Float2(120, 120)).draw(pos + framepos);

	PartsDraw();

	TextureAsset(CResource::GetInstance().GetGraphic(CResource::GraphicType::PartsBackGraohic_2)).
		resize(Float2(120, 120)).draw(pos + framepos);

}
예제 #5
0
		bool System::mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
		{
			if(!m_bEnableInput){
				return true;
			}
			if(id==OIS::MB_Left){
				Engine::Scene* pScene	=	GameSystem::GetSingleton()->GetCurrentSection()->GetScene();
				switch(m_CM){
				case enCM_Select:{

					break;}
				case enCM_SelectList:{

					break;}
				case enCM_Move:{
					if(m_MoveType!=Engine::eMRCT_None){
						m_bIsControl	=	true;
						m_MoveDir		=	Float2(arg.state.X.abs,arg.state.Y.abs);
						Engine::MeshEntityList::iterator i = m_lstSelectObj.begin();
						if(i!=m_lstSelectObj.end()){

							m_OldPos	=	(*i)->GetParentSceneNode()->GetPosition();
							Float3 vPositive	=	m_OldPos+Float3(10,10,10);
						}
					}
					break;}
				case enCM_Scale:{
					if(m_MoveType!=Engine::eMRCT_None){
						m_bIsControl	=	true;
						m_MoveDir		=	Float2(arg.state.X.abs,arg.state.Y.abs);
						Engine::MeshEntityList::iterator i = m_lstSelectObj.begin();
						if(i!=m_lstSelectObj.end()){
							m_OldPos	=	(*i)->GetParentSceneNode()->GetScale();
						}
					}
					break;}
				case enCM_Rotate:{
					if(m_MoveType!=Engine::eMRCT_None){
						m_bIsControl	=	true;
						m_MoveDir		=	Float2(arg.state.X.abs,arg.state.Y.abs);
						Engine::MeshEntityList::iterator i = m_lstSelectObj.begin();
						if(i!=m_lstSelectObj.end()){
							m_OldQuat	=	(*i)->GetParentSceneNode()->GetQuat();
						}
					}
								 }break;
				case enCM_Create:{
					
					break;}
				}
			}
			return true;
		}
void InputComponent::resetMovementInput()
{
	while(itrPlayer.hasNext())
	{
		AttributePtr<Attribute_Player> ptr_player = itrPlayer.getNext();

		if(ptr_player->ptr_inputDevice.isEmpty())
			continue;

		AttributePtr<Attribute_Input> input = ptr_player->ptr_input;
		input->position = Float2(0.0f, 0.0f);
		input->rotation = Float2(0.0f, 0.0f);
	}
}
예제 #7
0
//-----------------------------------------------------------------------------
//! シャドウ書き込み開始
//-----------------------------------------------------------------------------
void CascadedShadow::begin(LightBase* pLight)
{
	// シャドウマップリスト数を上回っていたら処理しない
	if(_currentShadowNum >= SPLIT_COUNT ) return;

	static f32	minMax[6];
	
	// 現在のシャドウを保存
	_pCurrentShadow = _pShadow[_currentShadowNum];

	CameraBase*	cam		= GmCameraMan()->getCurrentCamera();
	Vector3		camPos	= cam->getPosition();
	Matrix		camMat  = cam->getMatrix();

	// 視錐台の8点を更新
//	updateFrustumPoints(f[_currentShadowNum], camPos, camMat);
	// クロップ行列作成
//	f32 minZ = applyCropMatrix(f[_currentShadowNum], pLight);

	

	if( !_isSetRender ) {
		calcAndSetViewMatrix(pLight->getLightDir().normalize(), -Vector3(camMat._m[2]).normalize(), camPos);
		// ビューポートを退避
		glPushAttrib(GL_VIEWPORT_BIT);
		// カメラからの距離リストを計算(コレを元にシェーダでテクスチャを使い分ける)
		calcFarDist();
		// 転送
		GmShader()->changeShader(SystemShader::SHADER_TEXTURE);
		GmShader()->setUniform1fv("farDist", _farDist, SPLIT_COUNT);
		GmShader()->beginPrevShader();

		if (!GmRender()->setRenderTarget(_depthTexture, Float2(0, 0), -1, &Size<s32>(DEPTH_SIZE, DEPTH_SIZE))) {
			MessageBoxA(NULL, "シャドウのバインドに失敗しました", "エラー", MB_OK);
		}
		glClear(GL_DEPTH_BUFFER_BIT);
		_isSetRender = true;	// 描画ターゲット設定フラグON
	}

	// モデルビュープロジェクション行列作成
	_depthMVP = _modelMatrix * _depthView[_currentShadowNum] * _depthProj[_currentShadowNum];

	// 現在のシャドウを描画開始する
	_pCurrentShadow->begin(pLight, _depthMVP, Float2((f32)( DEPTH_SIZE*_currentShadowNum ), 0.0f));
	
	// 次のシャドウマップへ
	++_currentShadowNum;

}
예제 #8
0
void CTopsManager::PartsDraw()
{
	const Float2 BackPos = Float2(50, 70);
	if (select_id <= -1) return;
	TextureAsset(CResource::GetInstance().GetTops(select_id)).draw(BackPos);

}
예제 #9
0
	TexturedQuad TextureRegion::rotatedAt(const double x, const double y, const double angle) const
	{
		return TexturedQuad(texture,
			uvRect,
			RectF(size).rotatedAt(x, y, angle),
			Float2(x, y));
	}
예제 #10
0
void CParts::Change()
{
	if (utility::IsMousePointer(pos + framepos, Float2(120, 120)) && Input::MouseL.clicked)
	{
		Select();
	}
}
예제 #11
0
			void Renderer::SetMaterialName( AString strMaterialName ){
				AString	strMaterial	=	AString("..\\Data\\UI\\")	+	strMaterialName	+	AString(".Material");
				AString	strImageSet	=	AString("..\\Data\\UI\\")	+	strMaterialName	+	AString(".ImageSet.Xml");
	
// 				Render::IMaterial*	pMaterial	=	Render::System::GetSingleton()->CreateProduct<Render::IMaterial*>(strMaterial,AString("Material"));
// 				if(pMaterial==NULL){
// 					EngineLogWarnning((AChar*)strMaterialName.c_str(),"UI材质更换失败!");
// 					return;
// 				}
// 				if(m_pMaterial!=NULL){
// 					EngineSystem::GetSingleton()->DestroyProduct(m_pMaterial);
// 					m_pMaterial	=	NULL;
// 				}
// 				m_pMaterial	=	pMaterial;
// 	
// 				if(pMaterial!=NULL){
// 					Render::IMaterial::Technique*	pTechnique	=	m_pMaterial->GetCurrentTechnique();
// 					if(pTechnique!=NULL){
// 						Render::ITexture*	pTex	=	(Render::ITexture*)pTechnique->GetParam("UI");
// 						if(pTex!=NULL){
// 							//Render::ITexture::Info	info	=	pTex->m_Info;
// 	
// 							m_vTextureSize.x	=	pTex->m_Info.width;
// 							m_vTextureSize.y	=	pTex->m_Info.height;
// 						}
// 					}
// 				}
	
				IImageSet::Info	info;
				info.vTextureSize	=	Float2(m_vTextureSize.x,m_vTextureSize.y);
				m_pImageSet	=	new	IImageSet(strImageSet,&info);
				m_pImageSet->Create();
			}
예제 #12
0
// Computes shadow depth bounds on the CPU using the mesh vertex positions
void MeshRenderer::ComputeShadowDepthBoundsCPU(const Camera& camera)
{
    Float4x4 viewMatrix = camera.ViewMatrix();
    const float nearClip = camera.NearClip();
    const float farClip = camera.FarClip();
    const float clipDist = farClip - nearClip;

    float minDepth = 1.0f;
    float maxDepth = 0.0f;
	for (int i = 0; i < _scene->getNumModels(); i++)
	{
		Model *model = _scene->getModel(i);
		const uint64 numMeshes = model->Meshes().size();
		for (uint64 meshIdx = 0; meshIdx < numMeshes; ++meshIdx)
		{
			const Mesh& mesh = model->Meshes()[meshIdx];
			const uint64 numVerts = mesh.NumVertices();
			const uint64 stride = mesh.VertexStride();
			const uint8* vertices = mesh.Vertices();
			for (uint64 i = 0; i < numVerts; ++i)
			{
				const Float3& position = *reinterpret_cast<const Float3*>(vertices);
				float viewSpaceZ = Float3::Transform(position, viewMatrix).z;
				float depth = Saturate((viewSpaceZ - nearClip) / clipDist);
				minDepth = std::min(minDepth, depth);
				maxDepth = std::max(maxDepth, depth);
				vertices += stride;
			}
		}
	}
    
    _shadowDepthBounds = Float2(minDepth, maxDepth);
}
예제 #13
0
void CGroupManager::PartsDraw()
{
	const Float2 BackPos = Float2(350, 150);
	if (select_id <= -1) return;
	TextureAsset(CResource::GetInstance().GetGroup(select_id)).draw(BackPos);

}
예제 #14
0
	TextureRegion TextureRegion::fitted(double width, double height, const bool scaleUp) const
	{
		if (!scaleUp)
		{
			width = std::min<double>(width, size.x);
			height = std::min<double>(height, size.y);
		}

		const double w = size.x;
		const double h = size.y;
		double ws = width / w;	// 何% scalingするか
		double hs = height / h;

		double targetWidth, targetHeight;

		if (ws < hs)
		{
			targetWidth = width;
			targetHeight = h * ws;
		}
		else
		{
			targetWidth = w * hs;
			targetHeight = height;
		}

		TextureRegion result = *this;
		result.size = Float2(targetWidth, targetHeight);

		return result;
	}
예제 #15
0
Float2<T> Float2<T>::randomPointInSquare(const Float2 &center, T width, T height, 
	Random &random)
{
	auto randDirection = Float2::randomDirection(random);
	return Float2(
		center.x + (width * randDirection.x),
		center.y + (height * randDirection.y));
}
예제 #16
0
void CAccessoryManager::PartsFrontDraw()
{
	const Float2 BackPos = Float2(50, 70);
	for (auto& it : parts)
	{
		if (it->GetState() == CParts::State::None) continue;
		if (std::dynamic_pointer_cast<CAccessory>(it)->GetZBuffer() != CAccessory::ZBuffer::Front) continue;
		TextureAsset(CResource::GetInstance().GetAccessory(it->GetId())).draw(BackPos);
	}
}
예제 #17
0
Interpolate1D::Interpolate1D() :
m_rbf(NULL)
{ 
	m_bound = Float2(-1.f, 1.f); 
	m_covTrain = new Covariance<float, RbfKernel<float> >();
	m_xTrain = new DenseMatrix<float >();
	m_yTrain = new DenseMatrix<float >();
	m_xMean = new DenseVector<float >(1);
	m_yMean = new DenseVector<float >(1);
}
예제 #18
0
bool Water::Initialise(float height, float spacing, int size)
{
    m_height = height;

    if (CreateGrid(Float2(1.0f, 1.0f), spacing, size, size, false, false))
    {
        InitialiseMeshData();
        return true;
    }
    return false;
}
예제 #19
0
void Interpolate1D::setObservation(const float & x,
					const float & y,
					const int & idx)
{
	if(idx >= numObservations() ) {
		addObservation(x, y);
		return;
	}
	
	m_observations[idx] = Float2(x, y);
}
LoaderFbxTextureDesc::LoaderFbxTextureDesc()
{
	textureName_ = "Unknown";
	fileName_	 = "Unknown";
	
	scale_					= Float2(0.0f, 0.0f);
	translation_			= Float2(0.0f, 0.0f);
	rotation_				= Float3(0.0f, 0.0f, 0.0f);
	swap_					= false;
	alphaSource_			= 0;
	croppingLeft_			= 0;
	croppingTop_			= 0;
	croppingRight_			= 0;
	croppingBottom_			= 0;
	mappingType_			= 0;
	planarMappingNormal_	= 0;
	blendMode_				= 0;
	defaultAlpha_			= 0.0f;
	materialUse_			= 0;
	textureUse_				= 0;
}
예제 #21
0
CGroupManager::CGroupManager(std::shared_ptr<CTask> task) :
CPage(task,0)
{
	const int MaxNum = CResource::MaxGroupNum;
	Float2 PlacementPos[MaxNum];
	const float PosX = 460;
	const float PosY = CPageManager::PartsPosY+50;
	const float SpaceX = 120;
	const float SpaceY = 130;

	for (int i = 0; i < 6; i++)
	{
		PlacementPos[i] = Float2(PosX + (i * SpaceX), PosY);
		PlacementPos[i + 6] = Float2(PosX + (i * SpaceX), PosY + SpaceY * 1);
		PlacementPos[i + 6 * 2] = Float2(PosX + (i * SpaceX), PosY + SpaceY * 2);
	}

	for (auto& it : PlacementPos)
	{
		parts.push_back(std::make_unique<CGroup>(task, it, 0));
	}
}
예제 #22
0
CSetManager::CSetManager(std::shared_ptr<CTask> task) :
CPage(task, 0)
{
	const Float2 framesize(120, 200);
	const int MaxNum = 8;
	Float2 PlacementPos[MaxNum];
	const float PosX = 550;
	const float PosY = CPageManager::PartsPosY+30;
	const float SpaceX = 132;
	const float SpaceY = 20 + framesize.y;

	for (int i = 0; i < 4; i++)
	{
		PlacementPos[i] = Float2(PosX + (i * SpaceX), PosY);
		PlacementPos[i + 4] = Float2(PosX + (i * SpaceX), PosY + SpaceY * 1);
	}

	for (auto& it : PlacementPos)
	{
		parts.push_back(std::make_unique<CSet>(task, it, 0,Float2(0,-50)));
	}
}
예제 #23
0
D3D11_TEXTURE2D_DESC SpriteRenderer::SetPerBatchData(ID3D11ShaderResourceView* texture)
{
    // Set per-batch constants
    VSPerBatchCB perBatch;

    // Get the viewport dimensions
    UINT numViewports = 1;
    D3D11_VIEWPORT vp;
    context->RSGetViewports(&numViewports, &vp);
    perBatch.ViewportSize = Float2(static_cast<float>(vp.Width), static_cast<float>(vp.Height));

    D3D11_TEXTURE2D_DESC desc;

    // Get the size of the texture
    if(texture)
    {
        ID3D11Resource* resource;
        ID3D11Texture2DPtr texResource;
        texture->GetResource(&resource);
        texResource.Attach(reinterpret_cast<ID3D11Texture2D*>(resource));
        texResource->GetDesc(&desc);
        perBatch.TextureSize = Float2(static_cast<float>(desc.Width), static_cast<float>(desc.Height));
    }
    else
    {
        perBatch.TextureSize = Float2(1.0f, 1.0f);
        desc.Width = 1;
        desc.Height = 1;
    }

    // Copy it into the buffer
    D3D11_MAPPED_SUBRESOURCE mapped;
    DXCall(context->Map(vsPerBatchCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped));
    CopyMemory(mapped.pData, &perBatch, sizeof(VSPerBatchCB));
    context->Unmap(vsPerBatchCB, 0);

    return desc;
}
예제 #24
0
///	HPバーの表示
void CPlayerAttack::DrawHpBar()
{
	auto hp = task->GetComponent<CPlayer>(CGameManager::PlayerName, 0)->GetHP();
	auto maxHp = task->GetComponent<CPlayer>(CGameManager::PlayerName, 0)->GetMaxHP();

	font(L"E").drawCenter(Float2(10, 30), Palette::Black);

	for (int i = 0; i < ColorMax; i++)
	{
		if (hp > maxHp * i / 7)
		{
			Rect(30, 10, hp / 10, 40).draw(Color[i]);
		}
	}
}
예제 #25
0
	GrassManager::GrassManager()
	{
		mShaderFX = ShaderFXManager::Instance()->Load("Grass", "Shader/MGrass.mfx");

		mWaveDir = Float2(1, 0);
		mWaveSpeed = 0.8f;
		mWaveStrength = 0.15f;
		mVisibleRadius = 2500;

		memset(&mWaveGrid[0], 0, sizeof(mWaveGrid));
		mWaveGridX = mWaveGridZ = 0;
		mWaveLastX = mWaveLastZ = 0;

		GrassTemplate::InitVertex();
	}
예제 #26
0
        OceanMaterialConstants BuildOceanMaterialConstants(const DeepOceanSimSettings& oceanSettings, float shallowGridPhysicalDimension)
        {
            const Float2 physicalDimensions = Float2(oceanSettings._physicalDimensions, oceanSettings._physicalDimensions);
            OceanMaterialConstants result = {
                physicalDimensions[0], physicalDimensions[1], 
                oceanSettings._strengthConstantXY, oceanSettings._strengthConstantZ,
                shallowGridPhysicalDimension, oceanSettings._baseHeight, 
                
                oceanSettings._foamThreshold, oceanSettings._foamIncreaseSpeed,
                oceanSettings._foamIncreaseClamp, oceanSettings._foamDecrease,

                0, 0
            };
            return result;
        }
예제 #27
0
void AppSetup::manageRender()
{
	if (m_isUsingVirtualSize)
	{
		Int2 virtualPos = this->getVirtualTopLeftCornerInWindow();
		Float2 ppp = this->getPixelPerPoint();
		Int2 sizeOrtho2DWindow = this->getSizeOrtho2DWindow();

		this->setPixelPerPointLowLevel(Float2(1.f,1.f), Int2(0,0));
		
		if (m_inf.virtualSizeBorderColor.a() != 0)
		{
			if (m_inf.virtualSize.width() < sizeOrtho2DWindow.width())
			{
				Engine::instance().getScene2DMgr().drawRectangle(
					Int2(0,0), 
					Int2(virtualPos.width(), m_inf.windowSize.height()), 
					m_inf.virtualSizeBorderColor, true);
				Engine::instance().getScene2DMgr().drawRectangle(
					Int2(m_inf.windowSize.width()-virtualPos.width(), 0), 
					m_inf.windowSize,
					m_inf.virtualSizeBorderColor, true);
			}
			else if (m_inf.virtualSize.height() < sizeOrtho2DWindow.height())
			{
				Engine::instance().getScene2DMgr().drawRectangle(
					Int2(0, 0), 
					Int2(m_inf.windowSize.width(), virtualPos.height()), 
					m_inf.virtualSizeBorderColor, true);
				Engine::instance().getScene2DMgr().drawRectangle(
					Int2(0, m_inf.windowSize.height()-virtualPos.height()), 
					m_inf.windowSize,
					m_inf.virtualSizeBorderColor, true);
			}
		}
		
		this->setPixelPerPointLowLevel(ppp, virtualPos);
	}

#if defined(USES_WINDOWS_OPENGL) || defined(USES_LINUX)
	m_openGL->manageOpenGL(m_inf.windowSize);
#else

#endif
}
예제 #28
0
void AppSetup::onResizeWindow(const Int2& newSize)
{
	m_inf.windowSize = newSize;

	Float2 newSizeF = Float2((float)newSize.width(), (float)newSize.height());
	Float2 virtualSizeF = Float2((float)m_inf.virtualSize.width(), (float)m_inf.virtualSize.height());

	if (m_inf.automaticFitToWindowSize && (newSize.width() != m_inf.virtualSize.width() || newSize.height() != m_inf.virtualSize.height()))
	{
		Float2 ppp(-1.f,-1.f);
		Int2 virtualPos(-1,-1);

		float ratioW = (float)newSize.width() / (float)m_inf.virtualSize.width();
		float ratioH = (float)newSize.height() / (float)m_inf.virtualSize.height();
		if (m_inf.virtualSizeAllowRatioDeformation)
		{
			ppp = Float2(ratioW,ratioH);
			virtualPos = Int2(0,0);
		}
		else if (newSizeF.width()/newSizeF.height() > virtualSizeF.width() / virtualSizeF.height())
		{
			ppp = Float2(ratioH,ratioH);
			virtualPos = Int2((int)((newSizeF.width()-virtualSizeF.width()*ratioH)/2.f), 0);
		}
		else
		{
			ppp = Float2(ratioW,ratioW);
			virtualPos = Int2(0, (int)((newSizeF.height()-virtualSizeF.height()*ratioW)/2.f));
		}
		
		this->setPixelPerPointLowLevel(ppp, virtualPos);
	}
	else
	{
		this->setPixelPerPointLowLevel(Float2(1.f,1.f), Int2(0,0));
#if defined(USES_WINDOWS_OPENGL) || defined(USES_LINUX)
		m_openGL->setRealWindowSize(newSize);
		m_openGL->set2DMode();
#else
		// do nothing here
#endif
	}

	m_isUsingVirtualSize = (this->getPixelPerPoint() != Float2(1.f, 1.f) || this->getVirtualTopLeftCornerInWindow() != Int2(0, 0));
}
예제 #29
0
	virtual void OnInit()
	{
		SetupUI();

		// Create Mesh
		MeshSourcePtr pMeshSource = MeshManager::Instance()->LoadMesh("Mesh/fox.mesh");
		
		gMesh = new Mesh;
		gMesh->SetSource(pMeshSource);
		gMesh->LoadAnimation("Idle1", "Mesh/fox_idle1.anim");
		gMesh->SetLighting(true);

		gMesh->PlayAnimation("Idle1");

		LookMesh(gMesh);

		// Setup Main Light
		World::Instance()->MainLight()->SetDirection(Float3(-1, 0, 1));
		World::Instance()->MainLight()->SetAmbient(Float3(0.2f, 0.2f, 0.2f));
		World::Instance()->MainLight()->SetDiffuse(Float3(0.2f, 0.2f, 0.2f));

		// Create Lights
		gLightDir = new Light(eLightType::DIRECTION);
		gLightPoint = new Light(eLightType::POINT);
		gLightSpot = new Light(eLightType::SPOT);

		gLightDir->SetDiffuse(Float3(1, 0, 0));
		gLightPoint->SetDiffuse(Float3(0, 1, 0));
		gLightSpot->SetDiffuse(Float3(0, 0, 1));

		gLightDir->SetVisible(true);
		gLightPoint->SetVisible(false);
		gLightSpot->SetVisible(false);

		// Create Billboard
		gBillboard = new Billboard;
		gBillboard->SetSize(Float2(1, 1));
		gBillboard->SetTexture("flare.png");
		gBillboard->GetMaterial()->blendMode = eBlendMode::ADD;
	}
예제 #30
0
//----------------------------------------------------------------------------
TriMesh* RoughPlaneSolidBox::CreateRamp ()
{
    float x = 8.0f;
    float y = 8.0f;
    float z = y*Mathf::Tan((float)mModule.Angle);

    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);
    int vstride = vformat->GetStride();

    VertexBuffer* vbuffer = new0 VertexBuffer(6, vstride);
    VertexBufferAccessor vba(vformat, vbuffer);

    vba.Position<Float3>(0) = Float3(-x, 0.0f, 0.0f);
    vba.Position<Float3>(1) = Float3(+x, 0.0f, 0.0f);
    vba.Position<Float3>(2) = Float3(-x, y, 0.0f);
    vba.Position<Float3>(3) = Float3(+x, y, 0.0f);
    vba.Position<Float3>(4) = Float3(-x, y, z);
    vba.Position<Float3>(5) = Float3(+x, y, z);
    vba.TCoord<Float2>(0, 0) = Float2(0.25f, 0.0f);
    vba.TCoord<Float2>(0, 1) = Float2(0.75f, 0.0f);
    vba.TCoord<Float2>(0, 2) = Float2(0.0f, 1.0f);
    vba.TCoord<Float2>(0, 3) = Float2(1.0f, 1.0f);
    vba.TCoord<Float2>(0, 4) = Float2(0.25f, 1.0f);
    vba.TCoord<Float2>(0, 5) = Float2(0.75f, 1.0f);

    IndexBuffer* ibuffer = new0 IndexBuffer(18, sizeof(int));
    int* indices = (int*)ibuffer->GetData();
    indices[ 0] = 0;  indices[ 1] = 1;  indices[ 2] = 4;
    indices[ 3] = 1;  indices[ 4] = 5;  indices[ 5] = 4;
    indices[ 6] = 0;  indices[ 7] = 4;  indices[ 8] = 2;
    indices[ 9] = 1;  indices[10] = 3;  indices[11] = 5;
    indices[12] = 3;  indices[13] = 2;  indices[14] = 4;
    indices[15] = 3;  indices[16] = 4;  indices[17] = 5;

    TriMesh* ramp = new0 TriMesh(vformat, vbuffer, ibuffer);

    std::string path = Environment::GetPathR("Metal.wmtf");
    Texture2D* texture = Texture2D::LoadWMTF(path);
    ramp->SetEffectInstance(Texture2DEffect::CreateUniqueInstance(texture,
        Shader::SF_LINEAR, Shader::SC_REPEAT, Shader::SC_REPEAT));

    return ramp;
}