Jump to content
Sign in to follow this  
drredfox

Adding hidden textures for custom objects

Recommended Posts

Hi,

I've made an ammo crate with my own model and textures, config, etc...It works and it's fine, BUT, I'm trying to improve the addon using hiddenSelection, so I can have one model, one base texture and a set of signs (like Bohemia did with they ammoxes). I've searched for all the internet but didn't understood...nothing.

So far, this is what i've done:

  • Model to O2. Added mesh, shadow LOD, and Geo Lod, texture and rvmat (with nohq and smdi).
  • I've created a selection called "text" with a set of faces, where the texture with signs must apply.
  • The config.cpp posted below.
  • Hit my face several times.

CONFIG.CPP
//CONFIG

#define _ARMA_

//ndefs=13
enum {
destructengine = 2,
destructdefault = 6,
destructwreck = 7,
destructtree = 3,
destructtent = 4,
stabilizedinaxisx = 1,
stabilizedinaxesxyz = 4,
stabilizedinaxisy = 2,
stabilizedinaxesboth = 3,
destructno = 0,
stabilizedinaxesnone = 0,
destructman = 5,
destructbuilding = 1
};

class CfgPatches {
class st_objects {
	units[] = {};
	weapons[] = {};
	requiredVersion = 0.1;
	requiredAddons[] = {};
};
};

class CfgVehicles {
class ReammoBox_F;
class ST1_Box: ReammoBox_F {
	scope = 0;
	hiddenSelections[] = {"text"};
	hiddenSelectionsTextures[] = {"\st_box\data\hiddenText.paa"};
};

class ST1_Med_Box: ST1_Box {
	author="DrRedfox";
	scope = 2;
	scopeCurator = public;
	vehicleClass = "Ammo";
	displayName = "ST1 Caja Medica";
	model = "\st_box\st_box";
	icon = "iconCrateWpns";
	class TransportWeapons{};
	class TransportMagazines{};
	class TransportItems{};
	class AnimationSources
	{
		class Ammo_source
		{
			source = "user";
			initPhase = 1;
			animPeriod = 1;
		};
		class AmmoOrd_source
		{
			source = "user";
			initPhase = 1;
			animPeriod = 1;
		};
		class Grenades_source
		{
			source = "user";
			initPhase = 1;
			animPeriod = 1;
		};
		class Support_source
		{
			source = "user";
			initPhase = 0;
			animPeriod = 1;
		};
	};
};
};

This config it's adapted from the BI ammoboxes. Really, I don't know what im doing...

In one post, someone says that a named selection it's needed (in my addon= "text"), and the line "sections[]={};"on cfgModel, where the named selection must be. But I can't see this in the BI configs. They are like the one posted above. I must assume that it's correct.

The original code for the BI NATO box:

	class NATO_Box_Base: ReammoBox_F
{
	scope = 0;
	hiddenSelections[] = {"Camo_Signs","Camo"};
	hiddenSelectionsTextures[] = {"A3\Weapons_F\Ammoboxes\data\AmmoBox_signs_CA.paa","A3\Weapons_F\Ammoboxes\data\AmmoBox_CO.paa"};
};

