www.tombraiderforums.com

Go Back   www.tombraiderforums.com > Tomb Raider Modding > Tomb Raider Level Editor > Software Development

Reply
 
Thread Tools
Old 29-06-16, 00:48   #11
zdimension
Hobbyist
 
zdimension's Avatar
 
Join Date: Feb 2016
Location: Somewhere in France
Posts: 66
Default

I need help. A TR4 level starts with 3 uint16: num_room_textiles (non-bumped room texture tiles), num_obj_textiles (model texture tiles) and num_bump_textiles (bumped room texture tiles). Is there a way to generate/guess them from the textures array (from a TR1-3 level) ?
zdimension is offline   Reply With Quote
Old 29-06-16, 02:16   #12
b122251
Explorer
 
b122251's Avatar
 
Join Date: Aug 2013
Posts: 560
Default

Quote:
Originally Posted by zdimension View Post
I need help. A TR4 level starts with 3 uint16: num_room_textiles (non-bumped room texture tiles), num_obj_textiles (model texture tiles) and num_bump_textiles (bumped room texture tiles). Is there a way to generate/guess them from the textures array (from a TR1-3 level) ?
Well, if you're converting from TR1-3 to TR4, you can just make the bump mapped textures empty, because TR1-3 didn't have bump mapping. Also I'm pretty sure TR4 just stores bitmap data like TR1-3 (except that TR4 include zlib-compression), so you can pretty much just copy that and compress it. I do know for a fact that TR1-3 do NOT have separate texture tiles for object textures and room textures. Both are stored in the same bitmap, and both are addressed in the same way as ObjectTexture structs, so if TR4 makes a distinction between them, there's no way to find out directly from TR1-3. However, I think TR4 does the same in that regard as TR1-3.
b122251 is offline   Reply With Quote
Old 29-06-16, 04:36   #13
Cochrane
Gold Contributor
 
Cochrane's Avatar
 
Join Date: Apr 2006
Location: Germany
Posts: 16,047
Default

Yeah, TR1-3 habitually mix room textures and object textures in the same texture tile. I would suggest experimenting whether TR4 works if you just set either num_room_textiles or num_object_textiles to 0 and then put everything gin the other bucket. Otherwise, this will be annoying. I'm not aware of any way of finding out whether a texture belongs to a room or an object other than by going through each room and object mesh and enumerating all the textures they reference.
__________________
GŁter auf die Bahn!
Cochrane is online now   Reply With Quote
Old 29-06-16, 14:32   #14
zdimension
Hobbyist
 
zdimension's Avatar
 
Join Date: Feb 2016
Location: Somewhere in France
Posts: 66
Default

Thanks, I'll try that. For now, I've managed to convert a TR1 level (City of Vilcacamba) to TR1 (to test if the writing part works), I'm getting two files with identical file size but there are some differences and neither TR1 nor Rview are able to load it.
zdimension is offline   Reply With Quote
Old 29-06-16, 16:34   #15
zdimension
Hobbyist
 
zdimension's Avatar
 
Join Date: Feb 2016
Location: Somewhere in France
Posts: 66
Default

Does anyone know what it means when the MeshIndices ('MeshPointers' on TRosettaStone) array contains 0 ?
I mean it's normal that the first item has a value of 0 (since it's the first item), but for example, in City of Vilcabamba (LEVEL2.PHD), around half of the items have a value of 0. What does that mean? That the first mesh (in the file) is present multiple times in the array?
zdimension is offline   Reply With Quote
Old 29-06-16, 18:17   #16
Cochrane
Gold Contributor
 
Cochrane's Avatar
 
Join Date: Apr 2006
Location: Germany
Posts: 16,047
Default

Yes. Or at least that's how I always interpreted it. I think these are generally placeholder meshes that mark e.g. flames or other special effects, and don't get rendered by the game engine at all, so they use the first mesh (typically Lara's hips). In TR3 and TR4 they changed to the pyramid thing. I'm not sure why these are different meshes that use the mesh pointers to use the same data, but that's how it works for some reason.

In my experience at least Tomb Raider 2 does not mind if you just duplicate the values for the meshes and give them separate Mesh Pointer values. You do need to keep alignment in mind; I think it was four-byte alignment here.

As for the problems you're seeing: A good hex editor with diff support is your friend. Or write a unit test that does whatever the C# equivalent of memcmp is.
__________________
GŁter auf die Bahn!
Cochrane is online now   Reply With Quote
Old 29-06-16, 18:48   #17
zdimension
Hobbyist
 
zdimension's Avatar
 
Join Date: Feb 2016
Location: Somewhere in France
Posts: 66
Default

Thanks, in fact I'm using HxD for comparing files, and then I just place breakpoints everywhere until the BinaryWriter's position is where the diff is.
Also for the alignment, OH THAT'S WHY THERE'S ALWAYS LIKE 2 OR 3 BYTES BETWEEN EACH MESH. THANKS.
zdimension is offline   Reply With Quote
Old 29-06-16, 20:20   #18
Cochrane
Gold Contributor
 
Cochrane's Avatar
 
Join Date: Apr 2006
Location: Germany
Posts: 16,047
Default

The weird thing is that this is more or less the only case where the engine cares about alignment. Anything else tends to be all over the place.
__________________
GŁter auf die Bahn!
Cochrane is online now   Reply With Quote
Old 29-06-16, 21:50   #19
zdimension
Hobbyist
 
zdimension's Avatar
 
Join Date: Feb 2016
Location: Somewhere in France
Posts: 66
Default

Thank you very much Cochrane, now writing of the mesh array works perfectly.
zdimension is offline   Reply With Quote
Old 30-06-16, 02:40   #20
zdimension
Hobbyist
 
zdimension's Avatar
 
Join Date: Feb 2016
Location: Somewhere in France
Posts: 66
Default

FINALLY! Now, "re-compilation" of a level (i.e. converting a TR2 level to a TR2 level, so that the result should be identical to the input) works perfectly (for TR1 up to TR3). The only differences between input and output are some frame index or offset stuff (that doesn't affect gameplay). Now, I am going to finish the TR4 and TR5 code, and then I will try converting levels between different games.
zdimension is offline   Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 06:04.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.