void COptionTreeWrapper::SerializeStaticItemBool(IArchive &ar, COptionTreeItem *item, bool read)
{
	bool bVal;
	COptionTreeItemStatic *otiStatic;
	CString text;

	otiStatic = dynamic_cast<COptionTreeItemStatic*>(item);
	if(otiStatic == NULL)
	{
		//error
		StdString error = _T("Could not cast item to COptionTreeItemStatic: ");
		error += item->GetLabelText();
		::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
		return;
	}
	if(read)
	{
		ar.Read(bVal);
		otiStatic->SetStaticText( bVal ? _T("true") : _T("false")  );
	}
	else
	{
		text = otiStatic->GetStaticText();
		if (_tcscmp( text, _T("true") ) == 0)
			ar.Write(true);
		else
			ar.Write(false);
	}
}
Ejemplo n.º 2
0
void CQHState::Serialize( IArchive &ar )
{
	if( ar.IsReading() )
	{
		float fVersion;
		ar.Read( fVersion, _T("version") );

		if( 1.2f == fVersion )
		{
			ReadFromVersion_1_2( ar );
		}
		else if( 1.1f == fVersion )
		{
			ReadFromVersion_1_1( ar );
		}
		else if( 1.0f == fVersion )
		{
			ReadFromVersion_1_0( ar );
		}
		else
		{
			LPCTSTR fmt = _T("%s(%d): Unsupported version (%f) of state machine state");
			m_ToolBox->Log( LOGERROR, fmt, __FILE__, __LINE__, fVersion );
			return;
		}
	}
	else
	{
		ar.Write( m_fCurrentVersion, _T("version") );
		ar.Write( m_Name.GetString(), _T("name") );
		ar.Write( m_EntryEvent.GetString(), _T("entryEvent") );
		ar.Write( m_UpdateEvent.GetString(), _T("updateEvent") );
		ar.Write( m_ExitEvent.GetString(), _T("exitEvent") );
	}
}
Ejemplo n.º 3
0
void CModelViewRender::CreateScene()
{
    Vec3 v3Zero(0.0f, 0.0f, 0.0f);
    EulerAngle eZero;
    Vec3 v3Scale(1.0f,1.0f,1.0f);
    StdString szEntityType(_T("EditorObject"));

    IArchive *pArchive = CreateMemoryArchive();
    pArchive->Write(_T("EditorObject"), _T("EntityType"));
    pArchive->Write(v3Zero, _T("Position"));
    pArchive->Write(eZero, _T("Rotation"));
    pArchive->Write(v3Scale, _T("Scale"));
    pArchive->SetIsWriting(false);

    // Create Instance of CEntity
    static CHashString hszEntity(_T("CEntity"));
    CreateEEObject(&m_hszSceneName, &hszEntity, m_hszEntityName, pArchive);

    pArchive->Close();

    m_v3Position.Set(0, 0, 0);
    m_v3CameraPos.Set(0.0f, 0.0f, 200.0f);
    m_v3Rotation.Set(0.0f, 0.0f, 0.0f);

    LoadModel();
}
Ejemplo n.º 4
0
void CDetailObject::Serialize( IArchive &ar )
{
	StdString temp;
	if(ar.IsReading())
	{
		ar.Read(temp, "LayerLink");
		m_LayerLink = temp.c_str();
		ar.Read(temp, "ModelName");
		m_ModelName = temp.c_str();
		ar.Read(m_XCoverage, "XCoverage");
		ar.Read(m_YCoverage, "YCoverage");
		ar.Read(m_XRandomness, "XRandomness");
		ar.Read(m_YRandomness, "YRandomness");
		ar.Read(m_MinScale, "MinScale");
		ar.Read(m_MinScale, "MaxScale");
		ar.Read(m_MinYaw, "MinYaw");
		ar.Read(m_MaxYaw, "MaxYaw");
	}
	else
	{
		ar.Write(m_LayerLink.GetString(), "LayerLink");
		ar.Write(m_ModelName.GetString(), "ModelName");
		ar.Write(m_XCoverage, "XCoverage");
		ar.Write(m_YCoverage, "YCoverage");
		ar.Write(m_XRandomness, "XRandomness");
		ar.Write(m_YRandomness, "YRandomness");
		ar.Write(m_MinScale, "MinScale");
		ar.Write(m_MinScale, "MaxScale");
		ar.Write(m_MinYaw, "MinYaw");
		ar.Write(m_MaxYaw, "MaxYaw");
	}
}
Ejemplo n.º 5
0
void CModelViewRender::LoadModel()
{
    ASSERT(GetDocument() != NULL);
    CString strPath = GetDocument()->GetPathName();
    LPCTSTR szPath = strPath;
    TCHAR extStr[_MAX_EXT];
    TCHAR fileName[_MAX_FNAME];
    _tsplitpath(szPath, NULL, NULL, fileName, extStr);

    if (strPath.IsEmpty())
    {
        m_ToolBox->Log(LOGWARNING, _T("%s(%i):LoadModel shouldn't have been called with NULL path\n"), __FILE__, __LINE__);
        return;
    }

    StdString szFilename = fileName;
    szFilename += extStr;
    m_hszModelName = szFilename;

    CFileVersionSetter setter( _T("2.5") );

    if (0 == _tcsicmp(extStr, _T(".cfg")))
    {
        IArchive *pArchive = CreateMemoryArchive();
        if (pArchive != NULL)
        {
            pArchive->Write(szPath, _T("Filepath"));
            pArchive->SetIsWriting(false);
            static CHashString hszCal3DRenderObject(_T("Cal3DRenderObject"));
            CreateEEObject(&m_hszEntityName, &hszCal3DRenderObject, m_hszModelName, pArchive);
            FillAnimationList();
            pArchive->Close();
        }
    }
    else if (0 == _tcsicmp(extStr, _T(".hrc")))
    {
        IArchive *pArchive = CreateMemoryArchive();
        if (pArchive != NULL)
        {
            pArchive->Write(szPath);
            pArchive->SetIsWriting(false);
            static CHashString hszCal3DRenderObject(_T("CHierarchicalModel"));
            CreateEEObject(&m_hszEntityName, &hszCal3DRenderObject, m_hszModelName, pArchive);
            pArchive->Close();
        }
    }
    else
    {
        m_ToolBox->Log(LOGWARNING, _T("%s(%i):LoadModel was passed %s extension, which is not recognized\n"), __FILE__, __LINE__, extStr);
    }
}
void COptionTreeWrapper::SerializeStaticItemDouble(IArchive &ar, COptionTreeItem *item, bool read)
{
	double dVal;
	COptionTreeItemStatic *otiStatic;
	TCHAR buff[50];
	CString text;

	otiStatic = dynamic_cast<COptionTreeItemStatic*>(item);
	if(otiStatic == NULL)
	{
		//error
		StdString error = _T("Could not cast item to COptionTreeItemStatic: ");
		error += item->GetLabelText();
		::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
		return;
	}
	if(read)
	{
		ar.Read(dVal);
		_stprintf(buff, "%g", dVal);
		otiStatic->SetStaticText(buff);
	}
	else
	{
		text = otiStatic->GetStaticText();
		dVal = _tstof(text);

		ar.Write(dVal);
	}
}
void COptionTreeWrapper::SerializeStaticItemInt(IArchive &ar, COptionTreeItem *item, bool read)
{
	int iVal;
	COptionTreeItemStatic *otiStatic;
	TCHAR buffer[50];
	CString text;

	otiStatic = dynamic_cast<COptionTreeItemStatic*>(item);
	if(otiStatic == NULL)
	{
		//error
		StdString error = _T("Could not cast item to COptionTreeItemStatic: ");
		error += item->GetLabelText();
		::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
		return;
	}
	if(read)
	{
		ar.Read(iVal);
		_itot(iVal, buffer, 10);
		otiStatic->SetStaticText(buffer);
	}
	else
	{
		text = otiStatic->GetStaticText();
		iVal = _tstoi(text);
		ar.Write(iVal);
	}
}
void COptionTreeWrapper::SerializeEditItemString(IArchive &ar, COptionTreeItem *item, bool read)
{	
	StdString szString;
	COptionTreeItemEdit *otiEdit;
	
	CString szItem;
	otiEdit = dynamic_cast<COptionTreeItemEdit*>(item);
	if(otiEdit == NULL)
	{
		//error
		StdString error = _T("Could not cast item to COptionTreeItemEdit: ");
		error += item->GetLabelText();
		::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
		return;
	}

	otiEdit->CreateEditItem(0, NULL);

	if (read)
	{
		ar.Read(szString);
		otiEdit->SetEditText(szString.c_str());
	}
	else
	{
		otiEdit->GetWindowText(szItem);
		ar.Write(szItem);
	}
}
void COptionTreeWrapper::SerializeEditItemDouble(IArchive &ar, COptionTreeItem *item, bool read)
{
	double dVal;
	COptionTreeItemEdit *otiEdit;

	otiEdit = dynamic_cast<COptionTreeItemEdit*>(item);
	
	if(otiEdit == NULL)
	{
		//error
		StdString error = _T("Could not cast item to COptionTreeItemEdit: ");
		error += item->GetLabelText();
		::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
		return;
	}

	otiEdit->CreateEditItem(OT_EDIT_NUMERICAL, NULL);

	if(read)
	{
		ar.Read(dVal);
		otiEdit->SetEditDouble(dVal);
	}
	else
	{
		otiEdit->GetEditDouble(dVal);
		ar.Write(dVal);
	}
}
Ejemplo n.º 10
0
DWORD CSchemaItem::GetType( DATABASEATTRIBUTEPARAMS *databaseAttributeParams )
{
	DWORD retVal = MSG_NOT_HANDLED;
	if( databaseAttributeParams != NULL )
	{
		
		if( databaseAttributeParams->m_AttributeTypeArchive != NULL )
		{
			IArchive *ar = databaseAttributeParams->m_AttributeTypeArchive;
			ar->SetIsWriting( true );
			ar->SeekTo( 0 );
			ar->Write( m_hszType.GetString() );
		}
		else
		{
			m_ToolBox->Log( LOGWARNING, _T("No archive specified for GetAttributeType.\n") );
		}

		retVal = MSG_HANDLED_STOP;
	}
	else
	{
		m_ToolBox->Log( LOGWARNING, _T("Attribute parameters not defined.\n") );
	}

	return retVal;
}
void COptionTreeWrapper::SerializeStaticItemString(IArchive &ar, COptionTreeItem *item, bool read)
{
	StdString szString;
	COptionTreeItemStatic *otiStatic = dynamic_cast<COptionTreeItemStatic*>(item);

	CString szItem;
	if(otiStatic == NULL)
	{
		//error
		StdString error = _T("Could not cast item to COptionTreeItemStatic: ");
		error += item->GetLabelText();
		::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
		return;
	}
	if(read)
	{
		ar.Read(szString);
		otiStatic->SetStaticText(szString.c_str());
	}
	else
	{
		szItem = otiStatic->GetStaticText();
		ar.Write(szItem);
	}
}
void COptionTreeWrapper::SerializeCheckBoxItem(IArchive &ar, COptionTreeItem *item, bool read)
{
	bool bVal;
	COptionTreeItemCheckBox *otiCheckBox;

	otiCheckBox = dynamic_cast<COptionTreeItemCheckBox*>(item);
	if(otiCheckBox == NULL)
	{
		//error
		StdString error = _T("Could not cast item to COptionTreeItemCheckBox: ");
		error += item->GetLabelText();
		::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
		return;
	}
	if(read)
	{
		ar.Read(bVal);
		otiCheckBox->SetCheck(bVal);
	}
	else
	{
		bVal = (otiCheckBox->GetCheck() != 0);
		ar.Write(bVal);
	}
}
void COptionTreeWrapper::SerializeSpinnerItemDouble(IArchive &ar, COptionTreeItem *item, bool read)
{
	double dVal;
	COptionTreeItemSpinner *otiSpinner;

	otiSpinner = dynamic_cast<COptionTreeItemSpinner*>(item);
	if (otiSpinner == NULL)
	{
		//error
		StdString error = _T("Could not cast item to COptionTreeItemSpinner: ");
		error += item->GetLabelText();
		::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
		return;
	}
	if (read)
	{
		ar.Read(dVal);
		otiSpinner->SetEditDouble(dVal);
	}
	else
	{
		otiSpinner->GetEditDouble(dVal);
		ar.Write(dVal);
	}
}
Ejemplo n.º 14
0
IArchive* CGUIStaticText::CreateAndFillArchive()
{
	if (m_LanguageTextParams)
	{
		CREATEARCHIVE ca;
		static CHashString memType(_T("Memory"));

		ca.mode = STREAM_MODE_WRITE | STREAM_MODE_READ;
		ca.streamData = NULL;
		ca.streamSize = 0;
		ca.streamType = &memType;
		static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
		m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca);

		IArchive *ar = ca.archive;
		if (ar)
		{
			ar->SetIsWriting(true);
			ar->SeekTo(0);
			ar->Write(m_LanguageTextParams, m_iLangTextParamSize);
		}
		return ar;
	}
	else
	{
		return NULL;
	}
}
void COptionTreeWrapper::SerializeRadioItem(IArchive &ar, COptionTreeItem *item, bool read)
{
	StdString szVal;
	COptionTreeItemRadio *otiRadio;
	OT_RADIO_NODE *node;
	int index;

	otiRadio = dynamic_cast<COptionTreeItemRadio*>(item);
	if (item == NULL)
	{
		//error
		StdString error = _T("Could not cast item to COptionTreeItemRadio: ");
		error += item->GetLabelText();
		::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
		return;
	}
	if (read)
	{
		ar.Read(szVal);
		node = otiRadio->Node_FindNode(szVal.c_str());
		if (node != NULL)
		{	
			otiRadio->Node_UnCheckAll();
			node->m_bChecked = true;
		}	
	}
	else
	{
		index = otiRadio->Node_GetChecked();
		node = otiRadio->Node_FindNode(index);
		ar.Write(node->m_strText);
	}
}
Ejemplo n.º 16
0
void CModelViewRender::PlaySequence(const ANIMATIONSEQUENCE &sequence)
{
    // make a copy of the requested sequence
    m_PlayingAnimationSequence.clear();
    std::copy(sequence.begin(), sequence.end(), std::back_inserter(m_PlayingAnimationSequence));
    m_itCurrentAnimationID = m_PlayingAnimationSequence.begin();

    // create all the callbacks at once for the sequence
    set<int> uniqueCallbackSet;
    for (ANIMATIONSEQUENCE::iterator itrAnim = m_PlayingAnimationSequence.begin(); itrAnim != m_PlayingAnimationSequence.end(); itrAnim++)
    {
        // skip duplicate animations (only need to make one callback per animation)
        if (uniqueCallbackSet.find( *itrAnim ) != uniqueCallbackSet.end())
            continue;

        IArchive* pArchive = CreateMemoryArchive();
        pArchive->Write(m_hszEntityName.GetString(), _T("EntityName"));
        pArchive->Write(*itrAnim);
        pArchive->SetIsWriting(false);
        m_AnimationCallbackArchives.push_back( pArchive );

        static CHashString hszCal3DRenderObject = _T("Cal3DRenderObject");
        static CHashString hszCModelViewComponent(_T("CModelViewComponent"));
        static CHashString hszPlayAnimationSequenceStep(_T("PlayAnimationSequenceStep"));

        REGISTERCAL3DANIMATIONCALLBACK ac;
        ac.AnimationId = *itrAnim;
        ac.bTriggerOnComplete = true;
        ac.bTriggerOnStop = false;
        ac.StateObjectName = &hszCModelViewComponent;
        ac.EventName = &hszPlayAnimationSequenceStep;
        ac.EventParamsArchive = pArchive;

        static DWORD msgHash_RegisterAnimationCallback = CHashString(_T("RegisterAnimationCallback")).GetUniqueID();
        DWORD res = m_ToolBox->SendMessage(msgHash_RegisterAnimationCallback, sizeof(ac), &ac, &m_hszEntityName, &hszCal3DRenderObject);
        if (MSG_HANDLED != res)
        {
            m_ToolBox->Log(LOGERROR, _T("%s(%i): Cannot register animation callback. \n"), __FILE__, __LINE__);
        }
        uniqueCallbackSet.insert( *itrAnim );
    }

    if (HasAnimation())
    {
        SINGLETONINSTANCE(CModelViewComponent)->PlayAnimation(this);
    }
}
Ejemplo n.º 17
0
void COceanRenderObject::Serialize(IArchive &ar)
{
	if(ar.IsReading())
	{
		CHashString hszVersion = _T("");
		float version;
		static DWORD msgHash_GetFileVersion = CHashString(_T("GetFileVersion")).GetUniqueID();
		DWORD retval = m_ToolBox->SendMessage(msgHash_GetFileVersion, sizeof(IHashString), &hszVersion);
		if (retval != MSG_HANDLED)
		{
			m_ToolBox->Log(LOGERROR, _T("CEntity Serialize: Could not get file version!"));
			assert(0);
			return;
		}
		version = (float)_tstof(hszVersion.GetString());
		

		if( version >= 3.0 )
		{
			ar.Read( m_szFoamTexture, "FoamTexture" );
			ar.Read( m_szEnvMapTexture, "EnvMapTexture" );
			ar.Read( m_DiffuseColor, "DiffuseColor" );
			ar.Read( m_AmbientValue, "AmbientValue" );
			ar.Read( m_SunDir, "SunDir" );
			ar.Read( m_fClipScale, "ClipScale" );
			ar.Read( m_fClipOffset, "ClipOffset" );
			ar.Read( m_fTextureScale, "TextureScale" );
			ar.Read( m_fWindy, "Windy" );
		}
		else
		{
			Vec3 temp;
			ar.Read( m_szFoamTexture, "FoamTexture" );
			ar.Read( m_szEnvMapTexture, "EnvMapTexture" );
			ar.Read( m_DiffuseColor, "DiffuseColor" );
			ar.Read( m_AmbientValue, "AmbientValue" );
			ar.Read( temp, "SunDir" );
			m_SunDir.Set( temp.x, temp.z, -temp.y );
			ar.Read( m_fClipScale, "ClipScale" );
			ar.Read( m_fClipOffset, "ClipOffset" );
			ar.Read( m_fTextureScale, "TextureScale" );
			ar.Read( m_fWindy, "Windy" );
		}
	}
	else
	{
		ar.Write( m_szFoamTexture, "FoamTexture" );
		ar.Write( m_szEnvMapTexture, "EnvMapTexture" );
		ar.Write( m_DiffuseColor, "DiffuseColor" );
		ar.Write( m_AmbientValue, "AmbientValue" );
		ar.Write( m_SunDir, "SunDir" );
		ar.Write( m_fClipScale, "ClipScale" );
		ar.Write( m_fClipOffset, "ClipOffset" );
		ar.Write( m_fTextureScale, "TextureScale" );
		ar.Write( m_fWindy, "Windy" );
	}
}
Ejemplo n.º 18
0
void CHeightmapObject::Serialize(IArchive &ar)
{
	if (ar.IsReading())
	{
		int iSize = 0;
		ar.Read( iSize );
		iSize = EE_ENDIANSWAP32( iSize );

		m_iWidth = iSize;
		m_iHeight = iSize;

		SAFE_DELETE_ARRAY( m_pHeightmapData );

		int iSamples = iSize * iSize;
		if( iSamples > 0 )
		{
			float f;
			m_pHeightmapData = new float[iSamples];
			for( int i = 0; i < iSamples; ++i )
			{
				ar.Read( f );
				m_pHeightmapData[i] = EE_ENDIANSWAP32F( f );
			}
		}
	}
	else
	{
		int iSize = m_iWidth;
		ar.Write( iSize );
		int iSamples = iSize * iSize;
		if( m_pHeightmapData != NULL )
		{
			for( int i = 0; i < iSamples; ++i )
			{
				ar.Write( m_pHeightmapData[i] );
			}
		}
		else
		{
			for( int i = 0; i < iSamples; ++i )
			{
				ar.Write( 0.0f );
			}
		}
	}
}
Ejemplo n.º 19
0
void CPrecacheObject::Serialize( IArchive &ar )
{
	if( ar.IsReading() )
	{
		// Version
		ar.Read( m_iVersion );
	
		// Number of Entries
		unsigned int tmpCount;
		ar.Read( tmpCount );
	
		// Read Entries and insert into the list
		for( unsigned int i = 0; i < tmpCount; i++ )
		{
			CHashString hszResourceName;
			StdString szResourceName;
			ar.Read( szResourceName );
			hszResourceName.Init( szResourceName );
			m_ResourceSet.insert( hszResourceName.GetUniqueID());
		}
	}
	
	else
	{
		// Version
		ar.Write( m_iVersion, _T("Version") );
		
		// Number of Entries
		ar.Write( (int)m_ResourceSet.size(), _T("NumEntries") );

		// Write out all the Entries from the list
		RESOURCESET::iterator itr = m_ResourceSet.begin();
		StdString szPrecacheEntry( _T("PrecacheEntry") );
		while( itr != m_ResourceSet.end() )
		{
			ar.StartClass( szPrecacheEntry );
			ar.Write( m_ToolBox->GetHashString( *itr ), _T("Name") );
			ar.EndClass();
			itr++;
		}
	}
}
Ejemplo n.º 20
0
void GameComponent::SetGlobalAttribute( IHashString *attributeName, bool value )
{
	if( attributeName != NULL )
	{
		IArchive *archive = CreateMemoryArchive();
		archive->SetIsWriting( true );
		archive->Write( (bool)value );
		archive->SetIsWriting( false );

		SetGlobalAttribute( attributeName, archive );

		archive->Close();
	}
}
Ejemplo n.º 21
0
void CLuaScript::Serialize(IArchive &ar)
{
	if(ar.IsReading())
	{
		ar.Read(m_ScriptName);
		ar.Read(m_bAutoStart);
	}
	else
	{
		ar.Write(m_ScriptName);
		ar.Write(m_bAutoStart);
	}

}
void CQHStateMachineActionHandler::Serialize( IArchive &ar )
{
	if( ar.IsReading() )
	{
		float fVersion;
		StdString tempStr;
		ar.Read( fVersion, _T("version") );
		if( fVersion > m_fCurrentVersion )
		{
			LPCTSTR fmt = _T("%s(%d): Unsupported version (%f) of state machine action handler");
			m_ToolBox->Log( LOGERROR, fmt, __FILE__, __LINE__, fVersion );
			return;
		}
		ar.Read( tempStr, _T("name") );
		m_szName.Init( tempStr );
		ar.Read( tempStr, _T("actionName") );
		m_szActionName.Init( tempStr );

		IComponent *amanagerComponent = m_ToolBox->GetComponent( GetManagerName() );
		CQHStateMachineManager *amanager = static_cast<CQHStateMachineManager*>( amanagerComponent );
		CQHStateMachineEvent *aparentEvent = amanager->GetEvent( GetParentName() );
		if( aparentEvent != NULL )
		{
			aparentEvent->AddActionHandler( this );
		}
		else
		{
			m_ToolBox->Log( LOGERROR, _T("Could not find parent event %s for action handler %s."), GetParentName()->GetString(), GetName()->GetString() );
		}
	}
	else
	{
		ar.Write( m_fCurrentVersion, _T("version") );
		ar.Write( m_szName.GetString(), _T("name") );
		ar.Write( m_szActionName.GetString(), _T("actionName") );
	}
}
Ejemplo n.º 23
0
void CSchemaItem::Serialize( IArchive &ar )
{
	if( ar.IsReading() )
	{
		StdString name; // Dummy variable to read the name. It should already be stored as CObjectTemplate
		StdString type;
		StdString attributeClass;

		ar.Read( m_fVersion, _T("Version") );
		ar.Read( name, _T("Name") );
		ar.Read( type, _T("Type") );
		ar.Read( attributeClass, _T("Class") );
		m_hszLabel.Init( name );
		m_hszType.Init( type );
		m_hszClass.Init( attributeClass );
		DBRead( &m_DefaultValue, &ar, _T("Default") ); // IMPORTANT: DBRead is dependent on m_hszType. Make sure m_hszType has been initialized before calling DBRead.

		// NOTE: We are assuming the order in which schema items are instantiated will be
		//       the order in which to read data items.
		if( m_Schema != NULL )
		{
			m_Schema->RegisterSchemaItem( this );
		}
	}
	else
	{
		ar.StartClass(_T("CSchemaItem"));

		ar.Write( m_fVersion, _T("Version") );
		ar.Write( m_hszLabel.GetString(), _T("Name") );
		ar.Write( m_hszType.GetString(), _T("Type") );
		ar.Write( m_hszClass.GetString(), _T("Class") );
		DBWrite( &m_DefaultValue, &ar, _T("Default") );

		ar.EndClass();
	}
}
void COptionTreeWrapper::SerializeFileItem(IArchive &ar, COptionTreeItem *item, bool read)
{
	StdString fileName;
	COptionTreeItemFile *otiFile;
	CString szItem;

	otiFile = dynamic_cast<COptionTreeItemFile*>(item);
	if(otiFile == NULL)
	{
		//error
		StdString error = _T("Could not cast item to COptionTreeItemFile: ");
		error += item->GetLabelText();
		::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
		return;
	}

	if (read)
	{
		ar.Read(fileName);
		CString fName = (const TCHAR*)fileName;
		GetRelativePath(fName, szItem);
		if ( _tcscmp(szItem, _T("")) != 0 )
		{
			otiFile->SetFileString(szItem);
		}
	}
	else
	{
		// Try to convert to a relative path
		if( !GetRelativePath(otiFile->GetFileString(), szItem) )
		{
			// if an invalid path reset the string
			otiFile->ResetFileString();
			// run it through the relative pathizer again
			GetRelativePath(otiFile->GetFileString(), szItem);					
		}
//		CGDSApp *app = DYNAMIC_DOWNCAST(CGDSApp, AfxGetApp());
//		CString resourcePath = app->GetResourcePath();
		StdString rootDir, resDir;
		EngineGetToolBox()->GetDirectories(&rootDir, &resDir);
		resDir += "\\";
		resDir += szItem;
		otiFile->SetFileString( szItem );
		// do not want to save absolute path! my bad
//		ar.Write(resDir);
		ar.Write(szItem);
	}
}
void COptionTreeWrapper::SerializeComboItem(IArchive &ar, COptionTreeItem *item, bool read)
{
	StdString defaultSelect;
	COptionTreeItemComboBox *otiCombo;
	CString szItem;
	int index;

	otiCombo = dynamic_cast<COptionTreeItemComboBox*>(item);
	if(otiCombo == NULL)
	{
		//error
		StdString error = _T("Could not cast item to COptionTreeItemCombo: ");
		error += item->GetLabelText();
		::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
		return;
	}
	if(read)
	{
		ar.Read(defaultSelect);
		if( _tcscmp( defaultSelect, _T("")) != 0 )
		{
			index = otiCombo->FindStringExact(0, defaultSelect.c_str());
			otiCombo->SetCurSel((index >= 0) ? index : 0);
		}

	}
	else
	{
		int sel = otiCombo->GetCurSel();
		if(sel == CB_ERR)
		{
			//display some message?
		}
		otiCombo->GetLBText(sel, szItem);
		ar.Write(szItem);
	}
}
Ejemplo n.º 26
0
/////////////////////////////////////////////////////////////
//	LOAD PARTICLE EMITTER
/////////////////////////////////////////////////////////////
DWORD CParticleLoader::OnLoadParticleFile(DWORD size, void *params)
{
	PERFORMANCE_PROFILER_AUTO(ParticleLoader_loadfile);

	VERIFY_MESSAGE_SIZE(size, sizeof(TCHAR *));
	TCHAR *pFilepath = (TCHAR *)params;

	StdString szFilename = ExtractFileName(pFilepath);
	CHashString hszFilename(szFilename);

	StdString szFilepath(pFilepath);
	CHashString hszFilepath(pFilepath);

	DWORD result;
	// Search for Object to see if it is already loaded
	// Check using the FindObject Message if the CParticleEmitter exists
	static DWORD msgHash_FindObject = CHashString(_T("FindObject")).GetUniqueID();
	FINDOBJECTPARAMS param;
	param.hszName = &hszFilepath;
	result = m_ToolBox->SendMessage(msgHash_FindObject, sizeof(FINDOBJECTPARAMS), &param);
	if (param.bFound == true)
	{
		//Object Exists
		return MSG_HANDLED_STOP;
	}

	// Create XMLArchive using IXML
	IXMLArchive *XMLar;
	CHashString streamType(_T("File"));

	CREATEARCHIVE ca;
	ca.mode = STREAM_MODE_READ;
	ca.streamData = pFilepath;
	ca.streamType = &streamType;
	static DWORD msgHash_CreateXMLArchive = CHashString(_T("CreateXMLArchive")).GetUniqueID();
	result = EngineGetToolBox()->SendMessage(msgHash_CreateXMLArchive, sizeof(CREATEARCHIVE), &ca);

	if( result != MSG_HANDLED )
	{
		m_ToolBox->Log(LOGWARNING, _T("Failed to load particle file: \"%s\"!\n"), szFilepath.c_str() );
		return MSG_ERROR;
	}
	XMLar = dynamic_cast<IXMLArchive *>(ca.archive);
	// break out if XMLar is NULL.
	if( !XMLar )
	{
		m_ToolBox->Log(LOGWARNING, _T("Failed to load particle file: \"%s\"!\n"), szFilepath.c_str() );
		XMLar->Close();
		return MSG_ERROR;
	}

	// Create MemArchive using IAR
	IArchive *MemArchive;
	CHashString memType(_T("Memory"));

	CREATEARCHIVE caOut;
	caOut.mode = STREAM_MODE_READ | STREAM_MODE_WRITE;
	caOut.streamData = NULL;
	caOut.streamSize = 0;
	caOut.streamType = &memType;
	static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
	if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &caOut) != MSG_HANDLED)
		return MSG_ERROR;
	MemArchive = caOut.archive;

	// EMITTER PARSE VALUES
	PARTICLEPROPERTIESKEY k;
	StdString szEmitterCheck;
	StdString szEmitterName;
	int numBrushes = 0;
	int numKeyframes = 0;
	StdString	szType;
	StdString	szBrushFilename;
	StdString	szPropertyName;

	// Archive -> GetNode (this should be "CParticleEmitter" )
	XMLar->GetNode(szEmitterCheck);

	// if this is particle line type, load it
	if ( szEmitterCheck == _T("CParticleLineType") )
	{
		static CHashString hszCParticleLineType(_T("CParticleLineType"));
		AddLoadedParticleType( &hszFilepath, &hszCParticleLineType, XMLar );
		m_ParticleObjectMap[ hszFilepath.GetUniqueID() ] = hszFilepath.GetUniqueID();
		XMLar->Close();
		MemArchive->Close();
		return MSG_HANDLED_STOP;
	}

	// if this is particle ribbon type, load it
	if ( szEmitterCheck == _T("CParticleRibbonType") )
	{
		static CHashString hszCParticleRibbonType(_T("CParticleRibbonType"));
		AddLoadedParticleType( &hszFilepath, &hszCParticleRibbonType, XMLar );
		m_ParticleObjectMap[ hszFilepath.GetUniqueID() ] = hszFilepath.GetUniqueID();
		XMLar->Close();
		MemArchive->Close();
		return MSG_HANDLED_STOP;
	}

	if ( szEmitterCheck != _T("ParticleEmitter") )
	{
		// Exit out if GetNode != CParticleEmitter
		XMLar->Close();
		MemArchive->Close();
		return MSG_ERROR;
	}
	MemArchive->SetIsWriting(true);
	// PARSE HEADER
	// READ
	XMLar->Read(szEmitterName, _T("name"));
	XMLar->Read(numBrushes, _T("brushes"));
	XMLar->Read(numKeyframes, _T("keyframes"));

	// WRITE
