diff options
author | olamedia <[email protected]> | 2012-12-23 11:30:36 +0600 |
---|---|---|
committer | olamedia <[email protected]> | 2012-12-23 11:30:36 +0600 |
commit | f58bdfcb66353bb77213cab580bc49ef890417ad (patch) | |
tree | 2983a05d564891e92c115a679f9bfbf55465c755 /src/jp/nyatla/nymmd/struct | |
parent | 5320fd1dad5b77fa227e83fbbe0a958f2c5fc283 (diff) |
0.1.7
Diffstat (limited to 'src/jp/nyatla/nymmd/struct')
-rw-r--r-- | src/jp/nyatla/nymmd/struct/DataReader.java | 120 | ||||
-rw-r--r-- | src/jp/nyatla/nymmd/struct/StructReader.java | 82 | ||||
-rw-r--r-- | src/jp/nyatla/nymmd/struct/StructType.java | 48 | ||||
-rw-r--r-- | src/jp/nyatla/nymmd/struct/pmd/PMD_Bone.java | 66 | ||||
-rw-r--r-- | src/jp/nyatla/nymmd/struct/pmd/PMD_FACE.java | 74 | ||||
-rw-r--r-- | src/jp/nyatla/nymmd/struct/pmd/PMD_FACE_VTX.java | 75 | ||||
-rw-r--r-- | src/jp/nyatla/nymmd/struct/pmd/PMD_Header.java | 69 | ||||
-rw-r--r-- | src/jp/nyatla/nymmd/struct/pmd/PMD_IK.java | 83 | ||||
-rw-r--r-- | src/jp/nyatla/nymmd/struct/pmd/PMD_Material.java | 82 | ||||
-rw-r--r-- | src/jp/nyatla/nymmd/struct/pmd/PMD_Vertex.java | 78 | ||||
-rw-r--r-- | src/jp/nyatla/nymmd/struct/vmd/VMD_Face.java | 60 | ||||
-rw-r--r-- | src/jp/nyatla/nymmd/struct/vmd/VMD_Header.java | 63 | ||||
-rw-r--r-- | src/jp/nyatla/nymmd/struct/vmd/VMD_Motion.java | 94 |
13 files changed, 994 insertions, 0 deletions
diff --git a/src/jp/nyatla/nymmd/struct/DataReader.java b/src/jp/nyatla/nymmd/struct/DataReader.java new file mode 100644 index 0000000..fd0f86e --- /dev/null +++ b/src/jp/nyatla/nymmd/struct/DataReader.java @@ -0,0 +1,120 @@ +/*
+ * PROJECT: NyMmd
+ * --------------------------------------------------------------------------------
+ * The MMD for Java is Java version MMD Motion player class library.
+ * NyMmd is modules which removed the ARToolKit origin codes from ARTK_MMD,
+ * and was ported to Java.
+ *
+ * This is based on the ARTK_MMD v0.1 by PY.
+ * http://ppyy.if.land.to/artk_mmd.html
+ * py1024<at>gmail.com
+ * http://www.nicovideo.jp/watch/sm7398691
+ *
+ *
+ * The MIT License
+ * Copyright (C)2008-2012 nyatla
+ * nyatla39<at>gmail.com
+ * http://nyatla.jp
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.nyatla.nymmd.struct;
+
+import java.io.*;
+import java.nio.*;
+
+import jp.nyatla.nymmd.*;
+
+public class DataReader
+{
+ private ByteBuffer _buf;
+ public DataReader(InputStream i_stream) throws MmdException
+ {
+ try{
+ //コレなんとかしよう。C#のBinaryReaderみたいに振舞うように。
+ int file_len=i_stream.available();
+ if(file_len<1){
+ file_len=2*1024*1024;
+ }
+ byte[] buf=new byte[file_len];
+ int buf_len=i_stream.read(buf,0,file_len);
+ this._buf=ByteBuffer.wrap(buf,0,buf_len);
+ this._buf.order(ByteOrder.LITTLE_ENDIAN);
+ return;
+ }catch(Exception e){
+ throw new MmdException();
+ }
+ }
+ public int readByte()
+ {
+ return this._buf.get();
+ }
+ public int read()
+ {
+ int v=this._buf.get();
+ return (v>=0)?v:0xff+v;//unsignedに戻す
+ }
+ public short readShort()
+ {
+ return this._buf.getShort();
+ }
+ public int readUnsignedShort()
+ {
+ int v=this._buf.getShort();
+ return (v>=0)?v:0xffff+v;//unsignedに戻す
+ }
+ public int readInt()
+ {
+ return this._buf.getInt();
+ }
+ public float readFloat()
+ {
+ return this._buf.getFloat();
+ }
+ public double readDouble()
+ {
+ return this._buf.getDouble();
+ }
+ public String readAscii(int i_length) throws MmdException
+ {
+ try{
+ String ret="";
+ int len=0;
+ byte[] tmp=new byte[i_length];
+ int i;
+ for(i=0;i<i_length;i++){
+ byte b=this._buf.get();
+ if(b==0x00){
+ i++;
+ break;
+ }
+ tmp[i]=b;
+ len++;
+ }
+ ret=new String(tmp,0,len,"Shift_JIS");
+ for(;i<i_length;i++){
+ this._buf.get();
+ }
+ return ret;
+ }catch(Exception e){
+ throw new MmdException();
+ }
+ }
+}
diff --git a/src/jp/nyatla/nymmd/struct/StructReader.java b/src/jp/nyatla/nymmd/struct/StructReader.java new file mode 100644 index 0000000..4a5a658 --- /dev/null +++ b/src/jp/nyatla/nymmd/struct/StructReader.java @@ -0,0 +1,82 @@ +/*
+ * PROJECT: NyMmd
+ * --------------------------------------------------------------------------------
+ * The MMD for Java is Java version MMD Motion player class library.
+ * NyMmd is modules which removed the ARToolKit origin codes from ARTK_MMD,
+ * and was ported to Java.
+ *
+ * This is based on the ARTK_MMD v0.1 by PY.
+ * http://ppyy.if.land.to/artk_mmd.html
+ * py1024<at>gmail.com
+ * http://www.nicovideo.jp/watch/sm7398691
+ *
+ *
+ * The MIT License
+ * Copyright (C)2008-2012 nyatla
+ * nyatla39<at>gmail.com
+ * http://nyatla.jp
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.nyatla.nymmd.struct;
+
+
+import jp.nyatla.nymmd.MmdException;
+import jp.nyatla.nymmd.types.*;
+
+public class StructReader
+{
+ public static void read(MmdColor4 i_dest,DataReader i_reader) throws MmdException
+ {
+ i_dest.r=i_reader.readFloat();
+ i_dest.g=i_reader.readFloat();
+ i_dest.b=i_reader.readFloat();
+ i_dest.a=i_reader.readFloat();
+ return;
+ }
+ public static void read(MmdColor3 i_dest,DataReader i_reader) throws MmdException
+ {
+ i_dest.r=i_reader.readFloat();
+ i_dest.g=i_reader.readFloat();
+ i_dest.b=i_reader.readFloat();
+ return;
+ }
+ public static void read(MmdTexUV i_dest,DataReader i_reader) throws MmdException
+ {
+ i_dest.u=i_reader.readFloat();
+ i_dest.v=i_reader.readFloat();
+ return;
+ }
+ public static void read(MmdVector3 i_dest,DataReader i_reader) throws MmdException
+ {
+ i_dest.x=i_reader.readFloat();
+ i_dest.y=i_reader.readFloat();
+ i_dest.z=i_reader.readFloat();
+ return;
+ }
+ public static void read(MmdVector4 i_dest,DataReader i_reader) throws MmdException
+ {
+ i_dest.x=i_reader.readFloat();
+ i_dest.y=i_reader.readFloat();
+ i_dest.z=i_reader.readFloat();
+ i_dest.w=i_reader.readFloat();
+ return;
+ }
+}
diff --git a/src/jp/nyatla/nymmd/struct/StructType.java b/src/jp/nyatla/nymmd/struct/StructType.java new file mode 100644 index 0000000..27f19fa --- /dev/null +++ b/src/jp/nyatla/nymmd/struct/StructType.java @@ -0,0 +1,48 @@ +/*
+ * PROJECT: NyMmd
+ * --------------------------------------------------------------------------------
+ * The MMD for Java is Java version MMD Motion player class library.
+ * NyMmd is modules which removed the ARToolKit origin codes from ARTK_MMD,
+ * and was ported to Java.
+ *
+ * This is based on the ARTK_MMD v0.1 by PY.
+ * http://ppyy.if.land.to/artk_mmd.html
+ * py1024<at>gmail.com
+ * http://www.nicovideo.jp/watch/sm7398691
+ *
+ *
+ * The MIT License
+ * Copyright (C)2008-2012 nyatla
+ * nyatla39<at>gmail.com
+ * http://nyatla.jp
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.nyatla.nymmd.struct;
+
+
+
+import jp.nyatla.nymmd.MmdException;
+
+public interface StructType
+{
+ public void read(DataReader i_reader) throws MmdException;
+
+}
diff --git a/src/jp/nyatla/nymmd/struct/pmd/PMD_Bone.java b/src/jp/nyatla/nymmd/struct/pmd/PMD_Bone.java new file mode 100644 index 0000000..cb949d5 --- /dev/null +++ b/src/jp/nyatla/nymmd/struct/pmd/PMD_Bone.java @@ -0,0 +1,66 @@ +/*
+ * PROJECT: NyMmd
+ * --------------------------------------------------------------------------------
+ * The MMD for Java is Java version MMD Motion player class library.
+ * NyMmd is modules which removed the ARToolKit origin codes from ARTK_MMD,
+ * and was ported to Java.
+ *
+ * This is based on the ARTK_MMD v0.1 by PY.
+ * http://ppyy.if.land.to/artk_mmd.html
+ * py1024<at>gmail.com
+ * http://www.nicovideo.jp/watch/sm7398691
+ *
+ *
+ * The MIT License
+ * Copyright (C)2008-2012 nyatla
+ * nyatla39<at>gmail.com
+ * http://nyatla.jp
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.nyatla.nymmd.struct.pmd;
+
+
+
+import jp.nyatla.nymmd.MmdException;
+import jp.nyatla.nymmd.struct.*;
+import jp.nyatla.nymmd.types.MmdVector3;
+
+public class PMD_Bone implements StructType
+{
+ public String szName; // ボーン名 (0x00 終端,余白は 0xFD)
+ public int nParentNo; // 親ボーン番号 (なければ -1)
+ public int nChildNo; // 子ボーン番号
+ public int cbKind; // ボーンの種類
+ public int unIKTarget; // IK時のターゲットボーン
+ public final MmdVector3 vec3Position=new MmdVector3(); // モデル原点からの位置
+
+ public void read(DataReader i_reader) throws MmdException
+ {
+ //szName
+ this.szName=i_reader.readAscii(20);
+ this.nParentNo=i_reader.readShort();
+ this.nChildNo=i_reader.readShort();
+ this.cbKind=i_reader.readByte();
+ this.unIKTarget=i_reader.readShort();
+ StructReader.read(this.vec3Position, i_reader);
+ return;
+ }
+}
diff --git a/src/jp/nyatla/nymmd/struct/pmd/PMD_FACE.java b/src/jp/nyatla/nymmd/struct/pmd/PMD_FACE.java new file mode 100644 index 0000000..e2c4f5c --- /dev/null +++ b/src/jp/nyatla/nymmd/struct/pmd/PMD_FACE.java @@ -0,0 +1,74 @@ +/*
+ * PROJECT: NyMmd
+ * --------------------------------------------------------------------------------
+ * The MMD for Java is Java version MMD Motion player class library.
+ * NyMmd is modules which removed the ARToolKit origin codes from ARTK_MMD,
+ * and was ported to Java.
+ *
+ * This is based on the ARTK_MMD v0.1 by PY.
+ * http://ppyy.if.land.to/artk_mmd.html
+ * py1024<at>gmail.com
+ * http://www.nicovideo.jp/watch/sm7398691
+ *
+ *
+ * The MIT License
+ * Copyright (C)2008-2012 nyatla
+ * nyatla39<at>gmail.com
+ * http://nyatla.jp
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.nyatla.nymmd.struct.pmd;
+
+
+import jp.nyatla.nymmd.MmdException;
+import jp.nyatla.nymmd.struct.*;
+
+public class PMD_FACE implements StructType
+{
+ public String szName; // 表情名 (0x00 終端,余白は 0xFD)
+ public int ulNumVertices; // 表情頂点数
+ public int cbType; // 分類
+ public PMD_FACE_VTX [] pVertices=PMD_FACE_VTX.createArray(64);// 表情頂点データ
+ public void read(DataReader i_reader) throws MmdException
+ {
+ int i;
+ //szName
+ this.szName=i_reader.readAscii(20);
+ this.ulNumVertices=i_reader.readInt();
+ this.cbType=i_reader.read();
+ //必要な数だけ配列を確保しなおす。
+ if(this.ulNumVertices>this.pVertices.length){
+ this.pVertices=PMD_FACE_VTX.createArray(this.ulNumVertices);
+ }
+ for(i=0;i<this.ulNumVertices;i++){
+ this.pVertices[i].read(i_reader);
+ }
+ return;
+ }
+/*
+ char szName[20]; // 表情名 (0x00 終端,余白は 0xFD)
+
+ unsigned long ulNumVertices; // 表情頂点数
+ unsigned char cbType; // 分類
+
+ PMD_FACE_VTX pVertices[1]; // 表情頂点データ
+*/
+}
diff --git a/src/jp/nyatla/nymmd/struct/pmd/PMD_FACE_VTX.java b/src/jp/nyatla/nymmd/struct/pmd/PMD_FACE_VTX.java new file mode 100644 index 0000000..6581be1 --- /dev/null +++ b/src/jp/nyatla/nymmd/struct/pmd/PMD_FACE_VTX.java @@ -0,0 +1,75 @@ +/*
+ * PROJECT: NyMmd
+ * --------------------------------------------------------------------------------
+ * The MMD for Java is Java version MMD Motion player class library.
+ * NyMmd is modules which removed the ARToolKit origin codes from ARTK_MMD,
+ * and was ported to Java.
+ *
+ * This is based on the ARTK_MMD v0.1 by PY.
+ * http://ppyy.if.land.to/artk_mmd.html
+ * py1024<at>gmail.com
+ * http://www.nicovideo.jp/watch/sm7398691
+ *
+ *
+ * The MIT License
+ * Copyright (C)2008-2012 nyatla
+ * nyatla39<at>gmail.com
+ * http://nyatla.jp
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.nyatla.nymmd.struct.pmd;
+
+
+import jp.nyatla.nymmd.*;
+import jp.nyatla.nymmd.struct.*;
+import jp.nyatla.nymmd.types.MmdVector3;
+public class PMD_FACE_VTX implements StructType
+{
+ public int ulIndex;
+ public MmdVector3 vec3Pos=new MmdVector3();
+ public void read(DataReader i_reader) throws MmdException
+ {
+ this.ulIndex=i_reader.readInt();
+ StructReader.read(this.vec3Pos, i_reader);
+ return;
+ }
+ public static PMD_FACE_VTX[] createArray(int i_length)
+ {
+ PMD_FACE_VTX[] ret=new PMD_FACE_VTX[i_length];
+ for(int i=0;i<i_length;i++)
+ {
+ ret[i]=new PMD_FACE_VTX();
+ }
+ return ret;
+ }
+ public void setValue(PMD_FACE_VTX i_value)
+ {
+ this.ulIndex=i_value.ulIndex;
+ this.vec3Pos.setValue(i_value.vec3Pos);
+ return;
+ }
+
+
+/*
+ unsigned long ulIndex;
+ Vector3 vec3Pos;
+*/
+}
diff --git a/src/jp/nyatla/nymmd/struct/pmd/PMD_Header.java b/src/jp/nyatla/nymmd/struct/pmd/PMD_Header.java new file mode 100644 index 0000000..a5b5863 --- /dev/null +++ b/src/jp/nyatla/nymmd/struct/pmd/PMD_Header.java @@ -0,0 +1,69 @@ +/*
+ * PROJECT: NyMmd
+ * --------------------------------------------------------------------------------
+ * The MMD for Java is Java version MMD Motion player class library.
+ * NyMmd is modules which removed the ARToolKit origin codes from ARTK_MMD,
+ * and was ported to Java.
+ *
+ * This is based on the ARTK_MMD v0.1 by PY.
+ * http://ppyy.if.land.to/artk_mmd.html
+ * py1024<at>gmail.com
+ * http://www.nicovideo.jp/watch/sm7398691
+ *
+ *
+ * The MIT License
+ * Copyright (C)2008-2012 nyatla
+ * nyatla39<at>gmail.com
+ * http://nyatla.jp
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.nyatla.nymmd.struct.pmd;
+
+import jp.nyatla.nymmd.*;
+import jp.nyatla.nymmd.struct.*;
+
+public class PMD_Header implements StructType
+{
+ public final static int SIZE_OF_STRUCT=3+4+20+256;
+ public String szMagic;
+ public float fVersion;
+ public String szName;
+ public String szComment;
+
+ public void read(DataReader i_reader) throws MmdException
+ {
+ this.szMagic=i_reader.readAscii(3);
+ //
+ this.fVersion=i_reader.readFloat();
+ //szName
+ this.szName=i_reader.readAscii(20);
+
+ //szComment
+ this.szComment=i_reader.readAscii(256);
+ return;
+ }
+/*
+ char szMagic[3]; // "Pmd"
+ float fVersion; // PMDバージョン番号
+ char szName[20]; // モデル名
+ char szComment[256]; // コメント(著作権表示など)
+*/
+}
diff --git a/src/jp/nyatla/nymmd/struct/pmd/PMD_IK.java b/src/jp/nyatla/nymmd/struct/pmd/PMD_IK.java new file mode 100644 index 0000000..d5fceea --- /dev/null +++ b/src/jp/nyatla/nymmd/struct/pmd/PMD_IK.java @@ -0,0 +1,83 @@ +/*
+ * PROJECT: NyMmd
+ * --------------------------------------------------------------------------------
+ * The MMD for Java is Java version MMD Motion player class library.
+ * NyMmd is modules which removed the ARToolKit origin codes from ARTK_MMD,
+ * and was ported to Java.
+ *
+ * This is based on the ARTK_MMD v0.1 by PY.
+ * http://ppyy.if.land.to/artk_mmd.html
+ * py1024<at>gmail.com
+ * http://www.nicovideo.jp/watch/sm7398691
+ *
+ *
+ * The MIT License
+ * Copyright (C)2008-2012 nyatla
+ * nyatla39<at>gmail.com
+ * http://nyatla.jp
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.nyatla.nymmd.struct.pmd;
+
+
+
+import jp.nyatla.nymmd.MmdException;
+import jp.nyatla.nymmd.struct.DataReader;
+import jp.nyatla.nymmd.struct.StructType;
+
+public class PMD_IK implements StructType
+{
+ public int nTargetNo; // IKターゲットボーン番号
+ public int nEffNo; // IK先端ボーン番号
+ public int cbNumLink; // IKを構成するボーンの数
+ public int unCount;
+ public float fFact;
+ public int[] punLinkNo;// IKを構成するボーンの配列(可変長配列)
+
+ public void read(DataReader i_reader) throws MmdException
+ {
+ this.nTargetNo=i_reader.readShort();
+ this.nEffNo=i_reader.readShort();
+ this.cbNumLink=i_reader.read();
+ this.unCount=i_reader.readUnsignedShort();
+ this.fFact=i_reader.readFloat();
+ //必要な数だけ配列を確保しなおす。
+ this.punLinkNo=new int[this.cbNumLink];
+ for(int i=0;i<this.cbNumLink;i++){
+ this.punLinkNo[i]=i_reader.readUnsignedShort();
+ }
+ return;
+ }
+
+
+
+/*
+ short nTargetNo; // IKターゲットボーン番号
+ short nEffNo; // IK先端ボーン番号
+
+ unsigned char cbNumLink; // IKを構成するボーンの数
+
+ unsigned short unCount;
+ float fFact;
+
+ unsigned short punLinkNo[1];// IKを構成するボーンの配列
+*/
+}
diff --git a/src/jp/nyatla/nymmd/struct/pmd/PMD_Material.java b/src/jp/nyatla/nymmd/struct/pmd/PMD_Material.java new file mode 100644 index 0000000..6d5e97c --- /dev/null +++ b/src/jp/nyatla/nymmd/struct/pmd/PMD_Material.java @@ -0,0 +1,82 @@ +/*
+ * PROJECT: NyMmd
+ * --------------------------------------------------------------------------------
+ * The MMD for Java is Java version MMD Motion player class library.
+ * NyMmd is modules which removed the ARToolKit origin codes from ARTK_MMD,
+ * and was ported to Java.
+ *
+ * This is based on the ARTK_MMD v0.1 by PY.
+ * http://ppyy.if.land.to/artk_mmd.html
+ * py1024<at>gmail.com
+ * http://www.nicovideo.jp/watch/sm7398691
+ *
+ *
+ * The MIT License
+ * Copyright (C)2008-2012 nyatla
+ * nyatla39<at>gmail.com
+ * http://nyatla.jp
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.nyatla.nymmd.struct.pmd;
+
+import jp.nyatla.nymmd.MmdException;
+import jp.nyatla.nymmd.struct.DataReader;
+import jp.nyatla.nymmd.struct.StructReader;
+import jp.nyatla.nymmd.struct.StructType;
+import jp.nyatla.nymmd.types.MmdColor3;
+import jp.nyatla.nymmd.types.MmdColor4;
+
+public class PMD_Material implements StructType {
+ public final MmdColor4 col4Diffuse = new MmdColor4();
+ public float fShininess;
+ public final MmdColor3 col3Specular = new MmdColor3();
+ public final MmdColor3 col3Ambient = new MmdColor3();
+ public int unknown;
+ public int toon;
+ public int edgeFlag;
+ public int ulNumIndices; // この材質に対応する頂点数
+ public String szTextureFileName; // テクスチャファイル名
+ public String szSphFileName; // テクスチャファイル名
+
+ public void read(DataReader i_reader) throws MmdException {
+ StructReader.read(this.col4Diffuse, i_reader);
+ this.fShininess = i_reader.readFloat();
+ StructReader.read(this.col3Specular, i_reader);
+ StructReader.read(this.col3Ambient, i_reader);
+ toon = i_reader.readByte();
+ edgeFlag = i_reader.readByte();
+ // this.unknown = i_reader.readUnsignedShort();
+ this.ulNumIndices = i_reader.readInt();
+ this.szTextureFileName = i_reader.readAscii(20);
+ return;
+ }
+ /*
+ * Color4 col4Diffuse;
+ * float fShininess;
+ * Color3 col3Specular,
+ * col3Ambient;
+ *
+ * unsigned short unknown;
+ * unsigned long ulNumIndices; // この材質に対応する頂点数
+ * char szTextureFileName[20]; // テクスチャファイル名
+ */
+
+}
diff --git a/src/jp/nyatla/nymmd/struct/pmd/PMD_Vertex.java b/src/jp/nyatla/nymmd/struct/pmd/PMD_Vertex.java new file mode 100644 index 0000000..efc425d --- /dev/null +++ b/src/jp/nyatla/nymmd/struct/pmd/PMD_Vertex.java @@ -0,0 +1,78 @@ +/*
+ * PROJECT: NyMmd
+ * --------------------------------------------------------------------------------
+ * The MMD for Java is Java version MMD Motion player class library.
+ * NyMmd is modules which removed the ARToolKit origin codes from ARTK_MMD,
+ * and was ported to Java.
+ *
+ * This is based on the ARTK_MMD v0.1 by PY.
+ * http://ppyy.if.land.to/artk_mmd.html
+ * py1024<at>gmail.com
+ * http://www.nicovideo.jp/watch/sm7398691
+ *
+ *
+ * The MIT License
+ * Copyright (C)2008-2012 nyatla
+ * nyatla39<at>gmail.com
+ * http://nyatla.jp
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.nyatla.nymmd.struct.pmd;
+
+
+import jp.nyatla.nymmd.MmdException;
+import jp.nyatla.nymmd.struct.DataReader;
+import jp.nyatla.nymmd.struct.StructReader;
+import jp.nyatla.nymmd.struct.StructType;
+import jp.nyatla.nymmd.types.MmdTexUV;
+import jp.nyatla.nymmd.types.MmdVector3;
+
+public class PMD_Vertex implements StructType
+{
+ public MmdVector3 vec3Pos=new MmdVector3(); // 座標
+ public MmdVector3 vec3Normal=new MmdVector3(); // 法線ベクトル
+ public MmdTexUV uvTex=new MmdTexUV(); // テクスチャ座標
+
+ public int[] unBoneNo=new int[2]; // ボーン番号
+ public int cbWeight; // ブレンドの重み (0~100%)
+ public int cbEdge; // エッジフラグ
+/*
+ Vector3 vec3Pos; // 座標
+ Vector3 vec3Normal; // 法線ベクトル
+ TexUV uvTex; // テクスチャ座標
+
+ unsigned short unBoneNo[2]; // ボーン番号
+ unsigned char cbWeight; // ブレンドの重み (0~100%)
+ unsigned char cbEdge; // エッジフラグ
+*/
+ public void read(DataReader i_reader) throws MmdException
+ {
+ StructReader.read(this.vec3Pos, i_reader);
+ StructReader.read(this.vec3Normal, i_reader);
+ StructReader.read(this.uvTex, i_reader);
+ this.unBoneNo[0]=i_reader.readUnsignedShort();
+ this.unBoneNo[1]=i_reader.readUnsignedShort();
+ this.cbWeight=i_reader.read();
+ this.cbEdge=i_reader.read();
+ return;
+ }
+
+}
diff --git a/src/jp/nyatla/nymmd/struct/vmd/VMD_Face.java b/src/jp/nyatla/nymmd/struct/vmd/VMD_Face.java new file mode 100644 index 0000000..d78ddbe --- /dev/null +++ b/src/jp/nyatla/nymmd/struct/vmd/VMD_Face.java @@ -0,0 +1,60 @@ +/*
+ * PROJECT: NyMmd
+ * --------------------------------------------------------------------------------
+ * The MMD for Java is Java version MMD Motion player class library.
+ * NyMmd is modules which removed the ARToolKit origin codes from ARTK_MMD,
+ * and was ported to Java.
+ *
+ * This is based on the ARTK_MMD v0.1 by PY.
+ * http://ppyy.if.land.to/artk_mmd.html
+ * py1024<at>gmail.com
+ * http://www.nicovideo.jp/watch/sm7398691
+ *
+ *
+ * The MIT License
+ * Copyright (C)2008-2012 nyatla
+ * nyatla39<at>gmail.com
+ * http://nyatla.jp
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.nyatla.nymmd.struct.vmd;
+
+
+
+import jp.nyatla.nymmd.MmdException;
+import jp.nyatla.nymmd.struct.DataReader;
+import jp.nyatla.nymmd.struct.StructType;
+
+public class VMD_Face implements StructType
+{
+ public String szFaceName;
+ public long ulFrameNo;
+ public float fFactor;
+ public void read(DataReader i_reader) throws MmdException
+ {
+ //szFaceName
+ this.szFaceName=i_reader.readAscii(15);
+ this.ulFrameNo=i_reader.readInt();
+ this.fFactor=i_reader.readFloat();
+ return;
+ }
+
+}
diff --git a/src/jp/nyatla/nymmd/struct/vmd/VMD_Header.java b/src/jp/nyatla/nymmd/struct/vmd/VMD_Header.java new file mode 100644 index 0000000..5a61aa7 --- /dev/null +++ b/src/jp/nyatla/nymmd/struct/vmd/VMD_Header.java @@ -0,0 +1,63 @@ +/*
+ * PROJECT: NyMmd
+ * --------------------------------------------------------------------------------
+ * The MMD for Java is Java version MMD Motion player class library.
+ * NyMmd is modules which removed the ARToolKit origin codes from ARTK_MMD,
+ * and was ported to Java.
+ *
+ * This is based on the ARTK_MMD v0.1 by PY.
+ * http://ppyy.if.land.to/artk_mmd.html
+ * py1024<at>gmail.com
+ * http://www.nicovideo.jp/watch/sm7398691
+ *
+ *
+ * The MIT License
+ * Copyright (C)2008-2012 nyatla
+ * nyatla39<at>gmail.com
+ * http://nyatla.jp
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.nyatla.nymmd.struct.vmd;
+
+
+import jp.nyatla.nymmd.MmdException;
+import jp.nyatla.nymmd.struct.DataReader;
+import jp.nyatla.nymmd.struct.StructType;
+
+public class VMD_Header implements StructType
+{
+ public String szHeader;
+ public String szModelName;
+ public void read(DataReader i_reader) throws MmdException
+ {
+ //szHeader
+ this.szHeader=i_reader.readAscii(30);
+ //szModelName
+ this.szModelName=i_reader.readAscii(20);
+ return;
+ }
+
+
+/*
+ char szHeader[30]; // "Vocaloid Motion Data 0002"
+ char szModelName[20]; // 対象モデル名
+*/
+}
diff --git a/src/jp/nyatla/nymmd/struct/vmd/VMD_Motion.java b/src/jp/nyatla/nymmd/struct/vmd/VMD_Motion.java new file mode 100644 index 0000000..10512cf --- /dev/null +++ b/src/jp/nyatla/nymmd/struct/vmd/VMD_Motion.java @@ -0,0 +1,94 @@ +/*
+ * PROJECT: NyMmd
+ * --------------------------------------------------------------------------------
+ * The MMD for Java is Java version MMD Motion player class library.
+ * NyMmd is modules which removed the ARToolKit origin codes from ARTK_MMD,
+ * and was ported to Java.
+ *
+ * This is based on the ARTK_MMD v0.1 by PY.
+ * http://ppyy.if.land.to/artk_mmd.html
+ * py1024<at>gmail.com
+ * http://www.nicovideo.jp/watch/sm7398691
+ *
+ *
+ * The MIT License
+ * Copyright (C)2008-2012 nyatla
+ * nyatla39<at>gmail.com
+ * http://nyatla.jp
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.nyatla.nymmd.struct.vmd;
+
+
+import jp.nyatla.nymmd.MmdException;
+import jp.nyatla.nymmd.struct.*;
+import jp.nyatla.nymmd.types.MmdVector3;
+import jp.nyatla.nymmd.types.MmdVector4;
+public class VMD_Motion implements StructType
+{
+ public String szBoneName; // ボーン名
+ public long ulFrameNo; // フレーム番号
+
+ public final MmdVector3 vec3Position=new MmdVector3();// 位置
+ public final MmdVector4 vec4Rotate=new MmdVector4(); // 回転(クォータニオン)
+
+ public final int[] cInterpolation1=new int[16]; // 補間情報
+ public final int[] cInterpolation2=new int[16];
+ public final int[] cInterpolation3=new int[16];
+ public final int[] cInterpolation4=new int[16];
+
+ public void read(DataReader i_reader) throws MmdException
+ {
+ int i;
+ //szName
+ this.szBoneName=i_reader.readAscii(15);
+ this.ulFrameNo=i_reader.readInt();
+ StructReader.read(this.vec3Position, i_reader);
+ StructReader.read(this.vec4Rotate,i_reader);
+ for(i=0;i<16;i++){
+ this.cInterpolation1[i]=i_reader.readByte();
+ }
+ for(i=0;i<16;i++){
+ this.cInterpolation2[i]=i_reader.readByte();
+ }
+ for(i=0;i<16;i++){
+ this.cInterpolation3[i]=i_reader.readByte();
+ }
+ for(i=0;i<16;i++){
+ this.cInterpolation4[i]=i_reader.readByte();
+ }
+ return;
+ }
+
+/*
+ char szBoneName[15]; // ボーン名
+
+ unsigned long ulFrameNo; // フレーム番号
+
+ Vector3 vec3Position; // 位置
+ Vector4 vec4Rotate; // 回転(クォータニオン)
+
+ char cInterpolation1[16]; // 補間情報
+ char cInterpolation2[16];
+ char cInterpolation3[16];
+ char cInterpolation4[16];
+*/
+}
|