About Store Forum Documentation Contact



Post Reply 
Static game object from external file
Author Message
Biga Offline
Member

Post: #1
Static game object from external file
I have an object initialized from asset:

Earth.create(*Game.Objs("#x3bnqjmn4!5a6w4^f6x360s"));

it works fine, but now I need load everything from external files with avoiding assets. (we move to Visual Studio project and external files from EE Editor).
I saved my mesh to a file with its save method, I have the materials also loaded from external file.

but it crashes when I try to show the object...

PHP Code:
Game::Static Earth;
   
Mesh earthmesh;
...
   
File earthmeshfileearthmeshfile.read(SpiritsConfig.DataPath "/Model/earthmesh.dat");
   
earthmesh.load(earthmeshfile);
   
Meshmeshptr = &earthmesh;
   
Earth.mesh meshptr;
   
   
PhysBody Body;
   
PhysPart Part;
   
Part.createMesh(Earth.mesh->setBase(), true);
   
Body.parts.add(Part);
   
Earth.actor.create(Body);
   
Earth.mesh->parts(0).base.include(VTX_MATERIAL);
   
Earth.mesh->parts(0).setMaterialTerrainMaterialPtrnullnullnull );
   
Earth.mesh->setRender(); 

earthmesh.dat is the file as a result of an earlier mesh.save() when it was initialized from asset.

this init part runs, object appear but inmediately crashes. unfortunately I cant debug, it doesnt run in debug mode, cant create a texture I assume due to not enough memory.

thanks
(This post was last modified: 06-20-2014 01:24 PM by Biga.)
06-20-2014 01:23 PM
Find all posts by this user Quote this message in a reply
Biga Offline
Member

Post: #2
RE: Static game object from external file
edit: tried to use Game::Static save and load methods, but it just saves the reference the mesh asset, so that isnt useful for me.
06-20-2014 02:38 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: Static game object from external file
You could try debugging step by step (line by line).

I still think you should let the Editor keep the asset management, doesn't matter if you use VS or not.
06-21-2014 02:39 AM
Find all posts by this user Quote this message in a reply
Biga Offline
Member

Post: #4
RE: Static game object from external file
Well we would like, but until the sync doesnt work perfectly, we cant rely on it in team mode. Last time we lost a day due to loosing assets while syncing.
06-21-2014 10:22 AM
Find all posts by this user Quote this message in a reply
Biga Offline
Member

Post: #5
RE: Static game object from external file
hi!

(06-21-2014 02:39 AM)Esenthel Wrote:  You could try debugging step by step (line by line).

done, crashes here (at phys hit part):

PHP Code:
VecI vertices Earth.mesh->parts(0).base.tri.ind(phys_hit.face); 

gives EE error in Mesh Base.h, line 162
PHP Code:
=>     VecI ind    ()  {return _ind     ;}     VecI ind    (Int i)  {RANGE_ASSERT(i_elms); return _ind     [i];} // get i-th triangle vertex indexes 

seems if I save then load a mesh from file, it looses the triangles...? it works fine if I use with the asset.

can you give me a clue at least what engine source I need to check to find the problem? I checked Engine Editor src/Object, but Im not sure this is what I need...

(06-21-2014 02:39 AM)Esenthel Wrote:  I still think you should let the Editor keep the asset management, doesn't matter if you use VS or not.

does it mean EE works only with own asset management?
or using EE with external files is unsupported?
Im wondering how game can be modded with internal asset system btw...

so in short, Im curious what steps I need to create a working Game::Static object from code and from saved files... smile

sadly I have problems with loading textures from file... it is compiled, but doesnt work... sth I miss here too :(

PHP Code:
File terrainfileterrainfile.read(SpiritsConfig.DataPath "/Image/Map/world.topo.bathy.png");
   
Image base0base1terrainspecularalphabumpnormalglow;
   
terrain.ImportPNG(terrainfile);
   
File specularfilespecularfile.read(SpiritsConfig.DataPath "/Image/Map/water_8k.png");
   
specular.ImportPNG(specularfile); 
   
   
uint       bt=CreateBaseTextures(base0base1terrainalphabumpnormalspecularglow);
   
   
TerrainMap.base_0 = &base0;
   
TerrainMap.base_1 = &base1;
  
   
TerrainMaterialPtr = &TerrainMap;

....
Earth.mesh->parts(0).setMaterialTerrainMaterialPtrnullnullnull ); 
(This post was last modified: 06-21-2014 04:51 PM by Biga.)
06-21-2014 04:39 PM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #6
RE: Static game object from external file
This is how I create images that I later pack into textures:
Code:
CACHE_MODE  Cache    = Images.mode( CACHE_ALL_DUMMY );  
      ImagePtr         x   = Images.ptrRequire( UID(  ).randomize(  ) );
      Images.mode( Cache );
Then try x->importPNG();
I don't know if this is the problem you are having with that section or not, but it's how I got it to work. Maybe you need to use this method as well for your MeshPtr? The MeshPtr and ImagePtr are actual pointers, for all practical purposes, so I think your problem might be that you are pointing to a local variable, unless your code is edited for smallness.

