Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Announcements and Showcase
Realtime Skybox Animation technique and weather tecnique...

just_in_case
Moderator
Quote
2016-03-15 04:05:56

Hey guys am providing an example file which will Show/Guide you How to create a realtime skybox animation!

our objective is to animate texture of skybox respective to time in our pc. instead of changing a texture i have used make visible or invisible action for behaviour if a variable has value do something

Download the file and test it.

It contains 3 different skyboxes blue skybox,sunset and midnight skybox.

blue skybox is the default skybox.

To test the app.
First set You pc's time to 1AM now test app.
Set time to 5PM Now test app.
Set time to 6AM test the app.(nothing will change unless its 5PM or 1AM in your pc's clock, because it is the default scene)

you will find that how the skyboxes animate according to pc's time.

there are also some 2d overlays which will draw realtime CLOCK,DATE,MONTH,YEAR

Here is the Code Also:
//implemented by Just_in_case.

var date = new Date();
var seconds = date.getSeconds();
var minute = date.getMinutes();
var hour = (date.getHours()+ 24) % 12 || 12;
var day = date.getDate();
var month = date.getMonth();
var year = date.getFullYear();

//Draw Time

var s = ccbGetSceneNodeFromName("Time"); //change 'Time' with your 2d overlay name
var text = ccbGetSceneNodeProperty(s, "Text");
ccbSetSceneNodeProperty(s, "Text",'Time:- '+date.getHours() +':'+date.getMinutes()+':'+date.getSeconds());

//Draw Date

var s = ccbGetSceneNodeFromName("date"); //change 'date' with your 2d overlay name
var text = ccbGetSceneNodeProperty(s, "Text");
ccbSetSceneNodeProperty(s, "Text",'Date:- '+date.getDate());

//Draw Month

var s = ccbGetSceneNodeFromName("month"); //change 'month' with your 2d overlay name
var text = ccbGetSceneNodeProperty(s, "Text");
ccbSetSceneNodeProperty(s, "Text",'Month:- '+date.getMonth());

//Draw Year

var s = ccbGetSceneNodeFromName("year"); //change 'year' with your 2d overlay name
var text = ccbGetSceneNodeProperty(s, "Text");
ccbSetSceneNodeProperty(s, "Text",'Year:- '+date.getFullYear());

//storing Variables

ccbSetCopperCubeVariable("seconds",date.getSeconds() );
ccbSetCopperCubeVariable("minutes",date.getMinutes() );
ccbSetCopperCubeVariable("hours",date.getHours() );
ccbSetCopperCubeVariable("month",date.getMonth() );
ccbSetCopperCubeVariable("year",date.getFullYear() );
ccbSetCopperCubeVariable("date",date.getDate() );



For Non-programmers Just add a new behaviour to your root scene node every few seconds do something and then add a new action Execute javascript and copy paste the above code there.
Use variables seconds,minutes,hours,year,date for your scene.

for better understanding download the Example file:

Download Link:- https://drive.google.com/open?id...

Hope the example will help you.

You can also animate weather according to month. and can create festivals in your game according to date.
for example if it will 25th of December in real world then it will be Christmas in your game too.

Thanks!
Justin Case


techno-valley
Registered User
Quote
2016-03-15 08:44:45

nice

could be a live screen saver too if converted


just_in_case
Moderator
Quote
2016-03-15 09:12:42

Yeah but that may drain battery faster... anyway who cares about the draining of battery while personalizing themes and wallpapers...


blackwater
Registered User
Quote
2017-02-03 09:46:22

This sounds super! Can the script be somewhat easily changed so that 24 hours translates to one hour (a whole day to pass in one hour)?

I am no coder, so who ever that feels for it, is free to come up with a full scripted solution :-)


rolevix
Registered User
Quote
2017-02-03 20:41:21

I can't download it... even i used proxy, can you upload it on other site or something?


just_in_case
Moderator
Quote
2017-02-05 07:26:07

@blackwater yes you can use it for "1 hour" to animate the skybox...

just change the variable hour to minutes used in the provided ccb file..

for example if you want the skybox to animate after 15 minutes.

Assume 15 minutes will be equal to 5:00 clock.

so in the provided ccb file click on the day night 2d overlay , goto behaviours.

click on the shown behaviour , and choose first action.

change variable name from "hours" to "minutes"

and set value to 15.

now time to test your app..

adjust the time of your pc to anytime which have 15 minutes in its last..

for example 12:15 , 1:15, 2:15 , 3:15 and so eveytime the minutes turns to be fifteen the skybox will change and animate to the provided skybox.


you can do the same thing for other 2 actions or can add as a many actions as you want just change the hour variable to minutes and value to you desired value.

hope you understand..



@Rolevix sorry that site has been shutted down... here is the updated link to the ccb file...

https://drive.google.com/open?id...


blackwater
Registered User
Quote
2017-02-05 21:08:23

@just_in_case: Speaking of time: Thanks a thousand for the detailed explanation!
(Got it working, so it will probably make some good use in my project/s)!


aloan
Registered User
Quote
2019-09-11 16:42:27

This is awesome!
I can't code, and was looking for this on the net!
Ihave the other day/night cycle but it does not show the time :(
Just what I needed for my little town simulation!
thanks a million!
btw, here is a thank you, download my town ccb file too!
https://steamcommunity.com/app/8...


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internationa?" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact