Jump to content

Roland

Members
  • Posts

    2,953
  • Joined

  • Last visited

Posts posted by Roland

  1. class MouseSensorListener
    {
    public:
       virtual void onmousewheelHit( float distance ) = 0;
    };
    class MouseSensor
    {
    private:
       float _lastMZ;
       MouseSensorListener _listener;
    public:
       void init()
       {
        _listener = nullptr;
        _lastMZ = Window::GetCurrent()->GetMousePosition().z;
       }
       void register( MouseSensorListener* listener )
       {
        _listener = listener;
       }
       void unregister()
       {
        _listener = nullptr;
       }
       void update()
       {
        auto mz = Window::GetCurrent()->GetMousePosition().z;
        if ( mz != _lastMZ )
        {
    	    // mouse wheel moved
    	    // distance is mz-_lastMZ
    	    if( _listener )
    	    {
    	    _listener->onmousewheelHit(mz-_lastMZ);
    	    }
    	    _lastMZ = mz;
        }
       }
    };
    class SomeClass :
       public MouseSensorListener
    {
    public:
       void init( MouseSensor* sensor )
       {
       sensor->register(this);
       }
       void onmousewheelHit( float distance )
       {
        // Mouse wheel moved 'distance'
       }
    };
    
    

  2. You have to check the mouse position Z component

     

    class SomeClass
    {
    float _lastMZ;
    ...
    
    void Init()
    {
     _lastMZ = Window::GetCurrent()->GetMousePosition().z;
    }
    
    void UpdateWorld()
    {
     auto mz = Window::GetCurrent()->GetMousePosition().z;
     if ( mz != _lastMZ )
     {
    		 // mouse wheel moved
    		 // distance is mz-_lastMZ
    		 _lastMZ = mz;
     }
    }
    };
    

    • Like 1
    • Upvote 1
  3. I can understand that all kinds of special effects should be user supplied. However fog is such a basic need. All engines I have tested have fog as that is the normal way to minimize the camera range. Well it's up to Josh to decide. Fog in my view is not an effect. It's a basic feature.

    • Upvote 5
  4. Hi

     

    What's needed to get the Fog shader included in Shadmar's PP-shader pack working in C++.

     

    I thought this was the only thing to do but the result is no fog at all. Adding the fog to the editor works and gives a nice fog, but only in the editor

     

    auto cam = reinterpret_cast<Camera*>(lb.getEntity("cam")); // this is my camera
    cam->AddPostEffect("Shaders/PostEffects/02_pp_fog_by_klepto.lua");
    cam->SetKeyValue("fog_fogrange", "0,20");
    cam->SetKeyValue("fog_fogcolor", "0.57,0.53,0.55,1.0");
    cam->SetKeyValue("fog_fogangle", "5,21");
    cam->SetKeyValue("fog_fogislocal", "0");
    

     

    In editor

    post-395-0-52870500-1487845961.png

     

    In C++ program

    post-395-0-75874300-1487845970.png

  5. I will be honest: I fully expected to see 3d models of Swedish people when I clicked on this topic. Really wondered how you would have captured the essence of a swedish person.

    Hahaha.. sorry for that biggrin.png

     

    Here is a fully normal Swede ... (me?)

     

    post-395-0-01641100-1487358259_thumb.jpg

    • Upvote 5
  6. I've added a new Font::Load() command that will accept any string of characters as the glyphs to pull from the font. However, I do not exactly know how this will work. It's all kind of strange to me, being a native English speaker everything else seems like some weird exception. biggrin.png

    Anything that can be tested?

  7. My code supports the game in different languages (actually English and Swedish for now, but its quite easy to add more languages). Switching language works just fine. However Ascii-characters above 0x7F are not rendered correctly or not at all. Is the any workaround or fix for this (C++)?

     

    Question for Josh? Will Leadwerks be able to deal with extended character sets in the future?

  8. Script.box = "" --entity

    Script.material = nil

     

    function Script:Start()

    self.material = Material:Create()

    self.material:SetColor(1,0,0)

    end

     

    function Script:Collision(entity, position, normal, speed)

    self.box:SetMaterial(self.material)

    end

  9. To use C++ you should open Projects\Windows\<your projectname>.sln in Visual Studio and compile.

    If you don't want Main.Lua to be executed you can go for a more clean approach and replace main.cpp

    with something like this

     

    #include "Leadwerks.h"
    #include <sstream>
    
    using namespace Leadwerks;
    
    int main(int argc, const char *argv[])
    {
       // Initialize Steamworks (optional)
       // Steamworks::Initialize();
    
       // Create the app window
       Window* window = Window::Create("My Game", 0, 0, 1024, 768, Window::Titlebar);
    
       // and some context to draw on
       Context* context = Context::Create(window, 0);
       if (context == nullptr)
       {
           return 1;
       }
    
       // The world containg all objects
       World* world = World::Create();
    
       // Load a map into the world
       if (!Map::Load( "Maps/start.map" )
       {
           return 2;
       }
    
       // Loop until window is closed or user presses ESCAPE
       bool showstats = false;
       while (!window->KeyDown(Key::Escape) && !window->Closed())
       {
           Time::Update();
           world->Update();
           world->Render();
    
           context->SetBlendMode(Blend::Alpha);
           showstats = window->KeyHit(Key::F11) ? !showstats : showstats;
           if (showstats)
           {
               ostringstream fps;
               fps << "FPS: " << Math::Round(Time::UPS());
               context->SetColor(1, 0, 0, 1);
               context->DrawText("Debug Mode", 2, 2);
               context->SetColor(1, 1, 1, 1);
               context->DrawText(fps.str(), 2, 2);
               context->DrawStats(2, 22);
               context->SetBlendMode(Blend::Solid);
           }
    
           context->Sync(true);
       }
    
       return 0;
    }
    
    

×
×
  • Create New...