Jump to content

Schoppy0384

Members
  • Posts

    31
  • Joined

  • Last visited

Posts posted by Schoppy0384

  1. Hi,

     

    is it possible to set an Entitys RenderPosition? In Blitz3D this was EntityOrder.

     

    The problem is when I use z-sort as Material Flag, the Model are not affect by a Light.

     

    Here are some Pictures:

    The Plane are pointed to the Camera. When the z-Sort Flag is false, the plane affected by the light.

     

    But I need z-Sort to Render the Plane before the Planet.

    post-8630-0-44539400-1410358153_thumb.jpg

  2. Ok, thanks all for help.

     

    I think I have the solution:

     

    //Get the Plane Normal
    Surface* surface = mPlane->GetSurface(0);
    Leadwerks::Vec3 V1 = surface->GetVertexNormal(1);
    //Get the Differenz between Camera and Plane
    Leadwerks::Vec3 V2 = camera->GetPosition() - mPlane->GetPosition();
    
    //Normalize the Vectors
    V1 = V1.Normalize();
    V2 = V2.Normalize();
    
    //The Dot Product
    float dot = V1.Dot(V2);
    
    //ABS
    float dotAbsolute = Leadwerks::Math::Abs(dot);
    
    cout << dotAbsolute << endl;
    
    mPlane->SetColor(1, 1, 1, dotAbsolute);
    

    • Upvote 2
  3. Hi,

    I need the Angle between a Plane and the Camera:

     

    
    Leadwerks::Vec3 V1 = mPlane->GetPosition();
    Leadwerks::Vec3 V2 = camera->GetPosition();
    
    // turn vectors into Normals
    Leadwerks::Vec3 V1n = V1.Normalize();
    Leadwerks::Vec3 V2n = V2.Normalize();
    
    //the Dot Product
    float dot = V1n.Dot(V2n);
    
    //And the Angle
    float angle = Leadwerks::Math::ACos(dot);
    
    

     

    But the Angle is not correct.

  4. Hi,

     

    I have Include the Raknet Library as described in this manual.

     

    http://www.jenkinssoftware.com/raknet/manual/tutorial.html

     

    But when I compile the Project, there are many Errors:

     

    Fehler 141 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: virtual __thiscall Leadwerks::Object::~Object(void)" (??1Object@Leadwerks@@UAE@XZ)" in Funktion ""public: virtual __thiscall Leadwerks::Vec3::~Vec3(void)" (??1Vec3@Leadwerks@@UAE@XZ)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 142 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __thiscall Leadwerks::Vec3::Vec3(void)" (??0Vec3@Leadwerks@@QAE@XZ)" in Funktion ""void __cdecl `dynamic initializer for 'camerarotation''(void)" (??__Ecamerarotation@@YAXXZ)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 143 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static void __cdecl Leadwerks::Time::Update(int)" (?Update@Time@Leadwerks@@SAXH@Z)" in Funktion ""public: virtual bool __thiscall App::Loop(void)" (?Loop@App@@UAE_NXZ)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 144 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static float __cdecl Leadwerks::Time::GetSpeed(void)" (?GetSpeed@Time@Leadwerks@@SAMXZ)" in Funktion ""public: virtual bool __thiscall App::Loop(void)" (?Loop@App@@UAE_NXZ)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 145 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Leadwerks::System::GetProperty(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?GetProperty@System@Leadwerks@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV34@V34@@Z)" in Funktion ""public: virtual bool __thiscall App::Start(void)" (?Start@App@@UAE_NXZ)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 146 error LNK2001: Nicht aufgelöstes externes Symbol ""public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Leadwerks::System::GetProperty(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?GetProperty@System@Leadwerks@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV34@V34@@Z)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 147 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static bool __cdecl Leadwerks::Map::Load(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int,unsigned __int64)" (?Load@Map@Leadwerks@@SA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H_K@Z)" in Funktion ""public: virtual bool __thiscall App::Start(void)" (?Start@App@@UAE_NXZ)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 148 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static class Leadwerks::World * __cdecl Leadwerks::World::Create(void)" (?Create@World@Leadwerks@@SAPAV12@XZ)" in Funktion ""public: virtual bool __thiscall App::Start(void)" (?Start@App@@UAE_NXZ)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 149 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static class Leadwerks::Context * __cdecl Leadwerks::Context::Create(class Leadwerks::Window *,int)" (?Create@Context@Leadwerks@@SAPAV12@PAVWindow@2@H@Z)" in Funktion ""public: virtual bool __thiscall App::Start(void)" (?Start@App@@UAE_NXZ)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 150 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static class Leadwerks::Camera * __cdecl Leadwerks::Camera::Create(class Leadwerks::Entity *)" (?Create@Camera@Leadwerks@@SAPAV12@PAVEntity@2@@Z)" in Funktion ""public: virtual bool __thiscall App::Start(void)" (?Start@App@@UAE_NXZ)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 151 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static class Leadwerks::Window * __cdecl Leadwerks::Window::Create(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int,int,int,int,int)" (?Create@Window@Leadwerks@@SAPAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@HHHHH@Z)" in Funktion ""public: virtual bool __thiscall App::Start(void)" (?Start@App@@UAE_NXZ)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 152 error LNK2001: Nicht aufgelöstes externes Symbol ""public: static int const Leadwerks::Key::Escape" (?Escape@Key@Leadwerks@@2HB)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 153 error LNK2001: Nicht aufgelöstes externes Symbol ""public: static int const Leadwerks::Key::A" (?A@Key@Leadwerks@@2HB)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 154 error LNK2001: Nicht aufgelöstes externes Symbol ""public: static int const Leadwerks::Key:" (?D@Key@Leadwerks@@2HB)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 155 error LNK2001: Nicht aufgelöstes externes Symbol ""public: static int const Leadwerks::Key::S" (?S@Key@Leadwerks@@2HB)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 156 error LNK2001: Nicht aufgelöstes externes Symbol ""public: static int const Leadwerks::Key::W" (?W@Key@Leadwerks@@2HB)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 157 error LNK2001: Nicht aufgelöstes externes Symbol ""public: static int const Leadwerks::Map::LoadScripts" (?LoadScripts@Map@Leadwerks@@2HB)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 158 error LNK2001: Nicht aufgelöstes externes Symbol ""public: static int const Leadwerks::Window::Titlebar" (?Titlebar@Window@Leadwerks@@2HB)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\App.obj RakNetTEST
    Fehler 159 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""void __cdecl Leadwerks::Print(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Print@Leadwerks@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 160 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Leadwerks::String(int)" (?String@Leadwerks@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 161 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Leadwerks::String::Right(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?Right@String@Leadwerks@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV34@H@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 162 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Leadwerks::String::Left(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?Left@String@Leadwerks@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV34@H@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 163 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Leadwerks::String::Lower(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Lower@String@Leadwerks@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV34@@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 164 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static int __cdecl Leadwerks::String::Int(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Int@String@Leadwerks@@SAHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 165 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Leadwerks::FileSystem::ExtractExt(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?ExtractExt@FileSystem@Leadwerks@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV34@@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 166 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Leadwerks::FileSystem::StripAll(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?StripAll@FileSystem@Leadwerks@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV34@@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 167 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static int __cdecl Leadwerks::FileSystem::GetFileType(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned __int64)" (?GetFileType@FileSystem@Leadwerks@@SAHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 168 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static class Leadwerks::Directory * __cdecl Leadwerks::FileSystem::LoadDir(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?LoadDir@FileSystem@Leadwerks@@SAPAVDirectory@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 169 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Leadwerks::FileSystem::GetAppDataPath(void)" (?GetAppDataPath@FileSystem@Leadwerks@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 170 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static bool __cdecl Leadwerks::FileSystem::CreateDir(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool)" (?CreateDir@FileSystem@Leadwerks@@SA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_N@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 171 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static bool __cdecl Leadwerks::System::SaveSettings(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?SaveSettings@System@Leadwerks@@SA_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 172 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static bool __cdecl Leadwerks::System::LoadSettings(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?LoadSettings@System@Leadwerks@@SA_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 173 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static void __cdecl Leadwerks::System::ParseCommandLine(int,char const * * const)" (?ParseCommandLine@System@Leadwerks@@SAXHQAPBD@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 174 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static void __cdecl Leadwerks::System::Print(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Print@System@Leadwerks@@SAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)" in Funktion ""void __cdecl DebugErrorHook(char *)" (?DebugErrorHook@@YAXPAD@Z)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 175 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static void __cdecl Leadwerks::System::AddHook(int,void *)" (?AddHook@System@Leadwerks@@SAXHPAX@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 176 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static class Leadwerks::Package * __cdecl Leadwerks::Package::Load(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool)" (?Load@Package@Leadwerks@@SAPAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0_N@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 177 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static bool __cdecl Leadwerks::Interpreter::LoadBreakpoints(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?LoadBreakpoints@Interpreter@Leadwerks@@SA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 178 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static bool __cdecl Leadwerks::Interpreter::Connect(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int,int)" (?Connect@Interpreter@Leadwerks@@SA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@HH@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 179 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static bool __cdecl Leadwerks::Interpreter::Disconnect(int)" (?Disconnect@Interpreter@Leadwerks@@SA_NH@Z)" in Funktion "_main". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 180 error LNK2001: Nicht aufgelöstes externes Symbol ""public: static int Leadwerks::System::DebugErrorHook" (?DebugErrorHook@System@Leadwerks@@2HA)". C:\Leadwerks3.1\Projects\RakNetTEST\Projects\Windows\main.obj RakNetTEST
    Fehler 181 error LNK1120: 39 nicht aufgelöste Externe C:\Leadwerks3.1\Projects\RakNetTEST\\RakNetTEST.debug.exe RakNetTEST
    

     

     

    Does anyone an Idea where is the Error?

     

    Thanks.

  5. Ok, first i calculate the new Planet Positions with:

     

    //calculate the planet Position

    yaw = yaw + 0.5;

    float ny = Math::Sin(soll_pitch) / Math::Cos(soll_pitch);

    float nx = Math::Sin(yaw);

    float nz = Math::Cos(yaw);

     

    then normalize

    //normalize vector

    float factor = sqrt(nx*nx + ny*ny + nz*nz);

    nx = nx / Math::Abs(factor);

    ny = ny / Math::Abs(factor);

    nz = nz / Math::Abs(factor);

     

    and last position

     

    planetSphere->SetPosition(nx*planetDistancetoSun, 0, nz*planetDistancetoSun);

     

    this works for the X and Z Axis.

     

    But now I would like calculate the Y Axis like 45° or another °.

  6. Hi,

    for my Project, I must calculate the Sphere Position with Sin and Cos on the x/y/z axis.

     

    There is a Error in the Orbital Inclination calculation. My Math in Sin and Cos are not so good ;-)

     

    Ok, i can use a Pivot and the move and turn Commands, but I need the calculation for later work without

    the Models.

     

    Here are my Code:

     

    #include "App.h"
    using namespace Leadwerks;
    App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}
    App::~App() { delete world; delete window; }
    Vec3 camerarotation;
    #if defined (PLATFORM_WINDOWS) || defined (PLATFORM_MACOS)
    bool freelookmode=true;
    #else
    bool freelookmode=false;
    #endif
    
    Model* sunSphere = NULL;
    Model* planetSphere = NULL;
    float planetDistancetoSun = 5.0;
    float pitch = -45.0;
    float yaw = 0.0;
    float soll_pitch = 0.0;
    bool Orbital_inclination;
    
    bool App::Start()
    {
    Orbital_inclination = false;
    //Create a window
    window = Leadwerks::Window::Create("OrbitInc");
    
    //Create a context
    context = Context::Create(window);
    
    //Create a world
    world = World::Create();
    
    //Create a camera
    camera = Camera::Create();
    camera->Move(0,2,-10);
    
    //Hide the mouse cursor
    window->HideMouse();
    
    //std::string mapname = System::GetProperty("map","Maps/start.map");
    //Map::Load(mapname);
    //Create a Light
    Light* light = DirectionalLight::Create();
    light->SetRotation(35, 35, 0);
    
    //Create Sun Sphere
    sunSphere = Model::Sphere();
    sunSphere->SetColor(1.0, 1.0, 0.0);
    sunSphere->SetScale(2.0,2.0,2.0);
    //Create Planet Sphere
    planetSphere = Model::Sphere();
    planetSphere->SetColor(0.0, 0.0, 1.0);
    
    
    //Move the mouse to the center of the screen
    window->SetMousePosition(context->GetWidth()/2,context->GetHeight()/2);
    
    return true;
    }
    bool App::Loop()
    {
    //Close the window to end the program
    if (window->Closed()) return false;
    
    //Press escape to end freelook mode
    if (window->KeyHit(Key::Escape))
    {
    if (!freelookmode) return false;
    freelookmode=false;
    window->ShowMouse();
    }
    
    if (freelookmode)
    {
    //Keyboard movement
    float strafe = (window->KeyDown(Key:) - window->KeyDown(Key::A))*Leadwerks::Time::GetSpeed() * 0.05;
    float move = (window->KeyDown(Key::W) - window->KeyDown(Key::S))*Leadwerks::Time::GetSpeed() * 0.05;
    camera->Move(strafe,0,move);
    //Get the mouse movement
    float sx = context->GetWidth()/2;
    float sy = context->GetHeight()/2;
    Vec3 mouseposition = window->GetMousePosition();
    float dx = mouseposition.x - sx;
    float dy = mouseposition.y - sy;
    //Adjust and set the camera rotation
    camerarotation.x += dy / 10.0;
    camerarotation.y += dx / 10.0;
    camera->SetRotation(camerarotation);
    //Move the mouse to the center of the screen
    window->SetMousePosition(sx,sy);
    }
    if (window->KeyHit(Key:))
    {
    if (Orbital_inclination == false)
    {
    Orbital_inclination = true;
    }
    else
    {
    Orbital_inclination = false;
    }
    }
    Leadwerks::Time::Update();
    
    //calculate the planet Position
    yaw = yaw + 0.5;
    float ny = Math::Sin(soll_pitch) / Math::Cos(soll_pitch);
    float nx = Math::Sin(yaw);
    float nz = Math::Cos(yaw);
    
    //calculate the Orbital_inclination
    if (Orbital_inclination)
    {
    float ist_yaw = Math::Mod(yaw,360);
    float p_weg = (ist_yaw * 100.0) / 360.0;
    float winkelWeg = (2 * pitch);
    if (winkelWeg < 0) { winkelWeg = -1 * winkelWeg; }
    //calculation from the first 180 degrees
    soll_pitch = -(winkelWeg / 2) + (p_weg *(winkelWeg * 2)) / 100;
    //calculation from the second 180 degrees --- not correct !!!!!!!!!!
    if (ist_yaw > 180.0)
    {
    soll_pitch = -(winkelWeg / 2) - (p_weg *(winkelWeg * 2)) / 100;
    }
    }
    
    //normalize vector
    float factor = sqrt(nx*nx + ny*ny + nz*nz);
    nx = nx / Math::Abs(factor);
    ny = ny / Math::Abs(factor);
    nz = nz / Math::Abs(factor);
    
    planetSphere->SetPosition(nx*planetDistancetoSun, ny*planetDistancetoSun, nz*planetDistancetoSun);
    
    
    world->Update();
    world->Render();
    
    context->SetBlendMode(Blend::Alpha);
    context->SetColor(1, 1, 1);
    context->DrawText("Press Key O for Oribital Inclinaton", 2, 2);
    if (Orbital_inclination) { context->DrawText("Oribital Inclinaton: 1" , 2, 20); }
    if (!Orbital_inclination) { context->DrawText("Oribital Inclinaton: 0", 2, 20); }
    context->SetBlendMode(Blend::Solid);
    
    context->Sync(false);
    
    return true;
    }
    

  7. Hi beo6,

    I have played around with your sample. The Problem is that the pickinfo.normal.y is allways a possitive value.

    Its right, it works on one side of a hill. But on the other side the value must be negative. But it is positive.

    I do not know why this is so.

  8. Yes, I have played with AlignToVector, too. It works and rotate the Model in the right Position.

    But for the Movment I have use SetVelocity and I have a flickering problem too.

    I think the problem is that AlignToVector breaks the Physic System.

  9. Ok, I thing it is Time for some Code (C++).

     

    Here I have write a little example with 3 Methods to Navigate a Character to a specific Position.

    All three Methods has his own problems.

    You can switch the Method with this lines:

     

    // Set Method

    int method = 1;

     

    #include "App.h"
    
    using namespace Leadwerks;
    
    App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}
    
    App::~App() { delete world; delete window; }
    
    Vec3 camerarotation;
    #if defined (PLATFORM_WINDOWS) || defined (PLATFORM_MACOS)
    bool freelookmode=true;
    #else
    bool freelookmode=false;
    #endif
    
    Model* pickSphere;
    Entity* characterController;
    Entity* characterMesh;
    PickInfo pickinfo;
    
    NavMesh* navMesh;
    NavPath* path;
    
    Model* box;
    list<Model*> models;
    list<Model*>::iterator modelsIt;
    
    int pointCounter = 1;
    
    // ####################### Character Move Methods ########################
    // Set Method
    int method = 1;
    
    //method 1 = Standard Character Move Method ( only on xy Axis while SetPhysicsMode(Entity::CharacterPhysics))
    //method 2 = Character Contoller is only a Pivot. The Charcter Model Follow this Pivot by SetPhysicPosition and Rotation (Problem the Model Collides with the Pivot and looks ver bad!)
    //method 3 = Calculate the Path Manuel and move and rotate the Model. (The Rotation is Bad and sometimes the Model collides with a wall)
    
    bool App::Start()
    {
    //Create a window
    window = Window::Create("RTS_Movement");
    
    //Create a context
    context = Context::Create(window);
    
    //Create a world
    world = World::Create();
    
    //Create a camera
    camera = Camera::Create();
    camera->SetFOV(40.0f);
    camera->SetRotation(45,0,0);
    camera->Move(0,0,-35);
    
    //Create a light
    Light* light = DirectionalLight::Create();
    light->SetRotation(35,35,0);
    
    //Build a Map
    //Create the ground
    Model* ground1 = Model::Box(44.75,0.25,62.5);
    ground1->SetPosition(8.875,-0.125,-0.25);
    ground1->SetColor(0.0,0.25,0.0);
    //Ground Shape
    Shape* groundShape1 = Shape::Box(0,0,0, 0,0,0, 44.75,0.25,62.5);
    ground1->SetShape(groundShape1);
    groundShape1->Release();
    
    Model* ground2 = Model::Box(44.75,0.25,28.5);
    ground2->SetPosition(-35.875,-0.125,16.75);
    ground2->SetColor(0.0,0.25,0.0);
    //Ground Shape
    Shape* groundShape2 = Shape::Box(0,0,0, 0,0,0, 44.75,0.25,28.5);
    ground2->SetShape(groundShape2);
    groundShape2->Release();
    
    Model* ground3 = Model::Box(44.75,0.25,25.0);
    ground3->SetPosition(-35.875,-0.125,-19.0);
    ground3->SetColor(0.0,0.25,0.0);
    //Ground Shape
    Shape* groundShape3 = Shape::Box(0,0,0, 0,0,0, 44.75,0.25,25.0);
    ground3->SetShape(groundShape3);
    groundShape3->Release();
    
    Model* ground4 = Model::Box(16.48,0.25,9.0);
    ground4->SetPosition(-21.51001,-0.875,-2.0);
    ground4->SetRotation(0,0,5.0);
    ground4->SetColor(0.0,0.25,0.0);
    //Ground Shape
    Shape* groundShape4 = Shape::Box(0,0,0, 0,0,0, 16.48,0.25,9.0);
    ground4->SetShape(groundShape4);
    groundShape4->Release();
    
    Model* ground5 = Model::Box(28.75,0.25,9.0);
    ground5->SetPosition(-43.875,-1.625,-2.0);
    ground5->SetColor(0.0,0.25,0.0);
    //Ground Shape
    Shape* groundShape5 = Shape::Box(0,0,0, 0,0,0, 28.75,0.25,9.0);
    ground5->SetShape(groundShape5);
    groundShape5->Release();
    
    Model* ground6 = Model::Box(0.75,2.75,8.5);
    ground6->SetPosition(5.625,1.125,11.5);
    ground6->SetColor(0.0,0.80,0.0);
    //Ground Shape
    Shape* groundShape6 = Shape::Box(0,0,0, 0,0,0, 0.75,2.75,8.5);
    ground6->SetShape(groundShape6);
    groundShape6->Release();
    
    Model* ground7 = Model::Box(0.75,2.75,8.5);
    ground7->SetPosition(-5.125,1.125,11.5);
    ground7->SetColor(0.0,0.80,0.0);
    //Ground Shape
    Shape* groundShape7 = Shape::Box(0,0,0, 0,0,0, 0.75,2.75,8.5);
    ground7->SetShape(groundShape7);
    groundShape7->Release();
    
    //Enable navigation obstacles
    ground1->SetNavigationMode(true);
    ground2->SetNavigationMode(true);
    ground3->SetNavigationMode(true);
    ground4->SetNavigationMode(true);
    ground5->SetNavigationMode(true);
    ground6->SetNavigationMode(true);
    ground7->SetNavigationMode(true);
    
    //Build the navigation mesh
    world->BuildNavMesh();
    
    //picksphere
    pickSphere = Model::Sphere(12);
    pickSphere->SetScale(0.5);
    pickSphere->Hide();
    
    
    if(method == 1)
    {
    //#############-- Create a Character --##################
    //Create a character controller
    characterController = Pivot::Create();
    characterController->SetPosition(0,0,0);
    
    characterMesh = Model::Box(1.0,0.2,1.5,characterController);
    characterMesh->SetScale(1,2,1);
    characterMesh->SetPosition(0,0,0);
    
    characterController->SetMass(1);
    characterController->SetPhysicsMode(Entity::CharacterPhysics);
    
    //#######################################################
    }
    
    if(method == 2)
    {
    //#############-- Create a Character --##################
    //Create a character controller
    characterController = Pivot::Create();
    characterController->SetPosition(0,0,0);
    
    characterController->SetMass(1);
    characterController->SetPhysicsMode(Entity::CharacterPhysics);
    
    //Create the Mesh
    characterMesh = Model::Box(1.0,0.2,1.5);
    characterMesh->SetScale(1,2,1);
    characterMesh->SetPosition(0,0,0);
    characterMesh->SetMass(1);
    
    //Set Shape
    Shape* characterShape = Shape::Box(0,0,0, 0,0,0, 1.0,0.2,1.5);
    characterMesh->SetShape(characterShape);
    characterShape->Release();
    //#######################################################
    }
    
    if(method == 3)
    {
    navMesh = world->navmesh;
    path = new NavPath(); // Create a new Instance
    path->navmesh = navMesh;
    
    //init list
    models = list<Model*>();
    //#############-- Create a Character --##################
    //Create the Mesh
    characterMesh = Model::Box(1.0,0.2,1.5);
    characterMesh->SetScale(1,2,1);
    characterMesh->SetPosition(0,0,0);
    characterMesh->SetMass(1);
    
    //Set Shape
    Shape* characterShape = Shape::Box(0,0,0, 0,0,0, 1.0,0.2,1.5);
    characterMesh->SetShape(characterShape);
    characterShape->Release(); //#######################################################
    
    }
    
    
    
    
    //Move the mouse to the center of the screen
    window->SetMousePosition(context->GetWidth()/2,context->GetHeight()/2);
    
    return true;
    }
    
    bool App::Loop()
    {
    //Close the window to end the program
    if (window->Closed() || window->KeyDown(Key::Escape)) return false;
    
    // Show Physics
    if(window->KeyHit(Key:)) camera->drawphysicsmode = !camera->drawphysicsmode;
    
    //Enable/Disable navmesh debugging
    if(window->KeyHit(Key::N))
    {
    if (camera->GetDebugNavigationMode() == false) {camera->SetDebugNavigationMode(true);} else {camera->SetDebugNavigationMode(false);}
    }
    
    
    //RTS Camera Movement
    if(!window->MouseDown(2))
    {
    float strafe = (window->KeyDown(Key:) - window->KeyDown(Key::A))*Time::GetSpeed() * 0.1;
    float move = (window->KeyDown(Key::W) - window->KeyDown(Key::S))*Time::GetSpeed() * 0.1;
    camera->Move(strafe,move,move);
    }
    
    //Temp Camera Movement
    if(window->MouseDown(2))
    {
    float strafe = (window->KeyDown(Key:) - window->KeyDown(Key::A))*Time::GetSpeed() * 0.1;
    float move = (window->KeyDown(Key::W) - window->KeyDown(Key::S))*Time::GetSpeed() * 0.1;
    camera->Move(strafe,0,move);
    
    //Get the mouse movement
    float sx = context->GetWidth()/2;
    float sy = context->GetHeight()/2;
    Vec3 mouseposition = window->GetMousePosition();
    float dx = mouseposition.x - sx;
    float dy = mouseposition.y - sy;
    
    //Adjust and set the camera rotation
    camerarotation.x += dy / 10.0;
    camerarotation.y += dx / 10.0;
    camera->SetRotation(camerarotation);
    
    //Move the mouse to the center of the screen
    window->SetMousePosition(sx,sy);
    }
    
    
    if(method == 1)
    {
    //#############-- Character Movment --##################
    //Place a new target position for our npcewa
    if (window->MouseHit(1))
    {
    Vec3 p = window->GetMousePosition();
    if (camera->Pick(p.x,p.y,pickinfo,0.5,true))
    {
    pickSphere->Show();
    pickSphere->SetPosition(pickinfo.position);
    }
    }
    
    //Move Character to Pick Position
    characterController->GoToPoint(pickinfo.position,3.0f,6.0f);
    //######################################################
    }
    
    
    if(method == 2)
    {
    //#############-- Character Movment --##################
    //Place a new target position for our npcewa
    if (window->MouseHit(1))
    {
    Vec3 p = window->GetMousePosition();
    if (camera->Pick(p.x,p.y,pickinfo,0.5,true))
    {
    pickSphere->Show();
    pickSphere->SetPosition(pickinfo.position);
    }
    }
    //Move Character to Pick Position
    characterController->GoToPoint(pickinfo.position,3.0f,6.0f);
    
    // Use the Physics to Position and Rotate The Mesh
    characterMesh->PhysicsSetRotation(characterController->GetRotation().x,characterController->GetRotation().y,characterController->GetRotation().z,0.005);
    characterMesh->PhysicsSetPosition(characterController->GetPosition().x,characterController->GetPosition().y,characterController->GetPosition().z,0.005);
    //######################################################
    }
    
    if(method == 3)
    {
    //#############-- Character Movment --##################
    //Place a new target position for our npcewa
    if (window->MouseHit(1))
    {
    Vec3 p = window->GetMousePosition();
    if (camera->Pick(p.x,p.y,pickinfo,0.5,true))
    {
    pickSphere->Show();
    pickSphere->SetPosition(pickinfo.position);
    }
    
    // Create a new Path
    pointCounter = 1;
    path->points.clear(); // Clear the old Points
    path = path->navmesh->FindPath(characterMesh->GetPosition(true), pickinfo.position);
    
    // Place Boxes to see the Path Points
    //Cleat the old Models
    for(modelsIt = models.begin() ; modelsIt != models.end() ; modelsIt++ )
    {
    delete (*modelsIt);
    }
    models.clear();
    // Set new Path Models
    for (int i = 0; i < path->points.size(); i++)
    {
    box = Model::Box(0.1,0.1,0.1);
    box->SetColor(1.0,0.0,0.0);
    box->SetPosition(path->points.at(i).x,path->points.at(i).y,path->points.at(i).z);
    models.push_back(box);
    cout << i << ": " << path->points.at(i).x << ", " << path->points.at(i).y << ", " << path->points.at(i).z << endl;
    }
    } //end MouseHit
    
    if(path->points.size() > 0 )
    {
    for (int i = 0; i < path->points.size(); i++)
    {
    if(i == pointCounter)
    {
    // Rotate the Character to the Points
    float targetX = path->points.at(i).x;
    float targetY = path->points.at(i).y;
    float meshPosX = characterMesh->GetPosition(true).x;
    float meshPosY = characterMesh->GetPosition(true).y;
    
    float angle = Math::ATan2(targetY - meshPosY,targetX - meshPosY);
    characterMesh->SetRotation(0,angle,0);
    }
    }
    
    if(characterMesh->GetPosition(true).x < path->points.at(pointCounter).x && characterMesh->GetPosition(true).y < path->points.at(pointCounter).y)
    {
    characterMesh->Move(0.005,0,0);
    }
    if(characterMesh->GetPosition(true).x >= path->points.at(pointCounter).x && characterMesh->GetPosition(true).y >= path->points.at(pointCounter).y)
    {
    pointCounter++;;
    }
    
    }
    
    
    
    
    //Now lets Move the Character
    
    //######################################################
    }
    
    Time::Update();
    world->Update();
    world->Render();
    
    // 2d Stuff ###########################################
    
    // Camera Projection
    if(characterController)
    {
    Vec3 p = camera->Project(characterController->GetPosition());
    
    std::string text = "Here are the Pivot";
    Leadwerks::Font* font = Leadwerks::Context::GetCurrent()->GetFont();
    p.x -= font->GetTextWidth(text)/2;
    p.y -= font->GetHeight()/2;
    p.y += -50;
    
    Leadwerks::Context::GetCurrent()->SetBlendMode(Leadwerks::Blend::Alpha);
    Leadwerks::Context::GetCurrent()->SetColor(0.0,1.0,0.0);
    Leadwerks::Context::GetCurrent()->DrawText(text,p.x,p.y);
    Leadwerks::Context::GetCurrent()->SetColor(1.0,1.0,1.0);
    }
    
    context->Sync(false);
    
    return true;
    }
    

     

    Maybe we'll find a solution together.

    I think that this is also interesting for others, too.

  10. Oh sorry, I am working on an little Tank RTS Game.

    I use the Navmesh to navigate the Tanks on the map.

     

    With a Character Controller it works very good. But the problem are hills.

    The Tanks rotate only on the y axis (Character Controller).

    What i need is a rotation upward/downward for the tanks, see first picture.

  11. Thanks for the answers.

    Ok, my Idea is to parent 2 boxes, one on the Frontside and one on the backside from the tank.

    Then I can check the height difference between the two boxes and calculate the Rotation Angel.

     

    What I need is a Pick Y Command on the box to check the Y Coordinate.

    Which command is the best for this?

    And second the Rotation Angel, i think ATAN2 is right?

×
×
  • Create New...