Important information: this site is currently scheduled to go offline indefinitely by end of the year.

Granny .GR2 Reader plugin for Noesis

Post questions about game models here, or help out others!
jayn23
mega-veteran
mega-veteran
Posts: 250
Joined: Sun Jul 17, 2011 9:30 pm
Has thanked: 61 times
Been thanked: 241 times

Re: Granny .GR2 Reader plugin for Noesis

Post by jayn23 »

Pepsee wrote: Mon Jan 25, 2021 11:11 pm Hey, I'm really loving this but really looking forward to some love for Mechassault 2 and some support be added for the animation .GR2 files. So far I can only open up and preview the base skeleton, but animations are another story.. I attached some skeletons and animations for a more in-depth analysis.
Thanks yet again for this great plugin!

Here are the animation samples:
https://mega.nz/file/9Z5WhC7I#0lFeK8kae ... u_3MpSWzsE
Hi,

I have tried using vtr_skeleton with vtr_run and with vtr_walk and animations seems to work with both of them, can you please let me know which animations aren't working and what skeleton is associated with the animation.

edit:
also tried P_G_skeleton with P_G_run_pilot and aniamtion works great
User avatar
Pepsee
mega-veteran
mega-veteran
Posts: 188
Joined: Fri Mar 04, 2016 9:26 pm
Has thanked: 53 times
Been thanked: 8 times

Re: Granny .GR2 Reader plugin for Noesis

Post by Pepsee »

What version of the script? Latest release?
User avatar
Pepsee
mega-veteran
mega-veteran
Posts: 188
Joined: Fri Mar 04, 2016 9:26 pm
Has thanked: 53 times
Been thanked: 8 times

Re: Granny .GR2 Reader plugin for Noesis

Post by Pepsee »

Thank you so much for your support and implication! Finally able to properly port this to Garry's Mod, now I'm going to try to have them scripted so people can have chaotic PVP/PVE fun with them!

Image
Image
Image
Image
Image
jayn23
mega-veteran
mega-veteran
Posts: 250
Joined: Sun Jul 17, 2011 9:30 pm
Has thanked: 61 times
Been thanked: 241 times

Re: Granny .GR2 Reader plugin for Noesis

Post by jayn23 »

Version 1.2.6.1 Release

Thanks to Pepsee i found a missing parameter when converting old type animations to new type that i haven't encountered yet,
now all tested Mechassault 2 animations work.
Last edited by jayn23 on Tue Jun 15, 2021 7:36 pm, edited 1 time in total.
noire90
ultra-n00b
Posts: 4
Joined: Mon Jan 13, 2020 12:49 am

Re: Granny .GR2 Reader plugin for Noesis

Post by noire90 »

It is possible to import scene maps from Divinity Original Sin 2 with this plugin?
jayn23
mega-veteran
mega-veteran
Posts: 250
Joined: Sun Jul 17, 2011 9:30 pm
Has thanked: 61 times
Been thanked: 241 times

Re: Granny .GR2 Reader plugin for Noesis

Post by jayn23 »

noire90 wrote: Sat Feb 20, 2021 11:41 am It is possible to import scene maps from Divinity Original Sin 2 with this plugin?
Well my intrest is more with charecter models so i have only tested those, but if the scene maps are in .gr2 format i dont see any reason they wont work.
TheFalcon19
ultra-n00b
Posts: 6
Joined: Wed Sep 25, 2019 2:42 pm
Has thanked: 5 times
Been thanked: 2 times

Re: Granny .GR2 Reader plugin for Noesis

Post by TheFalcon19 »

Looked into some ESO models that have the uv issue and it looks like they simply have the two uv channels in shorts instead of floats.
jayn23
mega-veteran
mega-veteran
Posts: 250
Joined: Sun Jul 17, 2011 9:30 pm
Has thanked: 61 times
Been thanked: 241 times

Re: Granny .GR2 Reader plugin for Noesis

Post by jayn23 »

TheFalcon19 wrote: Sat Feb 27, 2021 4:21 am Looked into some ESO models that have the uv issue and it looks like they simply have the two uv channels in shorts instead of floats.
Hi TheFalcon19,

In the past i remembered checking UV for shorts and i didnt find anything, but thanks to your post i decided to take another look,
at first i didnt find anything until i rememberedi reading somewhere about normlizing shorts to get floats or something similer, once i went down that path i figured it out , goes to show you what exprience gives you :D

by the way it works with signed shorts only from what i tested.

ill be uploading a new version in a day or so.
jayn23
mega-veteran
mega-veteran
Posts: 250
Joined: Sun Jul 17, 2011 9:30 pm
Has thanked: 61 times
Been thanked: 241 times

Re: Granny .GR2 Reader plugin for Noesis

Post by jayn23 »

Version 1.2.7 Release

1. Now supports UV for ESO static meshes
2. Added Support for Bauldrs Gate 3 .PAK files archive - has known issue with LowTex.pak - files are extracted but they arent usable , seem to be missing headers at the very least, anyway i dont have any plans to try and get them working.

edit:
I forgot to add that in order to get UV for ESO static meshes i added a game tag, GAME_TAG_ESO_STATIC = 1 since there was no way for the script to tell the diffrence between these meshes and any other.
its currently on by deafult and should not cause any issues for most games, but if any game get distorted UV try diabling it.

The Support for BG3 .PAK was added, to make script a bit more about BG3 which was my main reason for making it, and to get some practice with Archives and lz4 compression.

I have a weird issue with extractor, maybe someone can help me figure out what the issue is.
as you can see in gif below, when i double click file for export in runs thru the entire script without actually exporting the data.
i can then export normaly, and when i close the extractor it again runs thru the entire script without actually exporting the data.
as you can imagine for big files it causes a huge delay in loading and when closing as we actually run thru the file 3 times.

Image

Extractor code:

Code: Select all

from os.path import *
from math import *
from inc_noesis import *
import struct
import os
import io


def registerNoesisTypes(): 
    handle = noesis.register("Bauldrs Gate 3 Archive", ".pak")
    noesis.setHandlerExtractArc(handle, extractPAK)
    #opens debug consle
    noesis.logPopup()
    return 1
    
def noepyCheckType(data):
    '''Verify that the format is supported by this plugin. Default yes'''
    return 1
    

#get file and directory names from string 
def getfilename(name):
    array = name.split('/')
    filename = array[len(array)-1]
    num = len(name) - len(filename)
    directoryname = name[:num]

    return filename, directoryname

    
    
def extractPAK(fileName, fileLen, justChecking):
        

        
def extractPAK(fileName, fileLen, justChecking):
                   
    with open(fileName, "rb") as f:
        
        if justChecking:
            return 1
                
        f.seek(4,0) # magic
        version = struct.unpack("<I",f.read(4))[0] 

        #Get file names and parameters
        table_offset = struct.unpack("<Q",f.read(8))[0]
        f.seek(table_offset,0)
        NumFiles = struct.unpack("<I",f.read(4))[0] 
        CompressedSize = struct.unpack("<I",f.read(4))[0] 

        #Save current location
        TableOffset = f.tell()
        UncompressedSize = NumFiles * 296
        
        #Decompress using lz4.block format
        DecompressedData = rapi.decompLZ4(f.read(CompressedSize),UncompressedSize)

        #Convert data to IO format       
        DecompressStream = NoeBitStream(bytes(DecompressedData), NOE_LITTLEENDIAN)
        
        for i in range(NumFiles): 
            string = noeStrFromBytes(DecompressStream.readBytes(256), "UTF8")
            offset = DecompressStream.readUInt64()
            CompressedSize = DecompressStream.readUInt64()
            UncompressedSize = DecompressStream.readUInt64()
            dummy = DecompressStream.readUInt64()
            crc = DecompressStream.readUInt()
            dummy = DecompressStream.readUInt()

            f.seek(offset,0)
            #if file is compressed

            if UncompressedSize != 0 and fileName[-10:] != 'LowTex.pak':       
                FileDecompressedData = rapi.decompLZ4(f.read(CompressedSize),UncompressedSize)

            else:
                #data is not compressed
                #print("uncompressed file" + string)
                FileDecompressedData = f.read(CompressedSize)

            filename, directoryname = getfilename(string)
            print("{} {}".format(i,directoryname + filename))
            rapi.exportArchiveFile(directoryname + filename , FileDecompressedData)  
            
        
    return 1   
Last edited by jayn23 on Tue Jun 15, 2021 7:36 pm, edited 4 times in total.
zardalu
veteran
Posts: 134
Joined: Sat Sep 13, 2008 3:13 pm
Has thanked: 17 times
Been thanked: 31 times
Contact:

Re: Granny .GR2 Reader plugin for Noesis

Post by zardalu »

Amazing work! For some reason when I try to export any ESO static mesh, Noesis crashes. I am experimenting to see if I can figure it out. Thanks for your work

Edit: I'm an idiot, was using old version of Noesis. Works great :D
kodachrome
ultra-n00b
Posts: 5
Joined: Sun Dec 31, 2017 1:11 am

Re: Granny .GR2 Reader plugin for Noesis

Post by kodachrome »

Is Noesis with this Plugin meant to be able to preview/view GR2 files? In Baldurs Gate 3, want to extract character models for 3D Printing.
I have tried two Granny2.dll files and both give an error

Image
Kinda looks like a 64bit dll in a 32bit application error..


I do not have this problem with Norbytes LSLib on the same files, using the same Granny2.dll file??
https://github.com/Norbyte/lslib


EDIT: Looks like this DLL build works:
https://github.com/nikita322/GrannyConverter2.11.8
jayn23
mega-veteran
mega-veteran
Posts: 250
Joined: Sun Jul 17, 2011 9:30 pm
Has thanked: 61 times
Been thanked: 241 times

Re: Granny .GR2 Reader plugin for Noesis

Post by jayn23 »

kodachrome wrote: Thu Apr 01, 2021 12:49 am Is Noesis with this Plugin meant to be able to preview/view GR2 files? In Baldurs Gate 3, want to extract character models for 3D Printing.
I have tried two Granny2.dll files and both give an error

Image
Kinda looks like a 64bit dll in a 32bit application error..


I do not have this problem with Norbytes LSLib on the same files, using the same Granny2.dll file??
https://github.com/Norbyte/lslib


EDIT: Looks like this DLL build works:
https://github.com/nikita322/GrannyConverter2.11.8
You are correct, noesis is a 32bit application therefore i was able to add support only for 32bit granny2.dll, you need to find a different version, then it will work for you just make sure its one that supports BitKnit compression, there is a link somewhere in this thread, (by the way i Norbytes tool uses 64 bit Granny )

Nevermind i see you found it on your own - ill leave my answer for future refernce
Last edited by jayn23 on Sat Apr 03, 2021 7:24 pm, edited 1 time in total.
kodachrome
ultra-n00b
Posts: 5
Joined: Sun Dec 31, 2017 1:11 am

Re: Granny .GR2 Reader plugin for Noesis

Post by kodachrome »

Thanks for the reply, yep got that working.

Do Animations work for BG2? Trying to get one of Laezel's animations as an exportable pose. Enabled Animations in the Python script, open "GTY_F_NKD_Head_Laezel.GR2" , select the same file for animations (the GR2 file also contains the animations right? This is in the _Anims folder) but Noesis gives this error:
Image
jayn23
mega-veteran
mega-veteran
Posts: 250
Joined: Sun Jul 17, 2011 9:30 pm
Has thanked: 61 times
Been thanked: 241 times

Re: Granny .GR2 Reader plugin for Noesis

Post by jayn23 »

kodachrome wrote: Sat Apr 03, 2021 7:02 am Thanks for the reply, yep got that working.

Do Animations work for BG2? Trying to get one of Laezel's animations as an exportable pose. Enabled Animations in the Python script, open "GTY_F_NKD_Head_Laezel.GR2" , select the same file for animations (the GR2 file also contains the animations right? This is in the _Anims folder) but
Yes most animations work, i did find a few that were really messed up, i have a theory its beacuse they have really high oversampelling that my interpolation isnt handeling well enough, but i never tested it.

I took a look at "GTY_F_NKD_Head_Laezel.GR2" and it does not contain any animation data, as far as i can remember animation are always on seperate files from the mesh. i manged to find an animation file that worked with the head, but almost all i tried seemed to do nothing.
tested all of them with granny viewer , so no issue with my script just need to find the correct files.
kodachrome
ultra-n00b
Posts: 5
Joined: Sun Dec 31, 2017 1:11 am

Re: Granny .GR2 Reader plugin for Noesis

Post by kodachrome »

Just so I can see the workflow working.. can you give me a suggested BG3 model and anim file that does work in Granny viewer?

thanks
Post Reply