void SkyBox::SetCubeTex(const wchar_t* cubeTexName) { SAFE_DROP(mCubeTex); mCubeTex = gEngine->GetTextureManger()->GetCubeTexture(cubeTexName); mCubeTex->Grab(); }
CSoundData :: CSoundData ( const c8* filename ) { #if MY_DEBUG_MODE IUnknown::setClassName("CSoundData"); #endif ok = false; readfile = NULL; io::IReadFile *rfile = FILE_SYSTEM.createAndOpenFile(filename); if (rfile) { c8* rdata = new c8 [rfile->getSize()]; s32 rsize = rfile->read(rdata, rfile->getSize()); readfile = FILE_SYSTEM.createMemoryReadFile(rdata, rsize, filename, true); SAFE_DROP(rfile); numChannels = 0; frequency = 0; bitsPerSample = 8; ok = true; } }
void CTestSceneNode::setPrimitiveType(E_GEOM_PRIMITIVE_TYPE type) { if (m_GeomPrimitiveType==type) return; m_GeomPrimitiveType = type; SAFE_DROP(m_PrimitiveMesh); if (m_GeomPrimitiveType==EGPT_BOX) { m_PrimitiveMesh = SCENE_MANAGER.getMesh("#box_mesh"); } else if (m_GeomPrimitiveType==EGPT_SPHERE) { m_PrimitiveMesh = SCENE_MANAGER.getMesh("#sphere_mesh"); } else if (m_GeomPrimitiveType==EGPT_CYLINDER) { m_PrimitiveMesh = SCENE_MANAGER.getMesh("#cylinder_mesh"); } else { m_PrimitiveMesh = SCENE_MANAGER.getMesh("#caped_cylinder_mesh"); } SAFE_GRAB(m_PrimitiveMesh); m_BoundingBox = m_PrimitiveMesh->getBoundingBox(); }
void ShadowMapRenderer::Destory() { for(int i = 0; i < CASCADE_COUNTS; ++i) { SAFE_DROP(mShadowMapBluredTex[i]); } SAFE_DROP(mShadowMapBluredTexH); SAFE_DROP(mShadowMapTex); SAFE_DROP(mShadowTex); SAFE_RELEASE(mShadowMapRTSurface); SAFE_RELEASE(mDepthStencilSurface); SAFE_RELEASE(mBlurQuadVB); }
SkyBox::~SkyBox() { SAFE_RELEASE(mVertexBuffer); SAFE_RELEASE(mIndexBuffer); SAFE_DROP(mCubeTex); }
//! destructor CSceneNodeAnimatorTexture::~CSceneNodeAnimatorTexture() { for (u32 ts=0; ts<m_DirectionSets.size(); ++ts) { for (u32 i=0; i<m_DirectionSets[ts].size(); ++i) SAFE_DROP(m_DirectionSets[ts][i].Texture); } }
void CTextSceneNode::setFont(vid::IFont *font) { if (!font) return; SAFE_DROP(m_Font); m_Font = font; SAFE_GRAB(m_Font); }
void SkyBox::SetCubeTex(CubeTexture* cubeTex) { _Assert(NULL != cubeTex); SAFE_DROP(mCubeTex); mCubeTex = cubeTex; mCubeTex->Grab(); }
bool CImageSaverDevIL::saveImage(IImage* image, io::IWriteFile* file) { bool res = false; CImageDevIL *image_devil = new CImageDevIL(); image_devil->imageFrom(image); res = image_devil->saveTo(file); SAFE_DROP(image_devil); return res; }
PartResource::~PartResource() { SAFE_DROP(m_meshResource); for (VECTOR(MaterialResource*)::iterator iter = m_materialResources.begin(); iter != m_materialResources.end(); ++iter) { (*iter)->drop(); } }
//! загружает изображение из файла IImage* CImageLoader::loadImage(const c8* fileName) { io::IReadFile *file = FILE_SYSTEM.createAndOpenFile(fileName); IImage* image = loadImage(file); SAFE_DROP(file); return image; }
void CWin32CursorControl::resetGraphicCursor() { if (m_CursorTexture && m_IsVisible) ShowCursor(true); SAFE_DROP(m_CursorTexture); m_CenteredCursor = true; m_CursorOveralOffset.set(0,0); m_CursorOffset.set(0.0f, 0.0f); m_CursorSize.set(1, 1); }
void CSceneNodeAnimatorTexture::setFramesDirectionSet( u32 direction_idx, const core::array<SAnimationFrame> &frames) { if (direction_idx >= m_DirectionSets.size()) for (u32 d = m_DirectionSets.size(); d <= direction_idx; d++) m_DirectionSets.push_back(core::array<SAnimationFrame>()); u32 i=0; for (i=0; i < m_DirectionSets[direction_idx].size(); ++i) SAFE_DROP(m_DirectionSets[direction_idx][i].Texture); m_DirectionSets[direction_idx].set_used(0); for (i = 0; i < frames.size(); ++i) { m_DirectionSets[direction_idx].push_back(frames[i]); SAFE_GRAB(frames[i].Texture); } }
//! setting cursor void CWin32CursorControl::setGraphicCursor( vid::ITexture *tex, const core::dimension2df &size, const core::vector2df &offset, bool centered ) { if (!m_CursorTexture && m_IsVisible) ShowCursor(false); SAFE_DROP(m_CursorTexture); m_CursorTexture = tex; setRelativeSize(size); m_CursorOffset.set(offset.X*m_WindowSize.Width, offset.Y*m_WindowSize.Height); m_CenteredCursor = centered; _calculateCursorOffsetValue(); SAFE_GRAB(m_CursorTexture); }
//! destructor CWin32CursorControl::~CWin32CursorControl() { SAFE_DROP(m_CursorTexture); }
void CTextureAnim::clear() { for (u32 t=0; t<Frames.size(); t++) SAFE_DROP(Frames[t]); Frames.clear(); }
//! destructor CTestSceneNode::~CTestSceneNode() { SAFE_DROP(m_PrimitiveMesh); }
void OBJParser::parseTrianglesBlockLine(const wchar_t* lineContent, Geometry** curGeo, std::map<int, int>& posIndexMap, std::map<int, int>& uvIndexMap, std::map<int, int>& normalIndexMap, std::map<Vector3, int, Vector3::Comparer>& vertIndexMap) { Assert(NULL != lineContent); { OBJ_SPECIFIER specifier = OBJ_OTEHR; getOBJSpecifier(lineContent, &specifier); switch(specifier) { case MESH_MTL: { Material* material = NULL; { wchar_t mtlName[MAX_STR_LEN]; YString::Scan(lineContent, L"%*s %s", mtlName); getMaterial(mtlName, &material); Assert(NULL != material); } // 为使用mtlName材质的triangleList创建一个geo, 此mtl和geo共同构成一个subMesh Mesh* subMesh = NULL; { Assert((*curGeo) == NULL); wchar_t fileName[MAX_STR_LEN]; wchar_t geoName[MAX_STR_LEN]; wchar_t meshName[MAX_STR_LEN]; YString::GetFileName(fileName, _countof(fileName), mFilePath, false); YString::Format(geoName, L"%s_geo_%d", fileName, mGeoList.size()); YString::Format(meshName, L"%s_mesh_%d", fileName, mGeoList.size()); (*curGeo) = New Geometry(geoName); mGeoList.push_back((*curGeo)); if(mResultModel == NULL) { mResultModel = New Model(fileName); } subMesh = New Mesh(meshName, (*curGeo), material); mResultModel->AddSubMesh(subMesh); SAFE_DROP(subMesh); } break; } case FACE: { int posIndex[4] = { -1, -1, -1, -1 }; int uvIndex[4] = { -1, -1, -1, -1 }; int normalIndex[4] = { -1, -1, -1, -1 }; if(((mDataContentType & UV_DATA) == 0) && ((mDataContentType & NORMAL_DATA) == 0)) { YString::Scan(lineContent, L"%*c %d %d %d %d", &posIndex[0], &posIndex[1], &posIndex[2], &posIndex[3]); } else if(((mDataContentType & UV_DATA) == 0) && ((mDataContentType & NORMAL_DATA) != 0)) { YString::Scan(lineContent, L"%*c %d//%d %d//%d %d//%d %d//%d", &posIndex[0], &normalIndex[0], &posIndex[1], &normalIndex[1], &posIndex[2], &normalIndex[2], &posIndex[3], &normalIndex[3]); } else if(((mDataContentType & UV_DATA) != 0) && ((mDataContentType & NORMAL_DATA) == 0)) { YString::Scan(lineContent, L"%*c %d/%d %d/%d %d/%d %d/%d", &posIndex[0], &uvIndex[0], &posIndex[1], &uvIndex[1], &posIndex[2], &uvIndex[2], &posIndex[3], &uvIndex[3]); } else if(((mDataContentType & UV_DATA) != 0) && ((mDataContentType & NORMAL_DATA) != 0)) { YString::Scan(lineContent, L"%*c %d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d", &posIndex[0], &uvIndex[0], &normalIndex[0], &posIndex[1], &uvIndex[1], &normalIndex[1], &posIndex[2], &uvIndex[2], &normalIndex[2], &posIndex[3], &uvIndex[3], &normalIndex[3]); if(uvIndex[0] == -1 && uvIndex[1] == -1 && uvIndex[2] == -1 && uvIndex[3] == -1) { // 包含uvData但face未使用的情况 YString::Scan(lineContent, L"%*c %d//%d %d//%d %d//%d %d//%d", &posIndex[0], &normalIndex[0], &posIndex[1], &normalIndex[1], &posIndex[2], &normalIndex[2], &posIndex[3], &normalIndex[3]); } } int vertIndex[4] = { -1, -1, -1, -1 }; Vector3 vert[4]; vert[0] = Vector3((float)posIndex[0] - 1, (float)uvIndex[0] - 1, (float)normalIndex[0] - 1); vert[1] = Vector3((float)posIndex[1] - 1, (float)uvIndex[1] - 1, (float)normalIndex[1] - 1); vert[2] = Vector3((float)posIndex[2] - 1, (float)uvIndex[2] - 1, (float)normalIndex[2] - 1); vert[3] = Vector3((float)posIndex[3] - 1, (float)uvIndex[3] - 1, (float)normalIndex[3] - 1); for(int i = 0; i < 4; ++i) { if(i == 3 && posIndex[i] == -1) // 三角面 break; // OBJ文件是从1开始的, 减1变成从0开始 Assert((posIndex[i] -= 1) >= 0); int curGeoPosIndex = -1; int curGeoUVIndex = -1; int curGeoNormalIndex = -1; //int curVertIndex = -1; int& curVertIndex = vertIndex[i]; bool posIndexExist = posIndexMap.find(posIndex[i]) != posIndexMap.end(); if(posIndexExist) { curGeoPosIndex = posIndexMap[posIndex[i]]; } else { curGeoPosIndex = (*curGeo)->mGeoData.posData.size(); (*curGeo)->mGeoData.posData.push_back(mPosData[posIndex[i]]); posIndexMap[posIndex[i]] = curGeoPosIndex; } if((mDataContentType & UV_DATA) != 0 && (uvIndex[i] -= 1) >= 0) // 有包含uvData但face未使用的情况 { bool uvIndexExist = uvIndexMap.find(uvIndex[i]) != uvIndexMap.end(); if(uvIndexExist) { curGeoUVIndex = uvIndexMap[uvIndex[i]]; } else { curGeoUVIndex = (*curGeo)->mGeoData.uvData.size(); (*curGeo)->mGeoData.uvData.push_back(uvData[uvIndex[i]]); uvIndexMap[uvIndex[i]] = curGeoUVIndex; } } if((mDataContentType & NORMAL_DATA) != 0) { Assert((normalIndex[i] -= 1) >= 0); bool normalIndexExist = uvIndexMap.find(uvIndex[i]) != uvIndexMap.end(); if(normalIndexExist) { curGeoNormalIndex = normalIndexMap[normalIndex[i]]; } else { curGeoNormalIndex = (*curGeo)->mGeoData.normalData.size(); (*curGeo)->mGeoData.normalData.push_back(normalData[normalIndex[i]]); normalIndexMap[normalIndex[i]] = curGeoNormalIndex; } } bool isVertExist = vertIndexMap.find(vert[i]) != vertIndexMap.end(); if(isVertExist) { curVertIndex = vertIndexMap[vert[i]]; } else { curVertIndex = (*curGeo)->mGeoData.verts.size(); Vert newVert(curGeoPosIndex, curGeoUVIndex, curGeoNormalIndex); (*curGeo)->mGeoData.verts.push_back(newVert); vertIndexMap[vert[i]] = curVertIndex; } } Triangle tri1; tri1.vertexIndex[0] = vertIndex[0]; tri1.vertexIndex[1] = vertIndex[1]; tri1.vertexIndex[2] = vertIndex[2]; (*curGeo)->mGeoData.tris.push_back(tri1); if(vertIndex[3] != -1) { Triangle tri2; tri2.vertexIndex[0] = vertIndex[0]; tri2.vertexIndex[1] = vertIndex[2]; tri2.vertexIndex[2] = vertIndex[3]; (*curGeo)->mGeoData.tris.push_back(tri2); } break; } case OBJ_OTEHR: { break; } } } Exit: return; }
CSoundData :: ~CSoundData () { SAFE_DROP(readfile); }
CTextSceneNode::~CTextSceneNode() { SAFE_DROP(m_Font); }