ETHBackBufferTargetManager::ETHBackBufferTargetManager(gs2d::VideoPtr video, const ETHAppEnmlFile& file, const Platform::Logger& logger)
{
	const gs2d::str_type::string fixedWidth  = file.GetFixedWidth();
	const gs2d::str_type::string fixedHeight = file.GetFixedHeight();
	if (!ComputeLength(video, fixedWidth, fixedHeight, true))
	{
		ComputeLength(video, fixedHeight, fixedWidth, false);
	}
	const gs2d::math::Vector2 screenSize(video->GetScreenSizeF());
	m_bufferSize.x = gs2d::math::Min(screenSize.x, m_bufferSize.x);
	m_bufferSize.y = gs2d::math::Min(screenSize.y, m_bufferSize.y);

	gs2d::str_type::stringstream ss; ss << GS_L("Backbuffer created as ") << m_bufferSize.x << GS_L(", ") << m_bufferSize.y
										<< GS_L(" on ");
	if (m_bufferSize == screenSize)
	{
		m_backBuffer = ETHDynamicBackBufferPtr(new ETHNoDynamicBackBuffer(video, m_bufferSize));
		ss << GS_L("default backbuffer mode");
	}
	else
	{
		m_backBuffer = ETHDynamicBackBufferPtr(new ETHDefaultDynamicBackBuffer(video, m_bufferSize));
		ss << GS_L("dynamic framebuffer mode");
	}
	m_targetScale = m_bufferSize.x / screenSize.x;

	CreateOBB();

	logger.Log(ss.str(), Platform::Logger::INFO);
}
Ejemplo n.º 2
0
TAbscissa::TAbscissa(const Element & ele)
: TBisector(ele)
{
    id = generateId();

    ComputeLength();
}
Ejemplo n.º 3
0
TAbscissa::TAbscissa(const TPoint& PP0, const TPoint& PP1)
: TBisector(PP0, PP1)
{
    id = generateId();

    ComputeLength();
}
ETHBackBufferTargetManager::ETHBackBufferTargetManager(gs2d::VideoPtr video, const gs2d::enml::File& file, const Platform::Logger& logger)
{
	const gs2d::str_type::string fixedWidth  = file.get(GS_L("window"), GS_L("fixedWidth"));
	const gs2d::str_type::string fixedHeight = file.get(GS_L("window"), GS_L("fixedHeight"));
	if (!ComputeLength(video, fixedWidth, fixedHeight, true))
	{
		ComputeLength(video, fixedHeight, fixedWidth, false);
	}
	const gs2d::math::Vector2 screenSize(video->GetScreenSizeF());
	m_bufferSize.x = gs2d::math::Min(screenSize.x, m_bufferSize.x);
	m_bufferSize.y = gs2d::math::Min(screenSize.y, m_bufferSize.y);

	m_backBuffer = (m_bufferSize == screenSize) ? 
					ETHDynamicBackBufferPtr(new ETHNoDynamicBackBuffer(video, m_bufferSize)) :
					ETHDynamicBackBufferPtr(new ETHDefaultDynamicBackBuffer(video, m_bufferSize));
	m_targetScale = m_bufferSize.x / screenSize.x;

	gs2d::str_type::stringstream ss; ss << GS_L("Backbuffer created as ") << m_bufferSize.x << GS_L(", ") << m_bufferSize.y;
	logger.Log(ss.str(), Platform::Logger::INFO);
}
Ejemplo n.º 5
0
Point2D::Point2D(float _x, float _y)
{
	x = _x;
	y = _y;
	ComputeLength();
}
Ejemplo n.º 6
0
void Point2D::Set(float _x, float _y)
{
	x = _x;
	y = _y;
	ComputeLength();
}
Ejemplo n.º 7
0
void TAbscissa::SetPoints(const TPoint& PP0, const TPoint& PP1) {
    TBisector::SetPoints(PP0, PP1);
    ComputeLength();
}
Ejemplo n.º 8
0
void GenerateLOD::GetEdgeCost(bool &isUtoV, FbxDouble &cost, int U, int V, FbxVector4 *pControlPoints)
{
	FbxDouble LUV = ComputeLength(pControlPoints, U, V);
	const std::set<int> &UTi = (*ControlP)[U].Ti;
	const std::set<int> &VTi = (*ControlP)[V].Ti;
	std::unordered_set<int> Tuv;
	Tuv.clear();
	// Set Tuv as the union for (*ControlP)[U].Ti and (*ControlP)[V].Ti
	std::set_union(UTi.begin(), UTi.end(),
		VTi.begin(), VTi.end(),
		std::inserter(Tuv, Tuv.begin()));

	// U ---> V
	FbxDouble fu = -1;
	for (const auto &i1 : (*ControlP)[U].Ti) {
		Tuv.erase(i1); // remove i1 from Tuv
		FbxDouble minfuv = (std::numeric_limits<double>::max)();
		const std::vector<FbxDouble> &normal_i = (*Triangles)[i1].normal;
		for (const auto &j : Tuv) {
			const std::vector<FbxDouble> &normal_j = (*Triangles)[j].normal;
			// (1 - f.normal * n.normal) / 2
			FbxDouble ijnorlmal = (1 - (
				normal_i[0] * normal_j[0] +
				normal_i[1] * normal_j[1] +
				normal_i[2] * normal_j[2])) / 2.0;
			if (ijnorlmal < minfuv)
				minfuv = ijnorlmal;
		}
		if (minfuv > fu)
			fu = minfuv;
		Tuv.insert(i1); // add back i1 to Tuv
	}
	//FbxDouble costUV = LUV * fu;

	// V ---> U
	FbxDouble fv = -1;
	for (const auto &i1 : (*ControlP)[V].Ti) {
		Tuv.erase(i1); // remove i1 from Tuv
		FbxDouble minfvu = (std::numeric_limits<double>::max)();
		const std::vector<FbxDouble> &normal_i = (*Triangles)[i1].normal;
		for (const auto &j : Tuv) {
			if (j == i1)
				continue;
			const std::vector<FbxDouble> &normal_j = (*Triangles)[j].normal;
			// (1 - f.normal * n.normal) / 2
			FbxDouble ijnorlmal = (1 - (
				normal_i[0] * normal_j[0] +
				normal_i[1] * normal_j[1] +
				normal_i[2] * normal_j[2])) / 2.0;
			if (ijnorlmal < minfvu)
				minfvu = ijnorlmal;
		}
		if (minfvu > fv)
			fv = minfvu;
		Tuv.insert(i1); // add back i1 to Tuv
	}
	//FbxDouble costVU = LUV * fv;

	if (fv < fu) {
		isUtoV = false;
		cost = LUV * fv;
	}
	else {
		isUtoV = true;
		cost = LUV * fu;
	}
}
Ejemplo n.º 9
0
void GenerateLOD::InitEdges(FbxMesh *pMesh)
{
	FbxVector4 *pControlPoints = pMesh->GetControlPoints();
	int EdgeCount = pMesh->GetMeshEdgeCount();

	pMesh->BeginGetMeshEdgeVertices();
	for (int i = 0; i < EdgeCount; ++i) {
		int U;
		int V;
		pMesh->GetMeshEdgeVertices(i, U, V);
		(*ControlP)[U].Ei.insert(i);
		(*ControlP)[V].Ei.insert(i);

		//(*Edges)[i] = Edge();
		(*Edges)[i].twoPoints = { U, V };

		if ((*ControlP)[U].uvSet.size() > 1 || (*ControlP)[V].uvSet.size() > 1) {
			(*Edges)[i].ShouldCollapse = false;
			continue;
		}

		//MessageBox(NULL, "InitEdge1", "This", 0);

		FbxDouble LUV = ComputeLength(pControlPoints, U, V);

		// U ---> V
		FbxDouble fu = -1;
		const std::set<int> &UTi = (*ControlP)[U].Ti;
		const std::set<int> &VTi = (*ControlP)[V].Ti;
		std::unordered_set<int> Tuv;
		Tuv.clear();
		// Set Tuv as the union for (*ControlP)[U].Ti and (*ControlP)[V].Ti
		std::set_union(UTi.begin(), UTi.end(),
			VTi.begin(), VTi.end(),
			std::inserter(Tuv, Tuv.begin()));

		//MessageBox(NULL, "InitEdge2", "This", 0);

		for (const auto &i1 : (*ControlP)[U].Ti) {
			Tuv.erase(i1); // remove i1 from Tuv
			FbxDouble minfuv = (std::numeric_limits<double>::max)();
			const std::vector<FbxDouble> &normal_i = (*Triangles)[i1].normal;
			for (const auto &j : Tuv) {
				const std::vector<FbxDouble> &normal_j = (*Triangles)[j].normal;
				// (1 - f.normal * n.normal) / 2
				FbxDouble ijnorlmal = (1 - (
					normal_i[0] * normal_j[0] +
					normal_i[1] * normal_j[1] +
					normal_i[2] * normal_j[2])) / 2.0;
				if (ijnorlmal < minfuv)
					minfuv = ijnorlmal;
			}
			if (minfuv > fu)
				fu = minfuv;
			Tuv.insert(i1); // add back i1 to Tuv
		}
		FbxDouble costUV = fu;

		//MessageBox(NULL, "InitEdge3", "This", 0);

		// V ---> U
		FbxDouble fv = -1;
		for (const auto &i1 : (*ControlP)[V].Ti) {
			Tuv.erase(i1); // remove i1 from Tuv
			FbxDouble minfvu = (std::numeric_limits<double>::max)();
			const std::vector<FbxDouble> &normal_i = (*Triangles)[i1].normal;
			for (const auto &j : Tuv) {
				const std::vector<FbxDouble> &normal_j = (*Triangles)[j].normal;
				// (1 - f.normal * n.normal) / 2
				FbxDouble ijnorlmal = (1 - (
					normal_i[0] * normal_j[0] +
					normal_i[1] * normal_j[1] +
					normal_i[2] * normal_j[2])) / 2.0;
				if (ijnorlmal < minfvu)
					minfvu = ijnorlmal;
			}
			if (minfvu > fv)
				fv = minfvu;
			Tuv.insert(i1); // add back i1 to Tuv
		}
		FbxDouble costVU = fv;

		//MessageBox(NULL, "InitEdge4", "This", 0);

		if (costVU < costUV) {
			FbxDouble cost = LUV * costVU;
			(*Edges)[i].isUV = false;
			(*Edges)[i].Cost = cost;
			HeapCost->push(cost);
			//if ((*CostToEdge).find(cost) != (*CostToEdge).end())
			(*CostToEdge)[cost].push_back(i);
			//else
			//(*CostToEdge)[cost] = std::vector<int>({ i });
		}
		else {
			FbxDouble cost = LUV * costUV;
			(*Edges)[i].isUV = true;
			(*Edges)[i].Cost = cost;
			HeapCost->push(cost);
			//if ((*CostToEdge).find(cost) != (*CostToEdge).end())
			(*CostToEdge)[cost].push_back(i);
			//else
			//(*CostToEdge)[cost] = std::vector<int>({ i });
		}
	}
	pMesh->EndGetMeshEdgeVertices();
}