IdeasVacuum , look the following example about TransFormMesh, which i have posted before. since there is no TransFormMesh keyword inside 3D examples.
when you press arrow keys you can detach a triangle and moving it away from the mesh. but i can't decide if the scalex,scaley,scalez and rotatex,rotatey,rotatez are working okay or not.
Code: Select all
Declare CreateFigure_(FigNum, size)
#Win=8
#node=9
EnableExplicit
Define Mat2,rot,xx.f,yy.f,zz.f,yyy.l,ss.s,k.l,Event.l
InitEngine3D()
InitSprite()
InitKeyboard()
Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
;oooooooooooooooooooooooooooooooooooooooooooooooooooooooo
OpenWindow(#Win,0,0,640,480,"Use arrow keys to detach a triangle",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Win),0,0,640,400,1,0,0)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0,0,0,300)
CameraLookAt(0, 0,0, 0)
CameraBackColor(0,0)
CreateLight(1,RGB(255,255,255),0,0,0)
Mat2=CreateMaterial(0, LoadTexture(0, "ValetCoeur.jpg"))
MaterialCullingMode(0, 1)
CreateFigure_(1,150)
CreateEntity(1,MeshID(1),Mat2,400,-350,0)
CreateNode(#node , 0, 0, 0)
AttachNodeObject(#node, EntityID(1))
;TransformMesh(#Mesh, x, y, z, ScaleX, ScaleY, ScaleZ, RotateX, RotateY, RotateZ [, SubMesh])
Repeat
Event = WindowEvent()
zz=0:xx=0
ExamineKeyboard()
yyy+1
RotateNode(#node, 0, rot, 0 )
rot+1 : If rot>360 :rot= 1 :EndIf
RenderWorld()
FlipBuffers()
If KeyboardPushed(#PB_Key_Up)
zz=zz-2
TransformMesh(1, xx, yy, zz, 1, 1, 1, 0, 0, 0 , 2)
ElseIf KeyboardPushed(#PB_Key_Down)
zz=zz+2
TransformMesh(1, xx, yy, zz, 1, 1, 1, 0, 0, 0 , 2)
ElseIf KeyboardPushed(#PB_Key_Right)
xx+2
TransformMesh(1, xx, yy, zz, 1, 1, 1, 0, 0, 0 , 2)
ElseIf KeyboardPushed(#PB_Key_Left)
xx-2
TransformMesh(1, xx, yy, zz, 1, 1, 1, 0, 0, 0 , 2)
EndIf
Until KeyboardPushed(#PB_Key_Escape) Or Event = #PB_Event_CloseWindow
Procedure CreateFigure_(FigNum, Size)
Protected.l i,r
Protected.f x, y, z,u, v
Protected.w t1, t2, t3
CreateMesh(FigNum,#PB_Mesh_TriangleList,#True)
r=0
AddSubMesh()
For i=0 To 11
;note that backside vertices begins with v12
r=r+1
If r=4
r=1
AddSubMesh()
EndIf
Read.f x : Read.f y : Read.f z
Read.f u: Read.f v
MeshVertexPosition(x * size, y * Size, z * Size)
MeshVertexTextureCoordinate(u, v)
;;wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
Next i
Restore Triangles
For i=0 To 3
Read.w t1 : Read.w t2 : Read.w t3
MeshFace(t1, t2, t3)
Next i
FinishMesh(#True)
EndProcedure
DataSection
Vertices:
Data.f -2.5, 2.5 ,0, 1,0.5
Data.f -2.5, 3 ,0, 1,0
Data.f -3, 3 ,0, 0,0
Data.f -3, 3 ,0, 0,0
Data.f -3, 2.5 ,0, 0,0.5
Data.f -2.5, 2.5 ,0, 1,0.5
Data.f -2.5, 2 ,0, 1,1
Data.f -2.5, 2.5 ,0, 1,0.5
Data.f -3, 2.5 ,0, 0,0.5
Data.f -3, 2.5 ,0, 0,0.5
Data.f -3, 2 ,0, 0,1
Data.f -2.5, 2 ,0, 1,1
Triangles:
Data.w 0,1,2
Data.w 3,4,5
Data.w 6,7,8
Data.w 9,10,11
EndDataSection