project reality header
Go Back   Project Reality Forums > PR:BF2 Mod Forums > PR:BF2 Community Modding
17 Nov 2019, 00:00:00 (PRT)
Register Developer Blogs Project Reality Members List Search Today's Posts Mark Forums Read
PR:BF2 Community Modding Making or wanting help making your own asset? Check in here

Reply
 
Thread Tools Display Modes
Old 2018-03-05, 11:18   #1
[R-DEV]​rPoXoTauJIo
PR:BF2 Developer
Supporting Member

rPoXoTauJIo's Avatar
Default [Coding] bf2 meshes python lib

https://github.com/rPoXoTauJIo/BF2Mesh

Thing i've been developing for a while, using bytehazard reference and his direct help, initially started as a script to get textures names out of meshes.

I've been interested in what can i do with meshes directly without touching 3dsmax&re-export, so after tests on evil boxes i've attempted to merge kits geometries in single skinnedmesh:

So far that i'm not seeing reports on weird issues with canadian kits, merge been successful

Another thing i've been doing lately is trying to merge staticmeshes which is working so far:

However, in game it works a bit strange :



Apparently, if player camera doesn't see collision of object - it doesn't render it. As i've merged only visible mesh, and left object using stock collision, it's disappear once i look away from collision mesh.

Ultimate goal of this project is to make it automated script for mappers to merge their statics into bigger arrays, hopefully decreasing amount of drawcalls due to lego structure.
For now it's nowhere from being complete, and serves more of purpose me learning mesh structure, but by small steps i'll hope it will work flawlessly someday

assetruler69: I've seen things you smurfs wouldn't believe. Apaches on the Kashan. I watched burned down tank hulls after the launch of the single TOW. All those moments will be lost in time, like tears in rain.
Time to give up and respawn.
rPoXoTauJIo is offline Reply With Quote
Old 2018-03-05, 11:19   #2
[R-DEV]​rPoXoTauJIo
PR:BF2 Developer
Supporting Member

rPoXoTauJIo's Avatar
Default Re: [Coding] bf2 meshes python lib

* Reserved for mesh struct explanation

assetruler69: I've seen things you smurfs wouldn't believe. Apaches on the Kashan. I watched burned down tank hulls after the launch of the single TOW. All those moments will be lost in time, like tears in rain.
Time to give up and respawn.
rPoXoTauJIo is offline Reply With Quote
Old 2018-03-15, 22:32   #3
[R-DEV]​rPoXoTauJIo
PR:BF2 Developer
Supporting Member

rPoXoTauJIo's Avatar
Default Re: [Coding] bf2 meshes python lib

Some little progress on generating collision meshes.


Unfortunately, it's crashing editor for some reason.
For those mocked boxes i've set y/z/adata in collision lods to zeroes, but those are unknowns unfortunately.

assetruler69: I've seen things you smurfs wouldn't believe. Apaches on the Kashan. I watched burned down tank hulls after the launch of the single TOW. All those moments will be lost in time, like tears in rain.
Time to give up and respawn.
rPoXoTauJIo is offline Reply With Quote
Old 2018-03-16, 11:01   #4
[R-DEV]​rPoXoTauJIo
PR:BF2 Developer
Supporting Member

rPoXoTauJIo's Avatar
Default Re: [Coding] bf2 meshes python lib

Works ingame, crashing when getting close to objects, weird.

assetruler69: I've seen things you smurfs wouldn't believe. Apaches on the Kashan. I watched burned down tank hulls after the launch of the single TOW. All those moments will be lost in time, like tears in rain.
Time to give up and respawn.
rPoXoTauJIo is offline Reply With Quote
Old 2018-03-17, 15:12   #5
[R-DEV]​rPoXoTauJIo
PR:BF2 Developer
Supporting Member

rPoXoTauJIo's Avatar
Default Re: [Coding] bf2 meshes python lib

More weird stuff from exporter.



Technically those meshes should be equal in terms of vertex numbers(both 4 vertices & 2 tris for simple plane, it's just 2nd being with offset and smaller), but for "segmented" mesh there's additional strange faces:
Quote:
face[2]: (0, 3, 3, 0)
face[3]: (3, 0, 0, 0)
Which corresponds to:
Quote:
vertex[0]: -0.5, 0.0, -0.5
vertex[3]: -0.5, 0.0, 0.5
vertex[3]: -0.5, 0.0, 0.5

vertex[3]: -0.5, 0.0, 0.5
vertex[0]: -0.5, 0.0, -0.5
vertex[0]: -0.5, 0.0, -0.5
Makes absolutely no sense from geometry point of view for me

assetruler69: I've seen things you smurfs wouldn't believe. Apaches on the Kashan. I watched burned down tank hulls after the launch of the single TOW. All those moments will be lost in time, like tears in rain.
Time to give up and respawn.
rPoXoTauJIo is offline
Last edited by [R-DEV]rPoXoTauJIo; 2018-03-17 at 15:17..
Reply With Quote
Old 2019-09-27, 22:17   #6
[R-DEV]​rPoXoTauJIo
PR:BF2 Developer
Supporting Member

rPoXoTauJIo's Avatar
Default Re: [Coding] bf2 meshes python lib

So i disbanded idea of modifying colmeshes, as they doesn't seems to affect fps.
Merging visible meshes produced interesting results through.

Sample is T-city of 15x15 blocks, each 10 floors
1x housingblock_1_groundfloor_v2
8x housingblock_1_midfloor_v1
1x housingblock_1_topfloor

Starting fps would be ~50 on my testing machine(i7-6700hq + 960m)


For a test i merged merges meshes as follows:
Single mesh for all top&ground floors


Single mesh for blocks of middlefloors


Result were more than i expected, 50->180 fps.


===============================
shit code examples for anyone interested
https://pastebin.com/bQVYQuhK
https://pastebin.com/e23UXBeB

assetruler69: I've seen things you smurfs wouldn't believe. Apaches on the Kashan. I watched burned down tank hulls after the launch of the single TOW. All those moments will be lost in time, like tears in rain.
Time to give up and respawn.
rPoXoTauJIo is offline Reply With Quote
Old 2019-09-28, 00:37   #7
Rabbit

Rabbit's Avatar
Default Re: [Coding] bf2 meshes python lib

lightmaps will be shit

Rabbit is offline Reply With Quote
Old 2019-09-28, 10:01   #8
[R-DEV]​AlonTavor
PR:BF2 Developer
PR Server License Administrator
Default Re: [Coding] bf2 meshes python lib

Quote:
Originally Posted by Rabbit View Post
lightmaps will be shit
y tho? why are they affected? aren't lightmaps just a 2d array of light-levels for the terrain?
or are you saying it'll take 20 years to generate them?
AlonTavor is online now Reply With Quote
Old 2019-09-28, 10:40   #9
[R-DEV]Mineral
PR:BF2 Lead Designer
Supporting Member
PR Server License Administrator

Mineral's Avatar
Default Re: [Coding] bf2 meshes python lib

Objects needs lightmaps too. One texture for each LOD. Which are all combined into atlas files. We have a maximum size limit of 2048 (can probably be 4096?) for out atlas files for lightmaps. Given you can't split a lightmap between atlas files it means that the maximum size for one 'object' is likely to be 2048 (or 4096). Using a single 2048 texture to lightmap extremely large combined statics such as one display here will end up looking rather crappy most likely.

But the T-Shapes are mostly a POC I suppose. Theoretically we could for example do it much better and for example perhaps split the maps into grids and merge them that way? Then a single 2048 'might' be enough.

I mostly worry about the filesize increase such a implementation would bring

Mineral is offline Reply With Quote
Old 2019-10-01, 14:00   #10
[R-DEV]​Rhino
PR:BF2 Developer
Supporting Member

Rhino's Avatar
Default Re: [Coding] bf2 meshes python lib

Ye this basically significantly cuts down the draw calls while the tri count stays the same and BF2 isn't very good at handling draw calls but still, not a realistic solution for most cases but there are some cases where combing objects into one objects is a good idea.

Quote:
Originally Posted by Mineral View Post
We have a maximum size limit of 2048 (can probably be 4096?)
I'm pretty sure you can go up to 4096 but would probably have to be done manually and I wouldn't advise it unless really necessary.


Also for merging all those buildings together means that when you get close to the edge of just one of those buildings, you will be drawing them all in LOD0 detail rather than only the nearest building/floor in LOD0 and the others drawing in much lower detail so for doing huge blocks like this isn't a good idea for that reason as a lot of PCs will really struggle with drawing all that high detail that the player can't appreciate since they are nowhere near the details to see them and will for some PCs, have a bigger negative impact than removing all the draw calls. So ye, I would limit how many objects you put together to really just one building, unless it was something like a surrounding terrain block of buildings that were already low detail to start with. There is also the small issue of losing the flexibility of having different types of floors done the original way but they are only different colours in the case of the T buildings, which are the only ones really to do this so not really much lost but ye, something to consider.

Rhino is offline Reply With Quote
Reply


Tags
bf2, coding, lib, meshes, python
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 19:58.