示例#1
0
void Entity_XMLParse( entity_t *pEntity, xmlNodePtr entity ){
	brush_t *pBrush;

	for ( xmlNodePtr current = entity->children; current != NULL; current = current->next )
	{
		if ( current->type != XML_ELEMENT_NODE ) {
			continue;
		}
		if ( !strcmp( (char *)current->name, "epair" ) ) {
			char *key = (char *)xmlGetProp( current, (xmlChar *)"key" );
			char *value = (char *)xmlGetProp( current, (xmlChar *)"value" );
			SetKeyValue( pEntity, key, value );
			xmlFree( key );
			xmlFree( value );
		}
		else if ( strcmp( (char *)current->name, "brush" ) == 0 ) {
			pBrush = Brush_Alloc();
			Brush_XMLParse( pBrush, current );
			( (CPtrArray*)pEntity->pData )->Add( pBrush );
		}
		else if ( strcmp( (char *)current->name, "patch" ) == 0 ) {
			pBrush = Brush_Alloc();
			pBrush->patchBrush = true;
			pBrush->pPatch = Patch_Alloc();
			pBrush->pPatch->pSymbiot = pBrush;
			Patch_XMLParse( pBrush->pPatch, current );
			( (CPtrArray*)pEntity->pData )->Add( pBrush );
		}
	}
}
示例#2
0
bool Primitive_Parse( brush_t *pBrush ){
	char *token = Token();

	GetToken( true );
	if ( !strcmp( token, "patchDef2" ) ) {
		pBrush->patchBrush = true;
		pBrush->pPatch = Patch_Alloc();
		pBrush->pPatch->pSymbiot = pBrush;
		Patch_Parse( pBrush->pPatch );
		GetToken( true ); //}

		// A patchdef should never be loaded from a quake2 map file
		// so we just return false and the brush+patch gets freed
		// and the user gets told.
		if ( g_MapVersion != MAPVERSION_Q3 ) {
			// FIXME: Hydra - I wanted to write out a line number here, but I can't because there's no API to access the core's "scriptline" variable.
			Syn_Printf( "ERROR: patchDef2's are not supported in Quake%d format .map files!\n",g_MapVersion );
			abortcode = MAP_WRONGVERSION;
			return false;
		}
	}
	else if ( !strcmp( token, "brushDef" ) ) {
		pBrush->bBrushDef = true;
		GetToken( true ); // {
		while ( 1 )
		{
			face_t    *f = pBrush->brush_faces;
			pBrush->brush_faces = Face_Alloc();
			Face_Parse( pBrush->brush_faces, true );
			pBrush->brush_faces->next = f;
			// check for end of brush
			GetToken( true );
			if ( strcmp( token,"}" ) == 0 ) {
				break;
			}
			UnGetToken();
		}
		GetToken( true ); // }
	}
	else
	{
		UnGetToken();
		while ( 1 )
		{
			face_t    *f = pBrush->brush_faces;
			pBrush->brush_faces = Face_Alloc();
			Face_Parse( pBrush->brush_faces );
			pBrush->brush_faces->next = f;

			// check for end of brush
			GetToken( true );
			if ( strcmp( token,"}" ) == 0 ) {
				break;
			}
			UnGetToken();
		}
	}
	return true;
}
示例#3
0
void DPatch::BuildInRadiant( scene::Node* entity ){
	NodeSmartReference patch( GlobalPatchCreator().createPatch() );

	scene::Node& parent = entity != 0 ? *entity : GlobalRadiant().getMapWorldEntity();
	Node_getTraversable( parent )->insert( patch );

	GlobalPatchCreator().Patch_setShader( patch, texture );
	GlobalPatchCreator().Patch_resize( patch, height, width );
	PatchControlMatrix matrix = GlobalPatchCreator().Patch_getControlPoints( patch );
	for ( int x = 0; x < width; x++ )
	{
		for ( int y = 0; y < height; y++ )
		{
			PatchControl& p = matrix( x, y );
			p.m_vertex[0] = points[x][y].xyz[0];
			p.m_vertex[1] = points[x][y].xyz[1];
			p.m_vertex[2] = points[x][y].xyz[2];
			p.m_texcoord[0] = points[x][y].st[0];
			p.m_texcoord[1] = points[x][y].st[1];
		}
	}
	GlobalPatchCreator().Patch_controlPointsChanged( patch );

	QER_entity = entity;
	QER_brush = patch.get_pointer();


#if 0
	int nIndex = g_FuncTable.m_pfnCreatePatchHandle();
	//$ FIXME: m_pfnGetPatchHandle
	patchMesh_t* pm = g_FuncTable.m_pfnGetPatchData( nIndex );

	b->patchBrush = true;
	b->pPatch = Patch_Alloc();
	b->pPatch->setDims( width,height );

	for ( int x = 0; x < width; x++ )
		for ( int y = 0; y < height; y++ )
			CopyDrawVert( &points[x][y], &pm->ctrl[x][y] );

/*	if(entity)
    {
   //		strcpy(pm->d_texture->name, texture);

        brush_t* brush = (brush_t*)g_FuncTable.m_pfnCreateBrushHandle();
        brush->patchBrush = true;
        brush->pPatch = pm;

        pm->pSymbiot = brush;
        pm->bSelected = false;
        pm->bOverlay = false;	// bleh, f*cks up, just have to wait for a proper function
        pm->bDirty = true;		// or get my own patch out....
        pm->nListID = -1;

        g_FuncTable.m_pfnCommitBrushHandleToEntity(brush, entity);
    }
    else*/                                                                                                                                                                                                                                                                                                                                                                                                                                                                // patch to entity just plain dont work atm

	if ( entity ) {
		g_FuncTable.m_pfnCommitPatchHandleToEntity( nIndex, pm, texture, entity );
	}
	else{
		g_FuncTable.m_pfnCommitPatchHandleToMap( nIndex, pm, texture );
	}

	QER_brush = pm->pSymbiot;
#endif
}