Beauty Salon α-BET (alphabet)

space001
Blender3d Collada dae modeling Use Papervision3d on Progression3 and 4 http://a-bet.secret.jp/#/access
more whaison works.
whaison space
space002
http://whaison.jugem.jp/ https://jp.pinterest.com/whaison/ https://www.instagram.com/whaison/ https://whaison.amebaownd.com/
https://suzuri.jp/whaison
http://whaison.blogspot.com/
http://whaison.tumblr.com/ http://qiita.com/users/whaison http://www.behance.net/whaison https://github.com/whaison/ https://bitbucket.org/whaison http://serato.com/user/whaison http://whaison.hatenablog.jp/

typo memo
http://d.hatena.ne.jp/whaison/


dayNote
http://www.myspace.com/whaison http://ameblo.jp/whaison/ http://blog.crooz.jp/whaison/ http://blog.crooz.jp/whaisoncafe/ http://nenpyo.org/whaison

fulldisk
http://full.shin-gen.jp/
http://whaison.client.jp/
http://www.dclog.jp/whaison/
featured forums.
space004
forum.unity3d.com/

forums.unrealengine.com.

Progression Forum.

FlashDevelop Forum.

Papervision3D Forum.

FlexUserGroup Forum.

SparkProjectForum.





Twitter







Mobile
qrcode
Calendar
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
282930    
<< June 2015 >>
New Entries
Archives
Categories
Recent comment
  • FlashDevelopでフォント埋め込み
    感謝!! (12/24)
  • cocos2d-x-3.0rc0 ,c++ ,cpp でTexturePacker で 吐き出した、plist と png でパラパラアニメーションのコード例
    whaison (04/17)
  • Blender2.67にbvh(web上に2500個以上ころがってる)入れてそのBoneオブジェクトをUnity4.0のmecanimで使う
    whaison (08/19)
  • Apple Dev Center 「Certificates, Identifiers & Profiles」で Adhoc をつくってXCode4.6.1でArchiveしてipaを書き出し
    whaison (04/30)
  • Flash CS6でプロパティーパネルで物理演算のジャンプの高さを設定できるCitrus Engine
    whaison (03/01)
  • 「Flash以外、例えばKinectとか」ON TOKYO (会場:高田馬場4-11-8 Floor 6階 ) 短縮URL http://bit.ly/dI0Bfx
    uka (03/02)
  • App Store Review Guidelines アップル社のアプリ審査基準ガイドライン和訳 Apple が 開発者を悩ませ ユーザーをハッピーにしたいガイドライン。w
    whaison (01/25)
  • Unity3d では ADOBE JAPAN OSAKIで行われたFITC 2010 TOKYOでは、 「iOS用にパブリッシュするためには、フリー版ではなくて、有料版を買ってください。さらに追加のパッケージである、"iOS Package (for Development)"を買ってください」とのことだった。
    whaison (01/25)
  • enjoy Adidas-Futsal-Park
    whaison (01/16)
  • MacBookAir にFlashPlayer入れたらなった。Mac Flash Player 10.1/10.2でUstream などでカメラが認識されないバグそんなときはUstreamProducer!でもなくiPhoneだと直ぐにライブ配信できた
    whaison (01/14)
simple sintax high lighter2.0
space003
SyntaxHighlighter2.0用 の貼り付けコード作成する!
ブログパーツ-BLOG PARTS.
Profile
Links
Recommend
Sponsored Links
Admin
無料ブログ作成サービス JUGEM
Seach this site
            
2022.03.28 Monday
スポンサーサイト

一定期間更新がないため広告を表示しています

| スポンサードリンク | - | | - | - | pookmark |
            
2015.06.26 Friday
PolyPlane _ plane の全部の枚数から各ポイントの position (x,y,z)を引っ張ってさらにwidth heightを計測するmelスクリプト
PolyPlane _ plane の全部の枚数から各ポイントの position (x,y,z)を引っ張ってさらにwidth heightを計測するmelスクリプト



照会モード 
-query
http://shikatanaku.blogspot.jp/2010/01/blog-post_02.html

lsコマンドと-slフラグ
http://shikatanaku.blogspot.jp/2009/05/select.html


float $pos[] = `xform -query -worldSpace -translation ($ObjectRef + ".vtx[0]")`;
http://simplymaya.com/forum/showthread.php?t=26685

http://me.autodesk.jp/wam/maya/docs/Maya2010/Commands/xform.html


//-----------------------------------
//plane -p 1 1 1 -s 10 -n "plane001";
//pointPosition plane001.vtx[2];
//getAttr plane001.vtx[2]
//string $a[];

//string $curPolyName="polyPlane";

//polyPlane -n ($curPolyName+"_plane") -w 1-h 1 -sw 1 -sh 1 -cuv 1 ;
//setAttr ($curPolyName+"_plane.translateY") (1);
//setAttr ($curPolyName+"_plane.translateX") ((2));
//setAttr ($curPolyName+"_plane.translateZ") ((3));

select -all;
//string $name[] = `ls`;

int $_planeNum=0;
string $name[] = `ls -sl`;
$size = size($name);
int $size_minus=0;
for ($i=0;$i<$size;$i++) 
{
string $ObjectRef=$name[$i];

switch ($ObjectRef) {
 case "uiConfigurationScriptNode":
 $size_minus =$size_minus +1;
 break;
 case "sceneConfigurationScriptNode":
  $size_minus =$size_minus +1;
 break;
  case "ikSCsolver":
  $size_minus =$size_minus +1;
 break;
  case "polyPlane1":
  $size_minus =$size_minus +1;
 break;
 default:
     string $ObjectRefArr[];
   tokenize $ObjectRef "_" $ObjectRefArr;
   $ObjectRefArrLength = size($ObjectRefArr);
  // print ("$ObjectRefArrLength= "+$ObjectRefArrLength+"¥n");
    //print ("$ObjectRefArr[$ObjectRefArrLength-1]= "+$ObjectRefArr[$ObjectRefArrLength-1]+"¥n");
    
 if($ObjectRefArr[$ObjectRefArrLength-1]=="plane"){
     
    print ("$ObjectRef= "+$ObjectRef+"--------------------¥n");

   
       float $pos0[] = `xform -query -worldSpace -translation ($ObjectRef + ".vtx[0]")`;
       float $pos1[] = `xform -query -worldSpace -translation ($ObjectRef + ".vtx[1]")`;
       float $pos2[] = `xform -query -worldSpace -translation ($ObjectRef + ".vtx[2]")`;
       float $pos3[] = `xform -query -worldSpace -translation ($ObjectRef + ".vtx[3]")`;
    // float $scale[]=`xform -query -worldSpace -scale( ($ObjectRef + ".vtx[0]")`;
    //now you can use the array to access the postions:
    
    
    print("pos0: " + $pos0[0] + " " + $pos0[1] + " " + $pos0[2]+"¥n");
    print("pos1: " + $pos1[0] + " " + $pos1[1] + " " + $pos1[2]+"¥n");
    print("pos2: " + $pos2[0] + " " + $pos2[1] + " " + $pos2[2]+"¥n");
    print("pos3: " + $pos3[0] + " " + $pos3[1] + " " + $pos3[2]+"¥n");
    float $width;
    $width=abs($pos0[0]-$pos1[0]);
    float $height;
    $height=abs($pos1[2]-$pos2[2]);
    print (" ---------------------------------$width = "+$width+"¥n");
    print (" ---------------------------------$height= "+$height+"¥n");
    
    //print("scale: " + $scale[0] + " " + $scale[1] + " " + $scale[2]+"¥n");
   select $ObjectRef;
    float $width;
    //polyPlane -query -width "ch_cn__face1_plane";
   //$width = `polyPlane -query -width $ObjectRef`;
   // print (" ----------$width= "+$width+"¥n");
    
    string $buildStr;
    $buildStr="";
    for ($j=0;$j<$ObjectRefArrLength-1;$j++) 
    {
        $buildStr=$buildStr+"_"+$ObjectRefArr[$j];
    }
    string $charaName=$buildStr;
    print("--------charaName="+$charaName+"¥n");
    string $jointName1=$charaName+"_joint";
    string $jointName2=$charaName+"_joint2";
     print("--------jointName1="+$jointName1+"¥n");
     print("--------jointName2="+$jointName2+"¥n");
     select -d;
     //joint -position $pos[0] $pos[1] $pos[2] -name $jointName1;
     //joint -position ($pos[0]) $pos[1] ($pos[2]+100) -name $jointName2;
    // joint -e -zso -oj xyz $jointName1;
      
      
   $_planeNum=$_planeNum+1;
     print ("$ObjectRef= "+$ObjectRef+"----------end------¥n");
   }
 break;
}


}
$size =$size-$size_minus;
print ("_plane total Number = " + $_planeNum + "¥n");
//-------------------------
//http://shikatanaku.blogspot.jp/2009/12/fieldfloatfield_26.html
//http://me.autodesk.jp/wam/maya/docs/Maya2009/index.html?url=Syntax_Command_syntax.htm,topicNumber=d0e164912
//---------------------------
sphere -name "mySphere";
sphere -edit -radius 5 "mySphere";
sphere -query -radius "mySphere";
if (`sphere -query -radius "mySphere"` == 5)
{
	print("This sphere has a radius of 5!"+"¥n");
}	
float $radius=`sphere -query -radius "mySphere"`;
print("$radius= "+$radius+"¥n");

polyPlane -name "polyPlane001";
 float $width;
    //polyPlane -query -width "ch_cn__face1_plane";
 $width = `polyPlane -query -width "polyPlane001"`;
    print (" ----------$width= "+$width+"¥n");
    string $type = `nodeType polyPlane001`;
  print (" ----------$type= "+$type+"¥n");
 string $type = `nodeType ch_cn__face1_plane`;
  print (" ----------$type= "+$type+"¥n");
    // $width = `polyPlane -query -width "ch_cn__face1_plane"`;
  //  print (" ----------$width= "+$width+"¥n");
 $width= `getAttr polyPlane1.width`;
 print (" ----------$width= "+$width+"¥n");




 
| whaison | MEL(Maya Embedded Language) | 16:22 | comments(0) | - | pookmark |
            
2015.06.24 Wednesday
MacOSX 新アカウントotsuka-noboru-3d から旧otsuka-noboruをアクセスを 書き/読み できるようにしてしまったことによる弊害-
------------------新アカウントotsuka-noboru-3d   からotsuka-noboruをアクセスを 書き/読み できるようにしてしまったことによる弊害-------------

Unityのプロジェクトで再生しなくても原因不明のエラーが起き続ける。
どのプロジェクトでもエラーがでる。下のがおかしいって。
/Users/otsuka-noboru/Library/Caches/com.unity3d.UnityEditor/GiCache

Error!
It looks like another Unity instance is running with this project open.

Multiple Unity instances cannot open the same project.

Project: /Users/otsuka-noboru/works/UnityStudy/unity5_assetbundle-demo/unity5_assetbundle

エラー!
別のUnityのインスタンスが開いているこのプロジェクトで実行されているように見えます。

複数のUnityのインスタンスは、同じプロジェクトを開くことができません。

プロジェクト:/Users/otsuka-noboru/works/UnityStudy/unity5_assetbundle-demo/unity5_assetbundle


ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
Title
macOSX Make new Account Old Acount user Folder permission Change to write/Read 
1. What happened
macOSX Make new Account Old Acount user Folder permission Change to write/Read 
login Old Acount and Open Unity5.1.0f3
Error!
It looks like another Unity instance is running with this project open.
Multiple Unity instances cannot open the same project.
Project: /Users/otsuka-noboru/works/UnityStudy/unity5_assetbundle-demo/unity5_assetbundle

2. How we can reproduce it using the example you attached
macOSX Make new Account Old Acount user Folder permission Change to write/Read 
login Old Acount and Open Unity5.1.0f3
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
| whaison | Unity3d | 20:57 | comments(0) | - | pookmark |
            
2015.06.22 Monday
Unity5.1.0f3 Unity fbxのanime分割してModelImporterClipAnimationからAnimationClipにしてAnimatorに貼り付け
Unity5.1.0f3 Unity fbxのanime分割してModelImporterClipAnimationからAnimationClipにしてAnimatorに貼り付け


こんなfr.txt用意して
anim_01_wait,2,14,
anim_02_run,15,29,
anim_03_stance,30,59,
anim_04_block,60,69,
anim_05_damage,70,79,
anim_06_near_death,80,99,
anim_07_death,100,149,
anim_08_victory,150,169,
anim_09_attack,300,319,OnAnimStart,0,OnAnimEventEnd,1.0,OnAnimEventTrigger,0.33,OnAnimEventTrigger,0.66,
anim_10_skill,380,480,OnAnimStart,0,OnAnimEventEnd,1.0,OnAnimEventTrigger,0.33,OnAnimEventTrigger,0.66,
anim_11_state_poison,170,199,
anim_12_state_paralysis,170,199,
anim_13_state_damaged,170,199,
anim_14_state_delicate,170,199,
anim_15_state_sickness,170,199,
anim_16_state_damned,170,199,
anim_17_state_confusion,170,199,
anim_18_state_berserk,170,199,
anim_19_state_transform,200,229,
anim_20_state_minimum,170,199,

 
using UnityEngine;
using UnityEditor;
using UnityEditor.Animations;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Linq;
/// <summary>
/// Model animation spliter.
/// by Koki Ibukuro @asus4 >Noboru Otsuka 
/// </summary>
public class ModelAnimationSplitterWithAnimeController : EditorWindow {
	TextAsset csvAsset;
	GameObject modelAsset;
	string modelAssetPath;

	string CharaName;
	string AnimationNameStr;
	string AnimationClipEventNameStr;
	string CharaDir;

	int build_colWidth;
	int build_colWidthleft;
	int build_colWidthright;
	int build_rowHeight;

	float buildX;
	float buildY;
	float buildY_event;
	bool build_baseLayer_start;
	bool build_left_start;
	bool build_right_start;
	bool build_left_now;
	bool build_right_now;
	int build_count;




	//Vector3 build_startPosition=new Vector3(-build_colWidth,-100,0);

	UnityEditor.Animations.AnimatorController AnimatorControllerRef;
	AnimatorStateMachine BaseLayerStateMachine;
	AnimatorStateMachine EventLayerStateMachine;

	private List<UnityEditor.Animations.AnimatorState> BaseLayerStateList = new List<UnityEditor.Animations.AnimatorState>();
	private List<UnityEditor.Animations.AnimatorState> EventLayerStateList = new List<UnityEditor.Animations.AnimatorState>();

	List<AnimationClip> CharaAnimationClipListRef;

	void OnGUI ()
	{
		GUILayout.Label ("CSV to Split Animtion", EditorStyles.boldLabel);
		GUILayout.Space (10f);
		csvAsset = EditorGUILayout.ObjectField ("CSV Text", csvAsset, typeof(TextAsset), false) as TextAsset;
		if (csvAsset == null) {
			GUILayout.Label ("Set CSV Data. Extension need .txt");
		}
		GUILayout.Space (10f);
		modelAsset = EditorGUILayout.ObjectField ("3D Model", modelAsset, typeof(GameObject), false) as GameObject;
		if (modelAsset == null) {
			GUILayout.Label ("Set FBX or other 3D model object.");
		}
		GUILayout.Space (20f);
		if (GUILayout.Button ("Split with CSV", GUILayout.Width (140f))) {
			SplitWithCsv ();
		}
	}
	void build_Reset()
	{
		 build_colWidth=250;
		build_colWidthleft = 250;
		build_colWidthright = 200;
		 build_rowHeight=50;

		 buildX=0;
		 buildY=0;
		buildY_event = 0;
		 build_baseLayer_start=false;
		 build_left_start=false;
		 build_right_start=false;
		 build_left_now=false;
		 build_right_now=false;
		build_count=1;

	}
	void SplitWithCsv ()
	{	

		if (Assert (csvAsset != null, "Need to set CSV Text") || Assert (modelAsset != null, "Need to set 3D Model")) {
			return;
		}

		string csv = csvAsset.text;
		Debug.Log ("csvAsset=" + csvAsset);
		Debug.Log ("modelAsset=" + modelAsset);

		/**/
		/////////////////////////////////////////////////////////////////////////////
		string modelDirStr = AssetDatabase.GetAssetPath (modelAsset);
		Debug.Log ("modelDirStr=" + modelDirStr);

		string[] modelDirArr;
		modelDirArr=modelDirStr.Split("/"[0]);
		string buildDir = modelDirArr[0];
		for(int i = 1; i < modelDirArr.Length-1; i++)
		{
			buildDir = buildDir +"/"+ modelDirArr [i];
		}
		CharaDir = buildDir;
		Debug.Log ("CharaDir="+CharaDir);
		CharaName = modelDirArr [modelDirArr.Length-1];
		Debug.Log ("CharaName="+CharaName);

		////////////////////////////////////////////////////////////////////////////////
		string ACpath;
		ACpath=CharaDir+"/"+modelAsset.name+"_AnimeController.controller";
		UnityEditor.Animations.AnimatorController controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath(ACpath);
		AnimatorControllerRef = controller;
		AnimatorControllerRef.RemoveLayer(0);
		AnimatorControllerRef.AddLayer("BaseLayer");
		BaseLayerStateMachine = AnimatorControllerRef.layers [0].stateMachine;
		BaseLayerStateMachine.exitPosition = new Vector3 (0,-150,0);
		BaseLayerStateMachine.entryPosition = new Vector3 (0,-100,0);
		BaseLayerStateMachine.anyStatePosition = new Vector3 (0,100,0);

		AnimatorControllerRef.AddLayer("EventLayer");
		EventLayerStateMachine = AnimatorControllerRef.layers [1].stateMachine;
		EventLayerStateMachine.exitPosition = new Vector3 (0,-150,0);
		EventLayerStateMachine.entryPosition = new Vector3 (0,-100,0);
		EventLayerStateMachine.anyStatePosition = new Vector3 (0,100,0);
		EventLayerStateMachine.AddState ("Default State", new Vector3 (-250, -100,0));

		//////////////////////
		build_Reset ();
		/////////////////////
		////////////////////////////////////////////////////////////////////////////////


		ModelImporterClipAnimation[] clipAnimations = ParceCSV (csv);

		Debug.Log ("SplitWithCsv () clipAnimations= "+clipAnimations);
		/*
		if (Assert (clipAnimations != null, "can't parse CSV to Animation")) {
			Debug.Log (csv);
			return;
		}
		*/

		string path = AssetDatabase.GetAssetPath (modelAsset);
		modelAssetPath = path;
		ModelImporter importer = AssetImporter.GetAtPath (path) as ModelImporter;

		if (Assert (importer != null, "set 3D model, like FBX,etc..")) {
			return;
		}

		//importer.splitAnimations = true; // obsolute in Unity4

		importer.clipAnimations = clipAnimations;
		AssetDatabase.ImportAsset (path);

		//DisplayDialog ("Success", "finish split!");

		FbxSeachAndStateMotionSettiong ();

		DisplayDialog ("Success", "finish split! And AnimatorController State.Motion Attach clips!");
	}


	void FbxSeachAndStateMotionSettiong(){
		//fbxファイルからAnimationClipを取得する
		//http://qiita.com/fujimisakari/items/dfcc1230cd135cf134a1

		//CharaAnimationClipListRef=GetAnimationClipInFbx (modelAsset.name);


		Object[] all = AssetDatabase.LoadAllAssetsAtPath(modelAssetPath);
		foreach (var item in all)
		{
			var clip = item as AnimationClip;
			if (clip != null)
			{
				Debug.Log ("clip : " + item.name);
				string animationName = item.name;
				string[] arr = animationName.Split ('_');
				if (arr[0]=="anim") {
					int animNum=int.Parse (arr[1]);

					BaseLayerStateList [animNum - 1].motion = item as UnityEngine.Motion;
					Debug.Log ("BaseLayerStateList ["+animNum+ "- 1].name"+BaseLayerStateList [animNum - 1].name);
					Debug.Log ("BaseLayerStateList ["+animNum+ "- 1].motion"+BaseLayerStateList [animNum - 1].motion);
				} 
			}
		}
	}

	bool Assert (bool b, string error)
	{
		if (!b) {
			DisplayDialog ("Warning", error);
			return true;
		} else {
			return false;
		}
	}

	void DisplayDialog (string title, string message)
	{
		Debug.LogWarning (message);
		EditorUtility.DisplayDialog (title, message, "OK");
	}

	ModelImporterClipAnimation[] ParceCSV (string csv)
	{


		// split to lines
		string[] lines = csv.Split ('¥n');

		//Debug.Log("[]lines = "+ []lines);

		char[] trims = {'¥r', ' '};

		Debug.Log("trims = "+trims);

		List<ModelImporterClipAnimation> clips = new List<ModelImporterClipAnimation> ();

		Debug.Log("lines.Length; = "+lines.Length);
		for (int i=0; i<lines.Length; i++) 
		{
			string s = lines [i].Trim (trims);
			ModelImporterClipAnimation clip = ParseClip (s);

			Debug.Log ("ParseClip(c) の戻り値=clip= "+clip);
			if (clip != null) {
				Debug.Log ("clipsにAdd する clip= "+clip);
				clips.Add (clip);
			}
		}

		if (clips.Count == 0) {
			Debug.Log ("CSVのクリップスは clips.Count= 0 個ありました");
			return null;
		} else {
			Debug.Log ("CSVのクリップスは clips.Count= " + clips.Count + " 個ありました");
			build_count = 0;
		}

		return clips.ToArray();
	}

	ModelImporterClipAnimation ParseClip (string line)
	{
		string[] arr = line.Split (',');
		//Debug.Log("[] arr = "+[] arr);
		Debug.Log("arr.Length = "+arr.Length);
		if (arr.Length < 4) {
			return null;
		} else {
			Debug.Log ("CSV行の長さは必要なだけあります。");
		}

		ModelImporterClipAnimation clip = new ModelImporterClipAnimation ();

		// name
		string name = arr [0];
		if (!string.IsNullOrEmpty (name)) {
			clip.name = name;
			Debug.Log ("clip.name =" + clip.name);
			AnimationNameStr = clip.name;

			AnimatorControllerRef.AddParameter(AnimationNameStr,UnityEngine.AnimatorControllerParameterType.Trigger);
		} else {
			return null;
		}

		// first
		try {
			//clip.firstFrame = int.Parse (arr [1]); // change to float in unity4
			clip.firstFrame = float.Parse (arr [1]);
			Debug.Log ("clip.firstFrame =" + clip.firstFrame);
		} catch {
			//			
			return null;
		}

		// last 
		try {
			//clip.lastFrame = int.Parse (arr [2]); // change to float in unity4
			clip.lastFrame = float.Parse (arr [2]);
			Debug.Log ("clip.lastFrame =" + clip.lastFrame);



			///////////////////////////////////////////
			/// 
			/// 
			///

			if(build_baseLayer_start==false){
				Debug.Log("------build_baseLayer_start="+build_baseLayer_start+" ここはfalseでスタート-----buildY  =  "+buildY+"-----build_count="+build_count+"-------");
				build_baseLayer_start=true;
				build_left_start=true;
			}
			if(build_left_start==true)
			{
				buildY=-100.0f;
				Debug.Log("------build_left_start="+build_left_start+" ここはtrueでスタート-----buildY  =  "+buildY+"----build_count="+build_count+"-----AnimationNameStr="+AnimationNameStr+"-----");
				build_left_start=false;
				build_left_now=true;
			}

			if(build_left_now==true){
				Debug.Log("------build_left_now="+build_left_now+" ここはtrueでadd--buildY  =  "+buildY+"----build_count="+build_count+"--AnimationNameStr="+AnimationNameStr+"--add---");
				if(build_count<=11){
					UnityEditor.Animations.AnimatorState state001 = BaseLayerStateMachine.AddState(clip.name,new Vector3(-build_colWidthleft,buildY,0));
					UnityEditor.Animations.AnimatorStateTransition state001Transition = BaseLayerStateMachine.AddAnyStateTransition(state001);
					state001Transition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, AnimationNameStr);

					BaseLayerStateList.Add(state001);

					//state001.motion=clip. as UnityEngine.Motion;
					buildY=buildY+build_rowHeight*1.0f;
					build_count++;
				}

			}
			Debug.Log("----------build_right_start="+build_right_start+" ここはtrueでスタート-------どう?---AnimationNameStr="+AnimationNameStr+"----build_right_start");
			if(build_right_start==true)
			{
				buildY=-100.0f;
				Debug.Log("------build_right_start="+build_right_start+" ここはtrueでスタート-----buildY  =  "+buildY+"----build_count="+build_count+"-----AnimationNameStr="+AnimationNameStr+"-----");
				build_right_start=false;
				build_right_now=true;
			}
			if(build_right_now==true){
				Debug.Log("------build_right_now="+build_right_now+" ここはtrueでadd---buildY  =  "+buildY+"----build_count="+build_count+"---AnimationNameStr="+AnimationNameStr+"-add---");
				if(build_count<=22){
					UnityEditor.Animations.AnimatorState state002 = BaseLayerStateMachine.AddState(clip.name,new Vector3(build_colWidthright,buildY,0));
					UnityEditor.Animations.AnimatorStateTransition state002Transition = BaseLayerStateMachine.AddAnyStateTransition(state002);
					state002Transition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, AnimationNameStr);

					BaseLayerStateList.Add(state002);

					buildY=buildY+build_rowHeight*1.0f;
					build_count++;
				}

			}

