Statistics: Posted by The Awakened — Sun Dec 04, 2005 12:19 pm
Statistics: Posted by matt2jones — Sun Dec 04, 2005 5:51 am
Statistics: Posted by Guest — Sun Dec 04, 2005 3:36 am
Code:
*--------* [Camera points-> | Ship | *--------*
Code:
*-* |p| |i| |h| |S| *-* [Camera points->
Code:
*-----------------* | p | | i | | h [CAM]-> | | S | *-----------------* So you'll now be looking at the rotated ship from the inside. You have to move it back to where is was originally to get the correct rotated view of it. Doing that is easy, just add back to the coords of every point in the ship the values you subtracted from them in the first step.Recap:* Pick point to rotate around* Translate ship model so that point is a origin* Rotate Ship about origin* Translate ship model so that the middle point is back where it was* Draw the model.I hope this helps,matt
Statistics: Posted by matt2jones — Sat Dec 03, 2005 8:45 am
Statistics: Posted by Guest — Sat Dec 03, 2005 1:08 am
Code:
#define SC_UP &h48#define SC_LEFT &h4B#define SC_RIGHT &h4D#define SC_DOWN &h50#define SC_Q &h10#define SC_E &h12#define pi 3.1415926535897932TYPE V3D X as Single Y as Single Z as SingleEND TYPETYPE SimpleEnt Rot as V3D Coor as V3DEND TYPEType Edges PointA as V3D PointB as V3DEND TYPEDeclare SUB rotpt (x1!, y1!, z1!, rotx!, roty!, rotz!, nx!, ny!, nz!)Declare SUB Point3D (xA!, yA!, zA!, xP, yP, DST)CONST LENS = 384CONST CenterX=320CONST CenterY=240Dim ToyLine(36) as EdgesDim ToyVert(16) as V3DDim TempX, TempY, TempZ, RotPY, RotPX, RotPZ as SingleDim Dist, ProjX(2), ProjY(2), PrevX, PrevY as IntegerDIM TOM, EEE as IntegerFOR TOM=1 to 16 READ ToyVert(TOM).X READ ToyVert(TOM).Z READ ToyVert(TOM).Y ToyVert(TOM).Z=-ToyVert(TOM).Z ToyVert(TOM).Y=-ToyVert(TOM).YNEXT TOMFor TOM =1 to 36 READ StartPNT READ EndPNT ToyLine(TOM).PointA.X=ToyVert(StartPNT+1).X ToyLine(TOM).PointA.Y=ToyVert(StartPNT+1).Y ToyLine(TOM).PointA.Z=ToyVert(StartPNT+1).Z ToyLine(TOM).PointB.X=ToyVert(EndPNT+1).X ToyLine(TOM).PointB.Y=ToyVert(EndPNT+1).Y ToyLine(TOM).PointB.Z=ToyVert(EndPNT+1).ZNext TOM Screen 18RotPY!=0RotPX!=0RotPZ!=0 DOFOR EEE = 1 to 36 rotpt ToyLine(EEE).PointA.X,ToyLine(EEE).PointA.Y,ToyLine(EEE).PointA.Z,RotPX!,RotPY!,RotPZ!,TempX!,TempY!,TempZ! Point3D TempX!, TempY!, TempZ!, ProjX(1), ProjY(1), Dist rotpt ToyLine(EEE).PointB.X,ToyLine(EEE).PointB.Y,ToyLine(EEE).PointB.Z,RotPX!,RotPY!,RotPZ!,TempX!,TempY!,TempZ! Point3D TempX!, TempY!, TempZ!, ProjX(2), ProjY(2), Dist If Dist>0 Then LINE (ProjX(1),ProjY(1))-(ProjX(2),ProjY(2)),15 END IF NEXT EEESLEEP 1CLSLocate 5,5:Print "3D Wireframe Ship Test"if multikey(SC_LEFT) then RotPY!=RotPY!+.005end ifif multikey(SC_Right) then RotPY!=RotPY!-.005end ifif multikey(SC_UP) then RotPX!=RotPX!-.005end ifif multikey(SC_Down) then RotPX!=RotPX!+.005end ifif multikey(SC_Q) then RotPZ!=RotPZ!-.005end ifif multikey(SC_E) then RotPZ!=RotPZ!+.005end ifLocate 1,1:Print RotPX!Locate 2,1:Print RotPY!Locate 3,1:Print RotPZ!Loop Until Inkey$=" "ENDSUB Point3D (xA!, yA!, zA!, xP, yP, DST) DST = (LENS - zA!) xP=CenterX+(LENS * xA! / DST) yP=CenterY+(LENS * yA! / DST)END SUBSUB rotpt (x1!, y1!, z1!, rotx!, roty!, rotz!, nx!, ny!, nz!) DIM AS SINGLE rx,ry,rz rx = rotx! ry = roty!+90 rz = rotz!+90 'xrot nx1! = x1! ny1! = z1! * SIN(pi * rx) + y1! * COS(pi * rx) nz1! = z1! * COS(pi * rx) - y1! * SIN(pi * rx) 'yrot nx2! = nx1! * COS(pi * ry) - nz1! * SIN(pi * ry) ny2! = ny1! nz2! = nx1! * SIN(pi * ry) + nz1! * COS(pi * ry) 'zrot nx! = nx2! * COS(pi * rz) - ny2! * SIN(pi * rz) ny! = nx2! * SIN(pi * rz) + ny2! * COS(pi * rz) nz! = nz2! END SUBData -22,-203,-3Data 22,-203,-3Data -53,162,43Data 53,162,43Data 118,129,-19Data 154,162,-3Data -154,162,-3Data -118,129,-19Data -18,-142,10Data 18,-142,10Data 38,-51,11Data -38,-51,11Data 20,-51,43Data -20,-51,43Data 53,162,-3Data -53,162,-3Data 8,13Data 8,11Data 8,9Data 9,12Data 9,10Data 0,11Data 0,8Data 0,7Data 0,6Data 0,1Data 1,10Data 1,9Data 1,5Data 1,4Data 2,15Data 2,13Data 2,11Data 2,6Data 2,3Data 3,14Data 3,12Data 3,10Data 3,5Data 4,14Data 4,7Data 4,5Data 5,14Data 5,10Data 6,15Data 6,11Data 6,7Data 7,15Data 10,12Data 11,13Data 12,13Data 14,15
Statistics: Posted by Guest — Sat Dec 03, 2005 1:06 am