They are two selections: 0 for the signs (that's what i want) and 1 for the base texture (they have 3 textures, one for each side, NATO, OPF and INDF).

The ammoboxes that inherits from this class (ammo, explosives, supports...), have this extra code:

class AnimationSources
	{
		class Ammo_source
		{
			source = "user";
			animPeriod = 1;
			initPhase = 0;
		};
		class AmmoOrd_source
		{
			source = "user";
			animPeriod = 1;
			initPhase = 1;
		};
		class Grenades_source
		{
			source = "user";
			animPeriod = 1;
			initPhase = 1;
		};
		class Support_source
		{
			source = "user";
			animPeriod = 1;
			initPhase = 1;
		};
	};

initPhase = 0; seems the key. And there is where I'm stuck. How I must define the classes for AnimationSources?

I need something else in the model?

Thanks,

Edited by drredfox

Share this post


Link to post
Share on other sites

Have you defined the hiddenselections as sections in your model.cfg file? You'll probably want something like this:

class CfgModels
{
class Default
{
	sectionsInherit="";
	sections[] = {};
	skeletonName = "";
};

class St_Box: Default
{
	sections[] =
	{
		"Text"
	};
};
};

I don't think you need the animationssources section of your config, either. (AFAIK BIS have all the different boxes in one p3d, then they render dynamically based on what sort of crates are needed)

Share this post


Link to post
Share on other sites

In fact, I don't have "model.cfg". I've created one with the code you provided. Also I've modified the config.cpp. Still no luck.

Config.cpp

class CfgVehicles {
class ReammoBox_F;
class ST1_Box: ReammoBox_F {
	scope = 0;
};

class ST1_Med_Box: ST1_Box {
	author="DrRedfox";
	scope = 2;
	scopeCurator = public;
	vehicleClass = "Ammo";
	displayName = "ST1 Caja Medica";
	model = "\st_box\st_box";
	icon = "iconCrateWpns";
	hiddenSelections[] = {"text"};
	hiddenSelectionsTextures[] = {"\st_box\data\hiddenText.paa"};
	class TransportWeapons{};
	class TransportMagazines{};
	class TransportItems{};
};
};

This is the base model, but the config (and the item placed in the editor) it's from a medical supply box. And this is how it looks:

http://i.imgur.com/pg5CLbz.jpg (126 kB)

That's how it must look:

http://i.imgur.com/CLGWPCI.png (1021 kB)

---------- Post added at 07:14 PM ---------- Previous post was at 07:02 PM ----------

So close. I've made a mistake by changing the class on model.cfg. Now it applies the texture, but...http://i.imgur.com/WAPGg4z.jpg (307 kB)

The texture it's inverted and the black colour should be transparent. Maybe it's caused by the texture itself. I've checked the Alpha Channel and it's OK.

Edited by drredfox

Share this post


Link to post
Share on other sites
So close. I've made a mistake by changing the class on model.cfg. Now it applies the texture, but...http://i.imgur.com/WAPGg4z.jpg (307 kB)

The texture it's inverted and the black colour should be transparent. Maybe it's caused by the texture itself. Gonna check that.

Configs are working perfectly - you haven't put _ca at the end of your texture (ie, hiddenText_ca.paa) - you might want to check the rest of your .paas follow the texture naming rules. The inversion is probably caused by the UV map, just transform (2D) -> Mirror X/Y (depending on camera orientation) then reverse faces (since mirror points inverts faces for some reason) in oxygen/object builder to fix it (easier than messing with the UV-editor IMHO :p )

Edited by BiggerDave

Share this post


Link to post
Share on other sites

Thanks, now the texture is in the correct orientation. But the black texture still persist. I've made what you told me but doesn't works. I don't know what happens to my model/textures.

Found this thread with the same problem, but really, i don't get it. http://forums.bistudio.com/showthread.php?169660-hiddenselection-amp-alpha-channel&p=2575593&viewfull=1#post2575593

My textures are as follow:

  • - Base texture: Diffuse map. Named _co.paa. Set in model.p3d
  • - Hidden Texture: Diffuse map with alpha channel. Named _ca.paa
  • - rvmat: contains the _co, _nohq and _smdi textures. (I don't know why without the _co, the texture appears black)

All in 2048x2048 resolution.

Also, I've tried to add an alpha channel to the base texture, renaming to _ca, and still the same. What i'm missing here? It's very frustating. I've made the model and textures in half the time i'm spending to import into A3...

Share this post


Link to post
Share on other sites

Are you saving the file you want to have an alpha texture as _ca.tga before you convert it to _ca.paa?

It doesn't work if you just rename the texture after it's been converted. The suffix has to be there in the original texture name because the tools use the name to encode information into the .paa file about how the game should render it.

Share this post


Link to post
Share on other sites

Yes, I'm doing like that. The texture it's ok. I've tested with setObjectTexture and here's the result:

http://i.imgur.com/VETbPdQ.jpg (119 kB)

So the problem must be in the model or in the base texture. Besides creating a named selection (on the model.p3d) and assign as hiddenTexture, Is there anything else to do?

Share this post


Link to post
Share on other sites

What texture is set inside the .p3d on the "text" selection?

Try applying #(argb,8,8,3)color(0,0,0,0,CA) in the texture field on the "text" selection

Edited by da12thMonkey

Share this post


Link to post
Share on other sites

In the "text" selection there is no texture.

I set from the config.cpp

        hiddenSelections[] = {"text"};
       hiddenSelectionsTextures[] = {"\st_box\data\hiddenText.paa"};

For the base texture (without any decal), I've selected all the faces in the lod 0 and set it.

My project files, in case you want to check.

https://mega.co.nz/#!1l03TT4S!OSsu8RPo0wbSaLDqA5J9vBeVTZHnOFie3XMMV7N6E7I

Share this post


Link to post
Share on other sites

As I said above, you should try applying an invisible _CA type texture to the "text" selection inside the model.

#(argb,8,8,3)color(0,0,0,0,CA) is the code for a procedurally generated _CA type texture with 0% opacity (i.e. an invisible texture) so that could work.

Share this post


Link to post
Share on other sites

hiddenselection replaces the whole texture on that part of the model, so if you got your alpha texture working with that current setup the wood wouldn't show underneath the text anyway. With the model set up like that it'd be more efficient to make the whole box part of the hiddenselection and apply the text directly to your original wood texture in photoshop and save a load of _co.paa textures with no alpha, so that you're effectively reskining the whole box.

So yea, if you want the text as a separate alpha overlay you need to create a polyplane that lies just above the surface of the box and set the hiddenselection to that.

Share this post


Link to post
Share on other sites

Ok, thanks to you and BiggerDave. I owe you a beer.

Gonna try ASAP.

Share this post


Link to post
Share on other sites

http://i.imgur.com/pCDtpPa.jpg (139 kB)

:yay::yay::yay:

I've made the whole model as a hidden selection and a texture for every kind of box. Maybe isn't the best way to do, but I'm tired of this addon.

I've learned important things with this for future addons.

Thanks for your answers. You've been very helpful.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×