Example #1
0
void idFixedPosition::parse(const char * (*text))
{
	const char *token;
	Com_MatchToken(text, "{");

	do
	{
		token = Com_Parse(text);

		if(!token[0])
		{
			break;
		}

		if(!strcmp(token, "}"))
		{
			break;
		}

		// here we may have to jump over brush epairs ( only used in editor )
		do
		{
			// if token is not a brace, it is a key for a key/value pair
			if(!token[0] || !strcmp(token, "(") || !strcmp(token, "}"))
			{
				break;
			}

			Com_UngetToken();
			idStr key = Com_ParseOnLine(text);

			Com_Parse(text);

			if(Q_stricmp(key.c_str(), "pos") == 0)
			{
				Com_UngetToken();
				Com_Parse1DMatrix(text, 3, pos);
			}
			else
			{
				Com_UngetToken();
				idCameraPosition::parseToken(key.c_str(), text);
			}

			token = Com_Parse(text);

		}
		while(1);

		if(!strcmp(token, "}"))
		{
			break;
		}

	}
	while(1);

	Com_UngetToken();
	Com_MatchToken(text, "}");
}
Example #2
0
bool idCameraPosition::parseToken(const char *key, const char *(*text)) {
	const char *token = Com_Parse(text);
	if (Q_stricmp(key, "time") == 0) {
		time = atol(token);
		return true;
	} else if (Q_stricmp(key, "type") == 0) {
		type = static_cast<idCameraPosition::positionType>(atoi(token));
		return true;
	} else if (Q_stricmp(key, "velocity") == 0) {
		long t = atol(token);
		token = Com_Parse(text);
		long d = atol(token);
		token = Com_Parse(text);
		float s = atof(token);
		addVelocity(t, d, s);
		return true;
	} else if (Q_stricmp(key, "baseVelocity") == 0) {
		baseVelocity = atof(token);
		return true;
	} else if (Q_stricmp(key, "name") == 0) {
		name = token;
		return true;
	} else if (Q_stricmp(key, "time") == 0) {
		time = atoi(token);
		return true;
	}
	Com_UngetToken();
	return false;
}
Example #3
0
void idSplineList::parse(const char *(*text)  ) {
	const char *token;
	//Com_MatchToken( text, "{" );
	do {
		token = Com_Parse( text );
	
		if ( !token[0] ) {
			break;
		}
		if ( !Q_stricmp (token, "}") ) {
			break;
		}

		do {
			// if token is not a brace, it is a key for a key/value pair
			if ( !token[0] || !Q_stricmp (token, "(") || !Q_stricmp(token, "}")) {
				break;
			}

			Com_UngetToken();
			idStr key = Com_ParseOnLine(text);
			const char *token = Com_Parse(text);
			if (Q_stricmp(key.c_str(), "granularity") == 0) {
				granularity = atof(token);
			} else if (Q_stricmp(key.c_str(), "name") == 0) {
				name = token;
			}
			token = Com_Parse(text);

		} while (1);

		if ( !Q_stricmp (token, "}") ) {
			break;
		}

		Com_UngetToken();
		// read the control point
		idVec3_t point;
		Com_Parse1DMatrix( text, 3, point );
		addPoint(point.x, point.y, point.z);
	} while (1);
 
	//Com_UngetToken();
	//Com_MatchToken( text, "}" );
	dirty = true;
}
Example #4
0
void idCameraFOV::parse(const char *(*text)  ) {
	const char *token;
	Com_MatchToken( text, "{" );
	do {
		token = Com_Parse( text );
	
		if ( !token[0] ) {
			break;
		}
		if ( !strcmp (token, "}") ) {
			break;
		}

		// here we may have to jump over brush epairs ( only used in editor )
		do {
			// if token is not a brace, it is a key for a key/value pair
			if ( !token[0] || !strcmp (token, "(") || !strcmp(token, "}")) {
				break;
			}

			Com_UngetToken();
			idStr key = Com_ParseOnLine(text);
			const char *token = Com_Parse(text);
			if (Q_stricmp(key.c_str(), "fov") == 0) {
				fov = atof(token);
			} else if (Q_stricmp(key.c_str(), "startFOV") == 0) {
				startFOV = atof(token);
			} else if (Q_stricmp(key.c_str(), "endFOV") == 0) {
				endFOV = atof(token);
			} else if (Q_stricmp(key.c_str(), "time") == 0) {
				time = atoi(token);
			}
			token = Com_Parse(text);

		} while (1);

		if ( !strcmp (token, "}") ) {
			break;
		}

	} while (1);
 
	Com_UngetToken();
	Com_MatchToken( text, "}" );
}
Example #5
0
void idCameraEvent::parse(const char *(*text)  ) {
	const char *token;
	Com_MatchToken( text, "{" );
	do {
		token = Com_Parse( text );
	
		if ( !token[0] ) {
			break;
		}
		if ( !strcmp (token, "}") ) {
			break;
		}

		// here we may have to jump over brush epairs ( only used in editor )
		do {
			// if token is not a brace, it is a key for a key/value pair
			if ( !token[0] || !strcmp (token, "(") || !strcmp(token, "}")) {
				break;
			}

			Com_UngetToken();
			idStr key = Com_ParseOnLine(text);
			const char *token = Com_Parse(text);
			if (Q_stricmp(key.c_str(), "type") == 0) {
				type = static_cast<idCameraEvent::eventType>(atoi(token));
			} else if (Q_stricmp(key.c_str(), "param") == 0) {
				paramStr = token;
			} else if (Q_stricmp(key.c_str(), "time") == 0) {
				time = atoi(token);
			}
			token = Com_Parse(text);

		} while (1);

		if ( !strcmp (token, "}") ) {
			break;
		}

	} while (1);
 
	Com_UngetToken();
	Com_MatchToken( text, "}" );
}
Example #6
0
void idCameraDef::parse(const char * (*text))
{

	const char  *token;

	do
	{
		token = Com_Parse(text);

		if(!token[0])
		{
			break;
		}

		if(!Q_stricmp(token, "}"))
		{
			break;
		}

		if(Q_stricmp(token, "time") == 0)
		{
			baseTime = Com_ParseFloat(text);
		}
		else if(Q_stricmp(token, "camera_fixed") == 0)
		{
			cameraPosition = new idFixedPosition();
			cameraPosition->parse(text);
		}
		else if(Q_stricmp(token, "camera_interpolated") == 0)
		{
			cameraPosition = new idInterpolatedPosition();
			cameraPosition->parse(text);
		}
		else if(Q_stricmp(token, "camera_spline") == 0)
		{
			cameraPosition = new idSplinePosition();
			cameraPosition->parse(text);
		}
		else if(Q_stricmp(token, "target_fixed") == 0)
		{
			idFixedPosition *pos = new idFixedPosition();
			pos->parse(text);
			targetPositions.Append(pos);
		}
		else if(Q_stricmp(token, "target_interpolated") == 0)
		{
			idInterpolatedPosition *pos = new idInterpolatedPosition();
			pos->parse(text);
			targetPositions.Append(pos);
		}
		else if(Q_stricmp(token, "target_spline") == 0)
		{
			idSplinePosition *pos = new idSplinePosition();
			pos->parse(text);
			targetPositions.Append(pos);
		}
		else if(Q_stricmp(token, "fov") == 0)
		{
			fov.parse(text);
		}
		else if(Q_stricmp(token, "event") == 0)
		{
			idCameraEvent *event = new idCameraEvent();
			event->parse(text);
			addEvent(event);
		}


	}
	while(1);

	if(!cameraPosition)
	{
		Com_Printf("no camera position specified\n");
		// prevent a crash later on
		cameraPosition = new idFixedPosition();
	}

	Com_UngetToken();
	Com_MatchToken(text, "}");

}