Beispiel #1
0
    /**
    * 計測開始
    */
    void CTimer::Begin()
    {
        LARGE_INTEGER sBegin;
        FILL_ZERO(&sBegin, sizeof(sBegin));

        IZ_BOOL result = QueryPerformanceCounter(&sBegin);
        IZ_ASSERT(result);

        m_Begin = sBegin.QuadPart;
    }
Beispiel #2
0
    /**
    * Allocate memory buffer (with filling zero).
    */
    void* CChunkedMemoryAllocator::AllocZero(size_t size, const IZ_CHAR* file, IZ_UINT line)
    {
        size = _ComputeAlignValue(size, m_nChunkSize);

        void* ret = Alloc(size, file, line);
        if (ret != IZ_NULL) {
            FILL_ZERO(ret, size);
        }
        return ret;
    }
Beispiel #3
0
    // 現在の時間取得
    IZ_INT64 CTimer::GetCurTime()
    {
        LARGE_INTEGER time;
        FILL_ZERO(&time, sizeof(time));

        IZ_BOOL result = QueryPerformanceCounter(&time);
        IZ_ASSERT(result);

        IZ_INT64 ret = time.QuadPart;
        return ret;
    }
Beispiel #4
0
    static inline void InitTimer()
    {
        if (s_Frequency == 0) {
            LARGE_INTEGER sFreq;
            FILL_ZERO(&sFreq, sizeof(sFreq));

            IZ_BOOL result = QueryPerformanceFrequency(&sFreq);
            IZ_ASSERT(result);

            s_Frequency = sFreq.QuadPart;
        }
    }
Beispiel #5
0
//bDeleteParent=trueのとき、Path自身も削除する
//bDeleteParent=falseのときは、Pathの中身だけ削除する
bool UtilDeleteDir(LPCTSTR Path,bool bDeleteParent)
{
	WIN32_FIND_DATA lp;

	TCHAR FindParam[_MAX_PATH+1];
	FILL_ZERO(FindParam);
	_tcsncpy_s(FindParam,Path,_MAX_PATH);
	PathAppend(FindParam,_T("*"));
	HANDLE h=FindFirstFile(FindParam,&lp);

	bool bRet=true;

	do{
		if((lp.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)&& 0!=_tcscmp(lp.cFileName,_T("..")) && 0!=_tcscmp(lp.cFileName,_T(".")))
		{
			CString SubPath=Path;
			SubPath+=_T("\\");
			SubPath+=lp.cFileName;

			bRet=bRet&&UtilDeleteDir(SubPath,true);
		}
		if((lp.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)!=FILE_ATTRIBUTE_DIRECTORY)
		{
			// lp.cFileNameでファイル名が分かる
			TCHAR FileName[_MAX_PATH+1];
			FILL_ZERO(FileName);
			_tcsncpy_s(FileName,Path,_MAX_PATH);
			PathAppend(FileName,lp.cFileName);

			bRet=bRet&&UtilDeletePath(FileName);
		}
	}while(FindNextFile(h,&lp));

	FindClose(h);
	if(bDeleteParent){
		bRet=bRet&&UtilDeletePath(Path);
	}

	return bRet;
}
Beispiel #6
0
void CIconSelectDialog::OnBrowseDefault(UINT uNotifyCode, int nID, HWND hWndCtl)
{
    TCHAR ResourcePath[_MAX_PATH+1];
    FILL_ZERO(ResourcePath);
    GetModuleFileName(GetModuleHandle(NULL), ResourcePath, _MAX_PATH);	//本体のパス取得
    //EXEのパスを元にDLLのファイル名を組み立てる
    PathRemoveFileSpec(ResourcePath);
    PathAppend(ResourcePath,CString(MAKEINTRESOURCE(IDS_ICON_FILE_NAME_DEFAULT)));
    IconPath=ResourcePath;

    DoDataExchange(FALSE);
    UpdateIcon();
}
Beispiel #7
0
/**
* シェーダ解析
*/
BOOL CPostEffectConverter::Export(LPCSTR lpszOutFile)
{
    IZ_ASSERT(m_pCgEffect != NULL);

    VRETURN(m_Out.Open(lpszOutFile));

    // ファイルヘッダ
    {
        FILL_ZERO(&m_PesHeader, sizeof(m_PesHeader));

        // TODO
        // magic
        // version

        m_PesHeader.sizeHeadaer = sizeof(m_PesHeader);
    }

    // ファイルヘッダ分空ける
    VRETURN(m_Out.Seek(sizeof(m_PesHeader), izanagi::E_IO_STREAM_SEEK_POS_START));

    ExportParameter();
    ExportTexture();
    ExportSampler();
    ExportTechnique();
    
    ExportPass();
    ExportUsedParamAndSamplerIdxByPass();

    ExportStringBuffer();

    // プログラム位置
    m_PesHeader.posProgram = m_Out.GetCurPos();

    ExportPSProgram();

    ExportVSProgram();

    // ファイルサイズ取得
    m_PesHeader.sizeFile = m_Out.GetCurPos();

    // 先頭に戻る
    VRETURN(m_Out.Seek(0, izanagi::E_IO_STREAM_SEEK_POS_START));

    // ファイルヘッダ出力
    m_Out.Write(&m_PesHeader, 0, sizeof(m_PesHeader));

    m_Out.Finalize();
    
    return TRUE;
}
Beispiel #8
0
    // 起動.
    IZ_BOOL Udp::start(const IPv4Endpoint& hostEp)
    {
        if (isValidSocket(m_socket)) {
            return IZ_TRUE;
        }

        IZ_BOOL result = IZ_FALSE;

        // ソケットの生成
        m_socket = socket(
            AF_INET,        // アドレスファミリ
            SOCK_DGRAM,     // ソケットタイプ
            IPPROTO_UDP);   // プロトコル
        VRETURN(isValidSocket(m_socket));

        // 通信ポート・アドレスの設定
        sockaddr_in inAddr;
        {
            FILL_ZERO(&inAddr, sizeof(inAddr));

            inAddr.sin_family = AF_INET;
            inAddr.sin_port = htons(hostEp.getPort());

            auto address = hostEp.getAddress();

            if (address.isAny()) {
                setIp(inAddr, htonl(INADDR_ANY));
            }
            else {
                IZ_CHAR ip[64];
                address.toString(ip, COUNTOF(ip));

                setIp(inAddr, inet_addr(ip));
            }
        }

        // ソケットにアドレスを結びつける
        result = (bind(m_socket, (const sockaddr*)&inAddr, sizeof(inAddr)) >= 0);
        
        if (result) {
            m_isBindAddr = IZ_TRUE;
            m_host = hostEp;
        }
        else {
            IZ_ASSERT(IZ_FALSE);
            stop();
        }

        return result;
    }
Beispiel #9
0
    void* CMemoryAllocator::Alloc(size_t size)
    {
        void* ret = IZ_NULL;

        if (s_Alloc) {
            ret = (*s_Alloc)(size);
        }
        else {
            ret = malloc(size);
        }

        if (ret != IZ_NULL) {
            FILL_ZERO(ret, size);
        }

        return ret;
    }
