bool PacketBuffer::GetPacket(Packet &packet)
{
    // check packet
    if (PacketVaild()) 
    {
        Packet *pPacket = (Packet *)raw();
        //INFO("Has a Packet");
        // block unnecessary packet
        if (PreProcess())
        {
            // delete a packet
            del(pPacket->GetPacketLen());
            return false;
        }
        else
        {
            // copy packet
            //packet = *pPacket; // this may dangerous
            ::memcpy(&packet, pPacket, pPacket->GetPacketLen());

            del(pPacket->GetPacketLen());
            return true;
        }
    }
    return false;
}
BOOL MzBarDecoder::DecodeFromFile(PCTSTR FileName,BYTE* pcode, DWORD* pnsize, DECODEPARA_ptr pPara){
    BOOL bRet = false;
    if(FileName == NULL || pcode == NULL) return bRet;

    DECODEPARA_t param;
    if(pPara == NULL) {
        param.dwThrehold = 128;
        param.dwScanRegion.left = 0; param.dwScanRegion.right = m_dib.GetImageWidth();
        param.dwScanRegion.top = 0; param.dwScanRegion.bottom = m_dib.GetImageHeight();
    }else{
        param.dwThrehold = pPara->dwThrehold;
        param.dwScanRegion = pPara->dwScanRegion;
		if(param.dwScanRegion.right == 0){
			param.dwScanRegion.right = m_dib.GetImageWidth();
		}
		if(param.dwScanRegion.bottom == 0){
			param.dwScanRegion.bottom = m_dib.GetImageHeight();
		}
    }
    if(LoadImage(FileName)){
        GrayImage(&param.dwScanRegion);
        BinaryImage(param.dwThrehold);
        if(PreProcess()){
            bRet = Recognize(pcode,pnsize);
        }
    }
    return bRet;
}
Exemple #3
0
bool ElMaxPlugin::ExportMeshAnim(LPCTSTR filename)
{
	// Open the stream
	outfile.open(filename);
	if (!outfile.good())
		return false;

	// Set format of the stream
	outfile << setprecision(4) << setiosflags(ios::fixed);

	// Add bones to out bone list, in case some bone be
	// exported as GeomObject
	boneList.Clear();
	PreProcess(ip->GetRootNode());

	// Export global info
	ExportGlobalInfo();

	// Export animation of each object found in the scene
	nodeEnumForAnim(ip->GetRootNode());

	// Close the stream
	outfile.close();

	return true;
}
Exemple #4
0
bool bgGlobalMax::Initialize(Interface* p3DMax)
{
	m_p3DMax = p3DMax;
	m_pRootNode = p3DMax->GetRootNode();

	if (m_p3DMax == NULL && m_pRootNode == NULL)
		return false;
	if (CheckFile(m_p3DMax) == false)
		return true;

	m_Interval = m_p3DMax->GetAnimRange();

	memset(&m_Scene, 0, sizeof(m_Scene));
	m_Scene.iVersion = 100;
	m_Scene.iFirstFrame = m_Interval.Start() / GetTicksPerFrame();
	m_Scene.iLastFrame = m_Interval.End() / GetTicksPerFrame();
	m_Scene.iFrameSpeed = GetFrameRate();
	m_Scene.iTickPerFrame = GetTicksPerFrame();

	PreProcess(m_pRootNode);

	m_Scene.iNumMesh = m_MatrixMap.Count();
	m_Scene.iMaxWeight = 1;

	return true;
}
int main()
{
	PreProcess("/home/cc/addNewFun/list.txt","/home/cc/addNewFun/Picture/");
	FFmpeg2Video("/home/cc/addNewFun/Picture/");
	ClearList("/home/cc/addNewFun/list.txt","/home/cc/addNewFun/Picture/");
	return 0;
}
Exemple #6
0
bool ElMaxPlugin::ExportSkeletalAnim(LPCTSTR filename)
{
	// Open the stream
	outfile.open(filename);
	if (!outfile.good())
		return false;

	// Set format of the stream
	outfile << setprecision(4) << setiosflags(ios::fixed);

	// Export global info
	ExportGlobalInfo();

	// Add bones to out bone list
	boneList.Clear();
	PreProcess(ip->GetRootNode());

	// Export list of animation
	ExportSkeletalAnim();

	// Close the stream
	outfile.close();

	return true;
}
Exemple #7
0
bool PrePostProcessor::Process() {

  if(!PreProcess()) return false;
  if(!DoProcess()) return false;
  if(!PostProcess()) return false;

  return ProcessNextMethod();
}
Exemple #8
0
bool bgDInput::Frame()
{
	PreProcess();

	KeyProcess();
	MouseProcess();

	return true;
}
Exemple #9
0
void AscOut::PreProcess(INode* node, int& nodeCount)
{
	nodeCount++;
	
	// For each child of this node, we recurse into ourselves 
	// and increment the counter until no more children are found.
	for (int c = 0; c < node->NumberOfChildren(); c++) {
		PreProcess(node->GetChildNode(c), nodeCount);
	}
}
Exemple #10
0
	Shader::Shader(const String& name, const String& source)
		: m_Name(name), m_Source(source)
	{
		String** shaders = new String*[2];
		shaders[0] = &m_VertexSource;
		shaders[1] = &m_FragmentSource;

		PreProcess(source, shaders);
		m_ShaderID = Load(m_VertexSource, m_FragmentSource);
		ResolveUniforms();
		ValidateUniforms();
	}
Exemple #11
0
void XsiExp::PreProcess(INode* node, int& nodeCount)
{
	nodeCount++;
	
	// Add the nodes material to out material list
	// Null entries are ignored when added...
	mtlList.AddMtl(node->GetMtl());

	// For each child of this node, we recurse into ourselves 
	// and increment the counter until no more children are found.
	for (int c = 0; c < node->NumberOfChildren(); c++)
  {
		PreProcess(node->GetChildNode(c), nodeCount);
	}
}
int CheckEndBuffer(char **ppcCheckPoint,char *pcSubName)//检测是否越界,并自动切换缓冲区,bufferL越界返回1,bufferR越界返回2,没有越界返回0
{
	static char fcBuffer ='L';//初始化第一次扫描bufferl
	int iTempOffset;//临时偏移量变量
	fcBuffer=='L'?(iTempOffset=*ppcCheckPoint-acScanBufL):(iTempOffset=*ppcCheckPoint-acScanBufR);//计算偏移量
	if(iTempOffset>=SBUFSIZE-1)//越界
	{
		if(fcBuffer=='L')
		{
			PreProcess(pcSubName);//装入Buffer
			*ppcCheckPoint=acScanBufR;//修改当前的指示器到下一个缓冲区的开始
			fcBuffer='R';//修改buffer标志,当前指针在bufferR中
			return 1;//bufferL越界返回1
		}
		else
		{
			PreProcess(pcSubName);//装入Buffer
			*ppcCheckPoint=acScanBufL;//修改当前的指示器到下一个缓冲区的开始
			fcBuffer='L';//修改buffer标志,当前指针在bufferL中
			return 2;//bufferR越界返回2
		}
	}
	return 0;//没有越界返回0
}
Exemple #13
0
void bgGlobalMax::PreProcess(INode* pNode)
{
	if (pNode == NULL)
		return;

	AddObject(pNode);
	AddMtl(pNode);

	int iNumChildren = pNode->NumberOfChildren();
	for (int iCnt = 0; iCnt < iNumChildren; iCnt++)
	{
		INode* pChild = pNode->GetChildNode(iCnt);
		PreProcess(pChild);
	}
}
Exemple #14
0
void Parser::Do(Stream& in, const Vector<String>& ignore, CppBase& _base,
                const String& p, const String& f) throw(Parser::Error)
{
	base = &_base;
	file = PreProcess(in);
	lex = ~file.text;
	lex.Ignore(ignore);
	context.nesting.Clear();
	context.nameing = "::";
	context.access = PUBLIC;
	context.typenames.Clear();
	package = p;
	filename = f;
	lpos = 0;
	line = 0;
	Do();
}
Exemple #15
0
bool CGenericProcessingMachine::Run(void)
{
    if (!PreProcess()) return false;
//
    bool result = true;
    CString source_directory;
    CString target_directory;
    if (PSC().VarDefined(GPM_VAR_NAME_INDIR))
    {
        source_directory = CheckLastChar(PSC().VarNamed(GPM_VAR_NAME_INDIR).GetString(),'/');
        PSC().VarNamed(GPM_VAR_NAME_INDIR).SetString(source_directory);
    }
    if (PSC().VarDefined(GPM_VAR_NAME_OUTDIR))
    {
        target_directory = CheckLastChar(PSC().VarNamed(GPM_VAR_NAME_OUTDIR).GetString(),'/');
        PSC().VarNamed(GPM_VAR_NAME_OUTDIR).SetString(target_directory);
    }
    bool do_rename_outfile = ((!PSC().VarDefined(GPM_VAR_NAME_LIST))&&(PSC().VarDefined(GPM_VAR_NAME_OUT)));
    bool do_create_outlist = ((PSC().VarDefined(GPM_VAR_NAME_LIST))&&(PSC().VarDefined(GPM_VAR_NAME_OUT)));
//if ((ILST().GetCount()>1)||(!PSC().VarDefined(GPM_VAR_NAME_OUT)))
    for (int i = 0; i < ILST().GetCount(); i++)
    {
        m_FileIndex = i;
        if (ILST().GetString(i).GetLength()==0) continue;
        CString source_file_name = source_directory + ILST().GetString(i);
        CString target_name = TargetName(i,ILST().GetString(i));
        if (do_rename_outfile)
        {
            target_name = PSC().VarNamed(GPM_VAR_NAME_OUT).GetString();
        }
        CString target_file_name = target_directory + target_name;
        result = result && ProcessFile(source_file_name,target_file_name);
        if (!target_file_name.IsEmpty())
        {
            OLST().Insert(target_name);
        }
    }
    if (do_create_outlist)
    {
        OLST().SaveToFile(PSC().VarNamed(GPM_VAR_NAME_OUT).GetString());
    }
//
    result = result && PostProcess();
    return result;
}
// Classify
int imageNet::Classify( float* rgba, uint32_t width, uint32_t height, float* confidence )
{
	// verify parameters
	if( !rgba || width == 0 || height == 0 )
	{
		printf(LOG_TRT "imageNet::Classify( 0x%p, %u, %u ) -> invalid parameters\n", rgba, width, height);
		return -1;
	}
	
	// downsample and convert to band-sequential BGR
	if( !PreProcess(rgba, width, height) )
	{
		printf(LOG_TRT "imageNet::Classify() -- PreProcess() failed\n");
		return -1;
	}
	
	return Classify(confidence);
}
Exemple #17
0
//------------------------------------------------------------------------
// Pre-process the progress bar
//------------------------------------------------------------------------
void SMDExporter::PreProcess( INode* node,int& nodeCount )
{
    Mtl* mtl = node->GetMtl();

	if( !exportSelected || node->Selected() )
	{
		// The ObjectState is a 'thing' that flows down the pipeline containing
		// all information about the object. By calling EvalWorldState() we tell
		// max to evaluate the object at the end of pipeline
		ObjectState os = node->EvalWorldState(0);

		// The obj member of ObjectState is the actual
		// object we will export
		if( os.obj )
		{
			// We look at the superclassID to determin the type of the object
			switch( os.obj->SuperClassID() )
			{
			case GEOMOBJECT_CLASS_ID:
                // Add the materials to our material list!
                // Only export the Material which have four colors
                // and the Diffuse texMap.
	            if( (StdMat*)mtl )
                {
                    mtlList.AddMtl( mtl );
                }

				nodeCount++;
				break;
			}
		}
	}

	// Traverse the child nodes
	for( int c=0;c<node->NumberOfChildren();c++ )
	{
		PreProcess( node->GetChildNode(c),nodeCount );
	}
}
Exemple #18
0
int GetToken(
  char *pcToken)
/******************************************************************************/
/* get a token from the input file. Return a put back token if available      */
/******************************************************************************/
{
  int       iResult;

  if (bPutBackTokenValid == TRUE)
  {
    strcpy((char *) pcToken, (char *) pcPutBackToken);
    bPutBackTokenValid = FALSE;
    iResult = iPutBackTokenType;
  }
  else
  {
    iResult = GetNewToken(pcToken);

    while (iResult == PRECOMPILER_TOKEN)
    {
      iResult = PreProcess(pcToken);
      if (iResult == NO_SCANNER_ERROR)
      {
        iResult = GetNewToken(pcToken);
      }
    }

    if (iResult == IDENTIFIER_TOKEN)
    {
      iResult = EvaluateMacroList(pcToken);
    }

    iPutBackTokenType = iResult;
  }

  strcpy((char *) pcPutBackToken, (char *) pcToken);

  return iResult;
}
Exemple #19
0
// Start the exporter!
// This is the real entrypoint to the exporter. After the user has selected
// the filename (and he's prompted for overwrite etc.) this method is called.
//
int XsiExp::DoExport( const TCHAR * name, ExpInterface * ei, Interface * i, BOOL suppressPrompts, DWORD options) 
{
	// Set a global prompt display switch
	showPrompts = suppressPrompts ? FALSE : TRUE;
	exportSelected = (options & SCENE_EXPORT_SELECTED) ? TRUE : FALSE;

	// Grab the interface pointer.
	ip = i;

	int numChildren = ip->GetRootNode()->NumberOfChildren();
  if (!numChildren)
  {
    return 1;
  }

	// Get the options the user selected the last time
	ReadConfig();

	if(showPrompts)
  {
		// Prompt the user with our dialogbox, and get all the options.
		if (!DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_EXPORT_DLG),
			ip->GetMAXHWnd(), ExportDlgProc, (LPARAM)this))
    {
			return 1;
		}
	}
	else
  {	// Set default parameters here
  	bIncludeAnim = TRUE;
		bIncludeVertexColors = FALSE;

    bAlwaysSample = FALSE;
		nKeyFrameStep = 5;
		nMeshFrameStep = 5;
		nPrecision = 4;
		nStaticFrame = 0;
	}
	
	sprintf(szFmtStr, "%%4.%df", nPrecision);

	// Open the stream
	pStream = _tfopen(name,_T("wt"));
	if (!pStream)
  {
		return 0;
	}
	
	// Startup the progress bar.
	ip->ProgressStart(GetString(IDS_PROGRESS_MSG), TRUE, fn, NULL);

	// Get a total node count by traversing the scene
	// We don't really need to do this, but it doesn't take long, and
	// it is nice to have an accurate progress bar.
	nTotalNodeCount = 0;
	nCurNode = 0;
	PreProcess(ip->GetRootNode(), nTotalNodeCount);
	
	// First we write out a file header with global information. 
	ExportGlobalInfo();

  // export meshes
	for (int idx = 0; idx < numChildren; idx++)
  {
		if (ip->GetCancel())
    {
			break;
    }
		nodeEnumMesh( ip->GetRootNode()->GetChildNode(idx), 0);
	}
	for (idx = 0; idx < numChildren; idx++)
  {
		if (ip->GetCancel())
    {
			break;
    }
		nodeEnumBone( ip->GetRootNode()->GetChildNode(idx), 0);
	}
  // close brace for hierarchy
 	fprintf(pStream,"}\n\n");

  if (bIncludeAnim)
  {
    int animHit = FALSE;    // write anim list head only the first time
	  for (idx = 0; idx < numChildren; idx++)
    {
		  if (ip->GetCancel())
      {
			  break;
      }
		  nodeEnumAnim( ip->GetRootNode()->GetChildNode(idx), animHit);
	  }

    if (animHit)
    {
  	  fprintf(pStream,"}\n\n");
    }
  }

	for (idx = 0; idx < numChildren; idx++)
  {
		if (ip->GetCancel())
    {
			break;
    }
    nodeEnumSkin( ip->GetRootNode()->GetChildNode(idx));
  }

	// We're done. Finish the progress bar.
	ip->ProgressEnd();

	// Close the stream
	fclose(pStream);

	// Write the current options to be used next time around.
	WriteConfig();

	return 1;
}
Exemple #20
0
/*
 * Source - main driver
 */
vi_rc Source( char *fn, char *data, int *ln )
{
    undo_stack  *atomic = NULL;
    labels      *lab, lb;
    vlist       vl;
    files       fi;
    sfile       *sf, *curr;
    char        tmp[MAX_SRC_LINE];
    char        sname[FILENAME_MAX];
    vi_rc       rc;
    bool        sicmp, wfb, ssa, exm;
    resident    *res;
    int         cTokenID;

    /*
     * startup
     */
    LastRC = LastRetCode;
    memset( &fi, 0, sizeof( fi ) );
    vl.head = vl.tail = NULL;
    res = residentScript( fn );
    if( res != NULL && EditFlags.LoadResidentScript ) {
        return( ERR_SCRIPT_ALREADY_RESIDENT );
    }
    if( EditFlags.CompileScript || res == NULL ) {
        lab = &lb;
        memset( lab, 0, sizeof( labels ) );
        sf = NULL;
    } else {
        lab = &res->lab;
        sf = res->sf;
    }
    if( EditFlags.CompileScript ) {
        sname[0] = 0;
        NextWord1( data, sname );
    }

    /*
     * initialize variables
     */
    memset( &fi, 0, sizeof( fi ) );
    rc = initSource( &vl, data );
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }

    /*
     * pre-process
     */
    sicmp = EditFlags.ScriptIsCompiled;
    SourceErrCount = 0;
    if( EditFlags.CompileScript || res == NULL ) {
        EditFlags.ScriptIsCompiled = FALSE;
        rc = PreProcess( fn, &sf, lab );
        finiSourceErrFile( fn );
        if( rc != ERR_NO_ERR || SourceErrCount > 0 ) {
            EditFlags.ScriptIsCompiled = sicmp;
            return( rc );
        }
    } else {
        EditFlags.ScriptIsCompiled = res->scriptcomp;
    }

    /*
     * if we were loading a resident script, then add it
     */
    if( EditFlags.LoadResidentScript ) {
        finiSource( NULL, &vl, NULL, NULL );
        if( SourceErrCount == 0 ) {
            addResidentScript( fn, sf, lab );
        }
        EditFlags.ScriptIsCompiled = sicmp;
        return( ERR_NO_ERR );
    }

    /*
     * if we were compiling, dump results and go back
     */
    if( EditFlags.CompileScript ) {
        rc = barfScript( fn, sf, &vl, ln, sname );
        finiSource( lab, &vl, sf, NULL );
        return( rc );
    }

    /*
     * process each source line
     */
    exm = EditFlags.ExMode;
    wfb = EditFlags.WatchForBreak;
    ssa = EditFlags.SourceScriptActive;
    EditFlags.SourceScriptActive = TRUE;
    EditFlags.WatchForBreak = TRUE;
    EditFlags.ExMode = TRUE;
    curr = sf->next;
    while( curr != NULL ) {

        cTokenID = curr->token - SRC_T_NULL - 1;

        if( !EditFlags.Starting ) {
            if( EditFlags.BreakPressed ) {
                ClearBreak();
                break;
            }
        }
        rc = LastError = ERR_NO_ERR;
        if( curr->data != NULL ) {
            strcpy( tmp, curr->data );
        } else {
            tmp[0] = 0;
        }

        if( EditFlags.Appending ) {
            if( curr->hasvar) {
                Expand( tmp, &vl );
            }
            rc = AppendAnother( tmp );
            goto evil_continue;
        }

        if( cTokenID == PCL_T_ENDFILETYPESOURCE ) {
            rc = FTSEnd();
            goto evil_continue;
        }

        if( EditFlags.FileTypeSource ) {
            rc = FTSAddCmd( tmp, curr->token );
            goto evil_continue;
        }

        if( curr->token > SRC_T_NULL ) {

            if( curr->hasvar) {
                Expand( tmp, &vl );
            }
            rc = TryCompileableToken( cTokenID, tmp, FALSE, 0 );
            if( rc == NOT_COMPILEABLE_TOKEN ) {
                rc = ProcessWindow( cTokenID, tmp );
            }
            if( rc < ERR_NO_ERR ) {
                rc = ERR_NO_ERR;
            }

        } else switch( curr->token ) {
        case SRC_T_ATOMIC:
            if( atomic == NULL ) {
                atomic = UndoStack;
                StartUndoGroup( atomic );
            }
            break;

        case SRC_T_IF:
            rc = SrcIf( &curr, &vl );
            break;

        case SRC_T_GOTO:
            rc = SrcGoTo( &curr, tmp, lab );
            break;

        case SRC_T_LABEL:
            break;

        case SRC_T_RETURN:
            if( curr->data != NULL ) {
                int     ret;
                GetErrorTokenValue( &ret, curr->data );
                rc = ret;
            } else {
                rc = ERR_NO_ERR;
            }
            goto evil_exit;

        case SRC_T_GET:
            SrcGet( tmp, &vl );
            rc = ERR_NO_ERR;
            break;

        case SRC_T_INPUT:
            LastRC = SrcInput( tmp, &vl );
            if( LastRC != NO_VALUE_ENTERED && LastRC != ERR_NO_ERR ) {
                rc = LastRC;
            }
            break;

        case SRC_T_NEXTWORD:
            rc = SrcNextWord( tmp, &vl );
            break;

        case SRC_T_ASSIGN:
            rc = SrcAssign( tmp, &vl );
            break;

        case SRC_T_EXPR:
            rc = SrcExpr( curr, &vl );
            break;

        case SRC_T_OPEN:
            LastRC = SrcOpen( curr, &vl, &fi, tmp );
            if( LastRC != ERR_FILE_NOT_FOUND && LastRC != ERR_NO_ERR ) {
                rc = LastRC;
            }
            break;

        case SRC_T_READ:
            LastRC = SrcRead( curr, &fi, tmp, &vl );
            if( LastRC != END_OF_FILE && LastRC != ERR_NO_ERR ) {
                rc = LastRC;
            }
            break;

        case SRC_T_WRITE:
            rc = SrcWrite( curr, &fi, tmp, &vl );
            break;

        case SRC_T_CLOSE:
            rc = SrcClose( curr, &vl, &fi, tmp );
            break;

        default:
#ifdef __WIN__
            {
                if( RunWindowsCommand( tmp, &LastRC, &vl ) ) {
                    rc = LastRC;
                    break;
                }
            }
#endif
            if( curr->hasvar ) {
                Expand( tmp, &vl );
            }
            LastRC = RunCommandLine( tmp );
            if( LastRC == DO_NOT_CLEAR_MESSAGE_WINDOW ) {
                LastRC = LastError;
            }
            break;
        }

evil_continue:
        if( rc != ERR_NO_ERR ) {
            break;
        }
        curr = curr->next;

    }

