JunkBox_Lib++ (for Windows) 1.10.1
Loading...
Searching...
No Matches
ColladaXML Class Reference

#include <ColladaTool.h>

Collaboration diagram for ColladaXML:

Public Member Functions

 ColladaXML (double meter=1.0, int axis=COLLADA_Z_UP, const char *ver=NULL)
 
 ColladaXML (float meter, int axis=COLLADA_Z_UP, const char *ver=NULL)
 
virtual ~ColladaXML (void)
 
void init (double meter=1.0, int axis=COLLADA_Z_UP, const char *ver=NULL)
 
void init (float meter, int axis=COLLADA_Z_UP, const char *ver=NULL)
 
void clear (double meter=1.0, int axis=COLLADA_Z_UP, const char *ver=NULL)
 
void clear (float meter, int axis=COLLADA_Z_UP, const char *ver=NULL)
 
void free (void)
 
void outputFile (const char *fn, const char *path=NULL, int mode=XML_SPACE_FORMAT)
 
void output_dae (FILE *fp, int mode=XML_SPACE_FORMAT)
 
void output_tree (FILE *fp)
 
void initCollada (double meter, int axis, const char *ver)
 
void initCollada (float meter, int axis, const char *ver)
 
void addShell (MeshObjectData *shelldata, bool collider, SkinJointData *skin_joint=NULL, tXML *joints_template=NULL)
 
char * addGeometry (MeshObjectData *shelldata)
 
char * addController (const char *geometry_id, MeshObjectData *shelldata, SkinJointData *skin_joint)
 
void addScene (const char *geometry_id, char *controll_id, MeshObjectData *shelldata, bool collider, SkinJointData *skin_joint)
 
char * addVertexSource (tXML *tag, MeshObjectData *shelldata)
 
char * addNormalSource (tXML *tag, MeshObjectData *shelldata)
 
char * addTexcrdSource (tXML *tag, MeshObjectData *shelldata)
 
char * addWeightSource (tXML *tag, MeshObjectData *shelldata, Vector< int > *weight_index, int num_joints)
 
char * addVerticesPos (tXML *mesh_tag, const char *position_id)
 
void addSimpleTechniqueAccessor (tXML *source_tag, const char *source_array_id, int count, int stride, const char *name, const char *type)
 
void addPosTechniqueAccessor (tXML *source_tag, const char *source_array_id, int count)
 
void addMapTechniqueAccessor (tXML *source_tag, const char *source_array_id, int count)
 
void addPolylists (tXML *mesh_tag, MeshObjectData *shelldata, const char *vertex_id, const char *normal_id=NULL, const char *texcrd_id=NULL)
 
char * addImage (const char *filename)
 
char * addMaterial (const char *material)
 
tXMLaddEffect (const char *material_url, const char *file_id, MaterialParam param)
 
void addExtraBumpmap (tXML *effect_tag, const char *bump_id)
 
void closeSolid (void)
 
void deleteJoint (tXML *delete_tag)
 
bool existSameID (tXML *top, const char *tag, const char *id)
 
void setBlankTexture (const char *name)
 
bool isBlankTexture (const char *name)
 
void setJointLocationMatrix (void)
 
void deleteNousedJoints (tXML *delete_tag)
 
void deleteListJoints (tXML *top_tag, tList *joints_name)
 
void addCenterObject (void)
 
void addCenterScene (void)
 

Public Attributes

tXMLxml_tag
 
tXMLcollada_tag
 
tXMLasset_tag
 
tXMLcontributor_tag
 
tXMLauthor_tag
 
tXMLauthoring_tool_tag
 
tXMLcreated_tag
 
tXMLmodified_tag
 
tXMLunit_tag
 
tXMLup_axis_tag
 
tXMLlibrary_images_tag
 
tXMLlibrary_effects_tag
 
tXMLlibrary_materials_tag
 
tXMLlibrary_geometries_tag
 
tXMLlibrary_controllers_tag
 
tXMLlibrary_physics_scenes_tag
 
tXMLlibrary_physics_models_tag
 
tXMLlibrary_visual_scenes_tag
 
tXMLinstance_physics_model_tag
 
tXMLvisual_scene_tag
 
tXMLphysics_scene_tag
 
tXMLphysics_model_tag
 
tXMLscene_tag
 
tXMLinstance_visual_scene_tag
 
tXMLinstance_physics_scene_tag
 
AffineTrans< double > * affineTrans
 
AffineTrans< double > affineSkeleton
 
tXMLjoints_template_tag
 
bool added_joints_xml
 
bool has_joints
 
bool no_offset
 
bool phantom_out
 
Buffer blank_texture
 
bool forUnity5
 
bool forUnity
 

Detailed Description

Definition at line 35 of file ColladaTool.h.

Constructor & Destructor Documentation

◆ ColladaXML() [1/2]

ColladaXML ( double meter = 1.0,
int axis = COLLADA_Z_UP,
const char * ver = NULL )
inline

Definition at line 38 of file ColladaTool.h.

38{ init(meter, axis, ver);}
void init(double meter=1.0, int axis=COLLADA_Z_UP, const char *ver=NULL)

References ColladaXML::init().

Here is the call graph for this function:

◆ ColladaXML() [2/2]

ColladaXML ( float meter,
int axis = COLLADA_Z_UP,
const char * ver = NULL )
inline

Definition at line 39 of file ColladaTool.h.

39{ init(meter, axis, ver);}

References ColladaXML::init().

Here is the call graph for this function:

◆ ~ColladaXML()

~ColladaXML ( void )
virtual

Definition at line 17 of file ColladaTool.cpp.

18{
19 DEBUG_MODE PRINT_MESG("ColladaXML::DESTRUCTOR:\n");
20}
#define PRINT_MESG(...)
環境依存用の出力関数.MS Windows用は未実装
Definition tools.h:469
#define DEBUG_MODE
Definition tools.h:502

References DEBUG_MODE, and PRINT_MESG.

Member Function Documentation

◆ addCenterObject()

void addCenterObject ( void )

Definition at line 1304 of file ColladaTool.cpp.

1305{
1307 return;
1308}
void addCenterScene(void)

References ColladaXML::addCenterScene().

Here is the call graph for this function:

◆ addCenterScene()

void addCenterScene ( void )

Definition at line 1312 of file ColladaTool.cpp.

1313{
1314 tXML* node_tag = add_xml_node(this->visual_scene_tag, "node");
1315 add_xml_attr_str(node_tag, "id", "#NODE_DUMMY");
1316 add_xml_attr_str(node_tag, "name", "center_origin");
1317 add_xml_attr_str(node_tag, "type", "NODE");
1318
1319 // 回転行列
1320 AffineTrans<double> affine;
1321 affine.computeMatrix();
1322 tXML* matrix_tag = add_xml_node(node_tag, "matrix");
1323 for (int i=1; i<=4; i++) {
1324 for (int j=1; j<=4; j++) {
1325 append_xml_content_node(matrix_tag, dtostr(affine.element(i, j)));
1326 }
1327 }
1328 affine.free();
1329
1330 return;
1331}
void computeMatrix(bool with_scale=true)
void element(int i, int j, T v)
Definition AffineTrans.h:88
void free(void)
Definition AffineTrans.h:49
tXML * visual_scene_tag
char * dtostr(double n)
double を文字に変換する.free() は不要
Definition tools.cpp:1516
tXML * add_xml_attr_str(tXML *xml, const char *name, const char *value)
xml に属性名 name, 文字列の属性値 value を持つノードを追加する.
Definition txml.cpp:1420
tXML * add_xml_node(tXML *xml, const char *name)
XMLツリーのxml の直下(姉妹の一番下:末っ子)にノード(属性は指定しない)を挿入する.
Definition txml.cpp:1219
tXML * append_xml_content_node(tXML *xml, const char *content)
XMLツリーのxml の直下のコンテントノードにコンテンツを追加する.
Definition txml.cpp:1313

References add_xml_attr_str(), add_xml_node(), append_xml_content_node(), AffineTrans< T >::computeMatrix(), dtostr(), AffineTrans< T >::element(), AffineTrans< T >::free(), and ColladaXML::visual_scene_tag.

Referenced by ColladaXML::addCenterObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addController()

char * addController ( const char * geometry_id,
MeshObjectData * shelldata,
SkinJointData * skin_joint )

Definition at line 199 of file ColladaTool.cpp.

