www.tombraiderforums.com  

Go Back   www.tombraiderforums.com > Tomb Raider Modding > Tomb Raider Level Editor > Next Generation Level Editor

Reply
 
Thread Tools
Old 04-04-18, 21:39   #421
AkyV
Moderator
 
Join Date: Dec 2011
Location: Hungary
Posts: 4,450
Default

Ah, that makes sense.

(Joey said something similar, but I didn't get the picture there... )
AkyV is offline   Reply With Quote
Old 05-04-18, 17:20   #422
JMN
Explorer
 
Join Date: Sep 2006
Posts: 674
Default

Basic matrix functions in tomb4:

phd_PushMatrix()
Pushes a new matrix onto the stack. Will contain the combined transformations from previous pushed matrices.

phd_TranslateAbs(int x, int y, int z)
Translate the current matrix to the absolute coordinates provided.

phd_TranslateRel(int x, int y, int z) // 0x48DFD0
Translate the current matrix relative to the previous one.

phd_RotYXZ(short HOrient, short VOrient, short ROrient)
Rotates the current matrix around the Y, X, Z axes, in that order.

phd_RotY(short Orient)
Rotates the current matrix around the Y axis only.

phd_RotX(short Orient) // 0x48E080
Rotates the current matrix around the X axis only.

phd_RotZ(short Orient) // 0x48E1E0
Rotates the current matrix around the Z axis only.

gar_RotYXZsuperpack(short **pprot, int skip) // 0x44FE00
Same as phd_RotYXZ, but takes a single value containing all rotations. Used when drawing animated objects as the rotation values are encoded in the keyframes as a single value. Not sure what skip does, usually set to 0.

ScaleCurrentMatrix(StrTripla *pTripla)
Scales the current matrix on the X, Y, Z axes.

phd_PopMatrix()
Pops the current matrix and returns to the previous one. All transformations applied since the last push are discarded.
Defined as a macro in the source, so can't use function pointer to call. Do the following instead:
*Trng.pGlobTomb4->pAdr->pZonaRecord30 -= 48;

phd_PutPolygons_train(StrMeshTr4 *pMesh, int SpostamentoSuX)
Puts a single mesh to be drawn. Not a matrix function, but will use the combined transformations of the current matrix when drawing.

Pushing/popping matrices are important when drawing animated objects according to their mesh trees. Each mesh will have push and/or pop flags indicating when to push and/or pop a matrix.

Also, remember to always pop what you've pushed, or else...

JMN is offline   Reply With Quote
Old 05-04-18, 17:49   #423
AkyV
Moderator
 
Join Date: Dec 2011
Location: Hungary
Posts: 4,450
Default

Bravo, JMN, you are our saviour!
Don't you want to write a little tutorial about the undiscovered functions of TR4? Perhaps a bit bigger one, with one little simple example for each?
That would be sssso helpful!
AkyV is offline   Reply With Quote
Old 05-04-18, 17:52   #424
Dustie
Relic Hunter
 
Dustie's Avatar
 
Join Date: Apr 2005
Location: Poland
Posts: 9,208
Default

and that music! Genius!!!


Are these functions used for rendering? Or are they part of game logic? I'm struggling to understand where do they belong. Are they used to invoke 3D objects being drawn on the screen?
Dustie is offline   Reply With Quote
Old 06-04-18, 16:19   #425
JMN
Explorer
 
Join Date: Sep 2006
Posts: 674
Default

Quote:
Originally Posted by AkyV View Post
Don't you want to write a little tutorial about the undiscovered functions of TR4? Perhaps a bit bigger one, with one little simple example for each?
Still trying to get my own head around all these functions and more, but will try when I have some time.

Quote:
Originally Posted by Dustie View Post
Are these functions used for rendering? Or are they part of game logic? I'm struggling to understand where do they belong. Are they used to invoke 3D objects being drawn on the screen?
They're primarily used when rendering stuff on screen, yes. Matrices are a very important tool when doing computer graphics programming. This is probably one of the best sources on the topic: https://www.scratchapixel.com/.

You could always use the plugin functions like DrawObject2D, DrawMesh3D, etc., but if you want full control you'll need these functions. For example there's no DrawObject3D, so that's something where matrices will come in handy if you want to implement such a function.
JMN is offline   Reply With Quote
Old 06-04-18, 18:47   #426
Dustie
Relic Hunter
 
Dustie's Avatar
 
Join Date: Apr 2005
Location: Poland
Posts: 9,208
Default

I see. I still don't fully understand how they fit in the flow of the tomb4 code, but I'm guessing it is possible to interfere with both game logic phase and rendering phase of the code using the plugins and that's why the matrix functions even do anything when plugins call for them.

I'm also guessing (since I haven't studied the code that much) that parts responsible for enemies (or all other stuff for the matter) define not just their behavior logic, but also their rendering methods. I would have thought there is a separate "module" which handles that (and produces, for example, the gun flash), but judging from this all is done in a more "manual" manner with instructions to render graphics being called from logic code (which seems pretty messy).
Dustie is offline   Reply With Quote
Old 06-04-18, 20:15   #427
Wolf 7
Historian
 