			if(build_count==11){
				build_left_start=false;
				build_left_now=false;
				build_right_start=true;
				build_right_now=false;
			}

			if(build_count==22){
				//
				build_left_start=false;
				build_left_now=false;

				build_right_start=false;
				build_right_now=false;
			}
			/////////////////////////////////////////////


		} catch {
			return null;

		}

		try {
			//clip.lastFrame = int.Parse (arr [2]); // change to float in unity4

			bool myLoopTimebool=true;

			switch (AnimationNameStr)
			{
			case "anim_01_wait":
				myLoopTimebool=true;
				break;
			case "anim_02_run":
				myLoopTimebool=true;
				break;
			case "anim_03_stance":
				myLoopTimebool=true;
				break;
			case "anim_04_block":
				myLoopTimebool=false;
				break;
			case "anim_05_damage":
				myLoopTimebool=false;
				break;
			case "anim_06_near_death":
				myLoopTimebool=true;
				break;
			case "anim_07_death":
				myLoopTimebool=false;
				break;
			case "anim_08_victory":
				myLoopTimebool=true;
				break;
			case "anim_09_attack":
				myLoopTimebool=false;
				break;
			case "anim_10_skill":
				myLoopTimebool=false;
				break;
			case "anim_11_state_poison":
				myLoopTimebool=true;
				break;
			case "anim_12_state_paralysis":
				myLoopTimebool=true;
				break;
			case "anim_13_state_damaged":
				myLoopTimebool=true;
				break;
			case "anim_14_state_delicate":
				myLoopTimebool=true;
				break;
			case "anim_15_state_sickness":
				myLoopTimebool=true;
				break;
			case "anim_16_state_damned":
				myLoopTimebool=true;
				break;
			case "anim_17_state_confusion":
				myLoopTimebool=true;
				break;
			case "anim_18_state_berserk":
				myLoopTimebool=true;
				break;
			case "anim_19_state_transform":
				myLoopTimebool=true;
				break;
			case "anim_20_state_minimum":
				myLoopTimebool=true;
				break;
			case "anim_21_state_near_death":
				myLoopTimebool=true;
				break;
			default:
				myLoopTimebool=true;
				break;
			}








			clip.loopTime=myLoopTimebool;

			Debug.Log ("clip.loopTime =" + clip.loopTime);





		} catch {
			return null;

		}

		/////////////////////////////Effect
		/// 
		/// 

		List<AnimationEvent> animEventsList1 = new List<AnimationEvent>(); 

		try {






			////////////////////////
			/// ////////////////////////////
			string eventStr1 = arr [3];

			// アニメーションイベントの作成
			AnimationEvent animEvent1 = new AnimationEvent();

			//AnimationEvent[] animEvents;


			// 関数名をセット
			animEvent1.functionName =eventStr1;
			AnimationClipEventNameStr=animEvent1.functionName;
			// Int型のパラメーターを格納
			animEvent1.intParameter = 0;
			//animEvent.time=arr [4];
			//animEvent.objectReferenceParameter=objEffect_0_start as UnityEngine.Object ;
			// 設定した時間にイベントを送信
			animEvent1.time = float.Parse (arr [4]);
			// アニメーションイベントの追加
			//clip.AddEvent(animEvent);

			if(arr [3+1]!=null){
				Debug.Log("while loop arr["+3+"+1]="+arr [3+1]+" があるので実行");
				//////////////////////////////////////

				//AnimationClipRef;
				CreateAnimationClip();


				Crate();
				///////////////////////////////////////

				animEvent1.objectReferenceParameter=ScriptableObjectRef as UnityEngine.Object ;

				// アニメーションイベントの追加
				//clip.AddEvent(animEvent);


				animEventsList1.Add(animEvent1);

			}
			//animEventsList1.Add(animEvent1);


		} catch {
			//return null;
		}
		try {



			////////////////////////
			/// ////////////////////////////
			string eventStr2= arr [5];

			// アニメーションイベントの作成
			AnimationEvent animEvent2 = new AnimationEvent();

			//AnimationEvent[] animEvents;


			// 関数名をセット
			animEvent2.functionName =eventStr2;
			AnimationClipEventNameStr=animEvent2.functionName;

			// Int型のパラメーターを格納
			animEvent2.intParameter = 0;
			//animEvent.time=arr [4];
			//animEvent.objectReferenceParameter=objEffect_0_start as UnityEngine.Object ;
			// 設定した時間にイベントを送信
			animEvent2.time = float.Parse (arr [6]);
			// アニメーションイベントの追加
			//clip.AddEvent(animEvent);


			if(arr [5+1]!=null){
				Debug.Log("while loop arr["+5+"+1]="+arr [5+1]+" があるので実行");
				//////////////////////////////////////
				Crate();
				///////////////////////////////////////

				animEvent2.objectReferenceParameter=ScriptableObjectRef as UnityEngine.Object ;

				// アニメーションイベントの追加
				//clip.AddEvent(animEvent);


				animEventsList1.Add(animEvent2);

			}

			//animEventsList1.Add(animEvent2);


		} catch {
			//return null;
		}
		try{
			//for(int i = 7; i < arr.Length; i+2)
			//{
			int i=7;
			while(i < arr.Length)
			{
				//Debug.Log ("I've washed a cup!");
				Debug.Log("--------while loop i="+i+"----------------------");
			
				/// ////////////////////////////
				string eventStr3= arr [i];
				Debug.Log("while loop eventStr3="+eventStr3);
				// アニメーションイベントの作成
				AnimationEvent animEvent3 = new AnimationEvent();

				//AnimationEvent[] animEvents;


				// 関数名をセット
				animEvent3.functionName =eventStr3;
				AnimationClipEventNameStr=animEvent3.functionName;

				// Int型のパラメーターを格納
				animEvent3.intParameter = 0;
				//animEvent.time=arr [4];

				// 設定した時間にイベントを送信
				animEvent3.time = float.Parse (arr [i+1]);
				Debug.Log("while loop animEvent3.time="+animEvent3.time);

				if(arr [i+1]!=null){
					Debug.Log("while loop arr["+i+"+1]="+arr [i+1]+" があるので実行");
					//////////////////////////////////////
					Crate();
					///////////////////////////////////////

					animEvent3.objectReferenceParameter=ScriptableObjectRef as UnityEngine.Object ;

					// アニメーションイベントの追加
					//clip.AddEvent(animEvent);


					animEventsList1.Add(animEvent3);

				}


				Debug.Log("--------while loop i="+i+"----------------------end");
				i=i+2;
				Debug.Log("--------while loop i="+i+"--------------------next");
			}
		} catch {
			//return null;
		}

		if(animEventsList1.Count!=0){
			AnimationEvent[] animationEventArr1 = animEventsList1.ToArray();
			//clip.events = animationEventArr1;

			AnimationClipRef.frameRate = 24;
			//AnimationClipRef.



			//AnimationClipRef.events= animationEventArr1;
			AnimationUtility.SetAnimationEvents(AnimationClipRef, animationEventArr1);
			//public static void SetAnimationEvents(AnimationClip clip, AnimationEvent[] events);
			//Debug.Log ("clip.events =" + clip.events);
			Debug.Log ("AnimationClipRef.events =" + AnimationClipRef.events);

			///////////////////////////////////////////////////////////////////////////
			if (buildY_event == 0) {
				buildY_event = buildY;
			} else {
				buildY_event = buildY_event + build_rowHeight;
			}
			UnityEditor.Animations.AnimatorState state003 = EventLayerStateMachine.AddState(clip.name,new Vector3(-build_colWidthleft,buildY_event,0));
			UnityEditor.Animations.AnimatorStateTransition state003Transition = EventLayerStateMachine.AddAnyStateTransition(state003);
			state003Transition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, AnimationNameStr);

			EventLayerStateList.Add(state003);

			if (buildY_event == 0) {

			}
			/// ///////////////////////////////////////////////////////////////////////
		}




		/*
		// wrapmode
		try {
			clip.wrapMode = (WrapMode) System.Enum.Parse(typeof(WrapMode), arr [3]);
		} catch {
			return null;
		}

		if (clip.wrapMode == WrapMode.Loop || clip.wrapMode == WrapMode.PingPong) {
			clip.loop = true;
		}
		*/
		Debug.Log ("ParseClipの返し値=clip=" + clip);
		return clip;
	}	

	/// <summary>
	/// CreateScriptableObjectPrefub
	/// </summary>
	/// 
	string[] labels = {"Data", "ScriptableObject"};

	ScriptableObject ScriptableObjectRef;
	void Crate ()
	{
		Debug.Log("--------Crate ----------------------");
		Debug.Log("--Crate-- Selection.objects="+Selection.objects);
		//foreach (Object selectedObject in Selection.objects) {
		//Object modelAssetObject=(modelAsset)Object;
		//selectedObject	 = 


		//selectedObject c = obj as TestClass;

		//Debug.Log("Crate selectedObject="+selectedObject);
			// get path
		//string path = getSavePath (selectedObject);
		string path = getSavePath (modelAsset,"AnimationEvent",".asset");

			/////////////////////////////////////////////////////////////////////////////
		/*
			string SelectedObjectDir;
			string selectedObjectStr = AssetDatabase.GetAssetPath (selectedObject);
			Debug.Log ("--Crate-- selectedObjectStr=" + selectedObjectStr);

			string[] modelDirArr;
			modelDirArr=selectedObjectStr.Split("/"[0]);
			string buildDir = modelDirArr[0];
			for(int i = 1; i < modelDirArr.Length-1; i++)
			{
				buildDir = buildDir +"/"+ modelDirArr [i];
			}
			SelectedObjectDir = buildDir;
			Debug.Log ("--Crate-- SelectedObjectDir="+SelectedObjectDir);
		*/
			////////////////////////////////////////////////////////////////////////////////


			// create instance

			//ScriptableObject obj = ScriptableObject.CreateInstance (selectedObject.name);
			//AnimationClipEventData
		ScriptableObject obj = ScriptableObject.CreateInstance ("AnimationClipEventData");
			AssetDatabase.CreateAsset (obj, path);

			// add label
			ScriptableObject sobj = AssetDatabase.LoadAssetAtPath (path, typeof(ScriptableObject)) as ScriptableObject;
			//sobj = AssetDatabase.LoadAssetAtPath (path, typeof(ScriptableObject)) as ScriptableObject;
			AssetDatabase.SetLabels (sobj, labels);
			EditorUtility.SetDirty (sobj);

			ScriptableObjectRef = sobj;
		//}
		Debug.Log("--------Crate ----------end-----------");
	}
	AnimationClip AnimationClipRef;
	void CreateAnimationClip(){

		string path = getSavePath (modelAsset,"EditedAnimation",".anim");
		AnimationClip newClip = new AnimationClip();
		newClip.name = name;
		AssetDatabase.CreateAsset(newClip, path);

		// add label
		AnimationClip obj = AssetDatabase.LoadAssetAtPath (path, typeof(AnimationClip)) as AnimationClip;
		//sobj = AssetDatabase.LoadAssetAtPath (path, typeof(ScriptableObject)) as ScriptableObject;
		AssetDatabase.SetLabels (obj, labels);
		EditorUtility.SetDirty (obj);

		AnimationClipRef = obj;

	}
	string getSavePath (Object selectedObject,string folderName,string filetype)
	{
		Debug.Log("------- getSavePath ----- selectedObject="+selectedObject);
		//string objectName = selectedObject.name;
		string objectName = selectedObject.name;
		//string objectName = selectedObject.name+"_AnimationClipEventData";
		if (filetype == ".asset") {
			 objectName = selectedObject.name+"_"+AnimationNameStr+"_"+AnimationClipEventNameStr;
		}
		if (filetype == ".anim") {
			objectName =AnimationNameStr+"_event";
		}

		Debug.Log("------- getSavePath ----- objectName="+objectName);
		//string dirPath = Path.GetDirectoryName (AssetDatabase.GetAssetPath (selectedObject));
		////////////
		string dirPath = CharaDir;
		//string dirPath = CharaDir+"/AnimationClipEventData";
		//////////
		Debug.Log ("------ getSavePath -----dirPath="+dirPath);
		//string path = string.Format ("{0}/{1}.asset", dirPath, objectName);
		//string path = dirPath+"/"+objectName+".asset";
		string path = dirPath+"/"+objectName+filetype;
		//string AnimationEventDir = dirPath + "/AnimationEvent";
		string MakeDir = dirPath +"/"+ folderName;
		if (AssetDatabase.IsValidFolder (MakeDir)) {

			Debug.Log (MakeDir + " ありました!");
		} else {
			Debug.Log (MakeDir+" ないのでつくりますです!");
			string guid = AssetDatabase.CreateFolder(dirPath, folderName);  
			string newFolderPath = AssetDatabase.GUIDToAssetPath(guid);
			Debug.Log (newFolderPath+" = newFolderPath 作りました!");
			Debug.Log (MakeDir+" = MakeDir 作りました!");
		}

		//path= MakeDir+"/"+objectName+".asset";
		path= MakeDir+"/"+objectName+filetype;


		if (File.Exists (path)) {
			for (int i = 1;; i++) {
				//path = string.Format ("{0}/{1}({2}).asset", dirPath, objectName, i);
				path=MakeDir+"/"+objectName+"_"+i+filetype;
				if (!File.Exists (path))
					break;
			}
		}


		Debug.Log("------ getSavePath  --------- path="+path);
		return path;
	}

	////////////////////////////////////////////////////////////////////////////////

	#region Static
	/// <summary>
	/// Open the tool window
	/// </summary>
	[MenuItem("Tools/Model/Animation Split And Make AnimeController")]
	static public void OpenWindow ()
	{
		EditorWindow.GetWindow<ModelAnimationSplitterWithAnimeController> (true, "Model Animation Splitter With AnimeController", true);
	}
	#endregion


}
| whaison | Unity3d | 20:49 | comments(0) | - | pookmark |
            