//	MemArchive->Write( szFilename, _T("filename") );
	MemArchive->Write( szEmitterName, _T("name"));

	MemArchive->Write( PARTICLE_SERIALIZE_NORMAL, _T("flag"));

	MemArchive->Write( numBrushes, _T("brushes"));
	MemArchive->Write( numKeyframes, _T("keyframes"));

	// PARSE BRUSHES
	for (int i = 0; i < numBrushes; i++)
	{
		XMLar->GetNode(szType);
		if (szType == _T("Brush"))
		{
			// READ
			XMLar->Read(szBrushFilename, _T("file"));
			// WRITE
			MemArchive->Write( szBrushFilename, _T("file"));
		}
		// Too many keyframes or invalid brush node
		else
		{
			XMLar->Close();
			MemArchive->Close();
			return MSG_ERROR;
		}
	}
	// PARSE KEYFRAMES
	for (int i = 0 ; i < numKeyframes ; i++)
	{
		XMLar->GetNode(szType);
		if (szType == _T("Keyframe"))
		{
			// READ
			XMLar->Read(szPropertyName, _T("type"));
			XMLar->Read(k.time, _T("time"));
			XMLar->Read(k.value, _T("value"));
			// WRITE
			MemArchive->Write( szPropertyName, _T("type"));
			MemArchive->Write( k.time, _T("time"));
			MemArchive->Write( k.value, _T("value"));
		}
		// Too many keyframes or invalid keyframe node
		else
		{
			XMLar->Close();
			MemArchive->Close();
			return MSG_ERROR;
		}
	}
	XMLar->Close();

	// Change the Memarchive to read;
	MemArchive->SetIsWriting(false);

	CHashString hszParticleManager = _T("CParticleManager");
	PARTICLELOADINFO pli;
	pli.filepath = &hszFilepath;
	pli.data = MemArchive;
	static DWORD msgHash_AddLoadedEmitter = CHashString(_T("AddLoadedEmitter")).GetUniqueID();
	result = m_ToolBox->SendMessage(msgHash_AddLoadedEmitter, sizeof( PARTICLELOADINFO), &pli);
	if (result != MSG_HANDLED)
	{
		m_ToolBox->Log(LOGERROR, _T("%s(%d): ParticleLoader failed to add emitter %s to manager map\n"), __FILE__, __LINE__, hszFilepath.GetString());
	}

	// Clean up temporary data.
	MemArchive->Close();

	return MSG_HANDLED_STOP;
}
Ejemplo n.º 27
0
void CModelViewRender::InitRenderScene()
{
    // set active scene to model view scene so objects created here will be placed in the correct scene
    SetActiveScene();

    //Create Cal3DRenderObject from loaded file
    CreateScene();

    // create a new Memory Archive
    IArchive *pArchive = CreateMemoryArchive();
    if (pArchive == NULL)
    {
        return;
    }

    StdString szEntityType(_T("EditorObject"));
    //Vec3 v3Zero(0.0f, 0.0f, 0.0f);
    Vec3 v3EntityLightPosition(0.0f, 200.0f, 200.0f);
    EulerAngle eaZero;
    Vec3 v3Scale(1.0f, 1.0f, 1.0f);
    pArchive->Write(szEntityType, _T("EntityType"));
    pArchive->Write(v3EntityLightPosition, _T("Position"));
    pArchive->Write(eaZero, _T("Rotation"));
    pArchive->Write(v3Scale, _T("Scale"));
    pArchive->SetIsWriting(false);

    CFileVersionSetter setter;
    // Create the CEntity LightObject Parent /////////////////////////////////////////////////////////
    static CHashString hszCEntity(_T("CEntity"));
    if (CreateEEObject(&m_hszSceneName, &hszCEntity, m_hszLightEntityName, pArchive))
    {
        pArchive->SetIsWriting(true);
        pArchive->SeekTo(0);
        int iVersionNumber = 1000;
        Vec3 v3LightPosition( 0.0, 0.0f, 0.0f );
        Vec3 v3LightDirection( 0.0f, 0.0f, 0.0f );
        float fAttenuation = 99999.0f;
        float fColor[] = { 0.75f, 0.75f, 0.75f, 1.0f };
        StdString szLightType(_T("OMNI_POINT_LIGHT"));
        bool bCastShadows = false;
        UINT numKeys = 0;
        pArchive->Write(iVersionNumber, _T("Version"));
        pArchive->Write(v3LightPosition, _T("Position"));
        pArchive->Write(v3LightDirection, _T("Direction"));
        pArchive->Write(fAttenuation, _T("Attenuation"));
        pArchive->Write(fColor[0], _T("ColorRed") );
        pArchive->Write(fColor[1], _T("ColorGreen") );
        pArchive->Write(fColor[2], _T("ColorBlue") );
        pArchive->Write(fColor[3], _T("ColorAlpha") );
        pArchive->Write(szLightType, _T("LightType") );
        pArchive->Write(bCastShadows, _T("CastShadows") );
        pArchive->Write(numKeys, _T("NumKeyframes") );
        pArchive->SetIsWriting(false);

        // Create the Light Object ////////////////////////////////////////////////////////////////
        static CHashString hszCLightObject(_T("CLightObject"));
        CreateEEObject(&m_hszLightEntityName, &hszCLightObject, m_hszLightObjectName, pArchive);
    }

    pArchive->Close();
}
Ejemplo n.º 28
0
/////////////////////////////////////////////////////////////
//	LOAD PARTICLE BRUSH
/////////////////////////////////////////////////////////////
DWORD CParticleLoader::OnLoadParticleBrush(DWORD size, void *params)
{
	VERIFY_MESSAGE_SIZE(size, sizeof(TCHAR *));
	TCHAR *pFilepath = (TCHAR *)params;

	StdString szFilename = ExtractFileName(pFilepath);
	CHashString hszFilename(szFilename);

	StdString szFilepath(pFilepath);
	CHashString hszFilepath(pFilepath);
	
	DWORD result;

	// Search for Object to see if it is already loaded
	// Check using the FindObject Message if the CParticleEmitter exists
	static DWORD msgHash_FindObject = CHashString(_T("FindObject")).GetUniqueID();
	FINDOBJECTPARAMS param;
	param.hszName = &hszFilename;
	result = m_ToolBox->SendMessage(msgHash_FindObject, sizeof(FINDOBJECTPARAMS), &param);
	if (param.bFound == true)
	{
		//Object Exists
		return MSG_HANDLED_STOP;
	}

	// Create XMLArchive using IXML
	IXMLArchive *XMLar;
	CHashString streamType(_T("File"));

	CREATEARCHIVE ca;
	ca.mode = STREAM_MODE_READ;
	ca.streamData = pFilepath;
	ca.streamType = &streamType;
	static DWORD msgHash_CreateXMLArchive = CHashString(_T("CreateXMLArchive")).GetUniqueID();
	result = EngineGetToolBox()->SendMessage(msgHash_CreateXMLArchive, sizeof(CREATEARCHIVE), &ca);

	if( result != MSG_HANDLED )
	{
		m_ToolBox->Log(LOGWARNING, _T("Failed to load particle file: \"%s\"!\n"), szFilepath.c_str() );
		return MSG_ERROR;
	}
	XMLar = dynamic_cast<IXMLArchive *>(ca.archive);
	// break out if XMLar is NULL.
	if( !XMLar )
	{
		m_ToolBox->Log(LOGWARNING, _T("Failed to load particle file: \"%s\"!\n"), szFilepath.c_str() );
		XMLar->Close();
		return MSG_ERROR;
	}

	// Create MemArchive using IAR
	IArchive *MemArchive;
	CHashString memType(_T("Memory"));

	CREATEARCHIVE caOut;
	caOut.mode = STREAM_MODE_READ | STREAM_MODE_WRITE;
	caOut.streamData = NULL;
	caOut.streamSize = 0;
	caOut.streamType = &memType;
	static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
	if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &caOut) != MSG_HANDLED)
	{
		XMLar->Close();
		return MSG_ERROR;
	}
	MemArchive = caOut.archive;

	// BRUSH PARSE VALUES
	StdString szType;
	StdString szPropertyName;
	StdString szBrushCheck;
	StdString szBrushName;
	bool additive;
	int nKeyframes;
	float framerate;
	float texturerate;
	StdString szTexturePath;
	bool loop;
	float AttachToEmitter;
	StdString szShader;
	PARTICLEPROPERTIESKEY k;

	// Archive -> GetNode (this should be "ParticleBrush" )
	XMLar->GetNode(szBrushCheck);
	if ( szBrushCheck != _T("ParticleBrush") )
	{
		// Exit out if GetNode != ParticleBrush
		XMLar->Close();
		MemArchive->Close();
		return MSG_ERROR;
	}

	MemArchive->SetIsWriting(true);
	// PARSE HEADER
	// READ
	XMLar->Read( szBrushName, _T("name"));
	XMLar->Read( additive, _T("additive"));
	XMLar->Read( framerate, _T("framerate"));
	XMLar->Read( texturerate, _T("texturerate"));
	XMLar->Read( szTexturePath, _T("texture"));
	XMLar->Read( loop, _T("loop"));
	XMLar->Read( AttachToEmitter, _T("AttachToEmitter"));
	XMLar->Read( szShader, _T("shader"));

	XMLar->Read( nKeyframes, _T("keyframes"));

	// WRITE
