コード例 #1
0
ファイル: LDModelParser.cpp プロジェクト: HazenBabcock/LDView
bool LDModelParser::substituteStud(int numSegments)
{
	TCULong blackColor = 0;

	if (m_flags.obi &&
		!m_topLDLModel->colorNumberIsTransparent(m_currentColorNumber) &&
		m_obiTokens.find("obi_stud_cancel") == m_obiTokens.end())
	{
		LDLPalette *palette = m_topLDLModel->getMainModel()->getPalette();
		int colorNumber = 0;

		if (palette)
		{
			colorNumber = palette->getColorNumberForName("OBI_BLACK");
		}
		blackColor = m_topLDLModel->getPackedRGBA(colorNumber);
	}
	m_currentTREModel->addCylinder(TCVector(0.0f, -4.0f, 0.0f), 6.0f, 4.0f,
		numSegments, numSegments, getBFCFlag(), blackColor, blackColor);
	m_currentTREModel->addStudDisc(TCVector(0.0f, -4.0f, 0.0f), 6.0f,
		numSegments, numSegments, getBFCFlag());
	if (getEdgeLinesFlag())
	{
		m_currentTREModel->addCircularEdge(TCVector(0.0f, -4.0f, 0.0f), 6.0f,
			numSegments, -1, blackColor);
		m_currentTREModel->addCircularEdge(TCVector(0.0f, 0.0f, 0.0f), 6.0f,
			numSegments, -1, blackColor);
	}
	return true;
}
コード例 #2
0
ファイル: LDLLineLine.cpp プロジェクト: HazenBabcock/LDView
bool LDLLineLine::parse(void)
{
	float x1, y1, z1;
	float x2, y2, z2;
	int lineType;

	if (sscanf(m_line, "%d %i %f %f %f %f %f %f", &lineType, &m_colorNumber,
		&x1, &y1, &z1, &x2, &y2, &z2) == 8)
	{
		m_points = new TCVector[2];
		m_points[0] = TCVector(x1, y1, z1);
		m_points[1] = TCVector(x2, y2, z2);
		if (!getMainModel()->getSkipValidation())
		{
			getMatchingPoints();
		}
		return true;
	}
	else
	{
		m_valid = false;
		setError(LDLEParse, TCLocalStrings::get(_UC("LDLLineParse")));
		return false;
	}
}
コード例 #3
0
ファイル: LDLQuadLine.cpp プロジェクト: tcobbs/ldview
bool LDLQuadLine::parse(void)
{
	float x1, y1, z1;
	float x2, y2, z2;
	float x3, y3, z3;
	float x4, y4, z4;
	int lineType;

	if (sscanf(m_line, "%d %i %f %f %f %f %f %f %f %f %f %f %f %f", &lineType,
		&m_colorNumber, &x1, &y1, &z1, &x2, &y2, &z2, &x3, &y3, &z3,
		&x4, &y4, &z4) == 14)
	{
		std::string prefix = getTypeAndColorPrefix();
		std::stringstream ss;
		if (!prefix.empty())
		{
			ss << prefix << "  ";
		}
		else
		{
			ss << "4 " << m_colorNumber << "  ";
		}
		ss << x1 << " " << y1 << " " << z1 << "  ";
		ss << x2 << " " << y2 << " " << z2 << "  ";
		ss << x3 << " " << y3 << " " << z3 << "  ";
		ss << x4 << " " << y4 << " " << z4 << "  ";
		m_formattedLine = copyString(ss.str().c_str());
		m_points = new TCVector[4];
		m_points[0] = TCVector(x1, y1, z1);
		m_points[1] = TCVector(x2, y2, z2);
		m_points[2] = TCVector(x3, y3, z3);
		m_points[3] = TCVector(x4, y4, z4);
		if (!getMainModel()->getSkipValidation())
		{
			// Note that we don't care what the second matching index is,
			// because we only need to throw out one of the two points, so don't
			// bother to even read it.
			if (getMatchingPoints(&m_matchingIndex))
			{
				m_valid = false;
			}
			else
			{
				swapPointsIfNeeded();
				checkForColinearPoints();
			}
		}
		return true;
	}
	else
	{
		m_valid = false;
		setError(LDLEParse, TCLocalStrings::get(_UC("LDLQuadLineParse")));
		return false;
	}
}
コード例 #4
0
ファイル: LDModelParser.cpp プロジェクト: HazenBabcock/LDView
bool LDModelParser::substituteStu24(bool isA, bool bfc)
{
	int numSegments = LO_NUM_SEGMENTS;

	m_currentTREModel->addCylinder(TCVector(0.0f, 0.0f, 0.0f), 6.0f, -4.0f, numSegments,
		numSegments, bfc);
	m_currentTREModel->addCylinder(TCVector(0.0f, -4.0f, 0.0f), 8.0f, 4.0f, numSegments,
		numSegments, bfc);
	m_currentTREModel->addOpenCone(TCVector(0.0f, -4.0f, 0.0f), 6.0f, 8.0f, 0.0f,
		numSegments, numSegments, bfc);
	if (getEdgeLinesFlag())
	{
		m_currentTREModel->addCircularEdge(TCVector(0.0f, -4.0f, 0.0f), 6.0f,
			numSegments);
		m_currentTREModel->addCircularEdge(TCVector(0.0f, -4.0f, 0.0f), 8.0f,
			numSegments);
		if (!isA)
		{
			m_currentTREModel->addCircularEdge(TCVector(0.0f, 0.0f, 0.0f), 6.0f,
				numSegments);
			m_currentTREModel->addCircularEdge(TCVector(0.0f, 0.0f, 0.0f), 8.0f,
				numSegments);
		}
	}
	return true;
}
コード例 #5
0
ファイル: LDModelParser.cpp プロジェクト: HazenBabcock/LDView
bool LDModelParser::substituteNotDisc(TCFloat fraction,
									  bool bfc, bool is48)
{
	int numSegments = getNumCircleSegments(fraction, is48);

	m_currentTREModel->addNotDisc(TCVector(0.0f, 0.0f, 0.0f), 1.0f, numSegments,
		getUsedCircleSegments(numSegments, fraction), bfc);
	return true;
}
コード例 #6
0
ファイル: LDModelParser.cpp プロジェクト: HazenBabcock/LDView
bool LDModelParser::substituteEighthSphere(bool bfc,
										   bool is48)
{
	int numSegments = getNumCircleSegments(1.0, is48);

	m_currentTREModel->addEighthSphere(TCVector(0.0f, 0.0f, 0.0f), 1.0f, numSegments,
		bfc);
	return true;
}
コード例 #7
0
ファイル: LDModelParser.cpp プロジェクト: HazenBabcock/LDView
bool LDModelParser::substituteRing(TCFloat fraction, int size,
								   bool bfc, bool is48, bool /*isOld*/)
{
	int numSegments = getNumCircleSegments(fraction, is48);

	m_currentTREModel->addRing(TCVector(0.0f, 0.0f, 0.0f), (TCFloat)size,
		(TCFloat)size + 1.0f, numSegments,
		getUsedCircleSegments(numSegments, fraction), bfc);
	return true;
}
コード例 #8
0
ファイル: LDModelParser.cpp プロジェクト: HazenBabcock/LDView
bool LDModelParser::substituteTorusQ(TCFloat fraction, int size, bool bfc,
									 bool is48)
{
	int numSegments;

	numSegments = getNumCircleSegments(fraction, is48);
	m_currentTREModel->addTorusIO(true, TCVector(0.0f, 0.0f, 0.0f), 1.0f,
		getTorusFraction(size), numSegments,
		getUsedCircleSegments(numSegments, fraction), bfc);
	m_currentTREModel->addTorusIO(false, TCVector(0.0f, 0.0f, 0.0f), 1.0f,
		getTorusFraction(size), numSegments,
		getUsedCircleSegments(numSegments, fraction), bfc);
	m_currentTREModel->addTorusIO(true, TCVector(0.0f, 0.0f, 0.0f), 1.0f,
		-getTorusFraction(size), numSegments,
		getUsedCircleSegments(numSegments, fraction), bfc);
	m_currentTREModel->addTorusIO(false, TCVector(0.0f, 0.0f, 0.0f), 1.0f,
		-getTorusFraction(size), numSegments,
		getUsedCircleSegments(numSegments, fraction), bfc);
	return true;
}
コード例 #9
0
ファイル: LDLQuadLine.cpp プロジェクト: HazenBabcock/LDView
bool LDLQuadLine::parse(void)
{
	float x1, y1, z1;
	float x2, y2, z2;
	float x3, y3, z3;
	float x4, y4, z4;
	int lineType;

	if (sscanf(m_line, "%d %i %f %f %f %f %f %f %f %f %f %f %f %f", &lineType,
		&m_colorNumber, &x1, &y1, &z1, &x2, &y2, &z2, &x3, &y3, &z3,
		&x4, &y4, &z4) == 14)
	{
		m_points = new TCVector[4];
		m_points[0] = TCVector(x1, y1, z1);
		m_points[1] = TCVector(x2, y2, z2);
		m_points[2] = TCVector(x3, y3, z3);
		m_points[3] = TCVector(x4, y4, z4);
		if (!getMainModel()->getSkipValidation())
		{
			// Note that we don't care what the second matching index is,
			// because we only need to throw out one of the two points, so don't
			// bother to even read it.
			if (getMatchingPoints(&m_matchingIndex))
			{
				m_valid = false;
			}
			else
			{
				swapPointsIfNeeded();
				checkForColinearPoints();
			}
		}
		return true;
	}
	else
	{
		m_valid = false;
		setError(LDLEParse, TCLocalStrings::get(_UC("LDLQuadLineParse")));
		return false;
	}
}
コード例 #10
0
ファイル: LDModelParser.cpp プロジェクト: HazenBabcock/LDView
bool LDModelParser::substituteCircularEdge(TCFloat fraction,
										   bool is48)
{
	if (getEdgeLinesFlag())
	{
		int numSegments = getNumCircleSegments(fraction, is48);

		m_currentTREModel->addCircularEdge(TCVector(0.0f, 0.0f, 0.0f), 1.0f, numSegments,
			getUsedCircleSegments(numSegments, fraction));
	}
	return true;
}
コード例 #11
0
ファイル: LDModelParser.cpp プロジェクト: HazenBabcock/LDView
bool LDModelParser::substituteTorusIO(bool inner, TCFloat fraction, int size,
									  bool bfc, bool is48)
{
	int numSegments;
	//int size;
	//const char *modelName = m_currentTREModel->getName();
	//TCFloat fraction;
	//int offset = 0;

	//if (is48)
	//{
	//	offset = 3;
	//}
	//sscanf(modelName + 1 + offset, "%d", &numSegments);
	//sscanf(modelName + 4 + offset, "%d", &size);
	//fraction = (TCFloat)numSegments / 16.0f;
	numSegments = getNumCircleSegments(fraction, is48);
	m_currentTREModel->addTorusIO(inner, TCVector(0.0f, 0.0f, 0.0f), 1.0f,
		getTorusFraction(size), numSegments,
		getUsedCircleSegments(numSegments, fraction), bfc);
	return true;
}
コード例 #12
0
void LDLAutoCamera::zoomToFit(void)
{
	if (m_model)
	{
		TCFloat d;
		TCFloat a[6][6];
		TCFloat b[6];
		TCFloat x[6];
		TCVector tmpVec;
		TCVector location;
		TCVector cameraDir;
		TCFloat tmpMatrix[16];
		TCFloat tmpMatrix2[16];
		TCFloat transformationMatrix[16];
		LDLMainModel *mainModel = m_model->getMainModel();
		bool origScanControlPoints =
			mainModel->getScanConditionalControlPoints();

		TCVector::initIdentityMatrix(tmpMatrix);
		tmpMatrix[12] = m_modelCenter[0];
		tmpMatrix[13] = m_modelCenter[1];
		tmpMatrix[14] = m_modelCenter[2];
		TCVector::multMatrix(tmpMatrix, m_rotationMatrix, tmpMatrix2);
		tmpMatrix[12] = -m_modelCenter[0];
		tmpMatrix[13] = -m_modelCenter[1];
		tmpMatrix[14] = -m_modelCenter[2];
		TCVector::multMatrix(tmpMatrix2, tmpMatrix, transformationMatrix);
		preCalcCamera();
#ifdef _DEBUG
		m_numPoints = 0;
#endif // _DEBUG
		mainModel->setScanConditionalControlPoints(
			m_scanConditionalControlPoints);
		m_model->scanPoints(this,
			(LDLScanPointCallback)&LDLAutoCamera::scanCameraPoint,
			transformationMatrix, m_step, true);
		mainModel->setScanConditionalControlPoints(origScanControlPoints);
#ifdef _DEBUG
		debugPrintf("num points: %d\n", m_numPoints);
#endif // _DEBUG
		d = m_width / m_height;
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		a[0][0] = m_cameraData->normal[0][0];
		a[0][1] = m_cameraData->normal[0][1];
		a[0][2] = m_cameraData->normal[0][2];
		b[0] = m_cameraData->dMin[0];
		a[1][0] = m_cameraData->normal[1][0];
		a[1][1] = m_cameraData->normal[1][1];
		a[1][2] = m_cameraData->normal[1][2];
		b[1] = m_cameraData->dMin[1];
		a[2][3] = m_cameraData->normal[2][0];
		a[2][4] = m_cameraData->normal[2][1];
		a[2][5] = m_cameraData->normal[2][2];
		b[2] = m_cameraData->dMin[2];
		a[3][3] = m_cameraData->normal[3][0];
		a[3][4] = m_cameraData->normal[3][1];
		a[3][5] = m_cameraData->normal[3][2];
		b[3] = m_cameraData->dMin[3];
		if (m_cameraData->direction[0] == 0.0)
		{
			a[4][1] = -m_cameraData->direction[2];
			a[4][2] = m_cameraData->direction[1];
			a[4][4] = m_cameraData->direction[2];
			a[4][5] = -m_cameraData->direction[1];
			if (m_cameraData->direction[1] == 0.0)
			{
				a[5][0] = -m_cameraData->direction[2];
				a[5][2] = m_cameraData->direction[0];
				a[5][3] = m_cameraData->direction[2];
				a[5][5] = -m_cameraData->direction[0];
			}
			else
			{
				a[5][0] = -m_cameraData->direction[1];
				a[5][1] = m_cameraData->direction[0];
				a[5][3] = m_cameraData->direction[1];
				a[5][4] = -m_cameraData->direction[0];
			}
		}
		else
		{
			a[4][0] = -m_cameraData->direction[2];
			a[4][2] = m_cameraData->direction[0];
			a[4][3] = m_cameraData->direction[2];
			a[4][5] = -m_cameraData->direction[0];
			if (m_cameraData->direction[1] == 0.0 && m_cameraData->direction[2]
				!= 0.0)
			{
				a[5][1] = -m_cameraData->direction[2];
				a[5][2] = m_cameraData->direction[1];
				a[5][4] = m_cameraData->direction[2];
				a[5][5] = -m_cameraData->direction[1];
			}
			else
			{
				a[5][0] = -m_cameraData->direction[1];
				a[5][1] = m_cameraData->direction[0];
				a[5][3] = m_cameraData->direction[1];
				a[5][4] = -m_cameraData->direction[0];
			}
		}
		if (!L3Solve6(x, a, b))
		{
			// Singular matrix; can't work
			// (We shouldn't ever get here, so I'm not going to bother with an
			// error message.  I'd have to first come up with some mechanism
			// for communicating the error with the non-portable part of the
			// app so that it could be displayed to the user.)
			return;
		}
		tmpVec = TCVector(x[3], x[4], x[5]) - TCVector(x[0], x[1], x[2]);
		cameraDir = TCVector(m_cameraData->direction[0], m_cameraData->direction[1],
			m_cameraData->direction[2]);
		d = cameraDir.dot(tmpVec);
		if (d > 0.0)
		{
			location[0] = x[0];
			location[1] = x[1];
			location[2] = x[2] * (m_height + m_margin) / m_height;
		}
		else
		{
			location[0] = x[3];
			location[1] = x[4];
			location[2] = x[5] * (m_width + m_margin) / m_width;
		}
		if (m_haveGlobeRadius)
		{
			if (m_globeRadius >= 0)
			{
				location[2] = m_globeRadius;
			}
			else
			{
				location[2] *= 1.0f - m_globeRadius / 100.0f;
			}
		}
		else
		{
			location[2] *= m_distanceMultiplier;
		}
		m_camera.setPosition(location);
	}
}