示例#1
0
bool CSkin::Unload()
{
    bool bRet = IsLoaded();
    if (bRet)
    {
        CRenderer* pRenderer = CRenderer::GetInstance();
        pRenderer->DeleteBuffers(2, m_uVBO);
        pRenderer->DeleteBuffers(1, &m_uVAO);
        SetLoadedFlag(false);
    }
    return bRet;
}
示例#2
0
bool CSkeleton::Load()
{
    bool bRet = true;
    // Load From File
    CSerializer serializer(_T("..\\Resource\\skeleton\\org.ske"));
    size_t uBoneCount = 0;
    serializer >> uBoneCount;
    for (size_t i = 0; i < uBoneCount; ++i)
    {
        ESkeletonBoneType boneType = eSBT_Count;
        serializer >> boneType;
        BEATS_ASSERT(boneType < eSBT_Count, _T("Invalid bone type!"));
        ESkeletonBoneType boneParentType = eSBT_Count;
        serializer >> boneParentType;
        BEATS_ASSERT(boneParentType < eSBT_Count, _T("Invalid bone type!"));

        SharePtr<CSkeletonBone> pNullParentBone;
        SharePtr<CSkeletonBone> _pSkeletonBone = new CSkeletonBone(pNullParentBone, boneType);
        _pSkeletonBone->SetParentType(boneParentType);
        kmMat4  _TPosMatrix;
        serializer >> _TPosMatrix.mat[0] >> _TPosMatrix.mat[1] >> _TPosMatrix.mat[2] >> _TPosMatrix.mat[3] 
                   >> _TPosMatrix.mat[4] >> _TPosMatrix.mat[5] >> _TPosMatrix.mat[6] >> _TPosMatrix.mat[7]
                   >> _TPosMatrix.mat[8] >> _TPosMatrix.mat[9] >> _TPosMatrix.mat[10] >> _TPosMatrix.mat[11]
                   >> _TPosMatrix.mat[12] >> _TPosMatrix.mat[13] >> _TPosMatrix.mat[14] >> _TPosMatrix.mat[15];
        _pSkeletonBone->SetTPosMatrix( _TPosMatrix );
        m_bonesMap[boneType] = _pSkeletonBone;
    }

    //Fill the parent
    std::map<ESkeletonBoneType, SharePtr<CSkeletonBone>>::iterator iter = m_bonesMap.begin();
    for (; iter != m_bonesMap.end(); ++iter)
    {
        ESkeletonBoneType parentType = iter->second->GetParentType();
        if (parentType != eSBT_Null)
        {
            std::map<ESkeletonBoneType, SharePtr<CSkeletonBone>>::iterator parentIter = m_bonesMap.find(parentType);
            BEATS_ASSERT(parentIter != m_bonesMap.end());
            iter->second->SetParent(parentIter->second);
        }
    }
    SetLoadedFlag(true);
    return bRet;
}
示例#3
0
bool CSkin::Load()
{
    bool bRet = false;
    BEATS_ASSERT(!IsLoaded(), _T("Can't Load a skin which is already loaded!"));

    // Load From File
    CSerializer serializer(_T("..\\Resource\\skin\\org.skin"));
    CSerializer tmpVerticesBufferPos, tmpVerticesBufferUV;
    CSerializer indexBuffer;
    size_t uVertexCount = 0;
    serializer >> uVertexCount;
    m_uVertexCount = uVertexCount;
    m_vertices = new CVertexPTB[uVertexCount];
    float x, y, z;
    float u,v;

    for (size_t i = 0; i < uVertexCount; ++i)
    {
        ESkeletonBoneType bone, bone1, bone2, bone3;
        float weight, weight1, weight2,weight3;
        serializer >> x >> y >> z >> u >> v;
        serializer >> bone;
        serializer >> weight;
        serializer >> bone1;
        serializer >> weight1;
        serializer >> bone2;
        serializer >> weight2;
        serializer >> bone3;
        serializer >> weight3;

        CVertexPTB &vertex = m_vertices[i];
        kmVec3Fill(&vertex.position,x,y,z);
        vertex.tex = CTex(u,v);
        vertex.bones = CIVector4(bone, bone1, bone2, bone3);
        kmVec4Fill(&vertex.weights,weight,weight1,weight2,weight3);

#ifdef _DEBUG
        float sum = weight + weight1 + weight2+weight3;
        BEATS_ASSERT(sum < 1.01F, _T("Weight can't be greater than 1.01F, cur Value : %f!"), sum);
        BEATS_WARNING(sum > 0.99F, _T("Weight can't be smaller than 0.99F, cur Value : %f!"), sum);
#endif
    }
    
    for (size_t i = 0; i < uVertexCount; ++i)
    {
        indexBuffer << (short)i;
    }

    CRenderer* pRenderer = CRenderer::GetInstance();
    pRenderer->GenVertexArrays(1, &m_uVAO);
    pRenderer->GenBuffers(2, m_uVBO);

#ifndef SW_SKEL_ANIM
    buildVBOVertex(m_vertices, m_uVertexCount*sizeof(CVertexPTB));
    BEATS_SAFE_DELETE_ARRAY(m_vertices);
#endif
    buildVBOIndex(indexBuffer.GetBuffer(), indexBuffer.GetWritePos());
    buildVAO();

    SetLoadedFlag(true);

    return bRet;
}
示例#4
0
bool CSpriteAnimation::Unload()
{
    SetLoadedFlag(false);
    return true;
}
示例#5
0
bool CSpriteAnimation::Load()
{
    SetLoadedFlag(true);
    return true;
}
示例#6
0
bool CColorScheme::Load(LPCTSTR pszFileName,bool fLegacy)
{
	CSettings Settings;
	TCHAR szText[MAX_COLORSCHEME_NAME];
	int i;

	if (!Settings.Open(pszFileName,TEXT("ColorScheme"),CSettings::OPEN_READ))
		return false;
	if (Settings.Read(TEXT("Name"),szText,lengthof(szText)))
		SetName(szText);
	::ZeroMemory(m_LoadedFlags,sizeof(m_LoadedFlags));
	for (i=0;i<NUM_COLORS;i++) {
		if (Settings.ReadColor((fLegacy?m_ColorInfoLegacyList:m_ColorInfoList)[i].pszText,&m_ColorList[i]))
			SetLoadedFlag(i);
	}
	for (i=0;i<NUM_COLORS;i++) {
		if (IsLoaded(i)) {
			for (int j=0;j<NUM_GRADIENTS;j++) {
				if (m_GradientInfoList[j].Color1==i
						|| m_GradientInfoList[j].Color2==i) {
					if (m_GradientInfoList[j].Color1==i
							&& !IsLoaded(m_GradientInfoList[j].Color2)) {
						m_ColorList[m_GradientInfoList[j].Color2]=m_ColorList[i];
						SetLoadedFlag(m_GradientInfoList[j].Color2);
					}
					m_GradientList[j].Type=Theme::GRADIENT_NORMAL;
					break;
				}
			}
		} else {
			static const struct {
				int To,From;
			} Map[] = {
			//	{COLOR_STATUSBORDER,						COLOR_STATUSBACK1},
				{COLOR_STATUSBOTTOMITEMBACK1,				COLOR_STATUSBACK2},
				{COLOR_STATUSBOTTOMITEMBACK2,				COLOR_STATUSBOTTOMITEMBACK1},
				{COLOR_STATUSBOTTOMITEMTEXT,				COLOR_STATUSTEXT},
				{COLOR_STATUSBOTTOMITEMBORDER,				COLOR_STATUSBOTTOMITEMBACK1},
			};

			static const struct {
				int To,From1,From2;
			} MixMap[] = {
				{COLOR_STATUSBORDER,		COLOR_STATUSBACK1,			COLOR_STATUSBACK2},
			};

			bool fFound=false;

			for (int j=0;j<lengthof(Map);j++) {
				if (Map[j].To==i && IsLoaded(Map[j].From)) {
					m_ColorList[i]=m_ColorList[Map[j].From];
					SetLoadedFlag(i);
					fFound=true;
					break;
				}
			}

			if (!fFound) {
				for (int j=0;j<lengthof(MixMap);j++) {
					if (MixMap[j].To==i && IsLoaded(MixMap[j].From1) && IsLoaded(MixMap[j].From2)) {
						m_ColorList[i]=MixColor(m_ColorList[MixMap[j].From1],m_ColorList[MixMap[j].From2]);
						SetLoadedFlag(i);
						break;
					}
				}
			}
		}
	}

	for (i=0;i<NUM_GRADIENTS;i++) {
		if (Settings.Read(m_GradientInfoList[i].pszText,szText,lengthof(szText))) {
			if (szText[0]=='\0' || ::lstrcmpi(szText,TEXT("normal"))==0)
				m_GradientList[i].Type=Theme::GRADIENT_NORMAL;
			else if (::lstrcmpi(szText,TEXT("glossy"))==0)
				m_GradientList[i].Type=Theme::GRADIENT_GLOSSY;
			else if (::lstrcmpi(szText,TEXT("interlaced"))==0)
				m_GradientList[i].Type=Theme::GRADIENT_INTERLACED;
		}

		TCHAR szName[128];
		::wsprintf(szName,TEXT("%sDirection"),m_GradientInfoList[i].pszText);
		m_GradientList[i].Direction=m_GradientInfoList[i].Direction;
		if (Settings.Read(szName,szText,lengthof(szText))) {
			for (int j=0;j<lengthof(GradientDirectionList);j++) {
				if (::lstrcmpi(szText,GradientDirectionList[j])==0) {
					m_GradientList[i].Direction=(Theme::GradientDirection)j;
					break;
				}
			}
		}
	}

	Settings.Close();

	for (i=0;i<NUM_BORDERS;i++)
		m_BorderList[i]=m_BorderInfoList[i].DefaultType;
	if (Settings.Open(pszFileName,TEXT("Style"),CSettings::OPEN_READ)) {
		for (i=0;i<NUM_BORDERS;i++) {
			if (Settings.Read(m_BorderInfoList[i].pszText,szText,lengthof(szText))) {
				if (::lstrcmpi(szText,TEXT("none"))==0) {
					if (!m_BorderInfoList[i].fAlways)
						m_BorderList[i]=Theme::BORDER_NONE;
				} else if (::lstrcmpi(szText,TEXT("solid"))==0)
					m_BorderList[i]=Theme::BORDER_SOLID;
				else if (::lstrcmpi(szText,TEXT("sunken"))==0)
					m_BorderList[i]=Theme::BORDER_SUNKEN;
				else if (::lstrcmpi(szText,TEXT("raised"))==0)
					m_BorderList[i]=Theme::BORDER_RAISED;
			}
		}
		Settings.Close();
	}

	SetFileName(pszFileName);
	return true;
}