Displaying Date/Time info in a VC

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Hi All,
Can anyone help me with the code to display Date/Time (or at least Time) in a virtual cockpit display. It is hopefully quite simple - but can't find any discussion on it.
Regards,
JMW
 

TSPenguin

The Seeker
Joined
Jan 27, 2008
Messages
4,075
Reaction score
4
Points
63
As far as I gathered, you would have to have seperate textures for each number and add some code to replace the texture in question with the appropiate one.
i.e.: change the texture for the last digit every second, the digit before every 10 seconds and so on.

Not simple at all.
I believe there are some very helpful discussions about this in the SSU development thread.
 

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Thank you TSP, I'll go searching.
(PS. I'm learning thro' lurking too !!)
JMW:speakcool:
 

SpaceNut

New member
Joined
Jun 15, 2008
Messages
316
Reaction score
0
Points
0
Location
Lorain
As far as I gathered, you would have to have seperate textures for each number and add some code to replace the texture in question with the appropiate one.
i.e.: change the texture for the last digit every second, the digit before every 10 seconds and so on.

Not simple at all.
I believe there are some very helpful discussions about this in the SSU development thread.

That's pretty much how I've done it in Second Life. I read the time from the system, which returns a string, then parse each character out and display the appropriate texture, and it's done via a timer event (not sure about C and timer events, but I'm guessing they're there.). I set the timer event to 1 second, and it updates the display that often. There are not arrays in Second Life's scripting language, but there's lists, which can be used like an array. You'd setup either a multi-dimensional array, or two arrays, and search the first array for the character, then use the position within the array as a pointer to the second array which would contain the reference to the appropriate texture. I've become a bit of a clock expert (both analog and digital) in Second Life in the last (nearly) two years.. :) Some of my work below:

p1.jpg


A digital clock I made, not using textures, but changing the visibility of primitives. Had to manually work out the logic of how real 7 segment LED's work for this one. Each segment piece has a lookup table of 1's and 0's and makes the prim visible or not depending on the character being displayed.

p2.jpg


Some of my analog clocks...

p3.jpg


A view from my old store layout, notice the similarity (virtually identical) to OrbitClock.

p4.jpg


One of my grandfather clocks.

p5.jpg


Plenty of stuff for Orbiter fans to see. All these rockets are created by an Avatar named 'Jimbo Perhaps'. He's about the premiere rocket builder in SL as you can see here. I made it a point to hunt him down and have become friends with him. As a matter of fact, it was this display I just happened across (that blew my mind!), that turned me on to Jimbo. He now has a couple of sims near NASA's Colab sims.

p6.jpg


Me sitting atop a model of the proposed Mars ARES platform, in the Mars Surface 'holodeck' which simulates (quite well I might add!) being on Mars.

p7.jpg
p8.jpg


Some VERY old pictures of me and my friend Hannah Yakan (Avatar Name) sitting on the Space Shuttle display at the International Spaceflight Museum. Many many many rockets on display from American, Japanese, Russian, European, space programs both old and new. You can also make out part of White Knight which is on display next to the shuttle as well.

If anyone heads into SL to check this stuff out, Search (people tab) for Johan Laurasia and then send me an instant message. Basic memberships in SL are free, and you can do virtually anything a paying member can do. Everything as a matter of fact except own land (but you can rent), and you get better live help if you're a member, other than that, you can do everything a premium member can, buy stuff, own business, etc. If I'm not on, it'll bounce to my email, and if I'm sitting at the computer, I'll log on and would be happy to show some of these sites to anyone interested.
 
Last edited:

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Thanks SpaceNut, but now you're going way over my head !
If I can see some code I could copy/modify it - but from scratch ! I doubt it.
I am willing to work - but anythin' to save time - you know.
Thanks for early replies guys.
JMW
 

SpaceNut

New member
Joined
Jun 15, 2008
Messages
316
Reaction score
0
Points
0
Location
Lorain
Well, my code is written in SL's Linden Scripting Language (LSL). My OrbiterClock isn't written in C, it's basically a cheat I realized I could do with animations using Vinka's spacecraft3.dll, and the animation abilities. All I'm doing is an animation that takes 1 hour (3600 seconds), and 12 hours (43200 seconds) to rotate the hands. It's not coded, it's cheated...lol, head into the forum chat and I maybe I can push you in the right direction though.


-----Posted Added-----


hmm, where did the forum chat go?


-----Posted Added-----


Ok, I'm no C programmer, but I did a bit of research on C# (isn't that's what Orbiter is compiled in? Sorry, not too well versed on the various flavors of C).

Anyways.... to do this, you need to define and start a timer event...

[FONT=Verdana, Arial, Helvetica, sans-serif]timer1.Interval = 100;
timer1.Enabled =
true[/FONT][FONT=Verdana, Arial, Helvetica, sans-serif];
timer1.Tick +=
new[/FONT][FONT=Verdana, Arial, Helvetica, sans-serif] System.EventHandler (OnTimerEvent);[/FONT]


This will create a timer event called OnTimerEvent () with an interval of 1 second and enable (start) the event (I think).

Then...

