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
void Com_Parse1DMatrix( const char** buf_p, int x, float* m ) {
	Com_MatchToken( buf_p, "(" );

	for ( int i = 0; i < x; i++ ) {
		const char* token = Com_Parse( buf_p );
		m[ i ] = String::Atof( token );
	}

	Com_MatchToken( buf_p, ")" );
}
Example #3
0
void Com_Parse3DMatrix( const char *(*buf_p), int z, int y, int x, float *m ) {
	int		i;

	Com_MatchToken( buf_p, "(" );

	for (i = 0 ; i < z ; i++) {
		Com_Parse2DMatrix (buf_p, y, x, m + i * x*y);
	}

	Com_MatchToken( buf_p, ")" );
}
Example #4
0
void Com_Parse1DMatrix( const char *(*buf_p), int x, float *m ) {
	const char	*token;
	int		i;

	Com_MatchToken( buf_p, "(" );

	for (i = 0 ; i < x ; i++) {
		token = Com_Parse(buf_p);
		m[i] = atof(token);
	}

	Com_MatchToken( buf_p, ")" );
}
Example #5
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 #6
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 #7
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, "}");

}