PnP TerrainCreator - Forum

The PnP TerrainCreator Forum
It is currently Sat Nov 18, 2017 7:45 pm

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Alpha & blendmap export
PostPosted: Tue Jun 30, 2009 2:05 pm 
Offline

Joined: Sat May 09, 2009 6:53 pm
Posts: 19
Hi,

We're currently using PNP terrain creator to make battle maps for Empire:Total War, CA's latest release in its Total War series.

Getting the texture & terrain maps exported and ingame works great, but some of the underlying 'game' maps that define movement speed, cover and some other game-related parameters need to be made by hand using GIMP or photoshop.
These are covered by various 'alpha' maps that tell the game engine where hiding is possible, where roads are etc.

I'd like to create an export plugin that would read some user defined data per texture and will make these 'alhpa' maps out of them (like have certain textures have a 'hide possible' value set to true and others to false. Writing these values to a black & white bitmap would create the map the engine needs to make this work with the terrain)

Therefor it would be necessary to find out how to read these user defined data from a plugin (similar to the texturemap exporter).

Any pointers how this could be achieved?

thanks
Badger


Top
 Profile  
 
 Post subject: Re: Alpha & blendmap export
PostPosted: Tue Jun 30, 2009 3:10 pm 
Offline
Programmierdochfix
User avatar

Joined: Tue Apr 27, 2004 12:53 pm
Posts: 892
Location: Braunschweig
Hi, sounds like a cool project. I'd love to see this in action.

Well...
First of all, you can add user defined properties to the definition of surface textures. So you can for example add a parameter for movement speed which can be set to a higher level for sand textures than for deep grass texture for example. Please take a look in the manual on the pages 22-23 and 67-68 for how to achieve this.

Now during export you can read these settings from the CIPnPTCTexture01 interface which encapsulates all of the single texture resources. You can get access to one such texture either by CIPnPTCTerrain01::GetTexture() or by CIPnPTCSectorTextures01::GetTexture(). These user defined settings are then stored in the property container of the texture, which can be read with CIPnPTCTexture01::GetPropertyContainer(). Finally, with CIPnPTCPropertyContainer01::GetNumProperties() and CIPnPTCPropertyContainer01::GetProperty() you can iterate through all of the defined properties.

Hope this helps. If not, please let me know.


Top
 Profile  
 
 Post subject: Re: Alpha & blendmap export
PostPosted: Wed Jul 01, 2009 12:39 pm 
Offline

Joined: Sat May 09, 2009 6:53 pm
Posts: 19
It would be pretty great to get this to work.

However, trying to compile the texturemap exporter sample project, i get a message about a missing header file. One of the headers of the project refers to the necessity of the 'Platform SDK'. Any ideas where i can find this? I'm using VS 2008 Express.

thx
B


Top
 Profile  
 
 Post subject: Re: Alpha & blendmap export
PostPosted: Wed Jul 01, 2009 12:49 pm 
Offline
Programmierdochfix
User avatar

Joined: Tue Apr 27, 2004 12:53 pm
Posts: 892
Location: Braunschweig
Can you post the error message?


Top
 Profile  
 
 Post subject: Re: Alpha & blendmap export
PostPosted: Wed Jul 01, 2009 1:21 pm 
Offline
Programmierdochfix
User avatar

Joined: Tue Apr 27, 2004 12:53 pm
Posts: 892
Location: Braunschweig
I see...

All exporters use MFC for the settings dialogs. So the Express editions fail to compile. The methods used during export are all independent of MFC. So if you don't need a settings dialog, you can simply use them in your own plugins without the need of embedding MFC.


Top
 Profile  
 
 Post subject: Re: Alpha & blendmap export
PostPosted: Sun Jul 12, 2009 8:16 pm 
Offline

Joined: Sat May 09, 2009 6:53 pm
Posts: 19
Hi Ralf,

I think i solved the mfc part for now.

I've gotten as far as 3.2 of the texturemap export plugin sample/tutorial, but when i build the solution, i get the following errors. Any pointers?

thx
B

Code:
1>------ Build started: Project: ETW_layersexport, Configuration: Debug Win32 ------
1>Compiling...
1>ETW_layersexport.cpp
1>j:\etw_testmap\exporter\etw_layersexport\etw_layersexport\etw_layersexport.cpp(26) : error C2059: syntax error : '__declspec(dllexport)'
1>j:\etw_testmap\exporter\etw_layersexport\etw_layersexport\etw_layersexport.cpp(27) : error C2143: syntax error : missing ';' before '{'
1>j:\etw_testmap\exporter\etw_layersexport\etw_layersexport\etw_layersexport.cpp(27) : error C2447: '{' : missing function header (old-style formal list?)
1>j:\etw_testmap\exporter\etw_layersexport\etw_layersexport\etw_layersexport.cpp(33) : error C2059: syntax error : '__declspec(dllexport)'
1>j:\etw_testmap\exporter\etw_layersexport\etw_layersexport\etw_layersexport.cpp(34) : error C2143: syntax error : missing ';' before '{'
1>j:\etw_testmap\exporter\etw_layersexport\etw_layersexport\etw_layersexport.cpp(34) : error C2447: '{' : missing function header (old-style formal list?)
1>Build log was saved at "file://j:\ETW_testmap\exporter\ETW_layersexport\ETW_layersexport\Debug\BuildLog.htm"
1>ETW_layersexport - 6 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Top
 Profile  
 
 Post subject: Re: Alpha & blendmap export
