Jump to content

Search the Community

Showing results for tags 'c++'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Categories

  • Models
    • Animals
    • Barriers
    • Characters
    • Containers
    • Environments
    • Furniture
    • Props
    • Rocks
    • Vegetation
    • Vehicles
    • Weapons
  • Materials
    • Brick
    • Cartoon
    • Decals
    • Dirt
    • Grass
    • Industrial
    • Medieval
    • Metal
    • Plastic
    • Plaster
    • Rock
    • SciFi
    • Sky
    • Signs
    • Tile
    • Stone
    • Walls
    • Wood
  • Plugins
  • Scripts
    • GUI
    • Object
    • Utilities
  • Shaders
    • Post-Processing Effects
    • Surface
  • Sounds
    • Ambience
    • Effects
    • Music
  • Tools
  • BATTLE LEAGUE's Assets
  • BATTLE LEAGUE's Mods

Blogs

There are no results to display.

There are no results to display.

Forums

  • Leadwerks
    • Technical Assistance
    • General Discussion
    • Programming
    • Game Art
    • Suggestion Box
    • Bug Reports
  • Platforms
    • Windows
    • Linux
    • OSX
  • Community
    • Showcase
    • Promotion
    • Off-topic
  • Arena Shooter's Forum
  • BATTLE LEAGUE's Topics
  • Away from Home's Zone Script
  • Away from Home's General
  • Away from Home's Zone Rigging / Modeling
  • Vec-Tec's Releases
  • Vec-Tec's Topics
  • Forth's Development
  • Forth's Game design
  • Forth's Graphics
  • Forth's Documentation
  • Forth's TODO
  • Forth's IMPORTANT
  • Forth's Screenshots
  • The uncertain world's Game Design
  • The uncertain world's Programming
  • The uncertain world's TODO
  • The uncertain world's Graphics
  • The uncertain world's Screenshots

Product Groups

  • Leadwerks
  • Model Packs
  • Gear

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Location


Interests