200{
201 if (geometry_id==NULL || shelldata==NULL || skin_joint==NULL) return NULL;
202
203 Buffer geometry_name = dup_Buffer(shelldata->alt_name);
204 if (geometry_name.buf==NULL) geometry_name = make_Buffer_str(geometry_id+1);
205 Buffer randomstr = make_Buffer_randomstr(8);
206
207 Buffer controller_id = make_Buffer_str("#AVATAR_");
208 cat_Buffer(&randomstr, &controller_id);
209
210 tXML* controller_tag = add_xml_node(library_controllers_tag, "controller");
211 add_xml_attr_str(controller_tag, "id", _tochar(controller_id.buf + 1));
212 add_xml_attr_str(controller_tag, "name", "avater");
213
214 tXML* skin_tag = add_xml_node(controller_tag, "skin");
215 add_xml_attr_str(skin_tag, "source", _tochar(geometry_id));
216
217 // bind_shape_matrix
218 tXML* bind_shape_tag = add_xml_node(skin_tag, "bind_shape_matrix");
219 for (int i=1; i<=4; i++) {
220 for (int j=1; j<=4; j++) {
221 append_xml_content_node(bind_shape_tag, dtostr(skin_joint->bind_shape.element(i, j)));
222 }
223 }
224
225 // source JOINT
226 Buffer joint_id = make_Buffer_str("#SOURCE_JOINT_");
227 cat_Buffer(&randomstr, &joint_id);
228 Buffer joint_name_id = make_Buffer_str("#SOURCE_JOINT_ARRAY_");
229 cat_Buffer(&randomstr, &joint_name_id);
230
231 tXML* joint_tag = add_xml_node(skin_tag, "source");
232 add_xml_attr_str(joint_tag, "id", _tochar(joint_id.buf + 1));
233
234 int num_joints = skin_joint->joint_names.get_size();
235 tXML* joint_name_tag = add_xml_node(joint_tag, "Name_array");
236 add_xml_attr_str(joint_name_tag, "id", _tochar(joint_name_id.buf + 1));
237 add_xml_attr_int(joint_name_tag, "count", num_joints);
238
239 for (int jnt=0; jnt<num_joints; jnt++) {
240 const char* joint_name = (const char*)skin_joint->joint_names.get_value(jnt);
241 append_xml_content_node(joint_name_tag, joint_name);
242 }
243 addSimpleTechniqueAccessor(joint_tag, _tochar(joint_name_id.buf), num_joints, 1, "JOINT", "name");
244
245 // source INVERSE_BIND_MATRIX
246 Buffer invbind_id = make_Buffer_str("#SOURCE_INVBIND_");
247 cat_Buffer(&randomstr, &invbind_id);
248 Buffer invbind_float_id = make_Buffer_str("#SOURCE_INVBIND_ARRAY_");
249 cat_Buffer(&randomstr, &invbind_float_id);
250
251 tXML* invbind_tag = add_xml_node(skin_tag, "source");
252 add_xml_attr_str(invbind_tag, "id", _tochar(invbind_id.buf + 1));
253
254 tXML* invbind_float_tag = add_xml_node(invbind_tag, "float_array");
255 add_xml_attr_str(invbind_float_tag, "id", _tochar(invbind_float_id.buf + 1));
256 add_xml_attr_int(invbind_float_tag, "count", num_joints*16);
257
258 for (int jnt=0; jnt<num_joints; jnt++) {
259 for (int i=1; i<=4; i++) {
260 for (int j=1; j<=4; j++) {
261 append_xml_content_node(invbind_float_tag, dtostr(skin_joint->inverse_bind[jnt].element(i, j)));
262 }
263 }
264 }
265 addSimpleTechniqueAccessor(invbind_tag, _tochar(invbind_float_id.buf), num_joints, 16, "TRANSFORM", "float4x4");
266
267 // source WEIGHT
268 int vec_len = sizeof(Vector<int>)*shelldata->ttl_vertex*num_joints;
269 Vector<int>* weight_index = (Vector<int>*)malloc(vec_len);
270 if (weight_index==NULL) return NULL;
271 memset(weight_index, 0, vec_len);
272 char* weight_id = addWeightSource(skin_tag, shelldata, weight_index, num_joints);
273
274 // joints
275 tXML* joints_tag = add_xml_node(skin_tag, "joints");
276 tXML* input_joint_tag = add_xml_node(joints_tag, "input");
277 add_xml_attr_str(input_joint_tag, "semantic", "JOINT");
278 add_xml_attr_str(input_joint_tag, "source", _tochar(joint_id.buf));
279
280 tXML* input_invbind_tag = add_xml_node(joints_tag, "input");
281 add_xml_attr_str(input_invbind_tag, "semantic", "INV_BIND_MATRIX");
282 add_xml_attr_str(input_invbind_tag, "source", _tochar(invbind_id.buf));
283
284 // vertex_weights
285 tXML* vertex_weights_tag = add_xml_node(skin_tag, "vertex_weights");
286 tXML* input_joint2_tag = add_xml_node(vertex_weights_tag, "input");
287 add_xml_attr_str(input_joint2_tag, "semantic", "JOINT");
288 add_xml_attr_str(input_joint2_tag, "source", _tochar(joint_id.buf));
289 add_xml_attr_int(input_joint2_tag, "offset", 0);
290
291 tXML* input_weight_tag = add_xml_node(vertex_weights_tag, "input");
292 add_xml_attr_str(input_weight_tag, "semantic", "WEIGHT");
293 add_xml_attr_str(input_weight_tag, "source", weight_id);
294 add_xml_attr_int(input_weight_tag, "offset", 1);
295
296 tXML* vcount_tag = add_xml_node(vertex_weights_tag, "vcount");
297 tXML* vindex_tag = add_xml_node(vertex_weights_tag, "v");
298
299 int snum = 0;
300 int wnum = 0;
301 int vnum = 0;
302 int prev_vertex = -1;
303 //
304 for (int i=0; i<shelldata->ttl_vertex*num_joints; i++) {
305 if (weight_index[i].z==TRUE) {
306 if (prev_vertex==-1) prev_vertex = weight_index[i].x; // vertex number
307 append_xml_content_node(vindex_tag, itostr(weight_index[i].y)); // joint number
308 append_xml_content_node(vindex_tag, itostr(wnum));
309 //
310 if (prev_vertex!=weight_index[i].x) {
311 append_xml_content_node(vcount_tag, itostr(vnum));
312 prev_vertex = weight_index[i].x;
313 snum++;
314 vnum = 1;
315 }
316 else vnum++;
317 wnum++;
318 }
319 }
320 append_xml_content_node(vcount_tag, itostr(vnum));
321 snum++;
322
323 if (snum!=shelldata->ttl_vertex) {
324 PRINT_MESG("WARNING: ColladaXML::addController: Vcount and Vertex number missmatched (%d != %d), Valid data num = %d\n", snum, shelldata->ttl_vertex, wnum);
325 }
326 add_xml_attr_str(vertex_weights_tag, "count", itostr(snum));
327
328 free_Buffer(&geometry_name);
329 free_Buffer(&randomstr);
330 free_Buffer(&joint_id);
331 free_Buffer(&joint_name_id);
332 free_Buffer(&invbind_id);
333 free_Buffer(&invbind_float_id);
334 if (weight_id!=NULL) ::free(weight_id);
335
336 return _tochar(controller_id.buf);
337}
void free_Buffer(Buffer *buf)
Buffer型変数のバッファ部を解放する
Definition buffer.cpp:128
Buffer dup_Buffer(Buffer buf)
Buffer型変数のコピーをつくる.
Definition buffer.cpp:211
int cat_Buffer(Buffer *src, Buffer *dst)
Buffer変数 srcから dstへバッファを catする.
Definition buffer.cpp:384
#define make_Buffer_str(str)
set_Buffer()
Definition buffer.h:61
#define make_Buffer_randomstr(sz)
make_Buffer_randomstr()
Definition buffer.h:63
T get_value(int n)
Definition tools++.h:96
int get_size(void)
Definition tools++.h:43
char * addWeightSource(tXML *tag, MeshObjectData *shelldata, Vector< int > *weight_index, int num_joints)
void addSimpleTechniqueAccessor(tXML *source_tag, const char *source_array_id, int count, int stride, const char *name, const char *type)
tXML * library_controllers_tag
int ttl_vertex
頂点データの総数.
AffineTrans< double > bind_shape
AffineTrans< double > * inverse_bind
ArrayParam< char * > joint_names
Joint名の配列.
#define TRUE
Definition common.h:226
unsigned char * buf
バッファの先頭へのポインタ.str[bufsz]は必ず 0x00となる.
Definition buffer.h:39
char * itostr(int n)
int を文字に変換する.free() は不要
Definition tools.cpp:1420
#define _tochar(a)
Definition tools.h:207
tXML * add_xml_attr_int(tXML *xml, const char *name, int value)
xml に属性名 name, 整数の属性値 value を持つノードを追加する.
Definition txml.cpp:1437

References _tochar, add_xml_attr_int(), add_xml_attr_str(), add_xml_node(), ColladaXML::addSimpleTechniqueAccessor(), ColladaXML::addWeightSource(), MeshObjectData::alt_name, append_xml_content_node(), SkinJointData::bind_shape, Buffer::buf, cat_Buffer(), dtostr(), dup_Buffer(), AffineTrans< T >::element(), ColladaXML::free(), free_Buffer(), ArrayParam< T >::get_size(), ArrayParam< T >::get_value(), SkinJointData::inverse_bind, itostr(), SkinJointData::joint_names, ColladaXML::library_controllers_tag, make_Buffer_randomstr, make_Buffer_str, PRINT_MESG, TRUE, MeshObjectData::ttl_vertex, and Vector< T >::x.

Referenced by ColladaXML::addShell().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addEffect()

tXML * addEffect ( const char * material_url,
const char * file_id,
MaterialParam param )

Definition at line 798 of file ColladaTool.cpp.

799{
800 if (material_url==NULL || file_id==NULL) return NULL;
801
802 Buffer fid = make_Buffer_str(file_id);
803 Buffer srf = make_Buffer_str(file_id);
804 Buffer smp = make_Buffer_str(file_id);
805
806 Buffer randomstr = make_Buffer_randomstr(5);
807 cat_s2Buffer("-", &srf);
808 cat_s2Buffer("-", &smp);
809 cat_s2Buffer(randomstr.buf, &srf);
810 cat_s2Buffer(randomstr.buf, &smp);
811 cat_s2Buffer("-surface", &srf);
812 cat_s2Buffer("-sampler", &smp);
813 free_Buffer(&randomstr);
814
815 tXML* effect_tag = add_xml_node(library_effects_tag, "effect");
816 add_xml_attr_str(effect_tag, "id", material_url+1);
817 tXML* profile_tag = add_xml_node(effect_tag, "profile_COMMON");
818
819 if (!isBlankTexture(mparam.getTextureName())) {
820 tXML* newparam_tag = add_xml_node(profile_tag, "newparam");
821 add_xml_attr_str(newparam_tag, "sid", _tochar(srf.buf));
822 tXML* surface_tag = add_xml_node(newparam_tag, "surface");
823 add_xml_attr_str(surface_tag, "type", "2D");
824 tXML* init_from_tag = add_xml_node(surface_tag, "init_from");
825 append_xml_content_node(init_from_tag, _tochar(fid.buf));
826
827 newparam_tag = add_xml_node(profile_tag, "newparam");
828 add_xml_attr_str(newparam_tag, "sid", _tochar(smp.buf));
829 tXML* sample_tag = add_xml_node(newparam_tag, "sampler2D");
830 tXML* source_tag = add_xml_node(sample_tag, "source");
831 append_xml_content_node(source_tag, _tochar(srf.buf));
832 }
833
834 tXML* technique_tag = add_xml_node(profile_tag, "technique");
835 add_xml_attr_str(technique_tag, "sid", "common");
836 tXML* phong_tag = add_xml_node(technique_tag, "phong");
837
838 // emission (glow)
839 if (mparam.isSetGlow()) {
840 tXML* emission_tag = add_xml_node(phong_tag, "emission");
841 tXML* color_tag = add_xml_node(emission_tag, "color");
842 for (int i=0; i<3; i++) append_xml_content_node(color_tag, dtostr(mparam.getGlow()));
843 append_xml_content_node(color_tag, "1.0"); // alpha
844 }
845
846 // ambient (bright)
847 if (mparam.isSetBright()) {
848 tXML* ambient_tag = add_xml_node(phong_tag, "ambient");
849 tXML* color_tag = add_xml_node(ambient_tag, "color");
850 for (int i=0; i<3; i++) append_xml_content_node(color_tag, dtostr(mparam.getBright()));
851 append_xml_content_node(color_tag, "1.0"); // alpha
852 }
853
854 // diffuse
855 tXML* diffuse_tag = NULL;
856 if (!isBlankTexture(mparam.getTextureName())) {
857 diffuse_tag = add_xml_node(phong_tag, "diffuse");
858 tXML* texture_tag = add_xml_node(diffuse_tag, "texture");
859 add_xml_attr_str(texture_tag, "texture", _tochar(smp.buf));
860 add_xml_attr_str(texture_tag, "texcoord", _tochar(fid.buf));
861 }
862
863 // color
864 if (mparam.texture.isSetColor()) {
865 bool no_texture = true;
866 if (diffuse_tag!=NULL) no_texture = false;
867 //
868 if (no_texture || forUnity5) {
869 // テクスチャがない場合 または Unity5 の場合は <diffuse>を新しく作成.
870 // テクスチャが存在 かつ Unity5 の場合は カラーを読むために必要.
871 // ただし,Unity2022, Unity2023 はカラーを読まない(たぶん).
872 diffuse_tag = add_xml_node(phong_tag, "diffuse");
873 }
874 //
875 tXML* color_tag = add_xml_node(diffuse_tag, "color");
876 //add_xml_attr_str(color_tag, "sid", "diffuse");
877 for (int i=0; i<4; i++) {
878 double col = mparam.texture.getColor(i);
879 if (forUnity && col==0.0) col = 0.0001;
880 append_xml_content_node(color_tag, dtostr(col));
881 }
882 }
883
884 // transparency (alpha channel)
885 if (mparam.isTransparency()) {
886 //double alpha = Min(mparam.getTransparent(), mparam.texture.getColor(3));
887 double alpha = mparam.texture.getColor(3);
888 if (forUnity && alpha<0.01) alpha = 0.01;
889 tXML* transparency_tag = add_xml_node(phong_tag, "transparency");
890 tXML* transfloat_tag = add_xml_node(transparency_tag, "float");
891 append_xml_content_node(transfloat_tag, dtostr(alpha));
892 }
893
894 // specular map & shininess
895 if (mparam.isSetShininess()) {
896 tXML* specular_tag = add_xml_node(phong_tag, "specular");
897 tXML* color_tag = add_xml_node(specular_tag, "color");
898 for (int i=0; i<4; i++) append_xml_content_node(color_tag, dtostr(mparam.specmap.getColor(i)));
899 //
900 tXML* shininess_tag = add_xml_node(phong_tag, "shininess");
901 tXML* shinfloat_tag = add_xml_node(shininess_tag, "float");
902 append_xml_content_node(shinfloat_tag, dtostr(mparam.getShininess()));
903 }
904
905 free_Buffer(&fid);
906 free_Buffer(&srf);
907 free_Buffer(&smp);
908
909 return profile_tag;
910}
#define cat_s2Buffer(src, dst)
cat_b2Buffer()
Definition buffer.h:122
bool isBlankTexture(const char *name)
tXML * library_effects_tag

References _tochar, add_xml_attr_str(), add_xml_node(), append_xml_content_node(), Buffer::buf, cat_s2Buffer, dtostr(), ColladaXML::forUnity, ColladaXML::forUnity5, free_Buffer(), MaterialParam::getBright(), TextureParam::getColor(), MaterialParam::getGlow(), MaterialParam::getShininess(), MaterialParam::getTextureName(), ColladaXML::isBlankTexture(), MaterialParam::isSetBright(), TextureParam::isSetColor(), MaterialParam::isSetGlow(), MaterialParam::isSetShininess(), MaterialParam::isTransparency(), ColladaXML::library_effects_tag, make_Buffer_randomstr, make_Buffer_str, MaterialParam::specmap, and MaterialParam::texture.

Referenced by ColladaXML::addPolylists().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addExtraBumpmap()

void addExtraBumpmap ( tXML * effect_tag,
const char * bump_id )

Definition at line 913 of file ColladaTool.cpp.

914{
915 if (profile_tag==NULL || bump_id==NULL) return;
916
917 Buffer fid = make_Buffer_str(bump_id);
918 Buffer srf = make_Buffer_str(bump_id);
919 Buffer smp = make_Buffer_str(bump_id);
920
921 Buffer randomstr = make_Buffer_randomstr(5);
922 cat_s2Buffer("-", &srf);
923 cat_s2Buffer("-", &smp);
924 cat_s2Buffer(randomstr.buf, &srf);
925 cat_s2Buffer(randomstr.buf, &smp);
926 cat_s2Buffer("-surface", &srf);
927 cat_s2Buffer("-sampler", &smp);
928 free_Buffer(&randomstr);
929
930 tXML* newparam_tag = insert_xml_node(profile_tag, "newparam");
931 add_xml_attr_str(newparam_tag, "sid", _tochar(smp.buf));
932 tXML* sample_tag = add_xml_node(newparam_tag, "sampler2D");
933 tXML* source_tag = add_xml_node(sample_tag, "source");
934 append_xml_content_node(source_tag, _tochar(srf.buf));
935
936 newparam_tag = insert_xml_node(profile_tag, "newparam");
937 add_xml_attr_str(newparam_tag, "sid", _tochar(srf.buf));
938 tXML* surface_tag = add_xml_node(newparam_tag, "surface");
939 add_xml_attr_str(surface_tag, "type", "2D");
940 tXML* init_from_tag = add_xml_node(surface_tag, "init_from");
941 append_xml_content_node(init_from_tag, _tochar(fid.buf));
942
943 tXML* technique_tag = get_xml_node_bystr(profile_tag, "<technique>");
944 tXML* extra_tag = add_xml_node(technique_tag, "extra");
945 tXML* techbump_tag = add_xml_node(extra_tag, "technique");
946 add_xml_attr_str(techbump_tag, "profile", "BumpMap");
947 tXML* bump_tag = add_xml_node(techbump_tag, "bump");
948
949 tXML* texture_tag = add_xml_node(bump_tag, "texture");
950 add_xml_attr_str(texture_tag, "texture", _tochar(smp.buf));
951 add_xml_attr_str(texture_tag, "texcoord", _tochar(fid.buf));
952
953 free_Buffer(&fid);
954 free_Buffer(&srf);
955 free_Buffer(&smp);
956
957 return;
958}
tXML * get_xml_node_bystr(tXML *pp, const char *str)
get_xml_node(tXML* pp, tXML* pt) の _bystr バージョン
Definition txml.cpp:2353
tXML * insert_xml_node(tXML *xml, const char *name)
XMLツリーのxml の直下(姉妹の一番上:長子)にノード(属性は指定しない)を挿入する.
Definition txml.cpp:1242

References _tochar, add_xml_attr_str(), add_xml_node(), append_xml_content_node(), Buffer::buf, cat_s2Buffer, free_Buffer(), get_xml_node_bystr(), insert_xml_node(), make_Buffer_randomstr, and make_Buffer_str.

Referenced by ColladaXML::addPolylists().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addGeometry()

char * addGeometry ( MeshObjectData * shelldata)

Definition at line 340 of file ColladaTool.cpp.

341{
342 if (shelldata==NULL) return NULL;
343
344 // ID String
345 Buffer randomstr = make_Buffer_randomstr(8);
346 Buffer geometry_id = make_Buffer_str("#GEOMETRY_");
347 cat_Buffer(&randomstr, &geometry_id);
348
349 //Buffer geometry_name = dup_Buffer(shelldata->data_name);
350 Buffer geometry_name = dup_Buffer(shelldata->alt_name);
351 if (geometry_name.buf!=NULL) {
352 cat_s2Buffer("_", &geometry_name);
353 cat_Buffer(&randomstr, &geometry_name);
354 }
355 else {
356 geometry_name = make_Buffer_str(geometry_id.buf + 1);
357 }
358 copy_Buffer(&geometry_name, &shelldata->alt_name);
359
360 // library_geometries
361 tXML* geomrtry_tag = add_xml_node(library_geometries_tag, "geometry");
362 add_xml_attr_str(geomrtry_tag, "id", _tochar(geometry_id.buf + 1));
363 add_xml_attr_str(geomrtry_tag, "name", _tochar(geometry_name.buf));
364 tXML* mesh_tag = add_xml_node(geomrtry_tag, "mesh");
365
366 // Source & Vertices
367 char* psitin_id = addVertexSource(mesh_tag, shelldata);
368 char* normal_id = addNormalSource(mesh_tag, shelldata);
369 char* texcrd_id = addTexcrdSource(mesh_tag, shelldata);
370 char* vertex_id = addVerticesPos (mesh_tag, psitin_id);
371
372 // Polylist
373 addPolylists(mesh_tag, shelldata, vertex_id, normal_id, texcrd_id);
374
375 freeNull(psitin_id);
376 freeNull(normal_id);
377 freeNull(vertex_id);
378 freeNull(texcrd_id);
379
380 free_Buffer(&randomstr);
381 free_Buffer(&geometry_name);
382
383 return _tochar(geometry_id.buf);
384}
int copy_Buffer(Buffer *src, Buffer *dst)
Buffer型変数 srcから dstへバッファをコピーする.
Definition buffer.cpp:315
char * addVertexSource(tXML *tag, MeshObjectData *shelldata)
char * addVerticesPos(tXML *mesh_tag, const char *position_id)
char * addNormalSource(tXML *tag, MeshObjectData *shelldata)
void addPolylists(tXML *mesh_tag, MeshObjectData *shelldata, const char *vertex_id, const char *normal_id=NULL, const char *texcrd_id=NULL)
tXML * library_geometries_tag
char * addTexcrdSource(tXML *tag, MeshObjectData *shelldata)
void freeNull(T &p)
Definition common++.h:37

References _tochar, add_xml_attr_str(), add_xml_node(), ColladaXML::addNormalSource(), ColladaXML::addPolylists(), ColladaXML::addTexcrdSource(), ColladaXML::addVertexSource(), ColladaXML::addVerticesPos(), MeshObjectData::alt_name, Buffer::buf, cat_Buffer(), cat_s2Buffer, copy_Buffer(), dup_Buffer(), free_Buffer(), jbxl::freeNull(), ColladaXML::library_geometries_tag, make_Buffer_randomstr, and make_Buffer_str.

Referenced by ColladaXML::addShell().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addImage()

char * addImage ( const char * filename)

Definition at line 756 of file ColladaTool.cpp.

757{
758 if (fn==NULL) return NULL;
759
760 Buffer file_name = make_Buffer_str(fn);
761 canonical_filename_Buffer(&file_name, TRUE);
762 Buffer file_id = replace_sBuffer_str(file_name, ".", "_");
763
764 bool exist_same_image = existSameID(library_images_tag, "<library_images><image>", _tochar(file_id.buf));
765 if (!exist_same_image) {
766 tXML* image_tag = add_xml_node(library_images_tag, "image");
767 add_xml_attr_str(image_tag, "id", _tochar(file_id.buf));
768 add_xml_attr_str(image_tag, "name", _tochar(file_id.buf));
769 add_xml_attr_int(image_tag, "height", 0);
770 add_xml_attr_int(image_tag, "width", 0);
771
772 tXML* init_from_tag = add_xml_node(image_tag, "init_from");
773 append_xml_content_node(init_from_tag, _tochar(file_name.buf));
774 }
775
776 free_Buffer(&file_name);
777 return _tochar(file_id.buf);
778}
#define replace_sBuffer_str(buf, f, t)
replace_sBuffer()
Definition buffer.h:174
tXML * library_images_tag
bool existSameID(tXML *top, const char *tag, const char *id)
void canonical_filename_Buffer(Buffer *fname, int no_dir)
fname の問題になりそうな ASCII文字を '_' に変換する.
Definition xtools.cpp:2057

References _tochar, add_xml_attr_int(), add_xml_attr_str(), add_xml_node(), append_xml_content_node(), Buffer::buf, canonical_filename_Buffer(), ColladaXML::existSameID(), free_Buffer(), ColladaXML::library_images_tag, make_Buffer_str, replace_sBuffer_str, and TRUE.

Referenced by ColladaXML::addPolylists().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addMapTechniqueAccessor()

void addMapTechniqueAccessor ( tXML * source_tag,
const char * source_array_id,
int count )

Definition at line 654 of file ColladaTool.cpp.

655{
656 if (source_tag==NULL || source_array_id==NULL) return;
657
658 tXML* technique_common_tag = add_xml_node(source_tag, "technique_common");
659 tXML* accessor_tag = add_xml_node(technique_common_tag, "accessor");
660 add_xml_attr_str(accessor_tag, "source", source_array_id);
661 add_xml_attr_int(accessor_tag, "count", count);
662 add_xml_attr_int(accessor_tag, "stride", 2);
663
664 tXML* param_s_tag = add_xml_node(accessor_tag, "param");
665 tXML* param_t_tag = add_xml_node(accessor_tag, "param");
666 add_xml_attr_str(param_s_tag, "name", "S");
667 add_xml_attr_str(param_t_tag, "name", "T");
668 add_xml_attr_str(param_s_tag, "type", "float");
669 add_xml_attr_str(param_t_tag, "type", "float");
670
671 return;
672}

References add_xml_attr_int(), add_xml_attr_str(), and add_xml_node().

Referenced by ColladaXML::addTexcrdSource().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addMaterial()

char * addMaterial ( const char * material)

Definition at line 781 of file ColladaTool.cpp.

782{
783 if (material_id==NULL) return NULL;
784
785 Buffer material_url = make_Buffer_str("#");
786 cat_s2Buffer(material_id, &material_url);
787 cat_s2Buffer("_URL", &material_url);
788
789 tXML* material_tag = add_xml_node(library_materials_tag, "material");
790 add_xml_attr_str(material_tag, "id", material_id);
791 tXML* instance_effect_tag = add_xml_node(material_tag, "instance_effect");
792 add_xml_attr_str(instance_effect_tag, "url", _tochar(material_url.buf));
793
794 return _tochar(material_url.buf);
795}
tXML * library_materials_tag

References _tochar, add_xml_attr_str(), add_xml_node(), Buffer::buf, cat_s2Buffer, ColladaXML::library_materials_tag, and make_Buffer_str.

Referenced by ColladaXML::addPolylists().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addNormalSource()

char * addNormalSource ( tXML * tag,
MeshObjectData * shelldata )

Definition at line 425 of file ColladaTool.cpp.

426{
427 if (tag==NULL || shelldata==NULL) return NULL;
428
429 Buffer randomstr = make_Buffer_randomstr(8);
430 Buffer source_id = make_Buffer_str("#SOURCE_NORMAL_");
431 Buffer source_array_id = make_Buffer_str("#SOURCE_NORMAL_ARRAY_");
432 cat_Buffer(&randomstr, &source_id);
433 cat_Buffer(&randomstr, &source_array_id);
434
435 int vnum = shelldata->ttl_vertex;
436 tXML* source_tag = add_xml_node(tag, "source");
437 add_xml_attr_str(source_tag, "id", _tochar(source_id.buf + 1));
438 tXML* source_array_tag = add_xml_node(source_tag, "float_array");
439 add_xml_attr_str(source_array_tag, "id", _tochar(source_array_id.buf + 1));
440 add_xml_attr_int(source_array_tag, "count", vnum*3); // 3 -> X, Y, Z の次元数
441 //
442 if (add_xml_content_area(source_array_tag, shelldata->ttl_vertex*10)) {
443 MeshFacetNode* facet = shelldata->facet;
444 while (facet!=NULL) {
445 Vector<double>* vect = facet->normal_value;
446 for (int i=0; i<facet->num_vertex; i++) {
447 append_xml_content_node(source_array_tag, dtostr(vect[i].x));
448 append_xml_content_node(source_array_tag, dtostr(vect[i].y));
449 append_xml_content_node(source_array_tag, dtostr(vect[i].z));
450 }
451 facet = facet->next;
452 }
453 }
454 addPosTechniqueAccessor(source_tag, _tochar(source_array_id.buf), vnum);
455
456 free_Buffer(&randomstr);
457 free_Buffer(&source_array_id);
458
459 return _tochar(source_id.buf);
460}
void addPosTechniqueAccessor(tXML *source_tag, const char *source_array_id, int count)
MeshObject の Polygonデータ(1面)を格納するクラス.リスト構造を取る.
Vector< double > * normal_value
法線ベクトルデータの並び.要素数は num_vertex
MeshFacetNode * next
int num_vertex
頂点のデータ数.(vertex_value, normal_value の要素数)
MeshFacetNode * facet
FACETデータ(1面のポリゴンデータ)のリストへのポインタ
int add_xml_content_area(tXML *xml, int len)
xml に空のコンテントノードを追加する.
Definition txml.cpp:1376

References _tochar, add_xml_attr_int(), add_xml_attr_str(), add_xml_content_area(), add_xml_node(), ColladaXML::addPosTechniqueAccessor(), append_xml_content_node(), Buffer::buf, cat_Buffer(), dtostr(), MeshObjectData::facet, free_Buffer(), make_Buffer_randomstr, make_Buffer_str, MeshFacetNode::next, MeshFacetNode::normal_value, MeshFacetNode::num_vertex, and MeshObjectData::ttl_vertex.

Referenced by ColladaXML::addGeometry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addPolylists()

void addPolylists ( tXML * mesh_tag,
MeshObjectData * shelldata,
const char * vertex_id,
const char * normal_id = NULL,
const char * texcrd_id = NULL )

Definition at line 676 of file ColladaTool.cpp.

677{
678 if (mesh_tag==NULL || vertex_id==NULL || shelldata==NULL) return;
679
680 int pnum = 0;
681 MeshFacetNode* facet = shelldata->facet;
682
683 while (facet!=NULL) {
684 //
685 tXML* polylist_tag = add_xml_node(mesh_tag, "polylist");
686 add_xml_attr_int(polylist_tag, "count", facet->num_polygon);
687
688 // Material
689 if (facet->material_param.enable && facet->material_id.buf!=NULL) {
690 //
691 add_xml_attr_str(polylist_tag, "material", _tochar(facet->material_id.buf + 1));
692 if (!facet->same_material) {
693 char* material = _tochar(facet->material_id.buf + 1);
694 bool exist_same_material = existSameID(library_materials_tag, "<library_materials><material>", material);
695 if (!exist_same_material) { // 一番最初
696 char* material_url = addMaterial(_tochar(facet->material_id.buf + 1));
697 char* file_id = addImage(facet->material_param.getTextureName());
698 tXML* profile_tag = addEffect(material_url, file_id, facet->material_param);
699 ::free(material_url);
700 ::free(file_id);
701 // Bumpmap
702 char* bump_id = addImage(facet->material_param.getBumpMapName());
703 if (bump_id!=NULL) {
704 addExtraBumpmap(profile_tag, bump_id);
705 ::free(bump_id);
706 }
707 }
708 }
709 }
710
711 //
712 tXML* input_vertex_tag = add_xml_node(polylist_tag, "input");
713 add_xml_attr_str(input_vertex_tag, "semantic", "VERTEX");
714 add_xml_attr_str(input_vertex_tag, "source", vertex_id);
715 add_xml_attr_int(input_vertex_tag, "offset", 0);
716
717 if (normal_id!=NULL) {
718 tXML* input_normal_tag = add_xml_node(polylist_tag, "input");
719 add_xml_attr_str(input_normal_tag, "semantic", "NORMAL");
720 add_xml_attr_str(input_normal_tag, "source", normal_id);
721 add_xml_attr_int(input_normal_tag, "offset", 0);
722 }
723
724 if (texcrd_id!=NULL) {
725 tXML* input_uvmap_tag = add_xml_node(polylist_tag, "input");
726 add_xml_attr_str(input_uvmap_tag, "semantic", "TEXCOORD");
727 add_xml_attr_str(input_uvmap_tag, "source", texcrd_id);
728 add_xml_attr_int(input_uvmap_tag, "offset", 0);
729 }
730
731 tXML* vcount_tag = add_xml_node(polylist_tag, "vcount");
732 if (add_xml_content_area(vcount_tag, facet->num_polygon*10)) { // 1データ 10桁の領域.予め確保した方が早い.
733 for (int i=0; i<facet->num_polygon; i++) {
734 append_xml_content_node(vcount_tag, itostr(shelldata->num_vcount));
735 }
736 }
737
738 tXML* p_data_tag = add_xml_node(polylist_tag, "p");
739 if (add_xml_content_area(p_data_tag, shelldata->num_vcount*10)) { // 1データ 10桁の領域.予め確保した方が早い.
740 for (int i=0; i<facet->num_polygon; i++) {
741 int n = i*shelldata->num_vcount;
742 for (int j=0; j<shelldata->num_vcount; j++) {
743 append_xml_content_node(p_data_tag, itostr(facet->data_index[n+j] + pnum));
744 }
745 append_xml_content_node(p_data_tag, "");
746 }
747 }
748
749 pnum += facet->num_vertex;
750 facet = facet->next;
751 }
752 return;
753}
char * addImage(const char *filename)
void addExtraBumpmap(tXML *effect_tag, const char *bump_id)
char * addMaterial(const char *material)
tXML * addEffect(const char *material_url, const char *file_id, MaterialParam param)
char * getBumpMapName(void)
char * getTextureName(void)
MaterialParam material_param
マテリアルパラメータ
bool same_material
他の Node が既に同じマテリアルを使用している.
int num_polygon
ポリゴンの数
int * data_index
インデックスデータ.要素数は num_index
Buffer material_id
マテリアルを識別するID.JBXL_MATERIAL_PREFIX で始まる.
int num_vcount
1ポリゴン あたりの頂点数.現在は 3のみサポート

References _tochar, add_xml_attr_int(), add_xml_attr_str(), add_xml_content_area(), add_xml_node(), ColladaXML::addEffect(), ColladaXML::addExtraBumpmap(), ColladaXML::addImage(), ColladaXML::addMaterial(), append_xml_content_node(), Buffer::buf, MeshFacetNode::data_index, MaterialParam::enable, ColladaXML::existSameID(), MeshObjectData::facet, ColladaXML::free(), MaterialParam::getBumpMapName(), MaterialParam::getTextureName(), itostr(), ColladaXML::library_materials_tag, MeshFacetNode::material_id, MeshFacetNode::material_param, MeshFacetNode::next, MeshFacetNode::num_polygon, MeshObjectData::num_vcount, MeshFacetNode::num_vertex, and MeshFacetNode::same_material.

Referenced by ColladaXML::addGeometry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addPosTechniqueAccessor()

void addPosTechniqueAccessor ( tXML * source_tag,
const char * source_array_id,
int count )

Definition at line 630 of file ColladaTool.cpp.

631{
632 if (source_tag==NULL || source_array_id==NULL) return;
633
634 tXML* technique_common_tag = add_xml_node(source_tag, "technique_common");
635 tXML* accessor_tag = add_xml_node(technique_common_tag, "accessor");
636 add_xml_attr_str(accessor_tag, "source", source_array_id);
637 add_xml_attr_int(accessor_tag, "count", count);
638 add_xml_attr_int(accessor_tag, "stride", 3);
639
640 tXML* param_x_tag = add_xml_node(accessor_tag, "param");
641 tXML* param_y_tag = add_xml_node(accessor_tag, "param");
642 tXML* param_z_tag = add_xml_node(accessor_tag, "param");
643 add_xml_attr_str(param_x_tag, "name", "X");
644 add_xml_attr_str(param_y_tag, "name", "Y");
645 add_xml_attr_str(param_z_tag, "name", "Z");
646 add_xml_attr_str(param_x_tag, "type", "float");
647 add_xml_attr_str(param_y_tag, "type", "float");
648 add_xml_attr_str(param_z_tag, "type", "float");
649
650 return;
651}

References add_xml_attr_int(), add_xml_attr_str(), and add_xml_node().

Referenced by ColladaXML::addNormalSource(), and ColladaXML::addVertexSource().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addScene()

void addScene ( const char * geometry_id,
char * controller_id,
MeshObjectData * shelldata,
bool collider,
SkinJointData * skin_joint )

Scene への配置(位置,サイズ,回転,コライダー, Joints_data)

Definition at line 964 of file ColladaTool.cpp.

