Author Topic: Coding scrapbook (side multipart turrents)  (Read 6585 times)

0 Members and 1 Guest are viewing this topic.

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
Re: Coding scrapbook (side multipart turrents)
that's because he has yet to add it in there, I was just sugesting a course of action.
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline StratComm

  • The POFressor
  • 212
  • Cameron Crazy
    • http://www.geocities.com/cek_83/index.html
Re: Coding scrapbook (side multipart turrents)
That's what I was thinking.  This isn't something that you'd want in the tables, as it's more pertinant to the POF itself.  I'd actually say you could use the existing rotation axis value, though most models butcher how that's actually done since turrets ignore it.  At any rate, I can see two different "default" configurations for side turrets, so either that would have to be cleared up explicitly or you'd need both a major (base) and minor (barrels) rotation axis to cover all possible combinations.

And a z-based turret would probably look a little strange on the front of a ship, but it'd make an excellent configuration for a bomber turret facing backwards.
who needs a signature? ;)
It's not much of an excuse for a website, but my stuff can be found here

"Holding the last thread on a page comes with an inherent danger, especially when you are edit-happy with your posts.  For you can easily continue editing in points without ever noticing that someone else could have refuted them." ~Me, on my posting behavior

Last edited by StratComm on 08-23-2027 at 08:34 PM

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Coding scrapbook (side multipart turrents)
it would make a good slasher :D

id like to see guns like the ones in the turret of the tank i posted. also sence people are looking at this i think it would be a good time to bring up.....

GATLING TURRETS!!!!!!!
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline FireCrack

  • 210
  • meh...
Re: Coding scrapbook (side multipart turrents)
Would it be possible to make turrets that dont have a defined direction their barrels should face, ex- the main body of the turret has no front, and the barrles can rotate through a full 180 arc instead of just 90 degrees.

That would make front turrets actualy semi-sensical.
actualy, mabye not.
"When ink and pen in hands of men Inscribe your form, bipedal P They draw an altar on which God has slaughtered all stability, no eyes could ever soak in all the places you anoint, and yet to see you all at once we only need the point. Flirting with infinity, your geometric progeny that fit inside you oh so tight with triangles that feel so right."
3.141592653589793238462643383279502884197169399375105820974944 59230781640628620899862803482534211706...
"Your ever-constant homily says flaw is discipline, the patron saint of imperfection frees us from our sin. And if our transcendental lift shall find a final floor, then Man will know the death of God where wonder was before."

 

Offline TrashMan

  • T-tower Avenger. srsly.
  • 213
  • God-Emperor of your kind!
    • FLAMES OF WAR
Re: Coding scrapbook (side multipart turrents)
That makes sense...When you think about it, the turret base rotates only around one axis, and hte turret barrels areound another (that is, IF the side turrets are positioned in a fixed 90° angle)

A good default position would have the barrels of hte side turrets (and hte base) facing towards the front of the ship. then you'd use the base z axis (or was it Y...the one that points towarsd hte top anyway) to determine how far the base has to rotate to track the target, and move the barrels.
Of course, the procedure would be different if the barels can move 180°
Nobody dies as a virgin - the life ****s us all!

You're a wrongularity from which no right can escape!

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Coding scrapbook (side multipart turrents)
id like to see single object turrets that can pivit on both the x and y axes. they would look cool and you could use alot of them withought using too many subobjects.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Mav

  • 28
  • location: Shivan fleet - closing in on GTVA space
Re: Coding scrapbook (side multipart turrents)
i think hes got a point.

i figure on a side turret youd just need to swap

desired_angles.p = (float)acos(of_dst.xyz.z);
desired_angles.h = PI - atan2_safe(of_dst.xyz.x, of_dst.xyz.y);
desired_angles.b = 0.0f;

with
desired_angles.p = PI - atan2_safe(of_dst.xyz.x, of_dst.xyz.y);
desired_angles.h = (float)acos(of_dst.xyz.z);
desired_angles.b = 0.0f;


essentially swapping pitch for heading.



Thanks :) . But that's not completely it. These fields set the angles the turret will try to face (or so I think). You'd more need to change

"      vm_interp_angle(&base_angles->h,desired_angles.h,step_size);
vm_interp_angle(&gun_angles->p,desired_angles.p,step_size);      "


to something like

"      vm_interp_angle(&base_angles->p,desired_angles.p,step_size);
vm_interp_angle(&gun_angles->h,desired_angles.h,step_size);      "


for the side turrets. These seem (to me at least) to do the actual rotation. Note how they refer to "base" and "gun" (i.e. barrel) . :)


This is still not very well thought through, but it is something that could be tested (if one of the coders decides to do so). :)


@Nuke: Nose-mounted slashers? Hmm, nice idea - can't wait to see some... :drevil: ;)
-__ o_O___O_o
I______O_O_______dragons
________o