evil_exit:
    if( EditFlags.Appending ) {
        AppendAnother( "." );
    }
    if( curr != NULL ) {
        *ln = curr->line;
    } else {
        *ln = CurrentSrcLine;
        rc = ERR_NO_ERR;
    }
    EditFlags.WatchForBreak = wfb;
    EditFlags.SourceScriptActive = ssa;
    EditFlags.ScriptIsCompiled = sicmp;
    EditFlags.ExMode = exm;
    if( res != NULL && !EditFlags.CompileScript ) {
        sf = NULL;
        lab = NULL;
    }
    finiSource( lab, &vl, sf, atomic );
    return( rc );

} /* Source */
BOOL CShockWaveEffect::Process(FLOAT time)
{
	FLOAT fDeltaTime, fProcessedTime;
	BOOL bRet, bRender;
	if(!PreProcess(time, bRet, bRender, fDeltaTime, fProcessedTime))
	{
		if(!bRender) SetNotRenderAtThisFrame();
		return bRet;
	}

	//color 정보
	FLOAT fadeVal = this->GetFadeValue(fProcessedTime);
	if(fadeVal == 1.0f && m_bColorWhite)
	{
		//nothing
	}
	else
	{
		m_vectorGFXColor.clear();
		m_vectorGFXColor.reserve(m_iSplitCount*2);
		UBYTE ubColElement = UBYTE(255.0f * fadeVal);
		GFXColor col;
		if( m_eBlendType == PBT_BLEND || m_eBlendType == PBT_ADDALPHA )
		{
			col = 0xFFFFFF00 | ubColElement; //fade by alpha
		}
		else if( m_eBlendType == PBT_ADD )
		{
			col = (ubColElement << 24) | (ubColElement << 16) | (ubColElement << 8) | 0x000000FF; //fade by color
		}
		else col = 0xFFFFFFFF;	//fade 의미 없음.
		for(INDEX i=0; i<m_iSplitCount; ++i)
		{
			m_vectorGFXColor.push_back(col);
			m_vectorGFXColor.push_back(col);
		}
	}

	//wave 정보
	m_ssHeight.Prepare();
	FLOAT3D height(0, m_ssHeight.Value(fProcessedTime), 0);
	FLOAT radiusInner = 0, radiusOuter = 0;
	m_ssRadius.Prepare();
	m_ssWidth.Prepare();
	if(m_bInnerBasis)
	{
		radiusInner = m_ssRadius.Value(fProcessedTime);
		radiusOuter = radiusInner + m_ssWidth.Value(fProcessedTime);
	}
	else
	{
		radiusOuter = m_ssRadius.Value(fProcessedTime);
		radiusInner = radiusOuter - m_ssWidth.Value(fProcessedTime);
	}

	//tag의 정보
	if(m_ePosition == EOTT_ALWAYS) m_vTagPos = m_ptrAttachTag->CurrentTagInfo().m_vPos;
	if(m_eRotation == EOTT_ALWAYS) m_qTagRot = m_ptrAttachTag->CurrentTagInfo().m_qRot;

	//gfx vertex fill, every frame
	GFXVertex vtx;
	FLOAT3D pos;
	const FLOAT angleUnit = 2 * PI / m_iSplitCount;
	FLOAT angle = 0;
	INDEX index = 0;
	m_vectorGFXVertex.clear();
	m_vectorGFXColor.reserve(m_iSplitCount*2);
	for(INDEX i=0; i<m_iSplitCount; ++i)
	{
		index = 2*i+0;
		pos = m_vectorMoveVector[index] * radiusOuter + height;
		RotateVector(pos, m_qTagRot);
		pos += m_vTagPos;
		vtx.x = pos(1);	vtx.y = pos(2);	vtx.z = pos(3);
		m_vectorGFXVertex.push_back(vtx);

		++index;
		pos = m_vectorMoveVector[index] * radiusInner;
		RotateVector(pos, m_qTagRot);
		pos += m_vTagPos;
		vtx.x = pos(1);	vtx.y = pos(2);	vtx.z = pos(3);
		m_vectorGFXVertex.push_back(vtx);
		angle += angleUnit;
	}

	PostProcess();
	return TRUE;
}
int main(int argc, const char* argv[])
{
    mutl::ArgumentParser parser;

    if( false == parser.Initialize(argc, argv, descs, sizeof(descs)/sizeof(Desc))
        || parser.IsEnabled("h")
        || parser.GetArgumentCount() < 2 )
    {
        usage(param);
        return 0;
    }
    param.upperValue = 32767.0;
    param.optimize = false;
    param.optimizeSeparately = false;
    param.outputLog = false;
    param.inputLength = -1;

    param.inputFilepath = parser.GetArgument(0);
    param.referenceFilepath = parser.GetArgument(1);

    size_t& tapps = param.tapps;

    tapps = 256;
    if (parser.IsEnabled("m"))
    {
        tapps = atoi( parser.GetOption("m").c_str() );
    }
    if ( tapps < 1 )
    {
        ERROR_LOG("tapps (an argument of \"-m\" swtich) must be larger than 0: %d\n", static_cast<int>(tapps) );
        return 0;
    }
    if (parser.IsEnabled("c"))
    {
        param.upperValue = atof( parser.GetOption("c").c_str() );
        if (param.upperValue <= 0.0)
        {
            ERROR_LOG("The specified value with -c (%f) must be positive.\n", param.upperValue);
            return 0;
        }
    }
    if (parser.IsEnabled("l"))
    {
        param.inputLength = atoi( parser.GetOption("l").c_str() );
        if (param.inputLength < 1)
        {
            ERROR_LOG("The specified value with -l (%d) must be positive.\n", static_cast<int>(param.inputLength) );
            return 0;
        }
    }
    if (parser.IsEnabled("opt"))
    {
        param.optimize = true;
    }
    if (parser.IsEnabled("sep"))
    {
        param.optimizeSeparately = true;
    }
    if (parser.IsEnabled("log"))
    {
        param.outputLog = true;
    }

    std::string outputPrefix;
    if (parser.IsEnabled("o"))
    {
        outputPrefix = parser.GetOption("o");
    }
    else
    {
        mutl::NodePath _inputPath(param.inputFilepath);
        mutl::NodePath _referencePath(param.referenceFilepath);
        char tappsString[11];
        sprintf(tappsString, "%d", static_cast<int>(tapps));
        outputPrefix = std::string("./Af_")
            + std::string(tappsString)
            + std::string("tapps_")
            + _inputPath.GetBasename()
            + std::string("_")
            + _referencePath.GetBasename();
    }

    std::string outdir("./");
    if ( parser.IsEnabled("d") )
    {
        outdir = parser.GetOption("d");
        outdir += std::string("/");
    }
    param.outputBase = outdir + outputPrefix;

    // Display messages real-time
    setvbuf(stdout, NULL, _IONBF, 0);

    LOG("Input: %s\n", param.inputFilepath.c_str());
    LOG("Reference: %s\n", param.referenceFilepath.c_str());
    LOG("Tapps: %d\n", static_cast<int>(tapps) );
    LOG("Clamped Value: %g\n", param.upperValue);
    LOG("\n");

    status_t status;
    status = Setup(&param);
    if ( NO_ERROR != status )
    {
        ERROR_LOG("Failed in Startup(): %d\n", status);
        return 0;
    }
    LOG("[Input]\n");
    LOG("    File        : %s\n", param.inputFilepath.c_str());
    LOG("    SamplingRate: %d\n", static_cast<int>(param.samplingRate) );
    LOG("    Length      : %d\n", static_cast<int>(param.inputSignal.GetColumnLength()) );
    LOG("\n");
    LOG("[Reference]\n");
    LOG("    File  : %s\n", param.referenceFilepath.c_str());
    LOG("    Length: %d\n", static_cast<int>(param.referenceSignal.GetLength()));
    LOG("\n");

    status = PreProcess(&param);
    if ( NO_ERROR != status )
    {
        ERROR_LOG("Failed in PreProcess(): %d\n", status);
        return 0;
    }

    status = Process(&param);
    if ( NO_ERROR != status )
    {
        ERROR_LOG("Failed in Estimater(): %d\n", status);
        return 0;
    }

    status = PostProcess(&param);
    if ( NO_ERROR != status )
    {
        ERROR_LOG("Failed in PostProcess(): %d\n", status);
        return 0;
    }

    status = Cleanup(&param);
    if ( NO_ERROR != status )
    {
        ERROR_LOG("Failed in Cleanup(): %d\n", status);
        return 0;
    }
    return 0;
}
Exemple #23
0
// Create the model from an X-File, returns true on success
bool CMesh::Load( const string& fileName )
{
	// Create a X-File import helper class
	CImportXFile importFile;

	// Add media folder path
	string fullFileName = MediaFolder + fileName;

	// Check that the given file is an X-file
	if (!importFile.IsXFile( fullFileName ))
	{
		return false;
	}

	// Import the file, return on failure
	EImportError error = importFile.ImportFile( fullFileName );
	if (error != kSuccess)
	{
		if (error == kFileError)
		{
			string errorMsg = "Error loading mesh " + fullFileName;
			SystemMessageBox( errorMsg.c_str(), "Mesh Error" );
		}
		return false;
	}

	// Release any existing geometry
	if (m_HasGeometry)
	{
		ReleaseResources();
	}

	// Get node data from import class
	m_NumNodes = importFile.GetNumNodes();
	m_Nodes = new SMeshNode[m_NumNodes];
	if (!m_Nodes)
	{
		return false;
	}
	for (TUInt32 node = 0; node < m_NumNodes; ++node)
	{
		importFile.GetNode( node, &m_Nodes[node] );
	}

	// Get submesh data from import class - convert to DirectX data for rendering
	// but retain original data for easy access to vertices / faces
	TUInt32 requiredSubMeshes = importFile.GetNumSubMeshes();
	m_SubMeshes = new SSubMesh[requiredSubMeshes];
	m_SubMeshesDX = new SSubMeshDX[requiredSubMeshes];
	if (!m_SubMeshes || !m_SubMeshesDX)
	{
		ReleaseResources();
		return false;
	}
	for (m_NumSubMeshes = 0; m_NumSubMeshes < requiredSubMeshes; ++m_NumSubMeshes)
	{
		// Determine if the render method for this mesh needs tangents
		ERenderMethod meshMethod = importFile.GetSubMeshRenderMethod( m_NumSubMeshes );
		bool needTangents = RenderMethodUsesTangents( meshMethod );

		importFile.GetSubMesh( m_NumSubMeshes, &m_SubMeshes[m_NumSubMeshes], needTangents );
		if (!CreateSubMeshDX( m_SubMeshes[m_NumSubMeshes], &m_SubMeshesDX[m_NumSubMeshes] ))
		{
			ReleaseResources();
			return false;
		}
	}

	// Get material data from import class, also load textures
	TUInt32 requiredMaterials = importFile.GetNumMaterials();
	m_Materials = new SMeshMaterialDX[requiredMaterials];
	if (!m_Materials)
	{
		ReleaseResources();
		return false;
	}
	for (m_NumMaterials = 0; m_NumMaterials < requiredMaterials; ++m_NumMaterials)
	{
		SMeshMaterial importMaterial; 
		importFile.GetMaterial( m_NumMaterials, &importMaterial );
		if (!CreateMaterialDX( importMaterial, &m_Materials[m_NumMaterials] ))
		{
			ReleaseResources();
			return false;
		}
	}

	// Geometry pre-processing - just calculating bounding box in this example
	if (!PreProcess())
	{
		ReleaseResources();
		return false;
	}

	m_HasGeometry = true;
	return true;
}
Exemple #24
0
//------------------------------------------------------------------------
// Name: DoExport()
// Desc: Start the exporter!
//------------------------------------------------------------------------
int SMDExporter::DoExport( const TCHAR* name,ExpInterface* ei,Interface* i,
						   BOOL suppressPrompts,DWORD options )
{
	// Set a global prompt display switch
	showPrompts = suppressPrompts ? FALSE : TRUE;
	exportSelected = (options & SCENE_EXPORT_SELECTED) ? TRUE : FALSE;

	// Store the Interface pointer
	m_ip = i;
    m_sFilename = name;

	if( showPrompts )
	{
		// If user click "Cancel" then exit the plug-in
		if( !DialogBoxParam(hInstance,"SMDExporterDlg",m_ip->GetMAXHWnd(),ExporterDlgProc,(LPARAM)this) )
			return TRUE;
	}

	// Open a file to write data
	m_pFile = fopen( name,"wb" );
	if( !m_pFile ) return FALSE;

	// Startup the progress bar.
	m_ip->ProgressStart( GetString(IDS_PROGRESS_MSG),TRUE,fn,NULL );

	// Get the total node count by traversing the scene
	// It's nice to have a accurate progress bar
	m_nTotalNodeCount   = 0;
	m_nCurNode          = 0;
	PreProcess( m_ip->GetRootNode(),m_nTotalNodeCount );

	// Call our node Enumerator.
	// The nodeEnum function will recourse itself and
	// Export each object found in the scene
	int numChildren = m_ip->GetRootNode()->NumberOfChildren();

    fputc( 'S',m_pFile );
    fputc( 'M',m_pFile );
    fputc( 'D',m_pFile );
    fputc( '\0',m_pFile );
    ExportBinaryHeader();

	// Check the count of mesh
	m_nNumMeshes = m_nTotalNodeCount;
	m_pMeshes = new SMDMESH[m_nNumMeshes];
    memset( m_pMeshes,0,sizeof(SMDMESH)*m_nNumMeshes );

	for( int c=0;c<numChildren;c++ )
	{
		if( m_ip->GetCancel() ) break;

		nodeEnum( m_ip->GetRootNode()->GetChildNode(c) );
	}

	// Exported all datas, Close the file
	m_ip->ProgressEnd();
	fclose( m_pFile );

	// Clean up the memory
	CleanUpMem();

	return TRUE;
}
struct sBinaryRelation LexicalAnalyzer(char *pcSubName)//词法分析器
{
	static char fcFirst='Y';
	//初始化扫描指示器为第一个元素
	static char *fpcStart;
	char **fppcStart=&fpcStart;//取fpcstart的地址
	static char *fpcSerching;
	char **fppcfpcSerching=&fpcSerching;//取fpcSerching的地址
	static int iLine=1;//记录当前的行数
	int *piLine=&iLine;//指向行数的指针
	struct sBinaryRelation sTempResult;//存放返回结果

