TheZ Posted November 8, 2022 Share Posted November 8, 2022 (edited) Hey, need a help here with rendring order. How we can manage which object will be shown on top of another? Usually if we place/built something (a tile) it will be shown on a very top at this square and will be overlapped by next on the same square. But what is we want to change this rendering order later on - how to achieve that? I tried some functions of a IsoObject class like renderlast, or setRenderYOffset - but doesn't look to be used propely. Could anyone give any suggestions or options regarding that? thank you. Edited November 8, 2022 by TheZ Tchernobill 1 Link to comment Share on other sites More sharing options...
TheZ Posted November 11, 2022 Author Share Posted November 11, 2022 want to up my question cuz a really hot topic and still valid. Link to comment Share on other sites More sharing options...
stuck1a Posted December 4, 2022 Share Posted December 4, 2022 (edited) There are different types of IsoObjects. For example, there are Tiles. Tiles can be a flooring, which will be rendered at the very back of course. Then there are Special tile objects. They will overlap Floorings. The can be stacked, and will be rendered in exactly that order (newest to oldest) Then there are SpecialObjects which are most commonly solid structures or moveables. The will be rendered over tiles, of course. Then there are many special types, defined by their properties like wallType etc. Basically, they are also special objects, but due to their very own render functions, they will be rendered however it is implemented. (see ISWoodenWall.lua or ISWoodenStairs.lua as example) For know, I did not see any z-Layer implementation exposed to Lua, so I guess you will have to change the objects manually. Something like changing their pointers and force re-render would be the cheapest way, I guess. The worst would be to remove the objects and recreate them in the correct order. Should still be performant as long as it only happens occasionally (e.g. when a player has finished building something) Edited December 4, 2022 by stuck1a TheZ 1 Link to comment Share on other sites More sharing options...
TheZ Posted December 11, 2022 Author Share Posted December 11, 2022 (edited) Thank you stuck1a for your reply! Your rendering order explanation is very useful. The only part is unknown for me now is the implementation of pointer swaping and the force re-rendering just after on. I understand it like we shoud take our object initially assigned to variable "a" and assign it be variable "b", then assign something else to the variable "a" or just nulify it and then assign the object back from variable "b" to the variable "a" - but I really not sure that it is what you mean. It would be really cool if you could give a short example here. Anyway, thanks again for your effort. Edited December 11, 2022 by TheZ Link to comment Share on other sites More sharing options...
stuck1a Posted December 12, 2022 Share Posted December 12, 2022 17 hours ago, TheZ said: Thank you stuck1a for your reply! Your rendering order explanation is very useful. The only part is unknown for me now is the implementation of pointer swaping and the force re-rendering just after on. I understand it like we shoud take our object initially assigned to variable "a" and assign it be variable "b", then assign something else to the variable "a" or just nulify it and then assign the object back from variable "b" to the variable "a" - but I really not sure that it is what you mean. It would be really cool if you could give a short example here. Anyway, thanks again for your effort. Hey TheZ, As soon as I get out of the office I'll see if I can come up with a decent solution. Link to comment Share on other sites More sharing options...
stuck1a Posted December 13, 2022 Share Posted December 13, 2022 (edited) Didn't find time yesterday. Just played around a bit - it seems like simply re-rendering isn't possible (only with many detours), so I think re-creating the object should be the better way. You could try to re-use existing object, so you don't have to construct a new one. Here is a quck and dirty example: local OnKeyPressed = function(key) local oPlayer = getSpecificPlayer(0) local oSquare = oPlayer:getSquare() -- set some dummy structures for testing (Key R) if key == 19 then local ISChair = ISSimpleFurniture:new('Wooden Chair', 'carpentry_01_36', 'carpentry_01_36') ISChair:create(oSquare:getX(), oSquare:getY(), oSquare:getZ(), false, 'carpentry_01_36') local ISTable = ISSimpleFurniture:new('Small Table with Drawer', 'carpentry_02_0', 'carpentry_02_0') ISTable:create(oSquare:getX(), oSquare:getY(), oSquare:getZ(), false, 'carpentry_02_0') end -- switch objects (Key U) if key == 22 then local aObjects = oSquare:getObjects() local oFoundChair local oFoundTable -- check if we have the two objects on the square, we want to switch for i=0, aObjects:size() do local oCurr = aObjects:get(i) if instanceof(oCurr, 'IsoThumpable') then if oCurr:getName() == 'Wooden Chair' then oFoundChair = oCurr elseif oCurr:getName() == 'Small Table with Drawer' then oFoundTable = oCurr end end end -- now remove the existing chair and re-create it in front by using the stored object pointer if oFoundChair and oFoundTable then oSquare:transmitRemoveItemFromSquare(oFoundChair) oSquare:AddSpecialObject(oFoundChair) oFoundChair:transmitCompleteItemToServer() end end end Events.OnKeyPressed.Add(OnKeyPressed) Edited December 13, 2022 by stuck1a TheZ 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now