-----------------------------------
capship shields DO WORK !!!
my models, now with pics
test mission for commanding capships
-----------------------------------
suffering from a late stage of BoE-infection - DON'T call a doctor, it's too late for that anyway ;o)

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: Coding scrapbook (side multipart turrents)
Are you saying, swap both? Or just do your change and not Nuke's?
-C

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Coding scrapbook (side multipart turrents)
i think this line here
(float)acos(of_dst.xyz.z)
represents a 90 degree motion while this puppy
PI - atan2_safe(of_dst.xyz.x, of_dst.xyz.y)
is for the full 360
both are just simply using the normal vector to calculate the angular rotation of the various parts of the turret. or at least i think, you might try swithcing the math, do a build, and just watch what the turrets do. it might give you a bette idea of how everything works.

*edit*
i was just contemplating the vector math abit more. if i was right this might be the only thing youd need to change. the other parts of the code are for positionng the normal somewhere within the turret's fof (at least thats what im thinking). if you make this code smarter, that it can sence the kind of turret being used, you could give it different vector maths for different turret configurations.
« Last Edit: January 22, 2006, 12:32:22 pm by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Mav

  • 28
  • location: Shivan fleet - closing in on GTVA space
Re: Coding scrapbook (side multipart turrents)
@WMC: I'd say only my change... explanation below.

@Nuke: Surely I could be wrong, but as I am viewing it, the "desired_angles.X = XXX" calculates from the vector to the target what angles the turret should try to face - they don't do something to the turret itself. Then, the turrets rotation speed is read ("float step_size = turret->turret_turning_rate * flFrametime;") and used in the following commands which then actually move the turret parts around to point to the previously calculated target angles.
I see, I didn't realize that myself in the first post I made in this thread...  :o    Still, if the lines you're proposing were changed, that might quite possibly result in the turret trying to face 90 degree AWAY from its target (or something even more crazy :wtf: ), still only rotating around the old axes...

My assumptions might be wrong, but they seem rather plausible to me. As I said, I didn't realize it myself at the start, but now I think that first statement of mine was way too rushed... :/  Hope the new one's better though... :nervous:


[edit1] Oh, and the "(float)acos(of_dst.xyz.z)"-line gives me a major headache - shouldn't an acos take TWO lengths as argument??? :confused:
« Last Edit: January 23, 2006, 04:09:46 pm by Mav »
-__ o_O___O_o
I______O_O_______dragons
________o

-----------------------------------
capship shields DO WORK !!!
my models, now with pics
test mission for commanding capships
-----------------------------------
suffering from a late stage of BoE-infection - DON'T call a doctor, it's too late for that anyway ;o)

  

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Coding scrapbook (side multipart turrents)
my assuption is based entirely on the vector math and my limited understanding of trig functions, not on the actual code. also im only looking at the code snippet that was shown by wmc, not the whole of the turret code. so i assume you have more insight into those aspects. its not really a matter of whose right and whos wrong, just youre looking at one perspective while im looking at another.

im assuming that of_dst.xyz.z is the turret normal's forward distance from the turret center. the vector math sugests to be that it is caculating the rotational angle off of that distance. this indicates to me that single part turrets behave the same exact way that multipart turrets do, by rotating the normal around the fire point. the difference with multiparts is only in that they move and theese lines return the angles that they should try to move to  i may of course be entirely wrong there. now that piece of vector math i understand reasonably well. the PI - atan2_safe(of_dst.xyz.x, of_dst.xyz.y) calculation i understand less. but i think it calculates the heading angle of the turret. im trying to figure out how. so im looking at some trig on wikipedia to try to understand what it does a little better. if i figure it out il draw up some diagrams of how the turret angles are calculated so that we all can undersstand it better.

[edit1] Oh, and the "(float)acos(of_dst.xyz.z)"-line gives me a major headache - shouldn't an acos take TWO lengths as argument??? :confused:

acos is really a 1 dimentinal thing, but its suffietent to calculate the angle (in degrees or radians, im not sure) of pitch for the gun objec. this tells to code that does the moving where to go (at least for the gun's pitch). it works so long as the normal length is capped at 1 somewhere else in the code. im assuming all turret, gun, dock normals are capped at 1 on model load. there should be something like (nl /1)*nl in there (nl = normal length) in the loading cod to cap normals. seeing as normal conformity is rather important in a 3d game to keep them consistant. so if the normals been capped, and it pitches forward so its 45 degrees from its center, then acos on the distance of the normal 's z cood from the turret center should equil 45. so if the capped normal is 45 degrees off center, then the distance of the normal's z axis from its center would equil 0.70710678118654752440084436210485. and the acos of that number returns 45, i think the same is true no matter if you use radians or degrees.
« Last Edit: January 23, 2006, 06:55:59 pm by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN