SyntaxBomb - Indie Coders

Languages & Coding => Blitz2D, BlitzPlus, Blitz3D => Topic started by: Amanda Dearheart on November 06, 2020, 04:26:45

Title: Saving Entities to File
Post by: Amanda Dearheart on November 06, 2020, 04:26:45
Is there anyway to save an entity and its properties(textures, vertices, surfaces, etc.) to file.
As the code I'm looking at is written in BlitzMax, anyone coding in BlitzMax may join in as well as Monkey coders and CerberusX coders.

Reason, there is a program called PlanetCreator on these forums written in BlitzMax that I want to use to create planets, and use the planets to import them to my sci-fi game.  I am planning to use Godot 3d to load the planets into, so I will need to have loaded in by Python.
Title: Re: Saving Entities to File
Post by: Matty on November 06, 2020, 04:56:04
As pseudocode you want something like this:

Openfile to write
Write number of surfaces
For each surface write standard surface properties such as texture filename etc
For each surface write number of triangles and number of verts
Loop through each triangle
Loop through each triangle vertex and write vertex properties (xyz and uvw for each texture layer)

Close file.

On reading:

Open file for read.
Read number of surfaces
For each surface
Create surface load texture and apply properties
Read triangle and vertex count
Loop through triangles.
Create vertex.
Assign xyz and uvw for each vertex
Create triangle from vertices

Close file
Return mesh handle
Title: Re: Saving Entities to File
Post by: Amanda Dearheart on November 06, 2020, 07:33:02
What I meant was if any of the programs (Blitz3D, BlitzMax, or CerberusX) has any commands for saving entities.
BTW, thanks Matty.
Title: Re: Saving Entities to File
Post by: GrindalfGames on November 06, 2020, 15:46:50
blitz3D does not have any commands for saving entities but there are some mesh exporters(*.x, *.3ds, *.b3d) in the code archives so you could sort one out yourself
Title: Re: Saving Entities to File
Post by: RemiD on November 28, 2020, 21:15:48
QuoteIs there anyway to save an entity and its properties(textures, vertices, surfaces, etc.) to file.
blitz3d has all the commands necessary to save / load image, texture, mesh (with surfaces, vertices, triangles) but you need to write your own functions for custom file formats, or to load a rigged skinned mesh with animations. (i have posted an example here but i don't remember where...)
some examples which may help to write your own save/load texture / mesh functions :
https://www.syntaxbomb.com/index.php/topic,1962.msg2951.html
https://www.syntaxbomb.com/index.php/topic,1875.0.html

and for rigged skinned mesh with animations (with bones,  skinned vertices, vertices weights, animations, poses) you need to use the update v003 by bobysait.
see : https://mojolabs.nz/posts.php?topic=105408
an example on how to use :
(can't find the link but i have posted it somewhere on this forum... if you need an example send me a PM)