Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,466 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
wmpmdl7 SDK Open, Save - buffer #391472
01/12/12 21:55
01/12/12 21:55
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Hi,

is it possible to add an overloaded method to the reader and writer classes -of the wmpmdl7 SDK- to read/write from/to a memory buffer instead? This way it would be possible to construct a model/terrain correctly in memory with the SDK, so that the engine could read it from a named buffer without using the hard disc inbetween; this also enables the support for reading models/terrains from WRS ressources.

Best regards,
-Christian

Last edited by HeelX; 01/12/12 23:20.
Re: wmpmdl7 SDK Open, Save - buffer [Re: HeelX] #391475
01/12/12 23:14
01/12/12 23:14
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
add_buffer()?
Or are you not working with acknex.dll?

Code:
void makeMdlBuffer()
{
	var vSize;
	byte* buffer;
	
	/* the minimum MDL5 has no vertices and one single frame.
	   It requires 120 Byte of Memory
	   header: 84 bytes
	   frame:  36 bytes
	           byte pack info: 4 bytes
	           bounding box:   16 bytes (word packed)
	           frame name:     16 bytes

	   This is a hack to overcome the incompatibility between
	   NULL-Entities and ent_setmesh().
	   MDL5 format info taken from Acknex manual
	*/   
	vSize = 120;
	buffer = (byte*)malloc(sizeof(byte) * vSize);

	/* since there is no skin, no uv map, no lod, most bytes can remain zero */
	memset(buffer, 0x0, vSize);
	
	/* set file type info */
	buffer[0] = 'M';   
	buffer[1] = 'D';   
	buffer[2] = 'L';   
	buffer[3] = '5';
	
	/* set number of frames at bytes 69-72 */  
	buffer[68] = 1;
	
	/* MDL5 seems to support word packed vertex data only. 
	   Enable word packing at bytes 85-88 */
	buffer[84] = 2;

	/* that's it. Amazingly simple */
	add_buffer("simple.mdl", buffer, vSize);
}

...
	entDummy = ent_create("simple.mdl", vecPos, NULL);
...



Re: wmpmdl7 SDK Open, Save - buffer [Re: HeelX] #391476
01/12/12 23:20
01/12/12 23:20
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
I use the acknex.dll, but as the thread title indicates, I meant the

Quote:
wmpmdl7 SDK


and yes, then I could use add_buffer to write with the SDK into the buffer and load from there. Or load from the resource into a buffer and read with the SDK from there. I construct, load and save at the moment terrains with the SDK and would love to do everything in-memory, e.g. to create for instance procedural terrains and save it to file at an undefined point in time later.

Since the runtime functions are very very limited (for all other use cases as well), I use at the moment the HD. Which actually works, but, as I said, in memory would be more useful, especially when you are in the need to load a model/terrain from a WRS resource.

Last edited by HeelX; 01/12/12 23:26.
Re: wmpmdl7 SDK Open, Save - buffer [Re: HeelX] #391477
01/12/12 23:31
01/12/12 23:31
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
why not just use add_buffer() on the data package which is going to be saved by the SDK? Or don't you have access to the real memory layout as its construction is hidden somewhere in the sdk dll?

I have no experience with this SDK. I took a look and figured out that I didn't figure it out.

Re: wmpmdl7 SDK Open, Save - buffer [Re: FBL] #391499
01/13/12 12:09
01/13/12 12:09
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
OK, I checked it again. There is a public method in both the reader classes for mdl's and hmp's called

Code:
long Load(unsigned char * ptr, int size);



which might do the job for the opening from a buffer --- but that is just a guess, because comments are rare along the SDK sources. Though, in the writer classes there is just a method

Code:
Open(const char * file);

and nothing more.

So, @JCL: can you confirm 1.) that the method "Load" is intended for reading from a buffer and 2.) that there is no method for writing to a buffer at the moment? In the case of 2.), would you mind to add methods to the hmp and mdl writer classes for that?

Best regards,
-Christian

Re: wmpmdl7 SDK Open, Save - buffer [Re: HeelX] #391683
01/14/12 22:56
01/14/12 22:56
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Quote:
@JCL: can you confirm 1.) that the method "Load" is intended for reading from a buffer


No hurry, I confirm this by myself. It is also more robust, because if I open a file which is not in the work dir, the reader confirms that the file is opened (sic!), but I get a NULL-header... weird.

Here is the pattern:

Code:
// load file into buffer
long buffersize = 0;
void* buffer = file_load(filename, NULL, &buffersize);

HMP7R hmp;
if (hmp.Load((unsigned char*)buffer, buffersize))
{
	// get header
	const HMP5_HEADER* header = NULL;
	bool bHeader = hmp.Head(&header);

	if (bHeader && (header != NULL))
	{
		// do some magic!
	}

	hmp.Close(); // close file
}

// free the buffer
file_load(NULL, buffer, NULL);



So, @JCL: Do you think you can add saving to a buffer or so? smile please!

Last edited by HeelX; 01/14/12 22:57.

Moderated by  aztec, Spirit 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1