Edit:
I got something similar to your Mesh issue working using:
Code:
Game.ObjParamsPtr OPP = Game.Objs( "filename or ID" );
myMeshPtr = OPP.mesh();
(This post was last modified: 06-21-2014 10:22 PM by Rubeus.)
06-21-2014 07:24 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: Static game object from external file
(06-21-2014 10:22 AM)Biga Wrote:  Well we would like, but until the sync doesnt work perfectly, we cant rely on it in team mode. Last time we lost a day due to loosing assets while syncing.
I didn't experience any issues with asset syncing myself, if you do, please provide exact steps to reproduce the issue.
Thank you
06-21-2014 11:27 PM
Find all posts by this user Quote this message in a reply
Biga Offline
Member

Post: #8
RE: Static game object from external file
(06-21-2014 07:24 PM)Rubeus Wrote:  Edit:
I got something similar to your Mesh issue working using:
Code:
Game.ObjParamsPtr OPP = Game.Objs( "filename or ID" );
myMeshPtr = OPP.mesh();

thanks, but I found Game.Objs doesnt support external files as I see, only internal asset file or ID name.. (copied from asset properties)
06-22-2014 10:01 AM
Find all posts by this user Quote this message in a reply
Biga Offline
Member

Post: #9
RE: Static game object from external file
just found, that not me the first who asking this...

Quote:"I am curious about why there isn't any examples on how to use the imported assets into EE2.0 for use of EE purely through Visual Studio.
I know of a few people who really would like to be able to use the latest of the engine but there being no way to port over EE1.0 worlds and asset pipelines they are being cutoff(extremely hard to deal with).
There is also no examples on how to load the new way you are handling assets by encrypted names, this also kinda is preventing developers to be able to support modding properly in their projects."

http://www.esenthel.com/community/showth...ht=modding

I have exactly the same general problem here, how modding would work with assets...
(This post was last modified: 06-22-2014 06:26 PM by Biga.)
06-22-2014 06:23 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #10
RE: Static game object from external file
You can use the Editor Interface and save out the file manually to a readable name. it would however still require an additional step, eg Modder makes a model in 3rd party program<->Import to editor<->make adjustments<->Editor interface<-> object.save("readablename")

How well this works with 2.0 builtin world manager I am not sure.
06-22-2014 06:50 PM
Find all posts by this user Quote this message in a reply
Biga Offline
Member

Post: #11
RE: Static game object from external file
(06-22-2014 06:50 PM)Zervox Wrote:  You can use the Editor Interface and save out the file manually to a readable name. it would however still require an additional step, eg Modder makes a model in 3rd party program<->Import to editor<->make adjustments<->Editor interface<-> object.save("readablename")

How well this works with 2.0 builtin world manager I am not sure.

it maybe works with simple objects, but not with objects have "subassets". Like if you save a material, you will get just a placeholder file having reference to internal texture assets, or saving GUI just results also a placeholder with references to background, border, etc files.
if you use a mesh with textures, the result is similar I assume, it will have material references, so it seems I cant build a larger structure from external files, maybe only if I add the half of Editor import source to my project... :/
however I found a reload feature on folders in EE Editor, but seemed uneffective, I assumed it reloads all child assets from their source.

(06-21-2014 02:39 AM)Esenthel Wrote:  You could try debugging step by step (line by line).

I still think you should let the Editor keep the asset management, doesn't matter if you use VS or not.

ok I try really just ask a simple question, not too general ones "how I should do" smile

so a specific question, why triangles lost if I load a mesh back?
so I saved an object previously imported from FBX with .save(), but I cant use

mesh->parts(0).base.tri.ind(...), it crashes because of no triangles. (the mesh shows a second, crashes where the above line hit by mouse operation)

pls help, how can I get back the same object I exported?

thanks
(This post was last modified: 06-22-2014 07:07 PM by Biga.)
06-22-2014 07:02 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #12
RE: Static game object from external file
saving classes which has dependencies on others obviously might need a bit of planning for proper export.

Did you try mesh::setBase()?
also because it seems you are dealing with this using pointers, are you sure you are doing operations on a valid pointer?
(This post was last modified: 06-22-2014 07:21 PM by Zervox.)
06-22-2014 07:21 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #13
RE: Static game object from external file
Meshes by default will have only GPU version (MeshRender and not MeshBase) to reduce file size.
As Zervox mentioned setBase will create the CPU version.
06-23-2014 12:40 AM
Find all posts by this user Quote this message in a reply
Biga Offline
Member

Post: #14
RE: Static game object from external file
yup I tried, same crash.
it is in the #1 post source, if you scroll it down.
06-23-2014 10:11 AM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #15
RE: Static game object from external file
Did you do a check on earthmesh.load?

if( !earthmesh.load(earthmeshfile) )
Exit( "Earthmesh did not load from file!" );
06-23-2014 07:58 PM
Find all posts by this user Quote this message in a reply
Post Reply