why doesn't it show??

so i’ve got my script, but my sphere doesn’t show when i render it…why is that??


import Blender
from Blender import NMesh

import math
from math import * 

me=NMesh.GetRaw()

i=0.0
j=0.0

maxpoint=32.0*32.0

n=sqrt(maxpoint)
print n

radius = 2.0

for i in range(0,n):
	print i
	for j in range(0,n):
		print j
		x=sin(j*pi*2/(n-1))*cos(-pi/2+i*pi/(n-1))*radius
		y=cos(j*pi*2/(n-1))*cos(-pi/2+i*pi/(n-1))*radius
		z=sin(-pi/2+i*pi/(n-1))*radius
		v=NMesh.Vert(x,y,z)
		me.verts.append(v)

NMesh.PutRaw(me,"sphere", 1)
Blender.Redraw()

thats coz you did not create the faces. You just created the vertices.

bear with me here…i’m a complete noob at scripting…

so, now i have this:


import Blender
from Blender import NMesh

import math
from math import * 

me=NMesh.GetRaw()

i=0.0
j=0.0

maxpoint=32.0*32.0

n=sqrt(maxpoint)
print n

radius = 2.0

for i in range(0,n):
	print i
	for j in range(0,n):
		print j
		x=sin(j*pi*2/(n-1))*cos(-pi/2+i*pi/(n-1))*radius
		y=cos(j*pi*2/(n-1))*cos(-pi/2+i*pi/(n-1))*radius
		z=sin(-pi/2+i*pi/(n-1))*radius
		v=NMesh.Vert(x,y,z)
		me.verts.append(v)

n0=len(range(0,n))
print n0

for i in range(0, n-1):
	for j in range(0, n-1):
		f=NMesh.Face()
		f.v.append(me.verts[i*n0+j])
		f.v.append(me.verts[i*n0+j+1])
		f.v.append(me.verts[(i+1)*n0+j+1])
		f.v.append(me.verts[(i+1)*n0+j])
		me.faces.append(f)

NMesh.PutRaw(me,"sphere", 1)
Blender.Redraw()

but it shows up like a 2D flat circle instead of a sphere–how do i fix it to make it look like a sphere (3D)??

anyway, thanks for the patience!!

What are you talking about?

Your script does generate a sphere, in 3D. I tested it.

  • Satish.

thanks for the quick reply…

if i were to change it to, red, let’s say…when you render it. it looks flat. especially once you set it to smooth.

Hi.

Play with the positions of the light sources.

That should give it some shading.

works fine for me.