Graphics Reference
In-Depth Information
""
"location": "View3D > Add > Bouncing Cone",
"description": "Add a bouncing, colored cone.",
"warning": "",
"wiki_url": "http://wiki.blender.org",
"tracker_url": "https://projects.blender.org",
"category": "Add Object"}
import bpy
from bpy.props import FloatVectorProperty, FloatProperty
from add_utils import AddObjectHelper, add_object_data
from mathutils import Vector
from math import *
cverts = 10
def addBouncingCone(self, context):
scale_x = self.scale.x
scale_y = self.scale.y
scale_z = self.scale.z
verts = [Vector((0,0,0)),Vector((0,0,self.height*scale_z))]
edges = []
faces = []
for j in range(0,cverts,1):
x = (sin(j*pi*2/(cverts-1))*self.radius)*scale_x
y = (cos(j*pi*2/(cverts-1))*self.radius)*scale_y
z = 0
verts.append(Vector((x,y,z)))
if j > 0:
faces.extend([[0,j+1,j+2],[1,j+1,j+2]])
mesh = bpy.data.meshes.new(name='Bouncing Cone')
mesh.from_pydata(verts, edges, faces)
add_object_data(context, mesh, operator=self)
mesh.update(calc_edges=True)
obj = bpy.context.selected_objects
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.ops.mesh.normals_make_consistent(inside=False)
bpy.ops.mesh.remove_doubles(mergedist=0.0001)
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
obj = bpy.context.object
mat = bpy.data.materials.new(name="Cone Material")
mat.diffuse_color.r = self.r
mat.diffuse_color.g = self.g
mat.diffuse_color.b = self.b
obj.active_material = mat
obj.location[2] = self.location[2]
startframe = 1
Search WWH ::




Custom Search