예제 #1
0
/*
================
idSaveGame::WriteRenderEntity
================
*/
void idSaveGame::WriteRenderEntity( const renderEntity_t &renderEntity ) {
	int i;
	WriteModel( renderEntity.hModel );
	WriteInt( renderEntity.entityNum );
	WriteInt( renderEntity.bodyId );
	WriteBounds( renderEntity.bounds );
	// callback is set by class's Restore function
	WriteInt( renderEntity.suppressSurfaceInViewID );
	WriteInt( renderEntity.suppressShadowInViewID );
	WriteInt( renderEntity.suppressShadowInLightID );
	WriteInt( renderEntity.allowSurfaceInViewID );
	WriteVec3( renderEntity.origin );
	WriteMat3( renderEntity.axis );
	WriteMaterial( renderEntity.customShader );
	WriteMaterial( renderEntity.referenceShader );
	WriteSkin( renderEntity.customSkin );
	if( renderEntity.referenceSound != NULL ) {
		WriteInt( renderEntity.referenceSound->Index() );
	} else {
		WriteInt( 0 );
	}
	for( i = 0; i < MAX_ENTITY_SHADER_PARMS; i++ ) {
		WriteFloat( renderEntity.shaderParms[ i ] );
	}
	for( i = 0; i < MAX_RENDERENTITY_GUI; i++ ) {
		WriteUserInterface( renderEntity.gui[ i ], renderEntity.gui[ i ] ? renderEntity.gui[ i ]->IsUniqued() : false );
	}
	WriteFloat( renderEntity.modelDepthHack );
	WriteBool( renderEntity.noSelfShadow );
	WriteBool( renderEntity.noShadow );
	WriteBool( renderEntity.noDynamicInteractions );
	WriteBool( renderEntity.weaponDepthHack );
	WriteInt( renderEntity.forceUpdate );
}
예제 #2
0
void CXMLExporter::WriteMaterials()
{
    if (m_pOptions->GetExportMaterials())
    {
        if (m_pOptions->GetExportMaterialsByLayer())
        {
            HResult hr;

            CComPtr<ISkpLayers> pLayers;
            hr = m_pDocument->get_Layers(&pLayers);

            long count;
            hr = pLayers->get_Count(&count);

            if (count>0)
            {
                for(long i=0; i<count; i++) 
                {
                    CComPtr<ISkpLayer> pLayer;
                    hr = pLayers->get_Item(i, &pLayer);

                    CComPtr<ISkpMaterial> pMaterial;
                    hr = pLayer->get_Material(&pMaterial);
                    WriteMaterial(pMaterial);
                }
            }
        }
        else
        {
            HResult hr;
            CComPtr<ISkpMaterials> pMats;

            hr = m_pDocument->get_Materials(&pMats);
            long count = 0L;
            hr = pMats->get_Count(&count);
            
            if (count>0)
            {
                IncreaseIndent();
                Write("<Materials count=\"%ld\">\n", count);
                IncreaseIndent();
                for(long i=0; i<count; i++)
                {
                    CComPtr<ISkpMaterial> pMat;
                    hr = pMats->get_Item(i, &pMat);
                    WriteMaterial(pMat);
                }
                DecreaseIndent();
                Write("</Materials>\n");
                DecreaseIndent();
            }
        }
    }
}
예제 #3
0
/*
================
idSaveGame::WriteRenderLight
================
*/
void idSaveGame::WriteRenderLight( const renderLight_t &renderLight ) {
	int i;
	WriteMat3( renderLight.axis );
	WriteVec3( renderLight.origin );
	WriteInt( renderLight.suppressLightInViewID );
	WriteInt( renderLight.allowLightInViewID );
	WriteBool( renderLight.noShadows );
	WriteBool( renderLight.noSpecular );
	WriteBool( renderLight.pointLight );
	WriteBool( renderLight.parallel );
	WriteVec3( renderLight.lightRadius );
	WriteVec3( renderLight.lightCenter );
	WriteVec3( renderLight.target );
	WriteVec3( renderLight.right );
	WriteVec3( renderLight.up );
	WriteVec3( renderLight.start );
	WriteVec3( renderLight.end );
	// only idLight has a prelightModel and it's always based on the entityname, so we'll restore it there
	// WriteModel( renderLight.prelightModel );
	WriteInt( renderLight.lightId );
	WriteMaterial( renderLight.shader );
	for( i = 0; i < MAX_ENTITY_SHADER_PARMS; i++ ) {
		WriteFloat( renderLight.shaderParms[ i ] );
	}
	if( renderLight.referenceSound != NULL ) {
		WriteInt( renderLight.referenceSound->Index() );
	} else {
		WriteInt( 0 );
	}
}
예제 #4
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;
}
예제 #5
0
/*
===================
idSaveGame::WriteContactInfo
===================
*/
void idSaveGame::WriteContactInfo( const contactInfo_t &contactInfo ) {
	WriteInt( (int)contactInfo.type );
	WriteVec3( contactInfo.point );
	WriteVec3( contactInfo.normal );
	WriteFloat( contactInfo.dist );
	WriteInt( contactInfo.contents );
	WriteMaterial( contactInfo.material );
	WriteInt( contactInfo.modelFeature );
	WriteInt( contactInfo.trmFeature );
	WriteInt( contactInfo.entityNum );
	WriteInt( contactInfo.id );
}
예제 #6
0
void ApplyObjectMaterial(IObject object, ProcArgs &args)
{
    //TODO, check args
    
    Mat::MaterialFlatten mafla(object);
    
    if (!mafla.empty())
    {
        WriteMaterial(mafla, args);
    }
    
}
예제 #7
0
void dxExporter::WriteMeshMaterialList( DX_Mesh* dx_msh, gctp::XSaver &cur, bool is_wire )
{
	DX_MeshMaterialList*  meshMaterialList = is_wire ? dx_msh->wireMaterialList: dx_msh->meshMaterialList;
	DX_Material*          material;
	DX_DWORD              n;

	if (meshMaterialList == NULL) return;

	gctp::bbstream strm;
	/*
	 *  MeshMaterialList
	 */
	strm << meshMaterialList->nMaterials;
	strm << meshMaterialList->nFaceIndexes;
	for (n = 0; n < meshMaterialList->nFaceIndexes; n++) {
		strm << meshMaterialList->faceIndexes[n];
	}
	gctp::XSaveData mtrllist = cur.newData(TID_D3DRMMeshMaterialList, strm.pcount(), strm.buf());

	material = meshMaterialList->materials;
	for (n = 0; n < meshMaterialList->nMaterials; n++)
	{
		switch (_options->materialType) {
		case DX_MATTYPE_INLINE:
			WriteMaterial( material, mtrllist );
			break;
		case DX_MATTYPE_EXTERN:
			cur.addRefData(material->nodeName);
			break;
		case DX_MATTYPE_SHARED:
			cur.addRefData(material->surfName);
			break;
		}
		material = material->next;
	}
}
예제 #8
0
//-*****************************************************************************
void ProcessSubD( ISubD &subd, ProcArgs &args, const std::string & facesetName )
{
    ISubDSchema &ss = subd.getSchema();

    TimeSamplingPtr ts = ss.getTimeSampling();

    SampleTimeSet sampleTimes;
    GetRelevantSampleTimes( args, ts, ss.getNumSamples(), sampleTimes );

    bool multiSample = sampleTimes.size() > 1;

    //include this code path for future expansion
    bool isHierarchicalSubD = false;
    bool hasLocalResources = false;
    
    
    
    std::vector<IFaceSet> faceSets;
    std::vector<std::string> faceSetResourceNames;
    if ( facesetName.empty() )
    {
        std::vector <std::string> childFaceSetNames;
        ss.getFaceSetNames(childFaceSetNames);
        
        faceSets.reserve(childFaceSetNames.size());
        faceSetResourceNames.reserve(childFaceSetNames.size());
        
        for (size_t i = 0; i < childFaceSetNames.size(); ++i)
        {
            faceSets.push_back(ss.getFaceSet(childFaceSetNames[i]));
            
            IFaceSet & faceSet = faceSets.back();
            
            std::string resourceName = args.getResource(
                    faceSet.getFullName() );
            
            if ( resourceName.empty() )
            {
                resourceName = args.getResource( faceSet.getName() );
            }
            
#ifdef PRMAN_USE_ABCMATERIAL
                
                Mat::MaterialFlatten mafla(faceSet);
                
                if (!mafla.empty())
                {
                    if (!hasLocalResources)
                    {
                        RiResourceBegin();
                        hasLocalResources = true;
                    }
                    
                    RiAttributeBegin();
                    
                    if ( !resourceName.empty() )
                    {
                        //restore existing resource state here
                        RestoreResource( resourceName );
                    }
                    
                    
                    WriteMaterial( mafla, args );
                    
                    resourceName = faceSet.getFullName();
                    SaveResource( resourceName );
                    
                    RiAttributeEnd();
                }
#endif
            faceSetResourceNames.push_back(resourceName);
            
        }
    }
#ifdef PRMAN_USE_ABCMATERIAL    
    else
    {
        //handle single faceset material directly
        if ( ss.hasFaceSet( facesetName ) )
        {
            IFaceSet faceSet = ss.getFaceSet( facesetName );
            ApplyObjectMaterial(faceSet, args);
            
        }
    }
#endif
    
    
    
    
    

    if ( multiSample ) { WriteMotionBegin( args, sampleTimes ); }

    for ( SampleTimeSet::iterator iter = sampleTimes.begin();
          iter != sampleTimes.end(); ++iter )
    {
        
        ISampleSelector sampleSelector( *iter );

        ISubDSchema::Sample sample = ss.getValue( sampleSelector );

        RtInt npolys = (RtInt) sample.getFaceCounts()->size();

        ParamListBuilder paramListBuilder;

        paramListBuilder.add( "P", (RtPointer)sample.getPositions()->get() );

        IV2fGeomParam uvParam = ss.getUVsParam();
        if ( uvParam.valid() )
        {
            ICompoundProperty parent = uvParam.getParent();
            
            if ( !args.flipv )
            {
                AddGeomParamToParamListBuilder<IV2fGeomParam>(
                    parent,
                    uvParam.getHeader(),
                    sampleSelector,
                    "float",
                    paramListBuilder,
                    2,
                    "st");
            }
            else if ( std::vector<float> * values =
                    AddGeomParamToParamListBuilderAsFloat<IV2fGeomParam, float>(
                        parent,
                        uvParam.getHeader(),
                        sampleSelector,
                        "float",
                        paramListBuilder,
                        "st") )
            {
                for ( size_t i = 1, e = values->size(); i < e; i += 2 )
                {
                    (*values)[i] = 1.0 - (*values)[i];
                }
            }
            
        }

        ICompoundProperty arbGeomParams = ss.getArbGeomParams();
        AddArbitraryGeomParams( arbGeomParams,
                    sampleSelector, paramListBuilder );

        std::string subdScheme = sample.getSubdivisionScheme();

        SubDTagBuilder tags;

        ProcessFacevaryingInterpolateBoundry( tags, sample );
        ProcessInterpolateBoundry( tags, sample );
        ProcessFacevaryingPropagateCorners( tags, sample );
        ProcessHoles( tags, sample );
        ProcessCreases( tags, sample );
        ProcessCorners( tags, sample );
        
        if ( !facesetName.empty() )
        {
            if ( ss.hasFaceSet( facesetName ) )
            {
                IFaceSet faceSet = ss.getFaceSet( facesetName );
                
                ApplyResources( faceSet, args );
                
                // TODO, move the hold test outside of MotionBegin
                // as it's not meaningful to change per sample
                
                IFaceSetSchema::Sample faceSetSample = 
                        faceSet.getSchema().getValue( sampleSelector );
                
                std::set<int> facesToKeep;
                
                facesToKeep.insert( faceSetSample.getFaces()->get(),
                        faceSetSample.getFaces()->get() +
                                faceSetSample.getFaces()->size() );
                
                for ( int i = 0; i < npolys; ++i )
                {
                    if ( facesToKeep.find( i ) == facesToKeep.end() )
                    {
                        tags.add( "hole" );
                        tags.addIntArg( i );
                    }
                }
            }
        }
        else
        {
            //loop through the facesets and determine whether there are any
            //resources assigned to each
            
            for (size_t i = 0; i < faceSetResourceNames.size(); ++i)
            {
                const std::string & resourceName = faceSetResourceNames[i];
                
                //TODO, visibility?
                
                if ( !resourceName.empty() )
                {
                    IFaceSet & faceSet = faceSets[i];
                    
                    isHierarchicalSubD = true;
                    
                    tags.add("faceedit");
                    
                    Int32ArraySamplePtr faces = faceSet.getSchema().getValue(
                            sampleSelector ).getFaces();
                    
                    for (size_t j = 0, e = faces->size(); j < e; ++j)
                    {
                        tags.addIntArg(1); //yep, every face gets a 1 in front of it too
                        tags.addIntArg( (int) faces->get()[j]);
                    }
                    
                    tags.addStringArg( "attributes" );
                    tags.addStringArg( resourceName );
                    tags.addStringArg( "shading" );
                }
            }
        }


        if ( isHierarchicalSubD )
        {
            RiHierarchicalSubdivisionMeshV(
                const_cast<RtToken>( subdScheme.c_str() ),
                npolys,
                (RtInt*) sample.getFaceCounts()->get(),
                (RtInt*) sample.getFaceIndices()->get(),
                tags.nt(),
                tags.tags(),
                tags.nargs( true ),
                tags.intargs(),
                tags.floatargs(),
                tags.stringargs(),
                paramListBuilder.n(),
                paramListBuilder.nms(),
                paramListBuilder.vals()
                                          );
        }
        else
        {
            RiSubdivisionMeshV(
                const_cast<RtToken>(subdScheme.c_str() ),
                npolys,
                (RtInt*) sample.getFaceCounts()->get(),
                (RtInt*) sample.getFaceIndices()->get(),
                tags.nt(),
                tags.tags(),
                tags.nargs( false ),
                tags.intargs(),
                tags.floatargs(),
                paramListBuilder.n(),
                paramListBuilder.nms(),
                paramListBuilder.vals()
                              );
        }
    }

    if ( multiSample ) { RiMotionEnd(); }
    
    if ( hasLocalResources ) { RiResourceEnd(); }
}