	if(fcFirst=='Y')//第一次调用装入bufferl
	{
		PreProcess(pcSubName);
		fcFirst='N';
		fpcStart=acScanBufL;//将start和serch都指向第一个地址
	}

	while(*fpcStart==0x20) 
	{
		if(!CheckEndBuffer(fppcStart,pcSubName)) fpcStart++;//检查是否越界,若没越界将start指针指向一个不为空格的字符
	}
	fpcSerching=fpcStart;//serching指向start
	//fpcSerching++;//serching指向start的下一个位置

	while(*fpcSerching!=0x00)
	{
		if(CheckNewLine(*fpcStart,piLine))//检查回车,记录行数加一
		{
			//待扩建是否将\n也算作标识符
			fpcStart++;
			fpcSerching=fpcStart;//serching指向start
		}
		else if(isalpha(*fpcStart))//第一个字符是字母,为关键字
		{
			char cTempResult[SBUFSIZE]={0};
			char *pcCurrent=cTempResult;

			//检查是否为变量或关键字
			while(isalnum(*fpcSerching))//下一个是字符或数字
			{
				//if(isspace(*fpcSerching)) break;//若为空格结束

				*(pcCurrent++)=*fpcSerching;//将字符保存到临时数组,并且指针后移

				if(!CheckEndBuffer(fppcfpcSerching,pcSubName)) fpcSerching++; //检查是否越界,若没越界将serching++
			}//循环完成时fpceSerching指向当前标识符的下一个位置	
			//将start和serching重合
			fpcStart=fpcSerching;

			//返回当前的标识符放到结构体中
			int KeyWordScript;//关键字的下标
			if((KeyWordScript=CheckKeyWords(cTempResult))!=0)//检查是否为关键字还是普通变量
			{
				sTempResult.iId=0;//标志符置为0,关键字的下标
				sTempResult.iSubScript=KeyWordScript;
				sTempResult.acTempValName[0]='\0';//赋值
			}
			else//普通变量
			{
				sTempResult.iId=1;//单词为变量
				int i=-1;
				while(cTempResult[++i]!='\0')//将变量的值赋给变量名字数组
				{
					sTempResult.acTempValName[i]=cTempResult[i];
				}
				sTempResult.acTempValName[i]=cTempResult[i];//赋值个'\0'
				sTempResult.iSubScript=0;//赋值
			}
			//返回结构体
			
			return sTempResult;
		}
		else if(isdigit(*fpcStart))//如果是数字常量
		{
			int iTemp=0;
			while(*fpcSerching!=0x20)//下面字符都要是数字
			{
				if((!isdigit(*fpcSerching))&&(isalpha(*fpcSerching)))//若后面是字幕或者不是操作符
				{
					printf("词法分析:");
					Error(iLine);//不是数字报错
					printf(" %d %c非法字符\n",iTemp,*fpcSerching);
				}
				iTemp=iTemp*10+int(*fpcSerching-0x30);//将数字字符转化为整形
				if(!CheckEndBuffer(fppcfpcSerching,pcSubName)) fpcSerching++; //检查是否越界,若没越界将serching++
				//判断是否是;若下一个字符是分号或者操作符就结束
				if(*fpcSerching==';') break;
				if(CheckOperate(*fpcSerching)) break;
			}
			//循环完成时fpceSerching指向当前标识符的下一个位置
			fpcStart=fpcSerching;//将start和serching重合

			//返回当前的标识符放到结构体中
			sTempResult.iId=2;
			sTempResult.iSubScript=iTemp;
			sTempResult.acTempValName[0]='\0';//赋值
			return sTempResult;

		}
		else if(CheckOperate(*fpcStart)) //判断运算符
		{
			int iTempOperateOffset;//记录标识符下标
			iTempOperateOffset=CheckOperate(*fpcStart);
			//不需要因为serching本来就在start的下一个fpceSerching++;
			if(!CheckEndBuffer(fppcStart,pcSubName)) fpcStart=++fpcSerching;//检查serching是否越界,若没越界将start和serching重合
			
			//返回当前的标识符放到结构体中
			sTempResult.iId=3;
			sTempResult.iSubScript=iTempOperateOffset;
			sTempResult.acTempValName[0]='\0';//赋值
			return sTempResult;

		}
		else
		{
			printf("词法分析:");
			Error(iLine);//不是数字报错
			printf(" %c非法字符\n",*fpcSerching);
			exit(1);//退出程序
		}
				 
	}
	if(*fpcSerching!=0) printf("词法分析:未知错误\n");//若不为结束符,显示未知错误
	exit(1);//失败返回空
}
Exemple #26
0
// Start the exporter!
// This is the real entrypoint to the exporter. After the user has selected
// the filename (and he's prompted for overwrite etc.) this method is called.
int AscOut::DoExport(const TCHAR *name,ExpInterface *ei,Interface *i, BOOL suppressPrompts, DWORD options) 
{
	// Set a global prompt display switch
	showPrompts = suppressPrompts ? FALSE : TRUE;
	exportSelected = (options & SCENE_EXPORT_SELECTED) ? TRUE : FALSE;

	// Grab the interface pointer.
	ip = i;

	// Get the options the user selected the last time
	ReadConfig();

	if(showPrompts) {
		// Prompt the user with our dialogbox, and get all the options.
		if (!DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_ASCOUT_DLG),
			ip->GetMAXHWnd(), ExportDlgProc, (LPARAM)this)) {
			return 1;
		}
	}
	
	sprintf(szFmtStr, "%%4.%df", nPrecision);

	// Open the stream
	pStream = _tfopen(name,_T("wt"));
	if (!pStream) {
		return 0;
	}
	
	// Startup the progress bar.
	ip->ProgressStart(GetString(IDS_PROGRESS_MSG), TRUE, fn, NULL);

	// Get a total node count by traversing the scene
	// We don't really need to do this, but it doesn't take long, and
	// it is nice to have an accurate progress bar.
	nTotalNodeCount = 0;
	nCurNode = 0;
	PreProcess(ip->GetRootNode(), nTotalNodeCount);
	
	// First we write out a file header with global information. 
	ExportGlobalInfo();

	int numChildren = ip->GetRootNode()->NumberOfChildren();
	
	// Call our node enumerator.
	// The nodeEnum function will recurse into itself and 
	// export each object found in the scene.
	
	for (int idx=0; idx<numChildren; idx++) {
		if (ip->GetCancel())
			break;
		nodeEnum(ip->GetRootNode()->GetChildNode(idx), 0);
	}

	// We're done. Finish the progress bar.
	ip->ProgressEnd();

	// Close the stream
	fclose(pStream);

	// Write the current options to be used next time around.
	WriteConfig();

	return 1;
}
void sseConcurrentContextGuard::Render(sseGrafxInterface *pRenderer)
{
	PreProcess(pRenderer, m_pTextureLoader);
	DrawObject(pRenderer, m_pTextureLoader);
	PostProcess(pRenderer, m_pTextureLoader);
}