How to Set Up Cameras in Your Farming Simulator Mod

By Jason van Gumster, Christian Ammann

You may need to add cameras to your Farming Simulator mod. If your vehicle involves player interaction such as driving, the player is going to expect to be able to have at least one optimal viewing angle … and would prefer to have even more. To meet this expectation, you can set up cameras on your vehicle mod.

However, just because you have camera objects in your I3D file, GIANTS Engine still doesn’t quite know everything necessary to use them with your vehicle. You need to inform the engine where the cameras are, as well as their capabilities. The <cameras> tag of your vehicle XML file handles it.

The way the cameras section of the XML file works, you use the count attribute in the <cameras> tag to inform the game engine of the number of cameras in your vehicle. Then, within the open and close of the <cameras> tag, you have a specific tag for each camera, numbered sequentially (for instance, <camera1>, <camera2>, and so on). The main attributes for each individual camera tag are as follows:

  • index: Quite possibly the most important attribute, this index path goes to a camera object. Without it, GIANTS Engine doesn’t know which camera you’re talking about.

  • rotatable: Typically this attribute is set as true. The only exception is something like a rear-view camera that’s only used for backing up.

  • rotateNode: Having your camera rotate about a set of axes other than its own, such as having an outdoor camera that points at your vehicle, is occasionally desirable. In that case, the camera should rotate about a point somewhere within the vehicle rather than its own local axes.

    In those situations, the rotateNode attribute is the index path of the alternate axes. For this to work properly, the camera object should be a child of whatever that rotateNode object is (typically a transform group).

The rotateNode attribute is useful when your camera is an outdoor camera, where it looks at the vehicle from outside of it rather than giving the player a first-person perspective from the driver’s seat. However, when you set up an outdoor camera, GIANTS Engine has some automatic measures it takes to make using that camera more enjoyable for the player.

Specifically, outdoor cameras purposefully avoid obstructions that may get between the camera and the vehicle. The engine moves the camera closer to the vehicle when it detects an obstruction getting in the way.

In order for this automated obstruction avoidance to work, though, the game engine needs one or more references. It needs to draw an imaginary line between the camera and some other object in the vehicle. This imaginary line is sometimes referred to as a ray that is cast from the camera to some reference point.

The game engine makes sure that at least one reference point is visible to the camera. During gameplay, if another object crosses that ray, the game engine identifies an obstruction and moves the camera toward the vehicle.

To facilitate all of this in the vehicle XML file, you need to define a couple reference points, or raycast nodes (but not too many, casting too many rays can be computationally expensive) using a <raycastNode> tag as a child of your outdoor camera’s tag.

The <raycastNode> tag only has a single attribute, index, which is the index path of the object that the camera should cast a ray toward. Generally speaking, raycast node objects are transform groups, and you typically have one at the front of your vehicle and one at the rear.