EntityOrder - Workaround for FPS Gun Meshes
BlitzMax Forums/MiniB3D Module/EntityOrder - Workaround for FPS Gun Meshes
| ||
First post ever, g'day guys! The Issue: MiniB3D can not render multiple meshes with Z-Buffering in a order specified by a custom value. Even the EntityOrder command for Blitz3D states :- "Setting an entity's order to non-0 also disables z-buffering for the entity" The Solution: Adding a value to TMesh and TCamera which links the two together. This means that when the engine renders each camera only TMeshes with the same value as that camera are added to the rendering list and thus rendered. If you combine this solution with the TCamera.CameraClsMode function you can easily match your gun meshes to a secondary camera, still have lighting affect your gun AND not have to use CameraRange to cut out the rest of the world. Warning: I am not a expert in OpenGL or Programming and this fix may make things slower, or cause alot of experts to be unhappy as it might not be the correct way to do things or make them frown, so sorry and please suggest any better ways. Down to the juicy stuff, to apply this fix you will need to modify MiniB3D and in particular these files: TEntity.Bmx and TGlobal.Bmx ( SO BACK THEM UP FIRST!!! ) We will start with TEntity.Bmx, open it up and at the beginning of your file or at the end, wherever you like we're going to add a "_scene" value. Field _scene:Int = 0 Next we are going to add a handy little function to set our new value with the ability to recursively set child entities with the same value. I added this at the bottom of my TEntity.Bmx (before the EndType line). Method SetScene(scene:Int, children = False) Self._scene = scene If children Then For Local ent_c:TEntity=EachIn Self.child_list ent_c.SetScene(scene, True) Next EndIf EndMethod Right that is all for TEntity.Bmx, we can save that and move on to TGlobal.Bmx, we're going to modify the "RenderCamera" method, about 1/4 of the way down is the following line: For Local mesh:TMesh=EachIn TEntity.entity_list We want to add the following line below it: If mesh._scene <> cam._scene Then Continue And people, that is it! Save TGlobal.Bmx and re-build your MiniB3D module (hopefully with success!). Now to utilise the code you create 1 camera for your scene, and 1 for your hud, except with the hud camera you would "SetScene 2". Additionally to your gun parent you would "SetScene 2, True" Here is a couple of screenshots: before fix - ![]() after fix - ![]() Let me know what you think and if it works for you! |
| ||
if you dont want to do this you could make the player's entityradius bigger but then enemies will hit you unfairly and you may not be able to go through doors. |
| ||
For those who have given a go at modifying MiniB3D and tried the above changes, I have recently made another one which might come in handy for everybody. Within TEntity.Bmx I added a new variable: Field _wireframe = FalseThis then gets inherited in TMesh and TCamera as they are each based on TEntity Type. What this allows us to have is a per entity Wireframe render and a per Camera Wireframe render. We will next modify TGlobal.Bmx and write some if statements that will allow us to render a whole camera in wireframe or per entity based on the camera they're set to. Find the following line in TGlobal.Bmx UpdateSprites(cam,render_list) ' rotate sprites with respect to current camAnd we will add the following: If cam._wireframe glPolygonMode(GL_FRONT,GL_LINE) Else glPolygonMode(GL_FRONT,GL_FILL) EndIfFurther more below that within the 'For EachIn' loop we will add the following lines: If Not cam._wireframe Then If mesh2._wireframe Then glPolygonMode(GL_FRONT,GL_LINE) Else glPolygonMode(GL_FRONT,GL_FILL) EndIf EndIfbefore the line: mesh2.Update()So in the end each TEntity(TCamera, TMesh, etc...) anything that inherits TEntity will have a _wireframe property allowing the mesh/camera to be rendered in Wireframe. |
| ||
Of course you can just use illusion and bypass EntityOrder issues. You can scale the mesh small and position it in front of the camera so as to make the mesh look normal size - yet, in fact, it is small and also (being small) doesn't pass through walls, etc. |
| ||
True, however it will still get affected. |