Jump to content

Photo
- - - - -

Pal2pac.dll texture handling


  • Please log in to reply
7 replies to this topic
Thread Starter
Dschulle
Dschulle

    Corporal

  • Members
  • 98 posts

  • Joined: 15-June 2002

Posted 28 January 2004 - 20:04 #1

I don't want to keep this cool info away from you, even if most editors might have no use for it.
The Pal2Pac.dll is included with O2. The rest of the info is inside the header.

Big THX to SUMA!  Posted Image

[quote name='(Dschulle @ Jan. 28 2004,17:18)']Could you provide me with a header file? Or give me the complete function call of "CreateTexture" and "CombineTexture".
[/QUOTE]

Here you are:


<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#ifndef _PAL2PAC_HPP
#define _PAL2PAC_HPP

#define MYDLL _ _ declspec ( dllexport ) _ _ stdcall
//the spaces should not be there,
// but iconboard does not like it without them

// dynamic linking types etc...

extern "C"
{

// Objektiv Interface

int MYDLL AddTexture( const char *libPath, const char *textPath, int size );
int MYDLL UpdateTexture( const char *dest, const char *src, int size );

int MYDLL CombineTexture
(
const char *D, const char *S1, const char *S2, const char *S3, const char *S4,
int size, const char *bank, const char *water
);

// Visitor Interface
void MYDLL TextureMix
(
const char *t,
const char *s1, const char *s2, const char *s3, const char *s4,
const char *bankDirectory, const char *bankTexture
);

struct TextureDataStruct
{
int _w,_h; // data dimensions
DWORD *_data; // pointer to ARGB 8888 data
};
void MYDLL CreateTextureData( TextureDataStruct &data, const char *name );
void MYDLL DestroyTextureData( TextureDataStruct &data );

COLORREF MYDLL TextureColor( const char *s );
DWORD MYDLL TextureColorARGB( const char *s );

typedef int stdcall UpdateTextureT( const char *dest, const char *src, int size );

typedef void stdcall DestroyTextureDataT( TextureDataStruct &data );

};

extern UpdateTextureT *UpdateTextureF;
extern CreateTextureDataT *CreateTextureDataF;
extern DestroyTextureDataT *DestroyTextureDataF;

void InitPal2Pac();

// class encapsulation of TextureDataStruct
class TextureData
{
struct TextureDataStruct _data;

public:
TextureData( const char *name=NULL )
{
if (!CreateTextureDataF) return;
CreateTextureDataF(_data,name);
}
~TextureData()
{
if (!DestroyTextureDataF) return;
DestroyTextureDataF(_data);
}
void Load( const char *name )
{
if (!CreateTextureDataF) return;
if (!DestroyTextureDataF) return;
DestroyTextureDataF(_data);
CreateTextureDataF(_data,name);
}

int W() const {return _data._w;}
int H() const {return _data._h;}
const DWORD *Data() const {return _data._data;}
DWORD GetPixel( int x, int y ) const {return _data._data[y*_data._w+x];}

private:
TextureData( const TextureData &src );
void operator =( const TextureData &src );
};

#endif
[/QUOTE]

If you think anyone else can use this for the benefit of OPF community, feel free to share it. You can create and load pal/pac files with this interface. It is far from flexible, but it may help you.





Ebud
Ebud

    Sergeant Major

  • Members
  • 1491 posts

  • Joined: 13-July 2001

Posted 29 January 2004 - 00:53 #2

OK, explain the use of this for a dummy like me. Will it make pac files "better"? Will it allow people to make batch converters? etc?





shinRaiden
shinRaiden

    BI Developer

  • 1956 posts

  • Joined: 07-April 2003

Posted 29 January 2004 - 04:53 #3

There really ain't a thread for this...

Basicly, this is the critical core code for exporting graphics into OFP PAA/PAC format. If you want to make a converter like texview, or create a viewer application, or a wrp editor, this is the key to WRITING textures.

Essentially, this is just the skeleton _defs and code to structure your data arrays of pixels, and properly process them through the pal2pac.dll included with Oxygen.

The biggest need that can now be filled is to make a transition masher, where you could load in some base textures, a list of desired transitions, and punch out textures. Or you could make a converter for other raw formats.
And where is that band that so vauntingly swore, That the havoc of war and the battle's confusion,
A home and a country shall leave us no more? Their blood has washed out their foul footstep's pollution.
No refuge could save the hireling and slave, From the terror of flight, or the gloom of the grave;
And the Star-Spangled Banner in triumph doth wave O'er the land of the free and the home of the brave!
(3rd stanza of the Star-Spangled Banner)

Ebud
Ebud

    Sergeant Major

  • Members
  • 1491 posts

  • Joined: 13-July 2001

Posted 29 January 2004 - 06:12 #4

well, my dream tool is a batch converter for taking a whole folder of tgas and converting them to paa or pac... hope someone makes one now Posted Image

Dwarden
Dwarden

    BI Developer

  • 9651 posts

  • Joined: 05-March 2002
  • LocationBrno, Czech Republic

Posted 29 January 2004 - 06:59 #5

I got idea, can someone made .paa .pac plugin for IrfanView? Posted Image))

RealTimeChat ~ARMA2 in Your browser (w/o Java), RealTimeChat ~ARMA3 in Your browser (w/o Java),
irc.GameSurge.net/ARMA2 (external IRC clients) irc.GameSurge.net/ARMA3 (external IRC clients)
ARMA 3 Feedback Tracker: http://feedback.arma...y_view_page.php
~100k fans @STEAM ARMA 2 + ARMA 2: OA + ARMA 3: + ~2k @XFIRE A2:OA
Follow my Twitter: http://twitter.com/FoltynD or my Facebook http://facebook.com/FoltynD


Romolus
Romolus

    Sergeant

  • Members
  • 154 posts

  • Joined: 11-July 2001

Posted 29 January 2004 - 07:22 #6

well, my dream tool is a batch converter for taking a whole folder of tgas and converting them to paa or pac... hope someone makes one now Posted Image

You allready can do this with the pal2pace.exe you find in your Bulldozer folder:

pal2pace *.tga


Unfortunately this header file doesn't enable us to write a better textur converter than texView since the dll encapsulates the function for the texture compression and the file headers for the texture files are still unknown so that you can't write your own compression function.

But it makes it much easier for tools like WrpTool to read and write OFP textures.
Posted Image

Suma
Suma

    BI Developer

  • 3707 posts

  • Joined: 27-June 2001

Posted 29 January 2004 - 08:27 #7

I think O2 Doc will suit best for this topic.
Ondrej Spanel, BIS Lead Programmer

Romolus
Romolus

    Sergeant

  • Members
  • 154 posts

  • Joined: 11-July 2001

Posted 29 January 2004 - 09:14 #8

I got idea, can someone made .paa .pac plugin for IrfanView? Posted Image))

Currently Dschulle is trying to integrate the pal2pac.dll into PaNSee, the texture browser that comes with WrpTool.

We are also looking into writing a plugin for Photoshop (and programs who can also use PS-plugins like PSP and others), but the problem is that pal2pac needs file names and writes the files by itself wich isn't the way a PS-plugin should handle it.
A PS-plugin only gets a buffer to write the data into, while PS handles all the file creating and opening stuff, you don't even get the filename from Photoshop.

So what we would need for this is basically the source code of the pal2pac.dll or some info about the texture file headers of paa and pac files (just the header info, we allready know the different formats for the texture data and how to write/read it)


.....................................

WrpTool dev