2015.06.20 Saturday
Unity5.1.0f2 Create Animator Animation Controller のC# Editer 拡張 Scriptからの自動生成 vol.02
Unity5.1.0f2 Create Animator Animation Controller のC# Editer 拡張 Scriptからの自動生成 vol.02

paramater setting

addState 
addLayer

Condition Moving






using UnityEngine; 
using UnityEditor; 
using UnityEditor.Animations;
using System.Collections;
using System.Collections.Generic;
//using System.Linq;
//using UnityEditorInternal; 
public static class Simple3AnimatorController { 
	[MenuItem("Assets/Create Simple3AnimatorController")]
	public static void CreateAnimatorController ()
	{
		//非常に単純なAnimatorControllerを生成するEditor拡張コード
		//http://qiita.com/RyotaMurohoshi/items/c1f29f9afbce910c5438
		//OK
		//UnityEditor.Animations.AnimatorController animatorController = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath("Assets/Sample.controller");
		string path;
		path="Assets/Sample3.controller";
		UnityEditor.Animations.AnimatorController controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath(path);
		//http://docs.unity3d.com/ScriptReference/Animations.AnimatorController.html

		//LayerName
		//controller.layers[0].name="BaseLayer"; NG
		controller.RemoveLayer(0);
		controller.AddLayer("BaseLayer");

		// Add parameters 
		//NG  UnityEngine.AnimatorControllerParameterType.Trigger
		//OK  UnityEditorInternal.AnimatorControllerParameterType.Trigger
		controller.AddParameter("state001Trigger",UnityEngine.AnimatorControllerParameterType.Trigger);
		controller.AddParameter("state002Trigger", AnimatorControllerParameterType.Trigger);
		controller.AddParameter("state003Trigger", AnimatorControllerParameterType.Trigger);
		controller.AddParameter("state004Trigger", AnimatorControllerParameterType.Trigger);

		// Add StateMachines
		var rootStateMachine = controller.layers[0].stateMachine;
		//var stateMachineA = rootStateMachine.AddStateMachine("smA");
		//var stateMachineB = rootStateMachine.AddStateMachine("smB");
		//var stateMachineC = stateMachineB.AddStateMachine("smC");

		// Add States
		var state001 = rootStateMachine.AddState("state001",new Vector3(-200,0));
		var state002 = rootStateMachine.AddState("state002",new Vector3(-200,50));
		var state003 = rootStateMachine.AddState("state003",new Vector3(-200,100));
		var state004 = rootStateMachine.AddState("state004",new Vector3(-200,150));
		// Add Transitions
		var state001Transition = rootStateMachine.AddAnyStateTransition(state001);
		state001Transition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "state001Trigger");

