About Store Forum Documentation Contact
Donations:
327$/mo



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

Post: #16
RE: Static game object from external file
yeah it loads and I see it on screen, UNTIL I move the mouse (which triggers our physical hit check, for identifying triangle->UV->barycentric->province identification).

from debugger, I see there is no triangles in my mesh loaded back.
06-23-2014 09:16 PM
Find all posts by this user Quote this message in a reply
Biga Offline
Member

Post: #17
RE: Static game object from external file
just another question guys
if I make material from code, what I need to use to applying to mesh?

PHP Code:
Material TerrainMap;
MaterialPtr TerrainMaterialPtr;
...
// load images for material
   
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;
   
TerrainMap.validate();
  
TerrainMaterialPtr = &TerrainMap;
  ...
  
Earth.mesh->parts(0).setMaterialTerrainMaterialPtrnullnullnull ); 

I made a pointer to TerranMap and using it in mesh->setmaterial but it doesnt appear. (verified: I exported the TerrainMap.base_0 to .png, it holds data so material seems valid)
seems setMaterial isnt enough to see the material on my mesh...

thanks again
(This post was last modified: 06-24-2014 11:48 AM by Biga.)
06-24-2014 11:46 AM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #18
RE: Static game object from external file
This is what I use to create a material:
Code:
CACHE_MODE Mode = Materials.mode( CACHE_ALL_DUMMY ); // Set the cache to dummy mode
   MaterialPtr NameMat= Materials.ptrRequire( UID(  ) ); // Create the new material, getting a dummy UID
   Materials.mode( Mode );  // Set the mode back to default
  
   NameMat->base_0 = ITC.CreateImage( ConfName, PlyrName ); // This creates an imagePtr in the Images cache
   NameMat->technique = MTECH_BLEND;  // Set the technique to blend the alpha channel
   NameMat->tex_scale = 1.1;
   NameMat->validate(  );  // Validate  
   CreateMesh( base, NameMat->base_0->w(  ) * .005 );  // Create the mesh points with the verts 1 unit away for each ~200 pixes.
  
   PlyrBox.setMaterial( NameMat );
This code reliably works for me. In my code, if I use some of the other techniques that don't have alpha test or blend in them, my texture does not show up, and I'm not sure why(maybe something to do with the alpha channel?)
Hopefully this helps.
06-24-2014 08:44 PM
Find all posts by this user Quote this message in a reply
Biga Offline
Member

Post: #19
RE: Static game object from external file
sorry but what is ITC and CreateImage ? it is your object and method?
so I dont need CreateBaseTextures when working from external file?
I get Cant load Material "encodedfilename" for this code...
06-24-2014 09:55 PM
Find all posts by this user Quote this message in a reply
Biga Offline
Member

