PDA

View Full Version : How to change image/iwi in existing maps?



agribilos
10th March 2021, 10:33
Hi there.
I know you can quickly edit existing images (iwi) that are used by a map to display custom images or textures. I want to know if there is an easy way to add new iwi files (so you don't have to edit the original) to be used in an existing map. Or to you have to make an xmodel and spawn using this function? Any help welcome.


spawnModel( model, origin, angles )
{
if( !isdefined(model) || !isdefined(origin) )
return undefined;

if( !isdefined(angles) )
angles = (0,0,0);

spawn = spawn ("script_model",(0,0,0));
spawn.origin = origin;
spawn setmodel (model);
spawn.angles = angles;

return spawn;
}

agribilos
10th March 2021, 15:48
1647
This shown in the attached picture is done by editing the v_soze.iwi file. Just to be clear i would like to be able to put a poster like this in a custom location and ideally without having to modify the original iwi files. Any ideas on how it's possible?

pollo
11th March 2021, 11:42
For that you can use the IWI_X_DDS tool by DiegoLogic (http://www.diegologic.net/diegologic/CoD_tools/IWI%20X%20DDS.htm).

Basically you extract the original .iwi (in images folder) from the stock .iwds, double click it (open .iwi files with this program), and it will generate a .dds. Edit the image at your own likings, eg. this image is used for the signs in Toujane, I quickly edited it adding a "Custom Sign" text. That will be shown in certain areas where the actual map uses this texture (in Toujane, it will show in Brit spawn, at the tunnels on the left, and also in the little house below the infamous roof)

signs2.iwi
1648

Once you have the .dds ready (I personally use Photoshop CS6 + DDS plugin, but you can go for Paint.NET, Gimp, or the image editor of your preference), you can convert it back to .iwi using 2 ways:

1. CoD2 Asset Manager, in which you will need to make a new material, select the .dds as the color map, saving the .gdt and clicking on PC Convert -> Current asset. It will generate an .iwi in main/images and a material inside main/materials. You're just interested in the .iwi.

2. Use this tool, dds2iwi.exe, which iirc is made by @Tally. Drag and drop the .dds onto it, and you'll have it converted.
1649

After you got the .iwi, you just need to pack the output image into an .iwd (name it eg. z_img.iwd, so that it overrides the previous ones; and also dont put a long name on the .iwds because of the "iwdsum name mismatch" thing), making sure it is inside a folder called "images", and that the name of the .iwi overrides the one in the stock files; in other words, keep the same image name. And at last, of course place it in the fs_game folder of your mod.

Edit2 on page 2 for using models, as fx look buggy

Edit1. that's if you wanna replace the existing ones. If you wanna make more in custom locations, you will need to make an fx or a model (as IzNoGoD posted once in KT's Discord) and spawn it via script.

For a quick howto, you just need to make a new material with Asset Manager with the image you'd like, that will be used in CoD2 FX Editor to make the actual fx.

1655

Then in cod2 fx editor make the fx such that it's constant in shape/color (tweak the size as needed), and that uses the gfx previously made:

TYPO: it needs to be an Oriented Particle (so that it sticks to its position and doesnt face to the players camera)
1651
1652
1653
1654

And in script you will need to take the position of the sign, playing with bullettrace function and grabbing the trace["position"] and the trace["normal"] vector to orient it perpendicular to the surface. Here's a nice tutorial to understand the bullettrace func.

https://killtube.org/showthread.php?893-Bullettrace-and-you

For the script to get those, I'll make one in a bit if it's for help.

agribilos
11th March 2021, 12:15
Thank you very much!! I'll try to do the fx part.

pollo
11th March 2021, 13:22
This is the script, basically you hold F and it will print the position and normal vectors' angles of the surface you are aiming at. Rename mp_toujane to the map you want it to be executed. You'll need to write those coordinates, and at the end, in your final map script, you'll need to uncomment the precache() / loadSigns() functions and add there the info you gathered.

There is still a bug tho, engine related I'd say but someone correct me :confused:, that sometimes the fx is displayed wrong in the up vector ( see https://killtube.org/showthread.php?4428-roq-videos-as-textures to see what I mean), so the thing would be to make another effect (not material) of the same sign, but rotated 90 degrees and displayed in those positions that are bugged.

(credits to izno for the !pickup script part)
1657

agribilos
11th March 2021, 14:30
You are a real life saver!! Thank you so much for the effort!!!

agribilos
11th March 2021, 15:02
Works fine but the image displayed is rotated with the player. Any idea how to make it displayed statically? When i made the effect i chose type particle. Should it be other type maybe?
16581659

Edit: Nevermind i missed the part in your original post that stated that it has to be "oriented particle". So i have to try again.

agribilos
11th March 2021, 16:51
Hmmm I'm not sure what i did wrong but i remade the fx as "oriented particle" . Now the picture is static but is not flush on the surface of the wall. It looks like the second picture from my previous post. Any ideas?

pollo
11th March 2021, 18:49
Yeah sry... I edited the typo but I didnt post in another msg ^^ as I said cod2 acts a bit weirdly on placing the fx in the up vector, I couldnt find a script-way to fix it. So as a workaround, you'd need to make another fx (not material/image, just another .efx file) and rotate it 90 (or - 90) degrees in the Rotation tab. Play around until you see its working :) and display that fx only in the weird locations.

agribilos
11th March 2021, 19:57
Yeah sry... I edited the typo but I didnt post in another msg ^^ as I said cod2 acts a bit weirdly on placing the fx in the up vector, I couldn't find a script-way to fix it. So as a workaround, you'd need to make another fx (not material/image, just another .efx file) and rotate it 90 (or - 90) degrees in the Rotation tab. Play around until you see its working :) and display that fx only in the weird locations.

