Ooops
November 24, 2020, 06:26:17 AM

Author Topic: [bb] Milkshape - ASCII by Vertex [ 1+ years ago ]  (Read 719 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Milkshape - ASCII by Vertex [ 1+ years ago ]
« on: June 29, 2017, 12:28:38 AM »
Title : Milkshape - ASCII
Author : Vertex
Posted : 1+ years ago

Description : Hi!
this code export a entity as *.txt that
You can import in Milkshape (File -> Import -> Milkshape 3D ASCCI ...)
i need the commmands to read informations about the
brushs/textures and bones from a entity!!!!! Pleace Mark ! :D
cu olli


Code :
Code: BlitzBasic
  1. Graphics3D 640,480,32,2
  2. SetBuffer BackBuffer()
  3.  
  4. Sphere = CreateCylinder(5,1)
  5.  
  6. saveASCII(Sphere,"C:Sphere.txt")
  7.  
  8. Camera = CreateCamera()
  9. PositionEntity Camera,0,5,5
  10. PointEntity Camera,Sphere
  11.  
  12. Light = CreateLight(1,Camera)
  13.  
  14. While Not KeyDown(1)
  15.         TurnEntity Sphere,0,1,0
  16.         UpdateWorld : RenderWorld : Flip
  17. Wend
  18. ClearWorld : End
  19.  
  20. Function saveASCII(Entity,File$)
  21.         Local S,V,VX#,VY#,VZ#,VU#,VV#
  22.         Local NX#,NY#,NZ#,T,V0,V1,V2
  23.        
  24.         Stream = WriteFile(File$)
  25.        
  26.         WriteLine Stream,"Frames: 1" ; Totalframes
  27.         WriteLine Stream,"Frame: 1" ; Currentfame
  28.         WriteLine Stream,"Meshes: " + CountSurfaces(Entity) ; Number of meshes
  29.        
  30.         For S = 1 To CountSurfaces(Entity)
  31.             Surface = GetSurface(Entity,S)
  32.                 ; Mesh name flag and materialindex
  33.                 If S = 1 Then
  34.                         If EntityName$(Entity) <> "" Then
  35.                                 WriteLine Stream,Chr$(34) + EntityName$(Entity) + Chr$(34) + " 0 -1"
  36.                         Else
  37.                                 WriteLine Stream,Chr$(34) + "Group" + S + Chr$(34) + " 0 -1"                           
  38.                         EndIf
  39.                 Else
  40.                         WriteLine Stream,Chr$(34) + "Group" + S + Chr$(34) + " 0 -1"
  41.                 EndIf
  42.                                
  43.                                
  44.                 ; Number of vertices
  45.                 WriteLine Stream,CountVertices(Surface)
  46.                 For V = 0 To CountVertices(Surface) - 1
  47.                         VX# = VertexX#(Surface,V) : VY# = VertexY#(Surface,V)
  48.                         VZ# = VertexZ#(Surface,V) : VU# = VertexU#(Surface,V)
  49.                         VV# = VertexV#(Surface,V)
  50.                         ; Vertex flag X Y Z U V boneindex
  51.                         WriteLine Stream,"0 "+VX#+" "+VY#+" "+VZ#+" "+VU#+" "+VV#+" -1"
  52.                 Next
  53.                
  54.                 ; Number of normals
  55.                 WriteLine Stream,CountVertices(Surface)
  56.                 For V = 0 To CountVertices(Surface) - 1
  57.                         NX# = VertexNX#(Surface,V)
  58.                         NY# = VertexNY#(Surface,V)
  59.                         NZ# = VertexNZ#(Surface,V)
  60.                         ; Normal X Y Z
  61.                         WriteLine Stream,NX# + " " + NY# + " " + NZ#
  62.                 Next
  63.                
  64.                 ; Number of triangles
  65.                 WriteLine Stream,CountTriangles(Surface)
  66.                 For T = 0 To CountTriangles(Surface) - 1
  67.                         V0 = TriangleVertex(Surface,T,0)
  68.                         V1 = TriangleVertex(Surface,T,1)       
  69.                         V2 = TriangleVertex(Surface,T,2)
  70.                         ; Triangle flag vertexindex 0 1 2 Normalindex 0 1 2 smoothinggroup
  71.                         WriteLine Stream,"0 "+V0+" "+V1+" "+V2+" "+V0+" "+V1+" "+V2+" 0"
  72.                 Next
  73.                
  74.                 ; Bones...
  75.         Next
  76.         WriteLine Stream,"Materials: 0"
  77.         WriteLine Stream,"Bones: 0"
  78.         CloseFile Stream
  79. End Function


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal