The online racing simulator
Camera positioning with InSim
(4 posts, started )
Camera positioning with InSim
I'm trying to position a camera using CPP packets, but need help because I'm obviously doing something wrong. If I want to position the camera absolutely somewhere in the world, how do I do it? What flags do I set in the CPP packet? What does "Follower could not find position" mean when it prints out in red on the screen (during a multiplayer replay if it makes a difference)? Here's what I'm doing in general:

* Picking a world position to point the camera at.
* Setting the position in the CPP packet to +10 on the y-axis and +10 on the z-axis away from the position.
* Taking the arctangent of the delta between the camera and world positions y-axis divided by the difference between the x-axis (arc2(dy/dx)) for the heading of the camera.
* Taking the arctangent of the delta between the camera and world positions z-axis divided by the difference between the y-axis (arc2(dz/dy)) for the pitch of the camera.

The camera seems like it ends up really close to the track. I can't tell if it's pointed in the correct direction or not. Help!
not sure if that's the problem here, but +10 and -10 are only very small distances. Remember :

(from insim.txt)
int X; // X map (65536 = 1 metre)

so, the value 10 is like 1.5 mm. Maybe you need to convert your distance values first?
use noobTV
Quote from Victor :Maybe you need to convert your distance values first?

No, I'm doing that correctly. Here's the pertinent code snippet:


// private float ANGLE_CONSTANT = 65536.0f/360.0f;
CompCar challenger = event.getChallenger();

SetDirectCameraRequest request = new SetDirectCameraRequest();
request.setCameraType(StateResponse.CUSTOM_VIEW);
request.setFlags((short)(StateResponse.ISS_SHIFTU | StateResponse.ISS_VIEW_OVERRIDE | StateResponse.ISS_SHIFTU_NO_OPT));

InSimVector pos2 = new InSimVector(0, 65536 * 10, 65536 * 10);
InSimVector cameraPosition = challenger.getPosition().add(pos2);
request.setPosition(cameraPosition);

double heading = Math.toDegrees(Math.atan2((cameraPosition.getY()- challenger.getPosition().getY()),(cameraPosition.getX()- challenger.getPosition().getX())));
double pitch = Math.toDegrees(Math.atan2((cameraPosition.getZ()- challenger.getPosition().getZ()), (cameraPosition.getY()- challenger.getPosition().getY())));

request.setHeading((short)(heading * ANGLE_CONSTANT));
request.setPitch((short)(pitch * ANGLE_CONSTANT));

send(request);

The parts I'm unsure of are:

the call to setCameraType()
the call to setFlags()
the correct calculations of theta and phi with respect to the coordinate system

Camera positioning with InSim
(4 posts, started )
FGED GREDG RDFGDR GSFDG