Cham wrote:ROFL !
Try this one !
Celestia CARTOONS!



Cham wrote:ROFL !
Try this one !
Code: Select all
function test_periodic(t)
-- Create a new table
local orbit = {};
-- Save the parameter list
orbit.params = t;
-- Set the required fields boundingRadius and position; note that position is actually a function
orbit.boundingRadius = t.SemiAxis
-- The position function will be called whenever Celestia needs the position of the object
function orbit:position(tjd)
local t = tjd - 2451545.0
--local PeriodicTime = t - math.floor(t);
local Phi = 2 * math.pi * t / self.params.KeplerPeriod
local exc = self.params.Excentricity;
local Phase = Phi + exc * math.sin(Phi + exc * math.sin(Phi + exc * math.sin(Phi + exc * math.sin(Phi))));
local x1 = (self.params.SemiAxis) * (math.cos(Phase) - exc);
local y1 = (self.params.SemiAxis) * math.sqrt(1 - exc * exc) * math.sin(Phase);
local Omega = 2 * math.pi * self.params.PrecessionRate * t
local x = x1 * math.cos(Omega) - y1 * math.sin(Omega)
local y = x1 * math.sin(Omega) + y1 * math.cos(Omega)
local z = 0
return x, y, z
end
return orbit
end
Code: Select all
"Test" "Sol/Earth"
{
Class "spacecraft"
Mesh "UFO.cmod"
Orientation [90 1 0 0]
Radius 10
Albedo 0.6
ScriptedOrbit {
Module "test"
Function "test_periodic"
SemiAxis 24000 # in km
KeplerPeriod 0.0004 # Revolution period in days
Excentricity 0.7 # Must be < 1
PrecessionRate 200 # Precession rate, in units of 2Pi/day
}
}
Code: Select all
function test_periodic(t)
-- Create a new table
local orbit = {};
-- Save the parameter list
orbit.params = t;
-- Set the required fields boundingRadius and position; note that position is actually a function
orbit.boundingRadius = t.SemiAxis
-- The position function will be called whenever Celestia needs the position of the object
function orbit:position(tjd)
local t = tjd - 2451545.0
--local PeriodicTime = t - math.floor(t);
local Phi = 2 * math.pi * t / self.params.KeplerPeriod
local exc = self.params.Excentricity;
local Phase = Phi + exc * math.sin(Phi + exc * math.sin(Phi + exc * math.sin(Phi + exc * math.sin(Phi))));
-- position of the particle in canonical orbit orientation
local canonical = celestia:newvector(
(self.params.SemiAxis) * (math.cos(Phase) - exc),
(self.params.SemiAxis) * math.sqrt(1 - exc * exc) * math.sin(Phase),
0
);
-- rotation about the z axis
local rot = celestia:newrotation(
celestia:newvector(0,0,1),
2 * math.pi * self.params.PrecessionRate * t
);
-- compute coordinates in rotated orbit
local actual = rot:transform(canonical);
return actual.x, actual.y, actual.z
end
return orbit
end
Fenerit wrote:Hey Cham, FYI I've changed local t = (tjd - 2451545.0) to local t = (tjd - 2451545.0) * 100 for fast real-time smooth flows and I've gained ONE fps.
Cham wrote:Fenerit wrote:Hey Cham, FYI I've changed local t = (tjd - 2451545.0) to local t = (tjd - 2451545.0) * 100 for fast real-time smooth flows and I've gained ONE fps.
This wont be realistic. The particles are really taking about 30 minutes to move on their trajectory, since gravity is weak on Io. The code is using some real data (gravity, ejection velocity, etc). The user just have to accelerate time by a factor of 100 to see the flow.
Code: Select all
emissive 0.55 0.5 1
diffuse 0.55 0.5 1
chris wrote:Cham,
I've done some work with adding native particle system support to Celestia, which might eventually let you create these sorts of effects with tens of thousands of particles. What sort of motion do the particles have? As currently implemented, the motion of a particle in particle system must be expressible as a parametric quadratic curve. Is this adequate for your examples?
--Chris
chris wrote:As currently implemented, the motion of a particle in particle system must be expressible as a parametric quadratic curve. Is this adequate for your examples?
Code: Select all
function parabolic_motion(t)
local orbit = {};
orbit.params = t;
orbit.boundingRadius = 2 * t.InitialRadius
local RandomVelocity = t.MinVelocity + (t.MaxVelocity - t.MinVelocity) * math.random();
local Delta = math.rad(t.MinDeclination + (t.MaxDeclination - t.MinDeclination) * math.random());
local Phi = 2 * math.pi * math.random();
local MaxTime = 2.1 * RandomVelocity * math.sin(Delta)/(86400 * t.Gravity);
local RandomDelay = MaxTime * math.random();
function orbit:position(tjd)
local t = tjd - 2451545.0
local Alpha = math.rad(self.params.Longitude);
local Beta = math.rad(self.params.Latitude);
local CyclicTime = (t - RandomDelay) - MaxTime * math.floor((t - RandomDelay) / MaxTime)
local acct = 3732480 * self.params.Gravity * CyclicTime * CyclicTime;
local v0xt = 86.4 * RandomVelocity * math.cos(Delta) * math.cos(Phi) * CyclicTime;
local v0yt = 86.4 * RandomVelocity * math.cos(Delta) * math.sin(Phi) * CyclicTime;
local v0zt = 86.4 * RandomVelocity * math.sin(Delta) * CyclicTime;
local x = (self.params.InitialRadius + v0zt - acct) * math.cos(Beta) * math.cos(Alpha) - v0xt * math.sin(Beta) * math.cos(Alpha) + v0yt * math.sin(Alpha)
local y = (self.params.InitialRadius + v0zt - acct) * math.cos(Beta) * math.sin(Alpha) - v0xt * math.sin(Beta) * math.sin(Alpha) - v0yt * math.cos(Alpha)
local z = (self.params.InitialRadius + v0zt - acct) * math.sin(Beta) + v0xt * math.cos(Beta)
return x, y, z
end
return orbit
end
Code: Select all
function jet_motion(t)
local orbit = {};
orbit.params = t;
orbit.boundingRadius = 2 * t.InitialRadius
local v0 = 86.4 * (t.MinVelocity + (t.MaxVelocity - t.MinVelocity) * math.random());
local Delta = math.rad(t.MinDeclination + (t.MaxDeclination - t.MinDeclination) * math.random());
local MaxTime = 0.9 * v0 * math.sin(Delta)/(7464960 * t.Deceleration);
local RandomDelay = MaxTime * math.random();
local Phi = 2 * math.pi * math.random();
function orbit:position(tjd)
local t = tjd - 2451545.0
local PeriodicTime = (t - RandomDelay) - MaxTime * math.floor((t - RandomDelay) / MaxTime);
local x = v0 * math.cos(Delta) * math.cos(Phi) * PeriodicTime
local y = v0 * math.cos(Delta) * math.sin(Phi) * PeriodicTime
local z = self.params.Pole * (self.params.InitialRadius + v0 * math.sin(Delta) * PeriodicTime - 3732480 * self.params.Deceleration * PeriodicTime * PeriodicTime)
return x, y, z
end
return orbit
end