PDA

View Full Version : For all of you who wants different saber colors check this out !


Tchouky
06-01-2002, 10:34 PM
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 ...
http://mbalch.free.fr/new1.jpg

normal
06-01-2002, 10:51 PM
Niiiiice..!

SPY_jmr1
06-01-2002, 10:56 PM
wootness to you dude!

anyhope of a GUI type of pick and paste kinda thing? even a standalone program for the values? that would be cool.

any ETA at all?

TIA

SPY

Tchouky
06-01-2002, 11:02 PM
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 .....)

normal
06-01-2002, 11:49 PM
Originally posted by Tchouky
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 .....)
I would be glad to see how you did it :)

JRA_Wolf
06-02-2002, 12:21 AM
I'd like to know how, as well..

bhango
06-02-2002, 01:14 AM
so would i ;o

fourwood
06-02-2002, 03:41 AM
Yes.... I'd love to know. Posting here or email at fourwood@cox.net would be awsome. Thanks!

Elessil
06-02-2002, 04:31 AM
Great work! Can't wait. And it's nice to see you used my skin, too :)

Please email me the info how you did it to wc2@gmx.net. If it involves image editing programs I think I can do it :)

Tchouky
06-02-2002, 07:15 AM
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.

EffJi
06-02-2002, 09:07 AM
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?

Tchouky
06-02-2002, 09:23 AM
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 ....

ASk
06-02-2002, 10:13 AM
hmm....looks good.
If you alow me to, i could try editing the UI, so in addition to selecting one of the predefined colors there will be a switch and three textboxes for R G and B.

Tchouky
06-02-2002, 10:16 AM
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...

Tchouky
06-02-2002, 10:21 AM
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 .....

ASk
06-02-2002, 10:28 AM
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?!?

Tchouky
06-02-2002, 11:17 AM
it s a vec4_t because there is the R, G,B and Alpha values...
the alpha is supposed to be the transparency .....

ASk
06-02-2002, 01:02 PM
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

Darkhold X
06-02-2002, 01:07 PM
So if all goes well you can completly define how you want your saber in game? Or do you still have to edit the glow, and line yourself? I dont reallt care I just want that pink glow out of the purple saber that I changed the colors to.:D

Tchouky
06-02-2002, 01:23 PM
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

ASk
06-02-2002, 01:29 PM
i made both vars as extern..compiles now...
i'm not sure that UI will work tho...it's a real mess to understand it

Tchouky
06-02-2002, 01:44 PM
does the ui work with commands and cvar or with cvar only ???
because what i did was create a command so i don't know if the ui will work .
and will you explain me how you did the ui slidebars....

thx

Tchouky
06-02-2002, 05:58 PM
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 ...

ASk
06-02-2002, 06:05 PM
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

ASk
06-03-2002, 03:22 AM
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

Tchouky
06-03-2002, 04:49 AM
cool can you send me the ui code now plz ???
i must test it !
btw i changed many thing to the code and i m modifying the client-server communication to add the colors in the client's info ....

i ll update the code as soon as i m back home ...

ASk
06-03-2002, 07:37 AM
anyway...the menu does not want to update on tck_saber 1
so i set the group of the controls so that they will show if saber is enabled

for now there's a textbox that accept input in form of "255 255 255" (w/o quotes)
if you manage to make the strcat to work, uncomment the saberred, saberblue and sabergreen items in the .menu
and comment the textbox

the link to the UI is at http://www.darklordofsith.net/ask/ui.zip

Garik Loran
06-03-2002, 01:52 PM
Very interesting. I am still learning C and C++, and the source code is a good motivation for me.
So your explenations are very interesting :)
Ok, now a question. How far have you come with the saber color mod and can you give us a release date or something?
Besides programming I love playing JK2 and I am eager to see your work ingame.
Don't want you to hurry, just wanna know.

max4013
06-03-2002, 02:02 PM
pas mal du tout tchouky :saberb: :saberr:

Tchouky
06-03-2002, 02:37 PM
Originally posted by max4013
pas mal du tout tchouky :saberb: :saberr:

merci beaucoup max !

(it s french btw for all of you who didn t understand....)

And curently the shape of the blade is done ....
The result is acceptable (you don't really see the diference betwen my sabers and the original ones)....
now i m working on how the others see your saber ....

stay tunned !

thanx very much for the ui code !
i m gonna try it now !

Tchouky
06-03-2002, 06:26 PM
ok everything seems to be fine !!!!!

I have reworte enterely my code and added many things ....
You can see the color of the opponent's saber (if he has or hasn't modifyed it with my cvar)
The BOTS too have their sabers .....
you can add in the
botfiles\bots.txt
the color of their sabers ....
with these cvars if you place them just after the color1 line

tck_saberred 80
tck_sabergreen 0
tck_saberblue 180

will make the bot have a dark purple saber !!

if you don t want the custom colors you can disable it with
the cvar : tck_saber 0

And the custom saber won't show up if all the rgb values are at 0
(because you will have no glow just the white core ...)
so it will keep your default saber ......

Ask : I tested your menu but i have to try it again ....
but it should be fine (i removed the tck_color so no strcat problems....).

Ko'or Oragahn
06-03-2002, 07:43 PM
Ouais chic ! D'autres fromages qui puent ! :D

Bon boul˘t capitaine !

Raptorz922
06-03-2002, 08:07 PM
Ok. In plain noob english could you please explain how to do saber colors?