Beispiel #10
0
CMotionBindApp::CMotionBindApp()
{
    m_Img = IZ_NULL;
    m_Mdl = IZ_NULL;
    m_Msh = IZ_NULL;
    m_Skl = IZ_NULL;
    m_Shd = IZ_NULL;

    m_Anm[0] = IZ_NULL;
    m_Anm[1] = IZ_NULL;

    FILL_ZERO(m_Mtrl, sizeof(m_Mtrl));

    m_RenderGraph = IZ_NULL;
    m_Renderer = IZ_NULL;

    m_AnmBinder = IZ_NULL;
}
Beispiel #11
0
/**
* テクニック解析
*/
BOOL CPostEffectConverter::ExportTechnique()
{
    UINT nPassPos = 0;

    // テクニック取得
    CGtechnique tech = ::cgGetFirstTechnique(m_pCgEffect);

    if (tech != NULL) {
        while (tech != NULL) {
            izanagi::S_PES_TECHNIQUE sTech;
            {
                FILL_ZERO(&sTech, sizeof(sTech));

                IZ_PCSTR name = ::cgGetTechniqueName(tech);
                IZ_UINT pos = CStringChunk::GetInstance().Register(name);

                //sTech.name = *(IZ_PCSTR*)(&pos);
                sTech.posName = pos;
                sTech.keyName = izanagi::CKey::GenerateValue(name);
                sTech.numPass = _GetPassNum(tech);
                sTech.posPass = nPassPos;
            }

            nPassPos += sTech.numPass;

            // 出力
            VRETURN(ExportData(sTech));

            tech = ::cgGetNextTechnique(tech);

            m_PesHeader.numTech++;
        }
    }
    else {
        // テクニックは必ず一つはないといけない
        IZ_ASSERT(FALSE);

        // TODO

        return FALSE;
    }

    return TRUE;
}
Beispiel #12
0
bool CArchiver7ZIP::InspectArchiveBegin(LPCTSTR ArcFileName,CConfigManager&)
{
	TRACE(_T("CArchiverDLL::InspectArchiveBegin()\n"));
	ASSERT(ArchiverOpenArchive);
	if(!ArchiverOpenArchive){
		return false;
	}
	if(m_hInspectArchive){
		ASSERT(!"Close the Archive First!!!\n");
		return false;
	}
	m_hInspectArchive=ArchiverOpenArchive(NULL,C2UTF8(ArcFileName),m_dwInspectMode);
	if(!m_hInspectArchive){
		TRACE(_T("Failed to Open Archive\n"));
		return false;
	}
	m_bInspectFirstTime=true;

	FILL_ZERO(m_IndividualInfo);
	return true;
}
Beispiel #13
0
BOOL CPostEffectConverter::ExportTexture()
{
    m_TexList.clear();

    CGparameter param = ::cgGetFirstEffectParameter(m_pCgEffect);

    while (param != NULL) {
        if (CParamUtil::IsTexture(param)) {
            izanagi::S_PES_TEXTURE sTex;
            {
                FILL_ZERO(&sTex, sizeof(sTex));

                CParamUtil::SetNameAndSemantic(sTex, param);

                sTex.type = _GetTexTypeFromSemantic(param);

                sTex.ann.isRenderTarget = IZ_TRUE;
                sTex.ann.isDynamic = IZ_FALSE;
                sTex.ann.typeRsc = izanagi::graph::E_GRAPH_RSC_USAGE_STATIC;

                VRETURN(
                    CTextureUtil::SetAnnValue(
                        sTex.ann,
                        param));
            }

            m_TexList.push_back(param);

            // 出力
            VRETURN(ExportData(sTex));

            m_PesHeader.numTex++;
        }

        param = ::cgGetNextParameter(param);
    }

    return TRUE;
}
Beispiel #14
0
BOOL CPostEffectConverter::ExportParamAnn(
    izanagi::S_PES_PARAM_HEADER& paramHader,
    IZ_INT nAnnNum/*= -1*/)
{
    IZ_UINT nAnnCnt = 0;

    // For annotation.
    std::vector<CGparameter>::iterator it = m_ParamList.begin();

    for (; it != m_ParamList.end(); it++) {
        CGparameter param = *it;

        if (CParamUtil::HasAnn(param)) {
            izanagi::S_PES_PARAM_ANN sAnn;
            
            FILL_ZERO(&sAnn, sizeof(sAnn));

            VRETURN(
                CParamUtil::SetAnnValue(
                    sAnn,
                    param));

            // 出力
            VRETURN(ExportData(sAnn));

            nAnnCnt++;
        }
    }

    BOOL ret = (nAnnNum >= 0
                ? (nAnnCnt == nAnnNum)
                : TRUE);

    paramHader.numParamAnn = nAnnCnt;

    IZ_ASSERT(ret);
    return ret;
}
Beispiel #15
0
GBuffer::GBuffer()
{
    FILL_ZERO(m_buffers, sizeof(m_buffers));
}
Beispiel #16
0
BOOL CPostEffectConverter::ExportSampler()
{
    izanagi::S_PES_SAMPLER_HEADER smplHeader;
    {
        smplHeader.numSampler = 0;
    }

    // Blank for pass's header.
    izanagi::tool::CIoStreamSeekHelper cSeekHelper(&m_Out);
    VRETURN(cSeekHelper.Skip(sizeof(smplHeader)));

    // パスを取得
    std::vector<CGpass> passList;
    {
        CGtechnique tech = ::cgGetFirstTechnique(m_pCgEffect);
        while (tech != NULL) {
            CGpass pass = ::cgGetFirstPass(tech);
            while (pass != NULL) {
                passList.push_back(pass);
                pass = ::cgGetNextPass(pass);
            }
            tech = ::cgGetNextTechnique(tech);
        }
    }

    CGparameter param = ::cgGetFirstEffectParameter(m_pCgEffect);

    while (param != NULL) {
        if (::cgIsParameterUsed(param, m_pCgEffect)) {
            VRETURN(CParamUtil::IsValidParameter(param));

            if (CParamUtil::IsSampler(param)) {
                // 対象となるパスのインデックスを取得
                IZ_INT passIdx = -1;
                for (IZ_UINT i = 0; i < passList.size(); i++) {
                    if (::cgIsParameterUsed(param, passList[i])) {
                        passIdx = i;
                        break;
                    }
                }

                izanagi::S_PES_SAMPLER sSampler;
                {
                    FILL_ZERO(&sSampler, sizeof(sSampler));

                    sSampler.state.minFilter = izanagi::graph::E_GRAPH_TEX_FILTER_LINEAR;
                    sSampler.state.magFilter = izanagi::graph::E_GRAPH_TEX_FILTER_LINEAR;
                    sSampler.state.addrU = izanagi::graph::E_GRAPH_TEX_ADDRESS_CLAMP;
                    sSampler.state.addrV = izanagi::graph::E_GRAPH_TEX_ADDRESS_CLAMP;

                    CParamUtil::SetNameAndSemantic(sSampler, param);
                    
                    VRETURN(
                        CSamplerUtil::SetStateValue(
                            sSampler.state,
                            param));

                    // 対象となるテクスチャとのバインド情報を設定
                    VRETURN(
                        CSamplerUtil::BindTexture(
                            sSampler.state,
                            param,
                            m_TexList));

                    if (passIdx >= 0) {
                        // シェーダ定数テーブルを作成
                        IZ_ASSERT(passIdx < m_CompiledPSList.size());

                        izanagi::tool::CSimpleMemoryAllocator allocator;

                        izanagi::tool::CShaderConstTableLite* constTbl = izanagi::tool::CShaderConstTableLite::CreateShaderConstTableLite(
                            &allocator,
                            m_CompiledPSList[passIdx]);

                        const char* paramName = ::cgGetParameterName(param);

                        sSampler.resource_id = constTbl->GetSamplerIndex(paramName);

                        SAFE_RELEASE(constTbl);
                    }
                    else {
                        // ある?
                        sSampler.resource_id = -1;
                    }
                }

                m_SamplerList.push_back(param);

                // 出力
                VRETURN(ExportData(sSampler));

                smplHeader.numSampler++;
            }
        }

        param = ::cgGetNextParameter(param);
    }

    // Return to paremter's header position with anchor.
    VRETURN(cSeekHelper.ReturnWithAnchor());

    // Export paramter's header.
    IZ_OUTPUT_WRITE_VRETURN(&m_Out, &smplHeader, 0, sizeof(smplHeader));

    // Return to anchored position.
    VRETURN(cSeekHelper.ReturnToAnchor());

    return TRUE;
}
Beispiel #17
0
/**
* パラメータ解析
*/
BOOL CPostEffectConverter::ExportParameter()
{
    IZ_UINT nAnnIdx = 0;

    izanagi::S_PES_PARAM_HEADER paramHader;
    {
        paramHader.numParameter = 0;
        paramHader.numParamAnn = 0;
    }

    // Blank for pass's header.
    izanagi::tool::CIoStreamSeekHelper cSeekHelper(&m_Out);
    VRETURN(cSeekHelper.Skip(sizeof(paramHader)));

    // For description.
    CGparameter param = ::cgGetFirstEffectParameter(m_pCgEffect);

    while (param != NULL) {
        if (CParamUtil::IsParameter(param)
            && !_IgnoreParameter(param))
        {
            // For Debug...
            IZ_PCSTR name = ::cgGetParameterName(param);

            VRETURN(CParamUtil::IsValidParameter(param));

            izanagi::S_PES_PARAMETER sParam;
            FILL_ZERO(&sParam, sizeof(sParam));
            
            sParam.DoNotStrip = CParamUtil::DoNotStrip(param);
            
            if (sParam.DoNotStrip
                || DoNotRemoveParam(param))
            {
                CParamUtil::SetNameAndSemantic(sParam, param);

                VRETURN(
                    CParamUtil::SetDescValue(
                        sParam,
                        param));

                if (sParam.hasAnn) {
                    sParam.AnnotationIdx = nAnnIdx++;
                }

                // Register initial value.
                VRETURN(
                    CParamUtil::GetInitValue(
                        sParam,
                        param));

                m_ParamList.push_back(param);

                // 出力
                VRETURN(ExportData(sParam));

                paramHader.numParameter++;
            }
        }

        param = ::cgGetNextParameter(param);
    }

    VRETURN(ExportParamAnn(paramHader, nAnnIdx));

    // Export initial value.
    m_PesHeader.sizeValueBuffer = CDataBuffer::GetInstance().GetBufferSize();
    if (m_PesHeader.sizeValueBuffer > 0) {
        const void* pBuf = CDataBuffer::GetInstance().GetBuffer();

        IZ_OUTPUT_WRITE_VRETURN(
            &m_Out,
            pBuf,
            0,
            m_PesHeader.sizeValueBuffer);
    }

    // Return to paremter's header position with anchor.
    VRETURN(cSeekHelper.ReturnWithAnchor());

    // Export paramter's header.
    IZ_OUTPUT_WRITE_VRETURN(&m_Out, &paramHader, 0, sizeof(paramHader));

    // Return to anchored position.
    VRETURN(cSeekHelper.ReturnToAnchor());

    return TRUE;
}
Beispiel #18
0
bool CArchiver7ZIP::AddItemToArchive(LPCTSTR ArcFileName,const std::list<CString> &FileList,CConfigManager &ConfMan,LPCTSTR lpDestDir,CString &strLog)
{
	// レスポンスファイル用テンポラリファイル名取得
	TCHAR ResponceFileName[_MAX_PATH+1];
	FILL_ZERO(ResponceFileName);
	if(!UtilGetTemporaryFileName(ResponceFileName,_T("zip"))){
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_TEMPORARY_FILE_CREATE));
		return false;
	}
	ASSERT(0!=_tcslen(ResponceFileName));

	//===一時的にファイルをコピー
	//---\で終わる基点パスを取得
	CPath strBasePath;
	UtilGetBaseDirectory(strBasePath,FileList);
	TRACE(_T("%s\n"),strBasePath);

	//---テンポラリに対象ファイルをコピー
	//テンポラリ準備
	CTemporaryDirectoryManager tdm(_T("lhaf"));
	CPath strDestPath(tdm.GetDirPath());
	strDestPath+=lpDestDir;
	UtilMakeSureDirectoryPathExists(strDestPath);

	// 圧縮対象ファイル名を修正する
	const int BasePathLength=((CString)strBasePath).GetLength();
	CString strSrcFiles;	//コピー元ファイルの一覧
	CString strDestFiles;	//コピー先ファイルの一覧
	std::list<CString>::const_iterator ite;
	for(ite=FileList.begin();ite!=FileList.end();++ite){
		//ベースパスを元に相対パス取得 : 共通である基底パスの文字数分だけカットする
		LPCTSTR lpSrc((LPCTSTR)(*ite)+BasePathLength);

		//送り側ファイル名指定
		strSrcFiles+=(strBasePath+lpSrc);	//PathAppend相当
		strSrcFiles+=_T('|');
		//受け側ファイル名指定
		strDestFiles+=strDestPath+lpSrc;
		strDestFiles+=_T('|');
	}
	strSrcFiles+=_T('|');
	strDestFiles+=_T('|');

	//'|'を'\0'に変換する
	std::vector<TCHAR> srcBuf(strSrcFiles.GetLength()+1);
	UtilMakeFilterString(strSrcFiles,&srcBuf[0],srcBuf.size());
	std::vector<TCHAR> destBuf(strDestFiles.GetLength()+1);
	UtilMakeFilterString(strDestFiles,&destBuf[0],destBuf.size());

	//ファイル操作内容
	SHFILEOPSTRUCT fileOp={0};
	fileOp.wFunc=FO_COPY;
	fileOp.fFlags=FOF_MULTIDESTFILES|FOF_NOCONFIRMATION|FOF_NOCONFIRMMKDIR|FOF_NOCOPYSECURITYATTRIBS|FOF_NO_CONNECTED_ELEMENTS;
	fileOp.pFrom=&srcBuf[0];
	fileOp.pTo=&destBuf[0];

	//コピー実行
	if(::SHFileOperation(&fileOp)){
		//エラー
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_FILE_COPY));
		return false;
	}else if(fileOp.fAnyOperationsAborted){
		//キャンセル
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_USERCANCEL));
		return false;
	}

	//カレントディレクトリ設定
	::SetCurrentDirectory(tdm.GetDirPath());
	// 同時に、レスポンスファイル内にアーカイブ名および圧縮対象ファイル名を記入する
	{
		HANDLE hFile=CreateFile(ResponceFileName,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
		if(INVALID_HANDLE_VALUE==hFile){
			strLog=CString(MAKEINTRESOURCE(IDS_ERROR_TEMPORARY_FILE_ACCESS));
			return false;
		}
		//レスポンスファイルへの書き込み
		//全て圧縮
		WriteResponceFile(hFile,_T("*"));
		CloseHandle(hFile);
	}


	//===========================
	// DLLに渡すオプションの設定
	//===========================
	TRACE(_T("DLLに渡すオプションの設定\n"));

	CString Param;//コマンドライン パラメータ バッファ

	CConfigZIP confZIP;
	CConfig7Z  conf7Z;
	ASSERT(ArchiverGetArchiveType);
	switch(ArchiverGetArchiveType(C2UTF8(ArcFileName))){
	case 1:	//ZIP形式で圧縮
		confZIP.load(ConfMan);
		if(!FormatCompressCommandZIP(confZIP,Param,false,0,NULL,NULL,strLog)){
			DeleteFile(ResponceFileName);
			return false;
		}
		break;
	case 2:	//7z形式で圧縮
		conf7Z.load(ConfMan);
		if(!FormatCompressCommand7Z(conf7Z,Param,0,NULL,strLog)){
			DeleteFile(ResponceFileName);
			return false;
		}
		break;
	default:
		ASSERT(!"This code cannot be run");
		//エラー処理が面倒なので放っておく。
		return false;
	}

	Param+=_T("-scsUTF-8 ");	//レスポンスファイルのコードページ指定

	//作業ディレクトリ
	Param+=_T("\"-w");
	Param+=UtilGetTempPath();
	Param+=_T("\" ");

	//圧縮先ファイル名指定
	Param+=_T("\"");
	Param+=ArcFileName;
	Param+=_T("\" ");

	//レスポンスファイル名指定
	Param+=_T("\"@");
	Param+=ResponceFileName;
	Param+=_T("\"");

	ASSERT(!Param.IsEmpty());
	TRACE(_T("ArchiveHandler Commandline Parameter:%s\n"),Param);

	TRACE(_T("ArchiveHandler呼び出し\n"));
	//char szLog[LOG_BUFFER_SIZE]={0};
	std::vector<BYTE> szLog(LOG_BUFFER_SIZE);
	szLog[0]='\0';
	int Ret=ArchiveHandler(NULL,C2UTF8(Param),(LPSTR)&szLog[0],LOG_BUFFER_SIZE-1);
	CString strTmp;
	UtilToUNICODE(strTmp,&szLog[0],szLog.size()-1,UTILCP_UTF8);
	//strLog=&szLog[0];
	strLog=strTmp;

	//使ったレスポンスファイルは消去
	DeleteFile(ResponceFileName);

	return 0==Ret;
}
Beispiel #19
0
IZ_BOOL CColladaAnimation::GetAnmTarget(
    domChannelRef pChannel,
    SAnmChannel& sAnmChannel)
{
    static IZ_CHAR tmp[128];

    daeString target = pChannel->getTarget();

    // Get target joint's name.
    IZ_PCSTR pszId = _FindStr(target, "/");
    {
        if (pszId == IZ_NULL) {
            pszId = _FindStr(target, "(");
        }
        if (pszId == IZ_NULL) {
            pszId = _FindStr(target, ".");
        }

        VRETURN(pszId != IZ_NULL);

        size_t nSize = static_cast<size_t>(izanagi::CStdUtil::GetPtrDistance(target, pszId));
        VRETURN((1 < nSize) && (nSize < COUNTOF(tmp)));

        FILL_ZERO(tmp, sizeof(tmp));
        memcpy(tmp, target, nSize);

        sAnmChannel.joint = tmp;
    }

    static IZ_CHAR strMember[izanagi::ANM_NAME_LEN + 1];

    // Get target transform's sid.
    IZ_PCSTR pszSId = _FindStr(target, ".");
    {
        if (pszSId == IZ_NULL) {
            pszSId = _FindStr(target, "(");
        }
        if (pszSId == IZ_NULL) {
            pszSId = target + strlen(target);
        }

        VRETURN(pszSId != IZ_NULL);
        VRETURN(pszSId > pszId);

        size_t nSize = static_cast<size_t>(izanagi::CStdUtil::GetPtrDistance(pszSId, pszId));
        VRETURN((1 < nSize) && (nSize < COUNTOF(tmp)));

        FILL_ZERO(tmp, sizeof(tmp));
        memcpy(tmp, pszId + 1, nSize - 1);

        sAnmChannel.transform = tmp;

        FILL_ZERO(strMember, sizeof(strMember));
        if ((pszSId != '\0') && (strlen(pszSId) > 1)) {
            memcpy(strMember, pszSId + 1, strlen(pszSId) - 1);
        }
    }

    domElement* pRootNode = pChannel->getDocument()->getDomRoot();

    // Get transform element of target node.
    daeSIDResolver sidResolver(pRootNode, target);
    domElement* pElement = sidResolver.getElement();
    VRETURN(pElement != IZ_NULL);

#if 0
    COLLADA_TYPE::TypeEnum type = pElement->getElementType();
    switch (type) {
    case COLLADA_TYPE::TRANSLATE:
        sAnmChannel.type = izanagi::E_ANM_TRANSFORM_TYPE_TRANSLATE;
        break;
    case COLLADA_TYPE::ROTATE:
        sAnmChannel.type = izanagi::E_ANM_TRANSFORM_TYPE_QUATERNION;
        break;
    case COLLADA_TYPE::SCALE:
        sAnmChannel.type = izanagi::E_ANM_TRANSFORM_TYPE_SCALE;
        break;
    default:
        VRETURN(IZ_FALSE);
        break;
    }
#else
    izanagi::tool::CString type(pElement->getElementName());
    if (type == ColladaDOM141::COLLADA_TYPE_TRANSLATE)
    {
        sAnmChannel.type = izanagi::E_ANM_TRANSFORM_TYPE_TRANSLATE;
    }
    else if (type == ColladaDOM141::COLLADA_TYPE_ROTATE)
    {
        sAnmChannel.type = izanagi::E_ANM_TRANSFORM_TYPE_QUATERNION;
    }
    else if (type == ColladaDOM141::COLLADA_TYPE_SCALE)
    {
        sAnmChannel.type = izanagi::E_ANM_TRANSFORM_TYPE_SCALE;
    }
    else
    {
        VRETURN(IZ_FALSE);
    }
#endif

    if (strlen(strMember) > 0) {
        if (sAnmChannel.type & izanagi::E_ANM_TRANSFORM_TYPE_QUATERNION) {
            if (izanagi::tool::CString::CmpStr(strMember, "AXIS")) {
                sAnmChannel.type = izanagi::E_ANM_TRANSFORM_TYPE_QUATERNION_XYZ;
            }
            else if (izanagi::tool::CString::CmpStr(strMember, "ANGLE")) {
                sAnmChannel.type = izanagi::E_ANM_TRANSFORM_TYPE_QUATERNION_W;
            }
        }
        else if (izanagi::tool::CString::CmpStr(strMember, "X")) {
            sAnmChannel.type |= izanagi::E_ANM_TRANSFORM_TYPE_X;
        }
        else if (izanagi::tool::CString::CmpStr(strMember, "Y")) {
            sAnmChannel.type |= izanagi::E_ANM_TRANSFORM_TYPE_Y;
        }
        else if (izanagi::tool::CString::CmpStr(strMember, "Z")) {
            sAnmChannel.type |= izanagi::E_ANM_TRANSFORM_TYPE_Z;
        }
    }
    else {
        if (sAnmChannel.type & izanagi::E_ANM_TRANSFORM_TYPE_QUATERNION) {
            sAnmChannel.type |= izanagi::E_ANM_TRANSFORM_TYPE_XYZW;
        }
        else {
            sAnmChannel.type |= izanagi::E_ANM_TRANSFORM_TYPE_XYZ;
        }
    }

    return IZ_TRUE;
}
Beispiel #20
0
// パス解析
BOOL CShaderConverter::ExportPass(const SShaderConfig& config)
{
    _ExportChunkHeader(m_Out, izanagi::shader::SHD_CHUNK_MAGIC_NUMBER_PASS);

    izanagi::shader::S_SHD_PASS_HEADER sPassHeader;
    FILL_ZERO(&sPassHeader, sizeof(sPassHeader));

    // Blank for pass's header.
    izanagi::tool::CIoStreamSeekHelper cSeekHelper(&m_Out);
    VRETURN(_BeginExportChunk(sPassHeader, cSeekHelper));

    IZ_UINT nTechIdx = 0;
    IZ_UINT nPassIdx = 0;

    IZ_UINT nConstNum = 0;
    IZ_UINT nSamplerNum = 0;

    CGtechnique tech = ::cgGetFirstTechnique(m_pCgEffect);

    while (tech != NULL) {
        CGpass pass = ::cgGetFirstPass(tech);
        while (pass != NULL) {
            izanagi::shader::S_SHD_PASS sPass;
            {
                FILL_ZERO(&sPass, sizeof(sPass));

                IZ_PCSTR name = ::cgGetPassName(pass);
                IZ_UINT pos = CStringChunk::GetInstance().Register(name);

                //sPass.name = *(IZ_PCSTR*)(&pos);
                sPass.posName = pos;
                sPass.keyName = izanagi::CKey::GenerateValue(name);

                sPass.TechniqueIdx = nTechIdx;

                sPass.numConst = _GetUsedParamNum(m_ParamList, pass);
                sPass.numSampler = _GetUsedParamNum(m_SamplerList, pass);

                sPass.sizeVS = _GetFileSize(config, m_CompiledVSList[nPassIdx]);
                sPass.sizePS = _GetFileSize(config, m_CompiledPSList[nPassIdx]);

                nConstNum += sPass.numConst;
                nSamplerNum += sPass.numSampler;
            }

            VRETURN(
                CPassUtil::SetStateValue(
                    sPass.state,
                    pass));

            // 出力
            VRETURN(ExportData(sPass));

            pass = ::cgGetNextPass(pass);
            nPassIdx++;

            IZ_UINT nMax = IZ_MAX(sPass.sizeVS, sPass.sizePS);

            m_ShdHeader.maxProgamSize = IZ_MAX(m_ShdHeader.maxProgamSize, nMax);

            sPassHeader.numPass++;
        }

        tech = ::cgGetNextTechnique(tech);
        nTechIdx++;
    }

    m_ShdHeader.numPass = sPassHeader.numPass;

    // NOTE
    // 全体でのシェーダ定数、サンプラの総数を知りたい

    m_ShdHeader.numParam = nConstNum;
    m_ShdHeader.numSmpl = nSamplerNum;

    VRETURN(ExportUsedParamAndSamplerIdxByPass());

    VRETURN(_EndExportChunk(sPassHeader, cSeekHelper));

    return TRUE;
}
Beispiel #21
0
bool CArchiver7ZIP::Compress(LPCTSTR ArcFileName,std::list<CString> &ParamList,CConfigManager &ConfMan,const PARAMETER_TYPE Type,int Options,LPCTSTR lpszFormat,LPCTSTR lpszMethod,LPCTSTR lpszLevel,CString &strLog)
{
	if(!IsOK()){
		return false;
	}

	ASSERT(0!=_tcslen(ArcFileName));
	TRACE(_T("ArcFileName=%s\n"),ArcFileName);

	//分割書庫の場合は自己解凍は出来ない
	if((Options&COMPRESS_SPLIT)&&(Options&COMPRESS_SFX)){
		ErrorMessage(CString(MAKEINTRESOURCE(IDS_ERROR_CANNOT_SPLIT_SFX)));
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_CANNOT_SPLIT_SFX));
		Options&=~COMPRESS_SFX;
	}

	//==============================================
	// レスポンスファイル用テンポラリファイル名取得
	//==============================================
	TCHAR ResponceFileName[_MAX_PATH+1];
	FILL_ZERO(ResponceFileName);
	if(!UtilGetTemporaryFileName(ResponceFileName,_T("zip"))){
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_TEMPORARY_FILE_CREATE));
		return false;
	}
	ASSERT(0!=_tcslen(ResponceFileName));

	//============================================
	// 自己解凍ファイル用テンポラリファイル名取得
	//============================================
	TCHAR SFXTemporaryFileName[_MAX_PATH+1];
	FILL_ZERO(SFXTemporaryFileName);
	TCHAR SFXModulePath[_MAX_PATH+1];
	FILL_ZERO(SFXModulePath);
	bool bZIPSFX=((0!=(Options&COMPRESS_SFX))&&(PARAMETER_ZIP==Type));
	if(bZIPSFX){
		//2段階作成する
		if(!UtilGetTemporaryFileName(SFXTemporaryFileName,_T("sfx"))){
			strLog=CString(MAKEINTRESOURCE(IDS_ERROR_TEMPORARY_FILE_CREATE));
			return false;
		}
		ASSERT(0!=_tcslen(SFXTemporaryFileName));
		DeleteFile(SFXTemporaryFileName);//ゴミファイル消去

		//---SFXモジュール
		LPTSTR lptemp;
		{
			//安全なパスに移動;DLL読み込み対策
			CCurrentDirManager cdm(UtilGetModuleDirectoryPath());
			if(!SearchPath(NULL,_T("SFX32GUI.DAT"),NULL,_MAX_PATH,SFXModulePath,&lptemp)){
				strLog.Format(IDS_ERROR_SFX_MODULE_NOT_FOUND,_T("SFX32GUI.DAT"));
				return false;
			}
		}
	}

	//====================================================
	// レスポンスファイル内に圧縮対象ファイル名を記入する
	// アーカイブファイル名はコマンドラインで直接指定する
	//====================================================
	{
		HANDLE hFile=CreateFile(ResponceFileName,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
		if(INVALID_HANDLE_VALUE==hFile){
			strLog=CString(MAKEINTRESOURCE(IDS_ERROR_TEMPORARY_FILE_ACCESS));
			return false;
		}

		TRACE(_T("レスポンスファイルへの書き込み\n"));
		std::list<CString>::iterator ite;
		for(ite=ParamList.begin();ite!=ParamList.end();ite++){
			CPath strPath=*ite;

			if(strPath.IsDirectory()){
				strPath.Append(_T("*"));
			}
			WriteResponceFile(hFile,strPath);
		}
		CloseHandle(hFile);
	}

	//===========================
	// DLLに渡すオプションの設定
	//===========================
	TRACE(_T("DLLに渡すオプションの設定\n"));

	CString Param;//コマンドライン パラメータ バッファ

	CConfigZIP confZIP;
	CConfig7Z  conf7Z;
	switch(Type){
	case PARAMETER_ZIP:	//ZIP形式で圧縮
		confZIP.load(ConfMan);
		break;
	case PARAMETER_7Z:	//7z形式で圧縮
		conf7Z.load(ConfMan);
		break;
	}

	switch(Type){
	case PARAMETER_ZIP:	//ZIP形式で圧縮
		if(!FormatCompressCommandZIP(confZIP,Param,bZIPSFX,Options,lpszMethod,lpszLevel,strLog)){
			DeleteFile(ResponceFileName);
			return false;
		}
		break;
	case PARAMETER_7Z:	//7z形式で圧縮
		if(!FormatCompressCommand7Z(conf7Z,Param,Options,lpszMethod,strLog)){
			DeleteFile(ResponceFileName);
			return false;
		}
		break;
	}
	//分割
	if(Options&COMPRESS_SPLIT){
		C7Zip32VolumeSizeDialog vsd;
		if(IDOK!=vsd.DoModal())return false;
		CString temp;
		temp.Format(_T("-v%d%s "),vsd.VolumeSize,ZIP_VOLUME_UNIT[vsd.SelectIndex].ParamName);
		Param+=temp;
	}

	Param+=_T("-scsUTF-8 ");	//レスポンスファイルのコードページ指定

	//作業ディレクトリ
	Param+=_T("\"-w");
	Param+=UtilGetTempPath();
	Param+=_T("\" ");

	//圧縮先ファイル名指定
	if(bZIPSFX){
		Param+=_T("\"");
		Param+=SFXTemporaryFileName;
		Param+=_T("\" ");
	}
	else{
		Param+=_T("\"");
		Param+=ArcFileName;
		Param+=_T("\" ");
	}

	//レスポンスファイル名指定
	Param+=_T("\"@");
	Param+=ResponceFileName;
	Param+=_T("\"");

	ASSERT(!Param.IsEmpty());
	TRACE(_T("ArchiveHandler Commandline Parameter:%s\n"),Param);

	TRACE(_T("ArchiveHandler呼び出し\n"));
	std::vector<BYTE> szLog(LOG_BUFFER_SIZE);
	szLog[0]='\0';
	int Ret=ArchiveHandler(NULL,C2UTF8(Param),(LPSTR)&szLog[0],LOG_BUFFER_SIZE-1);
	CString strTmp;
	UtilToUNICODE(strTmp,&szLog[0],szLog.size()-1,UTILCP_UTF8);
	//strLog=&szLog[0];
	strLog=strTmp;

	//使ったレスポンスファイルは消去
	DeleteFile(ResponceFileName);

	//エラー時ログ出力
	if(!bZIPSFX||0!=Ret){
		if(bZIPSFX){
			DeleteFile(SFXTemporaryFileName);
		}
		return 0==Ret;
	}

	//==================================
	// 自己解凍書庫に変換(バイナリ結合)
	//==================================
	//出力先ファイルを開く
	HANDLE hArcFile=CreateFile(ArcFileName,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
	if(INVALID_HANDLE_VALUE==hArcFile){
		strLog.Format(IDS_ERROR_ACCESS_OUTPUT_FILE,ArcFileName);
		DeleteFile(ArcFileName);
		DeleteFile(SFXTemporaryFileName);
		return false;
	}
	{
		//SFXモジュールを読み取りモードで開く
		HANDLE hSFXModuleFile=CreateFile(SFXModulePath,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
		if(INVALID_HANDLE_VALUE==hSFXModuleFile){
			strLog.Format(IDS_ERROR_SFX_MODULE_CANNOT_ACCESS,SFXModulePath);
			CloseHandle(hArcFile);
			DeleteFile(ArcFileName);
			DeleteFile(SFXTemporaryFileName);
			return false;
		}
		//SFXモジュールの中身をコピー
		int Result=UtilAppendFile(hArcFile,hSFXModuleFile);
		if(Result>0){	//読み取りエラー
			strLog.Format(IDS_ERROR_SFX_MODULE_CANNOT_ACCESS,SFXModulePath);
			CloseHandle(hArcFile);
			CloseHandle(hSFXModuleFile);
			DeleteFile(ArcFileName);
			DeleteFile(SFXTemporaryFileName);
			return false;
		}
		else if(Result<0){	//書き込みエラー
			strLog.Format(IDS_ERROR_ACCESS_OUTPUT_FILE,ArcFileName);
			CloseHandle(hArcFile);
			CloseHandle(hSFXModuleFile);
			DeleteFile(ArcFileName);
			DeleteFile(SFXTemporaryFileName);
			return false;
		}
		CloseHandle(hSFXModuleFile);
	}
	{
		//テンポラリファイルを読み取りモードで開く
		HANDLE hSFXTempFile=CreateFile(SFXTemporaryFileName,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
		if(INVALID_HANDLE_VALUE==hSFXTempFile){
			strLog=CString(MAKEINTRESOURCE(IDS_ERROR_TEMPORARY_FILE_ACCESS));
			CloseHandle(hArcFile);
			DeleteFile(ArcFileName);
			DeleteFile(SFXTemporaryFileName);
			return false;
		}
		//テンポラリファイルの中身をコピー
		int Result=UtilAppendFile(hArcFile,hSFXTempFile);
		if(Result>0){	//読み取りエラー
			strLog=CString(MAKEINTRESOURCE(IDS_ERROR_TEMPORARY_FILE_ACCESS));
			CloseHandle(hArcFile);
			CloseHandle(hSFXTempFile);
			DeleteFile(ArcFileName);
			DeleteFile(SFXTemporaryFileName);
			return false;
		}
		else if(Result<0){	//書き込みエラー
			strLog.Format(IDS_ERROR_ACCESS_OUTPUT_FILE,ArcFileName);
			CloseHandle(hArcFile);
			CloseHandle(hSFXTempFile);
			DeleteFile(ArcFileName);
			DeleteFile(SFXTemporaryFileName);
			return false;
		}
		CloseHandle(hSFXTempFile);
		DeleteFile(SFXTemporaryFileName);
	}
	CloseHandle(hArcFile);

	return true;
}
Beispiel #22
0
BOOL CShaderConverter::ExportSampler(const SShaderConfig& config)
{
    VRETURN(_ExportChunkHeader(m_Out, izanagi::shader::SHD_CHUNK_MAGIC_NUMBER_SMPL));

    izanagi::shader::S_SHD_SAMPLER_HEADER sSmplHeader;
    FILL_ZERO(&sSmplHeader, sizeof(sSmplHeader));

    // Blank for texture's header.
    izanagi::tool::CIoStreamSeekHelper cSeekHelper(&m_Out);
    VRETURN(_BeginExportChunk(sSmplHeader, cSeekHelper));

    CGparameter param = ::cgGetFirstEffectParameter(m_pCgEffect);

    // パスを取得
    std::vector<CGpass> passList;
    {
        CGtechnique tech = ::cgGetFirstTechnique(m_pCgEffect);
        while (tech != NULL) {
            CGpass pass = ::cgGetFirstPass(tech);
            while (pass != NULL) {
                passList.push_back(pass);
                pass = ::cgGetNextPass(pass);
            }
            tech = ::cgGetNextTechnique(tech);
        }
    }

    while (param != NULL) {
        if (::cgIsParameterUsed(param, m_pCgEffect)) {
            VRETURN(CParamUtil::IsValidParameter(param));

            if (CParamUtil::IsSampler(param)) {
                // 対象となるパスのインデックスを取得
                IZ_INT passIdx = -1;
                for (IZ_UINT i = 0; i < passList.size(); i++) {
                    if (::cgIsParameterUsed(param, passList[i])) {
                        passIdx = i;
                        break;
                    }
                }

                izanagi::shader::S_SHD_SAMPLER sSampler;
                {
                    FILL_ZERO(&sSampler, sizeof(sSampler));

                    sSampler.state.minFilter = izanagi::graph::E_GRAPH_TEX_FILTER_LINEAR;
                    sSampler.state.magFilter = izanagi::graph::E_GRAPH_TEX_FILTER_LINEAR;
                    sSampler.state.mipFilter = izanagi::graph::E_GRAPH_TEX_FILTER_LINEAR;
                    sSampler.state.addressU = izanagi::graph::E_GRAPH_TEX_ADDRESS_CLAMP;
                    sSampler.state.addressV = izanagi::graph::E_GRAPH_TEX_ADDRESS_CLAMP;

                    CParamUtil::SetNameAndSemantic(sSampler, param);

                    CGtype type = CParamUtil::GetCgType(param);
                    sSampler.Type = CShaderConvUtil::CgParamTypeToIzanagiShaderParamType(type);

                    VRETURN(
                        CSamplerUtil::SetStateValue(
                            sSampler,
                            param));

                    // 対象となるテクスチャとのバインド情報を設定
                    VRETURN(
                        CSamplerUtil::BindTexture(
                            sSampler,
                            param,
                            m_TexList));

                    if (passIdx >= 0) {
                        // シェーダ定数テーブルを作成
                        IZ_ASSERT(passIdx < m_CompiledPSList.size());

                        if (config.type == izanagi::E_PLATFORM_DX9)
                        {
                            izanagi::tool::CSimpleMemoryAllocator allocator;

                            // ピクセルシェーダを読み込む
                            izanagi::tool::CShaderConstTableLite* constTbl = izanagi::tool::CShaderConstTableLite::CreateShaderConstTableLite(
                                        &allocator,
                                        m_CompiledPSList[passIdx].c_str());

                            const char* paramName = ::cgGetParameterName(param);

                            // シェーダからサンプラのインデックスを取得
                            sSampler.resource_id = constTbl->GetSamplerIndex(paramName);

                            SAFE_RELEASE(constTbl);
                        }
                        else if (config.type == izanagi::E_PLATFORM_GLES2)
                        {
                            const char* paramName = ::cgGetParameterName(param);

                            // ShaderCompilerに任せる
                            izanagi::tool::CString command;
                            command.format(
                                "%s --analyze %s %s\0",
                                config.compiler.c_str(),
                                m_CompiledPSList[passIdx].c_str(),
                                paramName);

                            // ShaderCompilerを起動
                            FILE* fp = _popen(command.c_str(), "r");
                            VRETURN(fp != NULL);

                            static char buf[4];

                            // 標準出力に出力された数値を取得
                            while(fgets(buf, sizeof(buf), fp) != NULL)
                            {
                                int index = ::atoi(buf);
                                sSampler.resource_id = index;
                            }

                            int result = _pclose(fp);
                            VRETURN(result == 0);
                        }
                        else
                        {
                            IZ_ASSERT(IZ_FALSE);
                        }
                    }
                    else {
                        // ある?
                        sSampler.resource_id = -1;
                    }
                }

                m_SamplerList.push_back(param);

                // 出力
                VRETURN(ExportData(sSampler));

                sSmplHeader.numSampler++;
            }
        }

        param = ::cgGetNextParameter(param);
    }

    //m_ShdHeader.numSmpl = sSmplHeader.numSampler;

    VRETURN(_EndExportChunk(sSmplHeader, cSeekHelper));

    return TRUE;
}
Beispiel #23
0
/**
* パラメータ解析
*/
BOOL CShaderConverter::ExportParameter(const SShaderConfig& config)
{
    _ExportChunkHeader(m_Out, izanagi::shader::SHD_CHUNK_MAGIC_NUMBER_PARAM);

    izanagi::shader::S_SHD_PARAM_HEADER sParamHeader;
    FILL_ZERO(&sParamHeader, sizeof(sParamHeader));

    // Blank for parameter's header.
    izanagi::tool::CIoStreamSeekHelper cSeekHelper(&m_Out);
    VRETURN(_BeginExportChunk(sParamHeader, cSeekHelper));

    IZ_UINT nAnnIdx = 0;

    // For description.
    CGparameter param = ::cgGetFirstEffectParameter(m_pCgEffect);

    while (param != NULL) {
        if (CParamUtil::IsParameter(param))
        {
            // For Debug...
            IZ_PCSTR name = ::cgGetParameterName(param);

            VRETURN(CParamUtil::IsValidParameter(param));

            izanagi::shader::S_SHD_PARAMETER sParam;
            FILL_ZERO(&sParam, sizeof(sParam));

            sParam.DoNotStrip = CParamUtil::DoNotStrip(param);
            BOOL bIsUsedInEffect = ::cgIsParameterUsed(param, m_pCgEffect);

#if 0
            if (sParam.DoNotStrip
                    || DoNotRemoveParam(param))
#else
            if (bIsUsedInEffect || sParam.DoNotStrip)
#endif
            {
                CParamUtil::SetNameAndSemantic(sParam, param);

                VRETURN(
                    CParamUtil::SetDescValue(
                        config,
                        sParam,
                        param));

                if (sParam.hasAnn) {
                    sParam.AnnotationIdx = nAnnIdx++;
                }

                // Register initial value.
                VRETURN(
                    CParamUtil::GetInitValue(
                        sParam,
                        param));

                if (config.type == izanagi::E_PLATFORM_GLES2) {
                    // For GLES2
#if 0
                    if (izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT1x1 <= sParam.Type
                            && sParam.Type <= izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT4x4)
                    {
                        // TODO
                        sParam.Type = izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT4;
                        sParam.Elements = (sParam.Elements > 0 ? sParam.Elements * 4 : 4);
                    }
#else
                    switch (sParam.Type) {
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT1x1:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT1x2:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT1x3:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT1x4:
                        sParam.Type = izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT;
                        //sParam.Elements = (sParam.Elements > 0 ? sParam.Elements * 1 : 1);
                        break;
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT2x1:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT2x2:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT2x3:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT2x4:
                        sParam.Type = izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT2;
                        //sParam.Elements = (sParam.Elements > 0 ? sParam.Elements * 2 : 2);
                        break;
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT3x1:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT3x2:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT3x3:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT3x4:
                        sParam.Type = izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT3;
                        //sParam.Elements = (sParam.Elements > 0 ? sParam.Elements * 3 : 3);
                        break;
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT4x1:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT4x2:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT4x3:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT4x4:
                        sParam.Type = izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT4;
                        //sParam.Elements = (sParam.Elements > 0 ? sParam.Elements * 4 : 4);
                        break;
                    }

                    //printf("    Rows(%d) Columns(%d) Elements(%d)\n", sParam.Rows, sParam.Columns, sParam.Elements);
#endif
                }

                m_ParamList.push_back(param);

                // 出力
                VRETURN(ExportData(sParam));

                sParamHeader.numParameter++;
            }
        }

        param = ::cgGetNextParameter(param);
    }

    VRETURN(ExportParamAnn(sParamHeader, nAnnIdx));

    // Export initial value.
    sParamHeader.sizeValueBuffer = CDataBuffer::GetInstance().GetBufferSize();
    if (sParamHeader.sizeValueBuffer > 0) {
        const void* pBuf = CDataBuffer::GetInstance().GetBuffer();

        IZ_OUTPUT_WRITE_VRETURN(
            &m_Out,
            pBuf,
            0,
            sParamHeader.sizeValueBuffer);
    }

    //m_ShdHeader.numParam = sParamHeader.numParameter;

    VRETURN(_EndExportChunk(sParamHeader, cSeekHelper));

    return TRUE;
}
Beispiel #24
0
bool CArchiver7ZIP::ExtractSpecifiedOnly(LPCTSTR ArcFileName,CConfigManager&,LPCTSTR OutputDir,std::list<CString> &FileList,CString &strLog,bool bUsePath)
{
	if(!IsOK()){
		return false;
	}
	//出力先移動
	CCurrentDirManager currentDir(OutputDir);

	//==============================================
	// レスポンスファイル用テンポラリファイル名取得
	//==============================================
	TCHAR ResponceFileName[_MAX_PATH+1];
	FILL_ZERO(ResponceFileName);
	if(!UtilGetTemporaryFileName(ResponceFileName,_T("7zp"))){
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_TEMPORARY_FILE_CREATE));
		return false;
	}
	ASSERT(0!=_tcslen(ResponceFileName));

	//解凍対象ファイルをレスポンスファイルに書き出す
	{
		HANDLE hFile=CreateFile(ResponceFileName,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
		if(INVALID_HANDLE_VALUE==hFile){
			strLog=CString(MAKEINTRESOURCE(IDS_ERROR_TEMPORARY_FILE_ACCESS));
			return false;
		}

		std::list<CString>::iterator ite=FileList.begin();
		const std::list<CString>::iterator end=FileList.end();
		for(;ite!=end;ite++){
			TRACE(_T("%s=>%s\n"),LPCTSTR(*ite),OutputDir);
			WriteResponceFile(hFile,*ite);
		}
		CloseHandle(hFile);
	}

	//===========================
	// DLLに渡すオプションの設定
	//===========================
	CString Param;

	//解凍パラメータ
	if(bUsePath){
		Param+=_T("x ");	//パス付き解凍
	}else{
		Param+=_T("e ");		//ディレクトリなしで解凍
	}
	Param+=
		_T("-r- ")		//再帰検索無効
		_T("-scsUTF-8 ")	//レスポンスファイルのコードページ指定
	;

	//作業ディレクトリ
	Param+=_T("\"-w");
	Param+=UtilGetTempPath();
	Param+=_T("\" ");

	//アーカイブファイル名指定
	Param+=_T("\"");
	Param+=ArcFileName;
	Param+=_T("\" ");

	//出力先指定
	Param+=_T("-o\"");
	Param+=OutputDir;
	Param+=_T("\" ");

	//レスポンスファイル名指定
	Param+=_T("\"@");
	Param+=ResponceFileName;
	Param+=_T("\"");

	TRACE(_T("ArchiveHandler呼び出し\nCommandline Parameter:%s\n"),Param);
	std::vector<BYTE> szLog(LOG_BUFFER_SIZE);
	szLog[0]='\0';
	int Ret=ArchiveHandler(NULL,C2UTF8(Param),(LPSTR)&szLog[0],LOG_BUFFER_SIZE-1);
	CString strTmp;
	UtilToUNICODE(strTmp,&szLog[0],szLog.size()-1,UTILCP_UTF8);
	//strLog=&szLog[0];
	strLog=strTmp;
	//使ったレスポンスファイルは消去
	DeleteFile(ResponceFileName);

	return 0==Ret;
}
Beispiel #25
0
    /**
    * 更新
    */
    IZ_BOOL CPadDInput::Update()
    {
        IZ_BOOL ret = (m_pPadDevice != IZ_NULL);

        if (ret) {
            // デバイスの取得
            HRESULT hr = m_pPadDevice->Acquire();

            ret = SUCCEEDED(hr);

            // 前の状態を保持
            memcpy(&m_LastState, &m_CurState, sizeof(m_CurState));

            if (ret) {
                m_bSucceedUpdate = IZ_TRUE;

                DIJOYSTATE state;
                m_pPadDevice->GetDeviceState(sizeof(state), &state);

                // TODO
                m_pPadDevice->GetDeviceState(sizeof(m_RawState), &m_RawState);

                // 左キーの状態を POV -> Button に移す
                switch (state.rgdwPOV[0]) {
                case 0:
                    state.rgbButtons[E_PAD_BUTTON_L_UP] = 128;
                    break;
                case 4500:
                    state.rgbButtons[E_PAD_BUTTON_L_UP] = 128;
                    state.rgbButtons[E_PAD_BUTTON_L_RIGHT] = 128;
                    break;
                case 9000:
                    state.rgbButtons[E_PAD_BUTTON_L_RIGHT] = 128;
                    break;
                case 13500:
                    state.rgbButtons[E_PAD_BUTTON_L_RIGHT] = 128;
                    state.rgbButtons[E_PAD_BUTTON_L_DOWN] = 128;
                    break;
                case 18000:
                    state.rgbButtons[E_PAD_BUTTON_L_DOWN] = 128;
                    break;
                case 22500:
                    state.rgbButtons[E_PAD_BUTTON_L_DOWN] = 128;
                    state.rgbButtons[E_PAD_BUTTON_L_LEFT] = 128;
                    break;
                case 27000:
                    state.rgbButtons[E_PAD_BUTTON_L_LEFT] = 128;
                    break;
                case 31500:
                    state.rgbButtons[E_PAD_BUTTON_L_LEFT] = 128;
                    state.rgbButtons[E_PAD_BUTTON_L_UP] = 128;
                    break;
                }

                {
                    m_CurState.axisLeft[0] = (IZ_FLOAT)state.lX / ANALOG_STCIK_MAX;
                    m_CurState.axisLeft[1] = (IZ_FLOAT)state.lY / ANALOG_STCIK_MAX;

                    m_CurState.axisRight[0] = (IZ_FLOAT)state.lRx / ANALOG_STCIK_MAX;
                    m_CurState.axisRight[1] = (IZ_FLOAT)state.lRy / ANALOG_STCIK_MAX;

                    // Right Buttons
                    //   3
                    // 2   1
                    //   0

                    for (IZ_UINT i = 0; i < E_PAD_BUTTON_NUM; i++)
                    {
                        m_CurState.buttons[i] = (state.rgbButtons[i] > 0 ? 1 : 0);
                    }
                }
            }
            else {
                FILL_ZERO(&m_CurState, sizeof(m_CurState));
            }
        }

        return ret;
    }
Beispiel #26
0
// パス解析
BOOL CPostEffectConverter::ExportPass()
{
    IZ_UINT nTechIdx = 0;
    IZ_UINT nPassIdx = 0;

    IZ_UINT nConstNum = 0;
    IZ_UINT nSamplerNum = 0;

    izanagi::tool::CString strPrevPassFunctoName;

    CGtechnique tech = ::cgGetFirstTechnique(m_pCgEffect);

    while (tech != NULL) {
        CGpass pass = ::cgGetFirstPass(tech);
        while (pass != NULL) {
            izanagi::S_PES_PASS sPass;
            {
                FILL_ZERO(&sPass, sizeof(sPass));

                IZ_PCSTR name = ::cgGetPassName(pass);
                IZ_UINT pos = CStringChunk::GetInstance().Register(name);

                //sPass.name = *(IZ_PCSTR*)(&pos);
                sPass.posName = pos;
                sPass.keyName = izanagi::CKey::GenerateValue(name);
                sPass.TechniqueIdx = nTechIdx;
                sPass.numConst = _GetUsedParamNum(m_ParamList, pass);
                sPass.numSampler = _GetUsedParamNum(m_SamplerList, pass);
                VRETURN(CPassUtil::SetVSType(sPass, pass));

                sPass.sizeProgram = _GetFileSize(m_CompiledPSList[nPassIdx]);

                sPass.ann.RenderTargetIdx = _GetRenderTargetIdx(m_TexList, pass);
                sPass.ann.TexOffsetParamIdx = _GetTexOffsetParamIdx(m_ParamList, pass);

                for (IZ_UINT i = 0; i < izanagi::PES_FUNCTOR_ARGS_NUM; i++) {
                    sPass.ann.FunctorArgs[i] = -1;
                }

                nConstNum += sPass.numConst;
                nSamplerNum += sPass.numSampler;
            }

            VRETURN(
                CPassUtil::SetAnnValue(
                    sPass.ann,
                    pass));

            IZ_PCSTR pszFunctorName = CPassUtil::GetFunctorName(pass);

            if (pszFunctorName != IZ_NULL) {
                if (strPrevPassFunctoName == pszFunctorName) {
                    sPass.ann.isSubPass = IZ_TRUE;
                }

                strPrevPassFunctoName = pszFunctorName;
            }

            // Stringで設定されているファンクタ引数
            std::vector<izanagi::tool::CString> tvFunctorArgSList;
            CPassUtil::GetFunctorArgsString(
                pass,
                tvFunctorArgSList);

            if (tvFunctorArgSList.size() > 0) {
                ConvertFunctorArgsStrToIndex(
                    tvFunctorArgSList,
                    sPass.ann);
            }

            VRETURN(
                CPassUtil::SetStateValue(
                    sPass.state,
                    pass));

            // 出力
            VRETURN(ExportData(sPass));

            pass = ::cgGetNextPass(pass);
            nPassIdx++;

            m_PesHeader.maxProgamSize = IZ_MAX(m_PesHeader.maxProgamSize, sPass.sizeProgram);
            m_PesHeader.numPass++;
        }

        tech = ::cgGetNextTechnique(tech);
        nTechIdx++;
    }

    // NOTE
    // 全体でのシェーダ定数、サンプラの総数を知りたい
    m_PesHeader.numParam = nConstNum;
    m_PesHeader.numSampler = nSamplerNum;

    return TRUE;
}
Beispiel #27
0
bool CArchiver7ZIP::DeleteItemFromArchive(LPCTSTR ArcFileName,CConfigManager&,const std::list<CString>& FileList,CString &strLog)
{
	if(!IsOK()){
		return false;
	}

	//==============================================
	// レスポンスファイル用テンポラリファイル名取得
	//==============================================
	TCHAR ResponceFileName[_MAX_PATH+1];
	FILL_ZERO(ResponceFileName);
	if(!UtilGetTemporaryFileName(ResponceFileName,_T("7zp"))){
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_TEMPORARY_FILE_CREATE));
		return false;
	}
	ASSERT(0!=_tcslen(ResponceFileName));

	//削除対象ファイルをレスポンスファイルに書き出す
	{
		HANDLE hFile=CreateFile(ResponceFileName,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
		if(INVALID_HANDLE_VALUE==hFile){
			strLog=CString(MAKEINTRESOURCE(IDS_ERROR_TEMPORARY_FILE_ACCESS));
			return false;
		}

		std::list<CString>::const_iterator ite=FileList.begin();
		const std::list<CString>::const_iterator end=FileList.end();
		for(;ite!=end;ite++){
			CString tmp=*ite;
			if(tmp[tmp.GetLength()-1]==_T('\\'))tmp.Delete(tmp.GetLength()-1);
			WriteResponceFile(hFile,tmp);
		}
		CloseHandle(hFile);
	}

	//===========================
	// DLLに渡すオプションの設定
	//===========================
	CString Param;

	//削除パラメータ
	Param+=
		_T("d ")	//削除
		_T("-r- ")	//再帰検索無効
		_T("-scsUTF-8 ")	//レスポンスファイルのコードページ指定
	;

	//作業ディレクトリ
	Param+=_T("\"-w");
	Param+=UtilGetTempPath();
	Param+=_T("\" ");

	//アーカイブファイル名指定
	Param+=_T("\"");
	Param+=ArcFileName;
	Param+=_T("\" ");

	//レスポンスファイル名指定
	Param+=_T("\"@");
	Param+=ResponceFileName;
	Param+=_T("\"");

	TRACE(_T("ArchiveHandler呼び出し\nCommandline Parameter:%s\n"),Param);
	//char szLog[LOG_BUFFER_SIZE]={0};
	std::vector<BYTE> szLog(LOG_BUFFER_SIZE);
	szLog[0]='\0';
	int Ret=ArchiveHandler(NULL,C2UTF8(Param),(LPSTR)&szLog[0],LOG_BUFFER_SIZE-1);
	CString strTmp;
	UtilToUNICODE(strTmp,&szLog[0],szLog.size()-1,UTILCP_UTF8);
	//strLog=&szLog[0];
	strLog=strTmp;
	//使ったレスポンスファイルは消去
	DeleteFile(ResponceFileName);

	return 0==Ret;
}
Beispiel #28
0
//パスに共通する部分を取り出し、基底パスを取り出す
void UtilGetBaseDirectory(CString &BasePath,const std::list<CString> &PathList)
{
	bool bFirst=true;
	size_t ElementsCount=0;	//共通項目数
	std::vector<CString> PathElements;	//共通項目の配列

	std::list<CString>::const_iterator ite,end;
	end=PathList.end();
	for(ite=PathList.begin();ite!=end;++ite){
		if(!bFirst&&0==ElementsCount){
			//既に共通している要素が配列内に存在しないとき
			break;
		}

		//親ディレクトリまでで終わるパスを作る
		TCHAR Path[_MAX_PATH+1];
		FILL_ZERO(Path);
		_tcsncpy_s(Path,*ite,_MAX_PATH);
		PathRemoveFileSpec(Path);
		PathAddBackslash(Path);

		CString buffer;
		size_t iElement=0;	//一致しているパスの要素のカウント用(ループ内)
		size_t iIndex=0;	//パス内の文字のインデックス
		const size_t Length=_tcslen(Path);
		for(;iIndex<Length;iIndex++){
#if !defined(_UNICODE)&&!defined(UNICODE)
			if(_MBC_SINGLE==_mbsbtype((const unsigned char *)Path,iIndex)){
#endif
				if(_T('\\')==Path[iIndex]){
					//初回ならパスを詰め込み、そうでなければ要素を比較
					if(bFirst){
						PathElements.push_back(buffer);
						buffer.Empty();
						continue;
					}
					else{
						//大文字小文字区別せずに比較
						if(0==PathElements[iElement].CompareNoCase(buffer)){
							//要素が共通しているうちはOK
							iElement++;
							if(iElement>=ElementsCount)break;
							else{
								buffer.Empty();
								continue;
							}
						}
						else
						{
							//要素数を減らす
							//0オリジンのi番目で不一致ならばi個まで一致
							ElementsCount=iElement;
							break;
						}
					}
				}
#if !defined(_UNICODE)&&!defined(UNICODE)
			}
#endif
			buffer+=Path[iIndex];
		}
		if(bFirst){
			bFirst=false;
			ElementsCount=PathElements.size();
		}
		else if(ElementsCount>iElement){
			//パスが短かった場合、不一致なしのまま処理が終了する場合がある
			ElementsCount=iElement;
		}
	}

	BasePath.Empty();
	for(size_t i=0;i<ElementsCount;i++){
		BasePath+=PathElements[i];
		BasePath+=_T("\\");
	}
	TRACE(_T("BasePath=%s\n"),BasePath);
}
Beispiel #29
0
 CShaderAttrTable::CShaderAttrTable()
 {
     FILL_ZERO(&m_Header, sizeof(m_Header));
     m_Attrs = IZ_NULL;
     m_AttrHolder = IZ_NULL;
 }
Beispiel #30
0
//ピクチャボックスにアイコンを指定
LRESULT CConfigDlgAssociation::OnInitDialog(HWND hWnd, LPARAM lParam)
{
    // メッセージループにメッセージフィルタとアイドルハンドラを追加
    CMessageLoop* pLoop = _Module.GetMessageLoop();
    pLoop->AddMessageFilter(this);

    // 関連付けのShellOpenCommandを算出
    {
        TCHAR szModule[_MAX_PATH+1];
        GetModuleFileName(GetModuleHandle(NULL), szModule, _MAX_PATH);	//本体のパス取得
        CPath fullPath;
        UtilGetCompletePathName(fullPath,szModule);	//パスを正規化
        fullPath.QuoteSpaces();
        m_strAssocDesired=(LPCTSTR)fullPath;
        //m_strAssocDesired.MakeLower();	//小文字に正規化
        m_strAssocDesired+=_T(" /m \"%1\"");	//パラメータ
        TRACE(_T("ShellOpenCommand_Desired=%s\n"),m_strAssocDesired);
    }

    // システムデフォルトアイコンを取得
    if(Icon_SystemDefault.IsNull()) {
        TCHAR Path[_MAX_PATH+1];
        FILL_ZERO(Path);
        GetSystemDirectory(Path,_MAX_PATH);
        PathAppend(Path,_T("shell32.dll"));
        Icon_SystemDefault.ExtractIcon(Path,0);
    }

    // 関連付け情報をチェック
    LOAD_ASSOC_AND_SET_ICON(LZH,	_T(".lzh"),	0,	0);
    LOAD_ASSOC_AND_SET_ICON(LZS,	_T(".lzs"),	0,	22);
    LOAD_ASSOC_AND_SET_ICON(LHA,	_T(".lha"),	0,	23);
    LOAD_ASSOC_AND_SET_ICON(ZIP,	_T(".zip"),	1,	1);
    LOAD_ASSOC_AND_SET_ICON(JAR,	_T(".jar"),	2,	2);
    LOAD_ASSOC_AND_SET_ICON(CAB,	_T(".cab"),	3,	3);
    LOAD_ASSOC_AND_SET_ICON(7Z,		_T(".7z"),	4,	4);
    LOAD_ASSOC_AND_SET_ICON(ARJ,	_T(".arj"),	14,	14);
    LOAD_ASSOC_AND_SET_ICON(RAR,	_T(".rar"),	5,	5);
    LOAD_ASSOC_AND_SET_ICON(JAK,	_T(".jak"),	10,	10);
    LOAD_ASSOC_AND_SET_ICON(GCA,	_T(".gca"),	6,	6);
    LOAD_ASSOC_AND_SET_ICON(IMP,	_T(".imp"),	17,	17);
    LOAD_ASSOC_AND_SET_ICON(ACE,	_T(".ace"),	13,	13);
    LOAD_ASSOC_AND_SET_ICON(YZ1,	_T(".yz1"),	12,	12);
    LOAD_ASSOC_AND_SET_ICON(HKI,	_T(".hki"),	11,	11);
    LOAD_ASSOC_AND_SET_ICON(BZA,	_T(".bza"),	15,	15);
    LOAD_ASSOC_AND_SET_ICON(GZA,	_T(".gza"),	16,	16);
    LOAD_ASSOC_AND_SET_ICON(ISH,	_T(".ish"),	18,	18);
    LOAD_ASSOC_AND_SET_ICON(UUE,	_T(".uue"),	19,	19);
    LOAD_ASSOC_AND_SET_ICON(BEL,	_T(".bel"),	20,	20);

    LOAD_ASSOC_AND_SET_ICON(TAR,	_T(".tar"),	7,	24);
    LOAD_ASSOC_AND_SET_ICON(GZ,		_T(".gz"),	7,	25);
    LOAD_ASSOC_AND_SET_ICON(TGZ,	_T(".tgz"),	7,	26);
    LOAD_ASSOC_AND_SET_ICON(BZ2,	_T(".bz2"),	7,	27);
    LOAD_ASSOC_AND_SET_ICON(TBZ,	_T(".tbz"),	7,	28);
    LOAD_ASSOC_AND_SET_ICON(XZ,		_T(".xz"),	7,	36);
    LOAD_ASSOC_AND_SET_ICON(TAR_XZ,	_T(".txz"),	7,	37);
    LOAD_ASSOC_AND_SET_ICON(LZMA,	_T(".lzma"),7,	38);
    LOAD_ASSOC_AND_SET_ICON(TAR_LZMA,_T(".tlz"),7,	39);
    LOAD_ASSOC_AND_SET_ICON(Z,		_T(".z"),	7,	29);
    LOAD_ASSOC_AND_SET_ICON(TAZ,	_T(".taz"),	7,	30);
    LOAD_ASSOC_AND_SET_ICON(CPIO,	_T(".cpio"),7,	31);
    LOAD_ASSOC_AND_SET_ICON(A,		_T(".a"),	7,	32);
    LOAD_ASSOC_AND_SET_ICON(LIB,	_T(".lib"),	9,	9);
    LOAD_ASSOC_AND_SET_ICON(RPM,	_T(".rpm"),	8,	33);
    LOAD_ASSOC_AND_SET_ICON(DEB,	_T(".deb"),	8,	34);
    LOAD_ASSOC_AND_SET_ICON(ISO,	_T(".iso"),	8,	35);
    return TRUE;
}