OSDN Git Service

fix io.write.
authorousttrue <ousttrue@gmail.com>
Sun, 13 Jun 2010 13:03:57 +0000 (22:03 +0900)
committerousttrue <ousttrue@gmail.com>
Sun, 13 Jun 2010 13:03:57 +0000 (22:03 +0900)
include/binary.h
include/pmd.h
src/binary.cpp
src/pmd.cpp
swig/blender/bl24.py
swig/blender/bl25.py
swig/pmd.i

index 78ee795..01a84f2 100644 (file)
@@ -148,6 +148,7 @@ class FileWriter : public IWriter
 
 public:
        FileWriter(const char *path);
+       FileWriter(const wchar_t *path);
        virtual ~FileWriter();
        virtual void write(const char *buf, unsigned int size);
 };
index 078bf8a..ed2c1e6 100644 (file)
@@ -265,6 +265,9 @@ struct BoneDisplayName
 {
        char name[50];
        char english_name[50];
+
+       void setName(const char *name);
+       void setEnglishName(const char *english);
 };
 
 ////////////////////////////////////////////////////////////
@@ -385,6 +388,7 @@ struct IO
        bool read(const wchar_t *path);
        bool write(binary::IWriter &writer);
        bool write(const char *path);
+       bool write(const wchar_t *path);
 
        const Vector2* getUV(int index)const;
        std::wstring getName()const;
index 198121a..229a98e 100644 (file)
@@ -124,6 +124,11 @@ FileWriter::FileWriter(const char *path)
        io_=fopen(path, "wb");
 }
 
+FileWriter::FileWriter(const wchar_t *path)
+{
+    io_=_wfopen(path, L"wb");
+}
+
 FileWriter::~FileWriter()
 {
        fclose(io_);
index 4616929..2a3d556 100644 (file)
@@ -693,11 +693,27 @@ bool IO::write(const char *path)
        return write(w);
 }
 
+bool IO::write(const wchar_t *path)
+{
+       binary::FileWriter w(path);
+       return write(w);
+}
+
 const Vector2* IO::getUV(int index)const
 {
        return &vertices[index].uv;
 }
 
+void BoneDisplayName::setName(const char *src)
+{
+       strncpy(name, src, 20);
+}
+
+void BoneDisplayName::setEnglishName(const char *src)
+{
+       strncpy(english_name, src, 20);
+}
+
 } // namespace
 } // namespace
 
index 1442b10..1819ac2 100644 (file)
@@ -38,7 +38,7 @@ class Writer(object):
 ###############################################################################
 class ProgressBar(object):
     def __init__(self, base):
-        print "#### %s ####" % base
+        print("#### %s ####" % base)
         self.base=base
         self.start=Blender.sys.time() 
         self.set('<start>', 0)
@@ -52,7 +52,7 @@ class ProgressBar(object):
         self._print(message)
 
     def _print(self, message):
-        print message
+        print(message)
         message="%s: %s" % (self.base, message)
         if message.__class__ is unicode:
             message=message.encode(FS_ENCODING)
index 1415e41..d3f74b3 100644 (file)
@@ -3,9 +3,19 @@ import bpy
 import mathutils
 
 import os
+import sys
 import time
 import functools
 
+# \e$B%U%!%$%k%7%9%F%`$NJ8;z%3!<%I\e(B
+# \e$B2~B$HG$H$N6&MQ$N$?$a\e(B
+FS_ENCODING=sys.getfilesystemencoding()
+if os.path.exists(os.path.dirname(sys.argv[0])+"/utf8"):
+    INTERNAL_ENCODING='utf-8'
+else:
+    INTERNAL_ENCODING=FS_ENCODING
+
+
 ###############################################################################
 # ProgressBar
 ###############################################################################
index 41c1d37..b75ef33 100644 (file)
@@ -24,6 +24,13 @@ using namespace pmd;
 %template(PBoneVector) std::vector<meshio::pmd::Bone*>;
 
 ///////////////////////////////////////////////////////////////////////////////
+// bytearray typemap
+///////////////////////////////////////////////////////////////////////////////
+%include <pybuffer.i>
+%pybuffer_string(const char *src);
+%pybuffer_string(const char *path);
+
+///////////////////////////////////////////////////////////////////////////////
 // meshio::pmd::IO::each_vertex
 ///////////////////////////////////////////////////////////////////////////////
 %inline %{
@@ -124,3 +131,4 @@ meshio::pmd::ToonTexture *getToonTexture(int index)
 }
 
 }
+