added the flag group_exclusive to material

added restrictDraw/Select/Render to objects in python
updated group and scene docs for last commit
made 3ds import use new scn.objects rather then Object.New() - (removed import as instance for now)
fixes off import error from this report http://blenderartists.org/forum/showthread.php?t=84182
This commit is contained in:
Campbell Barton 2006-12-11 08:57:39 +00:00
parent b42d1fe544
commit 9c3cacd283
8 changed files with 97 additions and 38 deletions

@ -130,8 +130,13 @@ try:
except:
from sets import Set as set
#global SCN_OBJECTS
#SCN_OBJECTS = None
BOUNDS_3DS= []
#this script imports uvcoords as sticky vertex coords
#this parameter enables copying these to face uv coords
#which shold be more useful.
@ -392,8 +397,10 @@ def process_next_chunk(file, previous_chunk, importedObjects):
tempName= '%s_%s' % (contextObName, matName) # matName may be None.
bmesh.name= tempName
ob = Object.New('Mesh', tempName)
ob.link(bmesh)
# ob = Object.New('Mesh', tempName)
# ob.link(bmesh)
ob = SCN_OBJECTS.new(bmesh, tempName)
####ob.setMatrix(contextMatrix)
importedObjects.append(ob)
@ -739,15 +746,15 @@ def process_next_chunk(file, previous_chunk, importedObjects):
putContextMesh(contextMesh_vertls, contextMesh_facels, contextMeshMaterials)
def load_3ds(filename, PREF_UI= True):
global FILENAME, SCN_OBJECTS
if BPyMessages.Error_NoFile(filename):
return
print '\n\nImporting "%s" "%s"' % (filename, Blender.sys.expandpath(filename))
print '\n\nImporting 3DS: "%s"' % (Blender.sys.expandpath(filename))
time1= Blender.sys.time()
global FILENAME
FILENAME=filename
current_chunk=chunk()
@ -768,7 +775,7 @@ def load_3ds(filename, PREF_UI= True):
# Get USER Options
pup_block= [\
('Size Constraint:', IMPORT_CONSTRAIN_BOUNDS, 0.0, 1000.0, 'Scale the model by 10 until it reacehs the size constraint. Zero Disables.'),\
('Group Instance', IMPORT_AS_INSTANCE, 'Import objects into a new scene and group, creating an instance in the current scene.'),\
#('Group Instance', IMPORT_AS_INSTANCE, 'Import objects into a new scene and group, creating an instance in the current scene.'),\
]
if PREF_UI:
@ -782,16 +789,18 @@ def load_3ds(filename, PREF_UI= True):
BOUNDS_3DS[:]= [1<<30, 1<<30, 1<<30, -1<<30, -1<<30, -1<<30]
else:
BOUNDS_3DS[:]= []
scn= Scene.GetCurrent()
SCN_OBJECTS = scn.objects
for ob in SCN_OBJECTS:
ob.sel= 0
importedObjects= [] # Fill this list with objects
process_next_chunk(file, current_chunk, importedObjects)
scn= Scene.GetCurrent()
for ob in scn.getChildren():
ob.sel= 0
# Link the objects into this scene.
Layers= scn.Layers
# Layers= scn.Layers
# REMOVE DUMMYVERT, - remove this in the next release when blenders internal are fixed.
for ob in importedObjects:
@ -799,7 +808,7 @@ def load_3ds(filename, PREF_UI= True):
me= ob.getData(mesh=1)
me.verts.delete([me.verts[0],])
# Done DUMMYVERT
"""
if IMPORT_AS_INSTANCE:
name= filename.split('\\')[-1].split('/')[-1]
# Create a group for this import.
@ -822,6 +831,7 @@ def load_3ds(filename, PREF_UI= True):
scn.link(ob)
ob.Layers= Layers
ob.sel= 1
"""
if IMPORT_CONSTRAIN_BOUNDS!=0.0:
# Set bounds from objecyt bounding box
@ -838,7 +848,7 @@ def load_3ds(filename, PREF_UI= True):
# Get the max axis x/y/z
max_axis= max(BOUNDS_3DS[3]-BOUNDS_3DS[0], BOUNDS_3DS[4]-BOUNDS_3DS[1], BOUNDS_3DS[5]-BOUNDS_3DS[2])
print max_axis
# print max_axis
if max_axis < 1<<30: # Should never be false but just make sure.
# Get a new scale factor if set as an option