965{
966 if ((geometry_id==NULL && controller_id==NULL) || shelldata==NULL) return;
967
968 bool local_affine = true;
969 AffineTrans<double> affine;
970 if (shelldata->affineTrans!=NULL) {
971 local_affine = false;
972 affine.free();
973 affine = *(shelldata->affineTrans);
974 //
975 if (affineTrans==NULL) {
977 affineTrans->setShift(affine.getShift());
978 }
979 }
980 else affine.init();
981
982 Vector<double> pelvis = Vector<double>(0.0, 0.0, 1.067);
983 // joints
984 if (this->has_joints && this->visual_scene_tag!=NULL) {
985 char buf[LNAME];
986 memset(buf, 0, LNAME);
987 buf[0] = '"';
988
989 int pelvis_num = -1;
990 int num_joints = skin_joint->joint_names.get_size();
991 for (int jnt=0; jnt<num_joints; jnt++) {
992 const char* joint_name = (const char*)skin_joint->joint_names.get_value(jnt);
993 if (joint_name!=NULL) {
994 int len = (int)strlen(joint_name);
995 memcpy(buf + 1, joint_name, len);
996 buf[len + 1] = '"';
997 buf[len + 2] = '\0';
998
999 tXML* node_tag = get_xml_attr_node(this->joints_template_tag, "name", (const char*)buf);
1000 if (node_tag!=NULL) {
1001 tXML* matrix_tag = node_tag->next;
1002 for (int i=1; i<=4; i++) {
1003 for (int j=1; j<=4; j++) {
1004 double element = skin_joint->alt_inverse_bind[jnt].element(i, j);
1005 if (i==1 && j==1) set_xml_content_node(matrix_tag, dtostr(element)); // 最初にタグを生成
1006 else append_xml_content_node(matrix_tag, dtostr(element));
1007 }
1008 }
1009 }
1010 else {
1011 PRINT_MESG("ERROR: ColladaXML::addScene: Joint (%s) is not found in Joints template file!\n", joint_name);
1012 }
1013 // Pelvis の座標
1014 if (!strcasecmp(joint_name, "mPelvis")) {
1015 pelvis.x = skin_joint->alt_inverse_bind[jnt].element(1, 4);
1016 pelvis.y = skin_joint->alt_inverse_bind[jnt].element(2, 4);
1017 pelvis.z = skin_joint->alt_inverse_bind[jnt].element(3, 4);
1018 pelvis_num = jnt;
1019 }
1020 }
1021 }
1022
1023 // joints_template の結合
1024 if (!this->added_joints_xml && this->has_joints) {
1025 tXML* jtemp = this->joints_template_tag;
1026 if (jtemp->ldat.id==JBXL_STATE_ANCHOR) {
1027 this->joints_template_tag = this->joints_template_tag->next;
1028 del_xml_node(&jtemp);
1029 }
1030 if (this->visual_scene_tag->next==NULL) add_tTree_node(this->visual_scene_tag, this->joints_template_tag);
1032 this->added_joints_xml = true;
1033 }
1034
1035 //**********************************************************************************
1036 // jointの位置合わせ用変換行列を計算
1037 if (pelvis_num >= 0) {
1038 AffineTrans<double> joint_space = skin_joint->inverse_bind[pelvis_num] * skin_joint->bind_shape;
1039 AffineTrans<double> joint_trans = joint_space.getInverseAffine();
1040
1041 Vector<double> shift = joint_trans.execRotationScale(pelvis);
1042 joint_trans.setShift(joint_trans.getShift() - shift);
1043 affineSkeleton = affine * joint_trans; // Joint -> Real の Affine変換
1045 //
1046 joint_space.free();
1047 joint_trans.free();
1048 }
1049 }
1050
1051 //Buffer geometry_name = dup_Buffer(shelldata->data_name);
1052 Buffer geometry_name = dup_Buffer(shelldata->alt_name);
1053 if (geometry_name.buf==NULL) geometry_name = make_Buffer_str(geometry_id + 1);
1054 //
1055 Buffer randomstr = make_Buffer_randomstr(8);
1056 Buffer node_id = make_Buffer_str("#NODE_");
1057 cat_Buffer(&randomstr, &node_id);
1058
1059 tXML* node_tag = add_xml_node(this->visual_scene_tag, "node");
1060 add_xml_attr_str(node_tag, "id", _tochar(node_id.buf + 1));
1061 add_xml_attr_str(node_tag, "name", _tochar(geometry_name.buf));
1062 add_xml_attr_str(node_tag, "type", "NODE");
1063
1064 // Collider
1065 tXML* rigid_body_tag = NULL;
1066 tXML* instance_rigid_body_tag = NULL;
1067 if (collider) {
1068 rigid_body_tag = add_xml_node(physics_model_tag, "rigid_body");
1069 add_xml_attr_str(rigid_body_tag, "sid", _tochar(node_id.buf + 1));
1070 add_xml_attr_str(rigid_body_tag, "name", _tochar(geometry_name.buf));
1071 //
1072 instance_rigid_body_tag = add_xml_node(instance_physics_model_tag, "instance_rigid_body");
1073 add_xml_attr_str(instance_rigid_body_tag, "body", _tochar(node_id.buf + 1));
1074 add_xml_attr_str(instance_rigid_body_tag, "target", _tochar(node_id.buf));
1075 }
1076 free_Buffer(&randomstr);
1077 free_Buffer(&node_id);
1078
1079 // 位置
1080 if (no_offset) affine.setShift(affine.getShift() - affineTrans->getShift());
1081 affine.computeMatrix();
1082 tXML* matrix_tag = add_xml_node(node_tag, "matrix");
1083 for (int i = 1; i <= 4; i++) {
1084 for (int j = 1; j <= 4; j++) {
1085 append_xml_content_node(matrix_tag, dtostr(affine.element(i, j)));
1086 }
1087 }
1088
1089 // Controller
1090 tXML* instance_tag = NULL;
1091 if (controller_id!=NULL) {
1092 instance_tag = add_xml_node(node_tag, "instance_controller");
1093 add_xml_attr_str(instance_tag, "url", controller_id);
1094 //
1095 tXML* skeleton_tag = add_xml_node(instance_tag, "skeleton");
1096 set_xml_content_node(skeleton_tag, "mPelvis");
1097 }
1098 else {
1099 instance_tag = add_xml_node(node_tag, "instance_geometry");
1100 add_xml_attr_str(instance_tag, "url", geometry_id);
1101 }
1102
1103 tXML* bind_material_tag = add_xml_node(instance_tag, "bind_material");
1104 tXML* technique_common_tag = add_xml_node(bind_material_tag, "technique_common");
1105
1106 tXML* instance_material_tag;
1107 MeshFacetNode* facet = shelldata->facet;
1108 while(facet!=NULL) {
1109 if (!facet->same_material) {
1110 instance_material_tag = add_xml_node(technique_common_tag, "instance_material");
1111 add_xml_attr_str(instance_material_tag, "symbol", _tochar(facet->material_id.buf + 1));
1112 add_xml_attr_str(instance_material_tag, "target", _tochar(facet->material_id.buf));
1113 }
1114 facet = facet->next;
1115 }
1116
1117 // Collider: physics_model
1118 if (collider) {
1119 technique_common_tag = add_xml_node(rigid_body_tag, "technique_common");
1120 tXML* dynamic_tag = add_xml_node(technique_common_tag, "dynamic");
1121 tXML* mass_tag = add_xml_node(technique_common_tag, "mass");
1122 add_xml_content_node(dynamic_tag, "false");
1123 add_xml_content_node(mass_tag, "0");
1124 tXML* shape_tag = add_xml_node(technique_common_tag, "shape");
1125 //
1126 if (controller_id!=NULL) {
1127 instance_tag = add_xml_node(shape_tag, "instance_controller");
1128 add_xml_attr_str(instance_tag, "url", controller_id);
1129 }
1130 else {
1131 instance_tag = add_xml_node(shape_tag, "instance_geometry");
1132 add_xml_attr_str(instance_tag, "url", geometry_id);
1133 }
1134 }
1135
1136 //
1137 free_Buffer(&geometry_name);
1138 if (local_affine) affine.free();
1139
1140 return;
1141}
void setShift(T x, T y, T z)
Definition AffineTrans.h:70
AffineTrans< T > getInverseAffine(void)
void init(void)
Definition AffineTrans.h:44
Vector< T > execRotationScale(Vector< T > v)
Vector< T > getShift(void)
tXML * instance_physics_model_tag
tXML * physics_model_tag
AffineTrans< double > * affineTrans
tXML * joints_template_tag
AffineTrans< double > affineSkeleton
void setJointLocationMatrix(void)
AffineTrans< double > * affineTrans
アフィン変換.ここで使用するのは,shift, rotate, scale(size) のみ
AffineTrans< double > * alt_inverse_bind
#define LNAME
Definition common.h:153
#define strcasecmp
Definition common.h:58
#define JBXL_STATE_ANCHOR
アンカーノード
Definition jbxl_state.h:30
tTree * add_tTree_node(tTree *pp, tTree *node)
ツリー ppへノード nodeを末っ子として追加.
Definition ttree.cpp:97
tTree * insert_tTree_node(tTree *pp, tTree *node)
ツリー ppへノード nodeを長子として追加.
Definition ttree.cpp:225
tXML * set_xml_content_node(tXML *xml, const char *content)
XMLツリーのxml の直下のコンテントノードの値を置き換える.
Definition txml.cpp:1346
tXML * add_xml_content_node(tXML *xml, const char *content)
XMLツリーのxml の直下にコンテントを挿入する.
Definition txml.cpp:1287
tXML * get_xml_attr_node(tXML *pp, const char *key, const char *val)
属性 key=val のノードを探し,最初に見つけたノードを返す.
Definition txml.cpp:2007
#define del_xml_node(p)
指定したノードを削除する.
Definition txml.h:203

References _tochar, add_tTree_node(), add_xml_attr_str(), add_xml_content_node(), add_xml_node(), ColladaXML::added_joints_xml, ColladaXML::affineSkeleton, ColladaXML::affineTrans, MeshObjectData::affineTrans, SkinJointData::alt_inverse_bind, MeshObjectData::alt_name, append_xml_content_node(), SkinJointData::bind_shape, Buffer::buf, cat_Buffer(), AffineTrans< T >::computeMatrix(), del_xml_node, dtostr(), dup_Buffer(), AffineTrans< T >::element(), AffineTrans< T >::execRotationScale(), MeshObjectData::facet, AffineTrans< T >::free(), free_Buffer(), ArrayParam< T >::get_size(), ArrayParam< T >::get_value(), get_xml_attr_node(), AffineTrans< T >::getInverseAffine(), AffineTrans< T >::getShift(), ColladaXML::has_joints, AffineTrans< T >::init(), insert_tTree_node(), ColladaXML::instance_physics_model_tag, SkinJointData::inverse_bind, JBXL_STATE_ANCHOR, SkinJointData::joint_names, ColladaXML::joints_template_tag, LNAME, make_Buffer_randomstr, make_Buffer_str, MeshFacetNode::material_id, MeshFacetNode::next, ColladaXML::no_offset, ColladaXML::physics_model_tag, PRINT_MESG, MeshFacetNode::same_material, set_xml_content_node(), ColladaXML::setJointLocationMatrix(), AffineTrans< T >::setShift(), strcasecmp, ColladaXML::visual_scene_tag, Vector< T >::x, Vector< T >::y, and Vector< T >::z.

Referenced by ColladaXML::addShell().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addShell()

void addShell ( MeshObjectData * shelldata,
bool collider,
SkinJointData * skin_joint = NULL,
tXML * joints_template = NULL )

Definition at line 157 of file ColladaTool.cpp.

158{
159 if (shelldata==NULL) return;
160
161 this->has_joints = false;
162 if (skin_joint!=NULL) {
163 if (joints_template!=NULL || this->joints_template_tag!=NULL) this->has_joints = true;
164 if (joints_template!=NULL) {
165 if (this->joints_template_tag==NULL) {
166 this->joints_template_tag = joints_template;
167 }
168 else {
169 del_all_xml(&joints_template);
170 }
171 }
172 }
173 //
174 char* geom_id = this->addGeometry(shelldata); // 幾何情報を配置
175 char* ctrl_id = this->addController(geom_id, shelldata, skin_joint); // Joints 情報を配置
176 this->addScene(geom_id, ctrl_id, shelldata, collider, skin_joint); // Scene への配置(位置,サイズ,回転,コライダー, Joints)
177
178 if (geom_id!=NULL) ::free(geom_id);
179 if (ctrl_id!=NULL) ::free(ctrl_id);
180 return;
181}
char * addController(const char *geometry_id, MeshObjectData *shelldata, SkinJointData *skin_joint)
char * addGeometry(MeshObjectData *shelldata)
void addScene(const char *geometry_id, char *controll_id, MeshObjectData *shelldata, bool collider, SkinJointData *skin_joint)
#define del_all_xml(p)
XMLツリーの全ノードの削除.ポインタ ppのノードを含むXMLツリー全体を削除する.
Definition txml.h:204

References ColladaXML::addController(), ColladaXML::addGeometry(), ColladaXML::addScene(), del_all_xml, ColladaXML::free(), ColladaXML::has_joints, and ColladaXML::joints_template_tag.

Here is the call graph for this function:

◆ addSimpleTechniqueAccessor()

void addSimpleTechniqueAccessor ( tXML * source_tag,
const char * source_array_id,
int count,
int stride,
const char * name,
const char * type )

Definition at line 613 of file ColladaTool.cpp.

614{
615 if (source_tag==NULL || source_array_id==NULL) return;
616
617 tXML* technique_common_tag = add_xml_node(source_tag, "technique_common");
618 tXML* accessor_tag = add_xml_node(technique_common_tag, "accessor");
619 add_xml_attr_str(accessor_tag, "source", source_array_id);
620 add_xml_attr_int(accessor_tag, "count", count);
621 add_xml_attr_int(accessor_tag, "stride", stride);
622 tXML* param_tag = add_xml_node(accessor_tag, "param");
623 add_xml_attr_str(param_tag, "name", name);
624 add_xml_attr_str(param_tag, "type", type);
625
626 return;
627}

References add_xml_attr_int(), add_xml_attr_str(), and add_xml_node().

Referenced by ColladaXML::addController(), and ColladaXML::addWeightSource().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addTexcrdSource()

char * addTexcrdSource ( tXML * tag,
MeshObjectData * shelldata )

Definition at line 464 of file ColladaTool.cpp.

465{
466 if (tag==NULL || shelldata==NULL) return NULL;
467
468 Buffer randomstr = make_Buffer_randomstr(8);
469 Buffer source_id = make_Buffer_str("#SOURCE_MAP_");
470 Buffer source_array_id = make_Buffer_str("#SOURCE_MAP_ARRAY_");
471 cat_Buffer(&randomstr, &source_id);
472 cat_Buffer(&randomstr, &source_array_id);
473
474 int vnum = shelldata->ttl_vertex;
475 tXML* source_tag = add_xml_node(tag, "source");
476 add_xml_attr_str(source_tag, "id", _tochar(source_id.buf + 1));
477 tXML* source_array_tag = add_xml_node(source_tag, "float_array");
478 add_xml_attr_str(source_array_tag, "id", _tochar(source_array_id.buf + 1));
479 add_xml_attr_int(source_array_tag, "count", vnum*2); // 2 -> S,T (U, V) の次元数
480 //
481 if (add_xml_content_area(source_array_tag, shelldata->ttl_texcrd*10)) {
482 MeshFacetNode* facet = shelldata->facet;
483 while (facet!=NULL) {
484 size_t len = facet->num_texcrd*sizeof(UVMap<double>);
485 UVMap<double>* uvmap = (UVMap<double>*)malloc(len);
486 if (uvmap!=NULL) {
487 memcpy(uvmap, facet->texcrd_value, len);
488 // PLANAR Texture
490 Vector<double> scale(1.0, 1.0, 1.0);
491 if (shelldata->affineTrans!=NULL) scale = shelldata->affineTrans->getScale();
492 facet->generatePlanarUVMap(scale, uvmap);
493 }
494 facet->execAffineTransUVMap(uvmap, facet->num_texcrd);
495
496 for (int i=0; i<facet->num_texcrd; i++) {
497 append_xml_content_node(source_array_tag, dtostr(uvmap[i].u));
498 append_xml_content_node(source_array_tag, dtostr(uvmap[i].v));
499 }
500 ::free(uvmap);
501 }
502 facet = facet->next;
503 }
504 }
505 addMapTechniqueAccessor(source_tag, _tochar(source_array_id.buf), vnum);
506
507 free_Buffer(&randomstr);
508 free_Buffer(&source_array_id);
509
510 return _tochar(source_id.buf);
511}
#define MATERIAL_MAPPING_PLANAR
Vector< T > getScale(void)
void addMapTechniqueAccessor(tXML *source_tag, const char *source_array_id, int count)
int mapping
マッピング方法
int num_texcrd
テクスチャ画像の座標数.通常は num_vertex に等しい.(texcrd_value の要素数)
void execAffineTransUVMap(UVMap< double > *uvmap=NULL, int num=-1)
UVMap< double > * texcrd_value
テクスチャマップの並び.要素数は num_texcrd
UVMap< double > * generatePlanarUVMap(Vector< double > scale, UVMap< double > *uvmap=NULL)
int ttl_texcrd
テクスチャ画像の座標総数.通常は ttl_vertexと同じ値.

References _tochar, add_xml_attr_int(), add_xml_attr_str(), add_xml_content_area(), add_xml_node(), ColladaXML::addMapTechniqueAccessor(), MeshObjectData::affineTrans, append_xml_content_node(), Buffer::buf, cat_Buffer(), dtostr(), MeshFacetNode::execAffineTransUVMap(), MeshObjectData::facet, ColladaXML::free(), free_Buffer(), MeshFacetNode::generatePlanarUVMap(), AffineTrans< T >::getScale(), make_Buffer_randomstr, make_Buffer_str, MaterialParam::mapping, MATERIAL_MAPPING_PLANAR, MeshFacetNode::material_param, MeshFacetNode::next, MeshFacetNode::num_texcrd, MeshFacetNode::texcrd_value, MeshObjectData::ttl_texcrd, and MeshObjectData::ttl_vertex.

Referenced by ColladaXML::addGeometry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addVertexSource()

char * addVertexSource ( tXML * tag,
MeshObjectData * shelldata )

Definition at line 387 of file ColladaTool.cpp.

388{
389 if (tag==NULL || shelldata==NULL) return NULL;
390
391 Buffer randomstr = make_Buffer_randomstr(8);
392 Buffer source_id = make_Buffer_str("#SOURCE_POS_");
393 Buffer source_array_id = make_Buffer_str("#SOURCE_POS_ARRAY_");
394 cat_Buffer(&randomstr, &source_id);
395 cat_Buffer(&randomstr, &source_array_id);
396
397 int vnum = shelldata->ttl_vertex;
398 tXML* source_tag = add_xml_node(tag, "source");
399 add_xml_attr_str(source_tag, "id", _tochar(source_id.buf + 1));
400 tXML* source_array_tag = add_xml_node(source_tag, "float_array");
401 add_xml_attr_str(source_array_tag, "id", _tochar(source_array_id.buf + 1));
402 add_xml_attr_int(source_array_tag, "count", vnum*3); // 3 -> X, Y, Z の次元数
403 //
404 if (add_xml_content_area(source_array_tag, shelldata->ttl_vertex*10)) {
405 MeshFacetNode* facet = shelldata->facet;
406 while (facet!=NULL) {
407 Vector<double>* vect = facet->vertex_value;
408 for (int i=0; i<facet->num_vertex; i++) {
409 append_xml_content_node(source_array_tag, dtostr(vect[i].x));
410 append_xml_content_node(source_array_tag, dtostr(vect[i].y));
411 append_xml_content_node(source_array_tag, dtostr(vect[i].z));
412 }
413 facet = facet->next;
414 }
415 }
416 addPosTechniqueAccessor(source_tag, _tochar(source_array_id.buf), vnum);
417
418 free_Buffer(&randomstr);
419 free_Buffer(&source_array_id);
420
421 return _tochar(source_id.buf);
422}
Vector< double > * vertex_value
頂点データの並び.要素数は num_vertex

References _tochar, add_xml_attr_int(), add_xml_attr_str(), add_xml_content_area(), add_xml_node(), ColladaXML::addPosTechniqueAccessor(), append_xml_content_node(), Buffer::buf, cat_Buffer(), dtostr(), MeshObjectData::facet, free_Buffer(), make_Buffer_randomstr, make_Buffer_str, MeshFacetNode::next, MeshFacetNode::num_vertex, MeshObjectData::ttl_vertex, and MeshFacetNode::vertex_value.

Referenced by ColladaXML::addGeometry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addVerticesPos()

char * addVerticesPos ( tXML * mesh_tag,
const char * position_id )

Definition at line 592 of file ColladaTool.cpp.

593{
594 if (tag==NULL || position_id==NULL) return NULL;
595
596 Buffer randomstr = make_Buffer_randomstr(8);
597 Buffer vertex_id = make_Buffer_str("#VERTEX_");
598 cat_Buffer(&randomstr, &vertex_id);
599
600 // Vertices
601 tXML* vertices_tag = add_xml_node(tag, "vertices");
602 add_xml_attr_str(vertices_tag, "id", _tochar(vertex_id.buf + 1));
603 tXML* input_position_tag = add_xml_node(vertices_tag, "input");
604 add_xml_attr_str(input_position_tag, "semantic", "POSITION");
605 add_xml_attr_str(input_position_tag, "source", position_id);
606
607 free_Buffer(&randomstr);
608
609 return _tochar(vertex_id.buf);
610}

References _tochar, add_xml_attr_str(), add_xml_node(), Buffer::buf, cat_Buffer(), free_Buffer(), make_Buffer_randomstr, and make_Buffer_str.

Referenced by ColladaXML::addGeometry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addWeightSource()

char * addWeightSource ( tXML * tag,
MeshObjectData * shelldata,
Vector< int > * weight_index,
int num_joints )

char* ColladaXML::addWeightSource(tXML* tag, MeshObjectData* shelldata, Vector<int>* weight_index, int num_joints)

Return values
weight_index[].xvertex No.
weight_index[].yjoint No.
weight_index[].zFALSE->データなし, TRUE->データあり
Returns
source_id

Definition at line 522 of file ColladaTool.cpp.

523{
524 if (tag==NULL || shelldata==NULL || weight_index==NULL) return NULL;
525
526 Buffer randomstr = make_Buffer_randomstr(8);
527 Buffer source_id = make_Buffer_str("#SOURCE_WEIGHT_");
528 Buffer source_array_id = make_Buffer_str("#SOURCE_WEIGHT_ARRAY_");
529 cat_Buffer(&randomstr, &source_id);
530 cat_Buffer(&randomstr, &source_array_id);
531
532 tXML* source_tag = add_xml_node(tag, "source");
533 add_xml_attr_str(source_tag, "id", _tochar(source_id.buf + 1));
534 tXML* source_array_tag = add_xml_node(source_tag, "float_array");
535 add_xml_attr_str(source_array_tag, "id", _tochar(source_array_id.buf + 1));
536 //
537 int count = 0;
538 int vnum = 0;
539 if (add_xml_content_area(source_array_tag, shelldata->ttl_vertex*10)) { // 1データ 10桁の領域.予め確保した方が早い.
540 MeshFacetNode* facet = shelldata->facet;
541 while (facet!=NULL) {
542 ArrayParam<int>* weight = facet->weight_value;
543 for (int i=0; i<facet->num_vertex; i++) {
544 int total = 0;
545 int jnum = weight[i].get_size(); // その頂点で有効なジョイントの最大値
546 for (int j=0; j<jnum; j++) {
547 total += weight[i].get_value(j);
548 }
549
550 if (total!=0) {
551 for (int j=0; j<num_joints; j++) {
552 weight_index[num_joints*vnum + j].x = i;
553 weight_index[num_joints*vnum + j].y = j;
554 weight_index[num_joints*vnum + j].z = FALSE;
555
556 int weight_value = 0;
557 if (j<jnum) weight_value = weight[i].get_value(j);
558
559 if (weight_value!=0) {
560 double value = weight_value/(double)total;
561 append_xml_content_node(source_array_tag, dtostr(value));
562 weight_index[vnum*num_joints + j].z = TRUE;
563 count++;
564 }
565 }
566 }
567 else {
568 weight_index[vnum*num_joints].x = i;
569 weight_index[vnum*num_joints].y = 0;
570 weight_index[vnum*num_joints].z = TRUE;
571 append_xml_content_node(source_array_tag, "0.000000");
572 count++;
573 }
574 vnum++;
575 }
576 facet = facet->next;
577 }
578 }
579 add_xml_attr_int(source_array_tag, "count", count);
580
581 if (vnum!=shelldata->ttl_vertex) {
582 PRINT_MESG("WARNING: ColladaXML::addWeightSource: no match vertex num (%d != %d)\n", vnum, shelldata->ttl_vertex);
583 }
584 addSimpleTechniqueAccessor(source_tag, _tochar(source_array_id.buf), count, 1, "WEIGHT", "float");
585
586 free_Buffer(&randomstr);
587 free_Buffer(&source_array_id);
588 return _tochar(source_id.buf);
589}
ArrayParam< int > * weight_value
頂点の重み.Jointを持つデータに使用される.要素数は num_vertex. 各 weight_value[i] の値は トータルで正規化される必要がある.
#define FALSE
Definition common.h:223

References _tochar, add_xml_attr_int(), add_xml_attr_str(), add_xml_content_area(), add_xml_node(), ColladaXML::addSimpleTechniqueAccessor(), append_xml_content_node(), Buffer::buf, cat_Buffer(), dtostr(), MeshObjectData::facet, FALSE, free_Buffer(), ArrayParam< T >::get_size(), ArrayParam< T >::get_value(), make_Buffer_randomstr, make_Buffer_str, MeshFacetNode::next, MeshFacetNode::num_vertex, PRINT_MESG, TRUE, MeshObjectData::ttl_vertex, MeshFacetNode::weight_value, Vector< T >::x, Vector< T >::y, and Vector< T >::z.

Referenced by ColladaXML::addController().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear() [1/2]

void clear ( double meter = 1.0,
int axis = COLLADA_Z_UP,
const char * ver = NULL )

Definition at line 53 of file ColladaTool.cpp.

54{
55 del_all_xml(&this->xml_tag);
56 this->init(meter, axis, ver);
57}

References del_all_xml, ColladaXML::init(), and ColladaXML::xml_tag.

Here is the call graph for this function:

◆ clear() [2/2]

void clear ( float meter,
int axis = COLLADA_Z_UP,
const char * ver = NULL )
inline

Definition at line 46 of file ColladaTool.h.

46{ clear((double)meter, axis, ver); }
void clear(double meter=1.0, int axis=COLLADA_Z_UP, const char *ver=NULL)

References ColladaXML::clear().

Referenced by ColladaXML::clear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closeSolid()

void closeSolid ( void )

Definition at line 184 of file ColladaTool.cpp.

185{
186 if (this->added_joints_xml) {
187 tXML* pelvis_tag = get_xml_attr_node(joints_template_tag, "name","\"mPelvis\"");
188 if (pelvis_tag!=NULL) {
189 this->deleteNousedJoints(pelvis_tag); // matrixデータの無い jointデータを削除
190 }
191 else {
192 PRINT_MESG("WARNING: ColladaXML::closeObject: not found mPelvis in Joints template file.\n");
193 }
194 }
195 return;
196}
void deleteNousedJoints(tXML *delete_tag)

References ColladaXML::added_joints_xml, ColladaXML::deleteNousedJoints(), get_xml_attr_node(), ColladaXML::joints_template_tag, and PRINT_MESG.

Here is the call graph for this function:

◆ deleteJoint()

void deleteJoint ( tXML * delete_tag)

Definition at line 1227 of file ColladaTool.cpp.

1228{
1229 if (delete_tag==NULL) return;
1230
1231 if (delete_tag->next!=NULL) {
1232 tXML* next = delete_tag->next;
1233 while (next->esis!=NULL) next = next->esis;
1234
1235 if (next->ysis!=NULL) {
1236 if (!strcasecmp((char*)next->ysis->ldat.key.buf, "extra")) {
1237 tXML* ysis = next->ysis;
1238 del_xml(&ysis);
1239 }
1240 }
1241 if (!strcasecmp((char*)next->ldat.key.buf, "matrix")) {
1242 del_xml(&next);
1243 }
1244 }
1245 del_xml_node(&delete_tag);
1246}
#define del_xml(p)
指定したノード以下のXMLツリー(ppの姉妹は含まない)を削除する.
Definition txml.h:202

References del_xml, del_xml_node, and strcasecmp.

Referenced by ColladaXML::deleteListJoints(), and ColladaXML::deleteNousedJoints().

Here is the caller graph for this function:

◆ deleteListJoints()

void deleteListJoints ( tXML * top_tag,
tList * joints_name )

Definition at line 1275 of file ColladaTool.cpp.

1276{
1277 if (top_tag==NULL) return;
1278
1279 char buf[LNAME];
1280 memset(buf, 0, LNAME);
1281 buf[0] = '"';
1282
1283 tList* lp = joints_name;
1284 while (lp!=NULL) {
1285 char* jname = (char*)lp->ldat.key.buf;
1286 int len = (int)strlen(jname);
1287 memcpy(buf + 1, jname, len);
1288 buf[len + 1] = '"';
1289 buf[len + 2] = '\0';
1290 tXML* del_tag = get_xml_attr_node(top_tag, "name", (const char*)buf);
1291 //
1292 deleteJoint(del_tag);
1293 //
1294 lp = lp->next;
1295 }
1296 return;
1297}
void deleteJoint(tXML *delete_tag)

References ColladaXML::deleteJoint(), get_xml_attr_node(), and LNAME.

Here is the call graph for this function:

◆ deleteNousedJoints()

void deleteNousedJoints ( tXML * delete_tag)

Definition at line 1250 of file ColladaTool.cpp.

1251{
1252 if (delete_tag==NULL) return;
1253
1254 if (!strcasecmp((char*)delete_tag->ldat.key.buf, "matrix")) {
1255 if (delete_tag->next==NULL) {
1256 if (delete_tag->prev!=NULL) delete_tag->prev->ctrl = TREE_DELETE_NODE;
1257 }
1258 }
1259
1260 if (delete_tag->next!=NULL) {
1261 deleteNousedJoints(delete_tag->next);
1262 }
1263 if (delete_tag->ysis!=NULL) {
1264 deleteNousedJoints(delete_tag->ysis);
1265 }
1266
1267 if (delete_tag->ctrl == TREE_DELETE_NODE) {
1268 deleteJoint(delete_tag);
1269 }
1270}
#define TREE_DELETE_NODE
後で削除処理を行うノード.
Definition ttree.h:57

References ColladaXML::deleteJoint(), ColladaXML::deleteNousedJoints(), strcasecmp, and TREE_DELETE_NODE.

Referenced by ColladaXML::closeSolid(), and ColladaXML::deleteNousedJoints().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ existSameID()

bool existSameID ( tXML * top,
const char * tag,
const char * id )

Definition at line 1144 of file ColladaTool.cpp.

1145{
1146 bool ret = false;
1147
1148 tXML* xml = xml_parse((char*)tag);
1149 tXML* lst = get_xml_node_list(top, xml);
1150
1151 Buffer cmpid = make_Buffer_str("\"");
1152 cat_s2Buffer(id, &cmpid);
1153 cat_s2Buffer("\"", &cmpid);
1154
1155 while (lst!=NULL) {
1156 char* attr_id = xml_get_node_attr(lst->altp, "id");
1157 if (!strcmp(attr_id, _tochar(cmpid.buf))) {
1158 ret = true;
1159 break;
1160 }
1161 lst = lst->next;
1162 }
1163
1164 del_all_xml(&xml);
1165 del_all_xml(&lst);
1166 free_Buffer(&cmpid);
1167
1168 return ret;
1169}
char * xml_get_node_attr(tXML *node, const char *attr)
属性値を持つノードのポインタから,指定された属性値へのポインタを返す.free() してはいけない.
Definition txml.cpp:1606
tXML * xml_parse(char *pp)
文字列のXMLデータを解釈して,tXMLのツリーを生成する.
Definition txml.cpp:48
tList * get_xml_node_list(tXML *pp, tXML *pt)
XMLツリー pp内で XMLツリー ptと同じパターンの枝を探し,ptに一致した枝の,ptの最後のノードに対応するノードへのポインタをリストに格納して返す.
Definition txml.cpp:2656

References _tochar, Buffer::buf, cat_s2Buffer, del_all_xml, free_Buffer(), get_xml_node_list(), make_Buffer_str, xml_get_node_attr(), and xml_parse().

Referenced by ColladaXML::addImage(), and ColladaXML::addPolylists().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free()

void free ( void )

◆ init() [1/2]

void init ( double meter = 1.0,
int axis = COLLADA_Z_UP,
const char * ver = NULL )

Definition at line 23 of file ColladaTool.cpp.

24{
25 this->initCollada(meter, axis, ver);
26 //
27 this->joints_template_tag = NULL;
28 this->added_joints_xml = false;
29 this->has_joints = false;
30 this->no_offset = false;
31
32 this->blank_texture = init_Buffer();
33 this->phantom_out = true;
34 this->forUnity5 = false;
35 this->forUnity = true;
36
37 this->affineTrans = NULL;;
38 this->affineSkeleton.init();
39}
Buffer init_Buffer()
初期化したBuffer型変数を返す.
Definition buffer.cpp:47
void initCollada(double meter, int axis, const char *ver)

References ColladaXML::added_joints_xml, ColladaXML::affineSkeleton, ColladaXML::affineTrans, ColladaXML::blank_texture, ColladaXML::forUnity, ColladaXML::forUnity5, ColladaXML::has_joints, AffineTrans< T >::init(), init_Buffer(), ColladaXML::initCollada(), ColladaXML::joints_template_tag, ColladaXML::no_offset, and ColladaXML::phantom_out.

Referenced by ColladaXML::clear(), ColladaXML::ColladaXML(), and ColladaXML::ColladaXML().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init() [2/2]

void init ( float meter,
int axis = COLLADA_Z_UP,
const char * ver = NULL )
inline

Definition at line 44 of file ColladaTool.h.

44{ init((double)meter, axis, ver); }

References ColladaXML::init().

Referenced by ColladaXML::init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initCollada() [1/2]

void initCollada ( double meter,
int axis,
const char * ver )

Definition at line 73 of file ColladaTool.cpp.

74{
75 Buffer buf;
76 if (ver!=NULL) buf = make_Buffer_str(ver);
78
79 // COLLADA
80 this->xml_tag = init_xml_doc();
81 this->collada_tag = add_xml_node(xml_tag, "COLLADA");
82 //
84 add_xml_attr_str(this->collada_tag, "version", _tochar(buf.buf));
85
86 // asset
87 this->asset_tag = add_xml_node(collada_tag, "asset");
88 this->contributor_tag = add_xml_node(asset_tag, "contributor");
89 this->author_tag = add_xml_node(contributor_tag, "author");
90 this->authoring_tool_tag = add_xml_node(contributor_tag, "authoring_tool");
91 this->created_tag = add_xml_node(asset_tag, "created");
92 this->modified_tag = add_xml_node(asset_tag, "modified");
93 this->unit_tag = add_xml_node(asset_tag, "unit");
94 this->up_axis_tag = add_xml_node(asset_tag, "up_axis");
95
96 //char* ltime = get_localtime('-', 'T', ':', 'Z');
97 char* ltime = get_local_timestamp(time(0), "%Y-%m-%dT%H:%M:%SZ");
98 //
101 add_xml_content_node(this->created_tag, ltime);
103 add_xml_attr_str(this->unit_tag, "name", "meter");
104 add_xml_attr_float(this->unit_tag, "meter", (float)meter);
105 ::free(ltime);
106
107 if (axis==COLLADA_X_UP) add_xml_content_node(this->up_axis_tag, "X_UP");
108 else if (axis==COLLADA_Y_UP) add_xml_content_node(this->up_axis_tag, "Y_UP");
109 else add_xml_content_node(this->up_axis_tag, "Z_UP");
110
111 this->library_images_tag = add_xml_node(this->collada_tag, "library_images");
112 this->library_effects_tag = add_xml_node(this->collada_tag, "library_effects");
113 this->library_materials_tag = add_xml_node(this->collada_tag, "library_materials");
114 this->library_geometries_tag = add_xml_node(this->collada_tag, "library_geometries");
115 this->library_controllers_tag = add_xml_node(this->collada_tag, "library_controllers");
116
117 // library_physics_models
118 this->library_physics_models_tag = add_xml_node(this->collada_tag, "library_physics_models");
119 this->physics_model_tag = add_xml_node(this->library_physics_models_tag, "physics_model");
120 add_xml_attr_str(this->physics_model_tag, "id", "Physics_Model");
121 add_xml_attr_str(this->physics_model_tag, "name", "Physics_Model");
122
123 // library_physics_scenes
124 this->library_physics_scenes_tag = add_xml_node(this->collada_tag, "library_physics_scenes");
125 this->physics_scene_tag = add_xml_node(this->library_physics_scenes_tag, "physics_scene");
126 add_xml_attr_str(physics_scene_tag, "id", "Physics_Scene");
127 add_xml_attr_str(physics_scene_tag, "name", "Physics_Scene");
128 this->instance_physics_model_tag = add_xml_node(this->physics_scene_tag, "instance_physics_model");
129 add_xml_attr_str(this->instance_physics_model_tag, "url", "#Physics_Model");
130 //tXML* technique_tag = add_xml_node(this->physics_scene_tag, "technique_common");
131 //tXML* gravity_tag = add_xml_node(this->technique_tag, "gravity");
132 //add_xml_content(this->gravity_tag, "0.000000 -9.810000 0.000000");
133
134 // library_visual_scenes
135 this->library_visual_scenes_tag = add_xml_node(this->collada_tag, "library_visual_scenes");
136 this->visual_scene_tag = add_xml_node(this->library_visual_scenes_tag, "visual_scene");
137 add_xml_attr_str(this->visual_scene_tag, "id", "Scene");
138 add_xml_attr_str(this->visual_scene_tag, "name", "Scene");
139
140 // scence
141 this->scene_tag = add_xml_node(this->collada_tag, "scene");
142 this->instance_physics_scene_tag = add_xml_node(this->scene_tag, "instance_physics_scene");
143 add_xml_attr_str(this->instance_physics_scene_tag, "url", "#Physics_Scene");
144 this->instance_visual_scene_tag = add_xml_node(this->scene_tag, "instance_visual_scene");
145 add_xml_attr_str(this->instance_visual_scene_tag, "url", "#Scene");
146 //
147
148 free_Buffer(&buf);
149}
#define COLLADA_Y_UP
Definition ColladaTool.h:24
#define COLLADA_STR_XMLNS
Definition ColladaTool.h:18
#define COLLADA_STR_AUTHOR
Definition ColladaTool.h:17
#define COLLADA_X_UP
Definition ColladaTool.h:23
#define COLLADA_STR_TOOL
Definition ColladaTool.h:19
#define COLLADA_STR_VER
Definition ColladaTool.h:20
tXML * library_visual_scenes_tag
tXML * physics_scene_tag
tXML * authoring_tool_tag
tXML * library_physics_models_tag
tXML * contributor_tag
Definition ColladaTool.h:98
tXML * instance_physics_scene_tag
tXML * instance_visual_scene_tag
tXML * library_physics_scenes_tag
char * get_local_timestamp(time_t date, const char *format)
要 free()
Definition tools.cpp:440
tXML * init_xml_doc()
XML のドキュメントヘッダを作成する.
Definition txml.cpp:1203
tXML * add_xml_attr_float(tXML *xml, const char *name, float value)
xml に属性名 name, float型実数の属性値 value を持つノードを追加する.
Definition txml.cpp:1454

