Jump to content

Bodycam-style Movement Experiment


Josh

95 views

 Share

I am a fan of the recent bodycam-style movement videos that have come out. It's an idea I have had before, and then seeing it working was very cool. Today I spent a little time trying out my own implementation to see how well it would work.

My idea was to use my VR headset as a mocap system to record myself walking and get the headset orientation for a few seconds, then play that back in a loop when the first-person player moves around. I started with a simple scene. The strip on the ground gave me a clear indication of direction so I knew which way to walk.

image.thumb.png.213c1657de8c551c36fb0e0bd2e3098f.png

The walkway is oriented along the X axis because the room I am using is wider than it is long!

Next I made a simple program that would just record the headset orientation for a few frames. I used the trigger button to control when recording occurs. The recorded data gets saved to mocap.json when the program ends. It's very easy to accidentally overwrite this file, so once you get a good recording, it's a good idea to just copy and paste the file in case you overwrite it accidentally.

Once I had the mocap data, I modified the FPSPlayer so it would get loaded and displayed.

I added two global variables at the top of the file:

table mocapdata;
int mocapindex = 0;

Then I added some code to load the mocap data in the Start method:

void FPSPlayer::Start()
{
	mocapdata = LoadTable("mocap.json");

Next I added this function. It's a function, not a class method, but I was just trying to get things working as fast as possible so I could see the result:

void UpdateBobble(shared_ptr<Entity> camera)
{
	int count = mocapdata.size();
	mocapindex = mocapindex % count;
	Vec3 offset;
	offset.x = mocapdata[mocapindex]["position"][0];
	offset.y = mocapdata[mocapindex]["position"][1];
	offset.y -= 1.65f;
	offset.z = 0;// mocapdata[mocapindex]["position"][2];
	camera->Move(offset);

	float pitch = camera->rotation.x;
	camera->SetRotation(0, camera->rotation.y, 0);

	offset.x = 0;// mocapdata[mocapindex]["rotation"][2];
	offset.y = float(mocapdata[mocapindex]["rotation"][1]) - 90.0f;
	offset.z = 0;// mocapdata[mocapindex]["rotation"][0];
	camera->Turn(offset);

	camera->Turn(pitch, 0, 0);


	++mocapindex;
}

Next I created another scene with an FPSPlayer and a long textured hallway to walk down.

image.thumb.png.e4dc3f49882b0ce8c662d268a40d4fdd.png

I was worried that my head movements might be too subtle to show up in first-person player view, but it turns out I had nothing to worry about. Just some simple code produced the approximate effect I was hoping to see.

The technique basically works, but could be improved with more recordings in a bigger space, blending the start and the end of the loop to prevent the jump, and smoothing the camera movement a bit. Of course, you would want to footstep sounds to be timed to the footsteps in the mocap data. Still, the initial results are pretty good and I am encouraged to experiment with this more.

Here are the files I used. In main.cpp I added a definition for RECORDMODE, which controls whether the application is being run to record movement or play it back.

FPSPlayer.cpp main.cpp Maps.zip mocap.json

 Share

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...