Openb3d - bmax question

Started by Alienhead, May 05, 2022, 14:36:48

Previous topic - Next topic

Alienhead

Hi, I'm attempting to center a window created by Openb3d Graphics3d(), I've had no luck thus far :(.

My desktop is 3840x2160/60 and I'm creating a 1920x1080 window in Openb3d, but I need it to be centered on the desktop.

Also whats the animation format? .b3d only?  Ive used Unwrap3d to save some of my meodels out as b3d, but I've yet to get any form of animation going,

Thanks for any help you might have.

markcwm

Hi Alienhead,

yes, the easy way is to use Maxgui, then you just use CreateWindow to set the window position.
Local win:TGadget=CreateWindow("OpenB3D in a GUI window",winx,winy,width,height)

I have just added this to the default minib3d/maxgui example:
https://github.com/markcwm/openb3d.docs/blob/master/minib3d/maxgui.bmx

The other way is to use the BRL Graphics function, but this was only added to NG by Brucey and only fairly recently. I tried with my old NG v0.92 but it wasn't there, basically x and y were added as 2 more parameters, I tried on Linux but it didn't work although looking in glgraphics.mod I can't see why it doesn't, it should work in Windows though but I personally would use Maxgui for windows as it gives you a lot.

Yes, .b3d is the only boned format at the moment, there's .md2 for vertex morphing, I plan to add .md3 to improve this and there has been a request for .gltf and I am interested in adding .ms3d, these would be ports. Which one would be more useful to you?

Alienhead

#2
I'm fine with any format as long as I can get it into Openb3d ( however I am a fbx fan since the format is so much more forgiving then most). I have Unwrap3d which I use to convert fbx, dae's and such to B3d format.    I have tried everything possible to get any of my animated media into Openb3d and animate, and I have failed 2 straight days.  I'll upload a b3d of my orc model, perhaps if you get time you can just give it a try and see if it works for you? Maybe im doing something wrong on my end.

PS: I have about 200 models in my collection from over the years,  the first 10 i've tried to convert to b3d and they load up and show fine, just wont animated.  I even took the stencil shadow demo from the openb3d samples and replaced the zombie with one of my own, same results. So I know its on my end, just not sure where.

If Im not trying to cast shadow,  then I would just use simple LoadAnimMesh, Extractanimseq and Animate to get it going ?  I realize theres some shader work needed on animated mesh to cast shadow ? or are models just keyframed animation ? not animated by shader?  Lol sorry for the bum rush of question.

Its just I have a game project near completion in another engine and I want to port it over to openb3d/bmax for Steam support plus Openb3d seems light years faster on older systems than the current high-end engine Im using.

Alienhead

#3
Here's another example -

Local ob:TMesh = LoadAnimMesh("media/ork.b3d")
ScaleEntity ob, 2,2,2
MoveEntity ob, 0,-2,0
TurnEntity ob, 0,180,0
Local cube_shadow5:TShadowObject=CreateShadow(ob)
Local ex = ExtractAnimSeq(ob, 1,20)
Animate ( ob, 3, 15, ex, 1000)  ' model, mode, speed, seq,  trans ( ms )

I got this model off Ron's site,   https://www.blitzcoder.org/forum/topic.php?id=840
It loads fine, hits t-pose but no animation.


Straight ole b3d model we all use to use back in the b3d days :)


Alienhead

Okay I think I understand the animation bit somewhat now,  in all the examples never is Animate () called.

