Exemplo n.º 1
0
        void KeepAspectMaskSubSkin::setMask(Sandbox::Graphics& g,const TexturePtr& texture,const MyGUI::FloatRect& uv) {
            if (!texture) return;
            Sandbox::Transform2d mTr = Sandbox::Transform2d();
            
            int x = mCroppedParent->getAbsoluteLeft();
            int y = mCroppedParent->getAbsoluteTop();
            int w = mCroppedParent->getWidth();
            int h = mCroppedParent->getHeight();
            
            float tw = uv.width() * texture->GetWidth();
            float th = uv.height() * texture->GetHeight();
            
            float sx = float(w) / tw;
            float sy = float(h) / th;
            
            float s = (sx > sy) ? sx : sy;
            
            float uvdx = (tw - float(w)/s) * 0.5f / texture->GetWidth();
            float uvdy = (th - float(h)/s) * 0.5f / texture->GetHeight();
            
            float uvsw = (1.0f/(s * texture->GetWidth() ) );
            float uvsh = (1.0f/(s * texture->GetHeight() ) );

            mTr.translate(uv.left+uvdx,uv.top+uvdy);
            mTr.scale(uvsw, uvsh);
            mTr.translate(-x,-y);
            
            g.SetMask(MASK_MODE_ALPHA, texture, mTr);
        }
Exemplo n.º 2
0
RenderTargetPtr D3D9VideoBufferManager::CreateRenderTarget(TexturePtr rtTex)
{
	int rWidth = rtTex->GetWidth(), rHeight = rtTex->GetHeight(); 

	if (rWidth == -1 || rHeight == -1)
	{
		rWidth = Engine::Instance()->GetDeviceProperty()->Width;
		rHeight = Engine::Instance()->GetDeviceProperty()->Height;
	}

	IDirect3DSurface9 * pD3D9RenderTarget = NULL;

	D3D9RenderTarget * pTexture = new D3D9RenderTarget(mD3D9Device);

	pTexture->mName = rtTex->GetName();
	pTexture->mWidth = rWidth;
	pTexture->mHeight = rHeight;
	pTexture->mFormat = rtTex->GetFormat();
	pTexture->mMSAA = MSAA_NONE;
	pTexture->mTexture = rtTex;

	D3D9Texture * d3dTex = (D3D9Texture *)rtTex.c_ptr();

	d3dTex->GetD3DTexture()->GetSurfaceLevel(0, &pTexture->mRenderTarget);

	mRenderTargets.Insert(pTexture->GetName(), pTexture);

	return RenderTargetPtr(pTexture);
}
Exemplo n.º 3
0
GfxSystem::GfxViewport::GfxViewport( ResourceSystem::ResourcePtr texture ):
	mPosition(Vector2_Zero),
	mSize(Vector2_Zero),
	mTexture(InvalidTextureHandle),
	mRelativeScale(false),
	mGridEnabled(true)
{
	OC_ASSERT(texture->GetType() == ResourceSystem::RESTYPE_TEXTURE);
	TexturePtr textureResource = (TexturePtr)texture; 
	mTexture = textureResource->GetTexture();
	mSize.x = (float32)textureResource->GetWidth();
	mSize.y = (float32)textureResource->GetHeight();
}
Exemplo n.º 4
0
 void MaskImageWidget::update_shader() {
     if (m_shader && getImage() && getImage()->GetTexture()) {
         TexturePtr texture = getImage()->GetTexture();
         ShaderVec2UniformPtr u = m_shader->GetVec2Uniform("texture_size");
         if (u) {
             u->SetValue(Vector2f(texture->GetWidth(),texture->GetHeight()));
         }
         u = m_shader->GetVec2Uniform("orig_texture_size");
         if (u) {
             u->SetValue(Vector2f(texture->GetOriginalWidth(),texture->GetOriginalHeight()));
         }
     }
 }
Exemplo n.º 5
0
void SphereCollision::RadiusFromTexture(TexturePtr texture)
{
    mOriginalRadius = static_cast<float>(Math::Max(texture->GetHeight() / 2,
                                         texture->GetHeight() / 2));
}