Jump to content

Bytecroc

Members
  • Posts

    56
  • Joined

  • Last visited

Everything posted by Bytecroc

  1. an editor field for colored text input and different font
  2. My tactic right now is to wait until LE5 is published. Since it is most likely very different from LE4, I no longer invest as much time in LE4 programming. I hope it comes out soon.
  3. I must make first a few tests, identify models from map and vegetation from map if this is possible. I need also different spawn points for the camera, it would be the best I implement a developer class for programming and grab them out for release versions. In this map I used I have not set a camera and no player, only the map itself. I posted that only for C++ users which have that same problem and did not find anything in the search function. But anyway thank you for help and suggestions.
  4. Yes, but if I want to have a dynamic weather system I will do that in C++ to have the control, I am not a Lua programmer. In the moment I want only a fix weather it is good to have it with the map. But thank you anyway for your info.
  5. I worked the half day on that problem and I think I give the information to everyone who also has this problem with fog. In the Editor fog looks a little bit like fog. Without implementig fog in C++ source, no fog is visible in C++. Loading a map after craeting a camera only a touch of a color is visible in the very far, and fog is not working as it should. I mean with map not a terrain, I loaded a map with only a plattform and some prefabs. I have not tested with terrain. So load a map before creating a camera. Nothing works correct if you not do that.
  6. I searched in the forum but found no artice with a link for TreeIt. It is a nice tree generator http://www.evolved-software.com/treeit/news
  7. First I load a prefab I saved "2 sliding doors, with slidingdoor.lua script", the first prefab works as it should. I loaded the prefab and it did not work. I duplicate the existing prefab in the editor and did not work. I checked all entries, all perfect. I looked in flowgraph editor all perfect ... but wait, it looks only perfect. The duplicated prefab lays directly over the first and when I click the first prefab the Tab from the first are on top when I clicked on the second prefab and look in the flowgraph the second Tabs are on top and it looks they where connected. I move the tabs around and they are not connected, they are both in the flowgraph but the second was not connected. After I connect them it works.
  8. Since 3 years I have not programmed anything with Leadwerks, that has nothing to do with Leadwerks it was a real life thing. So I must learn the stuff from the beginning. My natural language is not English, I hope you can forgive me a mistake or two . If you want test the code you make a new project and a map. I made some test objects to see if climbing fails or not and under which steps I can crouch and on which step I can jump. I make this blog for me to save the source code. Two times in my life I lost nearly all my source I programmed by HardDrive crashes. So it is a nice thing to have that online. And for beginnes to have a start code. In your project folder, by me in "documents/Leadwerks/Projects/.... <-- here are my Projects" you have a subfolder also named projects: "documents/Leadwerks/Projects/ProjectName/projects/" by me in the folder windows is the VisualStudio 17 project: "ProjectName.sln" << Start this with Doubleclick, but first install VisualStudio. I delete all the stuff inside main.cpp, App.cpp and app.h and put the following code in main.cpp change your mapname > "YouMapName.map" from your project and compile. I can not say whats the menu names in english because I have the german GUI. For VisualStudio tutorials look in the Web or YouTube, I am sure there are dozens of them. #include "Leadwerks.h" #include <string> using namespace Leadwerks; int screenwidth = GetSystemMetrics(0); int screenheight = GetSystemMetrics(1); Window* window; Context* context; World* world; Model* thePlayer; Camera* theCam; // declare functions that we need, they are used once so I made them inline for faster code. inline void Start(); inline void loop(); inline void DrawInfo(); //crouch, crawl, jog, run // used for mouse handling Vec3 mausdata = Vec3(0, 0, 0); float mausx = 0.0; float mausy = 0.0; // used for player movement Vec3 mdat = Vec3(0, 0, 0); Vec3 ppos = Vec3(0, 0, 0); Vec3 velo = Vec3(0, 0, 0); float walk = 0.0; float strafe = 0.0; float jump = 0.0; float crouch = 0.0; float strafespeed = 2.0; float movespeed = 2.4; float jumpspeed = 5.0; bool cdown = 0; bool sdown = 0; // used for mainloop bool mainloop = true; // mainfunction int main(int argc,const char *argv[]) { // hold the mainfuntion small and insert what we need with an inline function. Start(); // mainloop while (mainloop) { loop(); // Here is the most mailoop stuff if (window->Closed() || window->KeyDown(Key::Escape)) mainloop = false; //Quit if ESC is pressed Leadwerks::Time::Update(); world->Update(); world->Render(); // For holding the mainloop small put all drawing stuff inside an inline function. DrawInfo(); context->Sync(true); } return 0; } // Inline functions we use only once. inline void DrawInfo() { // For the first, all the drawing stuff in this funtion. context->SetBlendMode(Blend::Alpha); context->SetColor(1.0, 1.0, 1.0); context->DrawText("Camera Rotation: " + theCam->GetRotation().ToString(), 2, 2); context->DrawText("Player Position: " + thePlayer->GetPosition().ToString(), 2, 40); context->DrawText("Player Position: " + std::to_string(ppos[0]), 2, 70); context->DrawText("Player Position: " + std::to_string(ppos[1]), 2, 100); context->DrawText("Player Position: " + std::to_string(ppos[2]), 2, 130); context->DrawText("UPS: " + String(Time::UPS()), 2, 160); context->DrawText("Velocity: " + thePlayer->GetVelocity().ToString(), 2, 190); // a way to check if the player is not on ground, for possibly later use. if (thePlayer->GetAirborne()) { context->DrawText("In the air", 2, 220); } context->SetBlendMode(Blend::Solid); } inline void Start() { // Window //window = Window::Create("",0,0, 2560, 1440, Window::Fullscreen); //window = Window::Create("", 0, 0, screenwidth, screenheight, Window::Fullscreen); window = Window::Create("", 0, 0, screenwidth, screenheight); context = Context::Create(window); window->Maximize(); // The world world = World::Create(); // The player that we need for "First Player Sight" thePlayer = Model::Create(); thePlayer->SetPhysicsMode(Entity::CharacterPhysics); thePlayer->SetPosition(0, 5, 0); thePlayer->SetMass(1); // Put the camera as a child to the player, so we can move and look up and down separately theCam = Camera::Create(thePlayer); theCam->SetPosition(0,1.65,0); // Font we use for drawing operations Font* font = Font::Load("Fonts/Arial.ttf", 12); context->SetFont(font); // Map //Map::Load("Maps/TheWorld.map"); Map::Load("Maps/BetonMap.map"); // <<<<----- put here your mapname ............................................. } inline void loop() { ppos = thePlayer->GetPosition(); mausdata = window->GetMousePosition(); mausx += (mausdata[0] - window->GetWidth() / 2) * 0.1; mausy += (mausdata[1] - window->GetHeight() / 2) * 0.1; window->SetMousePosition(window->GetWidth() / 2, window->GetHeight() / 2); // not Shift: walk if (!window->KeyDown(Key::Shift) && sdown == 1) { sdown = 0; movespeed = 2.4; } //Shift: run if (window->KeyDown(Key::Shift) && sdown == 0) { sdown = 1; movespeed = 5.0; } // not CTRL: stay if (!window->KeyDown(Key::ControlKey) && cdown == 1) { cdown = 0; movespeed = 3.0; ppos = thePlayer->GetPosition(); theCam->SetPosition(0,1.65, 0); crouch = 0; } // CTRL: crouch if (window->KeyDown(Key::ControlKey) && cdown == 0) { cdown = 1; movespeed = 1.0; crouch = 1; ppos = thePlayer->GetPosition(); theCam->SetPosition(0,0.95,0); } // Walk with movespeed when press Key W walk = (window->KeyDown(Key::W) - window->KeyDown(Key::S)) * movespeed; strafe = (window->KeyDown(Key::D) - window->KeyDown(Key::A)) * strafespeed; // check if player is on ground, this means velo[1] = "y direction" has no velocity = 0 // in this way the player kann not jump if he is already in the air. velo = thePlayer->GetVelocity(); if (velo[1] == 0.0) { jump = window->KeyHit(Key::Space) * jumpspeed; } else { jump = window->KeyHit(Key::Space) * 0.0; } if (mausy > 50.0) mausy = 50.0; if (mausy < -90.0 ) mausy = -90.0; thePlayer->SetInput(mausx, walk, strafe, jump, crouch); //void SetInput(float angle, float move, float strafe = 0, float jump = 0, const bool crouch = false, const float maxaccel = 1, const float maxdecel = 0.5, const bool detailed = false, const float maxrotationspeed = 5.0) theCam->SetRotation(mausy, 0, 0); mdat = theCam->GetRotation(); } The next step I will made is to put the code into a class. Use the C Key for toggle crouching and use the CTRL for faster runnig, the I have walk with Key W, jogging with Shift+W and running with CTRL and W.
  9. Bytecroc

    Key down

    For C++ this is possibly a suggestion for the problem with some missing key functions http://www.leadwerks.com/werkspace/topic/14370-is-there-a-scan-code-function/
  10. Textures are paintet with a program like Paint or Gimp and much more or Texture Generators for Walls Floors. With Blender you give them a UV map
  11. what did you understand to animate something ? I often read something in the web of animations, and see the whole scene was meant. Something like let us roll a ball over a parkour or something. Or in OpenGL Tutorial something like, now let us program some animations and the result is moving some static objects around. in this case programming is needed. But only animating a model in it's movement or gesture is done by an rigging and skeletton or keyframe animation software like Blender, Fragmotion, 3D Studio Max, Milkshape Anim8tor and much more. If your friend must animate some character with an animation software only, then no programming is needed, but must he also move the characters inside a scene for a movie, then yes, but ask him if C/C++ is needed or if a script language or something else is used.
  12. OK, I was not informed about the speed of LUAJit or better I have not recognized that there is a difference to LUA. LUA was for me a interpreted script and so automatically slow. This let me think about some tests I will made in the near future. And possibly a BASIC to LUA converter.
  13. Nice game! Now what could be better. Pressing ESC should not immediately quit the game. I am too often press it to go out of the inventory or crafting window and the game quits. Starting with rain ? Rain should have a better quality. OK, now starting again and hope I did not press ESC OK, I am dead. Night should be dark but not only black.
  14. This gives you an overview how slow lua is against C/C++ http://benchmarksgame.alioth.debian.org/u64/which-programs-are-fastest.html
  15. If you are not sure if C++ is the right language then the only thing is what you can do to find out if it's the right language --> do it. go to this side, it's the best side to learn the STL http://www.cplusplus.com/reference/ possibly you want to learn how a file would be opened and read some binary code from it go to fstream then fstream or ifstream and click read look here http://www.cplusplus.com/reference/istream/istream/read/ you see examples for nearly each function in the STL library which is the base for C/C++ programming. start programming with console programs. To get a feeling for 3D programming you can try for the first the now free Blitz3D, it's outdated, but gives you a good feeling for 3D programming. And to switch to Leadwerks then is very easy. And don't let you suggest that you can not program an animation program, you can if you want. My first program (beside the small things I have done to learn 3D programming) was AnimB3D, not very successful but I have also stopped the development because Pacemaker and CharacterFX becomes free. And I would not say I am a professional programmer but I do what I want to do and not what other say what I can do or should do. But it's your choice if you do it or not. You can if you want, that's the truth. My first C++ program was a compiler or let's say converter that let me program C++ in BASIC Style, I did not like the == and the semicolon ; at he end of the line, I did not like curly braces { } to mark blocks, but to learn C++ was the only way to get the freedom to program what I want, today there is possibly the choice of C# but I stay with C++. So I go my way with BASIC to C++ but it's still C++ at the end. And you will find your way, if you say ony C not C++ is my way then you should go that way.
  16. I am also have buyed over a year ago the book from Anton Gerdelan Amazon Kindle. It's much better to understand than Object Oriented C++ OpenGL Tutorials. But I got surprisingly a job offered in Nov 2014 so I buyed also Leadwerks Pro, I do not use LUA, the C++ OO structure in Leadwerks is not that much complicate. There are some small examples in the API reference, compile them and look how they work. It's a good training. And LUA is not easier in my opinion.
  17. It's because english is not my natural language and I can not explain like I would do in my natural language what the problem 100% is. Sometimes there are hidden functions or functions I have not detected inside Leadwerks, and before I use WinAPI things I thought I ask in forum. For single key query there is GetKeyState() or GetAsyncKeyState() a better choice.
  18. Sorry that I reply that late, but I have had the problem in the past and Sync(false) solved not my problem. But NVidia Driver has swiched on in all programs VSync on. I put that off in NVidia Settings global. Possibly interessting for other users.
  19. Extended to translate also in ScanCode #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } unsigned long VKtoSC(unsigned long virtual_key) { return (static_cast<unsigned long>(::MapVirtualKeyEx(virtual_key, 4, ::GetKeyboardLayout(::GetCurrentThreadId())))); } bool App::Start() { window = Window::Create(); context = Context::Create(window); Font* font = Font::Load("Fonts/Comic.ttf", 36, Font::Smooth); context->SetFont(font); font->Release(); return true; } bool App::Loop() { if (window->Closed() || window->KeyDown(Key::Escape)) return false; context->SetColor(0, 0, 0); context->Clear(); context->SetColor(1, 1, 1); //Display some centered text std::string text; std::string text2; int sc; BYTE keys[256]; //GetKeyState(0); GetKeyboardState(keys); for (int i=0; i < 255; i++) { if (keys[i] & 0x80) { text = "VirtualKeyCode: " + String(i); sc = VKtoSC(i); text2 = "ScanCode: " + String(sc); //keys[i] = 0; //break; } } Font* font = context->GetFont(); int screenwidth = context->GetWidth(); int screenheight = context->GetHeight(); int x = (screenwidth - font->GetTextWidth(text)) / 2; int y = (screenheight - font->GetHeight()) / 2; context->SetBlendMode(Blend::Alpha); context->DrawText(text, x, y); context->DrawText(text2, x, y+50); context->SetBlendMode(Blend::Solid); context->Sync(); return true; }
  20. Thank you Undac and Athos for your answers and suggestions, my WinAPI knowledge to replacing the windows wndproc with an own procedure is a bit to low but the WinAPI did have some nice functions I tested. This one works for the first. It registers all Keys and also the mousebuttons I think this are also not scancodes but I can make a list for each user to register his own keys. Or receiving letters for input messages, like in a chat. possibly replace the "comic.ttf" with "arial.ttf" #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } bool App::Start() { window = Window::Create(); context = Context::Create(window); Font* font = Font::Load("Fonts/Comic.ttf", 36, Font::Smooth); context->SetFont(font); font->Release(); return true; } bool App::Loop() { if (window->Closed() || window->KeyDown(Key::Escape)) return false; context->SetColor(0, 0, 0); context->Clear(); context->SetColor(1, 1, 1); //Display some centered text std::string text; BYTE keys[256]; //GetKeyState(0); GetKeyboardState(keys); for (int i=0; i < 255; i++) { if (keys[i] & 0x80) { text += String(i); keys[i] = 0; //break; //yes or no? The numbers for the right ALT Key and others are lower with break. } } Font* font = context->GetFont(); int screenwidth = context->GetWidth(); int screenheight = context->GetHeight(); int x = (screenwidth - font->GetTextWidth(text)) / 2; int y = (screenheight - font->GetHeight()) / 2; context->SetBlendMode(Blend::Alpha); context->DrawText(text, x, y); context->SetBlendMode(Blend::Solid); context->Sync(); return true; }
  21. For Keyboard Input I can not found a way to get german umlaut like "ä,ö,ü,Ä,Ö,Ü,ß" also the Left- and right- Alt Key I am missing in the Keylist. I miss in the API- Reference a function to get the scancode from a keypress.
  22. For C++ programmes it would be good to have some other import and export files. Why not use the assimp imort library, the some import and export files could be used. http://assimp.org/
  23. I have had such problems with other programs and self compiled console programs in the past. I thought Win10 was the problem, but it was the Avast Free Antivirus. I think mostly problematic is there the deep screen modus. I swiched off the antivirus protection when I compile or will run something I have compiled.
  24. I use the first and found also the second, but not tested. http://www.helpndoc.com/ or https://dumah7.wordpress.com/2009/02/17/kel-chm-creator-v-1-4-0-0/
×
×
  • Create New...