[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41074] trunk/blender: docs / clenup ( no functional code changes)

Campbell Barton ideasman42 at gmail.com
Mon Oct 17 04:20:54 CEST 2011


Revision: 41074
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41074
Author:   campbellbarton
Date:     2011-10-17 02:20:53 +0000 (Mon, 17 Oct 2011)
Log Message:
-----------
docs / clenup (no functional code changes)
- added API examples for mathutils.Color/Euler/Quaternion/Matrix.
- corrected own bad spelling matricies --> matrices.
- minor pep8 edits.
- update CMake ignore file list.

Modified Paths:
--------------
    trunk/blender/build_files/cmake/cmake_consistency_check_config.py
    trunk/blender/doc/python_api/examples/mathutils.Euler.py
    trunk/blender/doc/python_api/examples/mathutils.Matrix.py
    trunk/blender/doc/python_api/examples/mathutils.Quaternion.py
    trunk/blender/doc/python_api/rst/bge.logic.rst
    trunk/blender/release/scripts/startup/bl_ui/properties_particle.py
    trunk/blender/source/blender/blenkernel/BKE_paint.h
    trunk/blender/source/blender/blenkernel/intern/constraint.c
    trunk/blender/source/blender/editors/util/crazyspace.c
    trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c

Added Paths:
-----------
    trunk/blender/doc/python_api/examples/mathutils.Color.py

Modified: trunk/blender/build_files/cmake/cmake_consistency_check_config.py
===================================================================
--- trunk/blender/build_files/cmake/cmake_consistency_check_config.py	2011-10-16 22:54:08 UTC (rev 41073)
+++ trunk/blender/build_files/cmake/cmake_consistency_check_config.py	2011-10-17 02:20:53 UTC (rev 41074)
@@ -27,6 +27,10 @@
     "extern/eltopo/common/openglutils.cpp",
     "extern/eltopo/eltopo3d/broadphase_blenderbvh.cpp",
     "source/blender/imbuf/intern/imbuf_cocoa.m",
+    "extern/recastnavigation/Recast/Source/RecastLog.cpp",
+    "extern/recastnavigation/Recast/Source/RecastTimer.cpp",
+    "entern/audaspace/SRC/AUD_SRCResampleFactory.cpp",
+    "entern/audaspace/SRC/AUD_SRCResampleReader.cpp",
 
     "extern/bullet2/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h",
     "extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h",
@@ -41,6 +45,10 @@
     "extern/eltopo/common/meshes/TriangleIndex.hpp",
     "extern/eltopo/common/meshes/meshloader.h",
     "extern/eltopo/eltopo3d/broadphase_blenderbvh.h"
+    "extern/recastnavigation/Recast/Include/RecastLog.h",
+    "extern/recastnavigation/Recast/Include/RecastTimer.h",
+    "intern/audaspace/SRC/AUD_SRCResampleFactory.h",
+    "intern/audaspace/SRC/AUD_SRCResampleReader.h",
     )
 
 UTF8_CHECK = True

Added: trunk/blender/doc/python_api/examples/mathutils.Color.py
===================================================================
--- trunk/blender/doc/python_api/examples/mathutils.Color.py	                        (rev 0)
+++ trunk/blender/doc/python_api/examples/mathutils.Color.py	2011-10-17 02:20:53 UTC (rev 41074)
@@ -0,0 +1,30 @@
+import mathutils
+
+# color values are represented as RGB values from 0 - 1, this is blue
+col = mathutils.Color((0.0, 0.0, 1.0))
+
+# as well as r/g/b attribute access you can adjust them by h/s/v
+col.s *= 0.5
+
+# you can access its components by attribute or index
+print("Color R:", col.r)
+print("Color G:", col[1])
+print("Color B:", col[-1])
+print("Color HSV: %.2f, %.2f, %.2f", col[:])
+
+
+# components of an existing color can be set
+col[:] = 0.0, 0.5, 1.0
+
+# components of an existing color can use slice notation to get a tuple
+print("Values: %f, %f, %f" % col[:])
+
+# colors can be added and subtracted
+col += mathutils.Color((0.25, 0.0, 0.0))
+
+# Color can be multiplied, in this example color is scaled to 0-255
+# can printed as integers
+print("Color: %d, %d, %d" % (col * 255.0)[:])
+
+# This example prints the color as hexidecimal
+print("Hexidecimal: %.2x%.2x%.2x" % (col * 255.0)[:])

Modified: trunk/blender/doc/python_api/examples/mathutils.Euler.py
===================================================================
--- trunk/blender/doc/python_api/examples/mathutils.Euler.py	2011-10-16 22:54:08 UTC (rev 41073)
+++ trunk/blender/doc/python_api/examples/mathutils.Euler.py	2011-10-17 02:20:53 UTC (rev 41074)
@@ -1,3 +1,32 @@
 import mathutils
+import math
 
-# todo
+# create a new euler with default axis rotation order
+eul = mathutils.Euler((0.0, math.radians(45.0), 0.0), 'XYZ')
+
+# rotate the euler
+eul.rotate_axis(math.radians(10.0), 'Z')
+
+# you can access its components by attribute or index
+print("Euler X", eul.x)
+print("Euler Y", eul[1])
+print("Euler Z", eul[-1])
+
+# components of an existing euler can be set
+eul[:] = 1.0, 2.0, 3.0
+
+# components of an existing euler can use slice notation to get a tuple
+print("Values: %f, %f, %f" % eul[:])
+
+# the order can be set at any time too
+eul.order = 'ZYX'
+
+# eulers can be used to rotate vectors
+vec = mathutils.Vector((0.0, 0.0, 1.0))
+vec.rotate(eul)
+
+# often its useful to convert the euler into a matrix so it can be used as
+# transformations with more flexibility
+mat_rot = eul.to_matrix()
+mat_loc = mathutils.Matrix.Translation((2.0, 3.0, 4.0))
+mat = mat_loc * mat_rot.to_4x4()

Modified: trunk/blender/doc/python_api/examples/mathutils.Matrix.py
===================================================================
--- trunk/blender/doc/python_api/examples/mathutils.Matrix.py	2011-10-16 22:54:08 UTC (rev 41073)
+++ trunk/blender/doc/python_api/examples/mathutils.Matrix.py	2011-10-17 02:20:53 UTC (rev 41074)
@@ -1,3 +1,28 @@
 import mathutils
+import math
 
-# todo
+# create a location matrix
+mat_loc = mathutils.Matrix.Translation((2.0, 3.0, 4.0))
+
+# create an identitiy matrix
+mat_sca = mathutils.Matrix.Scale(0.5, 4, (0.0, 0.0, 1.0))
+
+# create a rotation matrix
+mat_rot = mathutils.Matrix.Rotation(math.radians(45.0), 4, 'X')
+
+# combine transformations
+mat_out = mat_loc * mat_rot * mat_sca
+print(mat_out)
+
+# extract components back out of the matrix
+loc, rot, sca = mat_out.decompose()
+print(loc, rot, sca)
+
+# it can also be useful to access components of a matrix directly
+mat = mathutils.Matrix()
+mat[0][0], mat[1][0], mat[2][0] = 0.0, 1.0, 2.0
+
+mat[0][0:3] = 0.0, 1.0, 2.0
+
+# each item in a matrix is a vector so vector utility functions can be used
+mat[0].xyz = 0.0, 1.0, 2.0

Modified: trunk/blender/doc/python_api/examples/mathutils.Quaternion.py
===================================================================
--- trunk/blender/doc/python_api/examples/mathutils.Quaternion.py	2011-10-16 22:54:08 UTC (rev 41073)
+++ trunk/blender/doc/python_api/examples/mathutils.Quaternion.py	2011-10-17 02:20:53 UTC (rev 41074)
@@ -1,3 +1,23 @@
 import mathutils
+import math
 
-# todo
+# a new rotation 90 degrees about the Y axis
+quat_a = mathutils.Quaternion((0.7071068, 0.0, 0.7071068, 0.0))
+
+# passing values to Quaternion's directly can be confusing so axis, angle
+# is supported for initializing too
+quat_b = mathutils.Quaternion((0.0, 1.0, 0.0), math.radians(90.0))
+
+print("Check quaternions match", quat_a == quat_b)
+
+# like matrices, quaternions can be multiplied to accumulate rotational values
+quat_a = mathutils.Quaternion((0.0, 1.0, 0.0), math.radians(90.0))
+quat_b = mathutils.Quaternion((0.0, 0.0, 1.0), math.radians(45.0))
+quat_out = quat_a * quat_b
+
+# print the quat, euler degrees for mear mortals and (axis, angle)
+print("Final Rotation:")
+print(quat_out)
+print("%.2f, %.2f, %.2f" % tuple(math.degrees(a) for a in quat_out.to_euler()))
+print("(%.2f, %.2f, %.2f), %.2f" % (quat_out.axis[:] +
+                                    (math.degrees(quat_out.angle), )))

Modified: trunk/blender/doc/python_api/rst/bge.logic.rst
===================================================================
--- trunk/blender/doc/python_api/rst/bge.logic.rst	2011-10-16 22:54:08 UTC (rev 41073)
+++ trunk/blender/doc/python_api/rst/bge.logic.rst	2011-10-17 02:20:53 UTC (rev 41074)
@@ -106,7 +106,7 @@
 Matricies as used by the game engine are **row major**
 ``matrix[row][col] = float``
 
-:class:`bge.types.KX_Camera` has some examples using matricies.
+:class:`bge.types.KX_Camera` has some examples using matrices.
 
 *********
 Variables

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_particle.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_particle.py	2011-10-16 22:54:08 UTC (rev 41073)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_particle.py	2011-10-17 02:20:53 UTC (rev 41074)
@@ -404,7 +404,7 @@
             part = context.space_data.pin_id
 
         layout.enabled = particle_panel_enabled(context, psys)
-        
+
         layout.prop(part, "use_dynamic_rotation")
 
         if part.use_dynamic_rotation:
@@ -433,7 +433,6 @@
             subsub = sub.column()
             subsub.active = part.angular_velocity_mode != 'NONE'
             subsub.prop(part, "angular_velocity_factor", text="")
-            
 
 
 class PARTICLE_PT_physics(ParticleButtonsPanel, Panel):

Modified: trunk/blender/source/blender/blenkernel/BKE_paint.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_paint.h	2011-10-16 22:54:08 UTC (rev 41073)
+++ trunk/blender/source/blender/blenkernel/BKE_paint.h	2011-10-17 02:20:53 UTC (rev 41074)
@@ -84,7 +84,7 @@
 	int modifiers_active; /* object is deformed with some modifiers */
 	float (*orig_cos)[3]; /* coords of undeformed mesh */
 	float (*deform_cos)[3]; /* coords of deformed mesh but without stroke displacement */
-	float (*deform_imats)[3][3]; /* crazyspace deformation matricies */
+	float (*deform_imats)[3][3]; /* crazyspace deformation matrices */
 
 	/* Partial redraw */
 	int partial_redraw;

Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c	2011-10-16 22:54:08 UTC (rev 41073)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2011-10-17 02:20:53 UTC (rev 41074)
@@ -4351,7 +4351,7 @@
  * constraints either had one or no targets. It used to be called during the main constraint solving
  * loop, but is now only used for the remaining cases for a few constraints. 
  *
- * None of the actual calculations of the matricies should be done here! Also, this function is 
+ * None of the actual calculations of the matrices should be done here! Also, this function is
  * not to be used by any new constraints, particularly any that have multiple targets.
  */
 void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, short ownertype, void *ownerdata, float mat[][4], float ctime)

Modified: trunk/blender/source/blender/editors/util/crazyspace.c
===================================================================
--- trunk/blender/source/blender/editors/util/crazyspace.c	2011-10-16 22:54:08 UTC (rev 41073)
+++ trunk/blender/source/blender/editors/util/crazyspace.c	2011-10-17 02:20:53 UTC (rev 41074)
@@ -384,7 +384,7 @@
 	int totleft= sculpt_get_first_deform_matrices(scene, ob, deformmats, deformcos);
 
 	if(totleft) {
-		/* there are deformation modifier which doesn't support deformation matricies
+		/* there are deformation modifier which doesn't support deformation matrices
 		   calculation. Need additional crazyspace correction */
 
 		float (*deformedVerts)[3]= *deformcos;

Modified: trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c	2011-10-16 22:54:08 UTC (rev 41073)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list