Jump to content

Roland

Members
  • Posts

    2,953
  • Joined

  • Last visited

Everything posted by Roland

  1. I keep on getting the error "Asset map value is different" in the Errors tab, although everything seems to work. A bit irritating as that removes focus from the Output tab when running. No errors on the Output tab when loading. Okay then I though. Lets delete the map and make a new one. Same result and its really not a complicated map. A Terrain and some boxes and spheres. I have the latest Beta. Any idea on how to get rid of this annoying thing?
  2. Right down at the right bottom you have 'Who's Online' which is a chat tool
  3. Lerp is a linear interpolation. Maybe that would work better?
  4. Title says it all If answer is YES I'm disappointed as it shouldn't in my humble opinion
  5. As long as the current "have it all" version is available
  6. Will be there if I manage to figure out what time that is in northern Sweden
  7. https://github.com/alrusdi/leadwerks-blender-exporter
  8. Thanks to Rick that told me how to do local value = entity.script.param
  9. If have an entity in my scene with a script attached that holds some parameter, something like this Script.param = 10--int and then in my LUA program at some point picks that entity. Is is possible to access the script.param then (at this stage I have only the entity) I made a temporary solution for this that works by using the Get/SetKeyValue like this Script.param = 10--int function Script:Start() self.entity:SetKeyValue("param", self.param) end which allows me to get that param event though I only have the entity local value = entity:GetKeyValue("param") However this feels a bit odd. Maybe there is some better way ? Note: In C++ I could do this using my LuaBridge class, but this project is pure LUA
  10. Roland

    Enshrouded World

    Looks really fantastic
  11. Looking forward to that Aggror. I also missed that component post that you mentioned. Really great stuff
  12. This is the most interesting blog post I have read in years. I really get so many ideas on how to make my design better by reading this. I here by declare Rick my hero of the month if not the year. As some of you know I have been programming for many many years and because of that I have got stuck in old habits (like my player above) without even thinking if there's a better way to do it. Of course the component concept has come in my way now and then but in a more abstract and non-game format. Now Rick's words on this subject woke my interest as I know he's a clever guy and it was presented in a more hands-on format. I will absolutely adopt to this starting immediately and if I get drunk Rick is responsible
  13. Yes. Thanks for the advice. I'm aware that events have a small time-penalty
  14. Thanks Rick. You have really opened my eyes to this new concept. Also many thanks for taking the time to more or less type down a mini tutorial. Now with this new concept in mind I will start to break the player into components. I will keep you guys informed on how that goes, either here or in my blog. Reading this blog post by you Rick almost gave me religious experience, so thanks again
  15. Aaah... Good questions Rick. Now I understand where you are going. Very very nice approach. To answer you question about the mouse events (and all other events) I can confirm that I'm an idiot :D. As its now events are caught by the player and used for controlling other components. That might be needed in some rare cases, but what you are saying is of course a much much better way of doing it. Lets say the MouseInput send events about mouse movement (onmousemove..). Those events could as an example be used to control the camera rotation. So instead of catching the mouse movement event in the Player code and rotate the camera (or call some Camera-object method), its better to have a Camera-Object that catches the MouseEvents directly. The player does not have to be involved in this. Am I on the right track here Rick?? Regarding my Player its like you Player was before doing the cleanup you are describing... which means some 1000 lines of code. To much to describe here and of course a BIG hint that I also have to make some cleanup by using Components. Thanks for you interesting view on this. I really appreciated it. My player .cpp is far to big and complex to share here. However I can show the header file and as you see its to complex now. You can see the events handlers for various events (the methods starting with on.....). I will go through this as see what I can come up with class Player : public GameItem, public GameTimerClient, public ToolBarListener, public GameActorClient, public AreaClient, public PickDetectorClient, public CollisionDetectorClient, public CarryListener { const float WalkSpeed = 1.5; const float MaxWalkDistace = 6.0; const float WalkDecay = 0.1; const float MouseSense = 15.0; const float MinPitch = -60.0; const float MaxPitch = 60.0; const float PitchSmooth = 4.0; const float PitchSpeed = 20.0; const float Turnsmooth = 4.0; const int HealthSpeed = 2; const int HealthAdd = 2; const int HealthDec = 1; const float DoubleClickMsec = 400; const float JumpForce = 8; const int StartDelay = 4; const float CameraFOV = 70; const float CameraMinRange = 0.5; const float CameraMaxRange = 500; const float EyeHeight = 1.8; const int MaxCarryWeight = 20; const float CarryDrop = 2; const float CarryMaxDiff = 0.5; // --- LUA UserInterface* _userinterface; std::string _pick_decal_material; std::string _pick_decal_red_material; // --- INTERNAL bool _is_started; long _startdelay; bool _firstTime; Leadwerks::Vec3 _start_pos; Leadwerks::Font* _bigFont; bool _wait_for_left_mouse_release; Leadwerks::Listener* _soundlistener; Leadwerks::Sound* _music; Leadwerks::Source* _soundsource; GameTimer _timer; Leadwerks::Entity* _pointed_at; Leadwerks::Entity* _socket; // --- Health int _cur_health; long _healthTimer; std::vector<int> _healthDec; // --- Messages to user MessageWindow _msgwin; // --- Health & Toolbar HealthBar _healthbar; ToolBar _toolbar; // --- Cursor Cursor _cursor; // --- Picking items PickDetector _pick_detector; // --- Colliding with things CollisionDetector _collision_detector; // --- Carry things GameItem* _carriedItem; Leadwerks::Vec3 _carryrotation; Leadwerks::Vec3 _carryposition; int _carry_collsion; float _lastMZ; void grabItem(GameItem* gi); void carryItem(); void dropItem(); // --- Tool Leadwerks::Pivot* _toolhandle; // --- FlashLight FlashLight _flashlight; // --- Camera Leadwerks::Camera* _camera; Leadwerks::Vec3 _camera_rot; float _cameraPitch; Leadwerks::Vec2 _mousediff; void _on_started(); void _pick_detection(); void _triggerhandler(const Leadwerks::PickInfo& pickinfo); void _checkpointhandler(const Leadwerks::PickInfo& pickinfo); // Mouse double click bool _leftclicked; long _lastclick; // Walking float _move; float _walkdistance; bool _walking; Leadwerks::Vec3 _walkstart; // Screen size int _scx; int _scy; void updateCam(); void updateMove(); void die(); protected: void onCollision(Leadwerks::Entity* e, const Leadwerks::Vec3& pos, const Leadwerks::Vec3& normal, float speed); void onUpdateWorld(); void onUpdatePhysics() {} void onPostRender(Leadwerks::Context* ct); public: Player(Leadwerks::Entity* entity); ~Player(); // --- GameItem void init(LuaBridge& lb); void onRestore(); void onactivated(); // --- GameTimerClient void onMsec100(); void onSec(); void onMinute(); // --- ToolbarClient void onToolbarFull(ToolBar* tb); void onToolbarAdded(ToolBar* tb, Tool* t); void onToolbarSelected(ToolBar* tb, Tool* t); void onToolbarUsing(ToolBar* tb, Tool* t); void onToolbarShown(ToolBar* tb); void onToolbarHidden(ToolBar* tb); void onToolbarSelectChange(ToolBar* tb, Tool* t); // --- HealthClient void onZeroHealth(Health* h); void onWarnHealth(Health* h); void onOkHealth(Health* h); void onFullHealth(Health* h); // --- GameActorClient void onActorAtStart(GameActor* a); void onActorAtEnd(GameActor* a); void onActorDone(GameActor* a); void onActorPicked(GameActor* a); // --- AreaClient void onAreaEnter(Area* a); void onAreaLeave(Area* a); // --- CarryClient void onCarryGrabbed(Carry* item); void onCarryDropped(Carry* item); // --- PickDetectorClient bool onPickedHealth(Health* item); bool onPickedTool(Tool* item); bool onPickedCarry(Carry* item); bool onPickedEnergy(ToolEnergy* item); bool onPickedActor(GameActor* item); bool onPointingAt(GameItem* ent); // --- CollisionDetectorClient bool onCollidedHealth(Health* item); bool onCollidedTool(Tool* item); bool onCollidedCarry(Carry* item); bool onCollidedEnergy(ToolEnergy* item); bool onCollidedActor(GameActor* item); bool onCollidedArea(Area* item); // Inherited via CarryListener virtual void onCarryCollision(Carry * item, const Leadwerks::Vec3 & pos) override; };
  16. I'm probably missing something. You have a component that can act upon its own data by methods called from the outside world. The component can also send events to the outside world (the user of the component). How is this done? Either by callbacks or listeners that have a method that can handle (act on) such an event. Is there a third option? That sounds interesting. I'm using a combination of LUA and C++. The event-components are in C++ and uses inheritance, goes something like this (a simple fictional sample to illustrate how I'm doing it). Is there a better way to do this I'm certainly willing to adapt that into my code. // inherits this to be a listener for MouseInput events class MouseEventListener { public: // called when use left clicks mouse virtual void onMouseLeftClick() = 0; // called when use right clicks mouse virtual void onMouseRightClick() = 0; }; // A mouse input component class MouseInput { vector<MouseEventListener*> _listeners; MouseInput() {} // register a new listener void register( MouseEventListener* listener ) { _listeners.push_back(listener); } // unregister a listener void unregister( MouseEventListener* listener ) { remove( _listeners.begin(), _listeners.end(), listener ); } // must be called frequently void update() { if( Window::GetCurrent()->MouseHit(0) ) { for each ( auto listener in _listeners ) { listener->onMouseLeftClick(); } } if( Window::GetCurrent()->MouseHit(1) ) { for each ( auto listener in _listeners ) { listener->onMouseRightClick(); } } } // reset the mouse void reset() { Window::GetCurrent()->FlushMouse(); } }; class Player: public MouseEventListener { // Mouse input component MouseInput _mouse; public: // MouseEventListener void onMouseLeftClick() { // handle left mouse clicks } void onMouseRightClick() { // handle right mouse clicks } // Player void init() { // start listening to mouse // you can stop doing this by // _mouse.unregister(this) _mouse.register(this); } void update() { _mouse.update(); } };
  17. Very interesting reading. I really like your idea, especially with the events. Im using a similar approach by having some classes act as every generators where classes can register them self as event listeners. The listeners then inherits abstract event interfaces with methods like 'onMouseClick' ... If understood your system correctly we are more or less having the same approach.
  18. Solved now. I created the camera in C++ instead of loading a camera created in the editor and then it works. auto cam = Camera::Create(); 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");
  19. 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' } };
  20. 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; } } };
  21. The camera is a camera created in the editor and I'm 100% sure that the loaded entity is that camera as I use it my FPS player code later on
  22. 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.
  23. Its quite surprising that Leadwerks doesn't have official supported Fog as thats more or less needed in most programs. In some less and in some more. So please Josh! Come on - give us some fog.
×
×
  • Create New...