## Groverburger's 3D Engine (g3d) v1.3 Release

groverburger
Prole
Posts: 35
Joined: Tue Oct 30, 2018 9:27 pm

### Re: Groverburger's 3D Engine (g3d) v1.3 Release

pgimeno wrote: Sun Feb 21, 2021 3:18 am No, the w of a quaternion is not the angle! It's the real component, which for a quaternion representing a pure rotation (i.e. normalized), equals the cosine of half the rotation angle. The name of the function suggests that it accepts a quaternion, but an axis/angle rotation is not a quaternion, even if the conversion to quaternion is fairly simple. That's why I suggest choosing a name that doesn't cause this confusion. A quaternion is what you use internally as rotation[1..4]. I'd expect a function called setQuaternionRotation to set rotation[1..4] to each input parameter. Something like:
Oh good point, I mixed up some math lingo . Thanks for the feedback.
Just pushed a commit to fix this by splitting the function into two:

Code: Select all

-- create a quaternion from an axis and an angle
function model:setAxisAngleRotation(x,y,z,angle)
x,y,z = vectorNormalize(x,y,z)
angle = angle / 2

self.rotation[1] = x * math.sin(angle)
self.rotation[2] = y * math.sin(angle)
self.rotation[3] = z * math.sin(angle)
self.rotation[4] = math.cos(angle)

self:updateMatrix()
end

-- rotate given one quaternion
function model:setQuaternionRotation(x,y,z,w)
self.rotation[1] = x
self.rotation[2] = y
self.rotation[3] = z
self.rotation[4] = w
self:updateMatrix()
end

I could also consolidate model:setRotation and model:setQuaternionRotation into just one function with an optional fourth argument...
pgimeno
Party member
Posts: 2575
Joined: Sun Oct 18, 2015 2:58 pm

### Re: Groverburger's 3D Engine (g3d) v1.3 Release

Sounds sensible.
Nikki
Prole
Posts: 36
Joined: Wed Jan 25, 2017 5:42 pm

### Re: Groverburger's 3D Engine (g3d) v1.3 Release

Hi Groverburger, starting to play around with your engine,

Now i am wondering, i use the collision code to figure out a collision, that works.

If i would want to move an object in the 3d world, by dragging with the mouse, what steps would i need to take ?
Nikki
Prole
Posts: 36
Joined: Wed Jan 25, 2017 5:42 pm

### Re: Groverburger's 3D Engine (g3d) v1.3 Release

Sorry for the double posting, but another question which is a smaller step to my goal,

say you disable the firstperson controller, how do you still use the collision code ?
how should i calculate the look vector (to plug in the rayIntersectionAABB) in that case?

I would like the camera to be relatively static and be able to move the mouse and have collision with the mouse working.

Sorry for these noobish questions, but i am a 3d noob.
groverburger
Prole
Posts: 35
Joined: Tue Oct 30, 2018 9:27 pm

### Re: Groverburger's 3D Engine (g3d) v1.3 Release

Nikki wrote: Sun Apr 18, 2021 7:54 am Hi Groverburger, starting to play around with your engine,

Now i am wondering, i use the collision code to figure out a collision, that works.

If i would want to move an object in the 3d world, by dragging with the mouse, what steps would i need to take ?
Maybe you could get the mouse movement information with the love.mousemoved callback function, and move the model with the setTranslation function? You could also plug the mouse coordinates directly into the translation function, but neither of these will move the model relative to your viewport. That would require some trigonometry and math stuff.

Either way, the g3d model API wiki link might be useful to you here.

### Who is online

Users browsing this forum: No registered users and 21 guests