The VG Resource

Full Version: King.com Mobile (.ffm Files)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need .ffm model files from King.com Moblie Games.
List of .ffm model files Games

-Pet Rescue Saga
-Candy Crush Saga
-Farm Heroes Saga
-Candy Crush Soda Saga

You need script from 3DS Max?
Code:
-- 3ds max maxscript
-- King.com .ffm importer
-- Imports positions, normals, uvs, bones, rigging, texture mapping
-- Texture will be loaded automatically if you put the corresponding .png file in the same folder as the .ffm file
-- Made by TGE, contact me in case there's any issues ;p

gc()
clearlistener()

global gImportedFilePath = ""

fn ReadUShort fstream =
(
    return (ReadShort fstream #unsigned)
)

fn ReadULong fstream =
(
    return (ReadLong fstream #unsigned)
)

fn ReadUByte fstream =
(
    return (ReadByte fstream #unsigned)
)

fn ReadVector2 fstream =
(
    return [(ReadFloat fstream), ((ReadFloat fstream) * -1) + 1, 0]
)

fn ReadVector3 fstream =
(
    return [(ReadFloat fstream), (ReadFloat fstream), (ReadFloat fstream)]
)

fn ReadVector4 fstream =
(
    return [(ReadFloat fstream), (ReadFloat fstream), (ReadFloat fstream), (ReadFloat fstream)]
)

fn ReadMatrix44 fstream =
(
    return matrix3 (ReadVector4 fstream) (ReadVector4 fstream) (ReadVector4 fstream) (ReadVector4 fstream)
)

fn ReadFString fstream len =
(
    local s = ""
    for i = 1 to len do
    (
        s += bit.intaschar (ReadByte fstream #unsigned)
    )
    return s
)

fn ReadPrefixString fstream =
(
    local len = ReadLong fstream #unsigned
    return (ReadFString fstream len)
)

fn GetOpenFile =
(
    clearlistener()
    local fname = getOpenFileName \
    caption:"Open Model" \
    types:"FFM Model (*.ffm)|*.ffm" \
    historyCategory:"ffm Object Presets"
    if (fname == undefined) then
    (
        return undefined
    )
    else
    (
        gImportedFilePath = fname
        local f = fopen fname "rb"
        return f
    )
)

faceArray = #()
positionArray = #()
normalArray = #()
texCoordArray = #()
boneWeightsArray = #()
boneIdsArray = #()
boneArray = #()

file = GetOpenFile()

if (file != undefined) then
(
    fseek file 0x04 #seek_cur
    texName = ReadPrefixString file
    
    sceneTfm = ReadMatrix44 file
    sceneTfm2 = ReadMatrix44 file
    indexCount = ReadULong file
    
    for i = 1 to indexCount by 3 do
    (
        append faceArray [(ReadUShort file) + 1, (ReadUShort file) + 1, (ReadUShort file) + 1]
    )
    
    vertexCount = ReadULong file
    
    for i = 1 to vertexCount do
    (
        positionArray[i] = (ReadVector3 file) * sceneTfm
    )
    
    sceneTfmNrm = sceneTfm
    sceneTfmNrm.row4 = [0,0,0,1]
    
    for i = 1 to vertexCount do
    (
        normalArray[i] = (ReadVector3 file)  * sceneTfmNrm
    )
    
    for i = 1 to vertexCount do
    (
        texCoordArray[i] = ReadVector2 file
    )
    
    for i = 1 to vertexCount do
    (
        boneWeightsArray[i] = ReadVector3 file
    )

    for i = 1 to vertexCount do
    (
        boneIdsArray[i] = [(ReadULong file) + 1, (ReadULong file) + 1, (ReadULong file) + 1]
    )
    
    boneCount = ReadULong file
    
    for i = 1 to boneCount do
    (
        flag = ReadULong file
        hash = ReadULong file
        parentID = ReadULong file
        tfm = ReadMatrix44 file
        tfm2 = ReadMatrix44 file
        
        if (parentID != -1) then
        (
            tfm *= boneArray[(parentID+1)].objecttransform
        )

        tfm *= sceneTfm        

        newBone = bonesys.createbone    \
              tfm.row4    \
              (tfm.row4 + 0.01 * (normalize tfm.row1)) \
              (normalize tfm.row3)
        newBone.name = ("Bone"+ i as string)
        --newBone.name = (bit.intashex(hash))
        newBone.width  = 0.01
        newBone.height = 0.01
        newBone.transform = tfm
        newBone.setBoneEnable false 0
        newBone.wirecolor = yellow
        newbone.showlinks = true
        newBone.pos.controller      = TCB_position ()
        newBone.rotation.controller = TCB_rotation ()
                                              
        if (parentID != -1) then
        (
            newBone.parent = boneArray[(parentID+1)]
        )
        
        Append boneArray newBone
    )

    -- Build mesh
    msh = mesh vertices:positionArray faces:faceArray
    msh.numTVerts = positionArray.count
    buildTVFaces msh
    for j = 1 to texCoordArray.count do setTVert msh j texCoordArray[j]
    for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
    for j = 1 to msh.numfaces do setFaceSmoothGroup msh j 1
        
    
    -- Apply material
    msh.material = Standard()
    msh.material.diffuseMap = Bitmaptexture filename:((GetFileNamePath gImportedFilePath) + texName)
        
    
    -- Apply normals
    max modify mode
    select msh
    addmodifier msh (Edit_Normals ()) ui:off
    msh.Edit_Normals.MakeExplicit selection:#{1..normalArray.count}
    EN_convertVS = msh.Edit_Normals.ConvertVertexSelection
    EN_setNormal = msh.Edit_Normals.SetNormal
    normID = #{}

    for v = 1 to normalArray.count do(
        free normID
        EN_convertVS #{v} &normID
        for id in normID do EN_setNormal id normalArray[v]
    )
    maxOps.CollapseNodeTo msh 1 true -- Collapse the Edit Normals modifier
    
    -- Apply weights
    max modify mode
    select msh
    skinMod = skin ()
    addModifier msh skinMod
    for i = 1 to boneArray.count do
    (
        maxbone = boneArray[i]
        if i != boneArray.count then
            skinOps.addBone skinMod maxbone 0
        else
            skinOps.addBone skinMod maxbone 1
    )
    modPanel.setCurrentObject skinMod
    
    for i = 1 to positionArray.Count do
    (
       bi = #() --bone index array
       wv = #() --weight value array
      
       for j = 1 to 3 do
       (
            boneid = boneIdsArray[i][j]
            weight = boneWeightsArray[i][j]
            append bi boneid
            append wv weight
       )  
       skinOps.ReplaceVertexWeights skinMod i bi wv
    )
)
gc()
(12-27-2015, 10:30 AM)TGE Wrote: [ -> ]
Code:
-- 3ds max maxscript
-- King.com .ffm importer
-- Imports positions, normals, uvs, bones, rigging, texture mapping
-- Texture will be loaded automatically if you put the corresponding .png file in the same folder as the .ffm file
-- Made by TGE, contact me in case there's any issues ;p

gc()
clearlistener()

global gImportedFilePath = ""

fn ReadUShort fstream =
(
    return (ReadShort fstream #unsigned)
)

fn ReadULong fstream =
(
    return (ReadLong fstream #unsigned)
)

fn ReadUByte fstream =
(
    return (ReadByte fstream #unsigned)
)

fn ReadVector2 fstream =
(
    return [(ReadFloat fstream), ((ReadFloat fstream) * -1) + 1, 0]
)

fn ReadVector3 fstream =
(
    return [(ReadFloat fstream), (ReadFloat fstream), (ReadFloat fstream)]
)

fn ReadVector4 fstream =
(
    return [(ReadFloat fstream), (ReadFloat fstream), (ReadFloat fstream), (ReadFloat fstream)]
)

fn ReadMatrix44 fstream =
(
    return matrix3 (ReadVector4 fstream) (ReadVector4 fstream) (ReadVector4 fstream) (ReadVector4 fstream)
)

fn ReadFString fstream len =
(
    local s = ""
    for i = 1 to len do
    (
        s += bit.intaschar (ReadByte fstream #unsigned)
    )
    return s
)

fn ReadPrefixString fstream =
(
    local len = ReadLong fstream #unsigned
    return (ReadFString fstream len)
)

fn GetOpenFile =
(
    clearlistener()
    local fname = getOpenFileName \
    caption:"Open Model" \
    types:"FFM Model (*.ffm)|*.ffm" \
    historyCategory:"ffm Object Presets"
    if (fname == undefined) then
    (
        return undefined
    )
    else
    (
        gImportedFilePath = fname
        local f = fopen fname "rb"
        return f
    )
)

faceArray = #()
positionArray = #()
normalArray = #()
texCoordArray = #()
boneWeightsArray = #()
boneIdsArray = #()
boneArray = #()

file = GetOpenFile()

if (file != undefined) then
(
    fseek file 0x04 #seek_cur
    texName = ReadPrefixString file
    
    sceneTfm = ReadMatrix44 file
    sceneTfm2 = ReadMatrix44 file
    indexCount = ReadULong file
    
    for i = 1 to indexCount by 3 do
    (
        append faceArray [(ReadUShort file) + 1, (ReadUShort file) + 1, (ReadUShort file) + 1]
    )
    
    vertexCount = ReadULong file
    
    for i = 1 to vertexCount do
    (
        positionArray[i] = (ReadVector3 file) * sceneTfm
    )
    
    sceneTfmNrm = sceneTfm
    sceneTfmNrm.row4 = [0,0,0,1]
    
    for i = 1 to vertexCount do
    (
        normalArray[i] = (ReadVector3 file)  * sceneTfmNrm
    )
    
    for i = 1 to vertexCount do
    (
        texCoordArray[i] = ReadVector2 file
    )
    
    for i = 1 to vertexCount do
    (
        boneWeightsArray[i] = ReadVector3 file
    )

    for i = 1 to vertexCount do
    (
        boneIdsArray[i] = [(ReadULong file) + 1, (ReadULong file) + 1, (ReadULong file) + 1]
    )
    
    boneCount = ReadULong file
    
    for i = 1 to boneCount do
    (
        flag = ReadULong file
        hash = ReadULong file
        parentID = ReadULong file
        tfm = ReadMatrix44 file
        tfm2 = ReadMatrix44 file
        
        if (parentID != -1) then
        (
            tfm *= boneArray[(parentID+1)].objecttransform
        )

        tfm *= sceneTfm        

        newBone = bonesys.createbone    \
              tfm.row4    \
              (tfm.row4 + 0.01 * (normalize tfm.row1)) \
              (normalize tfm.row3)
        newBone.name = ("Bone"+ i as string)
        --newBone.name = (bit.intashex(hash))
        newBone.width  = 0.01
        newBone.height = 0.01
        newBone.transform = tfm
        newBone.setBoneEnable false 0
        newBone.wirecolor = yellow
        newbone.showlinks = true
        newBone.pos.controller      = TCB_position ()
        newBone.rotation.controller = TCB_rotation ()
                                              
        if (parentID != -1) then
        (
            newBone.parent = boneArray[(parentID+1)]
        )
        
        Append boneArray newBone
    )

    -- Build mesh
    msh = mesh vertices:positionArray faces:faceArray
    msh.numTVerts = positionArray.count
    buildTVFaces msh
    for j = 1 to texCoordArray.count do setTVert msh j texCoordArray[j]
    for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
    for j = 1 to msh.numfaces do setFaceSmoothGroup msh j 1
        
    
    -- Apply material
    msh.material = Standard()
    msh.material.diffuseMap = Bitmaptexture filename:((GetFileNamePath gImportedFilePath) + texName)
        
    
    -- Apply normals
    max modify mode
    select msh
    addmodifier msh (Edit_Normals ()) ui:off
    msh.Edit_Normals.MakeExplicit selection:#{1..normalArray.count}
    EN_convertVS = msh.Edit_Normals.ConvertVertexSelection
    EN_setNormal = msh.Edit_Normals.SetNormal
    normID = #{}

    for v = 1 to normalArray.count do(
        free normID
        EN_convertVS #{v} &normID
        for id in normID do EN_setNormal id normalArray[v]
    )
    maxOps.CollapseNodeTo msh 1 true -- Collapse the Edit Normals modifier
    
    -- Apply weights
    max modify mode
    select msh
    skinMod = skin ()
    addModifier msh skinMod
    for i = 1 to boneArray.count do
    (
        maxbone = boneArray[i]
        if i != boneArray.count then
            skinOps.addBone skinMod maxbone 0
        else
            skinOps.addBone skinMod maxbone 1
    )
    modPanel.setCurrentObject skinMod
    
    for i = 1 to positionArray.Count do
    (
       bi = #() --bone index array
       wv = #() --weight value array
      
       for j = 1 to 3 do
       (
            boneid = boneIdsArray[i][j]
            weight = boneWeightsArray[i][j]
            append bi boneid
            append wv weight
       )  
       skinOps.ReplaceVertexWeights skinMod i bi wv
    )
)
gc()

I *clap* don't *clap* like *clap* 3DS *clap* Max *clap* and *clap* there *clap* is *clap* no *clap* download *clap* for *clap* the *clap* script. *clap*
(12-28-2018, 09:59 PM)ItsMeGamerAndBFDIer7 Wrote: [ -> ]
(12-27-2015, 10:30 AM)TGE Wrote: [ -> ]
Code:
-- 3ds max maxscript
-- King.com .ffm importer
-- Imports positions, normals, uvs, bones, rigging, texture mapping
-- Texture will be loaded automatically if you put the corresponding .png file in the same folder as the .ffm file
-- Made by TGE, contact me in case there's any issues ;p

gc()
clearlistener()

global gImportedFilePath = ""

fn ReadUShort fstream =
(
    return (ReadShort fstream #unsigned)
)

fn ReadULong fstream =
(
    return (ReadLong fstream #unsigned)
)

fn ReadUByte fstream =
(
    return (ReadByte fstream #unsigned)
)

fn ReadVector2 fstream =
(
    return [(ReadFloat fstream), ((ReadFloat fstream) * -1) + 1, 0]
)

fn ReadVector3 fstream =
(
    return [(ReadFloat fstream), (ReadFloat fstream), (ReadFloat fstream)]
)

fn ReadVector4 fstream =
(
    return [(ReadFloat fstream), (ReadFloat fstream), (ReadFloat fstream), (ReadFloat fstream)]
)

fn ReadMatrix44 fstream =
(
    return matrix3 (ReadVector4 fstream) (ReadVector4 fstream) (ReadVector4 fstream) (ReadVector4 fstream)
)

fn ReadFString fstream len =
(
    local s = ""
    for i = 1 to len do
    (
        s += bit.intaschar (ReadByte fstream #unsigned)
    )
    return s
)

fn ReadPrefixString fstream =
(
    local len = ReadLong fstream #unsigned
    return (ReadFString fstream len)
)

fn GetOpenFile =
(
    clearlistener()
    local fname = getOpenFileName \
    caption:"Open Model" \
    types:"FFM Model (*.ffm)|*.ffm" \
    historyCategory:"ffm Object Presets"
    if (fname == undefined) then
    (
        return undefined
    )
    else
    (
        gImportedFilePath = fname
        local f = fopen fname "rb"
        return f
    )
)

faceArray = #()
positionArray = #()
normalArray = #()
texCoordArray = #()
boneWeightsArray = #()
boneIdsArray = #()
boneArray = #()

file = GetOpenFile()

if (file != undefined) then
(
    fseek file 0x04 #seek_cur
    texName = ReadPrefixString file
    
    sceneTfm = ReadMatrix44 file
    sceneTfm2 = ReadMatrix44 file
    indexCount = ReadULong file
    
    for i = 1 to indexCount by 3 do
    (
        append faceArray [(ReadUShort file) + 1, (ReadUShort file) + 1, (ReadUShort file) + 1]
    )
    
    vertexCount = ReadULong file
    
    for i = 1 to vertexCount do
    (
        positionArray[i] = (ReadVector3 file) * sceneTfm
    )
    
    sceneTfmNrm = sceneTfm
    sceneTfmNrm.row4 = [0,0,0,1]
    
    for i = 1 to vertexCount do
    (
        normalArray[i] = (ReadVector3 file)  * sceneTfmNrm
    )
    
    for i = 1 to vertexCount do
    (
        texCoordArray[i] = ReadVector2 file
    )
    
    for i = 1 to vertexCount do
    (
        boneWeightsArray[i] = ReadVector3 file
    )

    for i = 1 to vertexCount do
    (
        boneIdsArray[i] = [(ReadULong file) + 1, (ReadULong file) + 1, (ReadULong file) + 1]
    )
    
    boneCount = ReadULong file
    
    for i = 1 to boneCount do
    (
        flag = ReadULong file
        hash = ReadULong file
        parentID = ReadULong file
        tfm = ReadMatrix44 file
        tfm2 = ReadMatrix44 file
        
        if (parentID != -1) then
        (
            tfm *= boneArray[(parentID+1)].objecttransform
        )

        tfm *= sceneTfm        

        newBone = bonesys.createbone    \
              tfm.row4    \
              (tfm.row4 + 0.01 * (normalize tfm.row1)) \
              (normalize tfm.row3)
        newBone.name = ("Bone"+ i as string)
        --newBone.name = (bit.intashex(hash))
        newBone.width  = 0.01
        newBone.height = 0.01
        newBone.transform = tfm
        newBone.setBoneEnable false 0
        newBone.wirecolor = yellow
        newbone.showlinks = true
        newBone.pos.controller      = TCB_position ()
        newBone.rotation.controller = TCB_rotation ()
                                              
        if (parentID != -1) then
        (
            newBone.parent = boneArray[(parentID+1)]
        )
        
        Append boneArray newBone
    )

    -- Build mesh
    msh = mesh vertices:positionArray faces:faceArray
    msh.numTVerts = positionArray.count
    buildTVFaces msh
    for j = 1 to texCoordArray.count do setTVert msh j texCoordArray[j]
    for j = 1 to faceArray.count do setTVFace msh j faceArray[j]
    for j = 1 to msh.numfaces do setFaceSmoothGroup msh j 1
        
    
    -- Apply material
    msh.material = Standard()
    msh.material.diffuseMap = Bitmaptexture filename:((GetFileNamePath gImportedFilePath) + texName)
        
    
    -- Apply normals
    max modify mode
    select msh
    addmodifier msh (Edit_Normals ()) ui:off
    msh.Edit_Normals.MakeExplicit selection:#{1..normalArray.count}
    EN_convertVS = msh.Edit_Normals.ConvertVertexSelection
    EN_setNormal = msh.Edit_Normals.SetNormal
    normID = #{}

    for v = 1 to normalArray.count do(
        free normID
        EN_convertVS #{v} &normID
        for id in normID do EN_setNormal id normalArray[v]
    )
    maxOps.CollapseNodeTo msh 1 true -- Collapse the Edit Normals modifier
    
    -- Apply weights
    max modify mode
    select msh
    skinMod = skin ()
    addModifier msh skinMod
    for i = 1 to boneArray.count do
    (
        maxbone = boneArray[i]
        if i != boneArray.count then
            skinOps.addBone skinMod maxbone 0
        else
            skinOps.addBone skinMod maxbone 1
    )
    modPanel.setCurrentObject skinMod
    
    for i = 1 to positionArray.Count do
    (
       bi = #() --bone index array
       wv = #() --weight value array
      
       for j = 1 to 3 do
       (
            boneid = boneIdsArray[i][j]
            weight = boneWeightsArray[i][j]
            append bi boneid
            append wv weight
       )  
       skinOps.ReplaceVertexWeights skinMod i bi wv
    )
)
gc()

I *clap* don't *clap* like *clap* 3DS *clap* Max *clap* and *clap* there *clap* is *clap* no *clap* download *clap* for *clap* the *clap* script. *clap*

Or I will probably have to write a Blender script for importing the .ffm models.
Please do it I dont Have 3ds And i dont Want to waste My Computer storage.