Ship Shield Effect

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
cdrwolfe
Posts: 100
Joined: Thu Nov 15, 2007 5:38 pm
Location: Cranfield University

Ship Shield Effect

Post by cdrwolfe »

Hi all,

I just wanted to ask if anyone had any good ideas on how to replicate a shield hit effect, common in most space combat games.

Image

Is there some way of setting a texture to be transparent and then somehow highlight the areas where the shield is hit? or would i have to look into using some kind of shader.

Regards Wolfe
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The shield could be done with an mesh scene node that is a child of your spaceship. You might even be able to use a sphere scene node that has been scaled to give it the appropriate shape. The hit marks can be done with billboards or decals. Then just use transparent materials...

Travis
cdrwolfe
Posts: 100
Joined: Thu Nov 15, 2007 5:38 pm
Location: Cranfield University

Post by cdrwolfe »

Well luckily i currently have a sphere scene node which is scaled into an ellipsoid to act as the ships collision detection. So i could probably use that. I tried previously to add a material to the sphere meshs but for some reason it screwed up the collision detection part. I normally loop through each vertex of the mesh to get there position but it wouldn't allow me this time lol, i recall something about 3DS files having odd vertexes i.e x2 but can't quite remember.

I would like the effect to cover the sphere mesh or at least partially eminating from where the beam hits.

I guess using a billboard wouldn't work because it always faces the camera and is flat.

Could i use a texture / decal and then apply it somehow to a set of vertexes of the mesh, making it partially transparent?

Regards Wolfe
cdrwolfe
Posts: 100
Joined: Thu Nov 15, 2007 5:38 pm
Location: Cranfield University

Post by cdrwolfe »

Is it possible to create something similar to taht in this video?

http://www.youtube.com/watch?v=r7H6HBZS ... re=related

Would it be possible to apply multiple textures to the sphere to represent multiple hits, my guess would be yes but how exactly to mould it to the shape of the shield.

Hmm needs investigation :)

Regards Wolfe
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

As long as your shield is elliptical, it should not really matter. A flat textured plane that is aligned to the normal of the sphere should look okay.

If you are lazy then you just need to use a texture animator (to animate the texture) and scale animator (to make it grow), and a delete animator (to delete each decal when animation is done).

Travis
cdrwolfe
Posts: 100
Joined: Thu Nov 15, 2007 5:38 pm
Location: Cranfield University

Post by cdrwolfe »

The only hard thing i have in my mind is how to align the texture which for brevity we shall say is a roundish texture to align with the beam contact point on the shield.

Do i have to run through each vertex of the mesh and which is closest to my beam end point. If i find it do you happen to know exactly how i could apply the texture at that point.

Or perhaps if you know the terminology which describes the problem so i can search around. Half my problem is i only a little of the names of techniques so finding solutions is a bit of a problem. I only found out about projected textures the other day lol, though in this case i don't think it is applicable.

Kind Regards Wolfe
gogo
Posts: 65
Joined: Tue Apr 15, 2008 1:04 am

Post by gogo »

errror
Last edited by gogo on Fri Dec 05, 2008 11:42 pm, edited 1 time in total.
cdrwolfe
Posts: 100
Joined: Thu Nov 15, 2007 5:38 pm
Location: Cranfield University

Post by cdrwolfe »

gogo wrote:It is enough to use addEmptySceneNode for that purpose.
Teh? how is an empty scene node applicable in this instance. I won't be rotating anything.

Regards wolfe
cdrwolfe
Posts: 100
Joined: Thu Nov 15, 2007 5:38 pm
Location: Cranfield University

Post by cdrwolfe »

It seems that i can't use the getCollisionPoint to get my contact point on the shield.

Anyone happen to be good at maths :)

Image

And know how to calculate position tau given positions A, B and C.

Regards Wolfe
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I don't understand why you wouldn't be able to use getCollisionPoint(). If the shield is itself a mesh that is part of a scene node, you should have no problem. The nice thing is that will also get you the surface normal for orienting the quad.

You could use projective texturing to do this, but you'd have to figure it out and implement it.

Travis
Frank Dodd
Posts: 208
Joined: Sun Apr 02, 2006 9:20 pm

Post by Frank Dodd »

If I were to have a go at this problem I would probably create a partial dome and animate the color of the verticies. Moving an alpha line down the verticies one row at a time without worrying about blending from row to row. That would create a nice looking pulsed wave, with a cool texture on it, it would probably work well.
cdrwolfe
Posts: 100
Joined: Thu Nov 15, 2007 5:38 pm
Location: Cranfield University

Post by cdrwolfe »

The shield is itself an animated scene node made from a sphere 3DS mesh.

However i can't seem to get it to work correctly. Because the beam fires from one ship to another means if i draw a line from the ship cannon to the target hitpoint there is a chance of interescting another ships mesh.

Now i think i've got around this by just reversing the direction. by firing a line from the target hitpoint to the ships cannon and in theory it should leave the ships mesh and hit the shield.

However because getCollisionPoint doesn't have a bitmask check it is possible for the collision to detect the targt ship before it has reached its shield simply because some of the hitpoints lie within the ship.

Seems to be a bit temperamental, but i will check my code.

Regards Wolfe
cdrwolfe
Posts: 100
Joined: Thu Nov 15, 2007 5:38 pm
Location: Cranfield University

Post by cdrwolfe »

Well it seems i might have got it to work correctly.

Thanks Vitek, you were right the getCollision emthod should and did work. The problem originally was that i passed the ships scenenoce rather then the shields scene node. I though it would only need the shields mesh lol.

Here is a pic, as you can see i ended up drawing 3d lines of everything to debug the problem lol.

Image

If you want to know the hardcore math way of getting a point which intersects an ellipsoid, someone kindly posted a solution, though it might take some work to decipher ;)

Go to http://www.mathhelpforum.com/math-help/ ... psoid.html

to see solution.

Now all i need do is get the normal for the triangle.

Regards Wolfe
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

cdrwolfe wrote:Now all i need do is get the normal for the triangle.
triangle3d::getNormal() ? ;)

This is looking interesting. Do you have a project announcement up?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
cdrwolfe
Posts: 100
Joined: Thu Nov 15, 2007 5:38 pm
Location: Cranfield University

Post by cdrwolfe »

Once i get the AI working i'll probably post a project update. It is written in C# though using Irrlicht.Net and because it was the first thing i ever coded in C# some of the early work is pretty crap.

I think the 600+mb memory footprint after a while shows i might have made a few mistakes in my coding ;).

Anyway it is a combat engine (I hope) for the current Birth of the Federation II projects at Star-Trek-Games. They have much better coders and artists then I though :).

Regards Wolfe
Post Reply