January 18, 2002
at 12:00 pm /
#11279
Hi All,
The Neutral Object Format (NOF) is 3DC’ answer to MD2. It is a very simple file format that includes mesh animation. The main goal was to create a format that was andquot;Neutralandquot;, meaning it doesn’t favour a particular type of game, and is graphics API neutral. A secondary but nearly as important goal was to make it really easy to read.
I have written a plug-in that will be provided with the next release of 3DC that imports a NOF file and creates an object from it. This sample could be used to read in a NOF file and export to another format (say MD2) or it could be used by game development systems to load NOF.
Anyone who is interested in this plug-in let me know (<!– e –><a href="mailto:richard@amabilis.com">richard@amabilis.com</a><!– e –>)
Richard
Here is the source for reading a Neutral Object Format file:
‘******************************************************
‘ Purpose: Loads a Neutral Object File (nof)
‘******************************************************
Public Function udtLoadNOF(strFile As String) As udtNOFFile
Dim intFileNumber As Long
Dim lngPointListKeyFrame As Long
With udtLoadNOF
‘get the next available files and open input file
intFileNumber = FreeFile
Open strFile For Binary Lock Read As #intFileNumber
‘get the header
Get #intFileNumber, , .udtHeader
‘if there are textures, get them
If .udtHeader.lngTextureCount ] 0 Then
ReDim .udtaTextureList(.udtHeader.lngTextureCount – 1) As udtNOFTexture
Get #intFileNumber, , .udtaTextureList
End If
‘get the materials
ReDim .udtaMaterialList(.udtHeader.lngMaterialCount – 1) As udtNOFMaterial
Get #intFileNumber, , .udtaMaterialList
‘get the key-frames
ReDim .udtaPointListKeyFrames(.udtHeader.lngPointListKeyFrameCount – 1) As udtNOFPointListKeyFrame
For lngPointListKeyFrame = 0 To .udtHeader.lngPointListKeyFrameCount – 1
‘get each key-frame in succession
‘we can’t get the whole thing at once due to the ordering of VB multi-dimension arrays
ReDim Preserve .udtaPointListKeyFrames(lngPointListKeyFrame).udtKeyFrameList(.udtHeader.lngPointCount – 1) As udtNOFKeyFramePoint
Get #intFileNumber, , .udtaPointListKeyFrames(lngPointListKeyFrame).bytName
Get #intFileNumber, , .udtaPointListKeyFrames(lngPointListKeyFrame).udtKeyFrameList
Next lngPointListKeyFrame
‘get the normals
ReDim .udtaNormalList(.udtHeader.lngNormalCount – 1) As udtNOFVector
Get #intFileNumber, , .udtaNormalList
‘get the UV coordinates
ReDim .udtaUVList(.udtHeader.lngUVCount – 1) As udtNOFUV
Get #intFileNumber, , .udtaUVList
‘get the triangles
ReDim .udtaTriangleList(.udtHeader.lngTriangleCount – 1) As udtNOFTriangle
Get #intFileNumber, , .udtaTriangleList
‘close the file
Close
End With
End Function