About Store Forum Documentation Contact



Post Reply 
invisible cubes
Author Message
rndbit Offline
Member

Post: #1
invisible cubes
this is funny issue im unable to tackle. and very frustrating too :| i am trying to dynamically insert object into a world.
Code:
Game::ObjParamsPtr obj = Game::Objs.ptrRequire("Obj/box.obj");
Game::World.objCreate(*obj, Matrix(obj->scale(), Vec(i, y, j)));

Object in world editor is seen just fine:
[Image: 3c30a953c1eb4dd99a78a23.png]

However in game cube is invisible. objCreate() returns true, and cube is inserted into world just fine because i can spawn player on it. thing is cube is totally transparent. any clues what could cause this?

EDIT:
i forgot to mention that OBJ_BLOCK makes objects of Block class which basically just inherits Game::Static and nothing more.
(This post was last modified: 12-20-2011 10:56 AM by rndbit.)
12-19-2011 09:15 PM
Find all posts by this user Quote this message in a reply
rndbit Offline
Member

Post: #2
RE: invisible cubes
trying to solve this weird issue i stick my code into tutorial to see if same thing happens. player falls down on invisible table. any clues why table would not want to show up? Tested with meshes straight from ee sdk so it can not be tampering with objects, must be code. Any clues?

Code:
/******************************************************************************/
#include "stdafx.h"
/******************************************************************************

   Define your custom player character class basing on already defined Game::Chr
   Game::Chr is a class which handles the most basic character methods
   including : movement, animations, physics and actions

/******************************************************************************/
STRUCT(Player , Game::Chr) // extend character class by defining a player class based on the character
//{
   virtual Bool update(); // here we'll update the player (please note that this is a virtual method)
};
/******************************************************************************/
Bool Player::update()
{
   // here we update character input according to mouse and keyboard
   // before we set the input, we need to check if the character isn't controlled by an automatic action
   if(action)
   {
      // if it's controlled by an action we leave the input with no changes,
      // however we can optionally break that action, by pressing for example movement keys
      if(Kb.b(KB_W) || Kb.b(KB_S) || Kb.b(KB_A) || Kb.b(KB_D) || Kb.b(KB_Q) || Kb.b(KB_E))actionBreak();
   }

   if(!action) // if the character isn't controlled by an automatic action, we can set the input
   {
      // turn & move
      input.turn.x=Kb.b(KB_Q)-Kb.b(KB_E);
      input.turn.y=Kb.b(KB_T)-Kb.b(KB_G);
      input.move.x=Kb.b(KB_D)-Kb.b(KB_A);
      input.move.z=Kb.b(KB_W)-Kb.b(KB_S);
      input.move.y=Kb.b(KB_SPACE)-Kb.b(KB_LSHIFT);

      // dodge, crouch, walk, jump
      input.dodge = Kb.bd(KB_D)-Kb.bd(KB_A);
      input.crouch= Kb.b (KB_LSHIFT);
      input.walk  = Kb.b (KB_LCTRL );
      input.jump  =(Kb.bp(KB_SPACE) ? 3.5f : 0);

      // mouse turn
      Flt max=DegToRad(900)*Time.d();
      angle.x-=Mid(Ms.d().x*1.7f, -max, max);
      angle.y+=Mid(Ms.d().y*1.7f, -max, max);
   }

   return super::update(); // call Game::Chr::update on which Player is based on
}
/******************************************************************************/
Actor  ground; // ground actor
Player player; // player
/******************************************************************************/
#include "../data/Enum/_enums.h"
Game::ObjMemx<Game::Static> statics_objs;
void InitPre()
{
   App.name("Game Character");
   App.flag=APP_MS_EXCLUSIVE|APP_FULL_TOGGLE;
   DataPath("../data");
   Paks.add("engine.pak");

   D.sync(true);

   Cam.dist=5;
}
/******************************************************************************/
Bool Init()
{
    Physics.create(CSS_NONE, true, "../Installation/PhysX");
    // Create the game world.
    Game::World.init();

    Sky.atmospheric();
    Sun.image=Images("gfx/sky/sun.gfx");
    Sun.rays_color = Vec(0.42f, 0.42f, 0.42f);
    Clouds.layered.set(3,Images("Clouds/Layers/0.gfx")).scaleY( 0.1f );

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

    // Set object types to load from worldmap.
    Game::World
        .setObjType(statics_objs,      OBJ_STATIC)
        .update    (Cam.at               );

    Physics.create(CSS_FREEZE_XZ);

   Game::ObjParamsPtr obj2 = Game::Objs.ptrRequire("Obj/Static/Table/0.obj");
   if(!Game::World.objCreate(*obj2, Matrix(obj2->scale(), Vec(1, 0, 1))))
       return false;

   Game::ObjParams obj; // set object parameters
   obj.mesh(true, Meshes.ptrRequire("obj/chr/human/0.mesh"));
   obj.matrix.setScalePos(1.8f, Vec(1,2,1));
   player.create(obj); // create player from object parameters

   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Update()
{
   if(Kb.bp(KB_ESC))return false;

   Physics.startSimulation().stopSimulation();

   player.update(); // update player

   Cam.setSpherical(player.ctrl.actor.pos()+Vec(0,1,0), player.angle.x, player.angle.y, 0, Cam.dist*ScaleFactor(Ms.wheel()*-0.2f)).updateVelocities().set(); // update camera according to player angles and mouse wheel

   return true;
}
/******************************************************************************/
void Render()
{
   Game::World.draw();
   switch(Renderer())
   {
      case RM_PREPARE:
      {
         player.drawPrepare();

         LightDir(!(Cam.matrix.x-Cam.matrix.y+Cam.matrix.z)).add();
      }break;
   }
}
void Draw()
{
   Renderer(Render);
   if(Renderer.rebuildDepthNeededForDebugDrawing())Renderer.rebuildDepth();
   ground.draw(); // draw ground actor
}
/******************************************************************************/
(This post was last modified: 12-21-2011 10:20 AM by rndbit.)
12-20-2011 04:50 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: invisible cubes
void Render()
{
switch(Renderer())
{
case RM_PREPARE:
{
player.drawPrepare();

LightDir(!(Cam.matrix.x-Cam.matrix.y+Cam.matrix.z)).add();
}break;
}
}

I believe you're not calling Game::World.draw() wink
12-21-2011 12:44 AM
Find all posts by this user Quote this message in a reply
rndbit Offline
Member

Post: #4
RE: invisible cubes
uhh this is not the cause, or at least not all causes. i added the call (updated my code above your post too) and it still wont show up.
12-21-2011 10:21 AM
Find all posts by this user Quote this message in a reply
rndbit Offline
Member

Post: #5
RE: invisible cubes
umm.. bump! smile

golden rule: when all rational things you have tried and nothing works - try random stupid things, eventually you will succeed! Thats what i did!

So turns out problem occurs only if world is not loaded. Adding Game::World.New("World/test_0.world"); makes it work. that kind of tells me that loading world initializes the engine in some way. So i guess we can call this a bug of sorts.

So how do i properly make it all tick without loading a world? Could just make empty world and load that i guess, but its more like a hack than a proper way of doing things.
12-22-2011 11:05 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: invisible cubes
thanks, I will investigate this smile
12-23-2011 12:14 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: invisible cubes
current implementation requires operating on existing world folder
so please either use pre-made dummy world from World Editor
or you can use static method Game::WorldManager::Create to create wold folder from codes (Ineisis Lite uses this)
12-30-2011 01:56 PM
Find all posts by this user Quote this message in a reply
Post Reply