Hmm making a looping texture file shouldn't be a problem, I do it for the projectiles. No applying it to the sphere mesh at the correct position might be more troublesome.
Regards Wolfe
_________________
04 Dec 2008, 23:26
Matress_of_evil
Evil Romulan Overlord of Evil - Now 100% Faster!
Joined: 02 Dec 2004, 01:00 Posts: 7392 Location: Returned to the previous place.
I have no idea how it works, but i've attached part of the texture file that includes the shield effect from Starfleet Command 2. I think the top glow is the weapon hit effect whilst the rings are meant to be the shields arcs around the ship.
Attachment:
Shield Effects.png [ 9.78 KiB | Viewed 17982 times ]
And this is what the shields look like ingame:
Attachment:
Shields.png [ 144.42 KiB | Viewed 17981 times ]
I hope you'll find it useful, although I haven't got a clue how the game translates the image file into that effect in the game.
_________________
"Anyone without a sense of humour is truly at the mercy of the rest of us."
06 Dec 2008, 01:34
Malvoisin
Fleet Admiral
Joined: 13 Nov 2006, 01:00 Posts: 2111 Location: Germany
FS2 does it by having a shield mesh (usually a sphere, but it can be in other shapes too) that is invisible until hit by a weapon. It plays the shieldhit.ani on the impact position, mapped on the sphere...something like that. Looks good in-game.
_________________ - Modeler and Modder
- Vision of Escaflowne and Tolkien fan
07 Dec 2008, 17:25
Malvoisin
Fleet Admiral
Joined: 13 Nov 2006, 01:00 Posts: 2111 Location: Germany
FS2 is open-source, right? So it's just about downloading the code and checking the parts where the ani file is processed and hoping that it can converted into irrlicht..(along with the graphics and textures there)
Got what seems to be the hardest part done today, which is displacing the beam endpoint to hit the shields and not the intended target hitpoint on the ship.
Here is a debug pic
If anyone likes maths and wants to solve the equation used to find an intersection on a ellipsoid from a line feel free
I did working with finite elements a good while ago but I don't think you really need femlab to solve this equation .
I followed the link you posted and the math behind it is quite basic actually (if you happen to have studied it and know what's going on ), I only don't understand what the rho does in the formula. rho should be 1 in this case. rho usually describes densities of the material inside the ellipsoid when calculating intertia moments of the ellipsoid. Maybe ask him what he means with that. "The root in [0,1]"-part in his answer actually only refers to the fact that lambda will lie between 0 and 1 since our two points B and C lie in- and outside the ellipsoid so the intersection point lies somewhere in the middle. As solution you need to take the positive root to get the first intersection point (there are two, the negative root gives you the exit-point so to say in contrast to the entry point of your ray). One calls such a quadratic equation to be of second order btw.
lambda*x + (1-lambda)*y always gives you a point on the linear vector or geometric line between those two points x and y. you can test that pretty easily. if lambda=0 then you get y. if lambda=1 then x. Lambda=0.5 gives you (x+y)/2, the middle point between the two points. and so on and so on. There's not much behind that .
just solve to lambda. during that you'll get something like lambda^2(1/a^2 +1/b^2 + 1/c^2) + 2*lambda(x2/((x1-x2)*a^2) + y2/((y1-y2)*b^2) + z2/((z1-z2)*c^2)) = (1 - x2^2 - y2^2 - z2^2)/(x1-x2)*(y1-y2)*(z1-z2) which you can further solve by dividing through the factor at the lambda^2 part and then using good old school math to get it quadratic and get the solution.
@picard: such things you do on classic paper . No seriously, what again is a1, a2 and b1, b2? we should solve for x=lambda*x1 + (1-lambda)*x2) , y=.. and then for lambda, not the general equation for x,y and z. Also, all numbers (x1,x2,y1,y2,z1,z2) are known so numerically, there's nothing we can gain here. it's just brute force calculating and a modern CPU does that in no-time .
07 Dec 2008, 19:54
captain_picard
Communications Officer
Joined: 21 Aug 2008, 16:59 Posts: 717 Location: On this multiverse: EU
This is the ellipsoid equation: x^2/a^2+y^2/b^2+z^2/c^2==1 This is the definition of a line in 3 dimensions (the intersection of 2 planes):x+a1 y+a2 z==a3 &x+b1 y+b2 z==b3
I used a program called Mathematica that can solve symbolically many kinds of equations . The solution is given in the form: {{x->...,y->...,z->...},{x->...,y->...,z->...}}
where x,y,z are the coordinates of the point (there are 2 points since the ellipsoid is 2nd order.
_________________ "Never give up. Never surrender." -- Kenneth_of_Borg
"Seize the time, Meribor. Live now; make now always the most precious time. Now will never come again" -- Picard (The Inner Light)
07 Dec 2008, 20:00
Malvoisin
Fleet Admiral
Joined: 13 Nov 2006, 01:00 Posts: 2111 Location: Germany
alright, I know that program too . only thing is you don't need this definition of a line (better one in this case is the point and the cross product of the two normal vectors of the planes) since you already have two points to connect with a line. these are given so we should use the lambda definition to get our lambda since otherwise we need to artificially create two planes to intersect along the line between the two points and that wouldn't be necessary I think .
now I understand the a1, a2,.. 's . you give mathematica two general representations of your planes and tell him to find those points on the ellipsoid that match the plane equations, i.e. are on both planes. well, that is a little too much here in this case. Of course one could form 2 planes with that barymetric line representation we have and then your solution would be correct, but why the detour?
With regards to FEM, I'am currently working with microeletromechanical systems (MEMS) in which simulation of the geometric device and properties uses various techniques depending on the level of abstraction you want, of which finite element analysis / finite meshes is one. All about finding how much a beam bends or the effects of magnetism yadda yadda.
Regards Wolfe
_________________
07 Dec 2008, 22:29
captain_picard
Communications Officer
Joined: 21 Aug 2008, 16:59 Posts: 717 Location: On this multiverse: EU
Well, Mal I think you're right Also, despite the fact that both methods are the same, as they just use different representations for the line, I agree that mine is not suited for numerics. Calculations are so simple with Mathematica that I just didn't bother thinking it through!
Wolfe, in which language have you written your code? If it is in C, I could try and write a small routine that does what you want based on Mals algorithm.
Cheers
_________________ "Never give up. Never surrender." -- Kenneth_of_Borg
"Seize the time, Meribor. Live now; make now always the most precious time. Now will never come again" -- Picard (The Inner Light)
If you want you could give some random numbers for each of A B and C and the ellipse and write it out step by step lol, but i imagine that might take awhile .
So far what i have working seems to be ok but I may have to go back to the hard core math method if possible.
Regards Wolfe
_________________
08 Dec 2008, 01:25
Malvoisin
Fleet Admiral
Joined: 13 Nov 2006, 01:00 Posts: 2111 Location: Germany
pen&paper, pen&paper.. (no seriously, I'd recommend solving the equation to lambda on paper first and then it's just a one-liner in C# code to calculate lambda)
actually it's much less "hard core" math than you think: First, let's take out the third dimension (you'll see later on why this is not hurting anything). So the ellipsoid equation becomes an ellipse equation and looks like: x^2/a^2 + y^2/b^2 = 1 . Now let's take one special case and that's where a=b, then it gets to: x^2/a^2 + y^2/a^2 = 1. This is equal to: (x^2+y^2)/a^2=1 which is the same as x^2 + y^2 = a^2 . now let's just rename things (a little wildly I admit): a^2 + b^2 = c^2 . Now that does sound familiar, doesn't it?
so actually the ellipsoid equation is simple pythagoras in the end . You can use pythagoras to determine if a given point (a,b) is on the circle of radius sqrt(c^2)=c. If it fits the equation then yes, if a^2 + b^2 != c^2, then the point lies either inside or outside the circle with radius c. Now what you do above is simply calculating the lamdba needed to make a^2 + b^2 = c^2 (in simplified 2D case) whereby (a,b)=lambda*(x1,y1) + (1-lambda)*(x2,y2). This of course always works in the case where both points (x1,y1) and (x2,y2) lie in- and outside the circle (ellipsoid in 3D general case). In case both points lie outside the circle it can happen that the line does not intersect with the circle at all. You'll notice that when you get to take a sqrt of a negative number on the right side during calculation so there's only a complex solution to the equation.
08 Dec 2008, 08:00
Malvoisin
Fleet Admiral
Joined: 13 Nov 2006, 01:00 Posts: 2111 Location: Germany
of course never forget to translate the ellipsoid centre into the coordinate system's origin, i.e. take the vector from the origin to the centre point A (i.e. A) and subtract it from points B and C when insert B and C into the lambda formula. So instead of B and C you take (B-A) and (C-A). Otherwise the formula only works in case where A=0 .
09 Dec 2008, 07:20
3 0f 12
Crewman
Joined: 26 Jun 2008, 06:29 Posts: 42 Location: Ultramatrix 002
I must admit, this is beyond me, (borg synaptic processor explodes). But the effects are coming along nicely, nice job all.
_________________ We are the Borg. Lower your shields and surrender your ships. Your biological and technological distinctiveness will be added to our own. Your culture will adapt to service us. RESISTANCE IS FUTILE." - Borg Collective That doesn't mean I shouldn't be on your friend list.
Borg Quote of the Fortnight: "If only he had the chance of having an out-of-body experience, its truly perfection."
09 Dec 2008, 07:26
Malvoisin
Fleet Admiral
Joined: 13 Nov 2006, 01:00 Posts: 2111 Location: Germany
I also forgot you need to gram-schmidt orthonormalise (preserves norm of all vectors!) into the new vector space basis given by the vectors (a-A), (b-A) and (c-A) (yes, these are vectors at first, although in the ellipsoid formula, you take their norm and call it a, b and c). After that transform vector (B-A) and (C-A) into that new basis and calculate the formula.
you need to do that cause your ellipsoid usually isn't oriented along the 3 main axes!
09 Dec 2008, 07:46
Matress_of_evil
Evil Romulan Overlord of Evil - Now 100% Faster!
Joined: 02 Dec 2004, 01:00 Posts: 7392 Location: Returned to the previous place.
I vote we rename this thread the maths thread. People like me know to avoid it then.
So get any screenies of the shield effects yet? Or combat system updates? It would be nice to put something about the combat system on the front page of the portal...
_________________
"Anyone without a sense of humour is truly at the mercy of the rest of us."
09 Dec 2008, 09:56
captain_picard
Communications Officer
Joined: 21 Aug 2008, 16:59 Posts: 717 Location: On this multiverse: EU
I have the shield effect, first pass 90% done, everything is generally set up but i need to get the shield hit textures to align to the normal of the triangle it intersects. At the moment it is just a flat plane.
Still i'am shocked it was done this quickly (touch wood).
Regards Wolfe
_________________
09 Dec 2008, 11:18
Malvoisin
Fleet Admiral
Joined: 13 Nov 2006, 01:00 Posts: 2111 Location: Germany
I'm not very familiar with the actual mapping of textures done in 3D engines. Maybe you can ask the ST:Excalibur guys how they did it (if they already implemented shields and the corresponding shield texture mapping).
Users browsing this forum: No registered users and 4 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum