Skip to content

Instantly share code, notes, and snippets.

Avatar

Elie Michel eliemichel

View GitHub Profile
View varint.py
# Varint decoding: https://developers.google.com/protocol-buffers/docs/encoding
import struct
def readVarint(f):
multiplier = 1
value = 0
b = 0xff
while b & 128:
b = struct.unpack('B', f.read(1))[0]
value += multiplier * (b & 127)
@eliemichel
eliemichel / extract_marmoset_archive.py
Last active Sep 28, 2022
Extract the items contained in a Marmoset Viewer's .mview archive file
View extract_marmoset_archive.py
import struct
import os
# Parameter
archive = "vivfox.mview"
def readCString(f):
"""This is the most naive implementation possible, don't use in prod"""
str = ""
c = f.read(1)
@eliemichel
eliemichel / output
Last active Mar 2, 2019
Output of list_marmoset_archive on vivfox
View output
$ python marmoset/marmoset_archive.py
Name MIME type Compressed Size Raw size
thumbnail.jpg image/jpeg False 0x1e5ca 0x1e5ca
sky.dat image/derp True 0x127a8e 0x200000
mesh0.dat model/mset False 0x43230 0x43230
mesh1.dat model/mset False 0xd86c 0xd86c
mat0_c.jpg image/jpeg False 0x2c055 0x2c055
mat0_r.jpg image/jpeg False 0xbc42 0xbc42
mat0_n.png image/png False 0x110666 0x110666
mat0_g.jpg image/jpeg False 0x415a8 0x415a8
@eliemichel
eliemichel / list_marmoset_archive.py
Last active Sep 28, 2022
List the items contained in a Marmoset Viewer's .mview archive file
View list_marmoset_archive.py
import struct
def readCString(f):
"""This is the most naive implementation possible, don't use in prod"""
str = ""
c = f.read(1)
while c != '\0':
str += c
c = f.read(1)
return str
@eliemichel
eliemichel / marmoset.js
Created Mar 1, 2019
Marmoset viewer embedded code, as is
View marmoset.js
/*
(Built: Mon, Sep 24, 2018 4:38:25 PM)
Marmoset Viewer Code and Tools
Copyright (c) 2018 Marmoset LLC.
All rights reserved.
Redistribution and use of this software are permitted provided
that the software remains whole and unmodified and this copyright
notice remains attached. Use or inclusion of any portion of this
View BlenderSurfRigMerge.py
"""
Usage: blender.exe -b -P BlenderSurfRigMerge.py
Requires TransferMaterialsOperator.py in the same directory
Copyright (c) 2018 -- Elie Michel
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (theSoftware”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
View TransferMaterialsOperator.py
"""
Transfer material data from active to selected objects.
If the active object is a group instance, recurse over its elements and match
destination by name (object selection is then ignored).
Copyright (c) 2018 -- Elie Michel
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (theSoftware”), to deal in
the Software without restriction, including without limitation the rights to
View blender-icon-list.py
import bpy
class IconPanel(bpy.types.Panel):
"""Creates a Panel width all possible icons"""
bl_label = "Icons"
bl_idname = "icons_panel"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
@eliemichel
eliemichel / hscript
Last active Jul 16, 2018
Fade out offset
View hscript
// Fade in
{
float x0 = ch("../PARAM/start_crossfade_frame");
float x1 = ch("../PARAM/end_crossfade_frame");
float a1 = 0.01;
float a0 = a1 / (2 * (x1 - x0));
float b1 = a0 * (x1 - x0) * (x1 - x0) - a1 * x1;
return if($FF < x0, 0, if($FF < x1, a0 * ($FF - x0) * ($FF - x0), a1 * $FF + b1));
}
// Fade out
View autoRotateMaya.py
"""
autoRotate
==========
Align the selected edge to the world X axis of the scene by rotating the whole mesh.
Usage
-----
Select exactly one edge, then run the script.