Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Shield effect  (Read 2916 times)
0 Members and 1 Guest are viewing this topic.
Offline MickeyB

Senior Devvie




my game will work, my game will work!


« Posted 2004-10-25 15:23:03 »

I am considering a simple shield effect for my game.  I simply want to do a translucent sphere around the avatar (later on my have swriling colors, etc...).  OpenGL has a Sphere(float, int, int), is this object bad on performance or is this the way to go?

Thanks a ton!

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Offline SpuTTer

Senior Devvie


Medals: 1
Exp: 14 years


Lazy Middle Class Intellectual


« Reply #1 - Posted 2004-10-25 15:29:20 »

Kev has a nice shield in Grav2, and I thought that Alien Flux had one as well... should be able to hunt around in the source to find it...

Sacramento Volleyball
"Whitty phrase goes here."
Offline Funkapotamus

Junior Devvie




wo shuo han yu


« Reply #2 - Posted 2004-10-25 16:38:48 »

The way I would do it is to render a transparant quad over the avatar.  Any graphic effect you want to do can be done using particle effects or manipulaiton of the transparant quad's sprite.

Perhaps an animated sequence of images?  The method at that point is up to you, but I'd definatly go with the blended quad.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline MickeyB

Senior Devvie




my game will work, my game will work!


« Reply #3 - Posted 2004-10-25 17:01:43 »

forgot to mention I am in a full 3D mode, not overhead.  Still use a quad?  

Those games have great effects, but I was looking for more of the star trek, encompassing "globe" effect. without the wavyness or impact point, just "poof" theres a translucent bubble around the avatar.

Of course this leads into my other question here on transparent/translucent issues  LOL Grin

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Offline Middy

Junior Devvie




Java games rock!


« Reply #4 - Posted 2004-10-25 17:37:57 »

Well for a 2D game I would use the quad... For a 3D game I would go with the sphere - bluish with a nice alpha blending..


Idea 1:
Make each shot that hits feed the alpha value so multiple shots make shield look less transparent

Idea 2: Link shield aplha to shield strength. Less strength small aplha...

When do I get my makeMyGameAsILike() extension?
Offline kevglass

« JGO Spiffy Duke »


Medals: 319
Projects: 25
Exp: 22 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #5 - Posted 2004-10-25 18:16:15 »

Idea 3:

Make each point on the sphere have an alpha value which contantly tends up towards to some upper limit (shield recharging). When something hits you effect the points alpha based on their distance from the point of impact. That way you'll get blips eminating out from impact points.

Kev

Offline MickeyB

Senior Devvie




my game will work, my game will work!


« Reply #6 - Posted 2004-10-25 18:48:27 »

absolutely sweet!!! all 3 ideas.  

I used the Sphere class and with a faint blue hint (before I read you guys comments) and it looks pretty good, BUT it does have an obvious performance hit while displayed so may have to make my own sphere (with triangle_strip or something?).


self note: If I get CubeWars up and running, it will be time to convert GalaxyTraders 6 to lwjgl and add ideas 2 and 3 to ship shields.

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Offline Orangy Tang

JGO Kernel


Medals: 57
Projects: 11


Monkey for a head


« Reply #7 - Posted 2004-10-25 19:31:53 »

I assume you're using the GLU sphere, in which case its very easy to generate a sphere with a *huge* poly count - what seems like a small amount of slices/stacks can be much worse than you initially think.

Another snag is that its generated at the time you call .draw(), a simple optimisation might be to shove it into a display list so you only generate the geometry once.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Funkapotamus

Junior Devvie




wo shuo han yu


« Reply #8 - Posted 2004-10-25 22:28:08 »

Depending on how you want your shield to look, you could still render a normal opaque quad over your ship in 3d.  Just switch to ortho mode and translate the ship's coordinates relative to the camera before you draw.  This should speed things up considerably over the sphere.  

This of course all depends on how you want things to look.  The effect you get with the method I just described makes it look like the shield from smash brothers.
Offline Middy

Junior Devvie




Java games rock!


« Reply #9 - Posted 2004-10-26 04:24:48 »

Here is some code that will make a sphere for you.  It will not be faster than the GLU method.  But you have all the points here and can put them into some vertex array or something  and do the kevglass idea.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
                  double r      = _radius;
                  int n      = _n;
                  Coord  c      = _center;
     
           
                  final double PI       = Math.PI;
                  final double TWOPI = Math.PI *2.0f;
                  final double PID2       = Math.PI * 0.5f;
           
                  int i,j;
                  double theta1,theta2,theta3;
                  //Coord e,p;
                  Coord e= new Coord();
                  Coord p= new Coord();
           
                  if (r < 0)
                        r = -r;
                  if (n < 0)
                     n = -n;
                  if (n < 4 || r <= 0) {
                     GL11.glBegin(GL11.GL_POINTS);
                     GL11.glVertex3f(c.getX(),c.getY(),c.getZ());
                     GL11.glEnd();
                     return;
                  }
                  for (j=0;j<n/2;j++) {
                     theta1 = j * TWOPI / n - PID2;
                     theta2 = (j + 1) * TWOPI / n - PID2;

                     GL11.glBegin(GL11.GL_QUAD_STRIP);
                     for (i=0;i<=n;i++) {
                          theta3 = i * TWOPI / n;
             
                          e.setX((float)(Math.cos(theta2) * Math.cos(theta3)));
                          e.setY((float)(Math.sin(theta2)));
                          e.setZ((float)(Math.cos(theta2) * Math.sin(theta3)));
                          p.setX((float)(c.getX() + r * e.getX()));
                          p.setY((float)(c.getY() + r * e.getY()));
                          p.setZ((float)(c.getZ() + r * e.getZ()));

                          GL11.glNormal3f(e.getX(),e.getY(),e.getZ());
                          GL11.glTexCoord2f(i/(float)n,2*(j+1)/(float)n);
                          GL11.glVertex3f(p.getX(),p.getY(),p.getZ());

                          e.setX((float)(Math.cos(theta1) * Math.cos(theta3)));
                          e.setY((float)(Math.sin(theta1)));
                          e.setZ((float)(Math.cos(theta1) * Math.sin(theta3)));
                          p.setX((float)(c.getX() + r * e.getX()));
                          p.setY((float)(c.getY() + r * e.getY()));
                          p.setZ((float)(c.getZ() + r * e.getZ()));

                          GL11.glNormal3f(e.getX(),e.getY(),e.getZ());
                          GL11.glTexCoord2f(i/(float)n,2*j/(float)n);
                          GL11.glVertex3f(p.getX(),p.getY(),p.getZ());
                     }
                     GL11.glEnd();

                  }

When do I get my makeMyGameAsILike() extension?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline MickeyB

Senior Devvie




my game will work, my game will work!


« Reply #10 - Posted 2004-10-26 12:39:08 »

Quote
I assume you're using the GLU sphere, in which case its very easy to generate a sphere with a *huge* poly count - what seems like a small amount of slices/stacks can be much worse than you initially think.

Another snag is that its generated at the time you call .draw(), a simple optimisation might be to shove it into a display list so you only generate the geometry once.


I will try the list and see what happens as well as lower the slices, etc...


Thanks Middy, I do like the kevglass idea and may give this awhirl also.

EDIT: Fantastic.  I have the MiddySphere() up and running.  I was using Sphere() not gluSphere or glutSphere, just Sphere and honestly I dont know enough OpenGL to know where it is coming from.  Anyway, If I change Sphere(1.0f, 20, 16) to Sphere(1.0f, 10, 8 ) it runs beautifully and since it is only visible during impact of shield hindered projectiles, it should be ok.

I switched Sphere to the MiddySphere and still runs very well.  I may leave the fluctuation/modulation of the shield for the GT6 conversion and stick with the simple for CubeWars.  (and the fact that I am not fure how to implement it yet Smiley )

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Offline MickeyB

Senior Devvie




my game will work, my game will work!


« Reply #11 - Posted 2004-10-26 22:05:31 »

Doh, got my code home and it runs on my gaming box, but my text is gone...LOL always something!

When its ready to test I will throw it into "your games here"

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Offline Middy

Junior Devvie




Java games rock!


« Reply #12 - Posted 2004-10-27 04:44:14 »

How about some screenshots :-)



When do I get my makeMyGameAsILike() extension?
Offline MickeyB

Senior Devvie




my game will work, my game will work!


« Reply #13 - Posted 2004-10-27 11:48:01 »

Sure, but I must apologize for the location.  Brinkster is not image link friendly

http://www22.brinkster.com/mbowles/

Thumbs on that page.

Out of curiosity since it had 0 replies on the clubies thread.
http://68.57.86.113:11211/cw/CubeWars.jnlp
It will more than likely fail.

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Pages: [1]
  ignore  |  Print  
 
 

 
Ecumene (108 views)
2017-09-30 02:57:34

theagentd (135 views)
2017-09-26 18:23:31

cybrmynd (245 views)
2017-08-02 12:28:51

cybrmynd (240 views)
2017-08-02 12:19:43

cybrmynd (238 views)
2017-08-02 12:18:09

Sralse (252 views)
2017-07-25 17:13:48

Archive (864 views)
2017-04-27 17:45:51

buddyBro (1007 views)
2017-04-05 03:38:00

CopyableCougar4 (1567 views)
2017-03-24 15:39:42

theagentd (1373 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!