利用者:Walid shouman/Drafts

提供: wiki
< 利用者:Walid shouman
2018年6月29日 (金) 05:56時点におけるYamyam (トーク | 投稿記録)による版 (1版 をインポートしました)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

This page isn't intended to be informatic as much as it's as a draft for whatever I'm thinking about adding to the wiki, Walid shouman 01:12, 4 June 2013 (CEST)

what I'm up to now is making a custom data transfer between 2 meshes Priority-high.png

Details

  • Custom Data type: CD_MLOOPCOL (mesh color)
  • Custom Data number: 17


Actions

  • Link to new files that will hold the bmesh tools & operators(getting everything organized)
    in progress Inprogress100.jpg 100%
      :D
  • Registering a new operator (ease the development)-skipped for now first things first :D -
  • Getting the functions to work without errors (proving that I understood how to deal with customData and Bmesh)
    in progress Inprogress25.jpg 10%
     
  • Transferring the data successfully

Readings

Within the step of registering

Extra things

Totally like this progress bar ^_^

in progress Inprogress50.jpg 30%

 good progresses

Thought

Before getting things out of the draft I was thinking about a good hierarchy for this blog

Adding a file

this is considered a reminder till the blog is set up: Tips for adding a file

  • Create ur file.h //check the format of #ifdefs from any neighbouring file2.h
  • Create ur file.c //include the file.h into it
  • Declare the necessary functions of file.c in file.h
  • Add the file.c and file.h to the nearest CMakeList (for cmake users like me)
  • Goto the calling_file.c that will call ur function
  • Open its CMakeList and check the folders included there (figure out the nearest folder to file.h ... in my case it was ../../bmesh)
  • Open the calling_file.c and include the file.h relative to the nearest folder to it ... in my case it was (#include "tools/bmesh_transfer_data.h") as the file's path was blender/source/blender/bmesh/tools/bmesh_transfer_data.h
  • Now call any function you've already declared in file.h
  • That's it :)

Making/registering an operator

Overview

  • This guide is based upon testings! be careful :)
  • Operators's functionality could either be written in C or Python but the common thing is that registering happens in Python
  • The term functionality here includes (exec Code, description, name displayed in search(space bar), options)
  • Other than that would be registering AKA UI (or even easier finding the operator itself in the program)
  • Here I'll illustrate the steps to add the transfer shape keys within C and registering it in Python

Python part

  • Want to add the operator into the 3D View editor, open bin/2.67/scripts/startup/bl_ui/space_view3d_toolbar.py then find the section u want to add the operator into (sections represent different modes) for me i chosen
  1. ********** default tools for object-mode ****************

then add the following line @ line=~117

col.operator("object.shape_key_transfer", text="Transfer Shapekeys")

the first argument shape_key_transfer Must be the same as defined in C the second argument is the button's text

  • Want to add to a more relevant place (more difficult), open Properties_data_mesh.py, under the MESH_MT_shape_key_specials, add the following line
layout.operator("object.shape_key_transfer", icon='COPY_ID')

the first argument is the opertor name , the second is the icon name

  • Note: in my special case i had to change the name and label of the old shape key transfer tool found in 2.67/scirpts/startup/bl_operators/object.py to distinguish between the tool under development and the old tool written in python
    bl_idname = "object.shape_key_transfer_old"
    bl_label = "Transfer Shape Key Old"

C part

  • 4 main steps are to be done here
  • My function shall be written in the object scope so open blender/source/blender/editors/object/object_shapekey.c then append the funtion responsible for handling the operator to the end of the file
void OBJECT_OT_shape_key_transfer(wmOperatorType *ot)
{
	//notice that the function name should match the first argument sent in the python code

	/* identifiers */
	ot->name = "Transfer Shape Key";
	ot->idname = "OBJECT_OT_shape_key_transfer";
	ot->description = "Transfer () shape key to the selected objects";

	/* api callbacks */
	ot->poll = shape_key_poll;			//don't know how to edit this yet!!
	ot->exec = shape_key_transfer_exec;

	/* flags */
	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;

	/* properties */ //not yet!!
	//not available
}
  • Add the poll(already there for my case) and exec functions above the previous function... and let's have a trivial exec function that does nothing
static int shape_key_transfer_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
{
	/** UNUSED are used to tell the compiler not to worry and we don't want to use those variables
	* static int and return OPERATOR_FINISHED upon success are just necessery
	*/
	return OPERATOR_FINISHED;

}
  • Add the OBJECT_OT_shape_key_transfer() to the header file, open blender/source/blender/editors/object/object_intern.h and append the following after the other shape key functions around line =~234
void OBJECT_OT_shape_key_transfer(struct wmOperatorType *ot);
  • Finally add the function to the object operators to be accessed by Python, open blender/source/blender/editors/object/object_ops.c and append the following after the other shape key functions around line =~212
	WM_operatortype_append(OBJECT_OT_shape_key_transfer);


basis for the UV transfer function

Those drafts could be a bit messy but they were the basis for many steps to determining how to transfer UVs

raycasting UV algorithm seed based on Alexx reference
spatial UV algorithm seed
loop interpolation
サムネイルの作成エラー: 12.5メガピクセルよりも大きな寸法のファイル
island based transfer (see full resolution if the preview didn't work)