		var state002Transition = rootStateMachine.AddAnyStateTransition(state002);
		state002Transition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "state002Trigger");

		var state003Transition = rootStateMachine.AddAnyStateTransition(state003);
		state003Transition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "state003Trigger");

		var state004Transition = rootStateMachine.AddAnyStateTransition(state004);
		state004Transition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "state004Trigger");

		//AddLayer

		//controller.RemoveLayer[0];
		controller.AddLayer("EventLayer");

		var rootStateMachineEvent = controller.layers[1].stateMachine;
		// Add States
		var state001Event = rootStateMachineEvent.AddState("state001Event",new Vector3(-200,0));
		var state002Event = rootStateMachineEvent.AddState("state002Event",new Vector3(-200,50));
		var state003Event = rootStateMachineEvent.AddState("state003Event",new Vector3(-200,100));
		var state004Event = rootStateMachineEvent.AddState("state004Event",new Vector3(-200,150));
		// Add Transitions
		var state001TransitionEvent = rootStateMachineEvent.AddAnyStateTransition(state001Event);
		state001TransitionEvent.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "state001Trigger");

		var state002TransitionEvent = rootStateMachineEvent.AddAnyStateTransition(state002Event);
		state002TransitionEvent.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "state002Trigger");

		var state003TransitionEvent = rootStateMachineEvent.AddAnyStateTransition(state003Event);
		state003TransitionEvent.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "state003Trigger");

		var state004TransitionEvent = rootStateMachineEvent.AddAnyStateTransition(state004Event);
		state004TransitionEvent.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "state004Trigger");

		//state001Transition.duration = 0;
		/*
		var transitionB1 = rootStateMachine.AddEntryTransition(stateB1);
		transitionB1.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "GotoB1");
		stateMachineB.AddEntryTransition(stateB2);
		stateMachineC.defaultState = stateC2;
		var exitTransitionC2 = state001.AddExitTransition();
		exitTransitionC2.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "TransitionNow");
		exitTransitionC2.duration = 0;

		var stateMachineTransition = rootStateMachine.AddStateMachineTransition(stateMachineA, stateMachineC);
		stateMachineTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "GotoC");
		rootStateMachine.AddStateMachineTransition(stateMachineA, stateMachineB);
		*/
	}

}








 
| whaison | Unity3d | 20:48 | comments(0) | - | pookmark |
            
2015.06.20 Saturday
Unity5.1.0f2 Create Animator Animation Controller のC# Editer 拡張 Scriptからの自動生成
Unity5.1.0f2 Create Animator Animation Controller のC# Editer 拡張 Scriptからの自動生成 

AssetDatabase.CreateAsset をつかうのかと思いきや使わないこの方法。
アセンブリ内部的には使っている。なぜかラップしている。
アセンブリコードそのままつかっても動かなかった。
using System;
using System.IO;

public static AnimatorController CreateAnimatorControllerAtPath (string path)
{
    AnimatorController animatorController = new AnimatorController ();
    animatorController.name = Path.GetFileName (path);
    AssetDatabase.CreateAsset (animatorController, path);
    animatorController.pushUndo = ;// 動かない
    animatorController.AddLayer ();
// 動かない
    animatorController.pushUndo = ;// 動かない
    return animatorController;
}

スクリプトリファレンスのはなぜか動かなかった。

動くのはこれ。Asset直下にできます  Assets/Sample2.controller 
Unity5.1.0f2 OK Code is This
using UnityEngine; 
using UnityEditor; 
using UnityEditor.Animations;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
//using UnityEditorInternal; 
public static class Simple2AnimatorController { 
	[MenuItem("Assets/Create Simple2AnimatorController")]
	public static void CreateAnimatorController ()
	{
		//非常に単純なAnimatorControllerを生成するEditor拡張コード
		//http://qiita.com/RyotaMurohoshi/items/c1f29f9afbce910c5438
		//OK
		//UnityEditor.Animations.AnimatorController animatorController = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath("Assets/Sample.controller");
		string path;
		path="Assets/Sample2.controller";
		UnityEditor.Animations.AnimatorController controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath(path);
		//http://docs.unity3d.com/ScriptReference/Animations.AnimatorController.html

		// Add parameters 
		//NG  UnityEngine.AnimatorControllerParameterType.Trigger
		//OK  UnityEditorInternal.AnimatorControllerParameterType.Trigger
		controller.AddParameter("myTrigger",UnityEngine.AnimatorControllerParameterType.Trigger);
		controller.AddParameter("Reset", AnimatorControllerParameterType.Trigger);
		controller.AddParameter("GotoB1", AnimatorControllerParameterType.Trigger);
		controller.AddParameter("GotoC", AnimatorControllerParameterType.Trigger);

		// Add StateMachines
		var rootStateMachine = controller.layers[0].stateMachine;
		var stateMachineA = rootStateMachine.AddStateMachine("smA");
		var stateMachineB = rootStateMachine.AddStateMachine("smB");
		var stateMachineC = stateMachineB.AddStateMachine("smC");

		// Add States
		var stateA1 = stateMachineA.AddState("stateA1");
		var stateB1 = stateMachineB.AddState("stateB1");
		var stateB2 = stateMachineB.AddState("stateB2");
		stateMachineC.AddState("stateC1");
		var stateC2 = stateMachineC.AddState("stateC2"); // don’t add an entry transition, should entry to state by default

		// Add Transitions
		var exitTransition = stateA1.AddExitTransition();
		exitTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "TransitionNow");
		exitTransition.duration = 0;

		var resetTransition = stateMachineA.AddAnyStateTransition(stateA1);
		resetTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "Reset");
		resetTransition.duration = 0;

		var transitionB1 = stateMachineB.AddEntryTransition(stateB1);
		transitionB1.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "GotoB1");
		stateMachineB.AddEntryTransition(stateB2);
		stateMachineC.defaultState = stateC2;
		var exitTransitionC2 = stateC2.AddExitTransition();
		exitTransitionC2.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "TransitionNow");
		exitTransitionC2.duration = 0;

		var stateMachineTransition = rootStateMachine.AddStateMachineTransition(stateMachineA, stateMachineC);
		stateMachineTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "GotoC");
		rootStateMachine.AddStateMachineTransition(stateMachineA, stateMachineB);
	}

}


 
| whaison | Unity3d | 17:07 | comments(0) | - | pookmark |
            
2015.06.19 Friday
2dtoolkitを拡張した2dtoolkitUVをつくってアトラスとCSVからUV座標を自動設定するよ。(更新)
2dtoolkitを拡張した2dtoolkitUVをつくってアトラスとCSVからUV座標を自動設定するよ。

http://mozzhukhin.net/post/105384157236/2d-animation-in-maya
さん

