Did you know? Xentax started the Unepic SID Channel, that brings the latest music composed for the SID chip! Support us by listening and subscribing! Over 50.000 songs already there!

AION cgf to collada converter

Post questions about game models here, or help out others!
User avatar
Pesmontis
beginner
Posts: 33
Joined: Sun Jun 20, 2010 5:10 pm
Location: The Netherlands
Been thanked: 8 times
Contact:

Re: AION cgf to collada converter

Post by Pesmontis » Fri Jan 24, 2014 5:46 pm

In order to use CryImporter v1.2.1, you need to use a hex-editor to change the first six bytes in a model file from "NCAion" to "CryTek".

Apart from that, I don't know how to edit the CryImporter script(s) for proper materials import. chrrox might shed a light on that.

<Edit>
( also read: http://niftools.sourceforge.net/forum/v ... f=7&t=2383 ).

Jopsi332
ultra-n00b
Posts: 1
Joined: Thu Feb 13, 2014 5:37 pm
Has thanked: 1 time

Re: AION cgf to collada converter

Post by Jopsi332 » Thu Feb 13, 2014 10:59 pm

hi
i'm new to this blender stuff.
How to run this script?
When i try to install it as addon nothing appears

User avatar
Acewell
VIP member
VIP member
Posts: 1329
Joined: Wed Nov 05, 2008 12:16 pm
Has thanked: 2683 times
Been thanked: 841 times

Re: AION cgf to collada converter

Post by Acewell » Fri Feb 14, 2014 12:09 am

I've never used it, but the author suggests it is a stand-alone tool. According to the brief instructions, there are some modifications required in the aion2collada.py file (likely near the end starting at line 831) to adapt it to your file locations and names. It looks like aion2collada.py can be run from the command line to perform the desired operation once you have set your paths and names.

User avatar
Pesmontis
beginner
Posts: 33
Joined: Sun Jun 20, 2010 5:10 pm
Location: The Netherlands
Been thanked: 8 times
Contact:

Re: AION cgf to collada converter

Post by Pesmontis » Fri Feb 14, 2014 5:03 pm

You have to install Python first. I think only v2.5 or v2.6 (I installed Python v2.6.6).

Then running the script is very easy: start a command prompt, navigate to the location of the Aion2Collada.py file and simply type "Aion2Collada.py".

BUT (!): befor you run it, you must edit this script in a text editor.
Browse to the end of the script, and you will see a listing of directories and model files.
You need to change those directories, so that everything corresponds to your Aion set-up on your HDD.

Fiddle a bit with this to get the proper script set-up.
Whenever you get errors, read them closely to find out what (other) directories or files you need to configure / remove.

You might also have to put a '#' in front of the very last line where it says "ConvertMeshAnimation("..")".

I've tested this with a few Aion 4.0 models and it works OK.
For the rest you'd have to do a little trial & error yourself..

User avatar
CriticalError
double-veteran
double-veteran
Posts: 677
Joined: Sun Jul 05, 2009 2:03 am
Has thanked: 98 times
Been thanked: 37 times

Re: AION cgf to collada converter

Post by CriticalError » Wed Jun 25, 2014 6:21 am

many thanks for all, just got some problem with materials, maybe this can be fixed?

and some models give error like this.

Image
Image
-- Frame:
-- modelFilename: "C:\Users\GAMEMASTER\Desktop\Book\bo_drakanbook01.cgf"
-- reader: (ChunkReader chunkArchive:(CryChunkArchive meshChunks:#() helperChunks:#() vertAnimChunks:#() boneAnimChunks:#() boneNameListChunks:#() scenePropChunks:#() lightChunks:#() nodeChunks:#((CryNodeChunk header:(CryChunkHeader type:11 version:2083 fileOffset:212 chunkID:2) name:"BO_DrakanBook01" objectID:5 parentID:-1 materialID:3 isGroupHead:false isGroupMember:false TransMatrix:(CryMatrix44 row1:[1,0,0,0] row2:[0,1,0,0] row3:[0,0,1,0] row4:[0,0,0,1]) position:[0,0,0] rotation:(quat 0 0 0 1) scale:[1,1,1] posCtrlID:"ffffffff" rotCtrlID:"ffffffff" scaleCtrlID:"ffffffff" property:"" childNodes:#())) materialChunks:#() controllerChunks:#() timingChunks:#((CryTimingChunk header:(CryChunkHeader type:14 version:2328 fileOffset:144 chunkID:1) secsPerTick:0.000208333 ticksPerFrame:160 globalRange:(CryRange name:"GlobalRange" start:0 End:100) subRanges:#())) boneMeshChunks:#() boneLightBindingChunks:#() meshMorphTargetChunks:#() boneInitialPosChunks:#() sourceInfoChunks:#((CrySourceInfoChunk header:(CryChunkHeader type:19 version:0 fileOffset:20 chunkID:0) sourceFile:"D:\perforce\AION\AION_Data\OBJECTS\items\Max\NPC_Drop_item\BO_DrakanBook01.max" date:"11/28/2011 14:10" user:"Administrator@AIONBUILD")) numChunks:3 geomFileName:"C:\Users\GAMEMASTER\Desktop\Book\bo_drakanbook01.cgf" separatePhysicsMesh:false) log:log() bs:<BinStream:C:\Users\GAMEMASTER\Desktop\Book\bo_drakanbook01.cgf> fs:<File:C:\Users\GAMEMASTER\Desktop\Book\bo_drakanbook01.cgf>)
-- ret: undefined
-- called in btnCgfImport.pressed(); filename: C:\Program Files (x86)\Autodesk\3ds Max 2013\scripts\CryImporter\CryImporter.ms; position: 3598; line: 116
-- Frame:
>> MAXScript Rollout Handler Exception:
-- Unable to convert: undefined to type: Float <<
this is what I got whem import a bow, the model imported fine but ofc got error with materials, and about animation got error too.
Set the following shaders for the given materials:
-- Error occurred in x loop; filename: C:\Program Files (x86)\Autodesk\3ds Max 2013\scripts\CryImporter\CryImporter.ms; position: 8479; line: 301
-- Frame:
-- r: undefined
-- path: undefined
-- tempChunkArchive: undefined
-- ret: undefined
-- x: (CAFRecord name:"cdraw_bow_001" path:"Items\Bow_Cidle_Bow_001_loop.caf" startframe:undefined endframe:undefined)
-- called in calImport(); filename: C:\Program Files (x86)\Autodesk\3ds Max 2013\scripts\CryImporter\CryImporter.ms; position: 9268; line: 329
-- Frame:
-- reader: (CALReader STATE_STARTLINE:0 STATE_GETNAME:1 STATE_GETEQUALS:2 STATE_GETPATH:3 state:3 animList:#((CAFRecord name:"cdraw_bow_001" path:"Items\Bow_Cidle_Bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cdraw_bow_run_001" path:"Items\Bow_Cidle_Bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cidle_bow_001" path:"Items\Bow_Cidle_Bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cidle_bow_gasp_001" path:"Items\Bow_Cidle_Bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cjump_start_bow_001" path:"Items\Bow_Cidle_Bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cjump_air_bow_001" path:"Items\Bow_Cidle_Bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cjump_end_bow_001" path:"Items\Bow_Cidle_Bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"crun_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"crunL_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"crunR_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"crunB_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cattack_bow_001" path:"Items\bow_cattack_bow_001.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cattackL_bow_run_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cattackR_bow_run_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cattack_bow_run_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cattackB_bow_run_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cdamage_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cstumble_start_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cstumble_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cstumble_end_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), ...) currentCAF:(CAFRecord name:"Xfire_bow_powershot_001" path:"Items\Bow_Cfire_bow_powershot_001.caf" startframe:undefined endframe:undefined))
-- animFilename: "C:\Users\GAMEMASTER\Desktop\Bow\bw_drakanbow01.cal"
-- s: undefined
-- list: #((CAFRecord name:"cdraw_bow_001" path:"Items\Bow_Cidle_Bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cdraw_bow_run_001" path:"Items\Bow_Cidle_Bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cidle_bow_001" path:"Items\Bow_Cidle_Bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cidle_bow_gasp_001" path:"Items\Bow_Cidle_Bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cjump_start_bow_001" path:"Items\Bow_Cidle_Bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cjump_air_bow_001" path:"Items\Bow_Cidle_Bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cjump_end_bow_001" path:"Items\Bow_Cidle_Bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"crun_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"crunL_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"crunR_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"crunB_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cattack_bow_001" path:"Items\bow_cattack_bow_001.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cattackL_bow_run_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cattackR_bow_run_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cattack_bow_run_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cattackB_bow_run_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cdamage_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cstumble_start_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cstumble_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), (CAFRecord name:"cstumble_end_bow_001" path:"Items\bow_Cidle_bow_001_loop.caf" startframe:undefined endframe:undefined), ...)
-- ret: OK
-- called in btnCalImport.pressed(); filename: C:\Program Files (x86)\Autodesk\3ds Max 2013\scripts\CryImporter\CryImporter.ms; position: 3921; line: 137
-- Frame:
>> MAXScript Rollout Handler Exception:
-- Unable to convert: undefined to type: String <<

raykingnihong
mega-veteran
mega-veteran
Posts: 178
Joined: Sun Apr 06, 2014 8:06 pm
Has thanked: 215 times
Been thanked: 6 times

Re: AION cgf to collada converter

Post by raykingnihong » Sun Oct 19, 2014 8:31 pm

Szkaradek123 wrote:The contents of this post was deleted because of possible forum rules violation.
Hello my friend, thank you for your great work, your script has been deleted, can upload, thank you for your help

ivanches
ultra-n00b
Posts: 4
Joined: Sat Nov 08, 2014 2:54 am
Has thanked: 3 times

Re: AION cgf to collada converter

Post by ivanches » Sun Nov 09, 2014 6:26 am

Szkaradek123 wrote:The contents of this post was deleted because of possible forum rules violation.
Holy fuckin shit. :evil:

ivanches
ultra-n00b
Posts: 4
Joined: Sat Nov 08, 2014 2:54 am
Has thanked: 3 times

Re: AION cgf to collada converter

Post by ivanches » Sun Nov 09, 2014 10:06 am

Code: Select all

#2011-02-06 Mariusz Szkaradek Glogow Poland
import bpy,struct,os
import Blender,glob
from Blender import *
from struct import *
from Blender.Mathutils import *
from Blender import Armature as A
import math
import pyffi
from pyffi import *
from pyffi.formats.cgf import CgfFormat
from Blender.Draw import *
from Blender.BGL import *



def printchunk(data):
   opath = path[path.rfind('\\')+1:]+'.txt'
   ostream = open(opath, 'wb')
   for chunk in data.chunks:
        ostream.write(str(chunk))
        ostream.write('\n')
   ostream.close()


def check_armature():
    global armobj,arm
    armobj=None
    arm=None
    scn = Scene.GetCurrent()
    scene = bpy.data.scenes.active
    for object in scene.objects:
        if object.getType()=='Armature':
            if object.name == 'armature':
                scn.unlink(object)
    for object in bpy.data.objects:
        if object.name == 'armature':
            armobj = Blender.Object.Get('armature')
            arm = armobj.getData()
            arm.makeEditable()         
            for bone in arm.bones.values():
                del arm.bones[bone.name]
            arm.update()
    if armobj==None: 
        armobj = Blender.Object.New('Armature','armature')
    if arm==None: 
        arm = Armature.New('armature')
        armobj.link(arm)
    scn.link(armobj)
    arm.drawType = Armature.STICK
    armobj.drawMode = Blender.Object.DrawModes.XRAY
    arm.makeEditable()

def editbone(namenode,parent):
    parentlist[namenode]=parent
    eb = A.Editbone()   
    arm.bones[namenode] = eb
    bone = arm.bones[namenode]

def makeparents(bonename):
    bone = arm.bones[bonename]
    if parentlist[bonename]!=-1:
        parent = arm.bones[str(parentlist[bonename])]
        bone.parent = parent 

def read_cgf_data():
    global vertexy,faces,normalne,uvcoord,uvfaces,matface,mesh,obiekt,groups,bonenamelist
    global parentlist
    parentlist={}
    vertexy=[]
    faces=[]
    normalne=[]
    uvcoord=[]
    uvfaces=[]
    nummat=0 
    matface = [] 
    groups={}  
    bonenamelist = {}
    stream = open(filename, 'rb')
    data = CgfFormat.Data()
    data.read(stream)
    stream.close()
    mesh = bpy.data.meshes.new(namemodel)
    scene = bpy.data.scenes.active
    obiekt = scene.objects.new(mesh,namemodel) 
    for chunk in data.chunks: 
        #printchunk(data)
        #print chunk.__class__
        #=== GEOMETRY ===
        if chunk.__class__ == CgfFormat.MeshChunk:
            numvertices = chunk.numVertices
            numfaces = chunk.numFaces
            print 'numvertices=',numvertices
            print 'numfaces=',numfaces
            for vert in chunk.vertices:
                vertexy.append([vert.p.x,vert.p.y,vert.p.z])
                normalne.append([vert.n.x,vert.n.y,vert.n.z])   
            for uv in chunk.uvs:
                uvcoord.append([uv.u,uv.v]) 
            for f in chunk.faces:
                faces.append([f.v0,f.v1,f.v2])
                matface.append(f.material)
            for uv in chunk.uvFaces:
                uvfaces.append([uv.t0,uv.t1,uv.t2])
            nrvert = 0
            for vw in chunk.vertexWeights:
                for m in vw.boneLinks:
                    group = m.bone
                    weight = float(m.blending)
                    if weight!=0:
                        if str(group) not in groups:
                            groups[str(group)]=[]              
                            mesh.addVertGroup(str(group))
                        groups[str(group)].append([nrvert,weight]) 
                nrvert+=1 
        #===BONES === 
        #=== BONES relation===
        if chunk.__class__ == CgfFormat.BoneAnimChunk:
            check_armature()
            armobj.makeParentDeform([obiekt],1,0)
            numbones = chunk.numBones 
            #print 'numbones=',numbones   
            for bone in chunk.bones:
                boneid = bone.boneId
                parentid = bone.parentId 
                #print 'bone=',boneid,'parent=',parentid 
                editbone(str(boneid),parentid)  
            arm.update()
            arm.makeEditable()
            for i in range(numbones):
                makeparents(str(i)) 
            arm.update()         
        #=== BONES names===
        if chunk.__class__ == CgfFormat.BoneNameListChunk:
            print 'numbones=',chunk.numNames 
            boneid = 0
            for name in chunk.names:
                print 'bone=',name
                bonenamelist[str(boneid)]=name  
                boneid+=1             
        #=== BONES initial position===
        if chunk.__class__ == CgfFormat.BoneInitialPosChunk:
            #print 'numbones=',chunk.num_bones  
            arm.makeEditable()
            numbone = 0  
            for initial in chunk.initialPosMatrices:
                matrix = Matrix()
                mat = CgfFormat.Matrix44()
                mat.setIdentity
                mat.setMatrix33(initial.rot)
                mat.setTranslation(initial.pos)
                matrix =  mat.asList()
                matrix = Matrix(matrix[0],matrix[1],matrix[2],matrix[3])
                arm.bones[str(numbone)].matrix = matrix
                numbone+=1
            for bone in arm.bones.values():
                bone.name = bonenamelist[bone.name] 
            arm.update() 
        #=== MATERIAL === 
        if chunk.__class__ == CgfFormat.MtlChunk:
            try:
                mat = Material.Get('mat-'+str(nummat)+namemodel)
            except:
                mat = Material.New('mat-'+str(nummat)+namemodel)    
            try:
                mesh.materials+=[Material.Get('mat-'+str(nummat)+namemodel)]
            except:
                pass
            nummat+=1
            tex = Texture.New('diff')
            tex.setType('Image')
            imagepath = chunk.texD.longName
            imagepath = imagepath.split(os.sep)
            imagepath = imagepath[-1].split('.')[0]
            imagename = imagepath
            imageext = ['dds','png','tga']
            for ext in imageext:
                try:
                    img = Blender.Image.Load(tex_dir.val+os.sep+imagename+'.'+ext)
                    tex.image = img
                    print imagename,'===========found' 
                    break
                except:
                    print imagename,'========no found' 
            mat.setTexture(0,tex,Texture.TexCo.UV,Texture.MapTo.COL)


def makemesh(): 
    mesh.verts.extend(vertexy)
    mesh.faces.extend(faces,ignoreDups=True)
    for id in range(len(mesh.verts)):
        mesh.verts[id].no = Vector(normalne[id])
    for id in range(len(uvfaces)):
        face = mesh.faces[id]
        uv1 = Vector(uvcoord[uvfaces[id][0]])
        uv2 = Vector(uvcoord[uvfaces[id][1]])
        uv3 = Vector(uvcoord[uvfaces[id][2]])
        face.uv = [uv1, uv2, uv3]
        face.smooth=True
        try:
            face.mat = matface[id] 
        except:
            pass  
    mesh.recalcNormals(0)
    obiekt.makeDisplayList()
    mesh.update()
    for vgroup in groups:
         for dane in groups[vgroup]:
             mesh.assignVertsToGroup(vgroup,[dane[0]],dane[1],1)
    mesh.update()
    for name in bonenamelist:
        try:
            mesh.renameVertGroup(name,bonenamelist[name])
        except:
            pass
    mesh.update()
    Redraw()

def read_caf():
    global rotKeys
    global posKeys,matrixkeys
    rotKeys = {}
    posKeys = {}   
    matrixkeys = {}
    stream = open(filename, 'rb')
    data = CgfFormat.Data()
    data.read(stream)
    stream.close()
    for chunk in data.chunks: 
        #printchunk(data)
        #print chunk.__class__
        #=== ANIMATION ===
        if chunk.__class__ == CgfFormat.TimingChunk:
            secspertick = chunk.secsPerTick
            ticksperframe = chunk.ticksPerFrame
            #print secspertick,ticksperframe
        if chunk.__class__ == CgfFormat.BoneNameListChunk:
            bonelist = chunk.names
            #for i in range(chunk.numNames):
            #   print bonelist[i]
    idbone = 0 
    for chunk in data.chunks: 
        if chunk.__class__ == CgfFormat.ControllerChunk:
            name = bonelist[idbone]
            #name = str(idbone)
            rotKeys[name]=[]
            posKeys[name]=[]
            matrixkeys[name] = []
            for key in chunk.keys:
                time = key.time/160#*secspertick
                pos = key.relPos.asList()
                pos = (pos[0],pos[1],pos[2])
                rot = key.relQuat
                rot = Quaternion(rot.w,rot.x,rot.y,rot.z)
                rot = rot.toMatrix().invert() 
                #matrix = rot*pos
                matrix = Matrix()                  
                matrix[0][:3] = rot[0]
                matrix[1][:3] = rot[1]
                matrix[2][:3] = rot[2]
                matrix[3][:3] = pos
                rotKeys[name].append([time,rot])
                posKeys[name].append([time,pos])
                matrixkeys[name].append([time,matrix]) 
                #print time#pos,rot 
            idbone+=1


def check_armature_for_animation():  
    global armobj,newarm 
    scene = bpy.data.scenes.active
    for object in scene.objects:
        if object.getType()=='Armature':
            if object.name == 'armature':
                armobj = object
                newarm = armobj.getData()

def makeanimation():
    global pose,action
    pose=0
    action=0
    #print armOb.name
    nameaction = sys.basename(filename).split('.')[0]
    pose = armobj.getPose()
    action = Blender.Armature.NLA.NewAction(nameaction)
    action.setActive(armobj)
    for name, pbone in pose.bones.items():
        if name in matrixkeys:
            for id in range(len(matrixkeys[name])):
                matrix = matrixkeys[name][id][1]
                time   = int(matrixkeys[name][id][0])
                if pbone.parent:
                    pbone.poseMatrix =  matrix*pbone.parent.poseMatrix
                else:
                    pbone.poseMatrix = matrix
                pbone.insertKey(armobj,time,[Object.Pose.LOC,Object.Pose.ROT],True)
                pose.update()
    scn = Scene.GetCurrent()
    context = scn.getRenderingContext()
    context.eFrame = time
    Redraw()
    
 

def armatureobject():
    scene = bpy.data.scenes.active
    for obj in scene.objects:
        if obj.type == 'Armature':# and obj.name == 'Arm-'+nameob[:-4]:
            armobj = Object.Get(obj.name) 
    return armobj 

def makeparent():
    scene = bpy.data.scenes.active
    for obj in scene.objects:
        try:
          if obj.type == 'Mesh':
              if nameob[:-4] in obj.name:
                  armOb.makeParentDeform([obj],1,0)
        except:
          pass 
    scene = bpy.data.scenes.active 

def select_caf_dir(filename):
    global caf_dir
    caf_dir.val = sys.dirname(filename)

def select_cgf_dir(filename):
    global cgf_dir
    cgf_dir.val = sys.dirname(filename)


def select_tex_dir(filename):
  global tex_dir
  tex_dir.val=sys.dirname(filename)


def create_cgf_toggles():
    global cgf_toggles
    cgf_toggles = {}
    extends=['cgf']
    cgf_list_dir = os.listdir(cgf_dir.val)
    cgf_list_dir.sort()
    for file in cgf_list_dir:
        extend = file.split('.')[-1].lower()
        if extend in extends:
            cgf_toggles[file] = Create(0)


def create_caf_toggles():
    global caf_toggles
    caf_toggles = {}
    extends=['caf']
    caf_list_dir = os.listdir(caf_dir.val)
    caf_list_dir.sort()
    for file in caf_list_dir:
        extend = file.split('.')[-1].lower()
        if extend in extends:
            caf_toggles[file] = Create(0)


rollx = 0
skala_model = Create(1)
skala_bones = Create(1)
flip_uv_toggle = Create(0)
flip_yz_toggle = Create(0)
quick_toggle = Create(1)
caf_dir = Blender.Draw.Create("")
cgf_dir  = Blender.Draw.Create("")
tex_dir  = Blender.Draw.Create("")
tab = 0

def draw():
    global id_but,namemodel,dx,skala_model,skala_bones,flip_uv_toggle,flip_yz_toggle
    global size,rollx,quick_toggle,caf_dir,tab,cgf_dir,tex_dir

    size = Window.GetAreaSize()

    glClearColor(0.1, 0.1, 0.1, 0.0)
    glClear(GL_COLOR_BUFFER_BIT)
    id_but = 1
    dx = 10
    if tab == 2:        
        names=[]    
        for file in cgf_toggles:
            names.append(file)
        names.sort()
        for file in names:
            if rollx+dx<size[1]:
                cgf_toggles[file]  = Toggle(file, id_but ,15,dx+rollx, 300, 15,cgf_toggles[file].val, '')
                id_but+=1
                dx+=20
        glColor3f(0.6,0.6,0.6)
        glRasterPos2i(15,dx+rollx)
        Text('SELECT  CGF  FILES:')
    if tab == 1:        
        names=[]    
        for file in caf_toggles:
            names.append(file)
        names.sort()
        for file in names:
            if rollx+dx<size[1]:
                caf_toggles[file]  = Toggle(file, id_but ,15,dx+rollx, 300, 15,caf_toggles[file].val, '')
                id_but+=1
                dx+=20
        glColor3f(0.6,0.6,0.6)
        glClearColor(0.9, 0.9, 0.9, 0.0)
        glRasterPos2i(15,dx+rollx)
        Text('SELECT  CAF   FILES:')
    """
    skala_model = Slider('SCALE MODEL   ', id_but, 430, 10, 255, 25,skala_model.val, 0.1, 5, 0.1, '')
    id_but+=1
    skala_bones = Slider('SCALE BONES   ', id_but, 430, 40, 255, 25,skala_bones.val, 0, 3, 1, '')
    id_but+=1
    flip_uv_toggle = Toggle('FLIP U-V   ', id_but ,430,70, 255, 25,flip_uv_toggle.val, '')
    id_but+=1
    flip_yz_toggle = Toggle('FLIP Y-Z   ', id_but ,430,100, 255, 25,flip_yz_toggle.val, '')
    id_but+=1
    quick_toggle = Toggle('SHOW QUICK MODEL', id_but ,430,130, 255, 25,quick_toggle.val,\
                          'deselect if problem with material')
    id_but+=1
    """
    cgf_dir = Blender.Draw.String("CGF  DIR:",id_but,515,410,170,25,cgf_dir.val,255, "CGF  FILE")
    id_but+=1
    Button("SHOW  CGF  FILES",id_but,430,380,255,25,'')
    id_but+=1
    Button("BROWSE",id_but,430,410,80,25, "Specify cgf dir")
    id_but+=1

    glColor3f(0.6,0.6,0.6)
    glRasterPos2i(430,440)
    Text('SELECT  CGF  DIR:')

    caf_dir = Blender.Draw.String("CAF  DIR:",id_but,515,320,170,25,caf_dir.val,255, "CAF DIR")
    id_but+=1
    Button("SHOW  CAF  FILES",id_but,430,290,255,25,'')
    id_but+=1
    Button("BROWSE",id_but,430,320,80,25, "Specify caf dir")
    id_but+=1

    glRasterPos2i(430,350)
    Text('SELECT  CAF  DIR:')
    
    tex_dir = Blender.Draw.String("TEXTURE  DIR:",id_but,515,230,170,25,tex_dir.val,255, "TEXTURE DIR")
    id_but+=1
    Button("SHOW  TEXTURES",id_but,430,200,255,25,'')
    id_but+=1
    Button("BROWSE",id_but,430,230,80,25, "Specify texture dir")
    id_but+=1

    glRasterPos2i(430,260)
    Text('SELECT  TEXTURE  DIR:')
    
    Button('LOAD',id_but,320,10,50,dx+rollx,'') 
    id_but+=1
    Button('EXIT',id_but,375,10,50,dx+rollx,'') 
        

def event(evt,val):
    global rollx
    if (evt== QKEY and not val): Exit()
    if evt == WHEELDOWNMOUSE:
        if (rollx < 0):
            rollx += 100
            Draw()
    elif evt == WHEELUPMOUSE:
        if (rollx+dx > size[1]):
            rollx -= 100
            Draw()
def bevent(evt):
    global namemodel,skala,skalabones,flipuv,flipyz,quick,tab,anim,filename
    flipuv = flip_uv_toggle.val
    flipyz = flip_yz_toggle.val
    quick  = quick_toggle.val
    if evt == id_but-9:#show psk files
        if len(cgf_dir.val)>0: 
            create_cgf_toggles()
            tab = 2
            Draw()
    if evt == id_but-8:#browse psk
        Blender.Window.FileSelector(select_cgf_dir, "Select cgf dir...") 
        Draw()  
    if evt == id_but-6:#show animation
        if len(caf_dir.val)>0: 
            create_caf_toggles()
            tab = 1
            Draw()
    if evt == id_but-5:#browse psa
        Blender.Window.FileSelector(select_caf_dir, "Select animation file .psa...") 
        Draw()  
    if evt == id_but-4:#show textures
        pass
    if evt == id_but-2:#browse texture
        Blender.Window.FileSelector(select_tex_dir, "Select texture dir...") 
    if evt == id_but-1:#LOAD
        if tab == 2:
            for file in cgf_toggles:
                if cgf_toggles[file] == True:
                    skala = skala_model.val
                    skalabones = skala_bones.val
                    filename = cgf_dir.val+os.sep+file 
                    realnamemodel = sys.basename(filename).split('.')[0]
                    timenamemodel = str(sys.time())
                    if len(realnamemodel)>20:
                        namemodel=timenamemodel
                    else:
                        namemodel=realnamemodel
                    read_cgf_data()
                    makemesh()
                    Blender.Redraw()
        if tab == 1:   
            for file in caf_toggles:
                if caf_toggles[file] == True:
                    filename = caf_dir.val+os.sep+file 
                    check_armature_for_animation()
                    read_caf()
                    makeanimation()
    if evt == id_but:#EXIT    
        Blender.Draw.Exit()
    

Register(draw, event, bevent)
The code aion importer.py

raykingnihong
mega-veteran
mega-veteran
Posts: 178
Joined: Sun Apr 06, 2014 8:06 pm
Has thanked: 215 times
Been thanked: 6 times

Re: AION cgf to collada converter

Post by raykingnihong » Sun Nov 09, 2014 12:58 pm

ivanches wrote:

Code: Select all

#2011-02-06 Mariusz Szkaradek Glogow Poland
import bpy,struct,os
import Blender,glob
from Blender import *
from struct import *
from Blender.Mathutils import *
from Blender import Armature as A
import math
import pyffi
from pyffi import *
from pyffi.formats.cgf import CgfFormat
from Blender.Draw import *
from Blender.BGL import *



def printchunk(data):
   opath = path[path.rfind('\\')+1:]+'.txt'
   ostream = open(opath, 'wb')
   for chunk in data.chunks:
        ostream.write(str(chunk))
        ostream.write('\n')
   ostream.close()


def check_armature():
    global armobj,arm
    armobj=None
    arm=None
    scn = Scene.GetCurrent()
    scene = bpy.data.scenes.active
    for object in scene.objects:
        if object.getType()=='Armature':
            if object.name == 'armature':
                scn.unlink(object)
    for object in bpy.data.objects:
        if object.name == 'armature':
            armobj = Blender.Object.Get('armature')
            arm = armobj.getData()
            arm.makeEditable()         
            for bone in arm.bones.values():
                del arm.bones[bone.name]
            arm.update()
    if armobj==None: 
        armobj = Blender.Object.New('Armature','armature')
    if arm==None: 
        arm = Armature.New('armature')
        armobj.link(arm)
    scn.link(armobj)
    arm.drawType = Armature.STICK
    armobj.drawMode = Blender.Object.DrawModes.XRAY
    arm.makeEditable()

def editbone(namenode,parent):
    parentlist[namenode]=parent
    eb = A.Editbone()   
    arm.bones[namenode] = eb
    bone = arm.bones[namenode]

def makeparents(bonename):
    bone = arm.bones[bonename]
    if parentlist[bonename]!=-1:
        parent = arm.bones[str(parentlist[bonename])]
        bone.parent = parent 

def read_cgf_data():
    global vertexy,faces,normalne,uvcoord,uvfaces,matface,mesh,obiekt,groups,bonenamelist
    global parentlist
    parentlist={}
    vertexy=[]
    faces=[]
    normalne=[]
    uvcoord=[]
    uvfaces=[]
    nummat=0 
    matface = [] 
    groups={}  
    bonenamelist = {}
    stream = open(filename, 'rb')
    data = CgfFormat.Data()
    data.read(stream)
    stream.close()
    mesh = bpy.data.meshes.new(namemodel)
    scene = bpy.data.scenes.active
    obiekt = scene.objects.new(mesh,namemodel) 
    for chunk in data.chunks: 
        #printchunk(data)
        #print chunk.__class__
        #=== GEOMETRY ===
        if chunk.__class__ == CgfFormat.MeshChunk:
            numvertices = chunk.numVertices
            numfaces = chunk.numFaces
            print 'numvertices=',numvertices
            print 'numfaces=',numfaces
            for vert in chunk.vertices:
                vertexy.append([vert.p.x,vert.p.y,vert.p.z])
                normalne.append([vert.n.x,vert.n.y,vert.n.z])   
            for uv in chunk.uvs:
                uvcoord.append([uv.u,uv.v]) 
            for f in chunk.faces:
                faces.append([f.v0,f.v1,f.v2])
                matface.append(f.material)
            for uv in chunk.uvFaces:
                uvfaces.append([uv.t0,uv.t1,uv.t2])
            nrvert = 0
            for vw in chunk.vertexWeights:
                for m in vw.boneLinks:
                    group = m.bone
                    weight = float(m.blending)
                    if weight!=0:
                        if str(group) not in groups:
                            groups[str(group)]=[]              
                            mesh.addVertGroup(str(group))
                        groups[str(group)].append([nrvert,weight]) 
                nrvert+=1 
        #===BONES === 
        #=== BONES relation===
        if chunk.__class__ == CgfFormat.BoneAnimChunk:
            check_armature()
            armobj.makeParentDeform([obiekt],1,0)
            numbones = chunk.numBones 
            #print 'numbones=',numbones   
            for bone in chunk.bones:
                boneid = bone.boneId
                parentid = bone.parentId 
                #print 'bone=',boneid,'parent=',parentid 
                editbone(str(boneid),parentid)  
            arm.update()
            arm.makeEditable()
            for i in range(numbones):
                makeparents(str(i)) 
            arm.update()         
        #=== BONES names===
        if chunk.__class__ == CgfFormat.BoneNameListChunk:
            print 'numbones=',chunk.numNames 
            boneid = 0
            for name in chunk.names:
                print 'bone=',name
                bonenamelist[str(boneid)]=name  
                boneid+=1             
        #=== BONES initial position===
        if chunk.__class__ == CgfFormat.BoneInitialPosChunk:
            #print 'numbones=',chunk.num_bones  
            arm.makeEditable()
            numbone = 0  
            for initial in chunk.initialPosMatrices:
                matrix = Matrix()
                mat = CgfFormat.Matrix44()
                mat.setIdentity
                mat.setMatrix33(initial.rot)
                mat.setTranslation(initial.pos)
                matrix =  mat.asList()
                matrix = Matrix(matrix[0],matrix[1],matrix[2],matrix[3])
                arm.bones[str(numbone)].matrix = matrix
                numbone+=1
            for bone in arm.bones.values():
                bone.name = bonenamelist[bone.name] 
            arm.update() 
        #=== MATERIAL === 
        if chunk.__class__ == CgfFormat.MtlChunk:
            try:
                mat = Material.Get('mat-'+str(nummat)+namemodel)
            except:
                mat = Material.New('mat-'+str(nummat)+namemodel)    
            try:
                mesh.materials+=[Material.Get('mat-'+str(nummat)+namemodel)]
            except:
                pass
            nummat+=1
            tex = Texture.New('diff')
            tex.setType('Image')
            imagepath = chunk.texD.longName
            imagepath = imagepath.split(os.sep)
            imagepath = imagepath[-1].split('.')[0]
            imagename = imagepath
            imageext = ['dds','png','tga']
            for ext in imageext:
                try:
                    img = Blender.Image.Load(tex_dir.val+os.sep+imagename+'.'+ext)
                    tex.image = img
                    print imagename,'===========found' 
                    break
                except:
                    print imagename,'========no found' 
            mat.setTexture(0,tex,Texture.TexCo.UV,Texture.MapTo.COL)


def makemesh(): 
    mesh.verts.extend(vertexy)
    mesh.faces.extend(faces,ignoreDups=True)
    for id in range(len(mesh.verts)):
        mesh.verts[id].no = Vector(normalne[id])
    for id in range(len(uvfaces)):
        face = mesh.faces[id]
        uv1 = Vector(uvcoord[uvfaces[id][0]])
        uv2 = Vector(uvcoord[uvfaces[id][1]])
        uv3 = Vector(uvcoord[uvfaces[id][2]])
        face.uv = [uv1, uv2, uv3]
        face.smooth=True
        try:
            face.mat = matface[id] 
        except:
            pass  
    mesh.recalcNormals(0)
    obiekt.makeDisplayList()
    mesh.update()
    for vgroup in groups:
         for dane in groups[vgroup]:
             mesh.assignVertsToGroup(vgroup,[dane[0]],dane[1],1)
    mesh.update()
    for name in bonenamelist:
        try:
            mesh.renameVertGroup(name,bonenamelist[name])
        except:
            pass
    mesh.update()
    Redraw()

def read_caf():
    global rotKeys
    global posKeys,matrixkeys
    rotKeys = {}
    posKeys = {}   
    matrixkeys = {}
    stream = open(filename, 'rb')
    data = CgfFormat.Data()
    data.read(stream)
    stream.close()
    for chunk in data.chunks: 
        #printchunk(data)
        #print chunk.__class__
        #=== ANIMATION ===
        if chunk.__class__ == CgfFormat.TimingChunk:
            secspertick = chunk.secsPerTick
            ticksperframe = chunk.ticksPerFrame
            #print secspertick,ticksperframe
        if chunk.__class__ == CgfFormat.BoneNameListChunk:
            bonelist = chunk.names
            #for i in range(chunk.numNames):
            #   print bonelist[i]
    idbone = 0 
    for chunk in data.chunks: 
        if chunk.__class__ == CgfFormat.ControllerChunk:
            name = bonelist[idbone]
            #name = str(idbone)
            rotKeys[name]=[]
            posKeys[name]=[]
            matrixkeys[name] = []
            for key in chunk.keys:
                time = key.time/160#*secspertick
                pos = key.relPos.asList()
                pos = (pos[0],pos[1],pos[2])
                rot = key.relQuat
                rot = Quaternion(rot.w,rot.x,rot.y,rot.z)
                rot = rot.toMatrix().invert() 
                #matrix = rot*pos
                matrix = Matrix()                  
                matrix[0][:3] = rot[0]
                matrix[1][:3] = rot[1]
                matrix[2][:3] = rot[2]
                matrix[3][:3] = pos
                rotKeys[name].append([time,rot])
                posKeys[name].append([time,pos])
                matrixkeys[name].append([time,matrix]) 
                #print time#pos,rot 
            idbone+=1


def check_armature_for_animation():  
    global armobj,newarm 
    scene = bpy.data.scenes.active
    for object in scene.objects:
        if object.getType()=='Armature':
            if object.name == 'armature':
                armobj = object
                newarm = armobj.getData()

def makeanimation():
    global pose,action
    pose=0
    action=0
    #print armOb.name
    nameaction = sys.basename(filename).split('.')[0]
    pose = armobj.getPose()
    action = Blender.Armature.NLA.NewAction(nameaction)
    action.setActive(armobj)
    for name, pbone in pose.bones.items():
        if name in matrixkeys:
            for id in range(len(matrixkeys[name])):
                matrix = matrixkeys[name][id][1]
                time   = int(matrixkeys[name][id][0])
                if pbone.parent:
                    pbone.poseMatrix =  matrix*pbone.parent.poseMatrix
                else:
                    pbone.poseMatrix = matrix
                pbone.insertKey(armobj,time,[Object.Pose.LOC,Object.Pose.ROT],True)
                pose.update()
    scn = Scene.GetCurrent()
    context = scn.getRenderingContext()
    context.eFrame = time
    Redraw()
    
 

def armatureobject():
    scene = bpy.data.scenes.active
    for obj in scene.objects:
        if obj.type == 'Armature':# and obj.name == 'Arm-'+nameob[:-4]:
            armobj = Object.Get(obj.name) 
    return armobj 

def makeparent():
    scene = bpy.data.scenes.active
    for obj in scene.objects:
        try:
          if obj.type == 'Mesh':
              if nameob[:-4] in obj.name:
                  armOb.makeParentDeform([obj],1,0)
        except:
          pass 
    scene = bpy.data.scenes.active 

def select_caf_dir(filename):
    global caf_dir
    caf_dir.val = sys.dirname(filename)

def select_cgf_dir(filename):
    global cgf_dir
    cgf_dir.val = sys.dirname(filename)


def select_tex_dir(filename):
  global tex_dir
  tex_dir.val=sys.dirname(filename)


def create_cgf_toggles():
    global cgf_toggles
    cgf_toggles = {}
    extends=['cgf']
    cgf_list_dir = os.listdir(cgf_dir.val)
    cgf_list_dir.sort()
    for file in cgf_list_dir:
        extend = file.split('.')[-1].lower()
        if extend in extends:
            cgf_toggles[file] = Create(0)


def create_caf_toggles():
    global caf_toggles
    caf_toggles = {}
    extends=['caf']
    caf_list_dir = os.listdir(caf_dir.val)
    caf_list_dir.sort()
    for file in caf_list_dir:
        extend = file.split('.')[-1].lower()
        if extend in extends:
            caf_toggles[file] = Create(0)


rollx = 0
skala_model = Create(1)
skala_bones = Create(1)
flip_uv_toggle = Create(0)
flip_yz_toggle = Create(0)
quick_toggle = Create(1)
caf_dir = Blender.Draw.Create("")
cgf_dir  = Blender.Draw.Create("")
tex_dir  = Blender.Draw.Create("")
tab = 0

def draw():
    global id_but,namemodel,dx,skala_model,skala_bones,flip_uv_toggle,flip_yz_toggle
    global size,rollx,quick_toggle,caf_dir,tab,cgf_dir,tex_dir

    size = Window.GetAreaSize()

    glClearColor(0.1, 0.1, 0.1, 0.0)
    glClear(GL_COLOR_BUFFER_BIT)
    id_but = 1
    dx = 10
    if tab == 2:        
        names=[]    
        for file in cgf_toggles:
            names.append(file)
        names.sort()
        for file in names:
            if rollx+dx<size[1]:
                cgf_toggles[file]  = Toggle(file, id_but ,15,dx+rollx, 300, 15,cgf_toggles[file].val, '')
                id_but+=1
                dx+=20
        glColor3f(0.6,0.6,0.6)
        glRasterPos2i(15,dx+rollx)
        Text('SELECT  CGF  FILES:')
    if tab == 1:        
        names=[]    
        for file in caf_toggles:
            names.append(file)
        names.sort()
        for file in names:
            if rollx+dx<size[1]:
                caf_toggles[file]  = Toggle(file, id_but ,15,dx+rollx, 300, 15,caf_toggles[file].val, '')
                id_but+=1
                dx+=20
        glColor3f(0.6,0.6,0.6)
        glClearColor(0.9, 0.9, 0.9, 0.0)
        glRasterPos2i(15,dx+rollx)
        Text('SELECT  CAF   FILES:')
    """
    skala_model = Slider('SCALE MODEL   ', id_but, 430, 10, 255, 25,skala_model.val, 0.1, 5, 0.1, '')
    id_but+=1
    skala_bones = Slider('SCALE BONES   ', id_but, 430, 40, 255, 25,skala_bones.val, 0, 3, 1, '')
    id_but+=1
    flip_uv_toggle = Toggle('FLIP U-V   ', id_but ,430,70, 255, 25,flip_uv_toggle.val, '')
    id_but+=1
    flip_yz_toggle = Toggle('FLIP Y-Z   ', id_but ,430,100, 255, 25,flip_yz_toggle.val, '')
    id_but+=1
    quick_toggle = Toggle('SHOW QUICK MODEL', id_but ,430,130, 255, 25,quick_toggle.val,\
                          'deselect if problem with material')
    id_but+=1
    """
    cgf_dir = Blender.Draw.String("CGF  DIR:",id_but,515,410,170,25,cgf_dir.val,255, "CGF  FILE")
    id_but+=1
    Button("SHOW  CGF  FILES",id_but,430,380,255,25,'')
    id_but+=1
    Button("BROWSE",id_but,430,410,80,25, "Specify cgf dir")
    id_but+=1

    glColor3f(0.6,0.6,0.6)
    glRasterPos2i(430,440)
    Text('SELECT  CGF  DIR:')

    caf_dir = Blender.Draw.String("CAF  DIR:",id_but,515,320,170,25,caf_dir.val,255, "CAF DIR")
    id_but+=1
    Button("SHOW  CAF  FILES",id_but,430,290,255,25,'')
    id_but+=1
    Button("BROWSE",id_but,430,320,80,25, "Specify caf dir")
    id_but+=1

    glRasterPos2i(430,350)
    Text('SELECT  CAF  DIR:')
    
    tex_dir = Blender.Draw.String("TEXTURE  DIR:",id_but,515,230,170,25,tex_dir.val,255, "TEXTURE DIR")
    id_but+=1
    Button("SHOW  TEXTURES",id_but,430,200,255,25,'')
    id_but+=1
    Button("BROWSE",id_but,430,230,80,25, "Specify texture dir")
    id_but+=1

    glRasterPos2i(430,260)
    Text('SELECT  TEXTURE  DIR:')
    
    Button('LOAD',id_but,320,10,50,dx+rollx,'') 
    id_but+=1
    Button('EXIT',id_but,375,10,50,dx+rollx,'') 
        

def event(evt,val):
    global rollx
    if (evt== QKEY and not val): Exit()
    if evt == WHEELDOWNMOUSE:
        if (rollx < 0):
            rollx += 100
            Draw()
    elif evt == WHEELUPMOUSE:
        if (rollx+dx > size[1]):
            rollx -= 100
            Draw()
def bevent(evt):
    global namemodel,skala,skalabones,flipuv,flipyz,quick,tab,anim,filename
    flipuv = flip_uv_toggle.val
    flipyz = flip_yz_toggle.val
    quick  = quick_toggle.val
    if evt == id_but-9:#show psk files
        if len(cgf_dir.val)>0: 
            create_cgf_toggles()
            tab = 2
            Draw()
    if evt == id_but-8:#browse psk
        Blender.Window.FileSelector(select_cgf_dir, "Select cgf dir...") 
        Draw()  
    if evt == id_but-6:#show animation
        if len(caf_dir.val)>0: 
            create_caf_toggles()
            tab = 1
            Draw()
    if evt == id_but-5:#browse psa
        Blender.Window.FileSelector(select_caf_dir, "Select animation file .psa...") 
        Draw()  
    if evt == id_but-4:#show textures
        pass
    if evt == id_but-2:#browse texture
        Blender.Window.FileSelector(select_tex_dir, "Select texture dir...") 
    if evt == id_but-1:#LOAD
        if tab == 2:
            for file in cgf_toggles:
                if cgf_toggles[file] == True:
                    skala = skala_model.val
                    skalabones = skala_bones.val
                    filename = cgf_dir.val+os.sep+file 
                    realnamemodel = sys.basename(filename).split('.')[0]
                    timenamemodel = str(sys.time())
                    if len(realnamemodel)>20:
                        namemodel=timenamemodel
                    else:
                        namemodel=realnamemodel
                    read_cgf_data()
                    makemesh()
                    Blender.Redraw()
        if tab == 1:   
            for file in caf_toggles:
                if caf_toggles[file] == True:
                    filename = caf_dir.val+os.sep+file 
                    check_armature_for_animation()
                    read_caf()
                    makeanimation()
    if evt == id_but:#EXIT    
        Blender.Draw.Exit()
    

Register(draw, event, bevent)
The code aion importer.py
My friend, thank you very much for your help

ivanches
ultra-n00b
Posts: 4
Joined: Sat Nov 08, 2014 2:54 am
Has thanked: 3 times

Re: AION cgf to collada converter

Post by ivanches » Mon Nov 10, 2014 9:25 am

CriticalError wrote:many thanks for all, just got some problem with materials, maybe this can be fixed?

and some models give error like this.
Use the script of the title theme! After converting uncover everything in a blender 2.72.
I have all the fine imported without error. Some textures have to manually install.
Not complex manipulations but routine.

In a blender 2.72 standard import collada .dae correctly translates everything. In older versions do not correctly!
Last edited by ivanches on Mon Nov 10, 2014 9:37 am, edited 1 time in total.

ivanches
ultra-n00b
Posts: 4
Joined: Sat Nov 08, 2014 2:54 am
Has thanked: 3 times

Re: AION cgf to collada converter

Post by ivanches » Mon Nov 10, 2014 9:33 am

raykingnihong wrote: My friend, thank you very much for your help
Unable to open the animation does - does not load, gives an error with this script. You have this script animation work?

I use script of the title theme, and then open in blender 2.72
Animations converts without problems!

raykingnihong
mega-veteran
mega-veteran
Posts: 178
Joined: Sun Apr 06, 2014 8:06 pm
Has thanked: 215 times
Been thanked: 6 times

Re: AION cgf to collada converter

Post by raykingnihong » Tue Dec 09, 2014 8:18 pm

Szkaradek123 wrote:The contents of this post was deleted because of possible forum rules violation.



Update: 2014-12-08
Aion Blender importer.
It requires Blender version 249 and Python 26

Steps:
1.unpack importer
2.run Blender249.blend
3.in Blender Text Window press alt+p and select cgf file for meshes and skeleton
3.for animation press alt+p and select caf file
Hello my friend, thank you always for your great contribution, I think most of friends want to try, this script runs perfectly, you can import actions, models, textures. Very good, thanks again,Szkaradek123

Keezie
advanced
Posts: 45
Joined: Tue Jun 04, 2013 1:12 am
Has thanked: 7 times
Been thanked: 3 times

Re: AION cgf to collada converter

Post by Keezie » Fri Jan 09, 2015 6:54 am

Everything is working here!
Last edited by Keezie on Sat Jan 10, 2015 3:15 am, edited 1 time in total.

User avatar
Acewell
VIP member
VIP member
Posts: 1329
Joined: Wed Nov 05, 2008 12:16 pm
Has thanked: 2683 times
Been thanked: 841 times

Re: AION cgf to collada converter

Post by Acewell » Fri Jan 09, 2015 7:01 pm

The Blender script was written for version 2.49. You can run multiple versions of Blender side by side. Get 2.49 for the sake of using the script then export to whatever version of Blender you use.

ZaTii
ultra-n00b
Posts: 1
Joined: Sat Aug 09, 2014 10:43 pm

Re: AION cgf to collada converter

Post by ZaTii » Sat Jan 31, 2015 12:04 am

Hey Guys

That Python script with the Blender standalone is great!

I can import the Model and Skeleton without a problem. But when i wanna import a animation the Bones change and the animation looks destroyed. Is there something that i must look on?

Post Reply