예제 #1
0
static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
{
	Object *obedit;
	BMEditMesh *em;
	float loc[3], rot[3], mat[4][4], dia;
	bool enter_editmode;
	bool was_editmode;
	unsigned int layer;

	ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
	obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Icosphere"), &dia, mat, &was_editmode, loc, rot, layer);
	em = BKE_editmesh_from_object(obedit);

	if (!EDBM_op_call_and_selectf(
	        em, op, "verts.out", false,
	        "create_icosphere subdivisions=%i diameter=%f matrix=%m4",
	        RNA_int_get(op->ptr, "subdivisions"),
	        RNA_float_get(op->ptr, "size"), mat))
	{
		return OPERATOR_CANCELLED;
	}

	make_prim_finish(C, obedit, was_editmode, enter_editmode);

	return OPERATOR_FINISHED;
}
예제 #2
0
static int add_primitive_cone_exec(bContext *C, wmOperator *op)
{
	Object *obedit;
	BMEditMesh *em;
	float loc[3], rot[3], mat[4][4], dia;
	bool enter_editmode;
	unsigned int layer;
	bool was_editmode;
	const int end_fill_type = RNA_enum_get(op->ptr, "end_fill_type");
	const bool cap_end = (end_fill_type != 0);
	const bool cap_tri = (end_fill_type == 2);

	ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
	obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Cone"), &dia, mat, &was_editmode, loc, rot, layer);
	em = BKE_editmesh_from_object(obedit);

	if (!EDBM_op_call_and_selectf(
	        em, op, "verts.out", false,
	        "create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f matrix=%m4",
	        RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1"),
	        RNA_float_get(op->ptr, "radius2"), cap_end, cap_tri, RNA_float_get(op->ptr, "depth"), mat))
	{
		return OPERATOR_CANCELLED;
	}

	make_prim_finish(C, obedit, was_editmode, enter_editmode);

	return OPERATOR_FINISHED;
}
예제 #3
0
static int add_primitive_monkey_exec(bContext *C, wmOperator *op)
{
	Object *obedit;
	BMEditMesh *em;
	float loc[3], rot[3], mat[4][4], dia;
	bool enter_editmode;
	bool is_view_aligned;
	unsigned int layer;
	bool was_editmode;

	ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, &is_view_aligned);
	if (!is_view_aligned)
		rot[0] += (float)M_PI / 2.0f;

	obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Suzanne"), &dia, mat, &was_editmode, loc, rot, layer);
	dia = RNA_float_get(op->ptr, "radius");
	mat[0][0] *= dia;
	mat[1][1] *= dia;
	mat[2][2] *= dia;

	em = BKE_editmesh_from_object(obedit);

	if (!EDBM_op_call_and_selectf(
	        em, op, "verts.out",  false,
	        "create_monkey matrix=%m4", mat))
	{
		return OPERATOR_CANCELLED;
	}

	make_prim_finish(C, obedit, was_editmode, enter_editmode);

	return OPERATOR_FINISHED;
}
예제 #4
0
static int add_primitive_cube_exec(bContext *C, wmOperator *op)
{
	Object *obedit;
	BMEditMesh *em;
	float loc[3], rot[3], mat[4][4], dia;
	bool enter_editmode;
	bool was_editmode;
	unsigned int layer;

	ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
	obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Cube"), &dia, mat, &was_editmode, loc, rot, layer);
	em = BKE_editmesh_from_object(obedit);

	if (!EDBM_op_call_and_selectf(
	        em, op, "verts.out", false,
	        "create_cube matrix=%m4 size=%f",
	        mat, RNA_float_get(op->ptr, "radius") * 2.0f))
	{
		return OPERATOR_CANCELLED;
	}

	/* BMESH_TODO make plane side this: M_SQRT2 - plane (diameter of 1.41 makes it unit size) */
	make_prim_finish(C, obedit, was_editmode, enter_editmode);

	return OPERATOR_FINISHED;
}
예제 #5
0
static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
{
	Object *obedit;
	Mesh *me;
	BMEditMesh *em;
	float loc[3], rot[3], mat[4][4], dia;
	int enter_editmode;
	int state;
	unsigned int layer;
	
	ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
	make_prim_init(C, "Icosphere", &dia, mat, &state, loc, rot, layer);

	obedit = CTX_data_edit_object(C);
	me = obedit->data;
	em = me->edit_btmesh;

	if (!EDBM_op_call_and_selectf(
	        em, op, "vertout",
	        "create_icosphere subdivisions=%i diameter=%f mat=%m4",
	        RNA_int_get(op->ptr, "subdivisions"),
	        RNA_float_get(op->ptr, "size"), mat))
	{
		return OPERATOR_CANCELLED;
	}
	
	make_prim_finish(C, &state, enter_editmode);

	return OPERATOR_FINISHED;	
}
예제 #6
0
static int add_primitive_monkey_exec(bContext *C, wmOperator *op)
{
	Object *obedit;
	Mesh *me;
	BMEditMesh *em;
	float loc[3], rot[3], mat[4][4], dia;
	int enter_editmode;
	int state, view_aligned;
	unsigned int layer;
	
	ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, &view_aligned);
	if (!view_aligned)
		rot[0] += M_PI / 2.0f;
	
	make_prim_init(C, "Monkey", &dia, mat, &state, loc, rot, layer);

	obedit = CTX_data_edit_object(C);
	me = obedit->data;
	em = me->edit_btmesh;

	if (!EDBM_op_call_and_selectf(em, op, "vertout", "create_monkey mat=%m4", mat)) {
		return OPERATOR_CANCELLED;
	}
	
	make_prim_finish(C, &state, enter_editmode);
	return OPERATOR_FINISHED;
}
예제 #7
0
static int add_primitive_cone_exec(bContext *C, wmOperator *op)
{
	Object *obedit;
	Mesh *me;
	BMEditMesh *em;
	float loc[3], rot[3], mat[4][4], dia;
	int enter_editmode;
	int state, cap_end, cap_tri;
	unsigned int layer;
	
	cap_end = RNA_enum_get(op->ptr, "end_fill_type");
	cap_tri = (cap_end == 2);
	
	ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
	make_prim_init(C, "Cone", &dia, mat, &state, loc, rot, layer);

	obedit = CTX_data_edit_object(C);
	me = obedit->data;
	em = me->edit_btmesh;

	if (!EDBM_op_call_and_selectf(
	        em, op, "vertout",
	        "create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f mat=%m4",
	        RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1"),
	        RNA_float_get(op->ptr, "radius2"), cap_end, cap_tri, RNA_float_get(op->ptr, "depth"), mat))
	{
		return OPERATOR_CANCELLED;
	}
	
	make_prim_finish(C, &state, enter_editmode);

	return OPERATOR_FINISHED;
}
예제 #8
0
static int add_primitive_cube_exec(bContext *C, wmOperator *op)
{
	Object *obedit;
	Mesh *me;
	BMEditMesh *em;
	float loc[3], rot[3], mat[4][4], dia;
	int enter_editmode;
	int state;
	unsigned int layer;
	
	ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
	make_prim_init(C, "Cube", &dia, mat, &state, loc, rot, layer);

	obedit = CTX_data_edit_object(C);
	me = obedit->data;
	em = me->edit_btmesh;

	if (!EDBM_op_call_and_selectf(em, op, "vertout", "create_cube mat=%m4 size=%f", mat, dia * 2.0f)) {
		return OPERATOR_CANCELLED;
	}
	
	/* BMESH_TODO make plane side this: M_SQRT2 - plane (diameter of 1.41 makes it unit size) */
	make_prim_finish(C, &state, enter_editmode);

	return OPERATOR_FINISHED;
}