GithubHelp home page GithubHelp logo

openb3d.mod's Introduction

OpenB3D

Introduction

OpenB3D is a lightweight OpenGL 1.4+ 3D engine written in C++, this is the BlitzMax wrapper for it. OpenB3D is based on MiniB3D which was based on Blitz3D. Help might be found at the SyntaxBomb MiniB3D Board or the BlitzCoder OpenB3D Board.

Features

  • Works with Legacy BRL BlitzMax but is really supposed to be for BlitzMax NG on Windows, Mac or Linux
  • Object-oriented with methods and a procedural interface of functions, like MiniB3D
  • Entities are objects (and not integer handles like Blitz3D) so you must specify their type
  • Types are as in MiniB3D, but fields are all pointers, except Tlists which are the same
  • Coordinate system is not OpenGL orientation, it is left-handed like Blitz3D
  • Works with BRL.MaxGui like MiniB3D, this allows more control of windows
  • BRL.Max2d provides 2D-in-3D rendering, along with BRL.Graphics this adds many 2D commands found in Blitz3D
  • The STB Image library loads texture formats, this provides support for TGA, BMP, GIF and PSD
  • BRL image loaders are used for PNG and JPG as they were more stable
  • Support for DDS with compressed textures in video memory but this needs a module tweak to Max2D (now in latest NG)
  • File streams for textures and meshes for Incbin and zip files with Koriolis.Zipstream
  • 3D model formats are 3DS, OBJ (no animation), B3D (skeletal animation) and MD2 (vertex interpolation)
  • Several more 3D formats can be loaded with the Assimp wrapper but no animation yet
  • Collision detection with Blitz3D's ellipsoid-to-something collisions, dynamic collisions are possible
  • Realtime textures created with BackBufferToTex, CameraToTex and DepthBufferToTex
  • Shader post-processing with either CameraToTex rendering to screen sprite or PostFX rendering to framebuffer
  • Quaternions are used for rotations instead of Eulers like MiniB3D, avoids Gimbal lock
  • Terrains are like Blitz3D, UpdateNormals replaces TerrainShading, alpha maps and shaders now work
  • Vertex and Fragment shaders examples written to comply with GLSL 1.10 (GL 2.0)
  • Shader effects include bump map, toon, per pixel lighting, anti alias, colorgrading, depth of field, bloom
  • Dynamic lighting and linear fog with either fixed function or shaders
  • Realtime volumetric stencil shadows with self-shadowing from multiple lights - no soft shadows
  • Stencil commands for mirror and portal type effects
  • CSG (constructive solid geometry) combine, subtract and intersect
  • Event-based entity control system called Actions, triggered once and then automatically update
  • Basic physics system consisting of constraints and rigid bodies
  • Newton library wrapper has support for primitives but no vehicles, ragdolls, etc
  • Sprites are all from a single surface, so very fast
  • Particle emitter system with callback function for custom controls, uses sprites
  • Particle Candy module for alternative particle system, not completed
  • Software anti-alias like MiniB3D, multisample hardware anti-alias but only in Windows with a module tweak

Status

I have very little spare time to work on the wrapper now but I will still try to look at pull requests and respond to issues that address bugs whether on Github or the boards.

Installation

  • Extract the zip to BlitzMax/mod folder
  • Remove -master from the openb3d folder name - modules must end in .mod
  • On Windows, you need a working version of the MinGW compiler
  • On Mac, you need a compatible version of XCode installed
  • On Linux, read this guide How To: Install BlitzMax NG on Win/Mac/Ubuntu 64-bit
  • To build with BRL Blitzmax, open Cmd, cd to BlitzMax/bin and type bmk makemods -d openb3d
  • For Blitzmax NG in 64-bit use bmk makemods -d -w -g x64 openb3d - on Unix use ./bmk
  • Or from MaxIDE enable Quick Build, Debug, GUI App and Build Modules
  • To syntax highlight the commands use ./makedocs or MaxIDE's Rebuild Documentation

License

The library is licensed with the GNU LGPL 2.1 or later with an exception to allow static linking and the wrapper is licensed with the permissive zlib license.

Credits

The OpenB3D library was based iMiniB3D, other core parts were ported from Warner Engine and MiniB3D Extended.

openb3d.mod's People

Contributors

druggedbunny avatar kippykip avatar markcwm avatar propuke avatar starfrost013 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

openb3d.mod's Issues

CSG leaking

Using any CSG method causes a lot of model leakage.

Some examples:
csg_2019-09-10_09-03-06
csg_2019-09-10_09-03-19
csg_2019-09-10_09-03-25

Segmentation fault on Graphics3d Fullscreen mode 1, depth 32.

'; 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.

Request: modern mesh format

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.

What causes OpenB3D to crash on .B3D Blender exports?

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.

Request / Help: Implementing a ManualCollision function

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?

TextureName is broken

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"

Can't test collisions if a type has "Collisions" with 2 or more other types.

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.

What about extend functions?

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?

Size_t overload warning

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

Completely unlinkable

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.

Memory leakage when Freeing TSprites

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

Question: Terrain LOD setting

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.

EntityCollided() Breaks if multiple entities with the same type set, which collide more than 1 type.

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

TGlobal is duplicate (in BlitzMaxNG at least)

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!

CopyMesh Crashes OpenB3D - EXCEPTION_ACCESS_VIOLATION

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! 🤞 😃

Ubuntu 22.04.2, X.org X server nouveau display driver segmentation fault in blitzmax OpenB3D

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.