For your pleasure today I have software rendered rotations! Although the quad is rendered by OpenGL and is in fact Hardware, the rotation math is all handled by the cpu.
This is a feature I am working on adding to sen3d.
Any ways, here is the code!
dim rad as double
dim i : i = 0
dim i2 : i2 = 0
dim pi as double : pi = 3.14
dim new_x as double
dim new_y as double
dim new_z as double
dim x_ang as double
dim move_speed as double : move_speed = 0.1
dim model(20) as double
model(0)= -1.0
model(1)= 1.0
model(2)= 0.0
model(3)= 1.0
model(4)= 1.0
model(5)= 0.0
model(6)= 1.0
model(7)= -1.0
model(8)= 0.0
model(9)= -1.0
model(10)= -1.0
model(11)= 0.0
dim x3d, y3d, z3d
dim tempModel(20) as double
while true
if ( x_ang < 2 * pi ) then
'model(i2) = 1 * cos(x_ang)
'model(i2 + 2) = 1 * sin(x_ang)
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
glTranslatef(0,0.0,-6.0)
glColor3f(0.5,0.5,1.0)
glBegin(GL_QUADS)
while(i < 11)
x3d = model(i)
y3d = model(i + 1)
z3d = model(i + 2)
tempModel(i) = (y3d * cos(x_ang)) - (z3d * sin(x_ang))
tempModel(i+2) = (y3d * sin(x_ang)) + (z3d * cos(x_ang))
tempModel(i) = (x3d * cos(x_ang)) - (tempModel(i+2) * sin(x_ang))
tempModel(i+2) = (x3d * sin(x_ang)) + (tempModel(i+2) * cos(x_ang))
glVertex3f(tempModel(i), model(i + 1), tempModel(i + 2))
i = i + 3
wend
glEnd()
SwapBuffers ()
else
x_ang = 0
endif
if (i > 11) then
i = 0
endif
x_ang = x_ang + 0.01
wend
It is still a bit bugged as I am not 100% sure of what I'm doing. But it is a large step in the right direction. The problem I am faced with in implementing these types of rotations in sen3d is that objects are up to 7000 vertex, and each object in the scene might need to rotate at a slightly different angle due to camera perspective. If anybody has any info on this, please let me know!