Point Crosshair at Wall, get texture name?
Moderator: InsideQC Admins
16 posts
• Page 1 of 2 • 1, 2
Point Crosshair at Wall, get texture name?
Metlslime added what I consider a great feature in FitzQuake 0.85, the ability to download all the textures and dump them.
Although my understanding of the .bsp is a bit improved from the past, I'm not sure how to do what I want to do here:
I want to write a command that will identify the texture of the worldmodel surface the crosshair is point at.
Although my understanding of the .bsp is a bit improved from the past, I'm not sure how to do what I want to do here:
I want to write a command that will identify the texture of the worldmodel surface the crosshair is point at.
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
Look at alias lighting code. It does a downwards trace, finds the surface, figures out the lightmap position, and uses that.
Well you don't care about the lightmap, only the texture. Its a bit simpler that way.
Well you don't care about the lightmap, only the texture. Its a bit simpler that way.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
For any arbitrary direction have a look at what happens when you shoot a surface. It should be (relatively) straightforward from there.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
I found Spike's way was the easiest, modifying RecursiveLightPoint() to store the texture name of the face in a global variable.
Though this method does not handle sky or liquid textures, and would need extra code to handle brush models.
Though this method does not handle sky or liquid textures, and would need extra code to handle brush models.
- andrewj
- Posts: 133
- Joined: Mon Aug 30, 2010 3:29 pm
- Location: Australia
I look forward to playing around with this. Doesn't sound too hard.
I bet looking at FTE's stain maps code will tell me quite a bit in itself.
Thanks all.
I bet looking at FTE's stain maps code will tell me quite a bit in itself.
Thanks all.
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
IIRC Darkplaces already has an extension to check texture names under an entity.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
RecursiveLightPoint is more useful here than stainmaps... Stainmaps are radial and can take shortcuts - they don't do any traces, only a spherical area. Useful if you want to find 50 surfaces near a given point, but less useful for querying stuff.
RecursiveLightPoint is basically a traceline - which is exactly what you want (the parent function currently just sets the start/end x/y coords the same, with end_z = start_z-2048 or so).
So much easier.
RecursiveLightPoint is basically a traceline - which is exactly what you want (the parent function currently just sets the start/end x/y coords the same, with end_z = start_z-2048 or so).
So much easier.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
The thing though is that the lightpoint functions only trace downwards whereas I get the impression that Baker wants it in any arbitrary direction (fnarr fnarr).
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
if by trace downwards, you mean:
end[0] = point[0];
end[1] = point[1];
end[2] = point[2] - 2048;
then yes, it traces downwards.
end[0] = point[0];
end[1] = point[1];
end[2] = point[2] - 2048;
then yes, it traces downwards.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Thank you, thank you, thank you!
This thread was awesome!!!!!
About every single of scrap of info in this thread was helpful.
[And I kind of learned a lot more about how collisions work in the process.]
This thread was awesome!!!!!
About every single of scrap of info in this thread was helpful.
[And I kind of learned a lot more about how collisions work in the process.]
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
Point crosshair at texture, get texture name ... polygon is highlighted in red.
Add some clipboard cut & paste fun to the equation for more fun. I'm thinking about how to make the command work.
But the reality is I'm gonna throw in a texture browser into the engine [I mean to see the uploaded textures to the video card, not some file texture browser. That'd be a bit stupid.].
The basics and this code isn't prettied up ...
Add a new surface flag like SURF_SELECTED ... have that draw a selection texture as an additive ... and the harder part, which is getting the surface info from a morphed R_RecursiveLightPoint ....
Doesn't work against map submodels (doors, lifts, platforms, removable floors like the Start map atrium).
Add some clipboard cut & paste fun to the equation for more fun. I'm thinking about how to make the command work.
But the reality is I'm gonna throw in a texture browser into the engine [I mean to see the uploaded textures to the video card, not some file texture browser. That'd be a bit stupid.].
The basics and this code isn't prettied up ...
Add a new surface flag like SURF_SELECTED ... have that draw a selection texture as an additive ... and the harder part, which is getting the surface info from a morphed R_RecursiveLightPoint ....
- Code: Select all
// Baker: this takes the entity origin
// Now we need to get a surface collision and have an XYZ
msurface_t *new_collision_wall; // Baker: this needs reset on map change
msurface_t *previous_collision_wall;
int R_SurfacePoint (void )
{
vec3_t player;
vec3_t forward, up, right;
vec3_t destination;
int texturenum;
qbool changed=false;
VectorCopy (r_refdef.vieworg, player); // Player eye position
AngleVectors (cl.viewangles, forward, right, up); // Take into account the angles
VectorMA (player, 4096, forward, destination); // Walk us forward
new_collision_wall = NULL; // Set to null
texturenum = RecursiveWallPoint (cl.worldmodel->nodes, player, destination);
// If there is a collision wall AND either there is no previous or the previous doesn't match, we have a change.
changed = (new_collision_wall && (!previous_collision_wall || (previous_collision_wall != new_collision_wall)));
if (previous_collision_wall && changed)
{
// We have a previous wall, restore its texture
//previous_collision_wall->texinfo->texture->gl_texturenum = oldtextnum;
previous_collision_wall->flags &= ~ SURF_SELECTED; // Remove flag
previous_collision_wall = NULL;
}
if (new_collision_wall && changed)
{
previous_collision_wall = new_collision_wall;
//oldtextnum = previous_collision_wall->texinfo->texture->gl_texturenum;
//oldtexture = previous_collision_wall->texinfo->texture;
previous_collision_wall->flags |= SURF_SELECTED; // Add flag
// Would need to save this
SetWindowText(engine.platform.mainwindow, va("Texture looked at is %s", previous_collision_wall->texinfo->texture->name /* gl_texturenum*/));
}
return texturenum;
}
int RecursiveWallPoint (mnode_t *node, vec3_t start, vec3_t end)
{
float front, back, frac;
vec3_t mid;
loc0:
if (node->contents < 0)
return false; // didn't hit anything
// calculate mid point
if (node->plane->type < 3)
{
front = start[node->plane->type] - node->plane->dist;
back = end[node->plane->type] - node->plane->dist;
}
else
{
front = DotProduct(start, node->plane->normal) - node->plane->dist;
back = DotProduct(end, node->plane->normal) - node->plane->dist;
}
// optimized recursion
if ((back < 0) == (front < 0))
{
node = node->children[front < 0];
goto loc0;
}
frac = front / (front-back);
mid[0] = start[0] + (end[0] - start[0]) * frac;
mid[1] = start[1] + (end[1] - start[1]) * frac;
mid[2] = start[2] + (end[2] - start[2]) * frac;
// go down front side
if (RecursiveWallPoint(node->children[front < 0], start, mid))
{
return true; // hit something
}
else
{
int i, ds, dt;
msurface_t *surf;
// check for impact on this node
VectorCopy (mid, lightspot);
surf = cl.worldmodel->surfaces + node->firstsurface;
for (i = 0 ; i < node->numsurfaces ; i++, surf++)
{
ds = (int)((float)DotProduct (mid, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3]);
dt = (int)((float)DotProduct (mid, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3]);
if (ds < surf->texturemins[0] || dt < surf->texturemins[1])
continue;
ds -= surf->texturemins[0];
dt -= surf->texturemins[1];
if (ds > surf->extents[0] || dt > surf->extents[1])
continue;
// At this point we have a collision with this surface
new_collision_wall = surf;
return true; // success
}
// go down back side
return RecursiveWallPoint (node->children[front >= 0], mid, end);
}
}
Doesn't work against map submodels (doors, lifts, platforms, removable floors like the Start map atrium).
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
this looks pretty cool. Great way to iterate on textures and see them in context with lighting without the iteration step of recompiling the bsp.
Now, something to consider is whether the replacement image data is treated as 32bpp, or if you can preview paletted image data too (i.e. can i use it to see how my fullbright pixels look?)
Instead of coloring the active face in red (which goes directly against the goal of accurately previewing the appearance of the texture) how about drawing an outline around the polygon?
Now, something to consider is whether the replacement image data is treated as 32bpp, or if you can preview paletted image data too (i.e. can i use it to see how my fullbright pixels look?)
Instead of coloring the active face in red (which goes directly against the goal of accurately previewing the appearance of the texture) how about drawing an outline around the polygon?
- metlslime
- Posts: 316
- Joined: Tue Feb 05, 2008 11:03 pm
metlslime wrote:Instead of coloring the active face in red (which goes directly against the goal of accurately previewing the appearance of the texture) how about drawing an outline around the polygon?
^^^ what metlslime said.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
I'd be more in favour of something like dimming all textures aside from the highlighted one (by modifyng their lightmaps or something similar, say), or rendering a default "unhighlighted" texture instead of them.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
metlslime wrote:Instead of coloring the active face in red (which goes directly against the goal of accurately previewing the appearance of the texture) how about drawing an outline around the polygon?
I kind of chose the red because Worldcraft uses that color when a brush face is selected. But yeah I get the idea of different perspectives of the right way to select stuff.
In Worldcraft I guess the downside of the red selection is that you can't see the color.
metlslime wrote:Now, something to consider is whether the replacement image data is treated as 32bpp, or if you can preview paletted image data too (i.e. can i use it to see how my fullbright pixels look?)
With a good texture manager, why not? I'm in the process of rewriting mine to use most of the FitzQuake texture manager philosophy.
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
16 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest