Rastar Posted October 22, 2013 Share Posted October 22, 2013 Noob alert... I still haven't grasped how to work with the render loop. As an example, I have integrated shadmar's skybox from http://www.leadwerks.com/werkspace/topic/7452-skybox-in-30-a-simple-example-with-shader/ into my C++ code. I put all that code in App::Start(), and everything works. Fine. Now, I would like to move the skybox with the camera. But when I move the lines sky->SetPosition(camera->GetPosition()); sky->Move(0,0,camera->GetRange().y-50); sky->SetScale(camera->GetRange().y*10); into the App::Update() method, the skybox isn't displayed, no matter if it's before or after world->Update() and world->Render(). Why is that? Is it because the buffer is cleared before the render loop? Why doesn't that affect stuff done in Start()? Do I have to use the DrawHook() to get the skybox into the render loop? If so, how can I affect the drawing order (or shouldn't I)? Sigh.. Quote Link to comment Share on other sites More sharing options...
shadmar Posted October 22, 2013 Share Posted October 22, 2013 you probably forgot sky->SetParent(camera); wich makes the skybox always follow camera pos and orientation. everything is suppose to go in app:start() since you parent the plane to the camera Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Rastar Posted October 22, 2013 Author Share Posted October 22, 2013 I set in the parent in the App:Start() method. But since I want to move I have have to adjust the skybox position every frame, so I movev those three calls to Update(). Quote Link to comment Share on other sites More sharing options...
shadmar Posted October 22, 2013 Share Posted October 22, 2013 No you don't. Parenting means that leadwerks handles this behind the scenes. so you can move camera all you want and plane will follow. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Admin Posted October 22, 2013 Share Posted October 22, 2013 sky->SetScale(camera->GetRange().y*10); Wouldn't this cause the skybox to be so huge it is too far away for the camera to see? Quote Link to comment Share on other sites More sharing options...
shadmar Posted October 22, 2013 Share Posted October 22, 2013 It's just a plane scaled in xy. Not an actual box. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Rastar Posted October 22, 2013 Author Share Posted October 22, 2013 In shadmar's code the skybox is created with coordinates (-0.5, 0.5, 0) etc., the camera has range 1000 so the box should be half of the camera range. I forgot about the parenting, so i don't actually have to do that. And my code means the skybox is scaled again every frame - no wonder i can't see it... Quote Link to comment Share on other sites More sharing options...
Admin Posted October 22, 2013 Share Posted October 22, 2013 That scaling won't be additive, FYI. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.