Can t change my material (name changed)

Posted By: Ayumi

Can t change my material (name changed) - 07/17/09 09:56

EDIT:Geaendert, da es einen ungehaltenen User gab, der
mein english in Frage stellt!
(Hatte etliche Jahre englisch aber in den jahren
geht wohl auch der ein oder andere Denkansatz verloren)

Ich habe hier einen Menue code der von der Syntax her
funktioniert aber nicht in seiner Funktionalitaet.

Ich moechte ueber ein Menue 3 Buttons anzeigen lassen
und per switch case function, je nach Button das Material
eines Models zur Laufzeit aendern.
Der Code sollte eigentlich funktionieren allerdings
frage ich mich nun, wieso die if verzweigung nicht funktioniert.

@Schrompf
Enschuldige bitte, das mein englisch fuer deine Verhaeltnisse
nicht gut genug ist.!!!!!!
Das Handbuch hab ich 3 Tage durchgelesen und nichts gefunden.
Und jeder faengt i-wann mal an oder?
Also hoer auf zu meckern.(Auch wenn ich dich verstehen kann)



Code:
var detail;

#define DETAIL_LOW 		0
#define DETAIL_MEDIUM 	        1
#define DETAIL_HIGH		2

PANEL* options_pan = 
{
	bmap = options_tga;
	layer = 30; 
	pos_x = 0;
	pos_y = 0;

        button_radio = 550, 400, low1_tga, low1_tga, low2_tga,menu_detail, NULL, NULL;
	button_radio = 610, 400, med1_tga, med1_tga, med2_tga,menu_detail, NULL, NULL;
	button_radio = 670, 403, high1_tga, high1_tga, high2_tga,menu_detail, NULL, NULL;
}


//count -1(define is 0, start is 1 ...-1 = 0
void menu_detail(var buttonNr)
{
	detail = buttonNr -1;
}

//Switch the buttons
void detail_einstellungen()
{
	switch(detail)
	{
		case DETAIL_LOW:			button_state(options_pan, 1,1);break;
		case DETAIL_MEDIUM:		button_state(options_pan, 2,1);break;
		case DETAIL_HIGH:			button_state(options_pan, 3,1);break;
	}
}

//________


MATERIAL* detail_test1 =
{
	effect = "detail_x.fx";
	event = detail_event;
	flags = ENABLE_RENDER;
}
MATERIAL* detail_test2 =
{
	effect = "empty_technique.fx";
	event = detail_event;
	flags = ENABLE_RENDER;
}


action detail_event()
{
	if(detail == DETAIL_HIGH)
	{
		wait(1);
		my.material = detail_test1;
		my.ambient = 90;
		return;			
	}
	else
		if(detail == DETAIL_MEDIUM)
		{
			wait(1);
			my.material = detail_test2;
			return;
			 
		}else 
			if(detail == DETAIL_LOW)
			{
				wait(1);
				                                            my.material=detail_test2;	
				//d3d_texlimit = 512;
				return;
				
			}	
			
			
	reset(my, DYNAMIC);
	//my.ambient = 90;
}


Posted By: MrGuest

Re: New Problem -.- - 07/17/09 11:29

when you hit a button, you call menu_detail, but this only changes var detail,

and in action detail_event(){ it's only searching on create for which detail it is

so... i'm guessing there's more to you code that creates the level after you've chosen detail, but if not, that's your problem

hope this helps
Posted By: VeT

Re: New Problem -.- - 07/17/09 11:29

Never name your post "New Problem -.-"... but "Materials Problem -.-" or "Menu Problem -.-".
Posted By: Ayumi

Re: New Problem -.- - 07/17/09 12:01

Thx and sry MrGuest and VeT.

I have edited my post just now.

The function menu_detail is put into the option panel.
Var detail you will see here:switch(detail)
so i think, it s right.
(I have had copy the Syntax example of (switch/ case)
function by the Rudy Game)

I have cleared all code what i don t need to show you.
Here is my code with the Main function:

Code:
var game_started = 0; // will be set to 1 when the game is started
var detail;

#define DETAIL_LOW 		0
#define DETAIL_MEDIUM 	        1
#define DETAIL_HIGH		2


//SStrings
STRING* UT_wmb = "unreal_Aussenlvl1.WMB";

//Function
function mouse_over();

//Main
function main()
{
	fps_max = 60;
	video_mode = 8; 				
	video_depth = 32; 
	video_screen = 1; 
        mouse_spot.x = 1; 
	mouse_spot.y = 1; 

        detail = DETAIL_HIGH; //set to high mode at the beginning
        set (main_pan, VISIBLE);

        vec_set (camera.x, nullvector); // move the camera to the origin
	while (game_started == 0) // this loop runs until the player presses the "New game" button
	{
		camera.pan += 0.1 * time_step; // rotate the camera gently
		camera.tilt += 0.02 * time_step; // on all the axis
		camera.roll += 0.05 * time_step;
		wait (1);
	}
	
}

//function start if pressed the start button on main pan
function start_game() 
{ 

	fps_max = 100;
	reset (main_pan, VISIBLE); 
	
	game_started = 1;
	mouse_mode = 0; 

		wait (1);
	}
	 
	preload_mode = 2;
	
	level_load (UT_wmb); // now load the real level
	wait (3);

	camera.z = 250; // set the camera up high
	camera.tilt = -90; // and then make it look down
}

function mouse_over() // this function runs when we move the mouse over one of the buttons on the panel
{
	snd_play (mouseover_wav, sound_vol, 0);
}	

function mouse_startup() // displays the mouse pointer
{
	mouse_mode = 2;
	mouse_map = cursor_tga;
	while (game_started == 0) // this loop runs until the game is started
	{
		vec_set(mouse_pos, mouse_cursor);
		wait (1); 		      
	}   
}



//the menue codes

PANEL* main_pan = 
{
	bmap = main_tga;
	layer = 20;
	pos_x = 0; 
	pos_y = 0; 
	//button = 52, 28, load1_pcx, load1_pcx, load2_pcx, NULL, NULL, mouse_over;
	//button = 45, 87, save1_pcx, save1_pcx, save2_pcx, NULL, NULL, mouse_over;
	button = 250, 350, new1_pcx, new1_pcx, new2_pcx, start_game, NULL, mouse_over;
	button = 350, 450, options1_pcx, options1_pcx, options2_pcx, set_options, NULL, mouse_over;		
	button = 390, 640, quit1_pcx, quit1_pcx, quit2_pcx, quit_game, NULL, mouse_over;
	button = 380, 550, Help1_tga, Help1_tga, Help2_tga, NULL, NULL, mouse_over;

	flags = OVERLAY;		
}

PANEL* options_pan = 
{
	bmap = options_tga;
	layer = 30; 
	pos_x = 0;
	pos_y = 0;
	
	button_radio = 550, 400, low1_tga, low1_tga, low2_tga,menu_detail, NULL, NULL;
	button_radio = 610, 400, med1_tga, med1_tga, med2_tga,menu_detail, NULL, NULL;
	button_radio = 670, 403, high1_tga, high1_tga, high2_tga,menu_detail, NULL, NULL;
	
	flags = OVERLAY;
}


// var detail for menue_detail, set in PANEL* options_pan
void menu_detail(var buttonNr)
{
	detail = buttonNr -1;
}

void detail_einstellungen()
{
	switch(detail)
	{
		case DETAIL_LOW:			button_state(options_pan, 1,1);break;
		case DETAIL_MEDIUM:		button_state(options_pan, 2,1);break;
		case DETAIL_HIGH:			button_state(options_pan, 3,1);break;
	}
}


//set Material 
//Detailmapping
//ENABLE_RENDER flag for switch material 

MATERIAL* detail_test1 =
{
	effect = "detail_x.fx";
	event = detail_event;
	flags = ENABLE_RENDER;
}
MATERIAL* detail_test2 =
{
	effect = "empty_technique.fx";
	event = detail_event;
	flags = ENABLE_RENDER;
}


action detail_event()
{
	if(detail == DETAIL_HIGH)
	{
		wait(1);
		my.material = detail_test1;
		my.ambient = 90;
		return; 			
	}
	/*
	else
		if(detail == DETAIL_MEDIUM)
		{
			wait(1);
			detail_test2 = mtl_create();
			return;
			 
		}else 
			if(detail == DETAIL_LOW)
			{
				wait(1);
				detail_test2 = mtl_create();
				return;
				
			}	
			*/
			
	reset(my, DYNAMIC);
	//my.ambient = 90;
}


Posted By: Widi

Re: New Problem -.- - 07/17/09 12:41

DYNAMIC: You don`t can reset the DYNAMIC flag and then change the material after... From the Manual: Statische Entities erlauben keine Events - einschließlich Materialevents.
function: from where you call the function detail_einstellungen() ? I don`t can find that.
material: Why is detail_event() a action and not a void / function?
Posted By: Ayumi

Re: New Problem -.- - 07/17/09 12:58

1) Oh, that i havn t known.I will clear it.

2) Maybe through "detail = buttonNr -1;"->switch(detail)???

3) It works with both.(Void,function,action)
But i have changed to function.

Btw:I am a noob for lite c code.(I am still learning).
thx for your answer.
Posted By: Widi

Re: New Problem -.- - 07/17/09 13:07

3: yes, it works both. The only different is that a action is show up in the WED Properties... But it is more "sauberes programmieren" if you use always the right one.

2: Sorry, whrite now in german, can better explain it (my english is not sooo good). Ich glaube du hast mich falsch verstanden. Du musst ja die Function detail_einstellungen() irgendwo aufrufen, aber wo? So wird diese Function gar nie durchgeführt!
Posted By: Ayumi

Re: New Problem -.- - 07/17/09 15:39

