I'm building the VR project template for Leadwerks 4.5. Although you can enable VR in any project, this template is specifically designed to provide some of your most common room-scale VR features:
Teleportation movement, which prevents motion sickness.
Picking up and throwing objects. (It's actually really fun!)
To start with I am creating the art assets for the teleport effect. This is basically what I want:
Your controller shoots a beam which ends in an indicator when it hits an upwards-facing slope. Typically this beam will be somewhat arced. Why the curve? This allows you to climb up to areas above you:
As always, I am starting with the game assets. I don't believe in using programmer art because it hurts your understanding of what you are trying to create, it's uninspiring, and you will end up writing your code twice once you get the final artwork and realize all the mistakes you made.
I started with textures. I know I want a circular indicator on the floor, a misty spinning effect rising off it, and a beam. I'm going to make all my textures grayscale so that I can control the color with the entity color value and dynamically change it in the game. Here are my textures I created in about ten minutes in Paint Shop Pro:
The first texture above is clamped along the X and Y axes and the second one is clamp along the Y axis. I am using uncompressed textures for all of these because they have a lot of soft gradients.
I created my materials with the following settings, again leaving everything white:
In 3ds Max I created my indicator model. It's just a plane with a cylinder on top, with the end caps removed:
When I import it into Leadwerks and apply my materials, the model looks like this:
I'll show you why I am using uncompressed textures. You can see in this shot the edge of the ring has some ugly artifacts when texture compression is used:
Here's a closeup. Not something I want to see in VR:
Now I am going to create an instance of the model in the editor and adjust the color. I want a bright blue glowy color. I am setting the color to RGB 128,255,255 and cranking the intensity way up to 2.0. This effectively sets the entity color to 256,512,512. This color is multiplied by the texture color at each pixel and then clamped to 0-255 (the maximum color range of the monitor). That means that the brightest spots on the material will reach a full 255,255,255 white color and look really intense, while darker parts will be tinted blue:
Notice the object isn't just a flat color, but has a range of color from blue to white. To get this effect I had to increase the intensity over 1.0 to create colors brighter than RGB 255,255,255, and I had to have some red in the color. If I had set the color to RGB 0,255,255 the red channel would never increase and I would have a flat color like this. Not so good:
If I had set the color to RGB 128,255,255 but left the intensity at 1.0 I would also have a solid color:
Finally I added a script to the model and saved it as a prefab. The script just rotates the model around slowly on its Y axis, which I think will look pretty good. I'm going to perform the rotation in the Draw() function so it doesn't get called if the object is hidden or offscreen, and I don't think anyone will notice if the rotation doesn't update when they look away:
function Script:Draw()
self.entity:Turn(, * Time:GetSpeed(), )
end
That's it for now. The next step will be to create my teleportation mechanic in VR.
↧