Forum

Traceline color to particle color?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Traceline color to particle color?

Postby Mexicouger » Thu Apr 11, 2013 5:26 pm

Is it possible to get a color using a traceline, and spawn a particle with effectinfo.txt using that traced color? I know there is a bulitiin in Darkplaces to get a pixel color from a traceline, but I'm not sure if that data can be passed over to a particle in effectinfo.txt
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Re: Traceline color to particle color?

Postby Nahuel » Thu Apr 11, 2013 7:17 pm

mmm i do not understand

for a visible traceline i spawn a new entity "owned" to the player else:

Code: Select all
 trailparticles(self, particleeffectnum("visibletraceline_red"), self.owner.origin, self.origin);


you can change the string "visibletraceline_red" for antoher
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: Traceline color to particle color?

Postby Mexicouger » Thu Apr 11, 2013 7:59 pm

say there's a dirt texture and you want to get the color of that dirt and turn that color into a particle effect in real time. is that possible?
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Re: Traceline color to particle color?

Postby frag.machine » Thu Apr 11, 2013 10:37 pm

Reading the corresponding entry in the Darkplaces Wiki I'd say it's very unlikely you can redefine effectinfo.txt on-the-fly. But I may be wrong...
EDIT: OTOH, You could define 16 similar particle effects, changing only the color range to match every color row in Quake default palette, and select which one is used based on what the pixel check returns. At least you wouldn't have brown particles when hitting a blue/red/yellow/green texture.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Re: Traceline color to particle color?

Postby Seven » Fri Apr 12, 2013 11:40 am

Hello Mexicouger,

I also think that it is not possible to detect a color in the world and "create" a matching effect via effectinfo.

You COULD do it this way (because you use DP and can therefore also use other dpextensions):
Nahuel did this once in one of his amazing mods.
And also footsteps sound can be done this way to get different sounds according the texture you are walking on.
This is something Moon[drunk] was working on, but as far as I know didnt finish it (yet).

Detect the texture you are shooting at, via
DP_QC_GETSURFACE

Then (depending on how many textures you use in your maps) make checks accordingly and spawn an already existing effect with the color of texture.
Be aware that you can create hundreds effects in your effectinfo, there seems to be no limit.


Example:
When your texture-check results in "city1_4" then you would spawn effectnum "middle_brown"
("middle_brown" is declared in your effectinfo.txt)

For many Quake textures you can use similar effectnums, because they share almost the same color.
This means a quite big one-time-effort in creating the texture-checks (depending on how many you use in your maps),
but in the end it might work as you want.

Good luck,
Seven

PS: If this is not what you asked for, then I am sorry. I also have issues with english sometimes... :)
Seven
 
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: Traceline color to particle color?

Postby ceriux » Fri Apr 12, 2013 3:43 pm

use frikfile to over write the .txt file?
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: Traceline color to particle color?

Postby Mexicouger » Fri Apr 12, 2013 4:47 pm

Seven wrote:Hello Mexicouger,

I also think that it is not possible to detect a color in the world and "create" a matching effect via effectinfo.

You COULD do it this way (because you use DP and can therefore also use other dpextensions):
Nahuel did this once in one of his amazing mods.
And also footsteps sound can be done this way to get different sounds according the texture you are walking on.
This is something Moon[drunk] was working on, but as far as I know didnt finish it (yet).

Detect the texture you are shooting at, via
DP_QC_GETSURFACE

Then (depending on how many textures you use in your maps) make checks accordingly and spawn an already existing effect with the color of texture.
Be aware that you can create hundreds effects in your effectinfo, there seems to be no limit.


Example:
When your texture-check results in "city1_4" then you would spawn effectnum "middle_brown"
("middle_brown" is declared in your effectinfo.txt)

For many Quake textures you can use similar effectnums, because they share almost the same color.
This means a quite big one-time-effort in creating the texture-checks (depending on how many you use in your maps),
but in the end it might work as you want.

Good luck,
Seven

PS: If this is not what you asked for, then I am sorry. I also have issues with english sometimes... :)


Unfortunately, this is what I already did before I asked here. I was really crossing my fingers for a shortcut for it.
Right now, I use trace_dphittexturename to get the name of the texture, and run my already-created particle effect. It would be much easier to be able to change the color on the fly, but It can be done either way. Thanks anyway guys
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Re: Traceline color to particle color?

Postby leileilol » Fri Apr 12, 2013 9:44 pm

If I did this in Engoo i'd probably try to sample the average color for every texture loaded (at load time), and keep that averaged color as part of the mips themselves.
SiN did something similar in which it remapped little gunshot debris chunk models with the texture iself.
Last edited by leileilol on Fri Apr 12, 2013 9:45 pm, edited 2 times in total.
i should not be here
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: Traceline color to particle color?

Postby frag.machine » Fri Apr 12, 2013 9:44 pm

ceriux wrote:use frikfile to over write the .txt file?


I suspect DP won't reload effecinfo.txt.

It would be interesting to have the ability to redefine an effect via QC though (or for extension any shader).
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Re: Traceline color to particle color?

Postby ceriux » Fri Apr 12, 2013 11:54 pm

cant frikfile also load files? but im sure ur right...
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: Traceline color to particle color?

Postby frag.machine » Sat Apr 13, 2013 4:40 am

ceriux wrote:cant frikfile also load files? but im sure ur right...


"Load" means "parse" here, and it's very unlikely that DP does it more than once at startup. BUT, as I said, I may be wrong...

I'd suggest to go with the 16 or so colors particles and check which one is closer to the pixel color in the texture.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest