144{
146 {
148
150 {
151 auto pSection = &
g_defblock->m_pSections[ i ];
152 auto pTexture = pRenderer->GetTexture( pSection->GetTextureFile() );
153
154 if ( pSection->GetMaterial() ==
TNULL )
155 {
156 if ( pTexture )
157 {
158 auto pMaterial = pRenderer->CreateMaterial( pTexture );
159 pSection->SetMaterial( pMaterial );
160
161 auto iWidth = pRenderer->GetWidth( pMaterial );
162 auto iHeight = pRenderer->GetHeight( pMaterial );
163
164 auto& uv1 = pSection->GetUVPoint1();
165 uv1.x =
TFLOAT( pSection->GetPoint1X() ) *
TFLOAT( iWidth );
166 uv1.y =
TFLOAT( pSection->GetPoint1Y() ) * ( 1.0f /
TFLOAT( iHeight ) );
167 uv1.z =
TFLOAT( pSection->GetPoint2X() ) *
TFLOAT( iWidth );
168 uv1.w =
TFLOAT( pSection->GetPoint1Y() ) * ( 1.0f /
TFLOAT( iHeight ) );
169
170 auto& uv2 = pSection->GetUVPoint2();
171 uv2.x =
TFLOAT( pSection->GetPoint2X() ) *
TFLOAT( iWidth );
172 uv2.y =
TFLOAT( pSection->GetPoint2Y() ) * ( 1.0f /
TFLOAT( iHeight ) );
173 uv2.z =
TFLOAT( pSection->GetPoint1X() ) *
TFLOAT( iWidth );
174 uv2.w =
TFLOAT( pSection->GetPoint2Y() ) * ( 1.0f /
TFLOAT( iHeight ) );
175 }
176 }
177 else if ( pTexture ==
TNULL )
178 {
179 pRenderer->DestroyMaterial( pSection->GetMaterial() );
180 pSection->SetMaterial(
TNULL );
181 }
182 }
183 }
184}