December 04, 2020, 01:52:36 PM

Author Topic: Saving Entities to File  (Read 119 times)

Offline bsisko

  • Full Member
  • ***
  • Posts: 109
Saving Entities to File
« on: November 06, 2020, 04:26:45 AM »
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.
Prepare to be assimilated !  Resistance is futile!

Offline Matty

  • Hero Member
  • *****
  • Posts: 1258
    • MattiesGames
Re: Saving Entities to File
« Reply #1 on: November 06, 2020, 04:56:04 AM »
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

Offline bsisko

  • Full Member
  • ***
  • Posts: 109
Re: Saving Entities to File
« Reply #2 on: November 06, 2020, 07:33:02 AM »
What I meant was if any of the programs (Blitz3D, BlitzMax, or CerberusX) has any commands for saving entities.
BTW, thanks Matty.
Prepare to be assimilated !  Resistance is futile!

Offline grindalf

  • Full Member
  • ***
  • Posts: 152
Re: Saving Entities to File
« Reply #3 on: November 06, 2020, 03:46:50 PM »
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

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1081
Re: Saving Entities to File
« Reply #4 on: November 28, 2020, 09:15:48 PM »
Quote
Is 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)
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal