Page 1 of 1
General texture question
Posted: 24.05.2008, 11:19
by zhar2
So ive got a planet that varies ccording to season, and i need it to switch (fade) between two textures, ive tried alternate texturesbut youd have to manually switch them plus i need to time them to switch properly and then to repeat again endlessly in a season cycle.
I know gif animations are not supported so i cant use them.
Re: General texture question
Posted: 24.05.2008, 12:07
by selden
Celestia has three different methods of animating the seasons.
1. With Celestia v1.3.0 or later, you can use Beginning and Ending directives to cause Celestia to draw an SSC object only between specific dates.
So, you can write a very long SSC file with a separate object definition for each season for a number of years.
2. With Celestia v1.5.0 or later, you can use a ScriptedOrbit to place different objects at the planet's position at different times.
So, you can define a different SSC object for each season. Each object's associated ScriptedOrbit determines that object's visiblity at appropriate times.
3. With Celestia built from svn code (i.e. using Celestia v1.6 when it's eventually released) you can use the Visible SSC directive and a CelX script to specify the visiblilty of objects.
So, you can define a different SSC object for each season. The CelX script changes each object's visiblity at appropriate times.
Re: General texture question
Posted: 24.05.2008, 12:35
by zhar2
Umm seems rather tricky but ill do so, i think my best bet is to go with #2, right now im reading something on those orbits on wikibooks so i guess its a matter of trial & error.
Re: General texture question
Posted: 24.05.2008, 19:14
by zhar2
Right, ive been going about this for a few hours without luck, could i have more information or a code example on how it should be done?
Thank you in advance
Re: General texture question
Posted: 24.05.2008, 21:12
by selden
Here's an example.
It could be done many other ways.
The file seasons.ssc contains the definitions for the seasonal bodies.
The file seasons.lua contains the ScriptedOrbit functions which place the seasonal bodies at the Earth's position.
seasons.lua must go in a folder named celxx within the folder which contains seasons.ssc.
seasons.ssc:
Code: Select all
# An example of one way to display seasonal changes
# released to the public domain by its author, S.Ball, May, 2008
# The module seasons.lua is in the subdirectory celxx
# don't draw the original Earth object
Modify "Earth" "Sol" { Class "invisible"}
# Here are four very simple seasonal bodies.
# They are placed relative to the position of the Earth.
# These definitions should be expanded to include
# Texture, Atmosphere, UniformRotation, etc.
"Winter" "Sol/Earth"
{
Radius 6378.14
Color [ 1 1 1 ]
OrbitFrame { BodyFixed { Center "Sol/Earth"}}
ScriptedOrbit { Module "seasons" Function "Winter" }
BodyFrame { BodyFixed { Center "Sol/Earth"}}
FixedRotation {}
}
"Spring" "Sol/Earth"
{
Radius 6378.14
Color [ 0.4 0.75 0 ]
OrbitFrame { BodyFixed { Center "Sol/Earth"}}
ScriptedOrbit { Module "seasons" Function "Spring" }
BodyFrame { BodyFixed { Center "Sol/Earth"}}
FixedRotation {}
}
"Summer" "Sol/Earth"
{
Radius 6378.14
Color [ 0 1 0 ]
OrbitFrame { BodyFixed { Center "Sol/Earth"}}
ScriptedOrbit { Module "seasons" Function "Summer" }
BodyFrame { BodyFixed { Center "Sol/Earth"}}
FixedRotation {}
}
"Fall" "Sol/Earth"
{
Radius 6378.14
Color [ 0.75 0.4 0 ]
OrbitFrame { BodyFixed { Center "Sol/Earth"}}
ScriptedOrbit { Module "seasons" Function "Fall" }
BodyFrame { BodyFixed { Center "Sol/Earth"}}
FixedRotation {}
}
/celxx/seasons.lua
Code: Select all
-- An example of one way to display seasonal changes
-- released to the public domain by its author, S.Ball, May, 2008
-- lua module to exchange seasonal objects
-- table of dates of seasons
-- these values are wrong, used just as examples
-- functions calculating the actual equinox and solstice times would be better
-- T0 should be set to the beginning of some earlier year.
-- These dates correspond approximately
-- to the seasons in the Earth's northern hemisphere.
-- My apologies to those who live south of the equator.
Seasons = {
T0 = 2451544.5, -- define 1st day of 1st year (1 Jan 2000)
}
Seasons.Winter = -10
Seasons.Spring = Seasons.Winter+ 91.3
Seasons.Summer = Seasons.Winter+182.6
Seasons.Fall = Seasons.Winter+273.9
Seasons.Winter2 = Seasons.Winter+365.25
-- ----------------------------
-- I like to do the positional calculations
-- separately from the ScriptedFunction definitions
-- These functions calculate each season object's placement
-- each returns a value which will be used as the X position of the object
-- During the desired season,
-- 0 = draw the object at xyz = 0,0,0
-- i.e. centered at the position of the coordinate system
-- Outside the desired season,
-- 1e18 = draw the object far, far away, at xyz= [1e18,0,0]
-- i.e. at a position 1,000,000,000,000,000,000 km
-- away from [0,0,0]
ShowWinter = function (date)
local day_of_year = math.mod(date - Seasons.T0,365.25)
if (
(day_of_year < Seasons.Spring) or (day_of_year >= Seasons.Winter2)
)
then return 0
else return 1e18
end
end
ShowSpring = function (date)
local day_of_year = math.mod(date - Seasons.T0,365.25)
if ( (day_of_year >= Seasons.Spring) and (day_of_year < Seasons.Summer ))
then return 0
else return 1e18
end
end
ShowSummer = function (date)
local day_of_year = math.mod(date - Seasons.T0,365.25)
if ( (day_of_year >= Seasons.Summer) and (day_of_year < Seasons.Fall ))
then return 0
else return 1e18
end
end
ShowFall = function (date)
local day_of_year = math.mod(date - Seasons.T0,365.25)
if ( (day_of_year >= Seasons.Fall) and (day_of_year < Seasons.Winter2 ))
then return 0
else return 1e18
end
end
-- --------------------------------------------
-- ScriptedOrbits: one for each seasonal object
-- --------------------------------------------
Winter = function (sscvals)
local orbit = {}
orbit.params = sscvals
orbit.boundingRadius = 4000
function orbit:position (tjd)
return ShowWinter(tjd), 0, 0
end
return orbit
end
Spring = function (sscvals)
local orbit = {}
orbit.params = sscvals
orbit.boundingRadius = 4000
function orbit:position (tjd)
return ShowSpring(tjd), 0, 0
end
return orbit
end
Summer = function (sscvals)
local orbit = {}
orbit.params = sscvals
orbit.boundingRadius = 4000
function orbit:position (tjd)
return ShowSummer(tjd), 0, 0
end
return orbit
end
Fall = function (sscvals)
local orbit = {}
orbit.params = sscvals
orbit.boundingRadius = 4000
function orbit:position (tjd)
return ShowFall(tjd), 0, 0
end
return orbit
end
Re: General texture question
Posted: 24.05.2008, 21:17
by ajtribick
There was an effort to do this in a far less messy way by extending the definition of the Texture property rather than switching objects on and off, but it seems to have stopped. See
this thread.
Re: General texture question
Posted: 24.05.2008, 21:24
by zhar2
But how are the specific textures specified for each season, shall i just try to declaredthem above radius?
Re: General texture question
Posted: 24.05.2008, 21:28
by ajtribick
zhar2 wrote:But how are the specific textures specified for each season, shall i just try to declaredthem above radius?
Yes, you define the textures on the "Spring" "Summer" "Fall" and "Winter" objects.
Re: General texture question
Posted: 24.05.2008, 21:38
by zhar2
Oh and as the year is longer in days i see i will need to make a new lua file secially for it, i seem to understand according to the numbers where the year lenght and season length must be changed.
So just a text document saved as celx as is done withthe ssc files?
Well, ive created the lua file such way, created a celxx file inside the addonds folder where i placed the the lua file, added the ssc bit to the main addon file, right?
heres how i modified the lua code.
Code: Select all
andorian-seasons = {
T0 = 2451544.5, -- define 1st day of 1st year (1 Jan 2000)
}
Seasons.Winter = -10
Seasons.Spring = Seasons.Winter+236.37
Seasons.Summer = Seasons.Winter+470.74
Seasons.Fall = Seasons.Winter+706.11
Seasons.Winter2 = Seasons.Winter+941.48
ShowWinter = function (date)
local day_of_year = math.mod(date - Seasons.T0,941.48)
if (
(day_of_year < Seasons.Spring) or (day_of_year >= Seasons.Winter2)
)
then return 0
else return 1e18
end
end
ShowSpring = function (date)
local day_of_year = math.mod(date - Seasons.T0,941.48)
if ( (day_of_year >= Seasons.Spring) and (day_of_year < Seasons.Summer ))
then return 0
else return 1e18
end
end
ShowSummer = function (date)
local day_of_year = math.mod(date - Seasons.T0,941.48)
if ( (day_of_year >= Seasons.Summer) and (day_of_year < Seasons.Fall ))
then return 0
else return 1e18
end
end
ShowFall = function (date)
local day_of_year = math.mod(date - Seasons.T0,941.48)
if ( (day_of_year >= Seasons.Fall) and (day_of_year < Seasons.Winter2 ))
then return 0
else return 1e18
end
end
Winter = function (sscvals)
local orbit = {}
orbit.params = sscvals
orbit.boundingRadius = 4000
function orbit:position (tjd)
return ShowWinter(tjd), 0, 0
end
return orbit
end
Spring = function (sscvals)
local orbit = {}
orbit.params = sscvals
orbit.boundingRadius = 4000
function orbit:position (tjd)
return ShowSpring(tjd), 0, 0
end
return orbit
end
Summer = function (sscvals)
local orbit = {}
orbit.params = sscvals
orbit.boundingRadius = 4000
function orbit:position (tjd)
return ShowSummer(tjd), 0, 0
end
return orbit
end
Fall = function (sscvals)
local orbit = {}
orbit.params = sscvals
orbit.boundingRadius = 4000
function orbit:position (tjd)
return ShowFall(tjd), 0, 0
end
return orbit
end
Re: General texture question
Posted: 24.05.2008, 22:12
by zhar2
Oh and i forgot, thank you all for your great help.
Re: General texture question
Posted: 25.05.2008, 10:45
by selden
Your changes look reasonable to me.
A more generic set of routines could replace the various numeric constants by variables and/or calculations, perhaps, with values provided by way of arguments in the SSC code.
Re: General texture question
Posted: 25.05.2008, 11:32
by zhar2
t still isnt working, i think i may have named the ssc file wrong and the first ssc file isnt accessing it or something, our the lua file was saved as .lua but it may need a different extention inside the celxx file.
Re: General texture question
Posted: 25.05.2008, 12:08
by selden
Did the initial example work for you before you started changing things?
It's best to make one change at a time. That way you know what change broke it.
Some Lua errors are reported in Celestia's "console log".
Type the single character <tilde> (~) to turn the log on and off again.
You may need to type
<tilde><space>
on some keyboards.
Type the up-arrow and down-arrow keys to move up and down in the log.
Re: General texture question
Posted: 25.05.2008, 14:02
by zhar2
Well here its my ssc file for the modifications:
Code: Select all
Modify "Andoria" "Andor" "Pi3 ori" { Class "invisible"}
"Winter" "Pi3 ori/Andor/Andoria"
{
Texture "andoria-winter.*"
BumpMap "andoria-bump.*"
BumpHeight 3.2
NightTexture "andoria-night.png"
Radius 6451.06
Radius 6450.06
Color [ 1 1 1 ]
OrbitFrame { BodyFixed { Center "Pi3 ori/Andor/Andoria"}}
ScriptedOrbit { Module "andorian-seasons" Function "Winter" }
BodyFrame { BodyFixed { Center "Pi3 ori/Andor/Andoria"}}
FixedRotation {}
}
"Spring" "Pi3 ori/Andor/Andoria"
{
Texture "andoria-spring.*"
BumpMap "andoria-bump.*"
BumpHeight 3.2
NightTexture "andoria-night.png"
Radius 6451.06
Color [ 0.4 0.75 0 ]
OrbitFrame { BodyFixed { Center "Pi3 ori/Andor/Andoria"}}
ScriptedOrbit { Module "andorian-seasons" Function "Spring" }
BodyFrame { BodyFixed { Center "Pi3 ori/Andor/Andoria"}}}}
FixedRotation {}
}
"Summer" "Pi3 ori/Andor/Andoria"
{
Texture "andoria-summer.*"
BumpMap "andoria-bump.*"
BumpHeight 3.2
NightTexture "andoria-night.png"
Radius 6451.06
Color [ 0 1 0 ]
OrbitFrame { BodyFixed { Center "Pi3 ori/Andor/Andoria"}}
ScriptedOrbit { Module "andorian-seasons" Function "Summer" }
BodyFrame { BodyFixed { Center "Pi3 ori/Andor/Andoria"}}}}
FixedRotation {}
}
"Fall" "Pi3 ori/Andor/Andoria"
{
Texture "andoria-fall.*"
BumpMap "andoria-bump.*"
BumpHeight 3.2
NightTexture "andoria-night.png"
Radius 6450.06
Color [ 0.75 0.4 0 ]
OrbitFrame { BodyFixed { Center "Pi3 ori/Andor/Andoria"}}
ScriptedOrbit { Module "andorian-seasons" Function "Fall" }
BodyFrame { BodyFixed { Center "Pi3 ori/Andor/Andoria"}}}}
FixedRotation {}
}
And the folder order is:
Pi3 ori
--textures
--models
--celxx---andorian-seasons.lua
andorian seasons.ssc
pi3 ori.ssc
Re: General texture question
Posted: 26.05.2008, 14:19
by selden
The Modify statement is incorrect.
Modify "Andoria" "Andor" "Pi3 ori" { Class "invisible"}
should be
Modify "Andoria" "Pi3 ori/Andor" { Class "invisible"}
Re: General texture question
Posted: 26.05.2008, 14:44
by zhar2
Ive changed it, ive tried that before too but nothing yet.
could there be something wrong here, maybe the changes hane to be declared here too?
Code: Select all
"Andoria" "Pi3 ori/Andor"
{
Texture "andoria.*"
BumpMap "andoria-bump.*"
BumpHeight 3.2
NightTexture "andoria-night.png"
Radius 6450.06
Atmosphere {
Height 60
Lower [ 0.43 0.52 0.65 ]
Upper [ 0.26 0.47 0.84 ]
Sky [ 0.40 0.6 1.0 ]
Sunset [ 1.0 0.6 0.2 ]
CloudHeight 7
CloudSpeed 65
CloudMap "andoria-clouds.png"
Mie 0.001
MieAsymmetry -0.25
Rayleigh [ 0.001 0.0025 0.006 ]
MieScaleHeight 12
}
EllipticalOrbit
{
Period 1.769138
SemiMajorAxis 1675497
Eccentricity 0.01
Inclination 0.040
}
UniformRotation
{
Inclination 0.0
MeridianAngle 0.0
}
RotationPeriod 30.0
Albedo 0.301
}
Re: General texture question
Posted: 26.05.2008, 14:59
by selden
You shouldn't mix the two kinds of rotation specifications, although that shouldn't cause it to fail.
Code: Select all
UniformRotation
{
Inclination 0.0
MeridianAngle 0.0
}
RotationPeriod 30.0
should be
Code: Select all
UniformRotation
{
Inclination 0.0
MeridianAngle 0.0
Period 30.0
}
Also, if you're going to have seasons, then either the MOON [ed] has to be inclined (e.g. Inclination 25), so northern and southern hemispheres have opposing seasons, or the PLANET'S [ed] orbit has to have a higher eccentricity, causing the same seasons to happen at the same time in both hemispheres, with a much longer winter than summer.
I don't see anything obviously wrong enough to cause a failure.
You'll have to provide what you have in the form of a complete Addon in a Zip file so that someone can determine the cause of the failure. I suspect there's something you've overlooked and thus haven't described.
Re: General texture question
Posted: 26.05.2008, 15:07
by zhar2
Yes i suspect its something ive not noticed, to reduce the file size i could substitute the teaxtures for small one colour textures to make the code the subject.
I dont know who could take look at it but if someone will i would be thankfull
.