[ 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.

/sci/ - Science & Math

Search:


View post   

>> No.6164488 [View]
File: 856 KB, 275x372, rotate.gif [View same] [iqdb] [saucenao] [google]
6164488

Hey /sci/, sorry to bother you guys. I'm doing some programming, and I'm having trouble solving a problem. I posted all around the internet, but so far no one has answered me.

Here's the problem:

I need to rotate a model on the screen with my mouse, but this rotation also needs to be based on the current roll and pitch of the camera. I've got the first part down, but I don't know how to go on with transforming my roll and pitch to be relative to the camera. Right now, the rotation only works if the camera has not been rotated yet (which is to be expected considering that's what the current code was made to do.)

Also, do note that I do mean roll instead of yaw. I want the roll to be controlled with the left and right swipes of the mouse.

I've read that quaternions can solve the problem, but being a learn-by-example learner, I haven't been able to figure out how to do this. I can't for the life of me figure out how those things work - a lot of websites seem to overcomplicate what they are. Or I'm probably just an idiot. I'm assuming the latter.

Here is my current code (Note that PI2 is simply Pi * 2):
http://pastebin.com/B3CkdcPL

Pic related is a GIF of how it looks right now when the camera hasn't be rotated. It goes out of whack when I rotate it though.

I'd go by /g/, but you guys are a lot smarter and will probably get down to the point really fast.

I'll delete the thread when I get an answer.

Navigation
View posts[+24][+48][+96]