の2dtoolkitを拡張したよ
2dtoolkitUV download
http://www.mediafire.com/download/z1x91uoqlz9vysh/2dtoolkitUV.zip
2dtoolkitUV sample psd
http://www.mediafire.com/download/js0etxkjcbj57ws/2dtoolkitUV_sample_psd.zip
まず同じレイヤー名で2つPSDを作るよ
(PSD内で同じレイヤー名のものがあると)
executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );でとエラー吐くので注意!!!

キャラクターの形にならべたPSD



アトラス用にならべたPSD

を作ってください。

キャラクターの形にならべたPSD
を開いて
2dtoolkit
SmartExportLayers.jsx
実行

アトラス用にならべたPSD
開いて
2dtoolkitUV
SmartExportLayersTextureUVpos.jsx
実行

_Out.txt
_UVtextureOut.txt

ができてるよ。

アトラス用にならべたPSD
も透明のpngとtgaで保存しておいてね!

あとは

mayaで
enToolbar.mel
を実行したあと

enBuildUV.mel
を実行したら完成です。



 
| whaison | MEL(Maya Embedded Language) | 20:06 | comments(0) | - | pookmark |
            
2015.06.19 Friday
fbx の Animation は (ReadOnly)で Event 追加できないから別クリップにアニメーション保存


新作はこちら

http://whaison.jugem.jp/?eid=695

fbx の Animation は (ReadOnly)で Event 追加できないから別クリップにアニメーション保存 

FBXアニメーションデータを編集できるようにする - 頑張って続ける
http://d.hatena.ne.jp/maximilianahead/20120125/1327509943
さん
同じような事してるけどなんか違ったので
作った。

AnimationController を Animatorで開いて
BaseLayer  は FBX アニメーションで
EffectLayerはEventアニメーションで
ふたつとも同じTrigerで動かす前提。

こんなテキストファイルをunityにインポートしておいて使う

anim_01_wait,2,14,
anim_02_run,15,29,
anim_03_stance,30,59,
anim_04_block,60,69,
anim_05_damage,70,79,
anim_06_near_death,80,99,
anim_07_death,100,149,
anim_08_victory,150,169,
anim_09_attack,300,319,OnAnimStart,0,OnAnimEventEnd,1.0,OnAnimEventTrigger,0.33,OnAnimEventTrigger,0.66,
anim_10_skill,380,449,OnAnimStart,0,OnAnimEventEnd,1.0,OnAnimEventTrigger,0.33,OnAnimEventTrigger,0.66,
anim_11_state_poison,170,199,
anim_12_state_paralysis,170,199,
anim_13_state_damaged,170,199,
anim_14_state_delicate,170,199,
anim_15_state_sickness,170,199,
anim_16_state_damned,170,199,
anim_17_state_confusion,170,199,
anim_18_state_berserk,170,199,
anim_19_state_transform,200,229,
anim_20_state_minimum,170,199,


 
| whaison | Unity3d | 18:16 | comments(0) | - | pookmark |
            
2015.06.18 Thursday
透明png32[.png]から3Dソフトでよく使うアルファチャンネル付きTarga[.tga]を自動作成するJSXをこさえたよ。
透明png32[.png]から3Dソフトでよく使うアルファチャンネル付きTarga[.tga]を自動作成するJSXをこさえたよ。

