Author Topic: RC/repeater ''power rings''  (Read 69124 times)

sirshiz

  • Posts: 75
  • Turrets: +3/-5
RC/repeater ''power rings''
« on: March 23, 2011, 03:52:26 pm »
Would it be feasible to implement anything like the ''power rings'' from StarCraft and use it for Tremulous? A visual indicator of where the power for the RC and/or repeater ends would be helpful. Right now you have to estimate (not that hard, I know) but it can get annoying when the repeaters are close to the RC power as you might not necessarily know if you are about to build from the RC or repeater BP.

Meisseli

  • Spam Killer
  • *
  • Posts: 765
  • Turrets: +83/-25
Re: RC/repeater ''power rings''
« Reply #1 on: March 23, 2011, 04:08:11 pm »
It has been suggested numerous times IIRC, each time the answer being something close to: "it's not possible with the quake renderer".

sirshiz

  • Posts: 75
  • Turrets: +3/-5
Re: RC/repeater ''power rings''
« Reply #2 on: March 23, 2011, 04:15:31 pm »
Why couldn't the game just make a ghost structure (just a green line or something) along the circumference of the power area only seen to the builder? The game can make greenish repeaters and other buildings appear and they turn red when outside of the power grid so I don't think it's much of a stretch.
I'm no expert or anything for Tremulous programming but I find it hard to believe that there aren't more creative solutions to this.


David

  • Spam Killer
  • *
  • Posts: 3543
  • Turrets: +249/-273
Re: RC/repeater ''power rings''
« Reply #3 on: March 23, 2011, 04:21:11 pm »
The problem isn't that it can't be done.

The problem is that it can't be easily done in a way that won't kill your FPS.
Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.

sirshiz

  • Posts: 75
  • Turrets: +3/-5
Re: RC/repeater ''power rings''
« Reply #4 on: March 23, 2011, 04:27:24 pm »
The problem isn't that it can't be done.

The problem is that it can't be easily done in a way that won't kill your FPS.

Oh.  :'(

gimhael

  • Posts: 546
  • Turrets: +70/-16
Re: RC/repeater ''power rings''
« Reply #5 on: March 23, 2011, 05:36:07 pm »
You can easily draw a semi-transparent sphere that shows the radius of the repeater/rc/whatever, all you need is a sphere model in md3 format (that should be doable in blender) and the engine can compute the position and scale to show the build area.

What you can NOT do with the quake renderer is to color all the surfaces which are within this radius, e.g. you can't draw a circle on the ground like in your starcraft screenshot, but a globe that shows the perimeter of the build radius is technically possible.

sirshiz

  • Posts: 75
  • Turrets: +3/-5
Re: RC/repeater ''power rings''
« Reply #6 on: March 23, 2011, 05:37:20 pm »
You can easily draw a semi-transparent sphere that shows the radius of the repeater/rc/whatever, all you need is a sphere model in md3 format (that should be doable in blender) and the engine can compute the position and scale to show the build area.

What you can NOT do with the quake renderer is to color all the surfaces which are within this radius, e.g. you can't draw a circle on the ground like in your starcraft screenshot, but a globe that shows the perimeter of the build radius is technically possible.


I would think that would suffice.

Nux

  • Posts: 1778
  • Turrets: +258/-69
Re: RC/repeater ''power rings''
« Reply #7 on: March 23, 2011, 05:41:40 pm »
Really? How exactly would rendering a few more polygons kill your fps?

It doesn't take much effort to just edit the existing models to include a ring or sphere or cone of influence around it. The problem comes when I don't want to see it anymore. It would be nice if the 'area of influence' model could be spawned and unspawned coinciding with that blueprint stage where nobody sees it but you. Maybe you could just add a new frame to the buildings animation that is only played at that time.

EDIT: ok, people have responded since I started writing... DAMNIT

David

  • Spam Killer
  • *
  • Posts: 3543
  • Turrets: +249/-273
Re: RC/repeater ''power rings''
« Reply #8 on: March 23, 2011, 06:59:41 pm »
Except that sphere would be opaque, so would block your vision while being unclear as to where the edge is.  It also would only tell you the edge of the area, if you can't see the edge you don't know if your current area has power.
And for turrets etc it would just show distance, ignoring walls and other stuff that blocks it.

For it to work in a usable sort of way we would need to render where the sphere intersects the map, which isn't something q3 can do.
Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.

cron

  • Donators
  • *
  • Posts: 197
  • Turrets: +22/-22
    • GrangerHub
Re: RC/repeater ''power rings''
« Reply #9 on: March 23, 2011, 07:58:43 pm »
I know it's not what you're looking for, but an easier implementation might be to make the ckit's display color change and/or glow with varying intesity when building using bp provided by a repeater.
« Last Edit: March 23, 2011, 08:00:19 pm by cron »

Nux

  • Posts: 1778
  • Turrets: +258/-69
Re: RC/repeater ''power rings''
« Reply #10 on: March 23, 2011, 08:00:33 pm »
The sphere doesn't have to be opaque. Even with opaque textures (blueprints are already semi-transparent) you can make a cage-like object for better viewing. If you can't see the edge then clearly it must be inside the area.

To be clear, I'm talking about displaying the range of the building you have in blueprint form. For already built buildings it'll be harder to do right.

Lakitu7

  • Tremulous Developers
  • *
  • Posts: 1002
  • Turrets: +120/-73
Re: RC/repeater ''power rings''
« Reply #11 on: March 23, 2011, 10:45:40 pm »
Certainly it's on the list of "stuff that I think everyone would like to see but it's hard," much like minimaps.

I think it'd be pretty cool if someone could create a reasonable prototype of this, but to really be useful it should also include things like tubes, hives, turrets, trappers, which adds a bit more complication since at least for trappers you need a cone.

gimhael

  • Posts: 546
  • Turrets: +70/-16
Re: RC/repeater ''power rings''
« Reply #12 on: March 23, 2011, 10:58:08 pm »
Quick proof of concept:




« Last Edit: March 23, 2011, 11:01:02 pm by gimhael »

sirshiz

  • Posts: 75
  • Turrets: +3/-5
Re: RC/repeater ''power rings''
« Reply #13 on: March 23, 2011, 11:06:50 pm »
Quick proof of concept:






THAT IS AWESOME.

ziplocpeople

  • Posts: 346
  • Turrets: +23/-20
Re: RC/repeater ''power rings''
« Reply #14 on: March 23, 2011, 11:58:08 pm »
Quick proof of concept:






THAT IS AWESOME.
Gross, I can't believe people play at that resolution.
Quote from: Sir|Periculosus
yes yes spam a little more and heyll understand! yes yes
मैं स्पैम बॉट समर्थन
मैं हिन्दी का समर्थन
~The Medistation

jm82792

  • Posts: 630
  • Turrets: +9/-34
Re: RC/repeater ''power rings''
« Reply #15 on: March 24, 2011, 03:03:44 am »
That works and would be nice.
Have a red one for the RC range perhaps?

Lakitu7

  • Tremulous Developers
  • *
  • Posts: 1002
  • Turrets: +120/-73
Re: RC/repeater ''power rings''
« Reply #16 on: March 24, 2011, 08:49:19 am »
Looks like a great start. Looking forward to seeing how it's implemented. If it's clean and the code looks good, we're on a roll here.

Menace13

  • Posts: 516
  • Turrets: +12/-41
    • hhhhhh
Re: RC/repeater ''power rings''
« Reply #17 on: March 24, 2011, 07:43:05 pm »
That works and would be nice.
Have a red one for the RC range perhaps?


Green. Definitely green. Red makes me think of aliens.

but a small twisty barrel will have small pew pew's, and small pew pew's can hurt mr.tyrant.

IPWNU

  • Posts: 8
  • Turrets: +0/-0
Re: RC/repeater ''power rings''
« Reply #18 on: March 24, 2011, 08:31:13 pm »
that would actually be awesome. the game is already polygons, its not too much to add a slightly opaque one. but gj gimhael. i think that would come in mighty handy

Nux

  • Posts: 1778
  • Turrets: +258/-69
Re: RC/repeater ''power rings''
« Reply #19 on: March 24, 2011, 09:06:18 pm »
Just so we're all on the same page, gimhael hasn't said that he's got anything working in code. I'm guessing he's just showing what it would look like with a model in game. I don't know this though, so if you could say what you did gimhael, that would be great.

Seems to me it would take a very small amount of code and the addition of single frame to the building's animation to get this working in the blueprints. Seems like other stuff will be harder to code but I don't know by how much.

Meisseli

  • Spam Killer
  • *
  • Posts: 765
  • Turrets: +83/-25
Re: RC/repeater ''power rings''
« Reply #20 on: March 24, 2011, 09:23:23 pm »
Just so we're all on the same page, gimhael hasn't said that he's got anything working in code. I'm guessing he's just showing what it would look like with a model in game. I don't know this though, so if you could say what you did gimhael, that would be great.
Now I'm no native English speaker, but I think the term "proof of concept" means precisely he's got a crude but working prototype coded.

SlackerLinux

  • Spam Killer
  • *
  • Posts: 555
  • Turrets: +41/-62
Re: RC/repeater ''power rings''
« Reply #21 on: March 25, 2011, 01:28:28 am »
concept looks good but i think it would be better if it is overlayed on the floor instead of a huge bubble(or a combo of both) also you could prob expand it to give the attack range of the turrets and tesla in red
Slackware64 13.1
SlackersQVM/

jm82792

  • Posts: 630
  • Turrets: +9/-34
Re: RC/repeater ''power rings''
« Reply #22 on: March 25, 2011, 06:25:54 am »
Just so we're all on the same page, gimhael hasn't said that he's got anything working in code. I'm guessing he's just showing what it would look like with a model in game. I don't know this though, so if you could say what you did gimhael, that would be great.
Now I'm no native English speaker, but I think the term "proof of concept" means precisely he's got a crude but working prototype coded.
That is correct, prototype is a crude yet functional example that is to be improved or not used.

gimhael

  • Posts: 546
  • Turrets: +70/-16
Re: RC/repeater ''power rings''
« Reply #23 on: March 25, 2011, 10:02:06 am »
concept looks good but i think it would be better if it is overlayed on the floor instead of a huge bubble(or a combo of both) also you could prob expand it to give the attack range of the turrets and tesla in red

Painting on the walls/floor means you either have to compute the intersection of all geometry with the sphere (very expensive) or you have to use the stencil buffer to mask out anything outside of the sphere and then render all geometry again (moderately expensive, but the stencil buffer can't be manipulated by user shaders in the current engine anyway).

The code for this power sphere is pretty simple however, I just created a radius 1.0 icosphere model in blender, registered it as usual
Code: [Select]
  cgs.media.sphereModel        = trap_R_RegisterModel( "models/buildables/sphere/sphere.md3" );

and then I defined a generic helper function to render an arbitrary sphere:
Code: [Select]
/*                                                                             
==================                                                             
CG_AddSphere                                                                   
==================                                                             
*/
void CG_AddSphere( vec3_t origin, vec_t radius, qhandle_t shader )
{
  refEntity_t     ent;

  memset( &ent, 0, sizeof( ent ) );
  VectorCopy( origin, ent.origin );
  ent.axis[0][0] = radius;
  ent.axis[1][1] = radius;
  ent.axis[2][2] = radius;
  ent.nonNormalizedAxes = qtrue;

  ent.hModel = cgs.media.sphereModel;
  ent.customShader = shader;

  trap_R_AddRefEntityToScene( &ent );
}

Then for the proof-of concept I made a simple loop to add a sphere to all buildables of your team:
Code: [Select]
void CG_AddBuildRanges( int team )
{
  int             i;
  centity_t       *cent;
  entityState_t   *es;

  for( i = 0; i < cg.snap->numEntities; i++ ) {
    cent  = &cg_entities[ cg.snap->entities[ i ].number ];
    es    = &cent->currentState;

    if( es->eType == ET_BUILDABLE &&
        BG_FindTeamForBuildable( i ) == team ) {
      switch( es->modelindex ) {
      case BA_H_REACTOR:
        CG_AddSphere( cent->lerpOrigin, REACTOR_BASESIZE,
                      cgs.media.humanSpawningShader );
        break;
      case BA_H_REPEATER:
        CG_AddSphere( cent->lerpOrigin, REPEATER_BASESIZE,
                      cgs.media.humanSpawningShader );
        break;
      case BA_A_OVERMIND:
        CG_AddSphere( cent->lerpOrigin, CREEP_BASESIZE,
                      cgs.media.humanSpawningShader );
        break;
      case BA_A_SPAWN:
        CG_AddSphere( cent->lerpOrigin, CREEP_BASESIZE,
                      cgs.media.humanSpawningShader );
        break;
      }
    }
  }
}

As you can see I just reused the telenode shader because it is transparent, but maybe someone with more skill than me could make some nice shaders and a sphere model with proper UV coords.

David

  • Spam Killer
  • *
  • Posts: 3543
  • Turrets: +249/-273
Re: RC/repeater ''power rings''
« Reply #24 on: March 25, 2011, 11:59:35 am »
That looks way better than I was expecting, I thought we would have to do the project-it-on-the-floor thing to make it work.

If people think it's a bit annoying, could bind it to a key or something so it only shows up when you want it.
Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.

Random ViruS

  • Guest
Re: RC/repeater ''power rings''
« Reply #25 on: March 25, 2011, 12:14:20 pm »
I thought we would have to do the project-it-on-the-floor thing to make it work.

If people think it's a bit annoying, could bind it to a key or something so it only shows up when you want it.
I would get annoyed too.
bind \ cg_showbuildingarea 0

SlackerLinux

  • Spam Killer
  • *
  • Posts: 555
  • Turrets: +41/-62
Re: RC/repeater ''power rings''
« Reply #26 on: March 25, 2011, 12:45:18 pm »
concept looks good but i think it would be better if it is overlayed on the floor instead of a huge bubble(or a combo of both) also you could prob expand it to give the attack range of the turrets and tesla in red

Painting on the walls/floor means you either have to compute the intersection of all geometry with the sphere (very expensive) or you have to use the stencil buffer to mask out anything outside of the sphere and then render all geometry again (moderately expensive, but the stencil buffer can't be manipulated by user shaders in the current engine anyway).
....<snip>.....

that's a pity i guess the "bubble" thing is the only obvious way then it just doesn't look anywhere near as good as painting/overlaying it on the floor would

anyway better to have something that works and is fast then something that looks good and lags heaps
Slackware64 13.1
SlackersQVM/

Nux

  • Posts: 1778
  • Turrets: +258/-69
Re: RC/repeater ''power rings''
« Reply #27 on: March 25, 2011, 03:23:34 pm »
Since you're just spawning the model separately with new code, it's best that you make an axis-aligned cylinder which extends all the way up and down, as that's how the powered-range works. The only reason I suggested a sphere is for when it's fixed to the model's orientation, which it doesn't seem to be here.

gimhael

  • Posts: 546
  • Turrets: +70/-16
Re: RC/repeater ''power rings''
« Reply #28 on: March 25, 2011, 04:24:43 pm »
Since you're just spawning the model separately with new code, it's best that you make an axis-aligned cylinder which extends all the way up and down, as that's how the powered-range works. The only reason I suggested a sphere is for when it's fixed to the model's orientation, which it doesn't seem to be here.

No, power works by measuring the 3d distance, so a sphere is correct.

/dev/humancontroller

  • Posts: 1033
  • Turrets: +1002/-383
Re: RC/repeater ''power rings''
« Reply #29 on: March 25, 2011, 06:02:49 pm »
who is this cocksucker named gimhael? he is showing features (including models and source code) from the Amsterdam Unlimited server, as if they were his work.