gamehook_gtav icon indicating copy to clipboard operation
gamehook_gtav copied to clipboard

Adding camera matricies to JSON

Open el3ment opened this issue 6 years ago • 0 comments

I'm trying to add avg_world, avg_world_view, and avg_world_view_proj to the JSON output. I've created a new function:

std::string toJSON(float4x4 & f) {
	std::stringstream s;
	s << "[ [" << f.d[0][0] << ", " << f.d[0][1] << ", " << f.d[0][2] << ", " << f.d[0][3] << "], ["
		<< f.d[1][0] << ", " << f.d[1][1] << ", " << f.d[1][2] << ", " << f.d[1][3] << "], ["
		<< f.d[2][0] << ", " << f.d[2][1] << ", " << f.d[2][2] << ", " << f.d[2][3] << "], ["
		<< f.d[3][0] << ", " << f.d[3][1] << ", " << f.d[3][2] << ", " << f.d[3][3] << "] ]";
	return s.str();
}

And added members to the GameInfo:

struct GameInfo {
	int time_since_player_hit_vehicle;
	int time_since_player_hit_ped;
	int time_since_player_drove_on_pavement;
	int time_since_player_drove_against_traffic;
	int dead;
	Vec3f position, forward_vector;
	float heading;
	int on_foot, in_vehicle, on_bike, money;
	float4x4 avg_world;
	float4x4 avg_world_view;
	float4x4 avg_world_view_projection;
};

And added the members to the TOJSON macro:

TOJSON(GameInfo, time_since_player_hit_vehicle, time_since_player_hit_ped, time_since_player_drove_on_pavement, time_since_player_drove_against_traffic, dead, position, forward_vector, heading, on_foot, in_vehicle, on_bike, money, avg_world, avg_world_view, avg_world_view_projection)

But, the output returns just a "1": {"time_since_player_hit_vehicle":-1,"time_since_player_hit_ped":-1,"time_since_player_drove_on_pavement":-1,"time_since_player_drove_against_traffic":-1,"dead":0,"position":[-14.380300,-1438.514282,31.101547],"forward_vector":[0.222740,-0.974878,0.000000],"heading":192.870010,"on_foot":1,"in_vehicle":0,"on_bike":0,"money":11,"avg_world":1,"avg_world_view":1,"avg_world_view_projection":1,"timestamp": 1534989424.864456}

Any ideas?

el3ment avatar Aug 23 '18 02:08 el3ment