http://www.mediafire.com/download/p4ol421aaad1i0k/pngToTga.jsx.zip








 
#target photoshop
//
// pngToTga.jsx
//
//
// Generated Thu Jun 18 2015 18:07:14 GMT+0900
//
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
//
//==================== pngToTga ==============
//
var myFilePathStr="";
var myFilePathArr=new Array();
var myFilePathDir="";
var myFileNameStr="";
var myFileNameArr=new Array();
var myFileNameDotArr=new Array();
var myCharacterBaseName="";
var TgaFilePath="";
function pngToTga() {
// //Tga保存先設定&#149;
function step0(){
//JSの場所
/*
const SELF = (function(){
try {app.documents.test()}
catch(e) {return File(e.fileName)}
})();
//$.writeln(SELF instanceof File);
// $.writeln(SELF);
// $.writeln(SELF.path)   
myFilePathStr=SELF.path;
$.writeln("myFilePathStr"+myFilePathStr+"")   
$.writeln("$.fileName"+$.fileName)   
*/
//Tga保存先設定
myFilePathDir = activeDocument.path;
$.writeln("myFilePathDir= "+myFilePathDir+"")   
myFileNameStr=activeDocument.name;
$.writeln("myFileNameStr= "+myFileNameStr+"")   
myFileNameArr=myFileNameStr.split ("_");
$.writeln("myFileNameArr= "+myFileNameArr+"")
myFileNameDotArr=myFileNameStr.split (".");
$.writeln("myFileNameArr.length= "+myFileNameArr.length+"")
if(myFileNameArr.length>1){
//ネームルール用
myCharacterBaseName=myFileNameArr[0]+"_"+myFileNameArr[1]+"_"+myFileNameArr[2]+"_";
$.writeln("myCharacterBaseName= "+myCharacterBaseName+"")   
TgaFilePath=myFilePathDir+"/"+myCharacterBaseName+"tga.tga";
}else{
//普通ファイル用
myCharacterBaseName=myFileNameDotArr[0]+"_";
$.writeln("myCharacterBaseName= "+myCharacterBaseName+"")   
TgaFilePath=myFilePathDir+"/"+myCharacterBaseName+"tga.tga";
}
$.writeln("TgaFilePath= "+TgaFilePath+"")   
}  
//TGAに保存する。
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var desc2 = new ActionDescriptor();
desc2.putInteger(cTID('BtDp'), 32);
desc2.putInteger(cTID('Cmpr'), 0);
desc1.putObject(cTID('As  '), cTID('TrgF'), desc2);
//desc1.putPath(cTID('In  '), new File("/Share/jsx_mel/Sotai/sd_0016_victoria/sd_0016_victoria_tga.tga"));
desc1.putPath(cTID('In  '), new File(TgaFilePath));
desc1.putInteger(cTID('DocI'), 2139);
desc1.putBoolean(cTID('Cpy '), true);
desc1.putBoolean(cTID('LwCs'), true);
executeAction(sTID('save'), desc1, dialogMode);
};
// 選択範囲 透明部分チャンネル
function step2(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Chnl'), sTID("selection"));
desc1.putReference(cTID('null'), ref1);
var ref2 = new ActionReference();
ref2.putEnumerated(cTID('Chnl'), cTID('Chnl'), cTID('Trsp'));
desc1.putReference(cTID('T   '), ref2);
executeAction(sTID('set'), desc1, dialogMode);
};
// 複製選択範囲 chara
function step3(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Chnl'), sTID("selection"));
desc1.putReference(cTID('null'), ref1);
desc1.putString(cTID('Nm  '), "chara");
executeAction(sTID('duplicate'), desc1, dialogMode);
};
// 作成レイヤー
function step4(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(cTID('Lyr '));
desc1.putReference(cTID('null'), ref1);
executeAction(sTID('make'), desc1, dialogMode);
};
// 選択範囲を反転
function step5(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
executeAction(sTID('inverse'), undefined, dialogMode);
};
// 描画色を黒に設定
function step6(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Clr '), cTID('FrgC'));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putUnitDouble(cTID('H   '), cTID('#Ang'), 359.994506835938);
desc2.putDouble(cTID('Strt'), 0);
desc2.putDouble(cTID('Brgh'), 0);
desc1.putObject(cTID('T   '), cTID('HSBC'), desc2);
desc1.putString(cTID('Srce'), "photoshopPicker");
executeAction(sTID('set'), desc1, dialogMode);
};
// 塗り潰し
function step7(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var desc2 = new ActionDescriptor();
desc2.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 1);
desc2.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 1);
desc1.putObject(cTID('From'), cTID('Pnt '), desc2);
desc1.putInteger(cTID('Tlrn'), 32);
desc1.putBoolean(cTID('AntA'), true);
desc1.putEnumerated(cTID('Usng'), cTID('FlCn'), cTID('FrgC'));
executeAction(sTID('fill'), desc1, dialogMode);
};
// レイヤーを作成
function step8(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(cTID('Lyr '));
desc1.putReference(cTID('null'), ref1);
executeAction(sTID('make'), desc1, dialogMode);
};
// 描画色の設定 白
function step9(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Clr '), cTID('FrgC'));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putUnitDouble(cTID('H   '), cTID('#Ang'), 359.994506835938);
desc2.putDouble(cTID('Strt'), 0);
desc2.putDouble(cTID('Brgh'), 100);
desc1.putObject(cTID('T   '), cTID('HSBC'), desc2);
desc1.putString(cTID('Srce'), "photoshopPicker");
executeAction(sTID('set'), desc1, dialogMode);
};
// 選択範囲すべて
function step10(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Chnl'), sTID("selection"));
desc1.putReference(cTID('null'), ref1);
desc1.putEnumerated(cTID('T   '), cTID('Ordn'), cTID('Al  '));
executeAction(sTID('set'), desc1, dialogMode);
};
//描画色 白で塗り潰し
function step11(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var desc2 = new ActionDescriptor();
desc2.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 1);
desc2.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 1);
desc1.putObject(cTID('From'), cTID('Pnt '), desc2);
desc1.putInteger(cTID('Tlrn'), 32);
desc1.putBoolean(cTID('AntA'), true);
desc1.putEnumerated(cTID('Usng'), cTID('FlCn'), cTID('FrgC'));
executeAction(sTID('fill'), desc1, dialogMode);
};
// 白で塗り潰したレイヤーを 黒の裏に移動
function step12(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
desc1.putReference(cTID('null'), ref1);
var ref2 = new ActionReference();
ref2.putIndex(cTID('Lyr '), 1);
desc1.putReference(cTID('T   '), ref2);
desc1.putBoolean(cTID('Adjs'), false);
desc1.putInteger(cTID('Vrsn'), 5);
executeAction(sTID('move'), desc1, dialogMode);
};
// レイヤー1の表示を使用しない
function step13(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(cTID('Lyr '), "レイヤー 1");
desc1.putReference(cTID('null'), ref1);
desc1.putBoolean(cTID('MkVs'), false);
executeAction(sTID('select'), desc1, dialogMode);
};
// レイヤーを結合&#135;
function step14(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
executeAction(sTID('mergeLayersNew'), desc1, dialogMode);
};
// 選択範囲すべて
function step15(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Chnl'), sTID("selection"));
desc1.putReference(cTID('null'), ref1);
desc1.putEnumerated(cTID('T   '), cTID('Ordn'), cTID('Al  '));
executeAction(sTID('set'), desc1, dialogMode);
};
//コピー
function step16(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
executeAction(sTID('copyEvent'), undefined, dialogMode);
};
// TGA開く
function step17(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
//desc1.putPath(cTID('null'), new File("/Share/jsx_mel/Sotai/sd_0016_victoria/sd_0016_victoria_tga.tga"));
desc1.putPath(cTID('null'), new File(TgaFilePath));
executeAction(sTID('open'), desc1, dialogMode);
};
// アルファチャンネル1選択
function step18(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(cTID('Chnl'), "アルファチャンネル 1");
desc1.putReference(cTID('null'), ref1);
executeAction(sTID('select'), desc1, dialogMode);
};
// 選択範囲すべて
function step19(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Chnl'), sTID("selection"));
desc1.putReference(cTID('null'), ref1);
desc1.putEnumerated(cTID('T   '), cTID('Ordn'), cTID('Al  '));
executeAction(sTID('set'), desc1, dialogMode);
};
// ペースト
function step20(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putEnumerated(cTID('AntA'), cTID('Annt'), cTID('Anno'));
executeAction(sTID('paste'), desc1, dialogMode);
};
// 表示:RGBチャンネル
function step21(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var list1 = new ActionList();
var ref1 = new ActionReference();
ref1.putEnumerated(cTID('Chnl'), cTID('Chnl'), cTID('Rd  '));
list1.putReference(ref1);
var ref2 = new ActionReference();
ref2.putEnumerated(cTID('Chnl'), cTID('Chnl'), cTID('Grn '));
list1.putReference(ref2);
var ref3 = new ActionReference();
ref3.putEnumerated(cTID('Chnl'), cTID('Chnl'), cTID('Bl  '));
list1.putReference(ref3);
desc1.putList(cTID('null'), list1);
executeAction(sTID('show'), desc1, dialogMode);
};
// 保存
function step22(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
executeAction(sTID('save'), undefined, dialogMode);
};
step0();      ////Tga保存先設定
step1();      //  //TGAに保存する。
step2();      //// 選択範囲 透明部分チャンネル
step3();      // // 複製選択範囲 chara
step4();      //// 作成レイヤー
step5();      //// 選択範囲を反転
step6();      //// 描画色を黒に設定
step7();      //// 塗り潰し
step8();      // // レイヤーを作成
step9();      // // 描画色の設定 白
step10();      //// 選択範囲すべて
step11();      ////描画色 白で塗り潰し
step12();      //// 白で塗り潰したレイヤーを 黒の裏に移動
step13();      // // レイヤー1の表示を使用しない
step14();      //// レイヤーを結合&#135;&#140;&#139;&#141;&#135;
step15();      //// 選択範囲すべて
step16();      ////コピー
step17();      //// TGA開く
step18();      // // アルファチャンネル1選択
step19();      //// 選択範囲すべて
step20();      //// ペースト
step21();      // // 表示:RGBチャンネル
step22();      // 保存
};
//=========================================
//                    pngToTga.main
//=========================================
//
pngToTga.main = function () {
pngToTga();
};
pngToTga.main();
// EOF
"pngToTga.jsx"
// EOF



変換元のatnはこんな内容
| whaison | jsx(ExtendScriptToolKit) | 19:31 | comments(0) | - | pookmark |
            
2015.06.18 Thursday
photoshop の Action の [.atn]をjsxへ変換する atn2js.jsx ActionToJavascript.jsxについて
photoshop の Action の [.atn]をjsxへ変換する atn2js.jsx ActionToJavascript.jsxについて 

ExtendScript Toolkit CC (ESTK CC 4.0.0.1)

http://sourceforge.net/projects/ps-scripts/files/xtools/v2.2betas/

xtools-2_2b1.zip


がダウンロードできるが
Macだと直下にフォルダ作っていれとく。
/Developer/xtools/xapps/ActionToJavascript.jsx
そのままじゃ動かなかった件

頭に
#target photoshop
いれれば動く

入れないと
//@include "xlib/xml/atn2bin.jsx" がエラーとか
DescValueType.ALIASTYPE がみつかりません。とか



動けばこんな感じ


変換される

。。
修正したものおいておく。
http://www.mediafire.com/download/7c426c6z16tukyy/xtools-2_2b1_whaison.zip
| whaison | jsx(ExtendScriptToolKit) | 16:49 | comments(0) | - | pookmark |
            
2015.06.16 Tuesday
Unity5.1.0f3でUnityで読み込んだ3Dモデルのアニメーションtake1分割してAnimationClipにEvent割当
Unity5.1.0f3でUnityで読み込んだ3Dモデルのアニメーションtake1分割してAnimationClipにEvent割当

http://asus4.hatenablog.com/entry/2013/03/05/134403
 

>3Dモデルのフレームアニメーションを、動作毎に分割する作業、とっても面倒でした。

>3Dモデルをもらって、Unityに持ってくるときにいちいち


Asus4 onD iboo (id:asus4)さんのEditerScriptを
ちょっと修正しているのでのせときます。

ModelAnimationSplitter

拡張子を.txtに変えたCSVファイルUnity内に置いて、 ModelAnimationSplitter.csをEditorフォルダに配置。

メニューバーの Tools->Model->Animation Splitter を選択するとウィンドウがでます。

3Dモデルと、CSVをドラッグして、スプリット!!


フォーマットはこんな感じ。簡単なので、すぐ出来ると思います。

anim_01_wait,2,14,
anim_02_run,15,29,
anim_03_stance,30,59,
anim_04_attack,60,79,
anim_05_skill,190,212,
anim_06_block,80,95,
anim_07_damage,100,109,
anim_08_near_death,110,129,
anim_09_state_abnormal,130,159,
anim_10_death,160,169,
anim_11_victory,170,189,


という
fr.txtを保存します。

| whaison | Unity3d | 11:30 | comments(0) | - | pookmark |