Exemple #1
0
vtEdge::vtEdge()
{
	m_Color.Set(255,0,0);		// default color: red
	m_iSlope = 90;		// vertical
	m_fEaveLength = 0.0f;
	m_pMaterial = GetGlobalMaterials()->FindName(BMAT_NAME_PLAIN);
}
Exemple #2
0
void vtEdge::Set(int iDoors, int iWindows, const char *material)
{
	vtEdgeFeature wall, window, door;

	window.m_code = WFC_WINDOW;
	window.m_width = WINDOW_WIDTH;
	window.m_vf1 = WINDOW_BOTTOM;
	window.m_vf2 = WINDOW_TOP;

	door.m_code = WFC_DOOR;
	door.m_width = DOOR_WIDTH;
	door.m_vf1 = 0.0f;
	door.m_vf2 = DOOR_TOP;

	m_Features.clear();
	m_Features.reserve((iDoors + iWindows) * 2 + 1);
	m_Features.push_back(wall);

	bool do_door, do_window, flip = false;
	while (iDoors || iWindows)
	{
		do_door = do_window = false;
		if (iDoors && iWindows)
		{
			if (flip)
				do_door = true;
			else
				do_window = true;
		}
		else if (iDoors)
			do_door = true;
		else if (iWindows)
			do_window = true;

		if (do_door)
		{
			m_Features.push_back(door);
			iDoors--;
		}
		if (do_window)
		{
			m_Features.push_back(window);
			iWindows--;
		}
		m_Features.push_back(wall);
	}
	m_pMaterial = GetGlobalMaterials()->FindName(material);
}
Exemple #3
0
void EnviroFrame::OpenFenceDialog()
{
	// inform the dialog about the materials
	m_pFenceDlg->SetStructureMaterials(GetGlobalMaterials());
	m_pFenceDlg->Show(true);
}
Exemple #4
0
void vtLevel::SetEdgeMaterial(const char *matname)
{
	const vtString *str = GetGlobalMaterials()->FindName(matname);
	for (uint i = 0; i < m_Edges.GetSize(); i++)
		m_Edges[i]->m_pMaterial = str;
}
Exemple #5
0
void StructVisitorGML::startElement(const char *name, const XMLAttributes &atts)
{
	const char *attval;
	float f;

	// clear data at the start of each element
	m_data = "";

	if (m_state == 0 && !strcmp(name, "StructureCollection"))
	{
		m_state = 1;
		return;
	}

	if (m_state == 1)
	{
		if (!strcmp(name, "Building"))
		{
			m_pBuilding = m_pSA->NewBuilding();
			m_pStructure = m_pBuilding;
			m_state = 2;
			m_iLevel = 0;
		}
		else if (!strcmp(name, "Linear"))
		{
			m_pFence = m_pSA->NewFence();
			m_pFence->GetParams().Blank();
			m_pStructure = m_pFence;

			// support obsolete attribute
			attval = atts.getValue("Height");
			if (attval)
			{
				f = (float) atof(attval);
				m_pFence->GetParams().m_fPostHeight = f;
				m_pFence->GetParams().m_fConnectTop = f;
			}
			m_state = 10;
		}
		else if (!strcmp(name, "Imported"))
		{
			m_pInstance = m_pSA->NewInstance();
			m_pStructure = m_pInstance;

			m_state = 20;
		}
		attval = atts.getValue("ElevationOffset");
		if (attval)
			m_pStructure->SetElevationOffset((float) atof(attval));
		attval = atts.getValue("Absolute");
		if (attval)
			m_pStructure->SetAbsolute(*attval == 't');

		return;
	}

	if (m_state == 2)	// Building
	{
		if (!strcmp(name, "Level"))
		{
			m_pLevel = m_pBuilding->CreateLevel();
			attval = atts.getValue("FloorHeight");
			if (attval)
				m_pLevel->m_fStoryHeight = (float) atof(attval);
			attval = atts.getValue("StoryCount");
			if (attval)
				m_pLevel->m_iStories = atoi(attval);
			m_state = 3;
			m_iEdge = 0;
		}
		return;
	}

	if (m_state == 3)	// Level
	{
		if (!strcmp(name, "Footprint"))
		{
			m_state = 4;
			m_Footprint.clear();
		}
		else if (!strcmp(name, "Edge"))
		{
			m_pEdge = m_pLevel->GetEdge(m_iEdge);
			if (m_pEdge)	// safety check
			{
				m_pEdge->m_Features.clear();

				attval = atts.getValue("Material");
				if (attval)
				{
					vtMaterialDescriptorArray *mats = GetGlobalMaterials();
					m_pEdge->m_pMaterial = mats->FindName(attval);
					if (m_pEdge->m_pMaterial == NULL)
					{
						// What to do when a VTST references a material that
						// we don't have?  We don't want to lose the material
						// name information, and we also don't want to crash
						// later with a NULL material.  So, make a dummy.
						vtMaterialDescriptor *mat;
						mat = new vtMaterialDescriptor(attval, "", VT_MATERIAL_COLOUR);
						mat->SetRGB(RGBi(255,255,255));	// white means: missing
						mats->Append(mat);
						m_pEdge->m_pMaterial = &mat->GetName();
					}
				}
				attval = atts.getValue("Color");
				if (attval)
					m_pEdge->m_Color = ParseHexColor(attval);
				attval = atts.getValue("Slope");
				if (attval)
					m_pEdge->m_iSlope = atoi(attval);
				attval = atts.getValue("EaveLength");
				if (attval)
					m_pEdge->m_fEaveLength = (float) atof(attval);
				attval = atts.getValue("Facade");
				if (attval)
					m_pEdge->m_Facade = attval;
			}

			m_state = 7;	// in Edge
		}
		return;
	}

	if (m_state == 4)	// Footprint
	{
		if (!strcmp(name, "gml:outerBoundaryIs"))
			m_state = 5;
		if (!strcmp(name, "gml:innerBoundaryIs"))
			m_state = 6;
	}

	if (m_state == 5)	// Footprint outerBoundaryIs
	{
		// nothing necessary here, catch the end of element
	}

	if (m_state == 6)	// Footprint innerBoundaryIs
	{
		// nothing necessary here, catch the end of element
	}

	if (m_state == 7)	// Edge
	{
		if (!strcmp(name, "EdgeElement"))
		{
			vtEdgeFeature ef;

			attval = atts.getValue("Type");
			if (attval)
				ef.m_code = vtBuilding::GetEdgeFeatureValue(attval);
			attval = atts.getValue("Begin");
			if (attval)
				ef.m_vf1 = (float) atof(attval);
			attval = atts.getValue("End");
			if (attval)
				ef.m_vf2 = (float) atof(attval);
			if (m_pEdge)
				m_pEdge->m_Features.push_back(ef);
		}
	}

	if (m_state == 10)	// Linear
	{
		vtLinearParams &param = m_pFence->GetParams();
		if (!strcmp(name, "Path"))
		{
			m_state = 11;
		}
		else if (!strcmp(name, "Posts"))
		{
			// this linear structure has posts
			const char *type = atts.getValue("Type");
			if (type)
				param.m_PostType = type;
			else
				param.m_PostType = "none";

			const char *spacing = atts.getValue("Spacing");
			if (spacing)
				param.m_fPostSpacing = (float)atof(spacing);

			const char *height = atts.getValue("Height");
			if (height)
				param.m_fPostHeight = (float)atof(height);

			const char *size = atts.getValue("Size");
			if (size)
			{
				FPoint3 postsize;
				sscanf(size, "%f, %f", &postsize.x, &postsize.z);
				param.m_fPostWidth = postsize.x;
				param.m_fPostDepth = postsize.z;
			}

			const char *exten = atts.getValue("Extension");
			if (exten)
				param.m_PostExtension = exten;
		}
		else if (!strcmp(name, "Connect"))
		{
			const char *type = atts.getValue("Type");
			if (type)
			{
				// Older format version had string "none", "wire", or a material for type
				// Newer format has integer 0,1,2,3 for none,wire,simple,profile
				if (*type >= '0' && *type <= '9')
					param.m_iConnectType = atoi(type);
				else
				{
					// Convert old to new
					if (!strcmp(type, "none"))
						param.m_iConnectType = 0;
					else if (!strcmp(type, "wire"))
						param.m_iConnectType = 1;
					else
					{
						param.m_iConnectType = 2;
						param.m_ConnectMaterial = type;
					}
				}
			}
			else
				param.m_iConnectType = 0;

			attval = atts.getValue("Material");
			if (attval)
				param.m_ConnectMaterial = attval;

			attval = atts.getValue("Top");
			if (attval)
				param.m_fConnectTop = (float)atof(attval);
			attval = atts.getValue("Bottom");
			if (attval)
				param.m_fConnectBottom = (float)atof(attval);
			attval = atts.getValue("Width");
			if (attval)
				param.m_fConnectWidth = (float)atof(attval);
			attval = atts.getValue("Slope");
			if (attval)
				param.m_iConnectSlope = atoi(attval);
			attval = atts.getValue("ConstantTop");
			if (attval)
				param.m_bConstantTop = (*attval == 't');

			attval = atts.getValue("Profile");
			if (attval)
				param.m_ConnectProfile = attval;
		}
	}
	if (m_state == 20)	// Imported
	{
		if (!strcmp(name, "Location"))
		{
			m_state = 21;
		}
	}
}