About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
Vehicle doesnt work..
Author Message
Truelegend Offline
Member

Post: #1
Vehicle doesnt work..
Code:
#include "stdafx.h"
#include <EsenthelEngine/Enum/_enums.h>
/******************************************************************************/
STRUCT (CarObj, Game::Item)
//{
    Vec Position;

    Wheel wheel[4];
    Wheel::Param wp;
    Flt angle;

    virtual Vec pos() { return T.Position; }
    virtual Matrix matrix() { return T.Position; }
    virtual Bool init  ();
    virtual Bool update();
    virtual Bool load(File &f)
    {
        f>>Position;
        return true;
    }
};
Bool CarObj::init()
{
    T.actor.massCenterL(T.actor.massCenterL()-Vec(0,0.8f,0));
    wheel[0].create(T.actor,Matrix().setPos(Vec( 1, -0.5f,  1.5f)),T.wp); // left -front
    wheel[1].create(T.actor,Matrix().setPos(Vec(-1, -0.5f,  1.5f)),T.wp); // right-front
    wheel[2].create(T.actor,Matrix().setPos(Vec( 1, -0.5f, -1.5f)),T.wp); // left -rear
    wheel[3].create(T.actor,Matrix().setPos(Vec(-1, -0.5f, -1.5f)),T.wp); // right-rear
    return true;
}
Bool CarObj::update() // Update
{
    Physics.startSimulation().stopSimulation();
    AdjustValTime(T.angle, (Kb.b(KB_D)-Kb.b(KB_A))*PI_4,0.01f);
    Flt accel=(Kb.b(KB_W)-Kb.b(KB_S))*1600,
        brake=Kb.b(KB_SPACE)         *3200;
    return true;
}
/******************************************************************************/
Game::ObjMemx<Game::Item   >   Items   ;
Game::ObjMemx<Game::Static >   Statics ;
Game::ObjMemx<Game::Chr    >   Chrs    ;
Game::ObjMemx<      CarObj >   CarObjs ;
/******************************************************************************/
void InitPre()
{
   App.name("");
   App.flag=EE::APP_MS_EXCLUSIVE|EE::APP_FULL_TOGGLE;
   DataPath("../data");
   Paks.add("../data/engine.pak");

   D.full(false).sync(true);
}
/******************************************************************************/
Bool Init()
{

    Sky.atmospheric();
    Physics.create(CSS_NONE,true,"../Installation/PhysX");

    Game::World.init()
        .setObjType(Items   ,    OBJ_ITEM)
        .setObjType(Statics ,    OBJ_STATIC)
        .setObjType(Chrs    ,    OBJ_CHR)
        .setObjType(CarObjs ,    OBJ_CAR)
    .New("world/swiat123.world");

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

   Game::World.update(Cam.at);
   Cam.setSpherical(CarObjs[0].pos(), Cam.yaw, Cam.pitch, Cam.roll, -4);
   Cam.updateVelocities().set();


   return true;
}
/******************************************************************************/
void Render()
{
    Game::World.draw();
}
/******************************************************************************/
void Draw()
{
    Renderer(Render);
    CarObj().actor.massCenterL().draw(RED);
}
/******************************************************************************/

Why car is doesnt work. What is wrong?
04-19-2011 08:54 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #2
RE: Vehicle doesnt work..
Why do you make a new thread about your car? And i don't know either whats wrong... can you elaborate what the problem is?

There is always evil somewhere, you just have to look for it properly.
04-19-2011 09:03 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Truelegend Offline
Member

Post: #3
RE: Vehicle doesnt work..
My mesh doesnt move when i click WSAD, etc..
04-19-2011 09:10 PM
Find all posts by this user Quote this message in a reply
menajev Offline
Bronze Supporter

Post: #4
RE: Vehicle doesnt work..
This is what should you be interested in.
04-19-2011 10:37 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #5
RE: Vehicle doesnt work..
Maybe the car is out of fuel wink

There is always evil somewhere, you just have to look for it properly.
04-19-2011 10:52 PM
Visit this user's website Find all posts by this user Quote this message in a reply
llynx Offline
Member

Post: #6
RE: Vehicle doesnt work..
Take a good hard look at your code smile It's pretty obvious... *hint* has to do with update()
04-19-2011 11:03 PM
Find all posts by this user Quote this message in a reply
Truelegend Offline
Member

Post: #7
RE: Vehicle doesnt work..
I forgotted 1 think in update function but i added this and i still the same.
[Image: wtfuvt.png]
... How you can see car positon and actor positon is the same so why MassCenterL of actors is somewhere else?
(This post was last modified: 04-20-2011 05:01 PM by Truelegend.)
04-20-2011 04:19 PM
Find all posts by this user Quote this message in a reply
Post Reply