//	MemArchive->Write( szFilename, _T("filename") );
//	MemArchive->Write( szFilepath, _T("filepath") );

	MemArchive->Write( szBrushName, _T("name"));
	MemArchive->Write( additive, _T("additive"));
	MemArchive->Write( framerate, _T("framerate"));
	MemArchive->Write( texturerate, _T("texturerate"));
	MemArchive->Write( szTexturePath, _T("texture"));
	MemArchive->Write( loop, _T("loop"));
	MemArchive->Write( AttachToEmitter, _T("AttachToEmitter"));
	MemArchive->Write( szShader, _T("shader"));

	MemArchive->Write( PARTICLE_SERIALIZE_NORMAL, _T("flag"));

	MemArchive->Write( nKeyframes, _T("keyframes"));

	// PARSE KEYFRAMES
	for (int i = 0 ; i < nKeyframes ; i++)
	{
		XMLar->GetNode(szType);
		if (szType == _T("Keyframe"))
		{
			// READ
			XMLar->Read(szPropertyName, _T("type"));
			XMLar->Read(k.time, _T("time"));
			XMLar->Read(k.value, _T("value"));
			// WRITE
			MemArchive->Write( szPropertyName, _T("type"));
			MemArchive->Write( k.time, _T("time"));
			MemArchive->Write( k.value, _T("value"));
		}
		// Too many keyframes or invalid keyframe node
		else
		{
			XMLar->Close();
			MemArchive->Close();
			return MSG_ERROR;
		}
	}
	XMLar->Close();

	// Change the Memarchive to read;
	MemArchive->SetIsWriting(false);

	CHashString hszParticleManager = _T("CParticleManager");
	PARTICLELOADINFO pli;
	pli.filepath = &hszFilepath;
	pli.data = MemArchive;
	static DWORD msgHash_AddLoadedBrush = CHashString(_T("AddLoadedBrush")).GetUniqueID();
	result = m_ToolBox->SendMessage(msgHash_AddLoadedBrush, sizeof( PARTICLELOADINFO), &pli);
	if (result != MSG_HANDLED)
	{
		m_ToolBox->Log(LOGERROR, _T("ParticleLoader failed to add emitter to manager map"));
	}

	// Object Serialized, close memarchive;
	MemArchive->Close();

	return MSG_HANDLED_STOP;
}
Ejemplo n.º 29
0
/////////////////////////////////////////////////////////////
// New Particle Brush
/////////////////////////////////////////////////////////////
DWORD CParticleLoader::OnNewParticleBrush(DWORD size, void *params)
{

	VERIFY_MESSAGE_SIZE(size, sizeof(TCHAR *));
	TCHAR *czFilepath = (TCHAR *)params;

	StdString szFilename = ExtractFileName(czFilepath);
	CHashString hszFilename(szFilename);

	StdString szFilepath(czFilepath);
	CHashString hszFilepath(czFilepath);

	CREATE_PARTICLE_STRING_TABLE(BrushPropertyStringTable);

	DWORD result;
	// Search for Object to see if it is already loaded
	// Check using the FindObject Message if the CParticleEmitter exists
	static DWORD msgHash_FindObject = CHashString(_T("FindObject")).GetUniqueID();
	FINDOBJECTPARAMS param;
	param.hszName = &hszFilename;
	result = m_ToolBox->SendMessage(msgHash_FindObject, sizeof(FINDOBJECTPARAMS), &param);
    if (param.bFound == true)
	{
		//Object Exists
		return MSG_HANDLED_STOP;
	}

	// Use Create Object Message to create the object (use the filename as the name)
	CHashString hszTypeName(_T("CParticleType"));
	CREATEOBJECTPARAMS cop;
	cop.name = &hszFilename;
	cop.parentName = NULL;
	cop.typeName = &hszTypeName;
	static DWORD msgHash_CreateObject = CHashString(_T("CreateObject")).GetUniqueID();
	result = m_ToolBox->SendMessage(msgHash_CreateObject, sizeof(CREATEOBJECTPARAMS), &cop);
	if (result == MSG_ERROR)
		return MSG_ERROR;

	// Create MemArchive using IAR
	IArchive *MemArchive;
	CHashString memType(_T("Memory"));

	CREATEARCHIVE caOut;
	caOut.mode = STREAM_MODE_READ | STREAM_MODE_WRITE;
	caOut.streamData = NULL;
	caOut.streamSize = 0;
	caOut.streamType = &memType;
	static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
	result = m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &caOut);
	if (result == MSG_ERROR)
		return MSG_ERROR;

	MemArchive = caOut.archive;

	// Change the Memarchive to write
	MemArchive->SetIsWriting(true);

	// Write Initial Emitter Properties:
	// WRITE INTERNAL DATA
	MemArchive->Write( szFilename, _T("filename") );
	MemArchive->Write( szFilepath, _T("filepath") );

	// WRITE FILE HEADER
	MemArchive->Write( _T("NewEmitter"), _T("name"));
	MemArchive->Write( false, _T("additive"));
	MemArchive->Write( 30.0f, _T("framerate"));
	MemArchive->Write( 30.0f, _T("texturerate"));
	MemArchive->Write( _T(""), _T("texture"));
	MemArchive->Write( false, _T("loop"));
	MemArchive->Write( 0.0f, _T("AttachToEmitter"));
	MemArchive->Write( _T(""), _T("shader"));

	MemArchive->Write( PARTICLE_VARIABLE_MAX, _T("keyframes"));

	// WRITE PROPERTIES
	for (int i = 0; i < PARTICLE_VARIABLE_MAX; i++)
	{
		MemArchive->Write(BrushPropertyStringTable[i], _T("type"));
		MemArchive->Write(0.0f, _T("time"));
		MemArchive->Write(0.0f, _T("value"));
	}

	// Change the Memarchive to read
	MemArchive->SetIsWriting(false);

	// Serialize out Emitter Data
	SERIALIZEOBJECTPARAMS sop;
	sop.archive = MemArchive;
	sop.name = &hszFilename;
	static DWORD msgHash_SerializeObject = CHashString(_T("SerializeObject")).GetUniqueID();
	result = m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sop, NULL, NULL);
	if (result == MSG_ERROR)
	{
		MemArchive->Close();
		return MSG_ERROR;
	}

	// Object Serialized, close memarchive;
	MemArchive->Close();

	// Use the Init Message with the MemArchive
	INITOBJECTPARAMS iop;
	iop.name = &hszFilename;
	static DWORD msgHash_InitObject = CHashString(_T("InitObject")).GetUniqueID();
	m_ToolBox->SendMessage(msgHash_InitObject, sizeof(INITOBJECTPARAMS), &iop, NULL, NULL);

	return MSG_HANDLED_STOP;
}
Ejemplo n.º 30
0
bool CWorldVisitor::Visit( IComponent * component, bool bVisitEnter )
{
	IObject *theObject;
	IHashString *name;
	IHashString *parentName;
	IHashString *type;

	StdString parentType;
	StdString childType;

	std::string str;

	theObject = dynamic_cast<IObject *>(component);
	// This shouldn't happen but it does for some odd reason....
	assert(theObject);
	if( theObject == NULL )
	{
		return false;
	}
	name = theObject->GetName();
	parentName = theObject->GetParentName();
	type = theObject->GetComponentType();

	//Check to see if it is a valid object (for object exclusion)
	if( !CheckObject( type->GetString() ) )
	{
		return true;
	}

	else
	{
		if ( name == NULL )
		{
			name = &CHashString(_T("NULL"));
		}	

		if( bVisitEnter == true )
		{
			//if( (m_pArchiver != NULL) && ( _tcscmp( type->GetString(), _T("CPhysicsObject") ) != 0 ) )
			if( (m_pArchiver != NULL) )
			{
				// Start the Node
				m_pArchiver->StartClass( type->GetString() );
				
				// Write out the Unique ID aka Name
				m_pArchiver->Write( name->GetString(), _T("Name") );
				theObject->Serialize( *m_pArchiver );
			}

			// Removal of CPhysShape and changes to CPhysicsObject
			if( _tcscmp( type->GetString(), _T("CPhysicsObject") ) == 0 )
			{
				
				CPhysObjectStruct tmpCPhysObject;
				StdString CPhyShapeFile;
				StdString CPhyShapeFileOld;
				// if it's parent is not a CTerrainSector Object
				if( _tcsstr( name->GetString(), _T("Terrain") ) == NULL )
				{
					static DWORD msgHash_GetModelFileName = CHashString(_T("GetModelFileName")).GetUniqueID();
					m_ToolBox->SendMessage(msgHash_GetModelFileName, sizeof(StdString*), &CPhyShapeFile, parentName, NULL );
					CPhyShapeFile += _T(".psl");
				}
				// CTerrainSector Object
				else
				{
					CPhyShapeFile = _T("maps\\terrain.psl");
				}

				IArchive *PhysObjectIn;
				IArchive *PhysObjectRead;
				CHashString memTypePhysObjectIn(_T("Memory"));
				
				int PhysObjectInMemSize = 1024 * 1024 * sizeof(char);
				char* PhysObjectInMemChunk = new char[PhysObjectInMemSize];
				memset( PhysObjectInMemChunk, 0, PhysObjectInMemSize );

				CREATEARCHIVE caPhysObjectIn;
				caPhysObjectIn.mode = STREAM_MODE_READ;
				caPhysObjectIn.streamData = PhysObjectInMemChunk;
				caPhysObjectIn.streamSize = PhysObjectInMemSize;
				caPhysObjectIn.streamType = &memTypePhysObjectIn;
				static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
				if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &caPhysObjectIn) != MSG_HANDLED)
				{
					return true;
				}
				PhysObjectIn = caPhysObjectIn.archive;

				CREATESTREAM csPhysObjectIn;
				csPhysObjectIn.streamData = caPhysObjectIn.streamData;
				csPhysObjectIn.streamSize = caPhysObjectIn.streamSize;
				csPhysObjectIn.mode = STREAM_MODE_WRITE;
				static DWORD msgHash_CreateStream_Memory = CHashString(_T("CreateStream_Memory")).GetUniqueID();
				if (m_ToolBox->SendMessage(msgHash_CreateStream_Memory, sizeof(CREATESTREAM), &csPhysObjectIn) != MSG_HANDLED)
				{
					return true;
				}
				PhysObjectIn->Init(csPhysObjectIn.openStream);		    

				SERIALIZEOBJECTPARAMS sop;
				sop.name = name;
				sop.archive = PhysObjectIn;
				static DWORD msgHash_SerializeObject = CHashString(_T("SerializeObject")).GetUniqueID();
				m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sop, NULL, NULL);
				PhysObjectIn->Close();
				
				CREATEARCHIVE caPhysObjectRead;
				caPhysObjectRead.mode = STREAM_MODE_WRITE;
				caPhysObjectRead.streamData = PhysObjectInMemChunk;
				caPhysObjectRead.streamSize = PhysObjectInMemSize;
				caPhysObjectRead.streamType = &memTypePhysObjectIn;
				if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &caPhysObjectRead) != MSG_HANDLED)
				{
					return true;
				}
				PhysObjectRead = caPhysObjectRead.archive;

				CREATESTREAM csPhysObjectRead;
				csPhysObjectRead.streamData = caPhysObjectRead.streamData;
				csPhysObjectRead.streamSize = caPhysObjectRead.streamSize;
				csPhysObjectRead.mode = STREAM_MODE_READ;
				if (m_ToolBox->SendMessage(msgHash_CreateStream_Memory, sizeof(CREATESTREAM), &csPhysObjectRead) != MSG_HANDLED)
				{
					return true;
				}
				PhysObjectRead->Init(csPhysObjectRead.openStream);
				PhysObjectRead->Read( tmpCPhysObject.vPosition, _T("pos") );
				PhysObjectRead->Read( tmpCPhysObject.vRotation, _T("rot") );
				PhysObjectRead->Read( tmpCPhysObject.vScale, _T("scale") );
				PhysObjectRead->Read( tmpCPhysObject.fMass, _T("mass") );
				PhysObjectRead->Read( tmpCPhysObject.szDynamic, _T("dynamics") );
				PhysObjectRead->Read( CPhyShapeFileOld, _T("shapeFile") );
				PhysObjectRead->Close();
                
				// Archive the Data Back In
				IArchive *MemArchivePhysObject;	
				CHashString memTypePhysObject(_T("Memory"));
				//int sizePhysObject = 1024 * 1024;
				//char* memchunkPhysObject = new char[sizePhysObject];

				CREATEARCHIVE caPhysObject;
				caPhysObject.mode = STREAM_MODE_WRITE;
				caPhysObject.streamData = PhysObjectInMemChunk;
				caPhysObject.streamSize = PhysObjectInMemSize;
				caPhysObject.streamType = &memTypePhysObject;
				if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &caPhysObject) != MSG_HANDLED)
				{
					return true;
				}
				MemArchivePhysObject = caPhysObject.archive;
				MemArchivePhysObject->Write( tmpCPhysObject.vPosition, _T("pos") );
				MemArchivePhysObject->Write( tmpCPhysObject.vRotation, _T("rot") );
				MemArchivePhysObject->Write( tmpCPhysObject.vScale, _T("scale") );
				MemArchivePhysObject->Write( tmpCPhysObject.fMass, _T("mass") );
				MemArchivePhysObject->Write( tmpCPhysObject.szDynamic, _T("dynamics") );
				MemArchivePhysObject->Write( CPhyShapeFile, _T("shapeFile") );
				
				CREATESTREAM csPhysObject;
				csPhysObject.streamData = caPhysObject.streamData;
				csPhysObject.streamSize = caPhysObject.streamSize;
				csPhysObject.mode = STREAM_MODE_READ;
				if (m_ToolBox->SendMessage(msgHash_CreateStream_Memory, sizeof(CREATESTREAM), &csPhysObject) != MSG_HANDLED)
				{
					return true;
				}
				MemArchivePhysObject->Init(csPhysObject.openStream);

				SERIALIZEOBJECTPARAMS sopPhysObject;
				sopPhysObject.name = name;
				sopPhysObject.archive = MemArchivePhysObject;
				m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sopPhysObject, NULL, NULL);

				MemArchivePhysObject->Close();
				//delete [] memchunkPhysObject;
				//memchunkPhysObject = NULL;
				delete [] PhysObjectInMemChunk;
				PhysObjectInMemChunk = NULL;
			}

			// Model Rename Changes
			if( (m_pReporter != NULL) && ( _tcscmp( type->GetString(), _T("CV3ORenderObject") ) == 0 ) )
			{
				IArchive *MemArchive;
				IArchive *MemArchive2;
				CHashString memType(_T("Memory"));
				memset( m_pMemChunk, '\0', m_iMemSize );

				CREATEARCHIVE ca;
				ca.mode = STREAM_MODE_READ;
				ca.streamData = m_pMemChunk;
				ca.streamSize = m_iMemSize;
				ca.streamType = &memType;
				static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
				if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca) != MSG_HANDLED)
				{
					return true;
				}
				MemArchive = ca.archive;

				CREATESTREAM cs;
				cs.streamData = ca.streamData;
				cs.streamSize = ca.streamSize;
				cs.mode = STREAM_MODE_WRITE;
				static DWORD msgHash_CreateStream_Memory = CHashString(_T("CreateStream_Memory")).GetUniqueID();
				if (m_ToolBox->SendMessage(msgHash_CreateStream_Memory, sizeof(CREATESTREAM), &cs) != MSG_HANDLED)
				{
					return true;
				}
				MemArchive->Init(cs.openStream);		    

				SERIALIZEOBJECTPARAMS sop;
				sop.name = name;
				sop.archive = MemArchive;
				static DWORD msgHash_SerializeObject = CHashString(_T("SerializeObject")).GetUniqueID();
				m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sop, NULL, NULL);
				MemArchive->Close();
				
				CREATEARCHIVE ca2;
				ca2.mode = STREAM_MODE_WRITE;
				ca2.streamData = m_pMemChunk;
				ca2.streamSize = m_iMemSize;
				ca2.streamType = &memType;
				if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca2) != MSG_HANDLED)
				{
					return true;
				}
				MemArchive2 = ca2.archive;

				CREATESTREAM cs2;
				cs2.streamData = ca2.streamData;
				cs2.streamSize = ca2.streamSize;
				cs2.mode = STREAM_MODE_READ;
				if (m_ToolBox->SendMessage(msgHash_CreateStream_Memory, sizeof(CREATESTREAM), &cs2) != MSG_HANDLED)
				{
					return true;
				}
				MemArchive2->Init(cs2.openStream);

				StdString wszModelFileName;
				Vec3 Position;
				Vec3 Rotation;
				Vec3 Scale;

				MemArchive2->Read( wszModelFileName );
				MemArchive2->Read( Position );
				MemArchive2->Read( Rotation );
				MemArchive2->Read( Scale );
				MemArchive2->Close();
				
				MODELMAP::iterator itr;
				bool bReArchive = false;
				while( 1 )
				{		
					itr = m_vModelReference.find( wszModelFileName );
					// If the Model Refernce already exists
					if( itr != m_vModelReference.end() )
					{
						// If its newfilename is different and it isn't an empty string
						// We Change the file name and set the archive flag
						if( (wszModelFileName != itr->second.m_wszNewFileName) &&
							(itr->second.m_wszNewFileName != StdString("")) )
						{
							wszModelFileName = itr->second.m_wszNewFileName;
							bReArchive = true;
						}
						
						// We've reached a file that has the same exact newfilename, no change neccisary
						else
						{
							break;
						}
					}
					
					
					// We change model name first (up above) and then make sure to add it as a reference and break out
					itr = m_vModelReference.find( wszModelFileName );
					if( itr == m_vModelReference.end() )
					{
						/*
						MODELINFO tmpModelInfo;
						tmpModelInfo.m_wszNewFileName = wszModelFileName;
						m_vModelReference[wszModelFileName] = tmpModelInfo;
						m_iNewEntries++;
						*/
						break;
					}
					
				}
				
				m_szLastV3OFileName = wszModelFileName;

				// Archive the object back out
				if( bReArchive == true )
				{
					IArchive *MemArchiveRE;	
					CHashString memTypeRE(_T("Memory"));
					int sizeRE = 1024 + sizeof(Vec3) * 3;
					char* memchunkRE = new char[sizeRE];

					CREATEARCHIVE caRE;
					caRE.mode = STREAM_MODE_WRITE;
					caRE.streamData = memchunkRE;
					caRE.streamSize = sizeRE;
					caRE.streamType = &memTypeRE;
					static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
					if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &caRE) != MSG_HANDLED)
					{
						return true;
					}
					MemArchiveRE = caRE.archive;
					MemArchiveRE->Write( wszModelFileName );
					MemArchiveRE->Write( Position );
					MemArchiveRE->Write( Rotation );
					MemArchiveRE->Write( Scale );

					CREATESTREAM csRE;
					csRE.streamData = caRE.streamData;
					csRE.streamSize = caRE.streamSize;
					csRE.mode = STREAM_MODE_READ;
					static DWORD msgHash_CreateStream_Memory = CHashString(_T("CreateStream_Memory")).GetUniqueID();
					if (m_ToolBox->SendMessage(msgHash_CreateStream_Memory, sizeof(CREATESTREAM), &csRE) != MSG_HANDLED)
					{
						return true;
					}
					MemArchiveRE->Init(csRE.openStream);

					SERIALIZEOBJECTPARAMS sopRE;
					sopRE.name = name;
					sopRE.archive = MemArchiveRE;
					static DWORD msgHash_SerializeObject = CHashString(_T("SerializeObject")).GetUniqueID();
					m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sopRE, NULL, NULL);

					MemArchiveRE->Close();
					delete [] memchunkRE;
					memchunkRE = NULL;
					m_iV3ONameEdits++;
				}
			}
		}

		// bVisitEnter == false
		else
		{
			if( m_pArchiver != NULL )
			{
				m_pArchiver->EndClass();
			}
		}
	}
	
	return true;
}