Esempio n. 1
0
mEResult mCAseWriter::WriteAseFileData( mCScene const & a_sceneSource, mCIOStreamBinary & a_streamDest, SOptions const a_Options )
{
    s_bAscFormat = a_Options.m_bGothicAscFormat;
    a_streamDest.Write( GetTokenLine( "3DSMAX_ASCIIEXPORT", ( a_Options.m_bGothicAscFormat ? "110" : "200" ) ) );
    a_streamDest.Write( GetTokenLine( "COMMENT", "\"Created using Baltram's ASC and ASE file writer\"" ) );
    a_streamDest.Write( StartBlock( "SCENE" ) );
    a_streamDest.Write( GetTokenLine( "SCENE_FILENAME", "\"" + g_GetFileName( a_sceneSource.GetName() ) + "\"" ) );
    a_streamDest.Write( GetTokenLine( "SCENE_FIRSTFRAME", "0" ) );
    a_streamDest.Write( GetTokenLine( "SCENE_LASTFRAME", "100" ) );
    a_streamDest.Write( GetTokenLine( "SCENE_FRAMESPEED", "30" ) );
    a_streamDest.Write( GetTokenLine( "SCENE_TICKSPERFRAME", "160" ) );
    a_streamDest.Write( GetTokenLine( "SCENE_BACKGROUND_STATIC", "0.0000\t0.0000\t0.0000" ) );
    a_streamDest.Write( GetTokenLine( "SCENE_AMBIENT_STATIC", "0.0000\t0.0000\t0.0000" ) );
    a_streamDest.Write( EndBlock() );
    a_streamDest.Write( StartBlock( "MATERIAL_LIST" ) );
    mTArray< mCNode const * > arrNodes;
    a_sceneSource.GetNodesSortedByLinks( arrNodes );
    mCScene sceneTemp;
    mCScene const & sceneMaterials = s_bAscFormat ? sceneTemp : a_sceneSource;
    mCNode nodeBip01( "Bip01" );
    if ( s_bAscFormat )
    {
        arrNodes.InsertAt( 0, &nodeBip01 );
        for ( MIUInt u = a_sceneSource.GetNumNodes(); u--; )
        {
            mCNode const & nodeNode = *a_sceneSource.GetNodeAt( u );
            MIUInt uMaterialIndex = a_sceneSource.GetMaterialIndexByName( nodeNode.GetMaterialName() );
            if ( ( uMaterialIndex != MI_DW_INVALID ) && ( sceneTemp.GetNumMaterials() == 0 ) )
                sceneTemp.AddMaterial( *a_sceneSource.GetMaterialAt( uMaterialIndex ) );
        }
    }
    MIUInt const uMaterialCount = sceneMaterials.GetNumMaterials();
    a_streamDest.Write( GetTokenLine( "MATERIAL_COUNT", mCString().Format( "%u", uMaterialCount ) ) );
    for ( MIUInt u = 0; u != uMaterialCount; ++u )
    {
        a_streamDest.Write( StartBlock( mCString().Format( "MATERIAL %u", u ) ) );
        WriteMaterial( sceneMaterials.GetMaterialAt( u ), a_streamDest );
        a_streamDest.Write( EndBlock() );
    }
    a_streamDest.Write( EndBlock() );
    for ( MIUInt u = 0, ue = arrNodes.GetCount(); u != ue; ++u )
    {
        if ( u && ( !arrNodes[ u ]->GetName().CompareNoCase( "Bip01" ) ) )
            continue;
        a_streamDest.Write( StartBlock( ( arrNodes[ u ]->HasMesh() || arrNodes[ u ]->GetIsBone() || !u ) ? "GEOMOBJECT" : "HELPEROBJECT" ) );
        WriteNode( a_sceneSource, *arrNodes[ u ], a_streamDest, a_Options );
        a_streamDest.Write( EndBlock() );
    }
    if ( a_Options.m_bGothicAscFormat )
    {
        for ( MIUInt u = 0; u != a_sceneSource.GetNumNodes(); ++u )
            if ( a_sceneSource.GetNodeAt( u )->HasSkin() && a_sceneSource.GetNodeAt( u )->HasMesh() )
                WriteSkin( a_sceneSource, u, a_streamDest );
    }
    return mEResult_Ok;
}
Esempio n. 2
0
STDMETHODIMP AitEncoder::Initialize(IStream *pIStream, WICBitmapEncoderCacheOption cacheOption)
{
    HRESULT result = E_INVALIDARG;

    if (pIStream)
    {
        result = S_OK;

        stream = pIStream;

        if (SUCCEEDED(result))
        {
            result = VerifyFactory();
        }

        // Remember the position of the header for later reference
        if (SUCCEEDED(result))
        {
            LARGE_INTEGER zero = { 0 };
            result = stream->Seek(zero, STREAM_SEEK_CUR, &headerPos);
        }

        // Write the header with a placeholder for the number of frames
        if (SUCCEEDED(result))
        {
            BeginBlock(stream, "AIT", 0xFFFFFFFF);            
            OutputValue(stream, (UINT)0);
            result = EndBlock(stream);
        }
    }    
    return result;
}
Esempio n. 3
0
/***************************************************
OnMouseMove
	is called when the user selects cells using the mouse
	droagging functionality.
Params:
	col, row	- coordinates of the cell user moved over
	nFlags		- additional information about the mouse move
Returns:
	<none>
*****************************************************/
void CUGMultiSelect::OnMouseMove(int col,long row, UINT nFlags)
{
	UNREFERENCED_PARAMETER(nFlags);

	if(m_mode&UG_MULTISELECT_OFF)
		return;

	if(col == m_lastCol && row == m_lastRow)
		return;
	
	EndBlock(col,row);
}
Esempio n. 4
0
static HRESULT OutputBitmapPalette(IStream *stream, UINT frameNum, IWICPalette *palette)
{
    HRESULT result = E_INVALIDARG;

    if (stream && palette)
    {
        UINT colorCount = 0;
        WICColor *colors = NULL;

        result = S_OK;

        if (SUCCEEDED(result))
        {
            result = palette->GetColorCount(&colorCount);
        }

        if (colorCount > 0)
        {

            if (SUCCEEDED(result))
            {
                colors = new WICColor[colorCount];

                if (NULL == colors)
                {
                    result = E_OUTOFMEMORY;
                }
            }

            if (SUCCEEDED(result))
            {
                UINT cActualColors = 0;
                result = palette->GetColors(colorCount, colors, &cActualColors);
            }

            if (SUCCEEDED(result))
            {
                BeginBlock(stream, "PAL", frameNum);
                OutputValue(stream, colorCount);
                OutputValues(stream, colors, colorCount);
                result = EndBlock(stream);
            }

            if (colors)
            {
                delete[] colors;
            }
        }
    }

    return result;
}
Esempio n. 5
0
 void DiProfiler::EndFrame()
 {
     if (mCurrent != mRoot)
     {
         EndBlock();
         ++mIntervalFrames;
         ++mTotalFrames;
         if (!mTotalFrames)
             ++mTotalFrames;
         mRoot->EndFrame();
         mCurrent = mRoot;
     }
 }
