Well, this code is BMax + minib3d but it should be easily to convert it to B3D. It simply morphs between these to meshes.
Maybe its useful ;)
Maybe its useful ;)
Import sidesign.minib3d Graphics3D 640,480,0,2 bit0 = LoadMesh ("bit0.3ds") MoveEntity bit0,10,0,0 bit1 = LoadMesh ("bit1.3ds") MoveEntity bit1,-10,0,0 Local bitmorph:TMorph = TMorph.Create(bit0,bit1) cam = CreateCamera() MoveEntity cam,0,0,-20 light = CreateLight() MoveEntity light,50,50,0 Print "C1 : " + CountTriangles(GetSurface(bit0,1)) Print "C2 : " + CountTriangles(GetSurface(bit1,1)) Local Frame:Float = 0.0 Local Morph:Byte = False While Not KeyHit(KEY_ESCAPE) TurnEntity bit0,0,1,0 TurnEntity bit1,0,1,0 TurnEntity bitmorph.result,0,1,0 If KeyHit(KEY_SPACE) Then Morph = True Frame = 0 EndIf If Morph = True Then Frame:+12.0 bitmorph.Morph(Sin(Frame)*99,100) If Frame > 180 Then Morph = False EndIf UpdateWorld() RenderWorld() Flip Wend Type TMorph Field Source:TMesh Field Target:TMesh Field Result:TMesh Field frames:Int = 60 Function Create:TMorph(S:TMesh,Target:TMesh) Local M:TMorph = New TMorph M.Source =S M.Target = Target M.Result = CopyMesh(S) Return M End Function Method Morph(Frame:Int,MaxFrames:Int = 300) Local P:Float = Abs((1.0/(MaxFrames-1))*(Frame Mod MaxFrames)) Local SS:TSurface = GetSurface(Source,1) Local ST:TSurface = GetSurface(Target,1) Local SR:TSurface = GetSurface(Result,1) EntityColor(Result,255.0*P,(1.0-P)*255.0,(1.0-P)*255.0) For Local V:Int = 0 To CountVertices(SS)-1 Local XS:Float = VertexX(SS,V) Local YS:Float = VertexY(SS,V) Local ZS:Float = VertexZ(SS,V) Local XT:Float = VertexX(ST,V) Local YT:Float = VertexY(ST,V) Local ZT:Float = VertexZ(ST,V) Local XR:Float = Interpolate(XS,XT,P) Local YR:Float = Interpolate(YS,YT,P) Local ZR:Float = Interpolate(ZS,ZT,P) VertexCoords(SR,V,XR,YR,ZR) Next UpdateNormals(Result) End Method Method Interpolate:Float(x1:Float , x2:Float , trans:Float) Return x1 + ((x2-x1)*trans) End Method End Type