Jump to content

Home

For all of you who wants different saber colors check this out !


Tchouky

Recommended Posts

ok it s a WIP and i m don t really like the shape of the blade but here are somme pics !

I have been able to change the trail and the color of the saber ....

 

i created a cvar witch allows you to define the color of the saber with the RGB values ....

curently only you can see it but as soon as i m satisfyed by the color trails shape and everything i ll change that ....

 

Curently you can t have a dark saber but i ll work on that too ...

 

here are some examples

EDITED scroll down to see the features ...

 

http://mbalch.free.fr/

 

and some preview

i know the screenshot is not very good but ...

new1.jpg

Link to comment
Share on other sites

well i m redoing the core and the blur saber effect ...

i ll add more color arround the saber ....

for creating a program we'll see ...but most picture editing software have one ....

 

and no eta for the moment .

 

 

btw normal if you or any other modder who wants to know how i did it just ask (i ll send you my code or explain .....)

Link to comment
Share on other sites

Every changes are in the cgame dll

 

so in the fisrt place i created an extern struct in cg_local.h

wich will keep the rgb values.

 

ttypedef struct 
{
vec3_t sabercolor;
cgMedia_t media;

} tck_t;

 

the cgMedia_t is to have a place to load my shaders....

it s stupid i could use qhandle_t but right now i store them in

tck.media.blueSaberGlowShader

tck.media.blueSaberCoreShader

....

 

next, in consolecmds.c

 

add a function like this

 static void CG_tckcolor_f (void)
{
tck.sabercolor[0] = atoi (CG_Argv(1));
tck.sabercolor[1] = atoi (CG_Argv(2));
tck.sabercolor[2] = atoi (CG_Argv(3));
}

 

and add

	{ "tck_color", CG_tckcolor_f},

in the array consoleCommand_t ...

 

now when you type tck_color 255 255 255 the settings of your blade would be white ....

 

now we must change the drawing of the lightsaber .....

goto cg_players.c and find the function that calculates the trail of the saber ...it s around the line 4325

there is a label CheckTrail:

 

there you can see a big switch wich depends on the color

after the switch add this :

 

 			if (tck_saber.integer)
			VectorSet(rgb1,tck.sabercolor[0],tck.sabercolor[1],tck.sabercolor[2]);

 

that s right i forgot to tell you to create a cvar in the cg_main.c

it s called tck_saber.

do that in cg_main.

the if tck_saber.integer means if you set tck_saber 1 in your console....

 

back to the cg_players.c now if you compile it if you set the tck_saber 1 in the game and then tck_color r g b

then your saber trail will be of the rgb values you set..

 

Now we need to fix the blade itself..

 

and so you go to the line 3672 ...(or so i added lines so i don t know if it s the same ...)

to the CG_dosaber function

 

after the switch ( color )

add your custom code

 

 
if (tck_saber.integer)
{
	glow = tck.media.blueSaberGlowShader;
	blade = tck.media.purpleSaberCoreShader;
	blade2 = tck.media.purpleSaberGlowShader;
	VectorSet(rgb,tck.sabercolor[0]/255,tck.sabercolor[1]/255,tck.sabercolor[2]/255);
   }

the tck.media.bluesaberglow are difened in the cg_main.c

i know it sucks using a .media to store 3 stupid shaders but when i ll have time i ll rewrite the code in a good way....

 

so go to cg_main.c line 910 register sounds

 

and add

tck.media.blueSaberCoreShader       = trap_R_RegisterShader( "gfx/effects/sabers/tck_line" );
   tck.media.blueSaberGlowShader       = trap_R_RegisterShader( "gfx/effects/sabers/tck_glow" );
   tck.media.purpleSaberCoreShader       = trap_R_RegisterShader( "gfx/effects/sabers/tck_core" );
   tck.media.purpleSaberGlowShader       = trap_R_RegisterShader( "gfx/effects/sabers/tck_blade" );

 

the tck_blade tck_core and tck_glow are shaders i created ....

i won t explain in details but :

i created 3 jpg images all of them in black and withe only.

the tck_glow2 is the same as blue_glow2 or so but in black and white.

 

well i m gonna stop here for now cause i m testing different way of creating the core but here are a few hints :

 