PostPosted: Sun Jul 12, 2009 9:18 pm 
Offline

Joined: Sat May 09, 2009 6:53 pm
Posts: 19
OK, apparently he first part of the cpp file from the tutorial is obsolete. It needs to be like this (immho).

Code:
__declspec(dllexport) int CALLBACK GetPlugInApiID()
{
   // return PlugIn ID
   return PNPTC_PLUGIN_APIID_EXPORT;
}

__declspec(dllexport) GUID CALLBACK GetPlugInGUID()
{
   // return the uid of your plugin
   return g_uidPlugIn;
}

__declspec(dllexport) char* CALLBACK GetPlugInName()
{
   // return name
   return PLUGIN_NAME;
}

//Construction of the plugin
__declspec(dllexport) IPnPTCPlugIn* CALLBACK CreatePlugin()
{
   // create and return the plugin pointer
   return new CPnPTCETW_LAYERSEXPORTPlugIn;
}


Yet now i get an error 'spawning rc.exe'.

Again, any help is appreciated

Code:
1>Compiling...
1>ETW_layersexport.cpp
1>Compiling...
1>dllmain.cpp
1>Compiling manifest to resources...
1>Project : error PRJ0003 : Error spawning 'rc.exe'.


Top
 Profile  
 
 Post subject: Re: Alpha & blendmap export
PostPosted: Wed Jul 15, 2009 9:54 pm 
Offline

Joined: Sat May 09, 2009 6:53 pm
Posts: 19
Hi,

I've gotten the plugin to compile finally, added the 4 user data fields to the terrain, but when i try to export it, i get an error here:

Code:
// get texture
   pTexture=pTexMap->GetTexture(iTexX,iTexY);
   pPropCon=pTexture->GetPropertyContainer();
   if(ETWtype>0)
   {
      ETWtype=ETWtype-1;
      pPropVal=pPropCon->GetProperty(ETWtype);
   }


ETWtype is passed on as an extra parameter to the WriteSector method of CTexturemapExporterBMP (added that in exporter.cpp), and contains an integer value to specify which type of map to write (based on a number of custom data types. Attached the crash dump.

thx
B


Attachments:
PnPTC-CrashReport.zip [18.72 KiB]
Downloaded 701 times
Top
 Profile  
 
 Post subject: Re: Alpha & blendmap export
PostPosted: Fri Jul 17, 2009 7:49 am 
Offline

Joined: Sat May 09, 2009 6:53 pm
Posts: 19
Hi,

I found out what was wrong. Apparently, i was reading the propertycontainer from the texturemap, instead of the textures themselves. Now it works like a charm, writing the necessary jpg files.

I've only noticed a small issue, i cant seem to open the jpg' s in photoshop, though they do open in GIMP. I've attached a sample.

cheers
B


Attachments:
grassmap_alpha.jpg
grassmap_alpha.jpg [ 18.91 KiB | Viewed 765 times ]
Top
 Profile  
 
 Post subject: Re: Alpha & blendmap export
PostPosted: Fri Jul 17, 2009 11:53 am 
Offline
Programmierdochfix
User avatar

Joined: Tue Apr 27, 2004 12:53 pm
Posts: 892
Location: Braunschweig
Sorry, for the late response.... good to hear, that it finally works for you.
You are right, I updated the source files, but the tutorial still uses old style function declarations. I'll update the tutorials.

As an improvement for your code, you should not use a fixed index of a property in your property container, as this index might change unexpected, when you edit the user defined property definitions. Instead iterate through all properties of a container and check its names to decide which action to take. This will also avoid the crash if a property is missing for some reason, as it might have been the case in your crash report.


Top
 Profile  
 
 Post subject: Re: Alpha & blendmap export
PostPosted: Fri Jul 17, 2009 3:43 pm 
Offline
Programmierdochfix
User avatar

Joined: Tue Apr 27, 2004 12:53 pm
Posts: 892
Location: Braunschweig
... we have no problem opening the jpg in any program. Do you get an error message or something?


Top
 Profile  
 
 Post subject: Re: Alpha & blendmap export
PostPosted: Fri Jul 17, 2009 8:29 pm 
Offline

Joined: Sat May 09, 2009 6:53 pm
Posts: 19
Sorry about that...

I can open it in PS now too, must have been a temporary glitch, restarting the PC solved it.

I've gotten Pnp to export allt he files i need now to make the ETW battlemaps.

I hope to make a tutorial over the weekend & i'll post links here too.

cheers
B


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: