About Store Forum Documentation Contact



Post Reply 
[Solved] Animated Leaves?
Author Message
kevindekever Offline
Member

Post: #1
[Solved] Animated Leaves?
Code:
/******************************************************************************/
Game.ObjMap<Game.Static> Trees; // container for item      objects
ObjectPtr obj;
MeshPtr mesh;
MaterialPtr material;

/******************************************************************************/
void InitPre()
{
   EE_INIT();
   App.flag=APP_MS_EXCLUSIVE;
  
   Renderer.type(RT_DEFERRED);

   Cam.dist =15;
   Cam.yaw  =-PI_4;
   Cam.pitch=-0.5;
   Cam.at.set(0, 0, 0);
}
/******************************************************************************/
bool Init()
{
   Physics.create(EE_PHYSX_DLL_PATH);

   // set world active range to match the view range
   Game.World.activeRange(D.viewRange());

   // we need to tell the world 'which class handles which object type'
   // this is done by assigning memory containers to certain Object Types
  

   // now when the engine is set up properly we can start a 'new game' with a builded world
   Game.World.New(UID(3502200796, 1195306463, 3389023402, 3176213)); // create the world by giving path to world
   Game.World.setObjType(Trees, OBJ_TREE);

   if(Game.World.settings().environment) // if the world has environment settings (like sun, ambient, sky, ..)
      Game.World.settings().environment->set(); // then set them

   // when the world is set it doesn't actually load all the terrain and objects into memory
   // it loads only information about them
   // you need to tell the world which terrain and objects you need to use at the moment
   // to do that call:
   Game.World.update(Cam.at); // which updates world to use only terrain and objects at given position, here camera position is used
  
   obj = ObjectPtr(UID(899129323, 1251729884, 1950262160, 3450165873)); // Tree Mesh
   obj->type(OBJ_TREE);
  
   MaterialPtr m  = MaterialPtr(UID(1563354693, 1083216022, 2280581278, 82071384)); //TEXTURE Leaves
   m->technique = MTECH_TEST_BLEND_LIGHT_LEAF;
   m->validate();
  
  
   obj->mesh()->parts[1].material(m);
   obj->mesh()->parts[0].material(UID(1823861687, 1309762074, 3259199142, 2235106019)); // TEXTURE Bark
   obj->mesh()->setBox();
   obj->mesh()->setShader();
   Game.World.objCreate(*obj, Matrix(MatrixIdentity, Vec(0, 0, 0)));

  
   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   Cam.transformByMouse(0.1, 100, CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT));
  
   D.grassUpdate();
  

   Game.World.update(Cam.at); // update the world to given position

   return true;
}
/******************************************************************************/
void Render()
{
  
   switch(Renderer())
   {
      case RM_PREPARE:
      {
            obj->mesh()->draw(MatrixIdentity);
      }break;
      
      case RM_SHADOW :
      {
        
      }break;
   }
}
void Draw()
{
   Renderer(Render);
}
/******************************************************************************/

What i have to do to add the animation shader? "MTECH_TEST_BLEND_LIGHT_LEAF"
(This post was last modified: 08-11-2015 08:28 AM by kevindekever.)
08-10-2015 11:45 PM
Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Member

Post: #2
RE: Animated Leaves?
to use this technique mesh must also contain leaf attachment positions, which can be generated in the Model Editor tool through menu options ?

idk i've never tried this so far, but i'm interested as well =) wanna see what can be done with that
08-11-2015 05:08 AM
Find all posts by this user Quote this message in a reply
kevindekever Offline
Member

Post: #3
RE: Animated Leaves?
(08-11-2015 05:08 AM)RedcrowProd Wrote:  to use this technique mesh must also contain leaf attachment positions, which can be generated in the Model Editor tool through menu options ?

idk i've never tried this so far, but i'm interested as well =) wanna see what can be done with that

Thanks, yes this was the problem. Just added this line:
Code:
obj->mesh()->parts[1].setLeafAttachment(Vec2(0.5f, 0.0f));
08-11-2015 08:27 AM
Find all posts by this user Quote this message in a reply
Post Reply