function showObjectTrajectoriesIn3D(filename)

fileData = load(filename);

nObj = fileData.nObj;
Obj = fileData.Obj;
TD = fileData.TD;


fh = figure(1); clf;hold on; 
sh = subplot(1,1,1);

if ~(nObj == 0)  % if there are any objs in the recording
    
    nObj = Obj.nObj;
    
    % Find the length of the recording to count the total number of frames
    initial_time = TD.ts(1);
    final_time = TD.ts(end);
    
    % Each frame is equal to 10000 uSecs
    nFrames = floor((final_time - initial_time)/10000);
    
    % Make an arrays for each object
    xCoordinateArray = nan(nFrames,nObj);
    yCoordinateArray = nan(nFrames,nObj);

    % Populate with respective x,y coordinates for each frame
    for i= 0:nObj-1
        xCoordinateArray(floor((Obj.ts(Obj.id==i)-initial_time)/1e4),i+1) = Obj.x(Obj.id==i);
        yCoordinateArray(floor((Obj.ts(Obj.id==i)-initial_time)/1e4),i+1) = Obj.y(Obj.id==i);
    end
    
    % For showing each object in a different colour
    colorArray=hsv(nObj);
    
    % Plot all the objects
    for i = 1:nObj
        plot3(xCoordinateArray(:,i),yCoordinateArray(:,i),1:nFrames,'.','color',colorArray(i,:),'markersize',7)
    end
    

end

hold off;

grid on;
zlabel('Frame Number (each frame = 10000 \mu Secs)')

xlabel('X')
ylabel('Y')
title("Object Trajectories")


% Viewing angle in 3D
view(40,10)




