ScaledTexture::ScaledTexture (const ContextManager& context_manager, TextureManager& texture_manager, const TextureDesc& original_desc, const TextureData* data, unsigned int scaled_width, unsigned int scaled_height) : BindableTexture (context_manager), original_width (original_desc.width), original_height (original_desc.height) { static const char* METHOD_NAME = "render::low_level::opengl::ScaledTexture::ScaledTexture"; if (data) throw xtl::format_not_supported_exception (METHOD_NAME, "Texture initial data not supported (not implemented)"); const ContextCaps& caps = GetCaps (); if (!scaled_width) { if (original_desc.width > caps.max_texture_size) scaled_width = caps.max_texture_size; else scaled_width = get_next_higher_power_of_two (original_desc.width); } if (!scaled_height) { if (original_desc.height > caps.max_texture_size) scaled_height = caps.max_texture_size; else scaled_height = get_next_higher_power_of_two (original_desc.height); } TextureDesc temp_desc = original_desc; temp_desc.width = scaled_width; temp_desc.height = scaled_height; horisontal_scale = (float)scaled_width / (float)original_desc.width; vertical_scale = (float)scaled_height / (float)original_desc.height; ITexture* created_texture = texture_manager.CreateTexture (temp_desc, 0); shadow_texture = TexturePtr (dynamic_cast<BindableTexture*> (created_texture), false); if (!shadow_texture.get ()) throw xtl::format_operation_exception (METHOD_NAME, "TextureManager::CreateTexture returned texture with incompatible type"); LogPrintf ("Warning: scaled texture %ux%ux%u has created for original texture %ux%ux%u@%s", scaled_width, scaled_height, temp_desc.layers, original_desc.width, original_desc.height, original_desc.layers, get_name (original_desc.format)); }
Map::Map(int w, int h) { usingSectors = false; width = w; height = h; texture = 0; GLASSERT(w <= MAX_MAP_SIZE); GLASSERT(h <= MAX_MAP_SIZE); GLOUTPUT(("Map created. %dK\n", int(sizeof(*this)) / 1024)); saturation = 1.0f; gamui::RenderAtom nullAtom; overlayM1.Init(this); overlay0.Init(this); overlay1.Init(this); TextureManager* texman = TextureManager::Instance(); texman->CreateTexture("miniMap", 512, 512, TEX_RGB16, Texture::PARAM_NONE, this); }
void Game::LoadTextures() { TextureManager* texman = TextureManager::Instance(); texman->CreateTexture( "white", 2, 2, TEX_RGB16, Texture::PARAM_NONE, this ); }
Model::Model(ID3D11Device* device, TextureManager& texMgr, const std::string& modelFilename, const std::string& texturePath) { //std::vector<M3dMaterial> mats; std::vector<MaterialLoader> mats; //M3DLoader m3dLoader; //m3dLoader.LoadM3d(modelFilename, Vertices, Indices, Subsets, mats); ModelLoader loader; loader.Load(modelFilename, Vertices, Indices, Subsets, mats, SkinnedData); ModelMesh.SetVertices(device, &Vertices[0], Vertices.size()); ModelMesh.SetIndices(device, &Indices[0], Indices.size()); ModelMesh.SetSubsetTable(Subsets); SubsetCount = mats.size(); TPM = mats[0].DiffuseMapNames.size(); for(UINT i = 0; i < SubsetCount; ++i) { Mat.push_back(mats[i].Mat); for (int j = 0; j < mats[i].DiffuseMapNames.size(); ++j) { if (mats[i].DiffuseMapNames[j] != "") { ID3D11ShaderResourceView* diffuseMapSRV = texMgr.CreateTexture(texturePath + mats[i].DiffuseMapNames[j]); if (diffuseMapSRV) DiffuseMapSRV.push_back(diffuseMapSRV); } } for (int j = 0; j < mats[i].NormalMapNames.size(); ++j) { if (mats[i].NormalMapNames[j] != "") { ID3D11ShaderResourceView* normalMapSRV = texMgr.CreateTexture(texturePath + mats[i].NormalMapNames[j]); if (normalMapSRV) NormalMapSRV.push_back(normalMapSRV); } } /* if (mats[i].DiffuseMapName != "") { ID3D11ShaderResourceView* diffuseMapSRV = texMgr.CreateTexture(texturePath + mats[i].DiffuseMapName); if (diffuseMapSRV) DiffuseMapSRV.push_back(diffuseMapSRV); } if (mats[i].NormalMapName != "") { ID3D11ShaderResourceView* normalMapSRV = texMgr.CreateTexture(texturePath + mats[i].NormalMapName); if (normalMapSRV) NormalMapSRV.push_back(normalMapSRV); }*/ } m_BoneBoxes = SkinnedData.CreateBoneBoxes(Vertices); if (m_BoneBoxes.size() == 0) { //BoundingSphere::CreateFromPoints(m_BoundingSphere, Vertices.size(), &Vertices[0].Pos, sizeof(Vertex::PosNormalTexTanSkinned)); BoundingBox AABB; BoundingBox::CreateFromPoints(AABB, Vertices.size(), &Vertices[0].Pos, sizeof(Vertex::PosNormalTexTanSkinned)); BoundingOrientedBox::CreateFromBoundingBox(m_BoundingOrientedBox, AABB); XMFLOAT3 Extents = m_BoundingOrientedBox.Extents; m_SmallestRadiusInBox = ( Extents.x > Extents.z ) ? Extents.z : Extents.x; BoundingSphere::CreateFromBoundingBox(m_BoundingSphere, m_BoundingOrientedBox); } else { AnimationClip* AC = SkinnedData.GetAnimation("ALL"); if (AC) { UINT numKeyFrames = AC->BoneAnimations[0].Keyframes.size(); std::vector<XMFLOAT3> bigBoxPoints; m_SmallestRadiusInBox = 99999; for (int i = 0; i < numKeyFrames; ++i) { float time = AC->BoneAnimations[0].Keyframes[i].TimePos; std::vector<XMFLOAT4X4> FinalTransforms(AC->BoneAnimations.size()); SkinnedData.GetFinalTransforms("ALL", time, FinalTransforms); std::vector<DirectX::BoundingOrientedBox> tempboxes(m_BoneBoxes.size()); for (int i = 0; i < m_BoneBoxes.size(); ++i) { m_BoneBoxes[i].Transform(tempboxes[i], XMLoadFloat4x4(&FinalTransforms[i])); } std::vector<XMFLOAT3> points; for (int i = 0; i < tempboxes.size(); ++i) { XMFLOAT3 corners[BoundingOrientedBox::CORNER_COUNT]; tempboxes[i].GetCorners(&corners[0]); for each (XMFLOAT3 point in corners) { points.push_back(point); bigBoxPoints.push_back(point); } } BoundingBox AABB; BoundingBox::CreateFromPoints(AABB, points.size(), &points[0], sizeof(XMFLOAT3)); XMFLOAT3 Extents = AABB.Extents; m_SmallestRadiusInBox = min(m_SmallestRadiusInBox, min(min(Extents.x, Extents.z), Extents.y)); } BoundingBox AABB; BoundingBox::CreateFromPoints(AABB, bigBoxPoints.size(), &bigBoxPoints[0], sizeof(XMFLOAT3)); BoundingOrientedBox::CreateFromBoundingBox(m_BoundingOrientedBox, AABB); BoundingSphere::CreateFromBoundingBox(m_BoundingSphere, m_BoundingOrientedBox); } //m_SmallestRadiusInBox = 10; /* BoundingSphere::CreateFromBoundingBox(m_BoundingSphere, m_BoundingOrientedBox); BoundingOrientedBox::CreateFromBoundingBox(m_BoundingOrientedBox, AABB); BoundingSphere::CreateFromBoundingBox(m_BoundingSphere, m_BoundingOrientedBox); */ }