References _tochar, add_xml_attr_float(), add_xml_attr_str(), add_xml_content_node(), add_xml_node(), ColladaXML::asset_tag, ColladaXML::author_tag, ColladaXML::authoring_tool_tag, Buffer::buf, COLLADA_STR_AUTHOR, COLLADA_STR_TOOL, COLLADA_STR_VER, COLLADA_STR_XMLNS, ColladaXML::collada_tag, COLLADA_X_UP, COLLADA_Y_UP, ColladaXML::contributor_tag, ColladaXML::created_tag, ColladaXML::free(), free_Buffer(), get_local_timestamp(), init_xml_doc(), ColladaXML::instance_physics_model_tag, ColladaXML::instance_physics_scene_tag, ColladaXML::instance_visual_scene_tag, ColladaXML::library_controllers_tag, ColladaXML::library_effects_tag, ColladaXML::library_geometries_tag, ColladaXML::library_images_tag, ColladaXML::library_materials_tag, ColladaXML::library_physics_models_tag, ColladaXML::library_physics_scenes_tag, ColladaXML::library_visual_scenes_tag, make_Buffer_str, ColladaXML::modified_tag, ColladaXML::physics_model_tag, ColladaXML::physics_scene_tag, ColladaXML::scene_tag, ColladaXML::unit_tag, ColladaXML::up_axis_tag, ColladaXML::visual_scene_tag, and ColladaXML::xml_tag.

Referenced by ColladaXML::init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initCollada() [2/2]

void initCollada ( float meter,
int axis,
const char * ver )
inline

Definition at line 55 of file ColladaTool.h.

55{ initCollada((double)meter, axis, ver); }

References ColladaXML::initCollada().

Referenced by ColladaXML::initCollada().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isBlankTexture()

bool isBlankTexture ( const char * name)

Definition at line 60 of file ColladaTool.cpp.

61{
62 if (this->blank_texture.buf==NULL) return false;
63 if (strncasecmp(_tochar(this->blank_texture.buf), name, strlen(_tochar(this->blank_texture.buf)))) return false;
64
65 return true;
66}
#define strncasecmp
Definition common.h:59

References _tochar, ColladaXML::blank_texture, Buffer::buf, and strncasecmp.

Referenced by ColladaXML::addEffect().

Here is the caller graph for this function:

◆ output_dae()

void output_dae ( FILE * fp,
int mode = XML_SPACE_FORMAT )
inline

Definition at line 50 of file ColladaTool.h.

50{ print_xml(fp, xml_tag, mode);}
void print_xml(FILE *fp, tXML *pp, int mode)
XMLの表示(出力).
Definition txml.cpp:1691

References print_xml(), and ColladaXML::xml_tag.

Referenced by ColladaXML::outputFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ output_tree()

void output_tree ( FILE * fp)
inline

Definition at line 51 of file ColladaTool.h.

51{ print_xml_tree(fp, xml_tag, " ");}
void print_xml_tree(FILE *fp, tXML *pp, const char *space)
XMLツリーをそのままツリー表示する.デバッグ用.
Definition txml.cpp:1759

References print_xml_tree(), and ColladaXML::xml_tag.

Here is the call graph for this function:

◆ outputFile()

void outputFile ( const char * fn,
const char * path = NULL,
int mode = XML_SPACE_FORMAT )

Definition at line 1172 of file ColladaTool.cpp.

1173{
1174 char* packname = pack_head_tail_char(get_file_name(fname), ' ');
1175 Buffer file_name = make_Buffer_bystr(packname);
1176 ::free(packname);
1177 //
1178 canonical_filename_Buffer(&file_name, TRUE);
1179 if (file_name.buf[0]=='.') file_name.buf[0] = '_';
1180
1181 Buffer out_path;
1182 if (path==NULL) out_path = make_Buffer_bystr("./");
1183 else out_path = make_Buffer_bystr(path);
1184 cat_Buffer(&file_name, &out_path);
1185 change_file_extension_Buffer(&out_path, ".dae");
1186 //
1187 FILE* fp = fopen((char*)out_path.buf, "wb");
1188 if (fp!=NULL) {
1189 output_dae(fp, mode);
1190 fclose(fp);
1191 }
1192 else {
1193 PRINT_MESG("ColladaXML::outputFile: ERROR: File open Error! (%s)\n", (char*)out_path.buf);
1194 }
1195
1196 free_Buffer(&file_name);
1197 free_Buffer(&out_path);
1198
1199 return;
1200}
#define make_Buffer_bystr(str)
set_Buffer()
Definition buffer.h:57
void output_dae(FILE *fp, int mode=XML_SPACE_FORMAT)
Definition ColladaTool.h:50
char * get_file_name(const char *str)
フルパスからファイル名へのポインタを取り出す.free() してはいけない.
Definition tools.cpp:2066
char * pack_head_tail_char(char *mesg, char cc)
文字の先頭のcc(複数),TAB, CR, LF.終わりのcc(複数),TAB, CR, LF を削除.要 free()
Definition tools.cpp:1092
void change_file_extension_Buffer(Buffer *path, const char *ext)
ファイルの拡張子を extにする.ファイルに拡張子が無い場合は extを付加する
Definition xtools.cpp:1960

References Buffer::buf, canonical_filename_Buffer(), cat_Buffer(), change_file_extension_Buffer(), ColladaXML::free(), free_Buffer(), get_file_name(), make_Buffer_bystr, ColladaXML::output_dae(), pack_head_tail_char(), PRINT_MESG, and TRUE.

Here is the call graph for this function:

◆ setBlankTexture()

void setBlankTexture ( const char * name)
inline

Definition at line 84 of file ColladaTool.h.

84{ if(name!=NULL) blank_texture = make_Buffer_bystr(name);}

References ColladaXML::blank_texture, and make_Buffer_bystr.

◆ setJointLocationMatrix()

void setJointLocationMatrix ( void )

void ColladaXML::setJointLocationMatrix(void)

Definition at line 1206 of file ColladaTool.cpp.

1207{
1208 if (!this->has_joints) return;
1209
1210 tXML* avatar_tag = get_xml_node_str(collada_tag, "<library_visual_scenes><visual_scene><node><matrix>");
1211 if (avatar_tag!=NULL) {
1214 //
1215 for (int i=1; i<=4; i++) {
1216 for (int j=1; j<=4; j++) {
1217 double element = affineSkeleton.element(i, j);
1218 if (i==1 && j==1) set_xml_content_node(avatar_tag, dtostr(element)); // 最初にタグを生成
1219 else append_xml_content_node(avatar_tag, dtostr(element));
1220 }
1221 }
1222 }
1223 return;
1224}
#define get_xml_node_str(p, s)
get_xml_node_bystr()
Definition txml.h:259

References ColladaXML::affineSkeleton, ColladaXML::affineTrans, append_xml_content_node(), ColladaXML::collada_tag, AffineTrans< T >::computeMatrix(), dtostr(), AffineTrans< T >::element(), get_xml_node_str, AffineTrans< T >::getShift(), ColladaXML::has_joints, ColladaXML::no_offset, set_xml_content_node(), and AffineTrans< T >::setShift().

Referenced by ColladaXML::addScene().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ added_joints_xml

bool added_joints_xml

Definition at line 130 of file ColladaTool.h.

Referenced by ColladaXML::addScene(), ColladaXML::closeSolid(), and ColladaXML::init().

◆ affineSkeleton

AffineTrans<double> affineSkeleton

◆ affineTrans

◆ asset_tag

tXML* asset_tag

Definition at line 97 of file ColladaTool.h.

Referenced by ColladaXML::initCollada().

◆ author_tag

tXML* author_tag

Definition at line 99 of file ColladaTool.h.

Referenced by ColladaXML::initCollada().

◆ authoring_tool_tag

tXML* authoring_tool_tag

Definition at line 100 of file ColladaTool.h.

Referenced by ColladaXML::initCollada().

◆ blank_texture

◆ collada_tag

tXML* collada_tag

Definition at line 96 of file ColladaTool.h.

Referenced by ColladaXML::initCollada(), and ColladaXML::setJointLocationMatrix().

◆ contributor_tag

tXML* contributor_tag

Definition at line 98 of file ColladaTool.h.

Referenced by ColladaXML::initCollada().

◆ created_tag

tXML* created_tag

Definition at line 101 of file ColladaTool.h.

Referenced by ColladaXML::initCollada().

◆ forUnity

bool forUnity

Definition at line 139 of file ColladaTool.h.

Referenced by ColladaXML::addEffect(), and ColladaXML::init().

◆ forUnity5

bool forUnity5

Definition at line 138 of file ColladaTool.h.

Referenced by ColladaXML::addEffect(), and ColladaXML::init().

◆ has_joints

◆ instance_physics_model_tag

tXML* instance_physics_model_tag

Definition at line 115 of file ColladaTool.h.

Referenced by ColladaXML::addScene(), and ColladaXML::initCollada().

◆ instance_physics_scene_tag

tXML* instance_physics_scene_tag

Definition at line 123 of file ColladaTool.h.

Referenced by ColladaXML::initCollada().

◆ instance_visual_scene_tag

tXML* instance_visual_scene_tag

Definition at line 122 of file ColladaTool.h.

Referenced by ColladaXML::initCollada().

◆ joints_template_tag

tXML* joints_template_tag

◆ library_controllers_tag

tXML* library_controllers_tag

Definition at line 110 of file ColladaTool.h.

Referenced by ColladaXML::addController(), and ColladaXML::initCollada().

◆ library_effects_tag

tXML* library_effects_tag

Definition at line 107 of file ColladaTool.h.

Referenced by ColladaXML::addEffect(), and ColladaXML::initCollada().

◆ library_geometries_tag

tXML* library_geometries_tag

Definition at line 109 of file ColladaTool.h.

Referenced by ColladaXML::addGeometry(), and ColladaXML::initCollada().

◆ library_images_tag

tXML* library_images_tag

Definition at line 106 of file ColladaTool.h.

Referenced by ColladaXML::addImage(), and ColladaXML::initCollada().

◆ library_materials_tag

tXML* library_materials_tag

◆ library_physics_models_tag

tXML* library_physics_models_tag

Definition at line 112 of file ColladaTool.h.

Referenced by ColladaXML::initCollada().

◆ library_physics_scenes_tag

tXML* library_physics_scenes_tag

Definition at line 111 of file ColladaTool.h.

Referenced by ColladaXML::initCollada().

◆ library_visual_scenes_tag

tXML* library_visual_scenes_tag

Definition at line 113 of file ColladaTool.h.

Referenced by ColladaXML::initCollada().

◆ modified_tag

tXML* modified_tag

Definition at line 102 of file ColladaTool.h.

Referenced by ColladaXML::initCollada().

◆ no_offset

bool no_offset

◆ phantom_out

bool phantom_out

Definition at line 133 of file ColladaTool.h.

Referenced by ColladaXML::init().

◆ physics_model_tag

tXML* physics_model_tag

Definition at line 119 of file ColladaTool.h.

Referenced by ColladaXML::addScene(), and ColladaXML::initCollada().

◆ physics_scene_tag

tXML* physics_scene_tag

Definition at line 118 of file ColladaTool.h.

Referenced by ColladaXML::initCollada().

◆ scene_tag

tXML* scene_tag

Definition at line 121 of file ColladaTool.h.

Referenced by ColladaXML::initCollada().

◆ unit_tag

tXML* unit_tag

Definition at line 103 of file ColladaTool.h.

Referenced by ColladaXML::initCollada().

◆ up_axis_tag

tXML* up_axis_tag

Definition at line 104 of file ColladaTool.h.

Referenced by ColladaXML::initCollada().

◆ visual_scene_tag

tXML* visual_scene_tag

◆ xml_tag


The documentation for this class was generated from the following files: