|
Post by DJLinux on Apr 9, 2008 21:29:03 GMT -5
Do you not happy with Anim8or, Blender, DeleD 3D, GameSpace, gMax, LightWave, Milk Shape 3D, Max Studio, OpenFX, Wings3D, and all the other wunderfull friends ? (i tryed all in the past)If so give the free version of TrueSpace an try www.caligari.com/products/truespace/ts3After 3-5 day's with it you will love this easy to use user interface. I'm writing an TrueSpace importer for Basic4GL. It's not a simple "hack" it can read all types of 3D objects (*.cob files) and whole TrueSpace scenes (*.scn files) (can be a simple still standing scene or a interaktive world/game) With the importer we can use from TrueSpace the whole inverse kinematik (6 DoF) , complex keyframe animations, all physics attributes like wind, gravity, collision, connectors ... , camera paths, all types of lights, and mutch more ... my importer can handle the most types of texturemaps png, tga, bmp, jpg, dds (gif only for cash you know :lol:) The free version of TS3.2 has no limitations and the best is i ported the TS3.2 SDK for it so if any modern function are missing (reaslistic looking fluid's for example) it can be implemented via plugin in any language that can create DLL's (C, C++, FreeBASIC, Pascal, Delphi...) If you will try TS3.2 in the help menu there are self running Task Tutorials ... same if you move "<-?" over any item if you run in any problems with TrueSpace ask me i can handle it while i'm sleeping ;D Joshy What i miss in TrueSpace is i can't put a blue print in the 2D or 3D views looks like a idea for the first TS plugin
|
|
|
Post by matthew on Apr 9, 2008 21:51:28 GMT -5
Thank's for the info, I'm going to download this now. I seem to remember there was a 3D animation program called trueSpace back when I owned an Amiga.
|
|
|
Post by Empyrion Martyr on Apr 10, 2008 14:56:43 GMT -5
The program looks interesting. I'll have a look at it... Still like Maya tho'... (and no i don't spend $$$$ on it )
|
|
|
Post by DJLinux on Apr 10, 2008 16:43:27 GMT -5
One feature is you can save your game objects (cars in my case) or whole levels (racing tracks in my case) as VRML (Virtual Reality Modeling Language) for your web site.
Joshy
|
|
|
Post by Darkjester on Apr 11, 2008 13:22:46 GMT -5
Awsome way better than blender!
|
|
|
Post by Darkjester on Apr 11, 2008 13:23:26 GMT -5
Any idea when the importer will be done?
|
|
|
Post by DJLinux on Apr 11, 2008 17:36:23 GMT -5
Any idea when the importer will be done? Any idea when you can create good looking modells with TrueSpace ? fun by site i can read all parts from TrueSpace scene and objects but i must create the right OpenGL code too. So 50% are done. Joshy
|
|
|
Post by smc44 on Apr 20, 2008 21:06:35 GMT -5
hey u guys should try somtin called 3dsmax p.s. it is the best (it was also used to make halo 1 , halo 2 , halo 3 )i know that because i watched all of the halo special edition discs to see if they were usin wat i was so that tells u how good of a modeler it is
|
|
|
Post by DJLinux on Nov 18, 2008 1:28:51 GMT -5
Since TrueSpace V7.6 is available for free too the old link to my favorite TrueSpace 3.2 are broken now you can get it from herethe free serial code is: 5300311749797 i lost my cool TS model/scene importer but i like this app so much and will write the importer in future again for beginners (without a TS book/manual) this can be very help full www.fignations.com/jelisa/tspace/basics/basics1.htmlTIP: take a look to the Point Editing section happy modeling :-) Joshy if any will write an B4GL importer too create a simple box save it as TS object *.cob and select [x] ASCII now you can read the object as text file and it's simple (the big numbers of diffrent posible material settings for any posible triangle can be a problem but a problem exist to solve it :lol:) Caligari V00.01ALH PolH V0.04 Id 35821900 Parent 0 Size 00000948 Name Cube center 0 0 1 x axis 1 0 0 y axis 0 1 0 z axis 0 0 1 Transform 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 World Vertices 8 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 1.000000 1.000000 -1.000000 -1.000000 1.000000 -1.000000 1.000000 -1.000000 1.000000 -1.000000 1.000000 1.000000 -1.000000 1.000000 1.000000 1.000000 -1.000000 1.000000 1.000000 Texture Vertices 14 0.000000 0.333333 0.000000 0.666667 0.250000 0.333333 0.250000 0.666667 0.500000 0.000000 0.500000 0.333333 0.500000 0.666667 0.500000 1.000000 0.250000 0.000000 0.250000 1.000000 0.750000 0.333333 0.750000 0.666667 1.000000 0.333333 1.000000 0.666667 Faces 6 Face verts 4 flags 0 mat 0 <2,2> <0,0> <1,1> <3,3> Face verts 4 flags 0 mat 0 <4,4> <0,8> <2,2> <5,5> Face verts 4 flags 0 mat 0 <5,5> <2,2> <3,3> <6,6> Face verts 4 flags 0 mat 0 <6,6> <3,3> <1,9> <7,7> Face verts 4 flags 0 mat 0 <4,10> <5,5> <6,6> <7,11> Face verts 4 flags 0 mat 0 <0,12> <4,10> <7,11> <1,13> Unit V0.01 Id 35821901 Parent 35821900 Size 00000009 Units 2 Mat1 V0.06 Id 35823284 Parent 35821900 Size 00000106 mat# 0 shader: phong facet: auto32 rgb 0.823529,0.823529,0.823529 alpha 1 ka 0.1 ks 0.1 exp 0 ior 1 END V1.00 Id 0 Parent 0 Size 0 EDIT:i found the sceleton of *.cob and *.scn parser in B4GL code for the binary mode. 'const File$ = "box.cob" const File$ = "box.scn"
type CHUNK_HEADER ChunkType as string ' 4 Chars VersMaj as integer ' 2 Bytes word VersMin as integer ' 2 Bytes word ChunkID as integer ParentID as integer ChunkSize as integer end type
const PHYSATR_GROUNDPLANE = 2 ' set truespace grid as a gravitation pad const PHYSATR_AUTOREWIND = 4 ' autorewind after end of simulation const PHYSATR_CONSTDELTA = 8 ' constant delta time is enabled const PHYSATR_DELETESCRIPT= 16 ' delete script when sim. is started const PHYSATR_ATMOSPHERE = 128 ' atmosphere is enabled
const PHYSDRW_SELECTED = 1 ' draw only selected objects const PHYSDRW_ALL = 2 ' draw all
const PHYSRES_INVISIBLE = 1 ' invisible const PHYSRES_SELECTED = 2 ' visible only if object is selected const PHYSRES_VISIBLE = 4 ' visible
' physics attributes data chunk type PHAS_DATA AtmosphereThinning as integer ' 0-400 AtmosphereDensity as single ' >0.0 GravityConst as single ' ReadInt()*0.01 PhysicsAttributes as integer ' see PHYSATR PhysicsDrawMode as integer ' see PHYSDRW NumOfSimFrames as integer ' simualtion frames per render frame NumOfSeconds as integer ' simulation time >0 PhysicsResources as integer ' see PHYSRES end type
' TrueSpace physical attributes scene chunk type PHAS_CHUNK Header as CHUNK_HEADER Chunk as PHAS_DATA end type ' scene data chunk type SCEN_DATA SceneNameDupecount as integer ' 2 Bytes word (can be 0) SceneName as string SelectedName as string
BackGroundRGBA(3) as single BackGroundName as string BackGroundAnimated as integer ' 2 bytes
GlobalEnvRGB(2) as single GlobalEnvName as string GlobalenvAnimated as integer ' 2 bytes FogEnabled as integer ' !!! 4 Bytes !!! FogRGB(2) as single FogNearClipping as single FogFarClipping as single
BackgroundFog as single ' 0.0 - 1.0 (0% - 100%) MinReflectivity as single ' 0.0 - 1.0 end type
' TrueSpace scene chunk type SCEN_CHUNK Header as CHUNK_HEADER Chunk as SCEN_DATA end type
' render options data type ROPT_DATA Raytracing as integer ' 1=on 0=off RenderResolution as integer ' 1=window 2=user defined 32=preset Width as integer Height as integer Antialias as integer ' 1=none 2=2x 4=3x 8=4x
FrameRate as integer ' 1 = render all frames ' 2 = render every 2nd frame ' 4 = render every 3rd frame ' 8 = render every 5th frame '16 = render every 10th frame
Depth as integer ' bits 1=32 2=16 4=15 8=8, 16=4
BaseRate as integer ' fps 1=25 2=30 4=24
Options as integer ' 1 = use background map ' 2 = use fog ' 4 = use global environment map ' 8 = use global environment cubic map ' 16 = use antialias ' 64 = use background movie '128 = use global environment movie '256 = use raytracing '512 = begin frame numbers with 0
Flags as integer ' dithering 1=on 2=off
Frame as integer ' 1=current fame only ' 2=all frames ' 4=selection of frames
JpgQuality as integer
FliFlags as integer ' 1=universal color palette ' 2=create palette for a first frame, ' 4-create palette for each frame separately ' 8-dither
TgaFlags as integer ' 1=compress file
ResolutionPreset as integer ' 0=720x480 1=720x486 2=720x576 3=768x576 4=320x200 ' 5=320x240 6=352x240 7=352x288 8=384x288 9=640x480 ' 10=704x480 11=704x576 12=736x398 13=256x192
DepthFocus as integer FieldFlags as integer ' 1=on 2=off MotionBlurFlags as integer ' 1=none 2=low 4=high 8=DoF off, 24=DoF On MotionBlurFrames as integer PixelAspectRatio as single RenderFilename as string DepthFocalDistance as single MotionBlurLength as single AntialiasingLevel as integer ' (1-none, 2-2x, 4-3x, 8-4x) RayDepthLimit as single MaxRayDepth as integer end type
' TruSpace render options chunk type ROPT_CHUNK Header as CHUNK_HEADER Chunk as ROPT_DATA end type
const VIEW_PERSP = 0 const VIEW_TOP = 1 const VIEW_FRONT = 2 const VIEW_LEFT = 3 const VIEW_CAMERA = 4
type ACTIVE_VIEW ViewType as integer ' 2 bytes word see VEW_CONTS ViewNumber as integer ' 2 bytes word Maximized as integer ' 2 bytes word Dimension(3) as single Shaded as integer ' 2 bytes word Smooth as integer ' 2 bytes word Textured as integer ' 2 bytes word end type
type ALL_VIEW EyeFlags as integer ' 2 bytes set to 0 Units as integer ' 2 bytes set to 2 (for meters) EyeZoom as single ' only for orthogonal eye OrthoDepth as single ' only for orthogonal eye EyeAxis(2) as single ' coordinates for horizontal eye axis Center(2) as single ' coordinates for center of axes. XAxis(2) as single ' direction of local X axis. YAxis(2) as single ' direction of local Y axis. ZAxis(2) as single ' direction of local Z axis. end type type VEWS_DATA NumOfViews as integer ' 2 bytes word TextureMapping as integer ' 2 bytes word SolidGrid as integer ' 2 bytes word Background as integer ' 2 bytes word ActiveViews(3) as ACTIVE_VIEW ' NumOfViews repeated AllViews(4) as ALL_VIEW ' for all 5 views end type
' TruSpace views chunk type VEWS_CHUNK Header as CHUNK_HEADER Chunk as VEWS_DATA end type const F_HOLE = 8 const F_BACKCULL = 16
type FACE_EDGE VertexIndex as integer UVIndex as integer end type
type POLH_FACE Flag as integer ' 1 byte NumOfEdges as integer ' 2 byte word MaterialIndex as integer ' 2 bytes (not for holes) &Edges() as FACE_EDGE end type
type POLH_DATA Dupecount as integer ' 2 Bytes word (can be 0) Name as string Center(2) as single XAxis(2) as single ' direction of local X axis. YAxis(2) as single ' direction of local Y axis. ZAxis(2) as single ' direction of local Z axis. Transform(3,3) as single NumOfVerticies as integer &Verticies()() as single NumOfUVCoords as integer &UVCoords()() as single NumOfFaces as integer ' !!! Faces and Holes !!! &Faces() as POLH_FACE end type
' TruSpace polygonal data chunk type POLH_CHUNK Header as CHUNK_HEADER Chunk as POLH_DATA end type
const U_MILLIMETERS = 0 const U_CENTIMETERS = 1 const U_METERS = 2 const U_KILOMETERS = 3 const U_INCHES = 4 const U_FEET = 5 const U_YARDS = 6 const U_MILES = 7 const U_POINTS = 8 type UNIT_DATA UnitsFlag as integer ' 2 bytes word see U_CONSTS end type
' TruSpace units chunk type UNIT_CHUNK Header as CHUNK_HEADER Chunk as UNIT_DATA end type
const ENV_CUBIC = 1 ' 0 = assumed to be a spherical environment map const ENV_USE = 2 const ENV_ANIMATED = 4 type ENV_MAP Flag as integer ' 1 byte see ENV_CONST's File as string end type const TEXT_OVERLAY = 1 const TEXT_USE = 2 const TEXT_AIMATED = 4 type TEXT_MAP Flag as integer ' 1 byte see TEXT_CONST's_ File as string OffsetU as single OffsetV as single RepeatU as single RepeatV as single end type
const BUMP_USE = 2 const BUMP_AIMATED = 4 type BUMP_MAP Flag as integer ' 1 byte see BUMP_CONST's_ File as string OffsetU as single OffsetV as single RepeatU as single RepeatV as single Amplitude as single end type
const GRANITE_USE = 2 type GRANITE_PROC Flag as integer ' byte 1 only GRANITE_USE ColorsRGBA(3,3) as single Amount(3) as single Sharpness as single Rscale as single ' (0.0 - 10.0) Sscale as single ' (0.0 - 10.0) Tscale as single ' (0.0 - 10.0) Seed as integer ' 2 bytes (1 - 32767) end type
const MARBLE_USE = 2 const GRAIN_R = 1 const GRAIN_S = 2 const GRAIN_T = 4 type MARBLE_PROC Flag as integer ' 1 byte only MARBLE_USE StoneRGBA(3) as single VeinRGBA(3) as single Sharpness as single Rscale as single ' (0.0 - 10.0) Sscale as single ' (0.0 - 10.0) Tscale as single ' (0.0 - 10.0) VeinTurbulence as integer ' 2 bytes (1-10) RSTGrainFlag as integer ' 2 bytes see GRAIN_CONST's Seed as integer ' 2 bytes (1 - 32767) end type
const WOOD_USE = 2 type WOOD_PROC Flag as integer ' 1 bye only WOOD_USE SpringRGBA(3) as single SummerRGBA(3) as single SpringSummerRatio as single ' (0.0 - 1.0)
RingDensity as single ' (0.0 - 10.0) RingWidthVariation as single ' (0.0 - 1.0) RingShapeVariation as single ' (0.0 - 1.0)
RRingCenter as single ' (0.0 - 1.0) SRingCenter as single ' (0.0 - 1.0) TRingCenter as single ' (0.0 - 1.0)
Rscale as single ' (0.0 - 10.0) Sscale as single ' (0.0 - 10.0) Tscale as single ' (0.0 - 10.0) RSTGrainFlag as integer ' 2 bytes see GRAIN_CONST's Seed as integer ' 2 bytes (1 - 32767) end type
type MAT1_DATA MaterialNumber as integer ' 2 byte word ShaderType as string ' 1 char "f"=flat "p"=phong "m"=metal FacetType as string ' 1 char "f"=faceted "a"=autofacet "s"=smooth AutofacetAngle as integer ' 1 byte 0-120 degrees ColorRGBA(3) as single Ambient as single Specular as single HilightSize as single IndexOfRefraction as single
EnvironmentMap as ENV_MAP BumpMap as BUMP_MAP TextureMap as TEXT_MAP
GraniteProc as GRANITE_PROC MarbleProc as MARBLE_PROC WoodProc as WOOD_PROC end type
' TruSpace material chunk type MAT1_CHUNK Header as CHUNK_HEADER Chunk as MAT1_DATA end type
type LGHT_DATA Dupecount as integer ' 2 Bytes word (can be 0) Name as string Center(2) as single XAxis(2) as single ' direction of local X axis. YAxis(2) as single ' direction of local Y axis. ZAxis(2) as single ' direction of local Z axis. Transform(3,3) as single LightType as integer ' 2 bytes 1=infinite 2=local 4=spot light CastShadows as integer ' 2 bytes 1=shadows 0=no shadows ' if cast shadows ShadowType as integer ' 2 bytes 1=ray traced 2=shadow map 4=memory map ' if ShadowMap or MemoryMap: ShadowMapResolution as integer ' 2 bytes 128=low 256=medium 512=high ShadowMapSharpness as integer ' 2 bytes 1=low 2=medium 3=high NormalizedRGB(2) as single Angle as single ' in degrees HotSpotAngle as single ' in degrees FallOff as integer ' 2 bytes 0=constant 1=linear 2=squared end type
' TruSpace light chunk type LGHT_CHUNK Header as CHUNK_HEADER Chunk as LGHT_DATA end type
function ReadString$(hFile,nChars) dim s$ while nChars s$=s$+ReadChar(hFile) nChars=nChars-1 wend return s$ end function
function IsTrueSpaceBinaryFormat(FileName$) dim hFile,ret hFile=OpenFileRead(FileName$) if hFile then if ReadString$(hFile,9)="Caligari " then if ReadString$(hFile,6)="V00.01" then if ReadString$(hFile,1)="B" then ret=True end if end if end if CloseFile(hFile) end if return ret end function
' integer shift right(value,shifts) sub shr(&v,n) v=v/pow(2,n) end sub
' integer shift left(value,shifts) sub shl(&v,n) v=v*pow(2,n) end sub
' integer to upper string (4 chars) function Int2UStr$(V) dim s$,i,a for i=1 to 4 a=(v and 255):SHR(v,8) if a>31 then s$=s$+chr$(a):end if next return ucase$(s$) end function
function CHUNK_HEADER ReadChunkHeader(hFile) dim H as CHUNK_HEADER H.ChunkType = UCase$(ReadString$(hFile,4)) H.VersMaj = ReadWord(hFile) H.VersMin = ReadWord(hFile) H.ChunkID = ReadInt(hFile) H.ParentID = ReadInt(hFile) H.ChunkSize = ReadInt(hFile) return H end function
function PHAS_DATA ReadPhasData(hFile,Size) dim D as PHAS_DATA D.AtmosphereThinning = ReadInt(hFile):Size=Size-4 D.AtmosphereDensity = ReadFloat(hFile):Size=Size-4 D.GravityConst = ReadInt(hFile)*0.01:Size=Size-4 D.PhysicsAttributes = ReadInt(hFile):Size=Size-4 D.PhysicsDrawMode = ReadInt(hFile):Size=Size-4 D.NumOfSimFrames = ReadInt(hFile):Size=Size-4 D.NumOfSeconds = ReadInt(hFile):Size=Size-4 D.PhysicsResources = ReadInt(hFile):Size=Size-4 if Size<>0 then ReadString$(hFile,Size) printr "warning: wrong PHAS data chunk size!" end if return D end function
function SCEN_DATA ReadScenData(hFile,Size) dim D as SCEN_DATA,i D.SceneNameDupecount = ReadWord(hFile):Size=Size-2 i = ReadWord(hFile):Size=Size-2 if i>0 then D.SceneName = ReadString$(hFile,i) + "," + D.SceneNameDupecount Size=Size-i end if i = ReadWord(hFile):Size=Size-2 if i then D.SelectedName = ReadString$(hFile,i) Size=Size-i end if
for i=0 to 3:D.BackGroundRGBA(i)=ReadFloat(hFile):Size=Size-4:next i = ReadWord(hFile):Size=Size-2 if i>0 then D.BackGroundName = ReadString$(hFile,i) Size=Size-i end if D.BackGroundAnimated = ReadWord(hFile):Size=Size-2
for i=0 to 2:D.GlobalEnvRGB(i)=ReadFloat(hFile):Size=Size-4:next i = ReadWord(hFile):Size=Size-2 if i>0 then D.GlobalEnvName = ReadString$(hFile,i) Size=Size-i end if D.GlobalenvAnimated = ReadWord(hFile):Size=Size-2 D.FogEnabled = ReadInt (hFile):Size=Size-4 for i=0 to 2:D.FogRGB(i)= ReadFloat(hFile):Size=Size-4:next D.FogNearClipping = ReadFloat(hFile):Size=Size-4 D.FogFarClipping = ReadFloat(hFile):Size=Size-4 D.BackgroundFog = ReadFloat(hFile):Size=Size-4 D.MinReflectivity = ReadFloat(hFile):Size=Size-4 if Size<>0 then printr "error: wrong SCEN data chunk size!" end end if return D end function
function ROPT_DATA ReadRoptData(hFile,Size) dim D as ROPT_DATA,i D.Raytracing = ReadInt(hFile):Size=Size-4 D.RenderResolution = ReadInt(hFile):Size=Size-4 D.Width = ReadInt(hFile):Size=Size-4 D.Height = ReadInt(hFile):Size=Size-4 D.Antialias = ReadInt(hFile):Size=Size-4 D.FrameRate = ReadInt(hFile):Size=Size-4 D.Depth = ReadInt(hFile):Size=Size-4 D.BaseRate = ReadInt(hFile):Size=Size-4 D.Options = ReadInt(hFile):Size=Size-4 D.Flags = ReadInt(hFile):Size=Size-4 D.Frame = ReadInt(hFile):Size=Size-4 D.JpgQuality = ReadInt(hFile):Size=Size-4 D.FliFlags = ReadInt(hFile):Size=Size-4 D.TgaFlags = ReadInt(hFile):Size=Size-4 D.ResolutionPreset = ReadInt(hFile):Size=Size-4 D.DepthFocus = ReadInt(hFile):Size=Size-4 D.FieldFlags = ReadInt(hFile):Size=Size-4 D.MotionBlurFlags = ReadInt(hFile):Size=Size-4 D.MotionBlurFrames = ReadInt(hFile):Size=Size-4 i=ReadWord(hFile):Size=Size-2 if i>0 then i=i+1 D.PixelAspectRatio=Val(ReadString$(hFile,i)) Size=Size-i end if
i=ReadWord(hFile):Size=Size-2 if i>0 then i=i+1 D.RenderFilename=ReadString$(hFile,i) Size=Size-i end if i=ReadWord(hFile):Size=Size-2 if i>0 then i=i+1 D.DepthFocalDistance=Val(ReadString$(hFile,i)) Size=Size-i end if
i=ReadWord(hFile):Size=Size-2 if i>0 then i=i+1 D.MotionBlurLength=Val(ReadString$(hFile,i)) Size=Size-i end if D.AntialiasingLevel = ReadInt(hFile):Size=Size-4 D.RayDepthLimit = ReadInt(hFile)*0.01:Size=Size-4 D.MaxRayDepth = ReadInt(hFile):Size=Size-4
if Size<>0 then printr "error: wrong ROPT data chunk size!" end end if return D end function
function VEWS_DATA ReadVewsData(hFile,Size) dim D as VEWS_DATA,i,j D.NumOfViews = ReadWord(hFile):Size=Size-2 D.TextureMapping = ReadWord(hFile):Size=Size-2 D.SolidGrid = ReadWord(hFile):Size=Size-2 D.Background = ReadWord(hFile):Size=Size-2
for i=0 to D.NumOfViews-1 d.ActiveViews(i).ViewType = ReadWord(hFile):Size=Size-2 d.ActiveViews(i).ViewNumber = ReadWord(hFile):Size=Size-2 d.ActiveViews(i).Maximized = ReadWord(hFile):Size=Size-2 for j=0 to 3 d.ActiveViews(i).Dimension(j) = ReadFloat(hFile):Size=Size-4 next d.ActiveViews(i).Shaded = ReadWord(hFile):Size=Size-2 d.ActiveViews(i).Smooth = ReadWord(hFile):Size=Size-2 d.ActiveViews(i).Textured = ReadWord(hFile):Size=Size-2 next for i=0 to 4 ' for all 5 views d.AllViews(i).EyeFlags = ReadWord(hFile):Size=Size-2 d.AllViews(i).Units = ReadWord(hFile):Size=Size-2 d.AllViews(i).EyeZoom = ReadFloat(hFile):Size=Size-4 d.AllViews(i).OrthoDepth = ReadFloat(hFile):Size=Size-4 for j=0 to 2:d.AllViews(i).EyeAxis(j)=ReadFloat(hFile):Size=Size-4:next for j=0 to 2:d.AllViews(i).Center(j) =ReadFloat(hFile):Size=Size-4:next for j=0 to 2:d.AllViews(i).XAxis(j) =ReadFloat(hFile):Size=Size-4:next for j=0 to 2:d.AllViews(i).YAxis(j) =ReadFloat(hFile):Size=Size-4:next for j=0 to 2:d.AllViews(i).ZAxis(j) =ReadFloat(hFile):Size=Size-4:next next
if Size<>0 then printr "error: wrong VEWS data chunk size!" end end if return D end function
function POLH_DATA ReadPolhData(hFile,Size) dim D as POLH_DATA,i,j D.Dupecount = ReadWord(hFile):Size=Size-2 i=ReadWord(hFile):Size=Size-2 if i>0 then D.Name=ReadString$(hFile,i) + "," + D.Dupecount Size=Size-i end if
for i=0 to 2:D.Center(i)=ReadFloat(hFile):Size=Size-4:next for i=0 to 2:D.XAxis(i) =ReadFloat(hFile):Size=Size-4:next for i=0 to 2:D.YAxis(i) =ReadFloat(hFile):Size=Size-4:next for i=0 to 2:D.ZAxis(i) =ReadFloat(hFile):Size=Size-4:next for i=0 to 2 for j=0 to 3 D.Transform(i,j) =ReadFloat(hFile):Size=Size-4 next next ' !!! last row not included !!! D.Transform(3,0)=0:D.Transform(3,1)=0:D.Transform(3,2)=0:D.Transform(3,3)=1.0
D.NumOfVerticies=ReadInt(hFile):Size=Size-4 Alloc D.Verticies,D.NumOfVerticies,3 For i=0 to D.NumOfVerticies-1 for j=0 to 2 D.Verticies(i,j)=ReadFloat(hFile):Size=Size-4 next next D.NumOfUVCoords=ReadInt(hFile):Size=Size-4 Alloc D.UVCoords,D.NumOfUVCoords,2 For i=0 to D.NumOfUVCoords-1 for j=0 to 1 D.UVCoords(i,j)=ReadFloat(hFile):Size=Size-4 next next D.NumOfFaces=ReadInt(hFile):Size=Size-4 Alloc D.Faces,D.NumOfFaces For i=0 to D.NumOfFaces-1 D.Faces(i).Flag=ReadByte(hFile):Size=Size-1 D.Faces(i).NumOfEdges=ReadWord(hFile):Size=Size-2 Alloc D.Faces(i).Edges,D.Faces(i).NumOfEdges ' only a face has material not a hole if (D.Faces(i).Flag and F_HOLE)=0 then D.Faces(i).MaterialIndex=ReadWord(hFile):Size=size-2 end if for j=0 to D.Faces(i).NumOfEdges-1 D.Faces(i).Edges(j).VertexIndex=ReadInt(hFile):Size=Size-4 D.Faces(i).Edges(j).UVIndex =ReadInt(hFile):Size=Size-4 next next
if Size<>0 then printr "error: wrong POHL data chunk size!" end end if return D end function
function UNIT_DATA ReadUnitData(hFile,Size) dim D as UNIT_DATA D.UnitsFlag=ReadWord(hFile):Size=Size-2 if Size<>0 then printr "error: wrong UNIT data chunk size!" end end if return D end function
function MAT1_DATA ReadMat1Data(hFile,Size) dim D as MAT1_DATA,i,j,map$ D.MaterialNumber = ReadWord(hFile):Size=Size-2 D.ShaderType = ReadChar(hFile):Size=Size-1 D.FacetType = ReadChar(hFile):Size=Size-1 D.AutofacetAngle = ReadByte(hFile):Size=Size-1 for i=0 to 3 D.ColorRGBA(i) = ReadFloat(hFile):Size=Size-4 next D.Ambient = ReadFloat(hFile):Size=Size-4 D.Specular = ReadFloat(hFile):Size=Size-4 D.HilightSize = ReadFloat(hFile):Size=Size-4 D.IndexOfRefraction = ReadFloat(hFile):Size=Size-4
' optinal E:nvironment T:exture B:ump maps or ' procedural texture G:ranite or M:arble or W:ood while Size>0 map$=Ucase$(ReadString$(hFile,2)):Size=Size-2 if map$="E:" then d.EnvironmentMap.Flag= ReadByte(hFile):Size=Size-1 i=ReadWord(hFile):Size=Size-2 d.EnvironmentMap.File=ReadString$(hFile,i):Size=Size-i
elseif map$="T:" then d.TextureMap.Flag = ReadByte(hFile):Size=Size-1 i=ReadWord(hFile):Size=Size-2 d.TextureMap.File=ReadString$(hFile,i):Size=Size-i d.TextureMap.OffsetU = ReadFloat(hFile):Size=Size-4 d.TextureMap.OffsetV = ReadFloat(hFile):Size=Size-4 d.TextureMap.RepeatU = ReadFloat(hFile):Size=Size-4 d.TextureMap.RepeatV = ReadFloat(hFile):Size=Size-4 elseif map$="B:" then d.BumpMap.Flag = ReadByte(hFile):Size=Size-1 i=ReadWord(hFile):Size=Size-2 d.BumpMap.File=ReadString$(hFile,i):Size=Size-i d.BumpMap.OffsetU = ReadFloat(hFile):Size=Size-4 d.BumpMap.OffsetV = ReadFloat(hFile):Size=Size-4 d.BumpMap.RepeatU = ReadFloat(hFile):Size=Size-4 d.BumpMap.RepeatV = ReadFloat(hFile):Size=Size-4 d.BumpMap.Amplitude = ReadFloat(hFile):Size=Size-4 elseif map$="G:" then d.GraniteProc.Flag = ReadByte(hFile):Size=Size-1 d.GraniteProc.Flag = GRANITE_USE for i=0 to 3 for j=0 to 3 d.GraniteProc.ColorsRGBA(i,j)= ReadFloat(hFile):Size=Size-4 next next for i=0 to 3 d.GraniteProc.Amount(3) = ReadFloat(hFile):Size=Size-4 next d.GraniteProc.Sharpness = ReadFloat(hFile):Size=Size-4 d.GraniteProc.Rscale = ReadFloat(hFile):Size=Size-4 d.GraniteProc.Sscale = ReadFloat(hFile):Size=Size-4 d.GraniteProc.Tscale = ReadFloat(hFile):Size=Size-4 d.GraniteProc.Seed = ReadWord(hFile):Size=Size-2
elseif map$="M:" then d.MarbleProc.Flag = ReadByte(hFile):Size=Size-1 d.MarbleProc.Flag = MARBLE_USE for i=0 to 3 d.MarbleProc.StoneRGBA(i) = ReadFloat(hFile):Size=Size-4 next for i=0 to 3 d.MarbleProc.VeinRGBA(i) = ReadFloat(hFile):Size=Size-4 next d.MarbleProc.Sharpness = ReadFloat(hFile):Size=Size-4 d.MarbleProc.Rscale = ReadFloat(hFile):Size=Size-4 d.MarbleProc.Sscale = ReadFloat(hFile):Size=Size-4 d.MarbleProc.Tscale = ReadFloat(hFile):Size=Size-4 d.MarbleProc.VeinTurbulence = ReadWord(hFile):Size=Size-2 d.MarbleProc.RSTGrainFlag = ReadWord(hFile):Size=Size-2 d.MarbleProc.Seed = ReadWord(hFile):Size=Size-2
elseif map$="W:" then d.WoodProc.Flag = ReadByte(hFile):Size=Size-1 d.WoodProc.Flag = WOOD_USE for i=0 to 3 d.WoodProc.SpringRGBA(i) = ReadFloat(hFile):Size=Size-4 next for i=0 to 3 d.WoodProc.SummerRGBA(i) = ReadFloat(hFile):Size=Size-4 next d.WoodProc.SpringSummerRatio = ReadFloat(hFile):Size=Size-4
d.WoodProc.RingDensity = ReadFloat(hFile):Size=Size-4 d.WoodProc.RingWidthVariation = ReadFloat(hFile):Size=Size-4 d.WoodProc.RingShapeVariation = ReadFloat(hFile):Size=Size-4
d.WoodProc.RRingCenter = ReadFloat(hFile):Size=Size-4 d.WoodProc.SRingCenter = ReadFloat(hFile):Size=Size-4 d.WoodProc.TRingCenter = ReadFloat(hFile):Size=Size-4
d.WoodProc.Rscale = ReadFloat(hFile):Size=Size-4 d.WoodProc.Sscale = ReadFloat(hFile):Size=Size-4 d.WoodProc.Tscale = ReadFloat(hFile):Size=Size-4 d.WoodProc.RSTGrainFlag = ReadWord(hFile):Size=Size-2 d.WoodProc.Seed = ReadWord(hFile):Size=Size-2 else printr "error: unknow maptype !" end end if wend
if Size<>0 then printr "error: wrong MAT1 data chunk size!" end end if return D end function
function LGHT_DATA ReadLghtData(hFile,Size) dim D as LGHT_DATA,i,j D.Dupecount = ReadWord(hFile):Size=Size-2 i=ReadWord(hFile):Size=Size-2 if i>0 then D.Name=ReadString$(hFile,i) + "," + D.Dupecount Size=Size-i end if printr "D.Name:" + D.Name for i=0 to 2:D.Center(i)=ReadFloat(hFile):Size=Size-4:next for i=0 to 2:D.XAxis(i) =ReadFloat(hFile):Size=Size-4:next for i=0 to 2:D.YAxis(i) =ReadFloat(hFile):Size=Size-4:next for i=0 to 2:D.ZAxis(i) =ReadFloat(hFile):Size=Size-4:next for i=0 to 2 for j=0 to 3 D.Transform(i,j) =ReadFloat(hFile):Size=Size-4 next next ' !!! last row not included !!! D.Transform(3,0)=0:D.Transform(3,1)=0:D.Transform(3,2)=0:D.Transform(3,3)=1.0 D.LightType = ReadWord(hFile):Size=Size-2 D.CastShadows = ReadWord(hFile):Size=Size-2 if D.CastShadows>0 then D.ShadowType = ReadWord(hFile):Size=Size-2 D.ShadowMapResolution = ReadWord(hFile):Size=Size-2 D.ShadowMapSharpness = ReadWord(hFile):Size=Size-2 end if for i=0 to 2 D.NormalizedRGB(2)=ReadFloat(hFile):Size=Size-4 next D.Angle = ReadFloat(hFile):Size=Size-4 D.HotSpotAngle = ReadFloat(hFile):Size=Size-4 D.FallOff = ReadWord(hFile):Size=Size-2
if Size<>0 then printr "Size:" + Size printr "error: wrong LGHT data chunk size!" end end if return D end function
' ' main ' ResizeText(WindowWidth()/16,WindowHeight()/16)
dim Hdr as CHUNK_HEADER dim hFile,i if IsTrueSpaceBinaryFormat(FILE$) then hFile=OpenFileRead(FILE$) Seek(hFile,32) Hdr=ReadChunkHeader(hFile) while Hdr.ChunkType<>"END " printr ">" + Hdr.ChunkType + "<" if Hdr.ChunkType = "PHAS" then ReadPHASData(hFile,Hdr.ChunkSize) elseif Hdr.ChunkType = "SCEN" then ReadSCENData(hFile,Hdr.ChunkSize) elseif Hdr.ChunkType = "ROPT" then ReadROPTData(hFile,Hdr.ChunkSize) elseif Hdr.ChunkType = "VEWS" then ReadVEWSData(hFile,Hdr.ChunkSize) elseif Hdr.ChunkType = "POLH" then ReadPOLHData(hFile,Hdr.ChunkSize) elseif Hdr.ChunkType = "UNIT" then ReadUNITData(hFile,Hdr.ChunkSize) elseif Hdr.ChunkType = "MAT1" then ReadMAT1Data(hFile,Hdr.ChunkSize) elseif Hdr.ChunkType = "PRTX" then ReadMAT1Data(hFile,Hdr.ChunkSize) elseif Hdr.ChunkType = "LGHT" then ReadLGHTData(hFile,Hdr.ChunkSize) else printr "not implemented!" for i=1 to Hdr.ChunkSize:ReadByte(hFile):next end if Hdr=ReadChunkHeader(hFile) wend CloseFile(hFile) end if
|
|
|
Post by Wayne Rayner on Nov 18, 2008 5:37:52 GMT -5
DjLinux it's ok bout ur bad english u r pretty good at it. I also learnt english as a second language when we moved to australia. My first langauge was Africaans, and TS is easy and awesome thanks for posting it here i really will help me a lot more wayne
|
|