Post: #20
RE: Static game object from external file
well the real problem is as I see, the mesh must have at least one material in EE
so when Im making a mesh.save() for later usage, the binary save will have this default material UID referenced...
so seems I cant use the interal save :(

the only solution is FBX import... but ofc it returns with false
I need add logs to Import, rebuild engine and see where it fails, maybe some DLL problem
06-25-2014 01:33 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #21
RE: Static game object from external file
FBX.dll needs to be present in the exe app folder unless you specify custom path using engine's function. (something like SetFBXDLLPath)

I really really recommend that you use the Editor for Asset management.

If you end up using real-time importing assets in the game, then it will not load as fast as with Assets already imported and optimized by the Editor.

You can use Mesh.save but also copy the material files and textures used by those assets.
06-25-2014 03:54 AM
Find all posts by this user Quote this message in a reply
Biga Offline
Member

Post: #22
RE: Static game object from external file
thx, with SetFBXDLLPath the ImportFBX works, but still sth bad with triangles in my mesh...

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

crashes with index out of range...

the plan is making the mesh and material with imports, then save the binary from code and use those files for final game. if that works at all...

yeah would be good to use the editor, but not me who makes the decision about it smile

well, material also uneffective on imported mesh, though base_0 has valid image.
seems I have to spend this day too for solving this 2 issues...
06-25-2014 10:15 AM
Find all posts by this user Quote this message in a reply
Biga Offline
Member

Post: #23
RE: Static game object from external file
-1 problem, the above fixed. material is only left (for now grin )
06-25-2014 03:48 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #24
RE: Static game object from external file
The PhysBody from Mesh uses all MeshParts and converts quads to triangles.
To get perfect triangle face mapping, you may want to first create one MeshBase from all MeshParts and convert quads to tris, then create phys from that MeshBase and access its faces.
You may want to check the source of MeshBase::createPhys or something named similar.
06-25-2014 11:44 PM
Find all posts by this user Quote this message in a reply
Biga Offline
Member

Post: #25
RE: Static game object from external file
thx that was fixed yesterday as I wrote, now just materials doesnt show... I see the good hits in log, just the mesh is transparent, no material shown...
06-26-2014 11:24 AM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #26
RE: Static game object from external file
(06-24-2014 09:55 PM)Biga Wrote:  sorry but what is ITC and CreateImage ? it is your object and method?
so I dont need CreateBaseTextures when working from external file?
I get Cant load Material "encodedfilename" for this code...
Those are my object and method; they return an ImagePtr that is dynamically created. The reason I don't use CreateBaseTextures is because I just use the RGBA channels only as RGBA instead of packing bump and such in there.
You should be able to modify this code to be able to see a basic RGBA texture to at least get it working that far.

Keep in mind, though, that the base_ objects in the material objects are only pointers. So if you are pointing them at a temporary variable.... (it looks like this is what you are doing in your code snippet)
06-26-2014 05:14 PM
Find all posts by this user Quote this message in a reply
Biga Offline
Member

Post: #27
RE: Static game object from external file
(06-26-2014 05:14 PM)Rubeus Wrote:  Keep in mind, though, that the base_ objects in the material objects are only pointers. So if you are pointing them at a temporary variable.... (it looks like this is what you are doing in your code snippet)

yeah that was the bug I fixed for mesh, material is globa, so no crash, but still doesnt appear..

(...) should sign that snippet isnt in one block smile

Material TerrainMap;
MaterialPtr TerrainMaterialPtr;

are global defined.
(This post was last modified: 06-26-2014 06:39 PM by Biga.)
06-26-2014 05:41 PM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #28
RE: Static game object from external file
Material and MaterialPtr have an ImagePtr inside them- base_0 and base_1. You are assigning them:
TerrainMap.base_0 = &base0;
TerrainMap.base_1 = &base1;
If base0 and base1 are created in the function, the address of base0 and base1 are no longer valid when the function exits. Or am I missing something? I've never been good with pointer/reference type stuff.
(This post was last modified: 06-26-2014 07:04 PM by Rubeus.)
06-26-2014 07:03 PM
Find all posts by this user Quote this message in a reply
Biga Offline
Member

Post: #29
RE: Static game object from external file
tried Images to be defined global, but same empty material I get.
(though exporting base_0 results a valid image with my texture so I assume there is another problem)

Image base0, base1, terrain, specular, alpha, bump, normal, glow;
...

EE and my methods..

I sent the main source how actually looks in PM
(snippets are confusing and doesnt reflect my changes meanwhile)
(This post was last modified: 06-26-2014 07:13 PM by Biga.)
06-26-2014 07:07 PM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #30
RE: Static game object from external file
Earth.mesh->parts(0).base.include(VTX_TEX_ALL);
Earth.mesh->parts(0).setMaterial( TerrainMaterialPtr, null, null, null );

//for(int i = 0; i < Earth.mesh->parts(0).base.vtxs(); i++)
//{
//Earth.mesh->parts(0).base.vtx.material(i).set(255, 0, 0, 0);
//}

I changed this section in Init, and in DrawPrepare, I changed the draw call to:

Earth.mesh->draw( MatrixIdentity);
(if you have implemented the game.static drawprepare call elsewhere, you may not need to change this part)

Doing so let me see a solid blue texture I set up as a place holder.
06-27-2014 01:00 AM
Find all posts by this user Quote this message in a reply
Post Reply