Join Date: Apr 2018
Posts: 291
Unhappy Troubles?

I don't actually know if this is the right thread in which asking this but I'll try anyway.
I'm having some kind of troubles: the AkyV's plugin mix 1 is making my roomeditor giving a lot of error before getting started. Then it works perfect, I just wanted to know if this was normal or not. Thanks to whoever answers me.
Wolf 7 is offline   Reply With Quote
Old 06-04-18, 21:32   #428
AkyV
Moderator
 
Join Date: Dec 2011
Location: Hungary
Posts: 4,450
Default

Quote:
Originally Posted by JMN View Post
Still trying to get my own head around all these functions and more, but will try when I have some time.
Cool!

Quote:
Originally Posted by Wolf 7 View Post
I don't actually know if this is the right thread in which asking this but I'll try anyway.
I'm having some kind of troubles: the AkyV's plugin mix 1 is making my roomeditor giving a lot of error before getting started. Then it works perfect, I just wanted to know if this was normal or not. Thanks to whoever answers me.
Hi!
First, of all, no, this is the wrong thread, it is about how to make plugins, not how to use plugins. About my plugin, next time use this.

Then, errors then perfect? It sounds strange, I don't know what was that.
However, I can only repeat again and again my warnings:

Quote:
Please, do not forget to check if your TRNG version is not older than the TRNG version recommended in the plugin text files! (Useable TRNG is 1.3.0.7 or higher for my plugin.)

A fresh installation of TRLE and TRNG is recommended before using plugins!

Do not install TRNG and NG Center in the same folder.

Be careful with unwanted spaces in the folder, route names.
AkyV is offline   Reply With Quote
Old 07-04-18, 08:37   #429
LGG_PRODUCTION
Explorer
 
LGG_PRODUCTION's Avatar
 
Join Date: Jul 2010
Location: Italy
Posts: 834
Default

News about TR3 enemies ?
__________________
I hope in some good news about TRNG!
LGG_PRODUCTION is offline   Reply With Quote
Old 07-04-18, 09:54   #430
AODfan
Archaeologist
 
AODfan's Avatar
 
Join Date: Jun 2010
Location: Germany
Posts: 1,503
Default

Quote:
Originally Posted by JMN View Post
pZonaRecord30 is the address to the top of the matrix stack which is basically just an array consisting of matrix elements. Each matrix consists of 4x3 32bit integers, so 12 x 4 bytes per matrix. To push or pop a matrix, you increment or decrement the address by 48 bytes.

What you can also do is get a pointer to the actual matrix stack allowing you to do the following:

Code:
int *mStack = (int*)(*Trng.pGlobTomb4->pAdr->pZonaRecord30);

// pop matrix
*Trng.pGlobTomb4->pAdr->pZonaRecord30 = (int)(mStack - 12);
In the assembly you'll see the following where matrices are popped:

Code:
SUB DWORD PTR [ptr_ZonaRecord30],30h
phd_PushMatrix does the opposite:

Code:
ADD DWORD PTR [ptr_ZonaRecord30],30h
That makes sense. Thanks for the explanation

Quote:
Originally Posted by LGG_PRODUCTION View Post
News about TR3 enemies ?
I'm gonna collect a few enemies into one plugin
AODfan is offline   Reply With Quote
Reply

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 01:15.


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