i have been playing a little bit around, with the character thingy, and i got a few problems...
first heres my code so far:
Code:
/******************************************************************************/
#include "stdafx.h"
#include "../data/enum/_enums.h"
/******************************************************************************/
struct Player:Game::Chr
{
virtual Bool update();
};
/******************************************************************************/
Game::ObjMemx<Player> Players;
/******************************************************************************/
Bool Player::update(){
input.anglei.x=Kb.b(KB_A)-Kb.b(KB_D);
input.diri.z=Kb.b(KB_W);
input.diri.y=Kb.b(KB_SPACE);
return __super::update();
}
/******************************************************************************/
Actor ground;
Player player;
/******************************************************************************/
void InitPre()
{
App.name="Test project";
App.flag=APP_FULL_TOGGLE | APP_MS_EXCLUSIVE;
PakAdd("data/engine.pak");
IOPath="../data/";
Cam.dist=5;
}
/******************************************************************************/
Bool Init()
{
Physics.create();
Game::World.init().setType(Players,OBJ_CHR).New("world/sample");
player.create(Vec(0, 1, 0), 1.7, "../data/obj/chr/skeleton/0.mesh");
return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Main()
{
if(Kb.bp(KB_ESC))return false;
Physics.sim().get();
player.update();
Game::World.update(Cam.at);
if(Ms.b(1)){
Cam.yaw -= Ms.d.x;
Cam.pitch +=Ms.d.y;
}
Cam.at = player.ctrl.actor.pos()+Vec(0,1,0);
Cam.dist -=Ms.wheel*0.2;
Cam.dist = 5;
Cam.setSpherical(Cam.at, Cam.yaw, Cam.pitch, 0, Cam.dist);
Cam.updateVelocities();
Cam.set();
return true;
}
/******************************************************************************/
void Render()
{
Game::World.draw();
switch(Renderer())
{
case RM_LIGHT:
LightDir(1,!Vec(1,-1,1)).add();
break;
}
player.draw();
ground.draw();
}
void Draw()
{
D.clear();
Renderer(Render);
}
/******************************************************************************/
and heres the problems i ran into:
1. for some reason there is also a controlable human mesh, which appears at the center of the ground (skeleton spawns on one of the corners)
some of the code, is copied from tutorials, and some of it i wrote myself, but i dont see anything that should create, or draw the human :S
2. when i walk around with my char, its like he is shaking... not much, but its kinda anoying :/
3. the line
Cam.at = player.ctrl.actor.pos()+Vec(0,1,0); i had to copy from a tutorial... first of i tried stuff like
Cam.at = player.pos(); and such, but it didnt work... what excactly does the .ctrl.actor thingy change?
4. i didnt really understand this:
Code:
case RM_LIGHT:
LightDir(1,!Vec(1,-1,1)).add();
break;
first of i tried to play around with some different light settings, but i couldnt make it light up the whole scene, so i decided to copy it from the "character and world" tutorial... but i kinda bugs me that i dont know what it actually does :oops:
hope you can help me out
thanks in advance