Instead its controlled via    SetAnimTime(ent,anim_time#)

What puzzles me is how do you play different sequences?  Just keep track of it and use Setframe or something ?

And also, the loadtimes , copy times and what not are very slow in openb3d,  it took me 3mins 13sec to load one model then copyentity() it 100 times.

markcwm

Hi Alienhead,

well #1 I tried your orc.b3d and I think the animation in it is broken, as I tested Ork.b3d and that works OK, I also tested in Minib3d and it's the same, so you must be doing something wrong in UU3D. I can't help more as I don't really use a modeller.

#2 currently there are no working shader shadows, just stencil shadows and they work with LoadAnimMesh, I don't really like the self-shadowing though so I was looking at how to remove it but no luck yet. There is also a bug with stencil shadows that seems to happen at specific camera angles, where lines stretch across the ground, you can see one of them in this pic.


#3 You can use Animate or SetAnimTime, but your use of Animate isn't right, speed should be around 1 and trans should usually be 0. ExtractAnimSeq and LoadAnimSeq both worked fine with Ork.b3d. One thing you can't do is use ScaleMesh or RotateMesh as the animations aren't transformed as well.

#4 Like Blitz3d, CopyEntity in Openb3d shares surfaces and is a child of the original, CopyMesh is a full/deep copy of the original so uses more memory, then there is an extra command RepeatMesh which shares surfaces and animations but is not a child of the original.

#5 The slowdown is a limitation of Openb3d because of the memory management it does everything immediately, whereas in Minib3d because of the GC this gets managed better. It might be possible to try loading models in a separate thread, I haven't tried that yet but it might help.

markcwm

Hi,

I wonder are you using UpdateWorld with Animate? I checked Blitz3d and you need UpdateWorld there too.

I looked at the Devil Shadow System and it also has this bug with stretched lines at certain camera angles, it seems to be to do with the volume raytracing technique. Also stencil shadows will slow down rendering the more you use them.

I also looked at the GOM shadow system which is textured shadows, it's slower than stencil shadows but is a nice alternative for simple scenes.

Kronos

#7
To play different animations just extract all the animations using extractanimseq
eg

Local orc = LoadAnimMesh("MyPath\models\scifi_brute_gun.b3d")

orc_walk = ExtractAnimSeq(orc,395,419)
orc_idle = ExtractAnimSeq(orc,571,595)


then set whichever animation you want to play with animate

Select orc_state
Case 1
Animate(orc,1,0.5,Orc_walk,5)
Case 0
Animate(orc,1,0.5,Orc_idle,5)
End Select


You can control the interpolation between the different animations in the animate function - 5th parameter -transition so that they will switch over more smoothly.

I use to have problems with certain models with alot of animations in xors3d where copying them would take ages but never seen it in openb3d.

minib3d didnt use shaders for animation it was done by cpu so I assume openb3d is the same (could be wrong!)

I just did a test with goblin model I have using copyentity and it took no time at all to copyentity 100 of them I think openb3d is working as it should. That being the case I wouldnt recommend trying to animate that many models at once as it will be slow.

markcwm

#8
Thanks Kronos.

No, Openb3d doesn't have GPU accelerated shader animation either, as it's just a port of iMinib3d.

RepeatMesh should be faster than CopyEntity as it shares animation data whereas CopyEntity makes a new copy of animation data, so RepeatMesh is really what you should use for instancing animated models.

Edit: actually that's not quite right, CopyEntity does share animation data but has it's own copy of vertexes, RepeatMesh is similar but it has a surface for every frame of animation so this actually converts boned animation to vertex deformed.

markcwm

OK, I've got a working threads example now using Ork.b3d:
https://github.com/markcwm/openb3d.docs/blob/master/standard/loadmesh_threads.bmx

This screenie is after all the clones have loaded, but they load one at a time which gets around this problem of Openb3d loading everything immediately.

Alienhead

Jey guys thanks for the indepth reply.  I much more educated on the animation system now. :)

markcwm

#11
There is more information about RepeatMesh in the Openb3d reference guide, the latest version is here. I haven't added any of this to the Blitzmax docs yet.

I should have said a bit more about your orc.b3d model, it was very small and when I animated it turned into a monster a bit like the ones in "Mrs Peregrine's home for peculiar children". So it looks like you may have scaled the mesh down.

Also the threading example is not quite proper thread procedure but I'm working on it. I'll probably do a second example as well.

Edit: fixed it, threads are much more stable now and it only needs a 10 ms delay to prevent crashes.

Alienhead

Outstanding, thanks for the link to the Openb3d docs, I must had overlooked that on my original install. Thats just what I was needing.

markcwm

#13
Yeah, many people don't realize that I put the examples in a separate download, I did that because I don't know if the media is all free to redistribute.

I updated the threads example again, it was creating empty threads so now ThreadRunning checks the last thread is finished before starting a new one. I also added a speed test for no threads and also one thread and it seems that there is no difference between using no threads and one thread for loading, but multi-threads really does allow the main thread to continue rendering normally.

Alienhead