Jump to content

SpiderPig

Members
  • Posts

    2,348
  • Joined

  • Last visited

Everything posted by SpiderPig

  1. So our own zips can't be read from, but the default data.zip can with our own files?
  2. I'm loading a few data files in c++ and have included these files in the publishing process (below) lod, data and strc are just binary files. lua, mat, mdl, phy, shader, tex, ttf, wav, ogg, mpd, cfg, lod, dat, strc Am I correct in saying that loading with ordinary commands like fopen_s() won't be able to access the encrypted files in data.zip? I can think of a few workarounds, like not including those files in the data.zip and adding them manually after publishing (won't be encrypted but it's not really needed for these I guess), or maybe using the internal Leadwerks file commands? Is there a way the publisher can change or retrieve the password used for encryption?
  3. Great work! How much memory does the voxel grid use and is it stored on the GPU? I'm thinking about large open worlds; would you generate all voxel data at large voxel sizes, then simply update in real-time the higher density voxel grid around the camera?
  4. SpiderPig

    Voxel Madness

    Yeeesssss! ? This would be amazing. Hopefully your idea pans out. Good luck!
  5. SpiderPig

    Voxel Madness

    Either way, Turbo is already a massive improvement on Leadwerks. It's always fun to see what things might be possible
  6. SpiderPig

    Voxel Madness

    Sounds like you've thought of everything ? How has the shadow distance been affected? Is there still a limit to how far away it can be shown from the camera? I'm guessing the further away from the camera the more voxels that need to be checked...?
  7. SpiderPig

    Voxel Madness

    I think the voxel data Josh has made is only for lighting calculations and not part of the mesh class... you will probably have to make your own voxel generator for things like terrain, which wouldn't be too hard. Another question for Josh - can the voxel data be instanced along with an Instanced entity? Or will each instance need recalculating? ?
  8. SpiderPig

    Voxel Madness

    That would be amazing. Can't wait
  9. SpiderPig

    Voxel Madness

    Sounds good. Will there also be a quality setting? Like a voxel density or something... I'm just thinking out loud
  10. SpiderPig

    Voxel Madness

    Looking awesome, can wait to try it out! Are the voxels calculated at load time? How does this work for meshes that are created by code and are edited through out run time?
  11. I've got a kinematic joint to position the sliders parent, but I'm not sure how SetFriction() is meant to stop any rotation from occurring. According to the docs I thought angular friction would be set to 0 to stop any rotation but that didn't seem to work. I think it's because I'm using a slider and am letting gravity pull it down till it collides with the terrain. Then as I move the sliders parent with the kinematic joint the sliders child drags and causes the parent to rotate not matter what the friction setting is. Can the slider be parented to the kinematic joint? Or is this an incorrect use of the slider...?
  12. Looks good. Can't wait to try it out.
  13. That's okay. I'd say Josh needs to have a look at it.
  14. You use the plane like a Vec3. The constructor can take three positions to define it, then you can use functions like GetNormal() and DistanceToPoint(). I imagine the positions as forming a triangle, and the plane extending out from that in all directions. Vec3 p1 = Vec3(-1.0f, -1.0f, -1.0f); Vec3 p2 = Vec3(0.0f, 1.0f, 1.0f); Vec3 p3 = Vec3(1.0f, 0.0f, 0.0f); Plane plane = Plane(p1, p2, p3); Vec3 normal = plane.GetNormal(); float distance = plane.DistanceToPoint(2, 1, 0); I'm not sure how to define it using the other constructors as shown in the example in Transform::Plane()
  15. Here's my attempt so far at making my own character controller. The reason for this is because I'm using multiple gravity directions in the same world and the current controller doesn't like gravity in any direction other than down the y axis. The problem I'm having is getting the controller to stay constrained to the up axis, when you move it with speed (shift key) you'll see that it drags across the terrain and bounces around. I'm not sure how to correctly use the joints settings to stop this kind of movement. Any help is appreciated. #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } float lookspeed = 0.1, looksmoothing = 0.5; Vec3 mousepos; float jointpos = 1; bool wireframe = false; Joint* joint; Entity* parent; Joint* k = nullptr; Entity* child; 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); parent->SetMass(1); parent->SetGravityMode(false); child = Model::Box(); child->SetColor(1.0, 0.0, 0.0); child->SetShape(Shape::Box()); child->SetMass(1); child->SetGravityMode(true); k = Joint::Kinematic(0, 0, 0, parent); joint = Joint::Slider(0, 0, 0, 0, 1, 0, child, parent); joint->EnableLimits(); joint->SetLimits(-5, 5); joint->SetMotorSpeed(100); Model* mdl = Model::Load("Models\\Terrain.mdl"); mdl->SetScale(20, 20, 20); mdl->SetPosition(0, -3, 0); Shape* shp = Shape::PolyMesh(mdl->GetSurface(0)); mdl->SetShape(shp); mousepos = window->GetMousePosition(); window->SetMousePosition(context->GetWidth() / 2, context->GetHeight() / 2); 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; } } float cx = Math::Round(context->GetWidth() / 2); float cy = Math::Round(context->GetHeight() / 2); Vec3 mpos = window->GetMousePosition(); window->SetMousePosition(cx, cy); mpos = mpos * looksmoothing + mousepos * (1 - looksmoothing); float dx = (mpos.x - cx) * lookspeed; float dy = (mpos.y - cy) * lookspeed; Vec3 camrot = camera->GetRotation(); camrot.x += dy; camrot.y += dx; camera->SetRotation(camrot); mousepos = mpos; float _time = Time::GetSpeed(); float camspeed = 0.2f * _time; if (window->KeyDown(Key::Shift) == true) { camspeed = camspeed * 5.0f; } if (window->KeyDown(Key::W) == true) { camera->Move(0, 0, camspeed); } else if (window->KeyDown(Key::S) == true) { camera->Move(0, 0, -camspeed); } if (window->KeyDown(Key::A) == true) { camera->Move(-camspeed, 0, 0); } else if (window->KeyDown(Key::D) == true) { camera->Move(camspeed, 0, 0); } if (window->KeyDown(Key::T) == true) { camera->Move(0, camspeed, 0); } else if (window->KeyDown(Key::G) == true) { camera->Move(0, -camspeed, 0); } Vec3 p = parent->GetPosition(true); Vec3 r = parent->GetRotation(true); float speed = 0.1f; if (window->KeyDown(Key::Shift) == true) { speed = 1.0f; } if (window->KeyDown(Key::Up)) { k->SetTargetPosition(p.x, p.y, p.z + speed); } if (window->KeyDown(Key::Down)) { k->SetTargetPosition(p.x, p.y, p.z - speed); } if (window->KeyDown(Key::Left)) { k->SetTargetPosition(p.x - speed, p.y, p.z); } if (window->KeyDown(Key::Right)) { k->SetTargetPosition(p.x + speed, p.y, p.z); } //Jumping...? joint->SetAngle(jointpos); if (joint->MotorEnabled() == true) { joint->DisableMotor(); } if (window->KeyHit(Key::Space)) { joint->EnableMotor(); } 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; } Other links; https://www.leadwerks.com/community/topic/17437-physics-constraints/ Project.zip
  16. I think I once had this problem... I think it was something to do with my display settings, nothing wrong with Leadwerks. Or even update your graphics driver. I have a feeling some antivirus software can cause odd things to happen as well. AVG did that to me. EDIT : Just saw its been solved. I think its bed time. ?
  17. I've not created metal materials before but if not the "diffuse+normal+specular" shader it might be the "diffuse+normal+specular+env" shader, where texture5 is a cube map that the object will reflect, perhaps making it look more like metal.
  18. You would use Sin () and Cos () to find the x and y position. Is alpha a constant? Like 90°? Do the red and blue positions vary in the third dimension as well? Or are you looking for the 2D position only of the black?
  19. Is this the correct way to use it? //Header.h class CustomActor : public Actor { public: virtual void UpdatePhysics(); }; //CPP.cpp void CustomActor::UpdatePhysics() { //Do Stuff }
  20. #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?
  21. You can only add lua script in that box.
  22. 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?
×
×
  • Create New...