void Profiler::EndFrame()
{
    if (current_ != root_)
    {
        EndBlock();
        ++intervalFrames_;
        ++totalFrames_;
        if (!totalFrames_)
            ++totalFrames_;
        root_->EndFrame();
        current_ = root_;
    }
}
Esempio n. 7
0
bool SirenTextParser::EndType(StringRef& refProto)
{
	refProto = refProto.TrimBegin();
	intp index = refProto.IndexOf('}');
	if (index < 0)
	{
		Log::Error("Cannot find }");
		return false;
	}

	refProto = refProto.SubString(index + 1);
	return EndBlock(refProto);;
}
Esempio n. 8
0
static HRESULT OutputColorContext(IStream *stream, UINT frameNum, UINT colorContextCount, IWICColorContext **colorContext)
{
    HRESULT result = E_INVALIDARG;
    if (stream && colorContext)
    {
        BeginBlock(stream, "COL", frameNum);
        for(int i = 0; i < colorContextCount; i++)
        {
            UINT numBytes = 0;
            BYTE *bytes = NULL;
    
            result = S_OK;

            if (SUCCEEDED(result))
            {
                result = colorContext[i]->GetProfileBytes(0, NULL, &numBytes);
            }

            if (numBytes > 0)
            {
                if (SUCCEEDED(result))
                {
                    bytes = new BYTE[numBytes];
    
                    if (NULL == bytes)
                    {
                        result = E_OUTOFMEMORY;
                    }
                }

                if (SUCCEEDED(result))
                {
                    result = colorContext[i]->GetProfileBytes(numBytes, bytes, &numBytes);
                }

                if (SUCCEEDED(result))
                {                    
                    OutputValue(stream, numBytes);
                    OutputValues(stream, bytes, numBytes);                    
                }

                if (bytes)
                {
                    delete[] bytes;
                }
            }
       }
       result = EndBlock(stream);
    }
    return result;
}
Esempio n. 9
0
/***************************************************
OnLClick
	is called by the grid control to inform the multislect
	class that the user has clicked a left mouse button
	over the grid area.
Params:
	col, row	- coordinates of the cell user clicked on
	nFlags		- additional information about the mouse click
Returns:
	<none>
*****************************************************/
void CUGMultiSelect::OnLClick(int col,long row, UINT nFlags)
{
	if(m_mode&UG_MULTISELECT_OFF)
		return;

	m_lastCol = col;
	m_lastRow = row;

	if(nFlags&MK_CONTROL){
		StartBlock(col,row);
	}
	else if(nFlags&MK_SHIFT){
		EndBlock(col,row);
	}
	else{
		AddTotalRangeToDrawHints(&m_ctrl->m_CUGGrid->m_drawHint);
		ClearAll();
		StartBlock(col,row);
	}
}
Esempio n. 10
0
bool SirenTextParser::ReadFunctionArguments(StringRef& refProto, List<StringRef>& outArguments)
{
	//read arguments
	intp endIndex = refProto.IndexOf(')');
	if (endIndex < 0)
	{
		Log::Error("Invalid function.Lost ')' ");
		return false;
	}
	StringRef args = refProto.SubString(1, endIndex - 1);
	bool isSuccess = StringParser::Split(args, ",", outArguments, false);
	if (!isSuccess)
	{
		Log::FormatError("Invalid function argument:{}", args);
		return false;
	}

	refProto = refProto.SubString(endIndex);
	return EndBlock(refProto);
}
Esempio n. 11
0
void CObjectIStreamJson::ReadAnyContentObject(CAnyContentObject& obj)
{
    obj.Reset();
    string value;
    string name = ReadKey();
    obj.SetName(name);
    if (PeekChar(true) == '{') {
        StartBlock('{');        
        while (NextElement()) {
            name = ReadKey();
            value = ReadValue();
            if (name[0] != '#') {
                obj.AddAttribute(name,kEmptyStr,value);
            } else {
                obj.SetValue(value);
            }
        }
        EndBlock('}');
        return;
    }
    value = ReadValue();
    obj.SetValue(value);
}
Esempio n. 12
0
/***************************************************
OnKeyMove
	Is called when the user moves within the grid
	using the keyboard.
Params:
	col, row	- coordinates of of the cell that the
				  user has just mode to.
Returns:
	<none>
*****************************************************/
void CUGMultiSelect::OnKeyMove(int col,long row)
{
	if(m_mode&UG_MULTISELECT_OFF)
		return;

	if(col == m_lastCol && row == m_lastRow)
		return;

	if(GetKeyState(VK_SHIFT) <0)
	{
		EndBlock(col,row);
	}
	else if(GetKeyState(VK_CONTROL) <0)
	{
		StartBlock(col,row);
	}
	else
	{
		AddTotalRangeToDrawHints(&m_ctrl->m_CUGGrid->m_drawHint);
		ClearAll();
		StartBlock(col,row);
	}
}
Esempio n. 13
0
static HRESULT OutputBitmapSource(IStream *stream, LPCSTR name, UINT frameNum,
                                  double dpiX, double dpiY,
                                  IWICBitmapSource *source)
{
    HRESULT result = E_INVALIDARG;

    if (stream && source)
    {
        UINT width = 0, height = 0;
        UINT stride = 0;
        WICPixelFormatGUID pixelFormat;
        BYTE *pixels = NULL;

        result = S_OK;

        // Retrieve the dimensions of the source
        if (SUCCEEDED(result))
        {
            result = source->GetSize(&width, &height);
        }

        // Optionally retrieve the resolution
        if (SUCCEEDED(result) && (dpiX == 0 || dpiY == 0))
        {
            result = source->GetResolution(&dpiX, &dpiY);
        }

        // Get the pixel format
        if (SUCCEEDED(result))
        {
            result = source->GetPixelFormat(&pixelFormat);
        }

        // Get the stride
        if (SUCCEEDED(result))
        {
            stride = GetScanlineStride(width, pixelFormat);

            if (stride < 1)
            {
                result = E_UNEXPECTED;
            }
        }

        // Allocate the pixels
        if (SUCCEEDED(result))
        {
            pixels = new BYTE[stride * height];

            if (NULL == pixels)
            {
                result = E_OUTOFMEMORY;
            }
        }

        // Get the pixels
        if (SUCCEEDED(result))
        {
            WICRect rct;
            rct.X = 0;
            rct.Y = 0;
            rct.Width = width;
            rct.Height = height;

            result = source->CopyPixels(&rct, stride, stride * height, pixels);
        }

        // Output everything
        if (SUCCEEDED(result))
        {
            BeginBlock(stream, name, frameNum);
            OutputValue(stream, width);
            OutputValue(stream, height);
            OutputValue(stream, dpiX);
            OutputValue(stream, dpiY);
            OutputValue(stream, stride);
            OutputValue(stream, pixelFormat);
            OutputValues(stream, pixels, stride*height);
            result = EndBlock(stream);
        }

        if (pixels)
        {
            delete[] pixels;
        }
    }

    return result;
}
Esempio n. 14
0
void CObjectIStreamJson::EndChoice(void)
{
    EndBlock((GetStackDepth() > 1 && FetchFrameFromTop(1).GetNotag()) ? 0 : '}');
}
Esempio n. 15
0
void CObjectIStreamJson::EndContainer(void)
{
    EndBlock(']');
}
Esempio n. 16
0
void CObjectIStreamJson::EndOfRead(void)
{
    EndBlock('}');
}
void GERBER_PLOTTER::StartBlock( void* aData )
{
    // Currently, it is the same as EndBlock(): clear all aperture net attributes
    EndBlock( aData );
}
Esempio n. 18
0
void Context::Composite()
{
    //printf( "composite()\n");
    auto& targ = gfxtarget;
    int mww = targ.GetW();
    int mwh = targ.GetH();
    int wd2 = mww/2;
    int hd2 = mwh/2;
    int bufw = fbo_left->miW;
    int bufh = fbo_left->miH;
    //printf( "bufw<%d> mainwin_w<%d>\n", bufw, mww);
    using fxp_t = const lev2::FxShaderParam*;

    static auto fxi = targ.FXI();
    static auto gbi = targ.GBI();
    static auto txi = targ.TXI();

    using vtx_t = lev2::SVtxV12C4T16;

    static lev2::DynamicVertexBuffer<vtx_t> gvbuf( 1<<20 );

    const float kbound = 1.0;

    auto ltexture = fbo_left->GetTexture();
    auto rtexture = fbo_right->GetTexture();
    lev2::RenderContextInstData rcid;

    //////////////
    // LEFT
    //////////////
    {
        lev2::VtxWriter<vtx_t> vwriter;
        vwriter.Lock(&targ,&gvbuf,6);
            vwriter.RefInc() = vtx_t(-kbound,-kbound,0, 0,0, 0xffffffff);
            vwriter.RefInc() = vtx_t(+0,-kbound,0, 1,0, 0xffffffff);
            vwriter.RefInc() = vtx_t(+0,+kbound,0, 1,1, 0xffffffff);
            vwriter.RefInc() = vtx_t(-kbound,-kbound,0, 0,0, 0xffffffff);
            vwriter.RefInc() = vtx_t(+0,+kbound,0, 1,1, 0xffffffff);
            vwriter.RefInc() = vtx_t(-kbound,+kbound,0, 0,1, 0xffffffff);
        vwriter.UnLock(&targ);
        fxi->BeginBlock(fx_distort,rcid);
            fxi->BindPass(fx_distort,0);
                fxi->BindParamMatrix( fx_distort,par_mvp,fmtx4());
                fxi->BindParamFloat2( fx_distort, par_fbosiz, float(bufw), float(bufh) );
                fxi->BindParamFloat2( fx_distort, par_cbufsiz, float(mww), float(mwh) );
                fxi->BindParamFloat2( fx_distort, par_llctr, gLensCenter, 0.5f );
                fxi->BindParamFloat2( fx_distort, par_rlctr, 1.0f-gLensCenter, 0.5f );
                fxi->BindParamFloat2( fx_distort, par_lsctr, gScrCenter, 0.5f );
                fxi->BindParamFloat2( fx_distort, par_rsctr, 1.0f-gScrCenter, 0.5f );
                fxi->BindParamFloat( fx_distort, par_chromab, chromab );
                fxi->BindParamCTex( fx_distort,par_texms,ltexture);
                fxi->CommitParams();
                gbi->DrawPrimitiveEML(vwriter,lev2::EPRIM_TRIANGLES);
            fxi->EndPass(fx_distort);
        fxi->EndBlock(fx_distort);
    }
    //////////////
    // RIGHT
    //////////////
    {
        lev2::VtxWriter<vtx_t> vwriter;
        vwriter.Lock(&targ,&gvbuf,6);
            vwriter.RefInc() = vtx_t(-0,-kbound,0, 0,0, 0xffffffff);
            vwriter.RefInc() = vtx_t(+kbound,-kbound,0, 1,0, 0xffffffff);
            vwriter.RefInc() = vtx_t(+kbound,+kbound,0, 1,1, 0xffffffff);
            vwriter.RefInc() = vtx_t(-0,-kbound,0, 0,0, 0xffffffff);
            vwriter.RefInc() = vtx_t(+kbound,+kbound,0, 1,1, 0xffffffff);
            vwriter.RefInc() = vtx_t(-0,+kbound,0, 0,1, 0xffffffff);
        vwriter.UnLock(&targ);
        fxi->BeginBlock(fx_distort,rcid);
            fxi->BindPass(fx_distort,0);
                fxi->BindParamMatrix( fx_distort,par_mvp,fmtx4());
                fxi->BindParamFloat2( fx_distort, par_fbosiz, float(bufw), float(bufh) );
                fxi->BindParamFloat2( fx_distort, par_cbufsiz, float(mww), float(mwh) );
                fxi->BindParamFloat2( fx_distort, par_llctr, gLensCenter, 0.5f );
                fxi->BindParamFloat2( fx_distort, par_rlctr, 1.0f-gLensCenter, 0.5f );
                fxi->BindParamFloat2( fx_distort, par_lsctr, gScrCenter, 0.5f );
                fxi->BindParamFloat2( fx_distort, par_rsctr, 1.0f-gScrCenter, 0.5f );
                fxi->BindParamFloat( fx_distort, par_chromab, chromab );
                fxi->BindParamCTex( fx_distort,par_texms,rtexture);
                fxi->CommitParams();
                gbi->DrawPrimitiveEML(vwriter,lev2::EPRIM_TRIANGLES);
            fxi->EndPass(fx_distort);
        fxi->EndBlock(fx_distort);
    }

}
Esempio n. 19
0
static void EndOfStmt( void )
{
    do {
        switch( BlockStack->block_type ) {
        case T_LEFT_BRACE:
            EndBlock();
            break;
        case T_IF:
            if( CurToken == T_ELSE ) {
                ElseStmt();
                return;
            }
            DropBreakLabel();
            break;
        case T_ELSE:
            DropBreakLabel();
            break;
        case T_WHILE:
            DropContinueLabel();
            Jump( BlockStack->top_label );
            --LoopDepth;
            DropBreakLabel();
            break;
        case T_FOR:
            EndForStmt();
            --LoopDepth;
            DropBreakLabel();
            if( CompFlags.c99_extensions ) {
                EndBlock();     /* Terminate the scope introduced by 'for' */
                PopBlock();
            }
            break;
        case T_DO:
            DropContinueLabel();
            MustRecog( T_WHILE );
            SrcLoc = TokenLoc;
            JumpTrue( BracketExpr(), BlockStack->top_label );
            MustRecog( T_SEMI_COLON );
            SrcLoc = TokenLoc;
            --LoopDepth;
            DropBreakLabel();
            break;
        case T_SWITCH:
            EndSwitch();
            DropBreakLabel();
            break;
#ifdef __SEH__
        case T__TRY:
        case T___TRY:
            if( EndTry() )
                return;
            break;
        case T__EXCEPT:
        case T___EXCEPT:
            DropBreakLabel();
            TryScope = BlockStack->parent_index;
            CompFlags.exception_handler = 0;
            break;
        case T__FINALLY:
        case T___FINALLY:
            AddStmt( LeafNode( OPR_END_FINALLY ) );
            CompFlags.in_finally_block = 0;
            TryScope = BlockStack->parent_index;
            break;
#endif
        }
        PopBlock();
        if( BlockStack == NULL ) break;
    } while( BlockStack->block_type != T_LEFT_BRACE );
}