[FONT=Verdana, Arial, Helvetica, sans-serif]public static void OnTimerEvent(object[/FONT][FONT=Verdana, Arial, Helvetica, sans-serif] source, EventArgs e)
{
[/FONT]
string date = DateTime.Now.Date;
date.time = date.ToString("HH:mm:ss")
// I'm guessing all along here, but to this point, that should read the current time into a string called date.time, from that point, you would need to parse out each character of the string, and display the appropriate texture, or, if possible, just output the text (not sure how that's done in Orbiter VC's and display it. If anyone who's a real C programmer wants to chime in, I could sure use the help, I don't really know C, but I'm searching around the web and trying to figure out how to put together a timer event and read the current time into a string, I think this is about how it would be done.
[FONT=Verdana, Arial, Helvetica, sans-serif]}[/FONT]


-----Posted Added-----


Not simple at all.
I believe there are some very helpful discussions about this in the SSU development thread.

Not really too difficult TS, I just took a stab at part of it above, but I'm not really a C programmer...lol, maybe a bit of 'pseudo code' would help make it clearer...

I'm not sure how C works, but there must be some default state that is entered when a program runs, and a state entry event of some type must be raised...

State Entry....
setup and start timer event

Timer Event...
Read system time into a string
For loop start {
Parse character from string
perform texture look up
display texture in appropriate position
For loop end }
Timer Event end


The For loop will iterate 8 times for each character 'HH:mm:ss', at which point the event will end. After another second has passed, the timer event will again be raised, and it will happen all over again.

Hope this helps, programmers, please chime in and let me know how I did with my C code.
 

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Hi Spacenut -I'm back !
Sorry for not being around to respond to your answer, but I can only sneak a few minutes at a time on the net ( in competition with a job/two daughters/wife (only ONE wife!))

I think Orbiter is in C++ (that's what I'm using anyhow) in which I'm very limited.
This is what I want to do - post a digital readout of time + maybe date in a VC screen at specific locations. I thought I could grab the "Info" data at top right of any Orbiter screen - but not so easy eh.?
You're right - I'm gonna need a lot of guiding on this, so if you can put up with my " now-you-see-me now-you-don't" life-style I'd appreciate any help.
If this approach isn't suitable for a Forum, maybe you could send me a Private message sometime.
Thanks,
JMW
 

SpaceNut

New member
Joined
Jun 15, 2008
Messages
316
Reaction score
0
Points
0
Location
Lorain
Nah, the open forum is fine, that way any others interested could benefit from the posts, and programmers who actually know C++ can chime in (and are heavily encouraged to do so!!!) since I don't really know C++. As far as your responses go, when you get them, you get them and same for me.

For starters, you're going to need to read up on how both 2D and 3D instrument panels are defined and implemented in your spacecraft class. Consult the file API_Guide.pdf in the Orbiter SDK (starting on page 20), and read up on how to initialize a panel. I'd recommend trying to do this on a 2D panel first, then, once working, move to a VC. I skimmed over it, and you will be able to update the display via a timer event, but don't get ahead of yourself just yet. Start by getting a 2D panel up and running, and working, and then we'll move forward from there to implement the timer event, reading the time, selecting the appropriate digit textures and displaying them.
 

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Thanks SpaceNut,
I will do some reading and work and get back to you. (Don't hold yer breath though!)
JMW
 

tblaxland

O-F Administrator
Administrator
Addon Developer
Webmaster
Joined
Jan 1, 2008
Messages
7,320
Reaction score
25
Points
113
Location
Sydney, Australia
I thought I could grab the "Info" data at top right of any Orbiter screen - but not so easy eh.?
Getting the time is not hard. Your clock should be located in your vessel module and you can place the code for updating the clock in clbkPreStep. Orbiter passes the date/time as to clbkPreStep using the mjd argument (see the document API_Reference.pdf for more info).

You can convert the mjd into hours/min/sec. For an example of how to do this have a look at the Scenario Editor code that is included with the SDK (Orbiter\OrbiterSDK\samples\ScnEditor). Look for "struct tm" in Convert.cpp.

As far as displaying the time, you have two options - dynamic textures or animations. Animations are what SpaceNut has used that would be OK for an analogue clock. For a digital clock, dynamic textures would be best. I have not used dynamic textures before myself some I may not be a lot of help. I recommend reading section 1.12 in the API_Guide and 19.15 in the API_Reference. These contain info on both dynamic textures and setting up a VC. Also, looking at the DeltaGlider code (also in the samples folder) would be useful.

I can't find the posts in the SSU thread relating to the clock textures at the moment. IIRC, Donamy did the texture for them. Note that all the digits were on a single texture and the display of them was controlled by adjusting the coordinates that the texture was mapped onto the mesh. Having a separate texture for each digit would be less efficient.
 

SpaceNut

New member
Joined
Jun 15, 2008
Messages
316
Reaction score
0
Points
0
Location
Lorain
Thanks for the input TB, much appreciated. I'm not a C programmer, plus, I'm not up on implementing code in Orbiter. The plan is to use texture(s) to display the time digitally. This isn't my project, I'm just trying to help out JMW. I have had quite a bit of experience making clocks in Second Life though, so I was helping JMW along with the logic behind it since I'm so well versed in clock scripting in Second Life.
 

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Thanks Guys,
I'm in the deep end - but willing to swim!
I'm getting there with the VC.
Time zones and unforseen occurences permitting - I'll get back to you !!
Keep breathing.
JMW
 
Top