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
}
/******************************************************************************/