Geographic Sun addon!

but how do you interpret your script from that point of view?
function of GMT and location

does it gives the 2 angles azimuth and altitude for the sun ?
and i assume here that the origin is at 000
can you print on panel or may be on console these values to show what they are

so the sun lamp would be added with these 2 angles in mind
above the XY plane

one suggeston here
can you in panel write time 24 H to show that it is on 24 hour clock

i’ll see how to find local time versus GMT
must be a simple way for converting this too!

GMT would be just adding subtracting your timezone from the date.

Here is a little file with drivers on the suns intensity and defaulting to 300 seconds per frame… To set it up “properly” would need to add a variable of some sort to save the start time, or change the sunpos to use a datetime var instead of the pointer… anyway it’s been more of a little test to see if i could get it driving.

Crunch in your starting data on frame 1 … hit “set sun angle” then hit play to see how the sun spins as the time goes up. The timing can be changed by adding a seconds per frame var to the second var of the driver

sundriver(f,3600)

would make each frame one hour for instance.

@RickyBlender… You’re closing in on that magical 10K posts.

not looking foward
but anyway do i win a prize here?

does not mean anything to me
it’s more important to help learn and fun too
then thinking about it!LOL

no time to think about it to many new things to learn in 2.5
which is becoming something totaly much better then old 2.49

i like more then ever it’s beginning to be something you can have fun to learn things in 3D
and also use in practice by more and more people on planet Earth

what do you think!

script is interesting i’ll test some more your little script

this is fun to see it move around

but where did you add the driver in script
don’t see it in any of the panel object
and not shown on world panel!
so i need to save this script under a new name i guess

i tought all scenes var where shown in worl panel!

Found myself tweaking the timing and watching the sun spin round and round too. you can even scrub on the settings to move it around, although be wary if you hit a wrong day eg 30th Feb it’ll kill the driver.

The driver is on the energy of the sun lamp object data panel. A custom function “sundriver” is defined for it and added to the drivers namespace. It’s only a test case so the driver looks for an object named “Lamp” to manipulate… once i get things working too lazy to fix them up properly later… Oh yeah and i jammed a keyframe into the sun data’s negative prop to get the driver kicking over.

A quick fix would be to create a string property and button to set it as the start date and then use start_date + (frame-1)*secsperframe to set an absolute starting point.

OH AND CONGRATS ON THE 10K hehe

Totally agree on 2.5+ kicks but over 2.49… to the point of if i see a post on here asking a q re 2.49 i avoid it like the plague.

[ATTACH=CONFIG]135529[/ATTACH]

yes already at 2 over the 10k WOW

2.49 what the hec is that ?

i still have to learn more about driver it’s new toy for 2.5 but with time i will learn this too

i did a small file to show angles here
what do you think

hope this is what you had in mind

Nice, how about including the zenith angle. Zenith is the direction directly above the observer.

So if you were the observer, with a compass you could face due north. Now turn clockwise to face the sun. How far you turn is your azimuth. Point straight up then to the sun… that will give you the zenith angle…

Would make a nice little animation have a character face north turn point look at watch and say i must be at latitude / longitude.

On another note would you or anyone happen to have a model of stonehenge?

well some call it zenith but if you look in given reference it’s called latitude

and i do have a big model for Stohenge
but don’t know the source anymore - lost it
so may have to modfiy it before using it
if you want it let me know i’ll upload it

i’m trying to use your sun example to make a new one for the moon
so i began renaming var to moon but get an error
on moonlamp and don’t understand why !

bpy.utils.register_class(moonPosTime)
bpy.utils.register_class(MoonPosLocation) 
bpy.utils.register_class(OBJECT_PT_moonpos)
bpy.utils.register_class(OBJECT_OT_moonpos)

bpy.types.<b>moonLamp</b>.moonpos_time = PointerProperty(type=moonPosTime,                                                    
                                                description="Moon Position Time Settings",options={'ANIMATABLE'})
bpy.types.moonLamp.moonpos_location = PointerProperty(type=MoonPosLocation,                                                        
                                                    description="Moon Position Location Settings",options={'ANIMATABLE'})

don’t know can you point out what the mistake is here

i’m using a basic program to port to python and make this new algo for moon
don’t know what i can use from your sun script
but i’ll continue and see what can be done!

like this function
any idea if there is a python function eqquivalent

’ the function below returns the true integer part,
’ even for negative numbers

DEF FNrange (x) = x - INT(x / twopi) * twopi

valid for positive or negative number !

thanks

Hi,

bpy.types.SunLamp is a blender type for a lamp object with data type sun to which the custom properties are attached. For the moon it might pay to stick them on a reflector or emitter object. On that note the position is only a “fudge”. The pointer vector points to its direction from 0,0,0 so its actual position would be a long way off, and would stretch blender a bit putting it in its real loc if you wanted to render it. However it would be an interesting exersize in maths to get its actual location and project it back to where it would appear re your cameras POV.

And the method looks like it is for returning an angle in the range of [0,2Pi] or in degrees 0 to 360

ok so how can you re write this with another object like don’t know may be a circle object in the sky for the moon ?

i’m just beginning to work with these prop group

what is the advantage of using these group instead of independant properties?
i have to check the program i got
seems to be a problem with errors on RA and Dec

it looks like i neeed to spec double precision numbers
have to check how to see errors!

what words you use to find these double precision number at python site ?
of if you have the page let me know

i found this decimal module where you can define almost any number of digits for precision WOW

http://docs.python.org/library/decimal.html#decimal.Context.number_class

unless there is another module to define doubles?
might be enough here

To use an object for instance you would assign the group property to bpy.types.Object…

Uncle Entity wrote the original script. I prob would have set it up with individual props too… but his way is far more elegant don’t you think?

agreed it’s very elegant but still not certain if needed !
but anyway i’m trying to follow it and learn from this
wish there was better documentation pages showing more about these features!

i tried to replace the original one
bpy.types.SunLamp.sunpos_time = PointerProperty(type=SunPosTime,
description=“Sun Position Time Settings”,options={‘ANIMATABLE’})

with this

bpy.types.moonLamp.moonpos_time = PointerProperty(type=moonPosTime,

description=“Moon Position Time Settings”,options={‘ANIMATABLE’})

but it did not like it at all!

are you saying that the sunlamp word is a real lamp in script or just a given name
cause that don’t seems to work by changing only the prop name

so wondering how to change prop name to reflect that it is for the moon not the sun
would be less confusing!
i can upload the new script i’m trying to change if neede but not complete yet

for new script i think i need to use double precision for numbers like float and int
is there a simple way to spec double precision for float or other like int
cannot find the python page doc for these double

Camara thanks for this script!

I know this is old thread, but I think this script still could be useful. Unfortunately, it does not work for me. No errors, but sun lamp does not change when I set time or date, even if I press “Set SUN position” button. Anybody still using this addon? If yes, any idea what could be wrong?

This script works fine in 2.70a.

I found how to fix my problem. I deleted sun in my start up scene and then recreated it, and now it works. Not sure what was wrong, but perhaps my experience will save some time to somebody.