@ -77,7 +77,7 @@ def read(filename):
# === OFF Header ===
# Skip the comments
offheader= file.readline()
while offheader.startswith('#'):
while offheader.startswith('#') or offheader.lower().startswith('off'):
offheader = file.readline()
numverts, numfaces, numedges= map(int, offheader.split())
@ -105,11 +105,15 @@ def read(filename):
for i in xrange(numfaces):
line = file.readline().split() # ignore the first value, its just the face count but we can work that out anyway
# appends all the indicies in reverse order except 0
# xrange(len(line)-1, -1, -1) # normal reverse loop
# xrange(len(line)-1, 0, -1) # ignoring index 0 because its only a count
face= [int(line[j]) for j in xrange(len(line)-1, 0, -1)]
# face= [int(line[j]) for j in xrange(len(line)-1, 0, -1)]
# Some OFF files have floats on the end of the face. what are these for?
face= [int(line[j]) for j in xrange(int(line[0]), 0, -1)]
if len(face)>4:
faces.extend( fan_face(face) )
else:
@ -136,9 +140,15 @@ def read(filename):
edge_dict[i1,i2]= ed
# Now make known edges fisible
# Now make known edges visible
has_edges = True
for i in xrange(numedges):
i1,i2= file.readline().split()
try:
i1,i2= file.readline().split()
except:
has_edges = False
break # some files dont define edges :/
i1= int(i1)
i2= int(i2)
if i1>i2:
@ -146,7 +156,12 @@ def read(filename):
# We know this edge is seen so unset the fgon flag
edge_dict[i1,i2].flag &= ~FGON_FLAG
if not has_edges:
# dang, we'v turned all the edges into fgons and then the file didnt define any edges.
# oh well, just enable them all
for ed in me.edges:
ed.flag &= ~FGON_FLAG
# Assign uvs from vert index
if has_uv:
@ -155,14 +170,10 @@ def read(filename):
for i, v in enumerate(f): # same as f.v
f_uv[i]= uvs[v.index]
for ob in scn.getChildren():
for ob in scn.objects:
ob.sel=0
ob= Blender.Object.New('Mesh', name)
ob.link(me)
scn.link(ob)
ob.Layers= scn.Layers
ob.sel= 1
scn.objects.active = scn.objects.new(me, name)
Blender.Window.RedrawAll()
print 'Off "%s" imported in %.4f seconds.' % (name, Blender.sys.time()-start)

@ -359,6 +359,7 @@ static PyObject *Material_ModesDict( void )
PyConstant_Insert(c, "RAYTRANSP", PyInt_FromLong(MA_RAYTRANSP));
PyConstant_Insert(c, "TANGENT_V", PyInt_FromLong(MA_TANGENT_V));
PyConstant_Insert(c, "NMAP_TS", PyInt_FromLong(MA_NORMAP_TANG));
PyConstant_Insert(c, "GROUP_EXCLUSIVE", PyInt_FromLong(MA_GROUP_NOLAY));
}
return Modes;

