Jump to content

thehankinator

Members
  • Posts

    436
  • Joined

  • Last visited

Posts posted by thehankinator

  1. 10 minutes ago, macklebee said:

    Just curious, but what do you have that is defining colors in 0-255? The editor does when you use the color picker but those values are converted to the 0-1 scale. Everything in LE now except for the color picker itself (which I suspect is due to the OS), specifically uses 0-1, so what are you doing/using that would require that specifically where you couldn't just make a simple function to handle it?

    I am creating emitters in code. It's convenient for me to define them in the editor then convert them to code. I don't have to do it this way but a division operator for a Vec4 isn't an uncommon thing in a vector library. Nothing I am doing requires this operator, I've already got a workaround. 

    • Like 1
  2. I am not able to divide a Vec2 or Vec4 but Vec3 works fine. Seems like this should work, am I wrong?

    local Case1 = Vec2(164, 0) / 255 --Doesn't work
    local Case2 = Vec3(164, 0, 0) / 255 --Works
    local Case3 = Vec4(164, 0, 0, 255) / 255 --Doesn't work

    Error message for Case1 and 3 is:

    Attempt to perform operation on an invalid operand

  3. Using this page https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_Emitter_SetMaxScale

    It isn't clear how many arguments this Lua function accepts. Syntax section states 1 argument

    Quote

    Syntax

    • SetMaxScale(number maxscale)

    But the example has 2 arguments

    if (window:KeyDown(Key.Up)) then
            maxscale = maxscale + 1
            emitter:SetMaxScale(maxscale,maxscale) 
        elseif (window:KeyDown(Key.Down) and maxscale > 0) then
            maxscale = maxscale -1  
            emitter:SetMaxScale(maxscale,maxscale) 
        end
    

    The C++ documentation is consistent in that there is a single argument. However the header file "Emitter.h" has two functions listed

    virtual void SetMaxScale(const float x);//lua
    virtual void SetMaxScale(const float x, const float y);//lua

    Seems like both Lua and C++ have 1 and 2 arguments variations but only the 1 argument variant is documented and Lua example shows 2 arguments.

    • Thanks 2
  4. Calling GetAngle() on a sprite set to Billboard mode is always returning 0. Here is how I set it up:

    1) Create a sprite

    2) Set it to Billboard mode

    3) Assign a material

    4) Put this script on it

    function Script:UpdateWorld()
    	System:Print(self.entity:GetAngle())
    end

    The billboard appears to be working (always facing the camera) but the script always prints 0. I tried casting it to a sprite ( tolua.cast(self.entity,"Sprite") ) and calling GetAngle on that but no change. Any idea what I am doing wrong?

  5. Sorry if this has already been posted but it seems like Material:SetPickMode is broken. For example this code:

    local mat = Material:Create()
    	
    local shader = Shader:Load("Shaders/Model/diffuse+alphamask.shader")
    mat:SetShader(shader)
    shader:Release()
    	
    mat:SetPickMode(true)

    Crashes with this error:

    attempt to call method 'SetPickMode' (a nil value)

    Seems like this should work, this is the documentation for the function:

    https://www.leadwerks.com/learn?page=API-Reference_Object_Asset_Material_SetPickMode

  6. I don't know what the signature of CreateBox() is nor what Entity and Model classes look like but this compiles for me under VS2015 and MinGW 5.3.0 (Debug and Release for both). Entity had to have a virtual function to make it polymorphic.

    #include <memory>
    
    class Entity
    {
    public:
    	virtual ~Entity()
    	{}
    };
    
    class Model : public Entity
    {
    public:
    	virtual ~Model()
    	{}
    };
    
    
    template <class T, class Y>
    std::shared_ptr<T> Cast(std::shared_ptr<Y> o)
    {
    #ifdef DEBUG
    	return std::dynamic_pointer_cast<T>(o);
    #else
    	return std::static_pointer_cast<T>(o);
    #endif
    }
    
    std::shared_ptr<Entity> CreateBox()
    {
    	return std::dynamic_pointer_cast<Entity>(std::make_shared<Model>());
    }
    
    int main()
    {
    	std::shared_ptr<Entity> entity = CreateBox();
    	std::shared_ptr<Model> model = Cast<Model>(entity);
    
    	return 0;
    }

     

  7. 10 hours ago, gamecreator said:

    Make sure you have the proper vegetation shader on the rock.  Seems like it should already be set up but just in case.  The appearing/disappearing thing may be because the billboards aren't rendering properly.

    That was it! Thanks!

    It would be nice if the editor would give a warning or message when the user selects an object that contains a material that does not have a vegetation shader defined.

     

    • Upvote 1
  8. I picked up The Zone DLC and started poking around with vegetation. After placing various rocks I get these really weird blue/white monoliths. When looking around, they appear to randomly move around or disappear/appear. I've trashed my map and started over a couple times, restarted LE they keep coming back.

    Also, the rocks in the screenshot disappear as the camera approaches them but appear when backing up. 

    vegetation.png

    Test.map

  9. 1 hour ago, Josh said:

    I know what you are talking about, I just need to adjust the zoom angle.

    Make sure you are calling VSync(false) or don't call it at all.

    I'm working on making the controllers load all the sub-parts as separate limbs so the triggers and buttons will animate when you move them.

    It's still choppy without calling and also setting vsync to false

  10. It loaded up ok but it was choppy(I don't know what the frame rate was but without VR and vsync it's over 350) and the models on the very left and right edge of the view "popped" in, like maybe they were culled for a narrower field of view or something. I tried to take a screenshot but the window was just blank. Is there a way to have Leadwerks mirror the scene in Rift on to my monitor?

  11. On 9/8/2017 at 1:44 AM, Josh said:

    With the pro version you could create your own Lua implementation, but if you are asking can you change Lua around and keep the Leadwerks Lua features, the answer is no.

    Leadwerks 5 will update Lua to the latest (5.3) and will no longer use LuaJIT.

    Have you profiled Lua vs LuaJIT in Leadwerks? I'm curious if there will be performance impact. LuaJIT comparison tool claims pretty substantial gains over regular Lua (http://luajit.org/performance_x86.html).

  12. You could do something hacky like this. Do this for like 10 or 20 points around the player using sin() and cos()  multiplied by the distance you want (10 in your example) from the player's global location. Use World:Pick() from that point to the player, this tell you if this point has line of sight to the player. If your level has walls then this will also tell you if you are on the map or not. If your level does not have walls you could do another World:Pick() from the point to the same point with a big -y value to see you are over an object. If your level is not flat this can get complicated, if there are no ceilings you could use World:Pick() with some big +y value to a big -y value to find the ground, then do the line of sight pick from that point to the player. You wouldn't want to run this every frame but it should work.

    • Upvote 1
  13. I never liked the "Error list" window, what's in the "Output" window regarding these errors? What does the line of code in Leadwerks that is causing the error look like?

    It seems like these errors don't all have the same cause. I am able to to reproduce the 6th error like this:

    std::shared_ptr<Point> blah;
    std::shared_ptr<Triangle> blah2;
    
    blah = blah2;

    Which is pretty obvious what's wrong there. The error given is:

    1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(579): error C2440: '<function-style-cast>': cannot convert from 'const std::shared_ptr<Triangle>' to 'std::shared_ptr<Point>'
    1>  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(579): note: No constructor could take the source type, or constructor overload resolution was ambiguous
    1>  C:\Junk\Src\Thing.cpp(155): note: see reference to function template instantiation 'std::shared_ptr<Point> &std::shared_ptr<Point>::operator =<Triangle>(const std::shared_ptr<Triangle> &) noexcept' being compiled
    1>  C:\Junk\Src\Thing.cpp(155): note: see reference to function template instantiation 'std::shared_ptr<Point> &std::shared_ptr<Point>::operator =<Triangle>(const std::shared_ptr<Triangle> &) noexcept' being compiled
    1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(579): error C2228: left of '.swap' must have class/struct/union

     

  14. 14 hours ago, tomis13lack said:

    I got everything fixed except one thing. Thui appears now and everything but the mouse is still locked when this happens. This problem did not occur before. Also if you click on some of the buttons the game crashes

    It sounds like you are missing some of the other changes to Main.lua. Take a look at this my THUI thread, verify that steps 1-5 have been completed properly in your Main.lua file. These changes will get reverted every time there is an update to the stock Main.lua so you will need to check after every update, I wish this wasn't the case but c'est la vie.

     

  15. std::for_each() is part of STL so part of the language. Range based for loops are the syntax as Rick said(but seriously, use auto&&, otherwise it's a copy every iteration). Both achieve the same thing but the STL version is a little more awkward to use but you can specify a begin and end if you wanted to.

     

    EDIT: i forgot to mention that ranged base for loops are also part of the language as of c++11 iirc

  16. When using ranged based for loop like, you usually want to make the variable a reference.

     


    std::vector<std::string> myvector = { "Bob", "Jane", "Fred" };

    for( auto&& element : myvector )
    {
    Print(element);
    }
    [/Code]

     

    Otherwise it's going to copy your string. The double && basically ensures it's a reference not a copy.

×
×
  • Create New...