the do_saber function is the only one i modify again you have to make it load your shaders instead of the original ones .....

 

and with the parameters

saber.shaderRGBA[0] = tck.sabercolor[0];

saber.shaderRGBA[1] = tck.sabercolor[1];

saber.shaderRGBA[2] = tck.sabercolor[2];

 

so check this by yourself now and as soon as i m satisfyed with the result i get

(i m curently working on the shader loading cause on the picture the glow is way too small .....)

i ll code it right and will write a real tutorial ....

i ll post new screen shots today too.

Link to comment
Share on other sites

would it be possible to change the color of the blurcore to another color than white?

 

Like making the core of the blue saber blue and the green saber green?

 

yep really easy !

But will it look good ? i don t know ....

i ll try and post screenshot if you want ....

Link to comment
Share on other sites

i ve redone the code and i m still curently changing some stuff as soon as it s ready i ll send the source to you !

no problem !

that would be great if you could do that in the ui coz i wanted to do it but i don t really know the ui code so i ll have to check ....

 

i m actually rewritting the code to be more clear and simple...

Link to comment
Share on other sites

great and when could even have a previsualisation of the saber because i saw the ui loaded a shader .

and my code loads 3 shaders for a saber instead of 2 :

 

- the glow2.jpg as usual

but in black and white and is loaded with

saber.shaderRGB[0]

saber.shaderRGB[1]

saber.shaderRGB[2]

equal to your rgb colors....

 

-the core is white and loaded in white ....(but i can fix that for the other dude)

without shadersrgb color's modified

 

-the blade

black and white and loaded

with the saders' rgb adjustements....

 

 

these 3 shaders draw a saber ....

 

for the ui we would still have to load the 2 last ones ....

but that could be easily done i think .....

Link to comment
Share on other sites

now i'm digging through all this UI code....

It's so messy, even I dont write code like this :p

 

[edit]

I just found the CD-KEY dialog displaying routine....boy...they are so lazy

 

[edit]

Here's probably the saber shader loading function

static void UI_DrawEffects(rectDef_t *rect, float scale, vec4_t color)

{

UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiSaberColorShaders[uiInfo.effectsColor]);

}

 

Notice that they don't use the scale and color in any way

and why is the color defined as vec4_t?!?

Link to comment
Share on other sites

ah...true

my mistake ;P

 

also, i tried adding your changes to the files, and got an error about tck undefined and alos about tck_saber being undefined.

 

I tried to correct the error by removing the definition from cg_main.c and placing these lines into cg_local.h:

tck_t tck;

vmCvar_t tck_saber;

but then while it compiles good in VC++, the VM compilers scream about redeclaration of both vars.

 

Also, I think I edited the UI files correctly, added 3 textboxes that would appear instead of saber display and saber colors + the code to handle them (it compiled correctly so i think it's ok :p, the code there is really messed up....)

But i can't test them without the cgame

Link to comment
Share on other sites

to ASk :

 

you have to let the vmCvar_t declaration in the main.c

but you have to export it in the cg_local.h

 

there is a block with the exportation of all variables :

extern vmCvar_t tck_saber;

so now you won't have this problem anymore....

 

i uploaded the source code (wich is cleaner that what i posted )

here

http://mbalch.free.fr/

and i ll post my shaders and jpg too

Link to comment
Share on other sites

so did you get it working ???? (the ui)

 

btw

i ve redone the blades and they are much better now ....

i ll do new scrrenshots when i ll have the time for it ...

and i m focusing on how to send the information to the server and vice versa ....

so that you'l be able to see the custom color of the others saber ...

Link to comment
Share on other sites

well

i had trouble with object placing on the menu

normal helped me out

i know that the functions are called, so i should just test it ;P

only thing is....

Q_strcat adds /0 at the end of the string...either i make 3 editboxes and strcat the values or i make on textbox (that's what it's now) and just assign the written in the textbox to the variable

(after some checks)

oh and btw...no preview yet...partly because i dont know what is the control that does it, and partly because i couldn't manage to find the code doing it

Link to comment
Share on other sites

ok tchouky...........my code works.

Now only to fix the small bugs left in the actual menu. And make it so that this box will appear instead of the colored saber when tck_saber is 1

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...