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,633 guests, and 5 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
Question about mat_effect #457424
01/18/16 02:35
01/18/16 02:35
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Hi,

If I use this code, I get the anticipated results, a texture tiled 2x:

Code:
function mtlEffect_init()

{

      
   float rotation_matrix[16] =
		{ 1.0, 0.0, 0.0, 0.0,
		  0.0, 1.0,	0.0, 0.0,
		  0.0, 0.0, 1.0, 0.0,
		  0.0, 0.0, 0.0, 1.0 };
		  
	
	float temp_matrix[16] =
		{ 1.0, 0.0, 0.0, 0.0,
		  0.0, 1.0,	0.0, 0.0,
		  0.0, 0.0, 1.0, 0.0,
		  0.0, 0.0, 0.0, 1.0 };	  
		  
			
	// scale the texture
	rotation_matrix[0] = 2;
	rotation_matrix[5] = 2;
	
	mat_set(temp_matrix, rotation_matrix);
	
	mat_effect1 = temp_matrix; 
	 
}





But if I use this code I don't. Am I misinterpreting the usage from the manual?

Code:
function mtlEffect_init()

{

      
   float rotation_matrix[16] =
		{ 1.0, 0.0, 0.0, 0.0,
		  0.0, 1.0,	0.0, 0.0,
		  0.0, 0.0, 1.0, 0.0,
		  0.0, 0.0, 0.0, 1.0 };
		  
	
	float temp_matrix[16];	  
		  
			
	// scale the texture
	rotation_matrix[0] = 2;
	rotation_matrix[5] = 2;
	
	mat_set(temp_matrix, rotation_matrix);
	
	mat_effect1 = temp_matrix; 
	 
}





And even if I do this I get the results like the second image:

Code:
function mtlEffect_init()

{

      
   float rotation_matrix[16];
		  
	mat_identity(rotation_matrix);
			
	// scale the texture
	rotation_matrix[0] = 2;
	rotation_matrix[5] = 2;
	
	mat_effect1 = rotation_matrix; 
	 
}



I'm wondering why, but its not clear in the manual.

Thanks for any clarification.

Re: Question about mat_effect [Re: Steempipe] #457434
01/18/16 11:10
01/18/16 11:10
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
An effect matrix, just as any other variable or object, can only work as long as it is not deleted or overwritten. Your matrices are fine inside your functions, but just garbage outside. When you want a variable to survive the return of the function, you must declare it global or static.

Re: Question about mat_effect [Re: jcl] #457482
01/19/16 12:30
01/19/16 12:30
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Thanks for the lesson. It works great.


Moderated by  old_bill, Tobias 

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