Found 313 results

  1. #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } float jointpos = 1; bool wireframe = false; Joint* joint; Entity* parent; bool App::Start() { window = Leadwerks::Window::Create(); context = Context::Create(window); world = World::Create(); camera = Camera::Create(); camera->Move(0, 0, -4); Light* light = DirectionalLight::Create(); light->SetRotation(35, 35, 0); parent = Model::Box(); parent->SetColor(0.0, 0.0, 1.0); Entity* child = Model::Box(); child->SetColor(1.0, 0.0, 0.0); child->SetShape(Shape::Box()); child->SetMass(1); child->SetFriction(0, 0); child->SetGravityMode(true); joint = Joint::Slider(0, 0, 0, 0, 1, 0, child, parent); joint->EnableLimits(); joint->SetLimits(-3, 1); Model* mdl = Model::Box(); mdl->SetScale(10, 0.1, 10); mdl->SetPosition(0, -2, 0); Shape* shp = Shape::Box(); mdl->SetShape(shp); return true; } bool App::Loop() { if (window->Closed() || window->KeyDown(Key::Escape)) return false; if (window->KeyHit(Key::F3) == true) { camera->GetDebugPhysicsMode() == true ? camera->SetDebugPhysicsMode(false) : camera->SetDebugPhysicsMode(true); } if (window->KeyHit(Key::F4) == true) { camera->GetDebugEntityBoxesMode() == true ? camera->SetDebugEntityBoxesMode(false) : camera->SetDebugEntityBoxesMode(true); } if (window->KeyHit(Key::F2) == true) { if (wireframe == true) { camera->SetDrawMode(0); wireframe = false; } else { camera->SetDrawMode(2); wireframe = true; } } if (window->KeyDown(Key::Up)) { parent->Move(0, 0, 0.1); } if (window->KeyDown(Key::Down)) { parent->Move(0, 0, -0.1); } if (window->KeyDown(Key::Left)) { parent->Move(-0.1, 0, 0); } if (window->KeyDown(Key::Right)) { parent->Move(0.1, 0, 0); } joint->SetAngle(jointpos); if (window->KeyHit(Key::Space)) { if (!joint->MotorEnabled()) { joint->EnableMotor(); } else { joint->DisableMotor(); } } Leadwerks::Time::Update(); world->Update(); world->Render(); context->SetBlendMode(Blend::Alpha); context->DrawText("Target position: " + String(jointpos), 0, 0); context->DrawText("Current position: " + String(joint->GetAngle()), 0, 20); context->DrawText("Motor enabled: " + String(joint->MotorEnabled()), 0, 40); context->SetBlendMode(Blend::Solid); context->Sync(); return true; } Using the arrows keys to move the sliders parent around you can see that the child takes time to realign itself. Is it possible to stop this delay?
  2. Can this be made a smart pointer so delete doesn't have to be called? int* index = new int[1024]; Or are smart pointers only for creating things like classes?
  3. What's the best way to add physics constraints to a custom player controller? For example, the cylinder shape is pulled toward gravity (which is not always straight down) then collides with an object, how do I stop little movements like sliding and twisting once it collides? As far as I can tell, the inbuilt character controller only slides if the slope is greater than max slope. And when it moves around by key press it doesn't rotate left or right or jitter as it goes over various sloped polygons. Gravity is added like so in a different class to the controller; float _force = -9.8f; entity->AddForce(_gravity->gravityDirection.x * _force, _gravity->gravityDirection.y * _force, _gravity->gravityDirection.z * _force); //gravityDirection is a normalized vector And so far for the controller I've been doing this to make it move; Vec3 _velocity = entity->GetVelocity(true); //Get the current velocity Vec3 _gravityVelocity = _velocity.Multiply(upDirection); //Find how much of the velocity is along the gravity vector Vec3 _otherVelocity = _velocity.Subtract(_gravityVelocity); //Any remaining velocity other than gravity Vec3 _forwardVelocity = _forwardVector * move; //A vector in front of the player and perpindicular to gravity Vec3 _strafeVelocity = _strafeVector * strafe; //A vector that is the cross of gravity and the forward vector (out to the side) Vec3 _jumpVelocity = upDirection * jump; //GravityDirection * -1.0f movementVector = _forwardVelocity + _strafeVelocity + _jumpVelocity; //Find total movement vector (don't normalize, magnitude is speed) entity->SetVelocity((_velocity - _otherVelocity) + movementVector, true); //Subtract othervelocity to get only what gravity is, then add any movemnt entity->SetOmega(0.0f, 0.0f, 0.0f, true); //Been using this to reduce angular rotation, not perfect though The above code has issues still, but it's my attempt at constraining it along gravity unless needed to move. This code isn't done in a physics hook, which I was wondering if that might be better? And here's a quick video showing the physic shape jittering. It doesn't translate to the camera much at the moment but it does when the jitter is larger. Also I can't move the shape along it's local axis because of the jitter and the random rotation that happens as a result of moving. https://youtu.be/ZA_UNsYCEQs Any thoughts on more accurate ways of constraining are appreciated
  4. What would cause the background to seep through the leaves? I've attached the two materials of the trees. PineTreeLeaves.mat PineTreeTrunk.mat
  5. Can the gravity direction be changed on a per object basis rather than per world? I'd like to change the direction for the character controller. Would it be possible to turn off the world gravity and add forces to the controller object, or will this mess things up? 🤔
  6. Hello, this is my first thread on this forum.😎 Today i am learning the c++ Official tutorial. But in this tutorial we need to launch our script you print hello world in c++ but it doesn't work, i have a bunch of errors (942) E1696. Any help will be appreciate 😛
  7. In my game I store six 2049 x 2049 height-maps in a dynamically created array, like this; size_t mapSize = 2049 * 2049; float* map = new float[mapSize];//approx 16mb When the app closes they are destroyed like this; delete[] map; As far as I can tell, the more data I load in this way, the app will eventually crash with a "bad_alloc" or "memory exception". It doesn't crash when it allocates for the new map I'm loading, it crashes later on when I'm allocating storage for something else. It could be another set of 16mb or the set of 50mb being allocated. Everything will be fine until I add another map. I've tried various things to rule out corrupted files and what not. I've also run the windows "memory diagnostic" just to verify that the ram is working. It should be, I've never had memory issues even with some high RAM demanding games. This is my error catching code too, the memory used is only about 700mb in total. RAM usage is nearly 5gb in the task manager out of 32gb system total. //Class header float* w1_map; float* w2_map; float* w3_map; float* w4_map; float* w5_map; float* w6_map; //class cpp void cFragment::InitMaps() { size_t _mapSize = 2049 * 2049; try { w1_map = new float[mapSize]; w2_map = new float[mapSize]; w3_map = new float[mapSize]; w4_map = new float[mapSize]; w5_map = new float[mapSize]; w6_map = new float[mapSize]; } catch (std::bad_alloc) { long _usedMemory = System::GetMemoryUsage(); std::stringstream _stream; _stream << "Used Memory : " << _usedMemory << "\nFunction : cFragment::InitMaps()\n\nClick OK to Terminate Program."; MessageBox(Window::GetCurrent()->GetHandle(), _stream.str().c_str(), "BAD ALLOC", MB_OK); exit(NULL); } } So I guess my questions are these; Has anyone else had similar issues? Are there limits to how much can be allocated to one pointer? Are there limits to the amount of consecutive calls to "new[]"? I have a 64bit system, but as I understand it L4 and visual studio are 32bit, so the most RAM that can be allocated for the entire application is 4gb?
  8. I'm currently trying to write a shader that makes every triangle of the mesh point to the position of the camera regardless of the camera's rotation. I think I can multiply the vertex positions in the vertex shader by a one of the matrices but I'm not sure which one or how. And I think the camera matrix will rotate the triangle to the same orientation as the camera and not just point to it's position? Basically I need the vertex shader (or geometry if it's easier) to do what Entity::Point() does but on each triangle and not the mesh as a whole. Anyone got any ideas on how to do this? 🤔 EDIT : I've been getting the direction the camera like this; normalize(vsModelVertexPosition.xyz - cameraposition)
  9. Today I feel good to start learning new thing in Leadwerks, that is C++ with long time bought Professional DLC (I did this before but not successful) I remember that now Leadwerks 4.4 support VS2017 then I do some simple steps Create a Blank Project in Leadwerks Editor Open Projects/Windows/TestBlankProject.sln by VS2017 Goto Build > Build Solution F7 then I get this This is what I found https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk2019?f1 But I don't understand anything on that page to find the solution (what a long content) I just want to start with a simple "Hello world" test for my new thing, but It seems not to be smooth as I expected.. Please help
  10. The Open Leadwerks Examples and Demo's (OLED) project is a community tutorial project for the Leadwerks Game Engine. The public repository contains all source code, materials, textures, models and sounds that are used and/or created in accompanying video tutorials. The repository also contains a wiki that keeps track of all the tutorials. There won't be a single script out there that does not have a good tutorial available for it. Tutorials The tutorials that will be recorded are divided in to the following categories: Editor usage Lua scripting Asset importing Youtube playlists Video tutorials will be posted on a regular basis right after I am done editing. There is no fixed date for new tutorials. Sometimes there will be severall a week, other times a week or 2 passes without any updates. : Repository The repository will exclude the default assets that come with a blank Leadwerks project. https://bitbucket.org/Aggror/projectoled Wiki The wiki contains a list of categories and recorded tutorials. https://bitbucket.org/Aggror/projectoled/wiki
  11. I'm using a buffer to draw some 2D graphics too but can't seam to clear the buffer with transparency. I looked at the forum here for the info regarding buffers and 2D drawing; I tried clearing the buffer with this code but only get a white screen; //App Start Buffer* topLevelBuffer = Buffer::Create(1024, 768, 1, 0); //Draw Loop topLevelBuffer->SetColor(1, 1, 1, 0); topLevelBuffer->Clear(); topLevelBuffer->Enable(); DrawUI(topLevelBuffer); _context->Enable(); _context->DrawImage(topLevelBuffer->GetColorTexture(), 0, 0); Anyone had any luck with clearing to a transparent buffer?
  12. When turning an entity, GetRotation() will return correct for a while then the Z axis will pop to zero for a bit before it starts reading properly again. Below is some test code showing the problem. On my current project, sometimes the Turn() function will suddenly pop to random values, but I'm unable to reproduce this here yet. I'm using the latest BETA build. #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } Model* box; bool App::Start() { window = Window::Create("Turn Test",50,50, 1024, 768); window->Show(); context = Context::Create(window); world = World::Create(); DirectionalLight* light = DirectionalLight::Create(); light->SetRotation(35, 35, 35); Camera* camera = Camera::Create(); box = Model::Box(); box->Move(0, 0, 2); return true; } bool App::Loop() { if (window->KeyHit(Key::Escape) == true) { return false; } box->Turn(0.2, 0.2, 0.2); Time::Update(); world->Update(); world->Render(); context->SetBlendMode(Blend::Alpha); std::stringstream ss; ss << "rot = " << box->GetRotation().ToString(); context->DrawShadowText(ss.str(), 20, 20); context->Sync(true); return true; }
  13. I just got the leadwerks game engine and was wondering if i needed to buy the Professional DLC to use C++, if not, how do I get started to enable C++ support? I code a lot in C++ and openGL in Visual Studios and would love to start using a game engine. Thanks for the help.
  14. I have been working on a menubar widget and it came out pretty nicely. I thought i would release it either for people to have an example of what would be possible with the widget's flexibility or just for people to use it. For now it only works in C++ since it makes use of CallFunction(). MenubarElement.lua !! Make sure when you create the widget you create it last so it will render on top !! It allows horizontal rules and submenus. How to use: (C++) Create the widget and fill the menu float scale = gui->GetScale(); mnuBarItem = Widget::Create("Name", 2 * scale, 2 * scale, 60 * scale, 26 * scale, gui->GetBase(), "Scripts/GUI/MenubarElement.lua"); mnuBarItem->SetObject("backgroundcolor", new Vec4(0.7, 0.7, 0.7, 1.0)); mnuBarItem->AddItem("Temp0"); mnuBarItem->AddItem("Temp1"); mnuBarItem->AddItem("@-");//create a horizontal rule(menu seperator) mnuBarItem->AddItem("&Submenu");//this will hold the submenu created next //create a submenu from the last added item in the list mnuBarItem->CallFunction("C_CreateSubMenuFromLastItem"); mnuBarItem->CallFunction("C_AddItemToLastSubMenu", "Sub0_A"); mnuBarItem->CallFunction("C_AddItemToLastSubMenu", "Sub0_B"); mnuBarItem->CallFunction("C_AddItemToLastSubMenu", "Sub0_C"); // mnuAccount->AddItem("Temp2"); Catching widget events ProcessEvent(Event event) { if (event.id == Event::WidgetAction) { if (event.source == mnuBarItem) { if (event.data == 0) { // } else if (event.data == 1) { // } //(event.data == 2) horizontal rule // else if (event.data == 3)//submenu { int item = event.position.x;//submenu itemidx if (item == 0) { // } else if (item == 1) { // } else if (item == 2) { // } } else if (event.data == 4) { // } } } } Also it needs a call to update somewhere in your loop. Which is just used to update some delay timing. mnuBarItem->CallFunction("C_Update");
  15. Very simply, where is the log file that shows what the console shows? I have a lot of console messages so I don't see the first part after the console cuts it off (even after scrolling up). After compiling, I have a project.log that I think Visual Studio generates and an update.log which is not it either. No other log files in my project folder or Steam Leadwerks folder. The one under AppData\Local\Leadwerks isn't it either.
  16. Hello everyone, I just playing around leadwerks c++ to learn engine. I've created a simple map with editor and save it under Maps folder. Once I try to load that map through cpp code and give path parameter as "Maps/sm.map", leadwerks can not find the map. Because engine is trying to load file at "../LeadwerksEngine/Projects/Maps/sm.map" It get fixed by adding project name to path as follows (Cube is project name) ../LeadwerksEngine/Projects/Cube/Maps/sm.map" However even so engine loads the map, engine can not load textures and etc within the map. Engine gives errors to read files with path on ../LeadwerksEngine/Projects/Textures/sometexture.tex" What did i make wrong? Could Anybody faced this problem help me?
  17. Hi all, I have problem compile a blank Leadwerks C++ project on ubuntu 16.04(64Bit) with CodeBlocs(ver.16.01). Before i used CB on Ubuntu 15.10 without problems. Strange is that after fresh install on ubuntu 16.04 I have to install also all dependecy libraries manualy (libgl1-mesa-dev...etc) even it is installed from Steam. After installation of libraries that linker wanted i got: g++ -o ../../SpaceWars.debug ../../Source/App.o ../../Source/main.o /media/mbarhon/53229DC13D856ACD/mbarhon/Steam/steamapps/common/Leadwerks/Library/Linux/Debug/Leadwerks.a -ldl -lopenal -lGL -lGLU /media/mbarhon/53229DC13D856ACD/mbarhon/Steam/steamapps/common/Leadwerks/Library/Linux/libluajit.a ../../libsteam_api.so -lX11 -lpthread undefined reference to `Leadwerks::FileSystem::StripAll(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' and this repeats for every line contain any function or varible from namespace Leadwerks. I tried to change a linker settings (directory of leadwerks lib ), but without success. Maybe I forgot to install some lib? I'm little stuck at this moment. Have someone any idea where can be the problem?
  18. Hi there, since Code::Blocks IDE is quiet unstable, buggy and occasionally freezes, especially on Linux (Ubuntu 16.10+) I have to look for another multi-platform IDE for C++. Now I mess with CodeLite IDE and it looks promising. It's possible officially support this IDE? - create a basic workspace and project, or is there someone who have some experience with this IDE in combination with Leadwerks? :-) Thanks :-)
  19. Hi, I was lately thinking about converting all my code from Lua to C++. Without knowing the size of my project, do you estaminate this is something taking very long, like more then 2 months, or is this something you could do within a week (I maybe have about 60-80 scripts) if you are working hard on it? Furthermore do you see any advantages in doing this (or better said is it worth the time) and I am not talking about speed, I much more mean the libraries that C++ offers and the more precice debugging. Thanks for your ideas and Merry Christmas.
  20. Hi guys, I'm trying to get the hang of drawing a GUI but falling rather short on actually getting anything to draw correctly. Right now I can create a button, but it only renders for a single frame when i hover the mouse over it and un-hover. So this leads me to believe that I need to perhaps render it every frame? Here's a test example: #include <Leadwerks.h> using namespace Leadwerks; int main( int argc,const char *argv[] ) { Window *window = Window::Create( "Some game", 100, 100, 400, 400, Window::Titlebar ); Context *context = Context::Create( window ); GUI *gui = GUI::Create( window ); Widget *button = Widget::Create( "Some Button", 100, 100, 100, 100, gui->GetBase(), "Scripts/GUI/Button.lua" ); button->Enable(); button->Show(); while( !window->Closed() ) { //button->Draw( 100, 100, 100, 100 ); context->Sync( true, 60.f ); } context->Release(); window->Release(); return 0; } Now, if I uncomment the Draw function I get an exception thrown on the following line. Thanks in advance for any help. EDIT: Just found this useful thread: https://www.leadwerks.com/community/topic/16487-understanding-new-gui-widgets/ Would calling Button::Redraw() every frame be the right way to go about this? And while I'm here, is there also a way to hook the event of button press in c++ or does it have to be done with lua?
  21. Probably a very simple question but if I have Light* light = DirectionalLight::Create(), how can I access shadowstagerange[4] via C++ code? I have some shadows acting weird and I think this could help, per Josh's suggestion here: https://www.leadwerks.com/community/topic/12573-directional-light-cast-shadow-distance-and-camera-zoom-important-issue/?do=findComment&comment=90577 If anyone's curious, this is what I'm looking at (shadow cutting off suddenly in a side-scroller). I already tried camera->SetMultisampleMode(32) and world->SetLightQuality(2) and setting various light ranges but nothing helped. Moving the camera left or right moves that edge left or right. If I move the camera closer, it doesn't change anything but if I move it back, the shadow gets shorter, so it's tied to the camera and/or light somehow.
  22. Manaxus

    Boost

    If I use the Boost library in my C++ code, will it break anything in Leadwerks? Cheers! -Caolan
  23. Hi guys, Trying to get your take on the correct usage of the Image class. I'm trying to change the image of a widget using SetImage(). It seems that the documentation is incomplete, missing the Image class (unless I've missed it :S). Through trying to use this class, I've noticed that Image::Load() has been commented out in Window.win32.h (perhaps it was not finished?). I instead tried something like: wstring str = L"Materials/GUI/button1.tex"; Image *image = new Image(); image->Initialize( str ); Which exited my program after attempting a run, not sure why. Log:
  24. Hi guys, What sort of technique would you recommend in order for building a footpath in a game like rollercoaster tycoon? I would like to be able to click with the mouse and place a footpath tile. Would decals be the right way to go here? Would they be efficient enough, since there could be (hypothetically) somewhat hundreds of tiles on screen at a time? Thank you.
  25. Lately I've been getting heaps of seemingly random errors. I traced a few of these problems to memory leaks which is why I started using smart pointers. But still I get random "Access Violations". Sometimes it will be inside a Leadwerks function and other times it will be in mine. I can stop the program and run again without cleaning the solution and it will crash somewhere else or it wont crash at all. Seems to be random and the only thing I think it could be is memory leaks. I'm not sure what else could cause random errors like this. Has anyone had similar problems or know of possible other causes / solutions?
×
×
  • Create New...