Jump to content

reepblue

Developers
  • Posts

    2,490
  • Joined

  • Last visited

Posts posted by reepblue

  1. How would I save a table without it saving like below?

    "{\n\t\"Console\": 112,\n\t\"Fullscreen\": 122,\n\t\"InGameControls\":\n\t{\n\t\t\"Crouch\": 17,\n\t\t\"Jump\": 32,\n\t\t\"MoveBackward\": 83,\n\t\t\"MoveForward\": 87,\n\t\t\"MoveLeft\": 65,\n\t\t\"MoveRight\": 68,\n\t\t\"QuickSpin\": 81,\n\t\t\"Use\": 69,\n\t\t\"ZoomIn\": 257,\n\t\t\"ZoomOut\": 258,\n\t\t\"axes\":\n\t\t{\n\t\t\t\"Camera\": 0\n\t\t},\n\t\t\"mousecursor\": 0\n\t},\n\t\"Pause\": 27,\n\t\"Quick Load\": 117,\n\t\"Quick Save\": 116,\n\t\"Screenshot\": 113,\n\t\"Terminate\": 35,\n\t\"mousecursor\": 1\n}"

     

  2. While doing simple mapping, I've ran into an issue with my session where the editor thinks I'm holding control when selecting objects when I'm not. This results in multiple objects getting selected unintentionally. 

    Also, clicking the void doesn't deselect the objects.

  3. Nevermind, loading is fine, saving is the remaining issue. 

    For the record, this is how I'm saving my json files.

        bool JSON::Save(nlohmann::json& j3, const std::string& path)
        {
            std::ofstream o(path);
            o << std::setw(4) << j3 << std::endl;
    
            return (bool)FileSystem::GetFileType(path);
        }

     

  4. This is for a Leadwerks project and over the few months I've fell in love with tableplusplus and I've used it for my input system in Ultra Engine. I'm trying to port it to Leadwerks but it seems my implementation of the loading and saving isn't correct. My JSON parsers work fine but no data loads, and tables don't save as pretty as when using the json library alone.

    Anything I'm doing wrong?

    #ifdef __TABLE_PLUS_PLUS
        table Table::Load(const std::string& path)
        {
            auto j3 = JSON::Load(path);
            table t(j3);
            return t;
        }
    
        table Table::Load(Stream* stream)
        {
            auto j3 = JSON::Load(stream);
            table t(j3);
            return t;
        }
    
        bool Table::Save(table& t, const std::string& path)
        {
            nlohmann::json j3 = t.to_json();
            return JSON::Save(j3, path);
        }
    
        table Table::Load(const std::wstring& path)
        {
            auto j3 = JSON::Load(path);
            table t(j3);
            return t;
        }
    
        table Table::Load(shared_ptr<FileStream> stream)
        {
            auto j3 = JSON::Load(stream);
            table t(j3);
            return t;
        }
    
        bool Table::Save(table& t, const std::wstring& path)
        {
            nlohmann::json j3 = t.to_json();
            return JSON::Save(j3, path);
        }
    #endif

     

  5. This looks like a Leadwerks game. If it uses the default main script, then ruining the application via command line using -fullscreen should do it. You probably also want to use +screenwidth and +screenheight followed by the number of your desired resolution.

  6. Some of these are corrections to design choices, others are bug. These have been noted in the last workshop and I'm making this topic so it doesn't get lost.

    1. Can not select items in vertex edit mode. 

    2. When in scale mode, the selected object is solid white in the 2D view. It's the faces that get highlighted orange to reflect the 3D editing tools. My suggestion is that the entire object should be highlighted in the 2D viewports to make it more consistent with the other modes.

    3. You can still get tall brush outlines when trying to create a brush when the last selected object was a point entity.

    4. You still can't delete string entries from the World Settings. 

    5. You should be able to save a prefab like saving a normal map. We discussed other systems that can be worked on later, but for now it might just be better just to mimic Leadwerks for now.

    6. Selection mode (Feature, just noting it here.)

    These 6 things should be accounted for 0.9.5! 

    • Thanks 1
  7. If you edit the FirstPersonControls component to with the below, then create a prefab using it, the mouse look will be sluggish. I've spent 4 hours last night trying to figure this out and I can confirm this is a bug with the prefab system. If you were to assign this to an entity normally, it'll work fine. 

    The Raw mouse code tends to work ok regardless. 

    #pragma once
    #include "UltraEngine.h"
    #include "FirstPersonControls.h"
    
    using namespace UltraEngine;
    
    FirstPersonControls::FirstPersonControls()
    {
    	name = "FirstPersonControls";
    }
    
    void FirstPersonControls::Start()
    {
    	auto entity = GetEntity();
    	entity->SetPhysicsMode(PHYSICS_PLAYER);
    	if (entity->GetMass() == 0.0f) entity->SetMass(78);
    	entity->SetCollisionType(COLLISION_PLAYER);
    	camera = CreateCamera(entity->GetWorld());
    	camera->SetPosition(0, eyeheight, 0);
    	camera->SetRotation(0, 0, 0);
    	camera->SetFov(70);
    	currentcameraposition = camera->GetPosition(true);
    	freelookrotation = entity->GetRotation(true);
    }
    
    void FirstPersonControls::Update()
    {
    	Vec3 movement;
    	float jump = 0;
    	bool crouch = false;
    	auto entity = GetEntity();
    	auto window = ActiveWindow();
    	if (window)
    	{
    		auto cx = Round((float)window->GetFramebuffer()->GetSize().x / 2);
    		auto cy = Round((float)window->GetFramebuffer()->GetSize().y / 2);
    		auto mpos = window->GetMousePosition();
    		window->SetMousePosition(cx, cy);
    		auto centerpos = window->GetMousePosition();
    
    		if (freelookstarted)
    		{
    			float looksmoothing = mousesmoothing; //0.5f;
    			float lookspeed = mouselookspeed / 10.0f;
    
    			if (looksmoothing > 0.00f)
    			{
    				mpos.x = mpos.x * looksmoothing + freelookmousepos.x * (1 - looksmoothing);
    				mpos.y = mpos.y * looksmoothing + freelookmousepos.y * (1 - looksmoothing);
    			}
    
    			auto dx = (mpos.x - centerpos.x) * lookspeed;
    			auto dy = (mpos.y - centerpos.y) * lookspeed;
    
    			freelookrotation.x = freelookrotation.x + dy;
    			freelookrotation.y = freelookrotation.y + dx;
    			camera->SetRotation(freelookrotation, true);
    			freelookmousepos = Vec3(mpos.x, mpos.y);
    		}
    		else
    		{
    			freelookstarted = true;
    			freelookrotation = camera->GetRotation(true);
    			freelookmousepos = Vec3(window->GetMousePosition().x, window->GetMousePosition().y);
    		}
    
    		float speed = movespeed;// / 60.0f;
    		bool jumpkey = window->KeyHit(KEY_SPACE);
    		if (entity->GetAirborne())
    		{
    			speed *= 0.25f;
    		}
    		else
    		{
    			if (window->KeyDown(KEY_SHIFT))
    			{
    				speed *= 2.0f;
    			}
    			else if (window->KeyDown(KEY_CONTROL))
    			{
    				speed *= 0.5f;
    			}
    			if (jumpkey)
    			{
    				jump = jumpforce;
    			}
    		}
    		if (window->KeyDown(KEY_D)) movement.x += speed;
    		if (window->KeyDown(KEY_A)) movement.x -= speed;
    		if (window->KeyDown(KEY_W)) movement.z += speed;
    		if (window->KeyDown(KEY_S)) movement.z -= speed;
    		if (movement.x != 0.0f and movement.z != 0.0f) movement *= 0.707f;
    		if (jump != 0.0f)
    		{
    			movement.x *= jumplunge;
    			if (movement.z > 0.0f) movement.z *= jumplunge;
    		}
    		crouch = window->KeyDown(KEY_CONTROL);
    	}
    	entity->SetInput(camera->rotation.y, movement.z, movement.x, jump, crouch);
    		
    	float eye = eyeheight;
    	float y = TransformPoint(currentcameraposition, nullptr, entity).y;
    	float h = eye;
    	if (y < eye) h = Mix(y, eye, 0.5f);
    	currentcameraposition = TransformPoint(0, h, 0, entity, nullptr);
    	camera->SetPosition(currentcameraposition, true);
    }
    
    //This method will work with simple components
    shared_ptr<Component> FirstPersonControls::Copy()
    {
    	return std::make_shared<FirstPersonControls>(*this);
    }
    
    bool FirstPersonControls::Load(table& properties, shared_ptr<Stream> binstream, shared_ptr<Map> scene, const LoadFlags flags)
    {
        if (properties["mousesmoothing"].is_number()) mousesmoothing = properties["mousesmoothing"];
        if (properties["mouselookspeed"].is_number()) mouselookspeed = properties["mouselookspeed"];
        if (properties["movespeed"].is_number()) movespeed = properties["movespeed"];
    	return true;
    }
    
    bool FirstPersonControls::Save(table& properties, shared_ptr<Stream> binstream, shared_ptr<Map> scene, const SaveFlags flags)
    {
    	properties["mousesmoothing"] = mousesmoothing;
    	properties["mouselookspeed"] = mouselookspeed;
    	properties["movespeed"] = movespeed;
    	return true;
    }

     

    testplayer.zip

  8. Two things:

    1. When creating a camera at the world's position (0,0,0) the entity will exist in the world but will not show up in the editor.

    2. The map will break and will be unrecoverable as the camera when a prefab includes a camera. The camera/prefab is no longer listed in the entity so you can't just delete it. 

    3. Also it seems that the camera can't be the first object to be made. You need another point entity in the scene first.

    camprefab.zip

  9. 1 hour ago, SpiderPig said:

    Thankyou.  This will speed up development for me by exporting straight from blender.  🙂

    If you can start with a simple .collider export extension for blender, I'm sure people would appreciate it!

    • Upvote 3
×
×
  • Create New...