2014-04-22 3 views
0

우선, Sonic Adventure 2에서 주입 된 코드를 제어하기 위해 치트 엔진에서 실행되는 루아 코드가 있습니다 (온라인이 아니기 때문에 걱정하지 마십시오). 게임 내에서 그래픽을 렌더링하는 함수를 호출합니다. 이 함수는 3D 선만 그릴 수 있습니다. 그 중 12 개에서 큐브를 그리는 함수를 작성 했으므로 실제로는 문제가 아닙니다. 다른 셰이프의 함수도 작성할 수 있습니다.3D 회전 코드가 제대로 작동하지 않습니다

이제 큐브를 회전 할 수 있어야합니다. Sonic Adventure 2가 회전을 처리하는 방법은 BAMS (Binary Angle Measurement System, 기본적으로 360도 = 0x10000)에 저장된 3 개의 값을 가지고 있다는 것입니다. 하나의 값이 각 축에 해당합니다. 회전은 Y, X, Z 순서로 수행됩니다. 내가하고있는 그림이 게임 내부의 객체와 일치하기 때문에 이것이 내 코드에서도 순환 게재를 처리하는 방법입니다. 그러나 회전이 제대로 작동하지 않는 것 같습니다. 여전히 6 면체를 형성하지만 (모서리는 여전히 연결되어 있습니다.) 큐브가 전단되고 찌그러져 보입니다. 그리고 대상을 움직이면 잘못된 방향으로 이동합니다.

여기 내 코드의 관련 부분입니다 :

function DrawLine3DPerformRotation(line, axis1, axis2, ctr1, ctr2, angle) 
    --Internal function used by DrawLine3D 
    if angle ~= 0 then 
     for i=1,2 do 
      local x = line[axis1..tonumber(i)] - ctr1 
      local y = line[axis2..tonumber(i)] - ctr2 
      local th = math.rad(angle * (360/0x10000)) 
      line[axis1..tonumber(i)] = (x*math.cos(th) - y*math.sin(th)) + ctr1 
      line[axis1..tonumber(i)] = (x*math.sin(th) + y*math.cos(th)) + ctr2 
     end 
    end 
end 

function DrawLine3D(identifier, x1, y1, z1, x2, y2, z2, color, temp) 
    local line = {} 
    line.x1 = x1 
    line.y1 = y1 
    line.z1 = z1 
    line.x2 = x2 
    line.y2 = y2 
    line.z2 = z2 

    DrawLine3DPerformRotation(line, "x", "z", LDRotateCtrX, LDRotateCtrZ, LDRotateY) 
    DrawLine3DPerformRotation(line, "y", "z", LDRotateCtrY, LDRotateCtrZ, LDRotateX) 
    DrawLine3DPerformRotation(line, "x", "y", LDRotateCtrX, LDRotateCtrY, LDRotateZ) 

    line.color = color 
    if temp then 
     LDLineListTemp[identifier] = line 
    else 
     LDLineList[identifier] = line 
    end 
    --UpdateLineList() 
end 

답변

1

문제를 발견. 9 행에서 axis1..tonumber(i)이라고 말하면 axis2..tonumber(i)이라고 말합니다.

관련 문제