|
Can t change my material (name changed)
#279326
07/17/09 09:56
07/17/09 09:56
|
Joined: Oct 2008
Posts: 681 Germany
Ayumi
OP
User
|
OP
User
Joined: Oct 2008
Posts: 681
Germany
|
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)
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;
}
Last edited by Ayumi; 07/17/09 12:01.
|
|
|
Re: New Problem -.-
[Re: VeT]
#279366
07/17/09 12:01
07/17/09 12:01
|
Joined: Oct 2008
Posts: 681 Germany
Ayumi
OP
User
|
OP
User
Joined: Oct 2008
Posts: 681
Germany
|
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:
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;
}
|
|
|
Re: New Problem -.-
[Re: Widi]
#279385
07/17/09 12:58
07/17/09 12:58
|
Joined: Oct 2008
Posts: 681 Germany
Ayumi
OP
User
|
OP
User
Joined: Oct 2008
Posts: 681
Germany
|
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.
Last edited by Ayumi; 07/17/09 13:02.
|
|
|
Re: New Problem -.-
[Re: Ayumi]
#279459
07/17/09 18:13
07/17/09 18:13
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
try this:
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;
}
Last edited by Widi; 07/17/09 18:20.
|
|
|
|