markcwm / openb3d.mod Goto Github PK
View Code? Open in Web Editor NEWOpenB3D BlitzMax wrapper, see openb3d.docs for examples
OpenB3D BlitzMax wrapper, see openb3d.docs for examples
We currently only have ellipsoid to sphere/polygon/box collision methods.
It would be great to have a cylinder to sphere/polygon/box collision method.
I found out that if you use the "Collisions" function on a type to have collisions for multiple other objects, you can't actually test for it.
Functions such as EntityCollided and CountCollisions are broken because of it. This bug is not present in MiniB3D.
Here's the thread on SyntaxBomb
https://www.syntaxbomb.com/index.php/topic,4071.msg12630.html
Here's an example below that colors the bullet and changes the text if it collides with an object.
collisionbug.zip
It's likely not a fault in the wrapper but the library itself.
Hey, I'm trying to implement a new ManualCollisions function into collisions2.c & collisions2.h
Basically it would work like so:
int ManualCollision(Entity& ent,Entity& ent2, int col_method, int col_response)
So instead of bothering with collision types and whatnot, I can just check between them manually within blitzmax.
Should return the number of hits while also doing the collision response.
The reasoning is because I've divided my map into chunks/blockmap, and I don't need objects testing collisions for far away objects or other entities in my project. Only every 500x500x500 metres. I've got the rest of the stuff handled but for it to work, I need a manual way of doing the collisions.
I imagine the game loop will look something like this:
While not AppTerminate()
ResetEntity(player)
if(ManualCollision(player, map, 2, 1) > 0)
print "hit!"
endif
RenderWorld()
Flip()
Wend
However I'm struggling to even add the function, I think I've made something(?) inside collisions2.c and can compile the modified module fine. But I just can't seem to figure out how to call the .cpp function within BlitzMax itself.
As soon as I attempt to add the function to functions.bmx I get:
Compile Error
Identifier 'ManualCollision' not found
C++ isn't really in my expertise, it took me a while to get the first function to compile because I was using ** instead of & hahaha.
Any hints or clues?
'; CreateTerrain Example
'; ---------------------
Framework openb3d.b3dglgraphics
DebugStop
Graphics3D 640,480, 32, 1
Local camera:TCamera=CreateCamera()
PositionEntity camera,0,1,0
Local light:TLight=CreateLight()
RotateEntity light,90,0,0
'; Create terrain
Local terrain:TTerrain=CreateTerrain(128)
'; Texture terrain
Local grass_tex:TTexture=LoadTexture( "../media/zone/grass.jpg" )
EntityTexture terrain,grass_tex
While Not KeyDown( 1 )
If KeyDown( 205 )=True Then TurnEntity camera,0,-1,0
If KeyDown( 203 )=True Then TurnEntity camera,0,1,0
If KeyDown( 208 )=True Then MoveEntity camera,0,0,-0.05
If KeyDown( 200 )=True Then MoveEntity camera,0,0,0.05
RenderWorld
Text 0,0,"Use cursor keys to move about the terrain"
Flip
Wend
End
Can this be fixed? i do not know exactly the terms and conditions for the line within graphics3d fullscreen that it crashes but that it does, let me know if you wish me to debug deeper to help.
copymesh crash example.zip
CopyMesh seems to flat out crash OpenB3D on loaded models, from what I understand it's this part in mesh.cpp
// recursively copy contents of child list before adding parent list<Entity*>::iterator it; for(it=child_list.begin();it!=child_list.end();it++){ Entity* ent=*it; dynamic_cast<Mesh*>(ent)->CopyMesh(mesh); }
Specifically the dynamic_cast<Mesh>(ent)->CopyMesh(mesh);* part, I'm not sure if it's trying to run it's own function or something?
I've attached an example, it would be very epic if this one could be fixed so I can have multiple entities with animated textures without having to LoadAnimMesh and cause stutters.
I'm still going to have a play around, I was able to restore minib3d behaviour where it copies the mesh without the animation, but hopefully we can fix this fully! 🤞 😃
I just built the latest version in the latest bmx-ng release, but ran into an error with TGlobal, where it said it was a duplicate of that found in pub.reflection (TGlobal is defined from line 1422 of mod\brl.mod\reflection.mod\reflection.bmx
).
I just renamed all instances in openb3d to TB3DGlobal
and it built after that -- I renamed the file mod\openb3dmax.mod\openb3dmax.mod\inc\TGlobal.bmx
to TB3DGlobal.bmx
and then did a bulk find-in-files using NotePad++ - this was done by simply dragging the whole openb3dmax.mod folder onto NP++, right-clicking the resulting folder tree and choosing Find, then doing the replacement. After that it built fine here.
(Not sure why you don't run into this -- maybe to do with using Framework and specifying imports? I'm just doing Import openb3dmax.B3dglgraphics
here.)
Thanks for keeping this going, just getting back to it!
Hi Mark,
compiling your mod for bmx-ng gives a warning in the title. As this might create some wondering for a new user.
You could edit the file stbimageloader.mod\stbimageloader.bmx , line 44 and change:
Local bufLen:Int = StreamSize(stream)
to:
?bmxng
Local bufLen:Size_T = StreamSize(stream)
?Not bmxng
Local bufLen:Int = StreamSize(stream)
?
-Henri
Do I understand correctly that your library is written in blitz basic? Why not in C++?
What about add next functionallity:
Add random generator.
Read\Write files.
Date\Time functions.
Direct access (pointer) to screen buffer.
It may be all wrong, of course.
Although it probably doesn't make sense.
What do you think about it?
Very oddly specific bug, it's the best way I could think of titling it.
From what I understand if you have multiple entities with the same type (such as a bullet) set on the entities and use Collisions() on them with two other types (such as the map, and some enemies). Whenever there are some bullets not hitting anything, the other bullets that are colliding won't be able to be tested with EntityCollided or CountCollisions().
I made an example attached below:
collisionbug.zip
I also made a syntaxbomb thread on it, which contains a YouTube video demonstrating the bug
Example:
While not(AppTerminate())
Local LeakyBoy:TSprite = CreateSprite()
FreeEntity(LeakyBoy)
GCCollect()
Wend
You will see in task manager that the memory usage will continue to rise.
Looks like it was just calling the standard TEntity FreeEntity instead of the TMesh FreeEntity code, which TSprites extend from normally.
I made a fix here:
Kippykip@736d79b
Heya, I've briefly mentioned about this before on syntaxbomb a long time ago but never got around to making an example of this bug.
I've got two models, one exported in MilkShape 3D and the other exported in Blender with the MineTest .B3D exporter.
(https://github.com/Kippykip/B3DExport)
The blender model export reads fine in FragMotion and loads in classic Blitz3D, but on OpenB3D EXCEPTION_ACCESS_VIOLATION crashes occur.
(When I export without textures, the debugger scrolls to Local inst:Byte Ptr=LoadAnimMesh_)
https://i.imgur.com/Jb2y6E5.png
Here's the code for both BlitzMax-NG and Blitz3D, with the models and everything included.
Example.zip
Also I noticed that OpenB3D doesn't seem to light meshes with groups correctly, when compared to the Blitz3D example.
TextureName returns a bunch of weird characters, but not the file path of the loaded texture like it should.
Returns "���"
when it should return something like
"wcrate.jpg"
Since I updated to the latest OpenB3D wrapper, 3DS meshes no longer load correctly and also I can't control them look a normal mesh.
Such as no texture filtering, no collisions, no hiding and no rotation etc.
I created a thread about it on SyntaxBomb
https://www.syntaxbomb.com/index.php/topic,4792.msg18261/topicseen.html#new
The version of OpenB3D I was using until was dated around 13/02/2018
GetChild and FindChild always returns Null, except at old *.b3d files.
It's hard to use OpenB3D without any modern model/mesh format support.
Blender for example, which is the most commonly used tool today, exports to things like .fbx
, .obj
, .glb/.gltf
and OpenB3D supports none of them.
.glb/.gltf
2.0 is a fairly straight forward format, well documented and supports animations: https://www.khronos.org/gltf/
(the .glb file format is a binary form of glTF that includes textures instead of referencing them as external images)
.obj
is also a very straight forward, static, simple and commonly used file format.
I make comparsion table:
https://blitz3dfasm.github.io/FASM_B3D_SDK_HELP/Full_Comparsion.htm
Does it make sense to compare OpenB3D and MiniB3D?
Or is MiniB3D just an old cropped version of OpenB3D?
OpenB3D is have Releases?
Also, I did not find MiniB3D.dll assemblies in the network. There are only sources on github.
Is there a way to change the dynamic terrain LOD?
I feel like it's a bit aggressive, and things just in front of the player always appears very blocky.
Doesn't matter whether you load with LoadMesh and LoadAnimMesh.
If the model file loaded contains bones and you use FreeEntity, it will crash BlitzMax.
Thread with more detail here:
http://www.syntaxbomb.com/index.php/topic,3663.0.html
Example here:
crashexample2.zip
Good luck! :)
I can't link anything using openb3dmax.
Building Vibranium [ 97%] Processing:Vibranium.bmx [ 98%] Compiling:Vibranium.bmx.gui.release.win32.x64.c [100%] Linking:Vibranium.exe C:/BMXNG/BlitzMax/mod/openb3dmax.mod/openb3dlib.mod/openb3dlib.release.win32.x64.a(geosphere.cpp.release.win32.x64.o):geosphere.cpp:(.text+0x5a09): undefined reference to
stbi_load'
C:/BMXNG/BlitzMax/mod/openb3dmax.mod/openb3dlib.mod/openb3dlib.release.win32.x64.a(material.cpp.release.win32.x64.o):material.cpp:(.text+0x3c53): undefined reference to stbi_load' C:/BMXNG/BlitzMax/mod/openb3dmax.mod/openb3dlib.mod/openb3dlib.release.win32.x64.a(terrain.cpp.release.win32.x64.o):terrain.cpp:(.text+0x4791): undefined reference to
stbi_load'
C:/BMXNG/BlitzMax/mod/openb3dmax.mod/openb3dlib.mod/openb3dlib.release.win32.x64.a(texture.cpp.release.win32.x64.o):texture.cpp:(.text+0xfb0): undefined reference to stbi_load' C:/BMXNG/BlitzMax/mod/openb3dmax.mod/openb3dlib.mod/openb3dlib.release.win32.x64.a(texture.cpp.release.win32.x64.o):texture.cpp:(.text+0x21dd): undefined reference to
stbi_load'
collect2.exe: error: ld returned 1 exit status
Build Error: Failed to link C:/@Vibranium/Client/Src/Vibranium.exe
Process complete
`
is all I get.
The OpenB3D commands are highlighted and I get into the BlitzMax-HELP with F1.
If I open the help for command Graphics3D I see the behind the keyword "Description" a link to "Online doc". This link goes to...
http://www.blitzbasic.com/b3ddocs/command.php?name=Graphics3D
....but this is of course not online anymore.
I've just added Anisotropic Filtering from Dreide. Hezkore actually requested this about 3 years ago http://www.mojolabs.nz/posts.php?topic=106572 I haven't tested it yet but maybe someone can test before me, you must set the texture flag to 1024 to enable anisotropic. This technique basically eliminates antialiasing especially at oblique angles.
So i put on debug mode and stepped in, on this line it it has the segmentation fault
the segmentation fault happened after or on this line (I think, i had to go back and see.
If usecanvas=False Then TGlobal3D.gfx_obj=Graphics( width,height,depth,rate,flags ) ' gfx object
i switched to this driver after upgrading my system (Ubuntu 22.04.2 LTS) so i dont know if it were the system apt upgrades
i switched to the nvidia open kernel nvidia driver 530, no segmentation fault with the nvidia driver.
Is the display driver not for 3d acceleration video games?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.