@Simeon Yes, I am working at an existing project using an iPad4.
In the meantime I managed to narrow down the problem but I still could not solve it. Here I attach a much reduced version of my code that still produces the error. I am working on am interactive 3D scene that updates the “modelMatrix” based on the “RotationRate” vector (i.e. acceleration data).
Editing the program using AirCode results in a crash of Codea. No crash occurred if the “RotationRate” vector is replaced by a constant vector or if
tot_rot_mat=tot_rot_mat:rotate(phi*180/ math.pi,rot_unit_vect.z, rot_unit_vect.x,rot_unit_vect.y)
is replaced by
tot_rot_mat=tot_rot_mat:rotate(phi*180/ math.pi,1,1,1)
Also no crash occurs when I simply display the “RotationRate” vector (without updating “tot_rot_mat”), i.e. if it is not used to update the “modelMatrix”.
----------------------------------------------
--# Main
-- Cube
function setup()
tot_rot_mat=matrix()
cube = mesh()
local vertices = {
vec3(-0.5, -0.5, 0.5), -- Left bottom front
vec3( 0.5, -0.5, 0.5), -- Right bottom front
vec3( 0.5, 0.5, 0.5), -- Right top front
vec3(-0.5, 0.5, 0.5), -- Left top front
vec3(-0.5, -0.5, -0.5), -- Left bottom back
vec3( 0.5, -0.5, -0.5), -- Right bottom back
vec3( 0.5, 0.5, -0.5), -- Right top back
vec3(-0.5, 0.5, -0.5), -- Left top back
}
cube.vertices = {
-- Front
vertices[1], vertices[2], vertices[3],
vertices[1], vertices[3], vertices[4],
-- Right
vertices[2], vertices[6], vertices[7],
vertices[2], vertices[7], vertices[3],
-- Back
vertices[6], vertices[5], vertices[8],
vertices[6], vertices[8], vertices[7],
-- Left
vertices[5], vertices[1], vertices[4],
vertices[5], vertices[4], vertices[8],
-- Top
vertices[4], vertices[3], vertices[7],
vertices[4], vertices[7], vertices[8],
-- Bottom
vertices[5], vertices[6], vertices[2],
vertices[5], vertices[2], vertices[1],
}
cube:setColors(color(234,0,2,255))
end
function draw()
background(0, 0, 0)
camera(0,0,-3,0,0,0)
perspective()
pushMatrix()
phi_vect=DeltaTime*RotationRate
phi=math.sqrt(phi_vect.x^2+phi_vect.y^2+phi_vect.z^2)
rot_unit_vect=(1/phi)*phi_vect
------ >>>>
tot_rot_mat=tot_rot_mat:rotate(phi*180/ math.pi,rot_unit_vect.z, rot_unit_vect.x,rot_unit_vect.y)
------ <<<<
modelMatrix(tot_rot_mat)
cube:draw()
popMatrix()
end