@ -4100,6 +4100,25 @@ static int setFloat3Attr( BPy_Object *self, PyObject *value, void *type )
/* BPy_Object methods and attribute handlers */
/*****************************************************************************/
static PyObject *Object_getRestricted( BPy_Object *self, void *type )
{
if (self->object->restrictflag & (short)type)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
static int Object_setRestricted( BPy_Object *self, PyObject *value,
void *type )
{
if (PyObject_IsTrue(value) )
self->object->restrictflag |= (short)type;
else
self->object->restrictflag &= ~(short)type;
return 0;
}
static PyObject *Object_getDrawModeBits( BPy_Object *self, void *type )
{
return EXPP_getBitfield( (void *)&self->object->dtx, (int)type, 'b' );
@ -5057,6 +5076,20 @@ static PyGetSetDef BPy_Object_getseters[] = {
(getter)Object_getType, (setter)NULL,
"String describing Object type",
NULL},
{"restrictDisplay",
(getter)Object_getRestricted, (setter)Object_setRestricted,
"Toggle object restrictions",
(void *)OB_RESTRICT_VIEW},
{"restrictSelect",
(getter)Object_getRestricted, (setter)Object_setRestricted,
"Toggle object restrictions",
(void *)OB_RESTRICT_SELECT},
{"restrictRender",
(getter)Object_getRestricted, (setter)Object_setRestricted,
"Toggle object restrictions",
(void *)OB_RESTRICT_RENDER},
{"properties", (getter)Object_GetProperties, (setter)NULL,
"Get the ID properties associated with this object"},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */

@ -15,9 +15,9 @@ Example::
from Blender import *
scn= Scene.GetCurrent()
for ob in Object.GetSelected():
for ob in scn.objects:
print 'Object Group Settings'
print ob.name, ob.getType()
print ob.name, ob.type
print 'enableDupVerts:', ob.enableDupVerts
print 'enableDupFrames:', ob.enableDupFrames
print 'enableDupGroup:', ob.enableDupGroup
@ -27,9 +27,7 @@ Example::
for dup_ob, dup_matrix in dupe_obs:
print '\tDupOb', dup_ob.name
new_ob= Object.New(dup_ob.getType())
new_ob.shareFrom(dup_ob)
scn.link(new_ob)
scn.objects.new(dup_ob.data)
new_ob.setMatrix(dup_matrix)
new_ob.sel= 1 # select all real instances.
@ -46,14 +44,13 @@ Example::
scn= Scene.GetCurrent()
# New Group
gp= Group.New('mygroup')
gp.objects= Object.GetSelected()
grp= Group.New('mygroup')
grp.objects= scn.objects
# Instance the group at an empty using dupligroups
ob= Object.New('Empty')
scn.link(ob)
ob= scn.objects.new(None)
ob.enableDupGroup= True
ob.DupGroup= gp
ob.DupGroup= grp
Window.RedrawAll()
"""
@ -94,8 +91,8 @@ class Group:
@ivar users: Number of users this group has (read only)
@ivar layers: Layer mask for this group.
@ivar objects: Objects that this group uses.
This is an iterator with list like access so use list(gp.objects) if you need to use a list. (where gp is a group object).
This is a sequence with list like access so use list(grp.objects) if you need to use a list. (where grp is a group).
The groups objects can be set by assigning a list or iterator of objects to the groups objects.
objects.add() and objects.remove() also work with the the objects iterator just like with lists.
objects.link() and objects.unlink() also work with the the objects iterator just like with lists.
"""

@ -66,6 +66,7 @@ Example::
- FULLOSA - Force rendering of all OSA samples.
- TANGENT_V - Use the tangent vector in V direction for shading
- NMAP_TS - Tangent space normal mapping.
- GROUP_EXCLUSIVE - Light from this group even if the lights are on a hidden Layer.
@type Shaders: readonly dictionary
@var Shaders: The available Material Shaders.

@ -250,6 +250,12 @@ class Object:
this object's ID Properties. Note that dict access is available for groups on the parent
L{IDProperty<IDProperty>} object, but for everything else you need to get the L{IDGroup<IDGroup>}
object from the L{IDProperty<IDProperty>}'s data member.
@ivar restrictDisplay: Dont display this object in the 3d view, disabled by default, use the outliner to toggle.
@type restrictDisplay: bool
@ivar restrictSelect: Dont select this object in the 3d view, disabled by default, use the outliner to toggle.
@type restrictSelect: bool
@ivar restrictRender: Dont render this object, disabled by default, use the outliner to toggle.
@type restrictRender: bool
@ivar LocX: The X location coordinate of the object.
@type LocX: float
@ivar LocY: The Y location coordinate of the object.

@ -106,8 +106,8 @@ class Scene:
scene.layers = [3] # set layer 3
scene.layers = scene.layers.append(1)
print scene.layers # will print: [1, 3]
@type objects: list of objects
@ivar objects: An iterator for the scenes objects with set-like functionality.
@type objects: sequence of objects
@ivar objects: An iterator for the scenes objects with with functions .link(ob) .unlink(ob) .new(obdata)
"""
def getName():