Skip to content

Instantly share code, notes, and snippets.

View tracebox55's full-sized avatar

tracebox tracebox55

View GitHub Profile
@tracebox55
tracebox55 / DistanceB2V.py
Last active December 25, 2015 12:19
[メタセコ]2つの選択頂点の距離を算出する
import math
doc = MQSystem.getDocument()
curidx = doc.currentObjectIndex
if curidx != -1:
obj = doc.object[curidx]
if not (obj is None):
mtx = doc.getGlobalInverseMatrix(obj)
# show vertices
numVert = obj.numVertex
@tracebox55
tracebox55 / LoadMaterialNames.cs
Last active December 25, 2015 12:19
[PMDE]pmdの材質名リストを読み込む
//
// pmdの材質名リストを読み込む
// [簡易形式]LoadMaterialNames.cx
//
// pmdデータと同じフォルダにある txt ファイル
string materiallist = string.Format(@"{0}\{1}.txt", Path.GetDirectoryName(pmx.FilePath), Path.GetFileNameWithoutExtension(pmx.FilePath));
// 材質名リストを一行ずつ読み込んでセットする
using (StreamReader reader = new StreamReader(materiallist, System.Text.Encoding.Default))
{
@tracebox55
tracebox55 / DeleteSpecifiedBones.cs
Last active December 25, 2015 12:29
[PMDE]指定した名前が含まれるボーンを削除する
//
// 指定した名前が含まれるボーンを削除する
// [簡易形式]DeleteSpecifiedBones.cx
//
string name = "スカート"; // ボーン名(一部)
for (int i = bone.Count - 1; i >= 0; i--)
{
if (bone[i].Name.IndexOf(name) >= 0)
{
bone.RemoveAt(i);
@tracebox55
tracebox55 / DeleteUnlinkedBodies.cs
Created October 14, 2013 14:26
[PMDE]関連するボーンが存在しない剛体を削除する
//
// 関連するボーンが存在しない剛体を削除する
// [簡易形式]DeleteUnlinkedBodies.cx
//
for (int i = body.Count - 1; i >= 0; i--)
{
if (body[i].Bone == null) // 関連するボーンが存在しない
{
body.RemoveAt(i);
}
@tracebox55
tracebox55 / DeleteUnlinkedJoionts.cs
Created October 14, 2013 14:31
[PMDE]接続剛体のないJOINTを削除する
//
// 接続剛体のないJOINTを削除する
// [簡易形式]DeleteUnlinkedJoionts.cx
for (int i = joint.Count - 1; i >= 0; i--)
{
if (joint[i].BodyA == null || joint[i].BodyB == null) // 接続剛体が存在しない
{
joint.RemoveAt(i);
}
}
@tracebox55
tracebox55 / SelectBonesRelatedVertexes.cs
Last active December 25, 2015 22:39
[PMDE]選択頂点に関連するボーンを選択する
//
// 選択頂点に関連するボーンを選択する
// [簡易形式]SelectBonesRelatedVertexes.cx
// 補足:Contorlキーが押されていれば選択頂点に関連しないボーンを選択します
// Shiftキーが押されていれば既に選択済みのボーンはそのまま選択されます
IList<int> selectList = new List<int>(); // 選択するボーン記憶用
IList<int> bonelist = new List<int>(); // 処理対象ボーン記憶用
// 選択頂点のボーンウェイトを調べ、参照されているボーン番号を bonelist に記憶する
foreach (int i in view.GetSelectedVertexIndices()) // 選択されている頂点を順次調べる
@tracebox55
tracebox55 / ReverseVertexSelection.cs
Created October 19, 2013 03:52
[PMDE]選択頂点を反転する
//
// 選択頂点を反転する
// [簡易形式]ReverseVertexSelection.cx
IList<int> vlist = new List<int>(); // 処理対象頂点のリスト格納用
int[] selectedMaterials = connect.View.PMDViewHelper.PartsSelect.GetCheckedMaterialIndices(); // 材質絞込み状態取得
if (selectedMaterials.Length < material.Count) // 材質絞込みがされている?
{
// 有効な頂点を記憶する
foreach (int i in selectedMaterials)
@tracebox55
tracebox55 / EnumResourceFiles.cx
Last active January 3, 2016 03:38
[PMDE]モデルが参照している画像ファイルを列挙する
//
// モデルが参照している画像ファイルを列挙する
// [簡易形式]EnumResourceFiles.cx
// 補足:メモ帳に貼り付けますが、たまに失敗します。
IList<string> usedlist = new List<string>(); // 一度以上現れたかの判定用リスト
string basepath = Path.GetDirectoryName(pmx.FilePath); // モデルが保存されているフォルダ名
StringBuilder sb = new StringBuilder(); // 結果出力用
//
// ボーンに手動ベイク用のガイドオブジェクトをくっつける
// [簡易形式]AddGuideObject.cx
// ここにガイドオブジェクトをつけたいボーンを記述する
string[] targetlist = new string[]{
"首",
"頭",
"左腕",
@tracebox55
tracebox55 / ExpectVertexFromMorph.cs
Last active August 29, 2015 14:06
[PMDE]頂点モーフから選択頂点のみを抜き出す
/// <summary>
/// [PMDE]頂点モーフから選択頂点のみを抜き出す
/// [簡易形式]ExtractVertexFromMorph.cx
/// PMDEのリストから対象のモーフを選択し、PMDViewで頂点を選択して使用します
/// </summary>
// 処理元のモーフ取得
int selectedMorph = connect.Form.SelectedExpressionIndex;
if (selectedMorph < 0)
{