You already did 99% of my work so no need to apologize. I'm the one who needs to apologize for asking too many questions :) . I saw your videos in https://killtube.org/showthread.php?4428-roq-videos-as-textures. But my problem is not exactly that. Your fx was rotated 90 degrees clockwise or counterclockwise while being flush to the wall. My fx is like rotated 45 degrees in the z (?) axis. Half is in the air and half passes through the wall. Do you think that if i rotate my fx 90 degrees will fix the issue? Anyway i'm a little tired right now and i can't think straight. I'll try to figure it out tomorrow.

agribilos
11th March 2021, 22:02
Here is a visual representation of what is happening.
1660166116621663
It seems like all the images have the same orientation regardless of the angles given... In the last picture is is displayed ok because the wall happens to be in the same orientation.

pollo
11th March 2021, 23:55
I see. Well I succeeded to avoid that and play it perpendicular to the surface, but yeah for some reason it appears weirdly rotated. I also rotated the origin (commented function) to see if the fx follows the forward vector of the origin, but apparently it does not, which is the root of the problem :confused:

Give it a try and do this lil workaround, normally it should be OK for axis-aligned surfaces. If it's no use then you'll have to go with the model approach.

PS: In FX editor make your fx spawn 1 unit ahead in forward vector, so that it doesnt coincide with the surface and do that "flashing" thing. I left you an .efx I used inside the .iwd which has that already.

1664

agribilos
12th March 2021, 07:41
I see. Well I succeeded to avoid that and play it perpendicular to the surface, but yeah for some reason it appears weirdly rotated. I also rotated the origin (commented function) to see if the fx follows the forward vector of the origin, but apparently it does not, which is the root of the problem :confused:

Give it a try and do this lil workaround, normally it should be OK for axis-aligned surfaces. If it's no use then you'll have to go with the model approach.

PS: In FX editor make your fx spawn 1 unit ahead in forward vector, so that it doesnt coincide with the surface and do that "flashing" thing. I left you an .efx I used inside the .iwd which has that already.

1664

Thanks again!!!
You mean the rotateYaw() function i guess. I'll try to play with that and see. The fx in the last picture appears to be flashing but in fact is not. I had just included an alpha channel to see how it would work. I had already spawned the fx in a way so it did not coincide with the wall. If it doesn't work I'll have to go with the model approach (i try to avoid it because i haven't used blender or any other 3d software before) or just go with this method on axis aligned surfaces.

agribilos
12th March 2021, 12:38
I decided to go the model approach since once it's created it is easier to manipulate.The hard part is to create the model... Too bad i couldn't make it your way. But maybe i use it to do fun stuff like playing a gif in the middle of the map or something. Thanks again for the effort and the info you shared. At least i learned something :)

pollo
12th March 2021, 14:52
Yeah it'll be better that way, tho it's a bit of a pain in the ass to do hehe. Anyways you still can use the script to get the location of the model, since what is bugging is the playfx function. Hopefully it won't bug (in the past I placed models through script and they work fine in whatever angle).

agribilos
12th March 2021, 18:48
Yeah it'll be better that way, tho it's a bit of a pain in the ass to do hehe. Anyways you still can use the script to get the location of the model, since what is bugging is the playfx function. Hopefully it won't bug (in the past I placed models through script and they work fine in whatever angle).
Sure the script will be very useful but first i have to learn the basics of blender. If i am right the latest version that works with the "Blender to COD" is 2.63?

pollo
12th March 2021, 20:05
Sure the script will be very useful but first i have to learn the basics of blender. If i am right the latest version that works with the "Blender to COD" is 2.63?

Last one that I know it's still supported is 2.78

agribilos
13th March 2021, 07:11
I confirm it works with 2.78

pollo
13th March 2021, 10:16
So I've been playing around with the models, so far it's working, though with a few decals (detail textures that overlap with normal textures, so to speak, like dirt on walls) you can see some of these through the signs. You'll also need to place them in sites that are flat, otherwise other brush that has different height will "eat" the sign (in the photo below you'll see it):

1666

I reworked a bit the scripts so that it lets you place the sign and remove it with melee button. Find inside the .zip the Maya scene (.ma + image texture), the model_export for if you want to import into Blender as well, and the .gdt to export both the texture + model to cod2 with Asset Manager. If you want to add more signs, you don't need to make another model, just need to:

1. make a new material image with a different sign
2. copy/paste the sign model from the xmodel folder eg. sign2
3. open it with a text editor, change the material name to the new one (you'll find it easily among the rest of binary data: mtl_custom_sign1)

and

4. in script, make sure to precache it and change the name of the default model in _getpositions to test the new one, to test how it looks

If you wish to only use one sign, you can just replace the texture .iwi with the IWI_X_DDS tool before.

If you wish to change the size of the model, you can edit the model itself, or also re-do the texture adding alpha-channels (that manage the transparency) + setting to "Blend" in Asset Manager's blendFunc selectbox. For example, the alpha channel would be like this if you want to display on walls only the red text "Custom Sign" (the more white the more opaque; the more black the more transparent):

1668

1670

Cheers

agribilos
13th March 2021, 10:34
Wow you did your miracle again!!! Thank you so much!!!

agribilos
13th March 2021, 11:54
Works fine but i had to rebuild the xmodelparts and xmodelsurfs in order to get it to work. so here is the iwd file with all the required files if someone else wants to try it too.

pollo
13th March 2021, 12:02
Argh yes! Hahaha forgot to add them to the .iwd