Показать сообщение отдельно
Старый 23.09.2007, 19:03   #18
mr.DIMAS
Дэвелопер
 
Аватар для mr.DIMAS
 
Регистрация: 26.12.2006
Адрес: Санкт-Петербург
Сообщений: 1,572
Написано 547 полезных сообщений
(для 1,540 пользователей)
Re: Редактор карт

Это весь код:

 
Type MObject
Field Entity
Field SX#,SY#,SZ#
Field X#,Y#,Z#
Field Picked
End Type
 
 
;Сдесь находятся все глобальные переменные
Global camera
Global world
 
Graphics3D 1024,768,32,1
SetBuffer BackBuffer()
 
camera=CreateCamera()
PositionEntity camera,0,5,0
 
world=CreatePlane()
EntityPickMode world,2
 
Repeat
For m.mobject = Each Mobject
pik=CameraPick(camera,MouseX(),Mouse())
If pik = world Then
If MouseHit(1) Then
CreateStena(PickedX(),PickedY(),PickedZ(),0,0,0,0. 5,2,2)
End If
End If
 
If pik=m\entity then 
m\picked=1-m\picked
End if
 
If KeyDown(200) Then MoveEntity camera,0,0,.1
If KeyDown(208) Then MoveEntity camera,0,0,-.1
If KeyDown(203) Then MoveEntity camera,.1,0,0
If KeyDown(205) Then MoveEntity camera,-.1,0,0
If KeyHit(64) Then WriteMap("map.shm") ;F6
If KeyHit(65) Then LoadMap("map.shm") ;F7
Next
RenderWorld
Text MouseX(),MouseY(),"^"
Flip
Until KeyHit(1)
End
 
 
Function CreateStena(X#,Y#,Z#,P#,YA#,R#,SX#,SY#,SZ#)
o.MObject=New MObject
o\entity=CreateCube()
PositionEntity o\entity,X#,Y#,Z#
ScaleEntity o\entity,SX#,SY#,SZ#
RotateEntity o\entity,P#,YA#,R#
EntityPickMode o\entity,2
End Function
 
Function WriteMap(Path$)
file=WriteFile(Path$)
For m.MObject = Each MObject
WriteFloat file,EntityX(m\entity)
WriteFloat file,EntityY(m\entity)
WriteFloat file,EntityZ(m\entity)
WriteFloat file,EntityPitch(m\entity)
WriteFloat file,EntityYaw(m\entity)
WriteFloat file,EntityRoll(m\entity)
WriteFloat file,MeshWidth(m\entity)
WriteFloat file,MeshHeight(m\entity)
WriteFloat file,MeshDepth(m\entity)
Next
 
End Function
 
Function LoadMap(Path$)
fil=ReadFile(Path$)
;Удаляем старые стены
For m.MObject = each MObject
 
Next
While Not Eof(file)
X#=ReadFloat(File)
Y#=ReadFloat(File)
Z#=ReadFloat(File)
P#=ReadFloat(File)
YA#=ReadFloat(File)
R#=ReadFloat(File)
SX#=ReadFloat(File)
SY#=ReadFloat(File)
SZ#=ReadFloat(File)
CreateStena(X#,Y#,Z#,P#,YA#,R#,SX#,SY#,SZ#)
Wend
End Function
 
Function Deformation()
For m.mobject=Each Mobject
If m\picked=1 Then
If KeyDown(2) Then 
ScaleEntity m\entity,MeshWidth(m\entity)+0.01,MeshHeight(m\ent ity),MeshDepth(m\entity)
End If 
If KeyDown(3) Then 
ScaleEntity m\entity,MeshWidth(m\entity)-0.01,MeshHeight(m\entity),MeshDepth(m\entity)
End If 
If KeyDown(4) Then 
ScaleEntity m\entity,MeshWidth(m\entity),MeshHeight(m\entity)+ .01,MeshDepth(m\entity)
End If 
If KeyDown(5) Then 
ScaleEntity m\entity,MeshWidth(m\entity),MeshHeight(m\entity)-.01,MeshDepth(m\entity)
End If 
If KeyDown(6) Then 
ScaleEntity m\entity,MeshWidth(m\entity),MeshHeight(m\entity), MeshDepth(m\entity)+.01
End If 
If KeyDown(7) Then 
ScaleEntity m\entity,MeshWidth(m\entity),MeshHeight(m\entity)-.01,MeshDepth(m\entity)-0.01
End If 
 
 
If KeyDown(8) Then 
PositionEntity m\entity,EntityX(m\entity)+0.01,EntityY(m\entity), EntityZ(m\entity)
End If 
If KeyDown(9) Then 
PositionEntity m\entity,EntityX(m\entity)-0.01,EntityY(m\entity),EntityZ(m\entity)
End If 
 
If KeyDown(10) Then 
PositionEntity m\entity,EntityX(m\entity),EntityY(m\entity)+0.01, EntityZ(m\entity)
End If 
If KeyDown(11) Then 
PositionEntity m\entity,EntityX(m\entity),EntityY(m\entity)-0.01,EntityZ(m\entity)
End If 
 
If KeyDown(12) Then 
PositionEntity m\entity,EntityX(m\entity),EntityY(m\entity),Entit yZ(m\entity)-.01
End If 
If KeyDown(13) Then 
PositionEntity m\entity,EntityX(m\entity),EntityY(m\entity),Entit yZ(m\entity)+.01
End If 
End If
Next
 
End Function
__________________

(Offline)
 
Ответить с цитированием