About Store Forum Documentation Contact



Post Reply 
Game::World.update and ocean
Author Message
uNetti Offline
Member

Post: #1
Game::World.update and ocean
Soo, I was playing around with Game::World.update(0,0,0); and I noticed it changes the level of the ocean, if you have previously set ocean with:
Water.plane.set(Vec(0,-300,0),Vec(0,1,0));

Then calling Game::World.update() would reset the position to Water.plane.set(Vec(0,0,0),Vec(0,1,0));?

Maybe if someone can explain why?
03-29-2013 09:59 PM
Visit this user's website Find all posts by this user Quote this message in a reply
gwald Offline
Member

Post: #2
RE: Game::World.update and ocean
In the water.h file:

struct WaterClass : WaterMtrl // Main water control
has this for:
Plane plane ; // water plane , , default=(pos(0,0,0), normal(0,1,0))


in v1 tut 22 water.cpp


Code:
/******************************************************************************/
#include "stdafx.h"
/******************************************************************************/
Mesh terrain;
/******************************************************************************/
void InitPre()
{
   App.name("Water");
   App.flag=APP_FULL_TOGGLE|APP_MS_EXCLUSIVE;
   DataPath("../data");
   Paks.add("engine.pak");

   D.full(true).ambientPower(0.4).hpRt(true);

   Cam.at.set(0,2,0);
   Cam.pitch=-0.5f;
   Cam.dist =30;
   Cam.yaw  =2.8f;
}
Bool Init()
{
   terrain.load("obj/terrain/0.mesh");                                      // terrain
   terrain.scale(Vec(1,10,1)).move(Vec(0,5,0));                             // scale and move terrain vertically
   Sky.atmospheric();                                                       // sky
   Sun.image="Env/Sky/sun.gfx"; Sun.light_color=1-D.ambientColor(); // sun

   Water.colorMap(Images("Env/Water/0.gfx")).normalMap(("Env/Water/0.n.gfx")).reflectionMap(("Env/Water/reflection.gfx")); // set water from textures
   Water.draw      =true; // enable drawing
   Water.wave_scale=0.8f; // adjust wave scales

   return true;
}
void Shut()
{
}
/******************************************************************************/
Bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   CamHandle(0.01f, 500, CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT));

   // here you can optionally set different water surface plane
   if(Kb.b(KB_UP  ))Water.plane+=Vec(0,1,0)*Time.d(); // move water surface plane upwards
   if(Kb.b(KB_DOWN))Water.plane-=Vec(0,1,0)*Time.d(); // move water surface plane downwards

   // update water waves movement
   Water.update(Vec2(0.01f, 0.01f));

   return true;
}
/******************************************************************************/
void Render()
{
   switch(Renderer())
   {
      case RM_PREPARE: terrain.draw(MatrixIdentity); break;
   }
}
void Draw()
{
   Renderer(Render);
   D.text(0, 0.9f, S+"Fps "+Time.fps());
   D.text(0, 0.8f, "Press up/down keys to change water level");
}
/******************************************************************************/


and lastly:
http://www.esenthel.com/community/showth...hp?tid=298

My Blog
http://www.esenthel.com/community/showthread.php?tid=6043

I hang out at Esenthel IRC Channel
http://webchat.freenode.net/?channels=#Esenthel
03-30-2013 03:54 AM
Visit this user's website Find all posts by this user Quote this message in a reply
uNetti Offline
Member

Post: #3
RE: Game::World.update and ocean
I am sorry, but what does this have to do with Water.plane.set(Vec(0,-300,0),Vec(0,1,0)); getting its values reset when you call Game::World.update()?

I have absolutely no idea what the reply you just made was about?
03-30-2013 02:01 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Dwight Offline
Member

Post: #4
RE: Game::World.update and ocean
On Update() the default value gets restored if you do not manually overwrite the default value of the header, if I am not mistaken.
03-30-2013 06:28 PM
Find all posts by this user Quote this message in a reply
gwald Offline
Member

Post: #5
RE: Game::World.update and ocean
(03-30-2013 02:01 PM)uNetti Wrote:  I am sorry, but what does this have to do with Water.plane.set(Vec(0,-300,0),Vec(0,1,0)); getting its values reset when you call Game::World.update()?

I have absolutely no idea what the reply you just made was about?

It's examples of others using water.

My Blog
http://www.esenthel.com/community/showthread.php?tid=6043

I hang out at Esenthel IRC Channel
http://webchat.freenode.net/?channels=#Esenthel
03-30-2013 10:47 PM
Visit this user's website Find all posts by this user Quote this message in a reply
uNetti Offline
Member

Post: #6
RE: Game::World.update and ocean
(03-30-2013 06:28 PM)Dwight Wrote:  On Update() the default value gets restored if you do not manually overwrite the default value of the header, if I am not mistaken.

Cheers.
03-31-2013 12:32 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply