[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/jp/ - Otaku Culture


View post   

File: 1.49 MB, 894x926, lasers.png [View same] [iqdb] [saucenao] [google]
25178461 No.25178461 [Reply] [Original]

How do you program these?
Right now I'm thinking about using a series of quads along with transformation matrices to fill the laser with the same sprite at each point, there points being defined in constant intervals with a bezier curve.

>> No.25178468
File: 8 KB, 586x300, programmerArt.png [View same] [iqdb] [saucenao] [google]
25178468

>> No.25182116

Think lazier and simpler, they are just lines rotated around a point.
If your algo is more than cos sin rotation and basic physics, you messed up.

>> No.25182926
File: 207 KB, 767x896, immafiringmahlazor.png [View same] [iqdb] [saucenao] [google]
25182926

>>25182116
Well I could always do this, but my sprite selection would for lasers be limited by how efectively the sprite blends and the laser curvature.
A mid-laser sprite change could be useful but it would be really limiting I think.

>> No.25186607

>>25178461
Told ya last thread.
It’s nothing but math.

>> No.25188183
File: 12 KB, 641x480, lasers.png [View same] [iqdb] [saucenao] [google]
25188183

divide laser texture into more sections the longer the laser is

>> No.25196835

>>25188183
Fuck, now I need to migrate my stuff to openGL

>> No.25208043
File: 33 KB, 801x693, possible.png [View same] [iqdb] [saucenao] [google]
25208043

>>25188183
Proposal:
Precompute the laser trajectory and get the angle difference between quads based on curvature.
Iterate the laser through the already generated quads (with a queue?).

>> No.25210433

>>25208043
(This doesn't account for the laser length, very bad)

>> No.25219897

>>25208043
>>25210433
solution: just map the quads on the actual sprite properly (the quad length in the sprite should have a length of ||p[i] - p[i+1]||.
sage.

>> No.25222810

>>25178461
Just learn math, dude
https://sparen.github.io/ph3tutorials/ph3tutorials.html

>> No.25233363

>>25208043
Like you show, the laser would be made up of nodes added at set intervals where the laser moving and growing are both just adding more nodes at the head according to its trajectory, and when it's full length the tail drops nodes. Segment the texture proportional to however many nodes there are. I wasn't really considering the exact vertex placement, but you might get something smooth if you put them perpendicular to the angle between a node's next and last nodes. This might be similar to what you mean by precomputing, but rather I think you would just not treat the current head node as active and only use it for computing the vertices for the one behind it. Of course also you wouldn't have to recompute any of these, just any new ones.

>> No.25233795

>>25178461
ask /g/

>> No.25245195
File: 2.36 MB, 420x428, 1590884374770.gif [View same] [iqdb] [saucenao] [google]
25245195

>>25178461
Thumbnail had me thinking it was some sperm fertilizing an egg.

>> No.25253412

>>25233795
/jp/ is smarter than /g/
you guys are also way nicer

>> No.25259243
File: 5 KB, 266x124, alright.png [View same] [iqdb] [saucenao] [google]
25259243

extremely shameful

>> No.25275964

>>25259243
just make it better

>>
Name
E-mail
Subject
Comment
Action