I am currently modifying Celestia to create an interactive installation.
The idea is to allow a person to walk into the installation, and as they move from left to right, have the viewpoint they see on the projection screen update - a pseudo VR effect.
I am using Openframeworks (http://www.openframeworks.cc) to take input from a camera, and send the position to Celestia via OSC (http://opensoundcontrol.org/).
I have sucessfully modified the Celestia source to allow OSC input.
I am using a Celxscript for the installation, running constantly.
Code: Select all
-- Title: Travel to Randomly Picked Stars with a look
timeToTravel = 30
timeToLook = 1
keepGoing = true
obs = celestia:getobserver()
while keepGoing do
nstars = celestia:getstarcount()
index = math.floor(nstars * math.random())
star = celestia:getstar(index)
celestia:select(star)
obs:center(star, timeToLook)
wait(timeToLook)
obs:goto(star, timeToTravel)
wait(timeToTravel)
timeToTravel = timeToTravel/2
if timeToTravel < 2 then
timeToLook = 0.5
end
if timeToTravel < 1 then
timeToLook = 0.2
end
if timeToTravel < 0.2 then
timeToLook = 0.1
end
if timeToTravel < 0.001 then
keepGoing = false
end
end
To move from random star to random star in the universe, at an ever increasing rate, before finally stopping.
What I want to be able to do, while the script is running, is to change the viewpoint of the observer, so that they orbit around the target that is currently being moved towards.
At the end of the CelestiaCore::tick method I have added the following lines, in the place where I process OSC messages:
Code: Select all
Quatf q(1.0f);
float coarseness = ComputeRotationCoarseness(*sim);
q = q * Quatf::yrotation((float) (dt * -KeyRotationAccel * coarseness * numberOfMessagesThisTick));
sim->orbit(q);
As I am trying to get this to work, numberOfMessagesThisTick is an int, representing how many OSC messages have been received this tick.
If a script isn't running, then everything works as expected - the camera orbits.
If a script is running, then I don't see any results. Is there a way that anyone could suggest to allow me to orbit while the script is running? I want to feel like someone is being taken on a random journey across the universe, with their movement in the real world updating the simulation.
In addition, I need to be able to start and stop the script from within the CelestiaCore::tick, so that the installation can activate when the user enters the room. Should I use:
Code: Select all
luaHook->loadScript(<#std #>, <#const std streamname#>)
Is the luaHook object the thing to use?