Mhm danke.

Ja, den englischen usern zu liebe ist es ok, in englisch zu schreiben;)

Ich hab dich richtig verstanden und dein englisch war i.O.
Meins is auch nicht besser^^

Ja du wirst lachen, aber die Frage wo diese unction aufgerufen wird ,
habe ich mich auch schon gefragt.

Im Rudi game wird diese in i-einer anderen Function aufgerufen
aber konnte damit nichts anfangen.
Und es bringt mir leider auch nicht wirklich was, diese in der main
aufzurufen aber ich teste nochmal durch.
Posted By: Ayumi

Re: New Problem -.- - 07/17/09 17:06

Nein, ich kann machen was ich will aber es aendert nicht sein
Material.

Punkte bisher ausgefuehrt:

- Eine Action geschrieben, die die Function als event function definiert
- Die Function der Case function in der Main Function gesetzt
- nur mit einer If verzweigung getestet
- "my.material" zu "mtl" ausgetauscht(wie es im Handbuch steht)
- wait anweisungen entfernt
Posted By: Widi

Re: New Problem -.- - 07/17/09 18:13

try this:
Code:
MATERIAL* detail_test1 =
{
	effect = "detail_x.fx";
}
MATERIAL* detail_test2 =
{
	effect = "empty_technique.fx";
}

void menu_detail(var buttonNr)
{
 	my = POINTER_ZU_DEINEM_MODEL;   // player?
	detail = buttonNr -1;
	switch(detail)
	{
		case DETAIL_LOW:	my.material = detail_test1;   button_state(options_pan, 1,1);   break;
		case DETAIL_MEDIUM:	my.material = detail_test1;   button_state(options_pan, 2,1);   break;
		case DETAIL_HIGH:	my.material = detail_test1;   button_state(options_pan, 3,1);   break;
	}
}


PANEL* options_pan = 
{
	bmap = options_tga;
	layer = 30; 
	pos_x = 0;
	pos_y = 0;
	
	button_radio = 550, 400, low1_tga, low1_tga, low2_tga,menu_detail, NULL, NULL;
	button_radio = 610, 400, med1_tga, med1_tga, med2_tga,menu_detail, NULL, NULL;
	button_radio = 670, 403, high1_tga, high1_tga, high2_tga,menu_detail, NULL, NULL;
	
	flags = OVERLAY;
}


Posted By: Ayumi

Re: New Problem -.- - 07/17/09 23:27

EDIT:

Sry ich hab mich nochmal schlau gemacht.
Und nun hab ichs verstanden^^

Und nein,leider funktionierts mit pointer
auch nicht-.-


Posted By: Ayumi

Re: New Problem -.- - 07/29/09 02:06

Keiner ne weitere Idee?
Posted By: Shinobi

Re: New Problem -.- - 07/29/09 18:24

Ich habe jetzt nicht alles gelesen aber wenn ich dein ersten posting richtig verstanden habe möchtest du einfach ein Material das einm entity zugewiesen wurde , zur laufzeit verändern . Nun dazu musst du am namen des Materials nichts verändern sondern nur dessen eigenschaften.

Ich habe z.b. In meinem Futurama Space Invaders Die Grünen Schilde (die eigendlich grau sind) mit einem Material versehen , so kann ich sie ganz weich von grün auf Rot oder Blau wechseln lassen. Schau dir dazu einfach das letzte Video an das du in meinem Space Invaders Threat sehen kannst. Wenn es sowas ist was du machen möchtest , dann kann ich dir weiter helfen.
Posted By: Ayumi

Re: New Problem -.- - 07/29/09 20:43

Mhm, ich hab mir das Video angeschut(schnuffig^^)aber i-wie
find ich da keine gruenen schilde(hab auch ne gruen rot schwaeche btw^^
nicht doll aber schon ziemlich..)

Ich moechte eigentlich nur zum test mal eine detailmap
(wie man sie z.b. aufs terrain setzt) entweder zur laufzeit
rendern(setzen) oder eben entfernen...je nach menue einstellung.
(Ist wie gesagt nur zum testen).

Kurzfassung:
- Material an / Material aus...zur laufzeit ...durch einen im menue
zugewiesenen schalter.

Danke fuer die antwort btw:)
Posted By: Shinobi

Re: New Problem -.- - 07/29/09 22:02

Ok das scheint mir dann doch etwas anderes zu sein als was ich gemacht habe , aber um ein Material ein und aus zu schalten musst du dem object das Material zuweisen um es ein zu schalten und mit "my.material=NULL;" kannst du es wieder entfernen bzw ab schalten.

Hoffe ich konnte dir damit helfen.
Posted By: Ayumi

Re: New Problem -.- - 07/30/09 03:31

Danke, ich habs noch nicht getestest...aber...ich loese erstmal andere
Problemchen bevor ich mich weiter dem wechsel der Materialien widme und
kkomme dann nochmal darauf zurueck:)
© 2024 lite-C Forums