Jump to content

Day-Night Cycle


Shard
 Share

Recommended Posts

Hey everyone. So I've written a(n okay) day-night cycle but I'm having a little trouble placing the corona for the sun to make it look realistic and I was wondering if someone code help my code out a little bit.

 

The problem I'm having right now is making the corona show up and making it rotate along with the light.

 

void World::CreateCycle(int time = 0)
{

time = (15*time) - 90;

this->cycle = true;



//Sunlight
this->sunLight = CreateDirectionalLight();
PositionEntity(this->sunLight, Vec3(0,0,0));
RotateEntity(this->sunLight,Vec3(time,0,0));

sun = CreateCorona();
PaintEntity(sun, LoadMaterial("abstract::flare1.mat"));
SetCoronaRadius(sun,10,30);
PositionEntity(sun,Vec3(0,500,0));

////Moonlight
//this->moonLight = CreateDirectionalLight();
//PositionEntity(this->moonLight, Vec3(0,0,0));
//RotateEntity(this->moonLight,Vec3(time + 180,0,0));
//EntityColor(this->moonLight,Vec4(0));

}

void World::UpdateCycle()
{

TurnEntity(this->sunLight,Vec3(.5,0,0),1);

TVec3 sunPos = EntityPosition(sun);

sunPos.X = 500*cos(.5);
sunPos.Y = 500*sin(.5);

PositionEntity(sun,sunPos);

}

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Link to comment
Share on other sites

Try making your directional light the parent to your corona. It should just follow it then.

 

 

Well if you notice the directional light has been placed at 0,0,0 and is rotated at that spot. But the corona has to be up in the sky.

 

I did try it in code but it didn't result with any changes.

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...