OPTION(WITH_FFMPEG "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)" OFF)
OPTION(WITH_OPENAL "Enable OpenAL Support (http://www.openal.org)" ON)
OPTION(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" OFF)
-OPTION(WITH_WEBPLUGIN "Enable Web Plugin (Mozilla-Unix only)" OFF)
+OPTION(WITH_WEBPLUGIN "Enable Web Plugin (Unix only)" OFF)
IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
SET(FTGL_LIB extern_ftgl)
+#-----------------------------------------------------------------------------
+# Blender WebPlugin
+
+IF(WITH_WEBPLUGIN)
+ SET(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
+ SET(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
+
+ SET(WITH_PLAYER ON)
+ENDIF(WITH_WEBPLUGIN)
+
+
#-----------------------------------------------------------------------------
# Configure OpenGL.
INCLUDE(${CMAKE_ROOT}/Modules/FindOpenGL.cmake)
# Blender Application
SUBDIRS(source/creator)
-#-----------------------------------------------------------------------------
-# Blender WebPlugin
-IF(WITH_WEBPLUGIN)
- SET(MOZILLA_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
- SET(WITH_PLAYER ON)
-ENDIF(WITH_WEBPLUGIN)
#-----------------------------------------------------------------------------
# Blender Player
BF_FFMPEG_INC = '${BF_FFMPEG}/include'
BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
+# enable ogg, vorbis and theora in ffmpeg
+WITH_BF_OGG = 'false' # -DWITH_OGG
+BF_OGG = '/usr'
+BF_OGG_INC = '${BF_OGG}/include'
+BF_OGG_LIB = 'ogg vorbis theoraenc theoradec'
+
WITH_BF_OPENJPEG = 'true'
BF_OPENJPEG = '#extern/libopenjpeg'
BF_OPENJPEG_LIB = ''
-# Uncomment the following two lines to use system's ffmpeg
-# BF_FFMPEG = '/usr'
-# BF_FFMPEG_LIB = 'avformat avcodec swscale avutil'
BF_OPENJPEG_INC = '${BF_OPENJPEG}/include'
BF_OPENJPEG_LIBPATH='${BF_OPENJPEG}/lib'
WITH_BF_REDCODE = 'false'
BF_REDCODE = '#extern/libredcode'
BF_REDCODE_LIB = ''
-# Uncomment the following two lines to use system's ffmpeg
-# BF_FFMPEG = '/usr'
-# BF_FFMPEG_LIB = 'avformat avcodec swscale avutil'
BF_REDCODE_INC = '${BF_REDCODE}/include'
BF_REDCODE_LIBPATH='${BF_REDCODE}/lib'
BF_VERSE_INCLUDE = "#extern/verse/dist"
# enable ffmpeg support
-WITH_BF_FFMPEG = 'false' # -DWITH_FFMPEG
+WITH_BF_FFMPEG = 'true' # -DWITH_FFMPEG
BF_FFMPEG = LIBDIR +'/ffmpeg'
BF_FFMPEG_INC = '${BF_FFMPEG}/include'
BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib'
BF_OPENEXR = LIBDIR + '/openexr'
BF_OPENEXR_INC = '${BF_OPENEXR}/include ${BF_OPENEXR}/include/IlmImf ${BF_OPENEXR}/include/Iex ${BF_OPENEXR}/include/Imath '
BF_OPENEXR_LIB = ' Iex Half IlmImf Imath IlmThread '
-BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib_msvc'
+BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib_vs2008'
# Warning, this static lib configuration is untested! users of this OS please confirm.
BF_OPENEXR_LIB_STATIC = '${BF_OPENEXR}/lib/libHalf.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_OPENEXR}/lib/libIex.a ${BF_OPENEXR}/lib/libImath.a ${BF_OPENEXR}/lib/libIlmThread.a'
BF_FTGL_INC = '${BF_FTGL}/include'
BF_FTGL_LIB = 'extern_ftgl'
-WITH_BF_GAMEENGINE = 'false'
+WITH_BF_GAMEENGINE = 'true'
+WITH_BF_PLAYER = 'true'
WITH_BF_ODE = 'true'
BF_ODE = LIBDIR + '/ode'
CC = 'cl.exe'
CXX = 'cl.exe'
-CCFLAGS = ['/nologo', '/Og', '/Ot', '/Ob1', '/Op', '/G6','/EHsc', '/J', '/W3', '/Gd', '/MT']
+CCFLAGS = ['/nologo', '/Ob1', '/J', '/W3', '/Gd', '/MT']
BF_DEBUG_FLAGS = ['/Zi', '/FR${TARGET}.sbr']
LLIBS = 'ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid'
PLATFORM_LINKFLAGS = '''
- /SUBSYSTEM:CONSOLE
- /MACHINE:IX86
- /ENTRY:mainCRTStartup
- /INCREMENTAL:NO
- /NODEFAULTLIB:"msvcprt.lib"
- /NODEFAULTLIB:"glut32.lib"
- /NODEFAULTLIB:"libc.lib"
- /NODEFAULTLIB:"libcd.lib"
- /NODEFAULTLIB:"libcpd.lib"
- /NODEFAULTLIB:"libcp.lib"
- '''
-
+ /SUBSYSTEM:CONSOLE
+ /MACHINE:IX86
+ /ENTRY:mainCRTStartup
+ /INCREMENTAL:NO
+ /NODEFAULTLIB:"msvcprt.lib"
+ /NODEFAULTLIB:"glut32.lib"
+ /NODEFAULTLIB:"libc.lib"
+ /NODEFAULTLIB:"libcd.lib"
+ /NODEFAULTLIB:"libcpd.lib"
+ /NODEFAULTLIB:"libcp.lib"
+ /LARGEADDRESSAWARE
+ '''
+
BF_BUILDDIR = '..\\build\\win32-vc'
BF_INSTALLDIR='..\\install\\win32-vc'
$BLENDERHOME/config/(platform)-config.py. After the build successfully
completes, you can find everything you need in BF_INSTALLDIR.
+ If you want to create the installer package of Blender on Windows you'll
+ need to install nullsoft scriptable install system from http://nsis.sf.net.
+ As an extra dependency, you need the MoreInfo plugin too. The creation of
+ the installer is tied into the build process and can be triggered with:
+
+ % scons nsis
+
Configuring the build
---------------------
debug symbols. Also note that BF_QUICKDEBUG and BF_DEBUG_LIBS are combined;
for example, setting BF_QUICKDEBUG won't overwrite the contents of BF_DEBUG_LIBS.
-
- Not installing
- --------------
-
- If you dont want to install the build result, you can use the following option either
- on the commandline or in your user-config.py :
-
- WITHOUT_BF_INSTALL='true'
-
- by default, this is set to 'false', and so the build is installed
-
-
Supported toolset
-----------------
specify what toolset to use
% scons BF_TOOLSET=msvc
- % scons BF_TOOLSET=mstoolkit
% scons BF_TOOLSET=mingw
If you have only the toolkit installed, you will also need to give
if env['OURPLATFORM'] == 'linux2':
SConscript(['binreloc/SConscript']);
-SConscript(['fftw/SConscript'])
+# FFTW not needed atm - dg
+# SConscript(['fftw/SConscript'])
#include "btTriangleIndexVertexArray.h"
btTriangleIndexVertexArray::btTriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,btScalar* vertexBase,int vertexStride)
+: m_hasAabb(0)
{
btIndexedMesh mesh;
#define BT_BOX_COLLISION_H_INCLUDED
/*! \file gim_box_collision.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
This source file is part of GIMPACT Library.
#define BT_CLIP_POLYGON_H_INCLUDED
/*! \file btClipPolygon.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
This source file is part of GIMPACT Library.
#define BT_CONTACT_H_INCLUDED
/*! \file gim_contact.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
This source file is part of GIMPACT Library.
/*! \file gim_box_set.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
This source file is part of GIMPACT Library.
#define GIM_BOX_SET_H_INCLUDED
/*! \file gim_box_set.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
This source file is part of GIMPACT Library.
3. This notice may not be removed or altered from any source distribution.
*/
/*
-Author: Francisco León Nájera
+Author: Francisco Le\7fn Nßjera
Concave-Concave Collision
*/
/*! \file btGImpactShape.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
This source file is part of GIMPACT Library.
/*! \file btGImpactMassUtil.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
This source file is part of GIMPACT Library.
/*! \file gim_box_set.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
This source file is part of GIMPACT Library.
#define GIM_QUANTIZED_SET_H_INCLUDED
/*! \file btGImpactQuantizedBvh.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
This source file is part of GIMPACT Library.
/*! \file btGImpactShape.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
This source file is part of GIMPACT Library.
/*! \file btGenericPoolAllocator.cpp
-\author Francisco León Nájera. email projectileman@yahoo.com
+\author Francisco Le\7fn Nßjera. email projectileman@yahoo.com
General purpose allocator class
*/
/*! \file btGenericPoolAllocator.h
-\author Francisco León Nájera. email projectileman@yahoo.com
+\author Francisco Le\7fn Nßjera. email projectileman@yahoo.com
General purpose allocator class
*/
#define BT_BASIC_GEOMETRY_OPERATIONS_H_INCLUDED
/*! \file btGeometryOperations.h
-*\author Francisco León Nájera
+*\author Francisco Le\7fn Nßjera
*/
/*
#define BT_QUANTIZATION_H_INCLUDED
/*! \file btQuantization.h
-*\author Francisco León Nájera
+*\author Francisco Le\7fn Nßjera
*/
/*
/*! \file btGImpactTriangleShape.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
This source file is part of GIMPACT Library.
/*! \file btGImpactShape.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
This source file is part of GIMPACT Library.
#ifndef GIM_ARRAY_H_INCLUDED
#define GIM_ARRAY_H_INCLUDED
/*! \file gim_array.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
-----------------------------------------------------------------------------
#define GIM_BASIC_GEOMETRY_OPERATIONS_H_INCLUDED
/*! \file gim_basic_geometry_operations.h
-*\author Francisco León Nájera
+*\author Francisco Le\7fn Nßjera
type independant geometry routines
*/
#ifndef GIM_BITSET_H_INCLUDED
#define GIM_BITSET_H_INCLUDED
/*! \file gim_bitset.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
-----------------------------------------------------------------------------
#define GIM_BOX_COLLISION_H_INCLUDED
/*! \file gim_box_collision.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
-----------------------------------------------------------------------------
#define GIM_BOX_SET_H_INCLUDED
/*! \file gim_box_set.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
-----------------------------------------------------------------------------
#define GIM_CLIP_POLYGON_H_INCLUDED
/*! \file gim_tri_collision.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
-----------------------------------------------------------------------------
#define GIM_CONTACT_H_INCLUDED
/*! \file gim_contact.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
-----------------------------------------------------------------------------
#define GIM_GEOM_TYPES_H_INCLUDED
/*! \file gim_geom_types.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
-----------------------------------------------------------------------------
#define GIM_GEOMETRY_H_INCLUDED
/*! \file gim_geometry.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
-----------------------------------------------------------------------------
#ifndef GIM_HASH_TABLE_H_INCLUDED
#define GIM_HASH_TABLE_H_INCLUDED
/*! \file gim_trimesh_data.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
-----------------------------------------------------------------------------
#define GIM_LINEAR_H_INCLUDED
/*! \file gim_linear_math.h
-*\author Francisco León Nájera
+*\author Francisco Le\7fn Nßjera
Type Independant Vector and matrix operations.
*/
/*
#ifndef GIM_MATH_H_INCLUDED
#define GIM_MATH_H_INCLUDED
/*! \file gim_math.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
-----------------------------------------------------------------------------
#ifndef GIM_MEMORY_H_INCLUDED
#define GIM_MEMORY_H_INCLUDED
/*! \file gim_memory.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
-----------------------------------------------------------------------------
#ifndef GIM_RADIXSORT_H_INCLUDED
#define GIM_RADIXSORT_H_INCLUDED
/*! \file gim_radixsort.h
-\author Francisco León Nájera.
+\author Francisco Le\7fn Nßjera.
Based on the work of Michael Herf : "fast floating-point radix sort"
Avaliable on http://www.stereopsis.com/radix.html
*/
/*! \file gim_tri_collision.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
-----------------------------------------------------------------------------
#define GIM_TRI_COLLISION_H_INCLUDED
/*! \file gim_tri_collision.h
-\author Francisco León Nájera
+\author Francisco Le\7fn Nßjera
*/
/*
-----------------------------------------------------------------------------
void btDiscreteDynamicsWorld::removeRigidBody(btRigidBody* body)
{
+ //remove all constraints too
+ while (body->getNumConstraintRefs())
+ {
+ btTypedConstraint* constraint = body->getConstraintRef(0);
+ removeConstraint(constraint);
+ }
+
removeCollisionObject(body);
}
}
//
-void btSoftBody::appendAnchor(int node,btRigidBody* body)
+void btSoftBody::appendAnchor(int node,btRigidBody* body,bool disableCollisionWithBody=false)
{
+ if (disableCollisionWithBody)
+ {
+ if (m_collisionDisabledObjects.findLinearSearch(body)==m_collisionDisabledObjects.size())
+ {
+ m_collisionDisabledObjects.push_back(body);
+ }
+ }
+
Anchor a;
a.m_node = &m_nodes[node];
a.m_body = body;
for(int i=0,ni=psb->m_rcontacts.size();i<ni;++i)
{
const RContact& c=psb->m_rcontacts[i];
+ ///skip object that don't have collision response
+ if (!psb->getWorldInfo()->m_dispatcher->needsResponse(psb,c.m_cti.m_body))
+ continue;
+
const sCti& cti=c.m_cti;
const btVector3 va=cti.m_body->getVelocityInLocalPoint(c.m_c1)*dt;
const btVector3 vb=c.m_node->m_x-c.m_node->m_q;
class btSoftBody : public btCollisionObject
{
public:
+ btAlignedObjectArray<class btCollisionObject*> m_collisionDisabledObjects;
+
//
// Enumerations
//
Material* mat=0);
/* Append anchor */
void appendAnchor( int node,
- btRigidBody* body);
+ btRigidBody* body,bool disableCollision);
/* Append linear joint */
void appendLinearJoint(const LJoint::Specs& specs,Cluster* body0,Body body1);
void appendLinearJoint(const LJoint::Specs& specs,Body body=Body());
btSoftBody* softBody = m_isSwapped? (btSoftBody*)body1 : (btSoftBody*)body0;
btCollisionObject* rigidCollisionObject = m_isSwapped? body0 : body1;
- softBody->defaultCollisionHandler(rigidCollisionObject);
+ if (softBody->m_collisionDisabledObjects.findLinearSearch(rigidCollisionObject)==softBody->m_collisionDisabledObjects.size())
+ {
+ softBody->defaultCollisionHandler(rigidCollisionObject);
+ }
}
/// older compilers (gcc 3.x) and Sun needs double version of sqrt etc.
/// exclude Apple Intel (i's assumed to be a Macbook or new Intel Dual Core Processor)
#if defined (__sun) || defined (__sun__) || defined (__sparc) || (defined (__APPLE__) && ! defined (__i386__))
+/* XXX Need to fix these... needed for SunOS 5.8 */
+#define sinf(a) sin((double)(a))
+#define cosf(a) cos((double)(a))
+#define fabsf(a) fabs((double)(a))
//use slow double float precision operation on those platforms
#ifndef BT_USE_DOUBLE_PRECISION
#define BT_FORCE_DOUBLE_FUNCTIONS
tempf = y;
*tfptr = (0xbfcdd90a - *tfptr)>>1; /* estimate of 1/sqrt(y) */
x = tempf;
- z = y*btScalar(0.5); /* hoist out the \93/2\94 */
+ z = y*btScalar(0.5); /* hoist out the ô/2ö */
x = (btScalar(1.5)*x)-(x*x)*(x*z); /* iteration formula */
x = (btScalar(1.5)*x)-(x*x)*(x*z);
x = (btScalar(1.5)*x)-(x*x)*(x*z);
extern unsigned int SND_GetNumberOfChannels(void* sample);
extern unsigned int SND_GetSampleRate(void* sample);
extern unsigned int SND_GetBitRate(void* sample);
-extern unsigned int SND_GetNumberOfSamples(void* sample);
-extern unsigned int SND_GetHeaderSize(void* sample);
+extern unsigned int SND_GetNumberOfSamples(void* sample, int sample_length);
+extern unsigned int SND_GetHeaderSize(void* sample, int sample_length);
extern unsigned int SND_GetExtraChunk(void* sample);
extern void SND_GetSampleInfo(signed char* sample, SND_WaveSlot* waveslot);
int numberofchannels = SND_GetNumberOfChannels(memlocation);
int samplerate = SND_GetSampleRate(memlocation);
int bitrate = SND_GetBitRate(memlocation);
- int numberofsamples = SND_GetNumberOfSamples(memlocation);
+ int numberofsamples = SND_GetNumberOfSamples(memlocation, size);
waveslot->SetFileSize(size);
waveslot->SetData(memlocation);
#endif
#ifdef USE_OPENAL
// ok, properties Set. now see if it must play
- if (pObject->GetPlaystate() == SND_MUST_PLAY)
- {
+ switch (pObject->GetPlaystate()){
+ case SND_MUST_PLAY:
m_audiodevice->PlayObject(id);
pObject->SetPlaystate(SND_PLAYING);
- //break;
+ break;
+ case SND_MUST_STOP:
+ RemoveActiveObject(pObject);
+ break;
+ case SND_MUST_PAUSE:
+ m_audiodevice->PauseObject(id);
+ pObject->SetPlaystate(SND_PAUSED);
+ break;
}
#endif
void SND_SoundObject::StartSound()
{
- m_playstate = SND_MUST_PLAY;
+ if (m_id >= 0)
+ m_playstate = SND_MUST_PLAY;
}
void SND_SoundObject::StopSound()
{
- m_playstate = SND_MUST_STOP;
+ if (m_id >= 0)
+ m_playstate = SND_MUST_STOP;
}
void SND_SoundObject::PauseSound()
{
- m_playstate = SND_MUST_PAUSE;
+ if (m_id >= 0)
+ m_playstate = SND_MUST_PAUSE;
}
/* gets the length of the actual sample data (without the header) */
-unsigned int SND_GetNumberOfSamples(void* sample)
+unsigned int SND_GetNumberOfSamples(void* sample, int sample_length)
{
- unsigned int chunklength, length = 0, offset = 16;
- char data[4];
-
+ unsigned int chunklength, length = 0, offset;
+ unsigned short block_align;
if (CheckSample(sample))
{
- memcpy(&chunklength, ((char*)sample) + offset, 4);
+ memcpy(&chunklength, ((char*)sample) + 16, 4);
+ memcpy(&block_align, ((char*)sample) + 32, 2); /* always 2 or 4 it seems */
+
/* This was endian unsafe. See top of the file for the define. */
- if (SND_fEndian == SND_endianBig) SWITCH_INT(chunklength);
-
- offset = offset + chunklength + 4;
- memcpy(data, ((char*)sample) + offset, 4);
+ if (SND_fEndian == SND_endianBig)
+ {
+ SWITCH_INT(chunklength);
+ SWITCH_SHORT(block_align);
+ }
+
+ offset = 16 + chunklength + 4;
/* This seems very unsafe, what if data is never found (f.i. corrupt file)... */
// lets find "data"
- while (memcmp(data, "data", 4))
+ while (memcmp(((char*)sample) + offset, "data", 4))
{
- offset += 4;
- memcpy(data, ((char*)sample) + offset, 4);
+ offset += block_align;
+
+ if (offset+block_align > sample_length) /* save us from crashing */
+ return 0;
}
offset += 4;
memcpy(&length, ((char*)sample) + offset, 4);
/* gets the size of the entire header (file - sampledata) */
-unsigned int SND_GetHeaderSize(void* sample)
+unsigned int SND_GetHeaderSize(void* sample, int sample_length)
{
unsigned int chunklength, headersize = 0, offset = 16;
- char data[4];
-
+ unsigned short block_align;
if (CheckSample(sample))
{
memcpy(&chunklength, ((char*)sample) + offset, 4);
+ memcpy(&block_align, ((char*)sample) + 32, 2); /* always 2 or 4 it seems */
+
/* This was endian unsafe. See top of the file for the define. */
- if (SND_fEndian == SND_endianBig) SWITCH_INT(chunklength);
+ if (SND_fEndian == SND_endianBig)
+ {
+ SWITCH_INT(chunklength);
+ SWITCH_SHORT(block_align);
+ }
offset = offset + chunklength + 4;
- memcpy(data, ((char*)sample) + offset, 4);
// lets find "data"
- while (memcmp(data, "data", 4))
+ while (memcmp(((char*)sample) + offset, "data", 4))
{
- offset += 4;
- memcpy(data, ((char*)sample) + offset, 4);
+ offset += block_align;
+
+ if (offset+block_align > sample_length) /* save us from crashing */
+ return 0;
}
headersize = offset + 8;
}
-
return headersize;
}
-
unsigned int SND_GetExtraChunk(void* sample)
{
unsigned int extrachunk = 0, chunklength, offset = 16;
if (CheckSample(sample))
{
memcpy(&fileheader, sample, sizeof(WavFileHeader));
- fileheader.size = SND_GetHeaderSize(sample);
- sample += sizeof(WavFileHeader);
- fileheader.size = ((fileheader.size+1) & ~1) - 4;
+ fileheader.size = SND_GetHeaderSize(sample, waveslot->GetFileSize());
+ if (fileheader.size) { /* this may fail for corrupt files */
+ sample += sizeof(WavFileHeader);
+ fileheader.size = ((fileheader.size+1) & ~1) - 4;
- while ((fileheader.size > 0) && (memcpy(&chunkheader, sample, sizeof(WavChunkHeader))))
- {
- sample += sizeof(WavChunkHeader);
- if (!memcmp(chunkheader.id, "fmt ", 4))
+ while ((fileheader.size > 0) && (memcpy(&chunkheader, sample, sizeof(WavChunkHeader))))
{
- memcpy(&fmtheader, sample, sizeof(WavFmtHeader));
- waveslot->SetSampleFormat(fmtheader.format);
-
- if (fmtheader.format == 0x0001)
+ sample += sizeof(WavChunkHeader);
+ if (!memcmp(chunkheader.id, "fmt ", 4))
{
- waveslot->SetNumberOfChannels(fmtheader.numberofchannels);
- waveslot->SetBitRate(fmtheader.bitrate);
- waveslot->SetSampleRate(fmtheader.samplerate);
- sample += chunkheader.size;
- }
- else
- {
- memcpy(&fmtexheader, sample, sizeof(WavFmtExHeader));
- sample += chunkheader.size;
- }
- }
- else if (!memcmp(chunkheader.id, "data", 4))
- {
- if (fmtheader.format == 0x0001)
- {
- waveslot->SetNumberOfSamples(chunkheader.size);
- sample += chunkheader.size;
+ memcpy(&fmtheader, sample, sizeof(WavFmtHeader));
+ waveslot->SetSampleFormat(fmtheader.format);
+
+ if (fmtheader.format == 0x0001)
+ {
+ waveslot->SetNumberOfChannels(fmtheader.numberofchannels);
+ waveslot->SetBitRate(fmtheader.bitrate);
+ waveslot->SetSampleRate(fmtheader.samplerate);
+ sample += chunkheader.size;
+ }
+ else
+ {
+ memcpy(&fmtexheader, sample, sizeof(WavFmtExHeader));
+ sample += chunkheader.size;
+ }
}
- else if (fmtheader.format == 0x0011)
+ else if (!memcmp(chunkheader.id, "data", 4))
{
- //IMA ADPCM
+ if (fmtheader.format == 0x0001)
+ {
+ waveslot->SetNumberOfSamples(chunkheader.size);
+ sample += chunkheader.size;
+ }
+ else if (fmtheader.format == 0x0011)
+ {
+ //IMA ADPCM
+ }
+ else if (fmtheader.format == 0x0055)
+ {
+ //MP3 WAVE
+ }
}
- else if (fmtheader.format == 0x0055)
+ else if (!memcmp(chunkheader.id, "smpl", 4))
{
- //MP3 WAVE
+ memcpy(&sampleheader, sample, sizeof(WavSampleHeader));
+ //loop = sampleheader.loops;
+ sample += chunkheader.size;
}
- }
- else if (!memcmp(chunkheader.id, "smpl", 4))
- {
- memcpy(&sampleheader, sample, sizeof(WavSampleHeader));
- //loop = sampleheader.loops;
- sample += chunkheader.size;
- }
- else
- sample += chunkheader.size;
+ else
+ sample += chunkheader.size;
- sample += chunkheader.size & 1;
- fileheader.size -= (((chunkheader.size + 1) & ~1) + 8);
+ sample += chunkheader.size & 1;
+ fileheader.size -= (((chunkheader.size + 1) & ~1) + 8);
+ }
}
}
}
#include "SND_SDLCDDevice.h"
#include "SoundDefines.h"
+#ifndef DISABLE_SDL
#include <SDL.h>
+#endif
SND_SDLCDDevice::SND_SDLCDDevice() :
m_cdrom(NULL),
CCFLAGS += $(LEVEL_2_CPP_WARNINGS)
+ifeq ($(WITH_BF_OPENMP),true)
+ CPPFLAGS += -DPARALLEL
+endif
+
CPPFLAGS += -DNOGUI -DELBEEM_BLENDER
CPPFLAGS += -I.
CPPFLAGS += -I../extern
ntlGeometryObjModel *obj = new ntlGeometryObjModel( );
gpWorld->getRenderGlobals()->getSimScene()->addGeoClass( obj );
+ gpWorld->getRenderGlobals()->getRenderScene()->addGeoClass(obj);
obj->initModel(
mesh->numVertices, mesh->vertices, mesh->numTriangles, mesh->triangles,
mesh->channelSizeVertices, mesh->channelVertices );
if(mvmFullDebug) errMsg("MeanValueMeshCoords::computeWeights","c="<<c<<" phi="<<phi<<" d="<<d);
//if (c[0] > 1. || c[0] < 0. || c[1] > 1. || c[1] < 0. || c[2] > 1. || c[2] < 0.) continue;
- s[0] = sqrtf((float)(1.-c[0]*c[0]));
- s[1] = sqrtf((float)(1.-c[1]*c[1]));
- s[2] = sqrtf((float)(1.-c[2]*c[2]));
+ s[0] = sqrt((float)(1.-c[0]*c[0]));
+ s[1] = sqrt((float)(1.-c[1]*c[1]));
+ s[2] = sqrt((float)(1.-c[2]*c[2]));
if(mvmFullDebug) errMsg("MeanValueMeshCoords::computeWeights","s");
if (s[0] <= cEPS || s[1] <= cEPS || s[2] <= cEPS) {
GHOST_TSuccess GHOST_WindowWin32::swapBuffers()
{
- // adding a glFinish() here is to prevent Geforce in 'full scene antialias' mode
- // from antialising the Blender window. Officially a swapbuffers does a glFinish
- // itself, so this feels really like a hack... but it won't harm. (ton)
- //
- // disabled this because it is a performance killer for the game engine, glFinish
- // forces synchronization with the graphics card and calling it is strongly
- // discouraged for good performance. (brecht)
- //
- // glFinish();
-
return ::SwapBuffers(m_hDC) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
}
--- /dev/null
+#dxfLibrary.py : provides functions for generating DXF files
+# --------------------------------------------------------------------------
+__version__ = "v1.27beta - 2008.10.05"
+__author__ = "Stani Michiels(Stani), Remigiusz Fiedler(migius)"
+__license__ = "GPL"
+__url__ = "http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_dxf"
+__bpydoc__ ="""The script exports geometry data to DXF format r12 version.
+
+Copyright %s
+Version %s
+License %s
+Homepage %s
+
+See the homepage for documentation.
+url:
+
+IDEAs:
+-
+
+TODO:
+-
+
+History
+v1.27 - 2008.10.07 by migius
+- beautifying output code: keys whitespace prefix
+- refactoring DXF-strings format: NewLine moved to the end of
+v1.26 - 2008.10.05 by migius
+- modif POLYLINE to support POLYFACE
+v1.25 - 2008.09.28 by migius
+- modif FACE class for r12
+v1.24 - 2008.09.27 by migius
+- modif POLYLINE class for r12
+- changing output format from r9 to r12(AC1009)
+v1.1 (20/6/2005) by www.stani.be/python/sdxf
+- Python library to generate dxf drawings
+______________________________________________________________
+""" % (__author__,__version__,__license__,__url__)
+
+# --------------------------------------------------------------------------
+# DXF Library: copyright (C) 2005 by Stani Michiels (AKA Stani)
+# 2008 modif by Remigiusz Fiedler (AKA migius)
+# --------------------------------------------------------------------------
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# ***** END GPL LICENCE BLOCK *****
+
+
+#import Blender
+#from Blender import Mathutils, Window, Scene, sys, Draw
+#import BPyMessages
+
+try:
+ import copy
+ #from struct import pack
+except:
+ copy = None
+
+####1) Private (only for developpers)
+_HEADER_POINTS=['insbase','extmin','extmax']
+
+#---helper functions-----------------------------------
+def _point(x,index=0):
+ """Convert tuple to a dxf point"""
+ #print 'deb: _point=', x #-------------
+ return '\n'.join([' %s\n%s'%((i+1)*10+index,x[i]) for i in range(len(x))])
+
+def _points(plist):
+ """Convert a list of tuples to dxf points"""
+ out = '\n'.join([_point(plist[i],i)for i in range(len(plist))])
+ #print 'deb: points=\n', out #-------------------
+ return out
+
+#---base classes----------------------------------------
+class _Call:
+ """Makes a callable class."""
+ def copy(self):
+ """Returns a copy."""
+ return copy.deepcopy(self)
+
+ def __call__(self,**attrs):
+ """Returns a copy with modified attributes."""
+ copied=self.copy()
+ for attr in attrs:setattr(copied,attr,attrs[attr])
+ return copied
+
+#-------------------------------------------------------
+class _Entity(_Call):
+ """Base class for _common group codes for entities."""
+ def __init__(self,color=None,extrusion=None,layer='0',
+ lineType=None,lineTypeScale=None,lineWeight=None,
+ thickness=None,parent=None):
+ """None values will be omitted."""
+ self.color = color
+ self.extrusion = extrusion
+ self.layer = layer
+ self.lineType = lineType
+ self.lineTypeScale = lineTypeScale
+ self.lineWeight = lineWeight
+ self.thickness = thickness
+ self.parent = parent
+
+ def _common(self):
+ """Return common group codes as a string."""
+ if self.parent:parent=self.parent
+ else:parent=self
+ result =''
+ if parent.layer!=None: result+=' 8\n%s\n'%parent.layer
+ if parent.color!=None: result+=' 62\n%s\n'%parent.color
+ if parent.extrusion!=None: result+='%s\n'%_point(parent.extrusion,200)
+ if parent.lineType!=None: result+=' 6\n%s\n'%parent.lineType
+ #TODO: if parent.lineWeight!=None: result+='370\n%s\n'%parent.lineWeight
+ if parent.lineTypeScale!=None: result+=' 48\n%s\n'%parent.lineTypeScale
+ if parent.thickness!=None: result+=' 39\n%s\n'%parent.thickness
+ return result
+
+#--------------------------
+class _Entities:
+ """Base class to deal with composed objects."""
+ def __dxf__(self):
+ return []
+
+ def __str__(self):
+ return ''.join([str(x) for x in self.__dxf__()])
+
+#--------------------------
+class _Collection(_Call):
+ """Base class to expose entities methods to main object."""
+ def __init__(self,entities=[]):
+ self.entities=copy.copy(entities)
+ #link entities methods to drawing
+ for attr in dir(self.entities):
+ if attr[0]!='_':
+ attrObject=getattr(self.entities,attr)
+ if callable(attrObject):
+ setattr(self,attr,attrObject)
+
+####2) Constants
+#---color values
+BYBLOCK=0
+BYLAYER=256
+
+#---block-type flags (bit coded values, may be combined):
+ANONYMOUS =1 # This is an anonymous block generated by hatching, associative dimensioning, other internal operations, or an application
+NON_CONSTANT_ATTRIBUTES =2 # This block has non-constant attribute definitions (this bit is not set if the block has any attribute definitions that are constant, or has no attribute definitions at all)
+XREF =4 # This block is an external reference (xref)
+XREF_OVERLAY =8 # This block is an xref overlay
+EXTERNAL =16 # This block is externally dependent
+RESOLVED =32 # This is a resolved external reference, or dependent of an external reference (ignored on input)
+REFERENCED =64 # This definition is a referenced external reference (ignored on input)
+
+#---mtext flags
+#attachment point
+TOP_LEFT = 1
+TOP_CENTER = 2
+TOP_RIGHT = 3
+MIDDLE_LEFT = 4
+MIDDLE_CENTER = 5
+MIDDLE_RIGHT = 6
+BOTTOM_LEFT = 7
+BOTTOM_CENTER = 8
+BOTTOM_RIGHT = 9
+#drawing direction
+LEFT_RIGHT = 1
+TOP_BOTTOM = 3
+BY_STYLE = 5 #the flow direction is inherited from the associated text style
+#line spacing style (optional):
+AT_LEAST = 1 #taller characters will override
+EXACT = 2 #taller characters will not override
+
+#---polyline flags
+CLOSED =1 # This is a closed polyline (or a polygon mesh closed in the M direction)
+CURVE_FIT =2 # Curve-fit vertices have been added
+SPLINE_FIT =4 # Spline-fit vertices have been added
+POLYLINE_3D =8 # This is a 3D polyline
+POLYGON_MESH =16 # This is a 3D polygon mesh
+CLOSED_N =32 # The polygon mesh is closed in the N direction
+POLYFACE_MESH =64 # The polyline is a polyface mesh
+CONTINOUS_LINETYPE_PATTERN =128 # The linetype pattern is generated continuously around the vertices of this polyline
+
+#---text flags
+#horizontal
+LEFT = 0
+CENTER = 1
+RIGHT = 2
+ALIGNED = 3 #if vertical alignment = 0
+MIDDLE = 4 #if vertical alignment = 0
+FIT = 5 #if vertical alignment = 0
+#vertical
+BASELINE = 0
+BOTTOM = 1
+MIDDLE = 2
+TOP = 3
+
+####3) Classes
+#---entitities -----------------------------------------------
+#--------------------------
+class Arc(_Entity):
+ """Arc, angles in degrees."""
+ def __init__(self,center=(0,0,0),radius=1,
+ startAngle=0.0,endAngle=90,**common):
+ """Angles in degrees."""
+ _Entity.__init__(self,**common)
+ self.center=center
+ self.radius=radius
+ self.startAngle=startAngle
+ self.endAngle=endAngle
+ def __str__(self):
+ return ' 0\nARC\n%s%s\n 40\n%s\n 50\n%s\n 51\n%s\n'%\
+ (self._common(),_point(self.center),
+ self.radius,self.startAngle,self.endAngle)
+
+#-----------------------------------------------
+class Circle(_Entity):
+ """Circle"""
+ def __init__(self,center=(0,0,0),radius=1,**common):
+ _Entity.__init__(self,**common)
+ self.center=center
+ self.radius=radius
+ def __str__(self):
+ return ' 0\nCIRCLE\n%s%s\n 40\n%s\n'%\
+ (self._common(),_point(self.center),self.radius)
+
+#-----------------------------------------------
+class Face(_Entity):
+ """3dface"""
+ def __init__(self,points,**common):
+ _Entity.__init__(self,**common)
+ if len(points)<4: #fix for r12 format
+ points.append(points[-1])
+ self.points=points
+
+ def __str__(self):
+ out = ' 0\n3DFACE\n%s%s\n' %(self._common(),_points(self.points))
+ #print 'deb:out=', out #-------------------
+ return out
+
+#-----------------------------------------------
+class Insert(_Entity):
+ """Block instance."""
+ def __init__(self,name,point=(0,0,0),
+ xscale=None,yscale=None,zscale=None,
+ cols=None,colspacing=None,rows=None,rowspacing=None,
+ rotation=None,
+ **common):
+ _Entity.__init__(self,**common)
+ self.name=name
+ self.point=point
+ self.xscale=xscale
+ self.yscale=yscale
+ self.zscale=zscale
+ self.cols=cols
+ self.colspacing=colspacing
+ self.rows=rows
+ self.rowspacing=rowspacing
+ self.rotation=rotation
+
+ def __str__(self):
+ result=' 0\nINSERT\n 2\n%s\n%s\n%s\n'%\
+ (self.name,self._common(),_point(self.point))
+ if self.xscale!=None:result+=' 41\n%s\n'%self.xscale
+ if self.yscale!=None:result+=' 42\n%s\n'%self.yscale
+ if self.zscale!=None:result+=' 43\n%s\n'%self.zscale
+ if self.rotation:result+=' 50\n%s\n'%self.rotation
+ if self.cols!=None:result+=' 70\n%s\n'%self.cols
+ if self.colspacing!=None:result+=' 44\n%s\n'%self.colspacing
+ if self.rows!=None:result+=' 71\n%s\n'%self.rows
+ if self.rowspacing!=None:result+=' 45\n%s\n'%self.rowspacing
+ return result
+
+#-----------------------------------------------
+class Line(_Entity):
+ """Line"""
+ def __init__(self,points,**common):
+ _Entity.__init__(self,**common)
+ self.points=points
+ def __str__(self):
+ return ' 0\nLINE\n%s%s\n' %(
+ self._common(), _points(self.points))
+
+
+#-----------------------------------------------
+class PolyLine(_Entity):
+ def __init__(self,points,org_point=[0,0,0],flag=0,width=None,**common):
+ _Entity.__init__(self,**common)
+ self.points=points
+ self.org_point=org_point
+ self.flag=flag
+ if self.flag==64:
+ self.points=points[0]
+ self.faces=points[1]
+ self.p_count=len(self.points)
+ self.f_count=len(self.faces)
+ self.width=width
+
+ def __str__(self):
+ result= ' 0\nPOLYLINE\n%s 70\n%s\n' %(self._common(),self.flag)
+ #print 'deb: self._common()', self._common() #----------
+ result+=' 66\n1\n'
+ result+='%s\n' %_point(self.org_point)
+ if self.flag==64:
+ result+=' 71\n%s\n' %self.p_count
+ result+=' 72\n%s\n' %self.f_count
+ for point in self.points:
+ result+=' 0\nVERTEX\n'
+ result+=' 8\n%s\n' %self.layer
+ result+='%s\n' %_point(point)
+ if self.flag==64: result+=' 70\n192\n'
+ if self.width: result+=' 40\n%s\n 41\n%s\n' %(self.width,self.width)
+ if self.flag==64:
+ for face in self.faces:
+ result+=' 0\nVERTEX\n'
+ result+=' 8\n%s\n' %self.layer
+ result+='%s\n' %_point(self.org_point)
+ result+=' 70\n128\n'
+ result+=' 71\n%s\n' %face[0]
+ result+=' 72\n%s\n' %face[1]
+ result+=' 73\n%s\n' %face[2]
+ if len(face)==4: result+=' 74\n%s\n' %face[3]
+ result+=' 0\nSEQEND\n'
+ result+=' 8\n%s\n' %self.layer
+ return result
+
+#-----------------------------------------------
+class Point(_Entity):
+ """Colored solid fill."""
+ def __init__(self,points=None,**common):
+ _Entity.__init__(self,**common)
+ self.points=points
+
+#-----------------------------------------------
+class Solid(_Entity):
+ """Colored solid fill."""
+ def __init__(self,points=None,**common):
+ _Entity.__init__(self,**common)
+ self.points=points
+ def __str__(self):
+ return ' 0\nSOLID\n%s%s\n' %(self._common(),
+ _points(self.points[:2]+[self.points[3],self.points[2]])
+ )
+
+
+#-----------------------------------------------
+class Text(_Entity):
+ """Single text line."""
+ def __init__(self,text='',point=(0,0,0),alignment=None,
+ flag=None,height=1,justifyhor=None,justifyver=None,
+ rotation=None,obliqueAngle=None,style=None,xscale=None,**common):
+ _Entity.__init__(self,**common)
+ self.text=text
+ self.point=point
+ self.alignment=alignment
+ self.flag=flag
+ self.height=height
+ self.justifyhor=justifyhor
+ self.justifyver=justifyver
+ self.rotation=rotation
+ self.obliqueAngle=obliqueAngle
+ self.style=style
+ self.xscale=xscale
+ def __str__(self):
+ result= ' 0\nTEXT\n%s%s\n 40\n%s\n 1\n%s\n'%\
+ (self._common(),_point(self.point),self.height,self.text)
+ if self.rotation: result+=' 50\n%s\n'%self.rotation
+ if self.xscale: result+=' 41\n%s\n'%self.xscale
+ if self.obliqueAngle: result+=' 51\n%s\n'%self.obliqueAngle
+ if self.style: result+=' 7\n%s\n'%self.style
+ if self.flag: result+=' 71\n%s\n'%self.flag
+ if self.justifyhor: result+=' 72\n%s\n'%self.justifyhor
+ #TODO: if self.alignment: result+='%s\n'%_point(self.alignment,1)
+ if self.justifyver: result+=' 73\n%s\n'%self.justifyver
+ return result
+
+#-----------------------------------------------
+class Mtext(Text):
+ """Surrogate for mtext, generates some Text instances."""
+ def __init__(self,text='',point=(0,0,0),width=250,spacingFactor=1.5,down=0,spacingWidth=None,**options):
+ Text.__init__(self,text=text,point=point,**options)
+ if down:spacingFactor*=-1
+ self.spacingFactor=spacingFactor
+ self.spacingWidth=spacingWidth
+ self.width=width
+ self.down=down
+ def __str__(self):
+ texts=self.text.replace('\r\n','\n').split('\n')
+ if not self.down:texts.reverse()
+ result=''
+ x=y=0
+ if self.spacingWidth:spacingWidth=self.spacingWidth
+ else:spacingWidth=self.height*self.spacingFactor
+ for text in texts:
+ while text:
+ result+='%s\n'%Text(text[:self.width],
+ point=(self.point[0]+x*spacingWidth,
+ self.point[1]+y*spacingWidth,
+ self.point[2]),
+ alignment=self.alignment,flag=self.flag,height=self.height,
+ justifyhor=self.justifyhor,justifyver=self.justifyver,
+ rotation=self.rotation,obliqueAngle=self.obliqueAngle,
+ style=self.style,xscale=self.xscale,parent=self
+ )
+ text=text[self.width:]
+ if self.rotation:x+=1
+ else:y+=1
+ return result[1:]
+
+#-----------------------------------------------
+##class _Mtext(_Entity):
+## """Mtext not functioning for minimal dxf."""
+## def __init__(self,text='',point=(0,0,0),attachment=1,
+## charWidth=None,charHeight=1,direction=1,height=100,rotation=0,
+## spacingStyle=None,spacingFactor=None,style=None,width=100,
+## xdirection=None,**common):
+## _Entity.__init__(self,**common)
+## self.text=text
+## self.point=point
+## self.attachment=attachment
+## self.charWidth=charWidth
+## self.charHeight=charHeight
+## self.direction=direction
+## self.height=height
+## self.rotation=rotation
+## self.spacingStyle=spacingStyle
+## self.spacingFactor=spacingFactor
+## self.style=style
+## self.width=width
+## self.xdirection=xdirection
+## def __str__(self):
+## input=self.text
+## text=''
+## while len(input)>250:
+## text+='3\n%s\n'%input[:250]
+## input=input[250:]
+## text+='1\n%s\n'%input
+## result= '0\nMTEXT\n%s\n%s\n40\n%s\n41\n%s\n71\n%s\n72\n%s%s\n43\n%s\n50\n%s\n'%\
+## (self._common(),_point(self.point),self.charHeight,self.width,
+## self.attachment,self.direction,text,
+## self.height,
+## self.rotation)
+## if self.style:result+='7\n%s\n'%self.style
+## if self.xdirection:result+='%s\n'%_point(self.xdirection,1)
+## if self.charWidth:result+='42\n%s\n'%self.charWidth
+## if self.spacingStyle:result+='73\n%s\n'%self.spacingStyle
+## if self.spacingFactor:result+='44\n%s\n'%self.spacingFactor
+## return result
+
+#---tables ---------------------------------------------------
+#-----------------------------------------------
+class Block(_Collection):
+ """Use list methods to add entities, eg append."""
+ def __init__(self,name,layer='0',flag=0,base=(0,0,0),entities=[]):
+ self.entities=copy.copy(entities)
+ _Collection.__init__(self,entities)
+ self.layer=layer
+ self.name=name
+ self.flag=0
+ self.base=base
+ def __str__(self):
+ e=''.join([str(x)for x in self.entities])
+ return ' 0\nBLOCK\n 8\n%s\n 2\n%s\n 70\n%s\n%s\n 3\n%s\n%s 0\nENDBLK\n'%\
+ (self.layer,self.name.upper(),self.flag,_point(self.base),self.name.upper(),e)
+
+#-----------------------------------------------
+class Layer(_Call):
+ """Layer"""
+ def __init__(self,name='pydxf',color=7,lineType='continuous',flag=64):
+ self.name=name
+ self.color=color
+ self.lineType=lineType
+ self.flag=flag
+ def __str__(self):
+ return ' 0\nLAYER\n 2\n%s\n 70\n%s\n 62\n%s\n 6\n%s\n'%\
+ (self.name.upper(),self.flag,self.color,self.lineType)
+
+#-----------------------------------------------
+class LineType(_Call):
+ """Custom linetype"""
+ def __init__(self,name='continuous',description='Solid line',elements=[],flag=64):
+ # TODO: Implement lineType elements
+ self.name=name
+ self.description=description
+ self.elements=copy.copy(elements)
+ self.flag=flag
+ def __str__(self):
+ return ' 0\nLTYPE\n 2\n%s\n 70\n%s\n 3\n%s\n 72\n65\n 73\n%s\n 40\n0.0\n'%\
+ (self.name.upper(),self.flag,self.description,len(self.elements))
+
+#-----------------------------------------------
+class Style(_Call):
+ """Text style"""
+ def __init__(self,name='standard',flag=0,height=0,widthFactor=40,obliqueAngle=50,
+ mirror=0,lastHeight=1,font='arial.ttf',bigFont=''):
+ self.name=name
+ self.flag=flag
+ self.height=height
+ self.widthFactor=widthFactor
+ self.obliqueAngle=obliqueAngle
+ self.mirror=mirror
+ self.lastHeight=lastHeight
+ self.font=font
+ self.bigFont=bigFont
+ def __str__(self):
+ return ' 0\nSTYLE\n 2\n%s\n 70\n%s\n 40\n%s\n 41\n%s\n 50\n%s\n 71\n%s\n 42\n%s\n 3\n%s\n 4\n%s\n'%\
+ (self.name.upper(),self.flag,self.flag,self.widthFactor,
+ self.obliqueAngle,self.mirror,self.lastHeight,
+ self.font.upper(),self.bigFont.upper())
+
+#-----------------------------------------------
+class View(_Call):
+ def __init__(self,name,flag=0,width=1,height=1,center=(0.5,0.5),
+ direction=(0,0,1),target=(0,0,0),lens=50,
+ frontClipping=0,backClipping=0,twist=0,mode=0):
+ self.name=name
+ self.flag=flag
+ self.width=width
+ self.height=height
+ self.center=center
+ self.direction=direction
+ self.target=target
+ self.lens=lens
+ self.frontClipping=frontClipping
+ self.backClipping=backClipping
+ self.twist=twist
+ self.mode=mode
+ def __str__(self):
+ return ' 0\nVIEW\n 2\n%s\n 70\n%s\n 40\n%s\n%s\n 41\n%s\n%s\n%s\n 42\n%s\n 43\n%s\n 44\n%s\n 50\n%s\n 71\n%s\n'%\
+ (self.name,self.flag,self.height,_point(self.center),self.width,
+ _point(self.direction,1),_point(self.target,2),self.lens,
+ self.frontClipping,self.backClipping,self.twist,self.mode)
+
+#-----------------------------------------------
+def ViewByWindow(name,leftBottom=(0,0),rightTop=(1,1),**options):
+ width=abs(rightTop[0]-leftBottom[0])
+ height=abs(rightTop[1]-leftBottom[1])
+ center=((rightTop[0]+leftBottom[0])*0.5,(rightTop[1]+leftBottom[1])*0.5)
+ return View(name=name,width=width,height=height,center=center,**options)
+
+#---drawing
+#-----------------------------------------------
+class Drawing(_Collection):
+ """Dxf drawing. Use append or any other list methods to add objects."""
+ def __init__(self,insbase=(0.0,0.0,0.0),extmin=(0.0,0.0),extmax=(0.0,0.0),
+ layers=[Layer()],linetypes=[LineType()],styles=[Style()],blocks=[],
+ views=[],entities=None,fileName='test.dxf'):
+ # TODO: replace list with None,arial
+ if not entities:entities=[]
+ _Collection.__init__(self,entities)
+ self.insbase=insbase
+ self.extmin=extmin
+ self.extmax=extmax
+ self.layers=copy.copy(layers)
+ self.linetypes=copy.copy(linetypes)
+ self.styles=copy.copy(styles)
+ self.views=copy.copy(views)
+ self.blocks=copy.copy(blocks)
+ self.fileName=fileName
+ #private
+ #self.acadver='9\n$ACADVER\n1\nAC1006\n'
+ self.acadver=' 9\n$ACADVER\n 1\nAC1009\n'
+ """DXF AutoCAD-Release format codes
+ AC1021 2008, 2007
+ AC1018 2006, 2005, 2004
+ AC1015 2002, 2000i, 2000
+ AC1014 R14,14.01
+ AC1012 R13
+ AC1009 R12,11
+ AC1006 R10
+ AC1004 R9
+ AC1002 R2.6
+ AC1.50 R2.05
+ """
+
+ def _name(self,x):
+ """Helper function for self._point"""
+ return ' 9\n$%s\n' %x.upper()
+
+ def _point(self,name,x):
+ """Point setting from drawing like extmin,extmax,..."""
+ return '%s%s' %(self._name(name),_point(x))
+
+ def _section(self,name,x):
+ """Sections like tables,blocks,entities,..."""
+ if x: xstr=''.join(x)
+ else: xstr=''
+ return ' 0\nSECTION\n 2\n%s\n%s 0\nENDSEC\n'%(name.upper(),xstr)
+
+ def _table(self,name,x):
+ """Tables like ltype,layer,style,..."""
+ if x: xstr=''.join(x)
+ else: xstr=''
+ return ' 0\nTABLE\n 2\n%s\n 70\n%s\n%s 0\nENDTAB\n'%(name.upper(),len(x),xstr)
+
+ def __str__(self):
+ """Returns drawing as dxf string."""
+ header=[self.acadver]+[self._point(attr,getattr(self,attr))+'\n' for attr in _HEADER_POINTS]
+ header=self._section('header',header)
+
+ tables=[self._table('ltype',[str(x) for x in self.linetypes]),
+ self._table('layer',[str(x) for x in self.layers]),
+ self._table('style',[str(x) for x in self.styles]),
+ self._table('view',[str(x) for x in self.views]),
+ ]
+ tables=self._section('tables',tables)
+
+ blocks=self._section('blocks',[str(x) for x in self.blocks])
+
+ entities=self._section('entities',[str(x) for x in self.entities])
+
+ all=''.join([header,tables,blocks,entities,' 0\nEOF\n'])
+ return all
+
+ def saveas(self,fileName):
+ self.fileName=fileName
+ self.save()
+
+ def save(self):
+ test=open(self.fileName,'w')
+ test.write(str(self))
+ test.close()
+
+
+#---extras
+#-----------------------------------------------
+class Rectangle(_Entity):
+ """Rectangle, creates lines."""
+ def __init__(self,point=(0,0,0),width=1,height=1,solid=None,line=1,**common):
+ _Entity.__init__(self,**common)
+ self.point=point
+ self.width=width
+ self.height=height
+ self.solid=solid
+ self.line=line
+ def __str__(self):
+ result=''
+ points=[self.point,(self.point[0]+self.width,self.point[1],self.point[2]),
+ (self.point[0]+self.width,self.point[1]+self.height,self.point[2]),
+ (self.point[0],self.point[1]+self.height,self.point[2]),self.point]
+ if self.solid:
+ result+= Solid(points=points[:-1],parent=self.solid)
+ if self.line:
+ for i in range(4):
+ result+= Line(points=[points[i],points[i+1]],parent=self)
+ return result[1:]
+
+#-----------------------------------------------
+class LineList(_Entity):
+ """Like polyline, but built of individual lines."""
+ def __init__(self,points=[],org_point=[0,0,0],closed=0,**common):
+ _Entity.__init__(self,**common)
+ self.closed=closed
+ self.points=copy.copy(points)
+ def __str__(self):
+ if self.closed:points=self.points+[self.points[0]]
+ else: points=self.points
+ result=''
+ for i in range(len(points)-1):
+ result+= Line(points=[points[i],points[i+1]],parent=self)
+ return result[1:]
+
+#-----------------------------------------------------
+def test():
+ #Blocks
+ b=Block('test')
+ b.append(Solid(points=[(0,0,0),(1,0,0),(1,1,0),(0,1,0)],color=1))
+ b.append(Arc(center=(1,0,0),color=2))
+
+ #Drawing
+ d=Drawing()
+ #tables
+ d.blocks.append(b) #table blocks
+ d.styles.append(Style()) #table styles
+ d.views.append(View('Normal')) #table view
+ d.views.append(ViewByWindow('Window',leftBottom=(1,0),rightTop=(2,1))) #idem
+
+ #entities
+ d.append(Circle(center=(1,1,0),color=3))
+ d.append(Face(points=[(0,0,0),(1,0,0),(1,1,0),(0,1,0)],color=4))
+ d.append(Insert('test',point=(3,3,3),cols=5,colspacing=2))
+ d.append(Line(points=[(0,0,0),(1,1,1)]))
+ d.append(Mtext('Click on Ads\nmultiple lines with mtext',point=(1,1,1),color=5,rotation=90))
+ d.append(Text('Please donate!',point=(3,0,1)))
+ d.append(Rectangle(point=(2,2,2),width=4,height=3,color=6,solid=Solid(color=2)))
+ d.append(Solid(points=[(4,4,0),(5,4,0),(7,8,0),(9,9,0)],color=3))
+ d.append(PolyLine(points=[(1,1,1),(2,1,1),(2,2,1),(1,2,1)],closed=1,color=1))
+
+ #d.saveas('c:\\test.dxf')
+ d.saveas('test.dxf')
+
+
+#-----------------------------------------------------
+if __name__=='__main__':
+ if not copy:
+ Draw.PupMenu('Error%t|This script requires a full python install')
+ main()
+
\ No newline at end of file
bvh_nodes_list= bvh_nodes.values()
- while lineIdx < len(file_lines) -1:
+ while lineIdx < len(file_lines):
line= file_lines[lineIdx]
for bvh_node in bvh_nodes_list:
#for bvh_node in bvh_nodes_serial:
Blender.Window.WaitCursor(1)
# Get the BVH data and act on it.
t1= Blender.sys.time()
- print '\tpassing bvh...',
+ print '\tparsing bvh...',
bvh_nodes= read_bvh(file, IMPORT_SCALE)
print '%.4f' % (Blender.sys.time()-t1)
t1= Blender.sys.time()
#!BPY
-
+# -*- coding: latin-1 -*-
"""
Name: 'Motion Capture (.c3d)...'
Blender: 246
fields = fields[2].split()
if len(fields) > 1:
fname = fields[1].split(sep)[-1]
+ i = 1
+ while not fname.endswith('.py'):
+ i += 1
+ fname = "%s %s" % (fname, fields[i])
ALL_SCRIPTS[fname] = (menuname, group_len - 1)
return True
Tooltip: 'Export geometry to DXF-r12 (Drawing eXchange Format).'
"""
-__version__ = "v1.25beta - 2008.09.28"
-__author__ = "Stani & migius(Remigiusz Fiedler)"
+__version__ = "v1.27beta - 2008.10.07"
+__author__ = "Remigiusz Fiedler (AKA migius)"
__license__ = "GPL"
__url__ = "http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_dxf"
__bpydoc__ ="""The script exports Blender geometry to DXF format r12 version.
-Copyright %s
Version %s
+Copyright %s
License %s
-Homepage %s
+
+extern dependances: dxfLibrary.py
See the homepage for documentation.
-url:
-""" % (__author__,__version__,__license__,__url__)
+url: %s
-"""
IDEAs:
- - correct normals for POLYLINE-POLYFACE objects via correct point-order
- - HPGL output for 2d and flattened3d content
+ - correct normals for POLYLINE-POLYFACE via proper point-order
+ - HPGL output for 2d and flattened 3d content
TODO:
- - support hierarchies: groups, instances, parented structures
- - support 210-code (3d orientation vector)
- - presets for architectural scales
+- optimize back-faces removal (probably needs matrix transform)
+- optimize POLYFACE routine: remove double-vertices
+- optimize POLYFACE routine: remove unused vertices
+- support hierarchies: groups, instances, parented structures
+- support 210-code (3d orientation vector)
+- presets for architectural scales
+- write drawing extends for automatic view positioning in CAD
History
+v1.27 - 2008.10.07 by migius
+- exclude Stani's DXF-Library to extern module
+v1.26 - 2008.10.05 by migius
+- add "hidden mode" substitut: back-faces removal
+- add support for mesh ->POLYFACE
+- optimized code for "Flat" procedure
v1.25 - 2008.09.28 by migius
- - modif FACE class for r12
- - add mesh-polygon -> Bezier-curve converter (Yorik's code)
- - add support for curves ->POLYLINEs
- - add "3d-View to Flat" - geometry projection to XY-plane
+- modif FACE class for r12
+- add mesh-polygon -> Bezier-curve converter (Yorik's code)
+- add support for curves ->POLYLINEs
+- add "3d-View to Flat" - geometry projection to XY-plane
v1.24 - 2008.09.27 by migius
- - add start UI with preferences
- - modif POLYLINE class for r12
- - changing output format from r9 to r12(AC1009)
+- add start UI with preferences
+- modif POLYLINE class for r12
+- changing output format from r9 to r12(AC1009)
v1.23 - 2008.09.26 by migius
- - add finish message-box
+- add finish message-box
v1.22 - 2008.09.26 by migius
- - add support for curves ->LINEs
- - add support for mesh-edges ->LINEs
+- add support for curves ->LINEs
+- add support for mesh-edges ->LINEs
v1.21 - 2008.06.04 by migius
- - initial adaptation for Blender
-v1.1 (20/6/2005) by www.stani.be/python/sdxf
- - Python library to generate dxf drawings
+- initial adaptation for Blender
+v1.1 (20/6/2005) by Stani Michiels www.stani.be/python/sdxf
+- Python library to generate dxf drawings
______________________________________________________________
-"""
+""" % (__author__,__version__,__license__,__url__)
+
+# --------------------------------------------------------------------------
+# Script copyright (C) 2008 Remigiusz Fiedler (AKA migius)
+# --------------------------------------------------------------------------
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
from Blender import Mathutils, Window, Scene, sys, Draw
import BPyMessages
-try:
- import copy
- #from struct import pack
-except:
- copy = None
-
-####1) Private (only for developpers)
-_HEADER_POINTS=['insbase','extmin','extmax']
-
-#---helper functions-----------------------------------
-def _point(x,index=0):
- """Convert tuple to a dxf point"""
- #print '_point=', x #-------------
- return '\n'.join(['%s\n%s'%((i+1)*10+index,x[i]) for i in range(len(x))])
-
-def _points(plist):
- """Convert a list of tuples to dxf points"""
- return [_point(plist[i],i)for i in range(len(plist))]
-
-#---base classes----------------------------------------
-class _Call:
- """Makes a callable class."""
- def copy(self):
- """Returns a copy."""
- return copy.deepcopy(self)
-
- def __call__(self,**attrs):
- """Returns a copy with modified attributes."""
- copied=self.copy()
- for attr in attrs:setattr(copied,attr,attrs[attr])
- return copied
-
-#-------------------------------------------------------
-class _Entity(_Call):
- """Base class for _common group codes for entities."""
- def __init__(self,color=None,extrusion=None,layer='0',
- lineType=None,lineTypeScale=None,lineWeight=None,
- thickness=None,parent=None):
- """None values will be omitted."""
- self.color = color
- self.extrusion = extrusion
- self.layer = layer
- self.lineType = lineType
- self.lineTypeScale = lineTypeScale
- self.lineWeight = lineWeight
- self.thickness = thickness
- self.parent = parent
-
- def _common(self):
- """Return common group codes as a string."""
- if self.parent:parent=self.parent
- else:parent=self
- result='8\n%s'%parent.layer
- if parent.color!=None: result+='\n62\n%s'%parent.color
- if parent.extrusion!=None: result+='\n%s'%_point(parent.extrusion,200)
- if parent.lineType!=None: result+='\n6\n%s'%parent.lineType
- if parent.lineWeight!=None: result+='\n370\n%s'%parent.lineWeight
- if parent.lineTypeScale!=None: result+='\n48\n%s'%parent.lineTypeScale
- if parent.thickness!=None: result+='\n39\n%s'%parent.thickness
- return result
-
-#--------------------------
-class _Entities:
- """Base class to deal with composed objects."""
- def __dxf__(self):
- return []
-
- def __str__(self):
- return '\n'.join([str(x) for x in self.__dxf__()])
-
-#--------------------------
-class _Collection(_Call):
- """Base class to expose entities methods to main object."""
- def __init__(self,entities=[]):
- self.entities=copy.copy(entities)
- #link entities methods to drawing
- for attr in dir(self.entities):
- if attr[0]!='_':
- attrObject=getattr(self.entities,attr)
- if callable(attrObject):
- setattr(self,attr,attrObject)
-
-####2) Constants
-#---color values
-BYBLOCK=0
-BYLAYER=256
-
-#---block-type flags (bit coded values, may be combined):
-ANONYMOUS =1 # This is an anonymous block generated by hatching, associative dimensioning, other internal operations, or an application
-NON_CONSTANT_ATTRIBUTES =2 # This block has non-constant attribute definitions (this bit is not set if the block has any attribute definitions that are constant, or has no attribute definitions at all)
-XREF =4 # This block is an external reference (xref)
-XREF_OVERLAY =8 # This block is an xref overlay
-EXTERNAL =16 # This block is externally dependent
-RESOLVED =32 # This is a resolved external reference, or dependent of an external reference (ignored on input)
-REFERENCED =64 # This definition is a referenced external reference (ignored on input)
-
-#---mtext flags
-#attachment point
-TOP_LEFT = 1
-TOP_CENTER = 2
-TOP_RIGHT = 3
-MIDDLE_LEFT = 4
-MIDDLE_CENTER = 5
-MIDDLE_RIGHT = 6
-BOTTOM_LEFT = 7
-BOTTOM_CENTER = 8
-BOTTOM_RIGHT = 9
-#drawing direction
-LEFT_RIGHT = 1
-TOP_BOTTOM = 3
-BY_STYLE = 5 #the flow direction is inherited from the associated text style
-#line spacing style (optional):
-AT_LEAST = 1 #taller characters will override
-EXACT = 2 #taller characters will not override
-
-#---polyline flags
-CLOSED =1 # This is a closed polyline (or a polygon mesh closed in the M direction)
-CURVE_FIT =2 # Curve-fit vertices have been added
-SPLINE_FIT =4 # Spline-fit vertices have been added
-POLYLINE_3D =8 # This is a 3D polyline
-POLYGON_MESH =16 # This is a 3D polygon mesh
-CLOSED_N =32 # The polygon mesh is closed in the N direction
-POLYFACE_MESH =64 # The polyline is a polyface mesh
-CONTINOUS_LINETYPE_PATTERN =128 # The linetype pattern is generated continuously around the vertices of this polyline
-
-#---text flags
-#horizontal
-LEFT = 0
-CENTER = 1
-RIGHT = 2
-ALIGNED = 3 #if vertical alignment = 0
-MIDDLE = 4 #if vertical alignment = 0
-FIT = 5 #if vertical alignment = 0
-#vertical
-BASELINE = 0
-BOTTOM = 1
-MIDDLE = 2
-TOP = 3
-
-####3) Classes
-#---entitities -----------------------------------------------
-#--------------------------
-class Arc(_Entity):
- """Arc, angles in degrees."""
- def __init__(self,center=(0,0,0),radius=1,
- startAngle=0.0,endAngle=90,**common):
- """Angles in degrees."""
- _Entity.__init__(self,**common)
- self.center=center
- self.radius=radius
- self.startAngle=startAngle
- self.endAngle=endAngle
- def __str__(self):
- return '0\nARC\n%s\n%s\n40\n%s\n50\n%s\n51\n%s'%\
- (self._common(),_point(self.center),
- self.radius,self.startAngle,self.endAngle)
-
-#-----------------------------------------------
-class Circle(_Entity):
- """Circle"""
- def __init__(self,center=(0,0,0),radius=1,**common):
- _Entity.__init__(self,**common)
- self.center=center
- self.radius=radius
- def __str__(self):
- return '0\nCIRCLE\n%s\n%s\n40\n%s'%\
- (self._common(),_point(self.center),self.radius)
-
-#-----------------------------------------------
-class Face(_Entity):
- """3dface"""
- def __init__(self,points,**common):
- _Entity.__init__(self,**common)
- if len(points)<4: #fix for r12 format
- points.append(points[-1])
- self.points=points
-
- def __str__(self):
- return '\n'.join(['0\n3DFACE',self._common()]+
- _points(self.points)
- )
-#-----------------------------------------------
-class Insert(_Entity):
- """Block instance."""
- def __init__(self,name,point=(0,0,0),
- xscale=None,yscale=None,zscale=None,
- cols=None,colspacing=None,rows=None,rowspacing=None,
- rotation=None,
- **common):
- _Entity.__init__(self,**common)
- self.name=name
- self.point=point
- self.xscale=xscale
- self.yscale=yscale
- self.zscale=zscale
- self.cols=cols
- self.colspacing=colspacing
- self.rows=rows
- self.rowspacing=rowspacing
- self.rotation=rotation
-
- def __str__(self):
- result='0\nINSERT\n2\n%s\n%s\n%s'%\
- (self.name,self._common(),_point(self.point))
- if self.xscale!=None:result+='\n41\n%s'%self.xscale
- if self.yscale!=None:result+='\n42\n%s'%self.yscale
- if self.zscale!=None:result+='\n43\n%s'%self.zscale
- if self.rotation:result+='\n50\n%s'%self.rotation
- if self.cols!=None:result+='\n70\n%s'%self.cols
- if self.colspacing!=None:result+='\n44\n%s'%self.colspacing
- if self.rows!=None:result+='\n71\n%s'%self.rows
- if self.rowspacing!=None:result+='\n45\n%s'%self.rowspacing
- return result
-
-#-----------------------------------------------
-class Line(_Entity):
- """Line"""
- def __init__(self,points,**common):
- _Entity.__init__(self,**common)
- self.points=points
- def __str__(self):
- return '\n'.join(['0\nLINE',self._common()]+
- _points(self.points))
-
-#-----------------------------------------------
-class PolyLine(_Entity):
- #TODO: Finish polyline (now implemented as a series of lines)
- def __init__(self,points,org_point=[0,0,0],flag=0,width=None,**common):
- _Entity.__init__(self,**common)
- self.points=points
- self.org_point=org_point
- self.flag=flag
- self.width=width
- def __str__(self):
- result= '0\nPOLYLINE\n%s\n70\n%s' %(self._common(),self.flag)
- #print 'self._common()', self._common() #----------
- result+='\n66\n1'
- result+='\n%s' %_point(self.org_point)
- for point in self.points:
- result+='\n0\nVERTEX'
- result+='\n8\n%s' %self.layer
- result+='\n%s' %_point(point)
- if self.width:result+='\n40\n%s\n41\n%s' %(self.width,self.width)
- result+='\n0\nSEQEND'
- result+='\n8\n%s' %self.layer
- return result
-
-#-----------------------------------------------
-class Point(_Entity):
- """Colored solid fill."""
- def __init__(self,points=None,**common):
- _Entity.__init__(self,**common)
- self.points=points
-
-#-----------------------------------------------
-class Solid(_Entity):
- """Colored solid fill."""
- def __init__(self,points=None,**common):
- _Entity.__init__(self,**common)
- self.points=points
- def __str__(self):
- return '\n'.join(['0\nSOLID',self._common()]+
- _points(self.points[:2]+[self.points[3],self.points[2]])
- )
-
-#-----------------------------------------------
-class Text(_Entity):
- """Single text line."""
- def __init__(self,text='',point=(0,0,0),alignment=None,
- flag=None,height=1,justifyhor=None,justifyver=None,
- rotation=None,obliqueAngle=None,style=None,xscale=None,**common):
- _Entity.__init__(self,**common)
- self.text=text
- self.point=point
- self.alignment=alignment
- self.flag=flag
- self.height=height
- self.justifyhor=justifyhor
- self.justifyver=justifyver
- self.rotation=rotation
- self.obliqueAngle=obliqueAngle
- self.style=style
- self.xscale=xscale
- def __str__(self):
- result= '0\nTEXT\n%s\n%s\n40\n%s\n1\n%s'%\
- (self._common(),_point(self.point),self.height,self.text)
- if self.rotation:result+='\n50\n%s'%self.rotation
- if self.xscale:result+='\n41\n%s'%self.xscale
- if self.obliqueAngle:result+='\n51\n%s'%self.obliqueAngle
- if self.style:result+='\n7\n%s'%self.style
- if self.flag:result+='\n71\n%s'%self.flag
- if self.justifyhor:result+='\n72\n%s'%self.justifyhor
- if self.alignment:result+='\n%s'%_point(self.alignment,1)
- if self.justifyver:result+='\n73\n%s'%self.justifyver
- return result
-
-#-----------------------------------------------
-class Mtext(Text):
- """Surrogate for mtext, generates some Text instances."""
- def __init__(self,text='',point=(0,0,0),width=250,spacingFactor=1.5,down=0,spacingWidth=None,**options):
- Text.__init__(self,text=text,point=point,**options)
- if down:spacingFactor*=-1
- self.spacingFactor=spacingFactor
- self.spacingWidth=spacingWidth
- self.width=width
- self.down=down
- def __str__(self):
- texts=self.text.replace('\r\n','\n').split('\n')
- if not self.down:texts.reverse()
- result=''
- x=y=0
- if self.spacingWidth:spacingWidth=self.spacingWidth
- else:spacingWidth=self.height*self.spacingFactor
- for text in texts:
- while text:
- result+='\n%s'%Text(text[:self.width],
- point=(self.point[0]+x*spacingWidth,
- self.point[1]+y*spacingWidth,
- self.point[2]),
- alignment=self.alignment,flag=self.flag,height=self.height,
- justifyhor=self.justifyhor,justifyver=self.justifyver,
- rotation=self.rotation,obliqueAngle=self.obliqueAngle,
- style=self.style,xscale=self.xscale,parent=self
- )
- text=text[self.width:]
- if self.rotation:x+=1
- else:y+=1
- return result[1:]
-
-#-----------------------------------------------
-##class _Mtext(_Entity):
-## """Mtext not functioning for minimal dxf."""
-## def __init__(self,text='',point=(0,0,0),attachment=1,
-## charWidth=None,charHeight=1,direction=1,height=100,rotation=0,
-## spacingStyle=None,spacingFactor=None,style=None,width=100,
-## xdirection=None,**common):
-## _Entity.__init__(self,**common)
-## self.text=text
-## self.point=point
-## self.attachment=attachment
-## self.charWidth=charWidth
-## self.charHeight=charHeight
-## self.direction=direction
-## self.height=height
-## self.rotation=rotation
-## self.spacingStyle=spacingStyle
-## self.spacingFactor=spacingFactor
-## self.style=style
-## self.width=width
-## self.xdirection=xdirection
-## def __str__(self):
-## input=self.text
-## text=''
-## while len(input)>250:
-## text+='\n3\n%s'%input[:250]
-## input=input[250:]
-## text+='\n1\n%s'%input
-## result= '0\nMTEXT\n%s\n%s\n40\n%s\n41\n%s\n71\n%s\n72\n%s%s\n43\n%s\n50\n%s'%\
-## (self._common(),_point(self.point),self.charHeight,self.width,
-## self.attachment,self.direction,text,
-## self.height,
-## self.rotation)
-## if self.style:result+='\n7\n%s'%self.style
-## if self.xdirection:result+='\n%s'%_point(self.xdirection,1)
-## if self.charWidth:result+='\n42\n%s'%self.charWidth
-## if self.spacingStyle:result+='\n73\n%s'%self.spacingStyle
-## if self.spacingFactor:result+='\n44\n%s'%self.spacingFactor
-## return result
-
-#---tables ---------------------------------------------------
-#-----------------------------------------------
-class Block(_Collection):
- """Use list methods to add entities, eg append."""
- def __init__(self,name,layer='0',flag=0,base=(0,0,0),entities=[]):
- self.entities=copy.copy(entities)
- _Collection.__init__(self,entities)
- self.layer=layer
- self.name=name
- self.flag=0
- self.base=base
- def __str__(self):
- e='\n'.join([str(x)for x in self.entities])
- return '0\nBLOCK\n8\n%s\n2\n%s\n70\n%s\n%s\n3\n%s\n%s\n0\nENDBLK'%\
- (self.layer,self.name.upper(),self.flag,_point(self.base),self.name.upper(),e)
-
-#-----------------------------------------------
-class Layer(_Call):
- """Layer"""
- def __init__(self,name='pydxf',color=7,lineType='continuous',flag=64):
- self.name=name
- self.color=color
- self.lineType=lineType
- self.flag=flag
- def __str__(self):
- return '0\nLAYER\n2\n%s\n70\n%s\n62\n%s\n6\n%s'%\
- (self.name.upper(),self.flag,self.color,self.lineType)
-
-#-----------------------------------------------
-class LineType(_Call):
- """Custom linetype"""
- def __init__(self,name='continuous',description='Solid line',elements=[],flag=64):
- # TODO: Implement lineType elements
- self.name=name
- self.description=description
- self.elements=copy.copy(elements)
- self.flag=flag
- def __str__(self):
- return '0\nLTYPE\n2\n%s\n70\n%s\n3\n%s\n72\n65\n73\n%s\n40\n0.0'%\
- (self.name.upper(),self.flag,self.description,len(self.elements))
-
-#-----------------------------------------------
-class Style(_Call):
- """Text style"""
- def __init__(self,name='standard',flag=0,height=0,widthFactor=40,obliqueAngle=50,
- mirror=0,lastHeight=1,font='arial.ttf',bigFont=''):
- self.name=name
- self.flag=flag
- self.height=height
- self.widthFactor=widthFactor
- self.obliqueAngle=obliqueAngle
- self.mirror=mirror
- self.lastHeight=lastHeight
- self.font=font
- self.bigFont=bigFont
- def __str__(self):
- return '0\nSTYLE\n2\n%s\n70\n%s\n40\n%s\n41\n%s\n50\n%s\n71\n%s\n42\n%s\n3\n%s\n4\n%s'%\
- (self.name.upper(),self.flag,self.flag,self.widthFactor,
- self.obliqueAngle,self.mirror,self.lastHeight,
- self.font.upper(),self.bigFont.upper())
-
-#-----------------------------------------------
-class View(_Call):
- def __init__(self,name,flag=0,width=1,height=1,center=(0.5,0.5),
- direction=(0,0,1),target=(0,0,0),lens=50,
- frontClipping=0,backClipping=0,twist=0,mode=0):
- self.name=name
- self.flag=flag
- self.width=width
- self.height=height
- self.center=center
- self.direction=direction
- self.target=target
- self.lens=lens
- self.frontClipping=frontClipping
- self.backClipping=backClipping
- self.twist=twist
- self.mode=mode
- def __str__(self):
- return '0\nVIEW\n2\n%s\n70\n%s\n40\n%s\n%s\n41\n%s\n%s\n%s\n42\n%s\n43\n%s\n44\n%s\n50\n%s\n71\n%s'%\
- (self.name,self.flag,self.height,_point(self.center),self.width,
- _point(self.direction,1),_point(self.target,2),self.lens,
- self.frontClipping,self.backClipping,self.twist,self.mode)
-
-#-----------------------------------------------
-def ViewByWindow(name,leftBottom=(0,0),rightTop=(1,1),**options):
- width=abs(rightTop[0]-leftBottom[0])
- height=abs(rightTop[1]-leftBottom[1])
- center=((rightTop[0]+leftBottom[0])*0.5,(rightTop[1]+leftBottom[1])*0.5)
- return View(name=name,width=width,height=height,center=center,**options)
-
-#---drawing
-#-----------------------------------------------
-class Drawing(_Collection):
- """Dxf drawing. Use append or any other list methods to add objects."""
- def __init__(self,insbase=(0.0,0.0,0.0),extmin=(0.0,0.0),extmax=(0.0,0.0),
- layers=[Layer()],linetypes=[LineType()],styles=[Style()],blocks=[],
- views=[],entities=None,fileName='test.dxf'):
- # TODO: replace list with None,arial
- if not entities:entities=[]
- _Collection.__init__(self,entities)
- self.insbase=insbase
- self.extmin=extmin
- self.extmax=extmax
- self.layers=copy.copy(layers)
- self.linetypes=copy.copy(linetypes)
- self.styles=copy.copy(styles)
- self.views=copy.copy(views)
- self.blocks=copy.copy(blocks)
- self.fileName=fileName
- #private
- #self.acadver='9\n$ACADVER\n1\nAC1006'
- self.acadver='9\n$ACADVER\n1\nAC1009'
- """DXF AutoCAD-Release format code
- AC1021 2008, 2007
- AC1018 2006, 2005, 2004
- AC1015 2002, 2000i, 2000
- AC1014 R14,14.01
- AC1012 R13
- AC1009 R12,11
- AC1006 R10
- AC1004 R9
- AC1002 R2.6
- AC1.50 R2.05
- """
-
- def _name(self,x):
- """Helper function for self._point"""
- return '9\n$%s'%x.upper()
-
- def _point(self,name,x):
- """Point setting from drawing like extmin,extmax,..."""
- return '%s\n%s'%(self._name(name),_point(x))
-
- def _section(self,name,x):
- """Sections like tables,blocks,entities,..."""
- if x:xstr='\n'+'\n'.join(x)
- else:xstr=''
- return '0\nSECTION\n2\n%s%s\n0\nENDSEC'%(name.upper(),xstr)
-
- def _table(self,name,x):
- """Tables like ltype,layer,style,..."""
- if x:xstr='\n'+'\n'.join(x)
- else:xstr=''
- return '0\nTABLE\n2\n%s\n70\n%s%s\n0\nENDTAB'%(name.upper(),len(x),xstr)
-
- def __str__(self):
- """Returns drawing as dxf string."""
- header=[self.acadver]+[self._point(attr,getattr(self,attr)) for attr in _HEADER_POINTS]
- header=self._section('header',header)
-
- tables=[self._table('ltype',[str(x) for x in self.linetypes]),
- self._table('layer',[str(x) for x in self.layers]),
- self._table('style',[str(x) for x in self.styles]),
- self._table('view',[str(x) for x in self.views]),
- ]
- tables=self._section('tables',tables)
-
- blocks=self._section('blocks',[str(x) for x in self.blocks])
-
- entities=self._section('entities',[str(x) for x in self.entities])
-
- all='\n'.join([header,tables,blocks,entities,'0\nEOF\n'])
- return all
-
- def saveas(self,fileName):
- self.fileName=fileName
- self.save()
-
- def save(self):
- test=open(self.fileName,'w')
- test.write(str(self))
- test.close()
-
-
-#---extras
-#-----------------------------------------------
-class Rectangle(_Entity):
- """Rectangle, creates lines."""
- def __init__(self,point=(0,0,0),width=1,height=1,solid=None,line=1,**common):
- _Entity.__init__(self,**common)
- self.point=point
- self.width=width
- self.height=height
- self.solid=solid
- self.line=line
- def __str__(self):
- result=''
- points=[self.point,(self.point[0]+self.width,self.point[1],self.point[2]),
- (self.point[0]+self.width,self.point[1]+self.height,self.point[2]),
- (self.point[0],self.point[1]+self.height,self.point[2]),self.point]
- if self.solid:
- result+='\n%s'%Solid(points=points[:-1],parent=self.solid)
- if self.line:
- for i in range(4):result+='\n%s'%\
- Line(points=[points[i],points[i+1]],parent=self)
- return result[1:]
-
-#-----------------------------------------------
-class LineList(_Entity):
- """Like polyline, but built of individual lines."""
- def __init__(self,points=[],org_point=[0,0,0],closed=0,**common):
- _Entity.__init__(self,**common)
- self.closed=closed
- self.points=copy.copy(points)
- def __str__(self):
- if self.closed:points=self.points+[self.points[0]]
- else: points=self.points
- result=''
- for i in range(len(points)-1):
- result+='\n%s' %Line(points=[points[i],points[i+1]],parent=self)
- return result[1:]
+#import dxfLibrary
+#reload(dxfLibrary)
+from dxfLibrary import *
+
+
+#-----------------------------------------------------
+def hidden_status(faces, mx_n):
+ #print 'HIDDEN_MODE: caution! not full implemented yet'
+ ok_faces = []
+ ok_edges = []
+ #sort out back-faces = with normals pointed away from camera
+ for f in faces:
+ #print 'deb: face=', f #---------
+ # get its normal-vector in localCS
+ vec_normal = f.no.copy()
+ #print 'deb: vec_normal=', vec_normal #------------------
+ #must be transfered to camera/view-CS
+ vec_normal *= mx_n
+ #vec_normal *= mb.rotationPart()
+ #print 'deb:2vec_normal=', vec_normal #------------------
+ #vec_normal *= mw0.rotationPart()
+ #print 'deb:3vec_normal=', vec_normal, '\n' #------------------
+
+ # normal must point the Z direction-hemisphere
+ if vec_normal[2] > 0.0 :
+ ok_faces.append(f.index)
+ for key in f.edge_keys:
+ #this test can be done faster with set()
+ if key not in ok_edges:
+ ok_edges.append(key)
+ #print 'deb: amount of visible faces=', len(ok_faces) #---------
+ #print 'deb: visible faces=', ok_faces #---------
+ #print 'deb: amount of visible edges=', len(ok_edges) #---------
+ #print 'deb: visible edges=', ok_edges #---------
+ return ok_faces, ok_edges
+
#-----------------------------------------------------
def projected_co(vec, mw):
- # convert the world coordinates of v to screen coordinates
+ # convert the world coordinates of vector to screen coordinates
#co = vec.co.copy().resize4D()
co = vec.copy().resize4D()
co[3] = 1.0
sc = co * mw
- #print 'viewprojection=', sc #---------
+ #print 'deb: viewprojection=', sc #---------
return [sc[0],sc[1],0.0]
+#--------not used---------------------------------------------
+def flatten(points, mw):
+ for i,v in enumerate(points):
+ v = projected_co(v, mw)
+ points[i]=v
+ #print 'deb: flatten points=', points #---------
+ return points
+
+#-----------------------------------------------------
+def exportMesh(ob, mx, mx_n):
+ entities = []
+ me = ob.getData(mesh=1)
+ #me.transform(mx)
+ # above is eventualy faster, but bad, cause
+ # directly transforms origin geometry and write back rounding errors
+ me_verts = me.verts[:] #we dont want manipulate origin data
+ #print 'deb: me_verts=', me_verts #---------
+ #me.transform(mx_inv) #counterpart to - back to the origin state
+ for v in me_verts:
+ v.co *= mx
+ faces=[]
+ edges=[]
+ if HIDDEN_MODE:
+ ok_faces, ok_edges = hidden_status(me.faces, mx_n)
+
+ #if (not FLATTEN) and len(me.faces)>0 and ONLYFACES:
+ if ONLYFACES:
+ if POLYFACES: #export 3D as POLYFACEs
+ allpoints = []
+ allfaces = []
+ allpoints = [v.co[:3] for v in me_verts]
+ for f in me.faces:
+ #print 'deb: face=', f #---------
+ if not HIDDEN_MODE or \
+ (HIDDEN_MODE and f.index in ok_faces):
+ if 1:
+ points = f.verts
+ face = [p.index+1 for p in points]
+ #print 'deb: face=', face #---------
+ allfaces.append(face)
+ else: #bad, cause create multiple vertex instances
+ points = f.verts
+ points = [ me_verts[p.index].co[:3] for p in points]
+ #points = [p.co[:3] for p in points]
+ #print 'deb: points=', points #---------
+ index = len(allpoints)+1
+ face = [index+i for i in range(len(points))]
+ allpoints.extend(points)
+ allfaces.append(face)
+ if allpoints and allfaces:
+ #print 'deb: allpoints=', allpoints #---------
+ #print 'deb: allfaces=', allfaces #---------
+ dxfPOLYFACE = PolyLine([allpoints, allfaces], flag=64)
+ entities.append(dxfPOLYFACE)
+ else: #export 3D as 3DFACEs
+ for f in me.faces:
+ #print 'deb: face=', f #---------
+ if not HIDDEN_MODE or \
+ (HIDDEN_MODE and f.index in ok_faces):
+ points = f.verts
+ points = [ me_verts[p.index].co[:3] for p in points]
+ #points = [p.co[:3] for p in points]
+ #print 'deb: points=', points #---------
+ dxfFACE = Face(points)
+ entities.append(dxfFACE)
+
+ else: #export 3D as LINEs
+ if HIDDEN_MODE and len(me.faces)!=0:
+ for e in ok_edges:
+ points = [ me_verts[key].co[:3] for key in e]
+ dxfLINE = Line(points)
+ entities.append(dxfLINE)
+
+ else:
+ for e in me.edges:
+ #print 'deb: edge=', e #---------
+ points=[]
+ #points = [e.v1.co*mx, e.v2.co*mx]
+ points = [ me_verts[key].co[:3] for key in e.key]
+ #print 'deb: points=', points #---------
+ dxfLINE = Line(points)
+ entities.append(dxfLINE)
+ return entities
+
+
+#-----------------------------------------------------
+def exportCurve(ob, mx):
+ entities = []
+ curve = ob.getData()
+ for cur in curve:
+ #print 'deb: START cur=', cur #--------------
+ if 1: #not cur.isNurb():
+ #print 'deb: START points' #--------------
+ points = []
+ org_point = [0.0,0.0,0.0]
+ for point in cur:
+ #print 'deb: point=', point #---------
+ if cur.isNurb():
+ vec = point[0:3]
+ else:
+ point = point.getTriple()
+ #print 'deb: point=', point #---------
+ vec = point[1]
+ #print 'deb: vec=', vec #---------
+ pkt = Mathutils.Vector(vec) * mx
+ #print 'deb: pkt=', pkt #---------
+ #pkt *= SCALE_FACTOR
+ if 0: #FLATTEN:
+ pkt = projected_co(pkt, mw)
+ points.append(pkt)
+ if cur.isCyclic(): closed = 1
+ else: closed = 0
+ if len(points)>1:
+ #print 'deb: points', points #--------------
+ if POLYLINES: dxfPLINE = PolyLine(points,org_point,closed)
+ else: dxfPLINE = LineList(points,org_point,closed)
+ entities.append(dxfPLINE)
+ return entities
+
+#-----------------------------------------------------
+def do_export(sel_group, filepath):
+ Window.WaitCursor(1)
+ t = sys.time()
+
+ #init Drawing ---------------------
+ d=Drawing()
+ #add Tables -----------------
+ #d.blocks.append(b) #table blocks
+ d.styles.append(Style()) #table styles
+ d.views.append(View('Normal')) #table view
+ d.views.append(ViewByWindow('Window',leftBottom=(1,0),rightTop=(2,1))) #idem
+
+ #add Entities --------------------
+ something_ready = False
+ #ViewVector = Mathutils.Vector(Window.GetViewVector())
+ #print 'deb: ViewVector=', ViewVector #------------------
+ mw0 = Window.GetViewMatrix()
+ #mw0 = Window.GetPerspMatrix() #TODO: how get it working?
+ mw = mw0.copy()
+ if FLATTEN:
+ m0 = Mathutils.Matrix()
+ m0[2][2]=0.0
+ mw *= m0 #flatten ViewMatrix
+
+ for ob in sel_group:
+ entities = []
+ mx = ob.matrix.copy()
+ mb = mx.copy()
+ #print 'deb: mb =\n', mb #---------
+ #print 'deb: mw0 =\n', mw0 #---------
+ mx_n = mx.rotationPart() * mw0.rotationPart() #trans-matrix for normal_vectors
+ if SCALE_FACTOR!=1.0: mx *= SCALE_FACTOR
+ if FLATTEN: mx *= mw
+
+ #mx_inv = mx.copy().invert()
+ #print 'deb: mx =\n', mx #---------
+ #print 'deb: mx_inv=\n', mx_inv #---------
+
+ if (ob.type == 'Mesh'):
+ entities = exportMesh(ob, mx, mx_n)
+ elif (ob.type == 'Curve'):
+ entities = exportCurve(ob, mx)
+
+ for e in entities:
+ d.append(e)
+ something_ready = True
+
+ if something_ready:
+ d.saveas(filepath)
+ Window.WaitCursor(0)
+ #Draw.PupMenu('DXF Exporter: job finished')
+ print 'exported to %s' % filepath
+ print 'finished in %.2f seconds' % (sys.time()-t)
+ else:
+ Window.WaitCursor(0)
+ print "Abort: selected objects dont mach choosen export option, nothing exported!"
+ Draw.PupMenu('DXF Exporter: nothing exported!|selected objects dont mach choosen export option!')
+
+#----globals------------------------------------------
+ONLYSELECTED = True
+POLYLINES = True
+ONLYFACES = False
+POLYFACES = 1
+FLATTEN = 0
+HIDDEN_MODE = False #filter out hidden lines
+SCALE_FACTOR = 1.0 #optional, can be done later in CAD too
+
+
+
#-----------------------------------------------------
def dxf_export_ui(filepath):
- print '\n\nDXF-Export %s' %__version__
+ global ONLYSELECTED,\
+ POLYLINES,\
+ ONLYFACES,\
+ POLYFACES,\
+ FLATTEN,\
+ HIDDEN_MODE,\
+ SCALE_FACTOR
+
+ print '\n\nDXF-Export %s -----------------------' %__version__
#filepath = 'blend_test.dxf'
# Dont overwrite
if not BPyMessages.Warning_SaveOver(filepath):
return
#test():return
- ONLYSELECTED = True
- POLYLINES = True
- ONLYFACES = False
- FLATTEN = 0 #dimmensions:1,2,3. Force Z dimmension value to 0.0, equal ground projection
- SCALE_FACTOR = 1.0 #optional, can be done in CAD too
+
PREF_ONLYSELECTED= Draw.Create(ONLYSELECTED)
PREF_POLYLINES= Draw.Create(POLYLINES)
PREF_ONLYFACES= Draw.Create(ONLYFACES)
+ PREF_POLYFACES= Draw.Create(POLYFACES)
PREF_FLATTEN= Draw.Create(FLATTEN)
+ PREF_HIDDEN_MODE= Draw.Create(HIDDEN_MODE)
PREF_SCALE_FACTOR= Draw.Create(SCALE_FACTOR)
PREF_HELP= Draw.Create(0)
block = [\
("only selected", PREF_ONLYSELECTED, "export only selected geometry"),\
("global Scale:", PREF_SCALE_FACTOR, 0.001, 1000, "set global Scale factor for exporting geometry"),\
- ("only faces", PREF_ONLYFACES, "from mesh-objects export only faces, not edges"),\
- ("write POLYLINEs", PREF_POLYLINES, "export curves to POLYLINEs, otherwise to LINEs"),\
+ ("only faces", PREF_ONLYFACES, "from mesh-objects export only faces, otherwise only edges"),\
+ ("write POLYFACE", PREF_POLYFACES, "export mesh to POLYFACE, otherwise to 3DFACEs"),\
+ ("write POLYLINEs", PREF_POLYLINES, "export curve to POLYLINE, otherwise to LINEs"),\
("3D-View to Flat", PREF_FLATTEN, "flatten geometry according current 3d-View"),\
- (''),\
+ ("Hidden Mode", PREF_HIDDEN_MODE, "filter out hidden lines"),\
+ #(''),\
("online Help", PREF_HELP, "calls DXF-Exporter Manual Page on Wiki.Blender.org"),\
]
- if not Draw.PupBlock("DXF-Exporter %s" %__version__[:10], block):
- return
+ if not Draw.PupBlock("DXF-Exporter %s" %__version__[:10], block): return
if PREF_HELP.val!=0:
try:
ONLYSELECTED = PREF_ONLYSELECTED.val
POLYLINES = PREF_POLYLINES.val
ONLYFACES = PREF_ONLYFACES.val
+ POLYFACES = PREF_POLYFACES.val
FLATTEN = PREF_FLATTEN.val
+ HIDDEN_MODE = PREF_HIDDEN_MODE.val
SCALE_FACTOR = PREF_SCALE_FACTOR.val
sce = Scene.GetCurrent()
if ONLYSELECTED: sel_group = sce.objects.selected
else: sel_group = sce.objects
- if sel_group:
- Window.WaitCursor(1)
- t = sys.time()
-
- #init Drawing ---------------------
- d=Drawing()
- #add Tables -----------------
- #d.blocks.append(b) #table blocks
- d.styles.append(Style()) #table styles
- d.views.append(View('Normal')) #table view
- d.views.append(ViewByWindow('Window',leftBottom=(1,0),rightTop=(2,1))) #idem
-
- #add Entities --------------------
- something_ready = False
- mw = Window.GetViewMatrix()
- #mw = Window.GetPerspMatrix() #TODO: how get it working?
- for ob in sel_group:
- entities = []
- mx = ob.matrix
- if (ob.type == 'Mesh'):
- me = ob.getData(mesh=1)
- faces=[]
- edges=[]
- if (not FLATTEN) and len(me.faces)>0 and ONLYFACES:
- #export 3D as 3DFACEs
- for f in me.faces:
- #print 'face=', f #---------
- verts = f.verts
- points = [verts[i].co*mx for i in range(len(verts))]
- if SCALE_FACTOR!=1.0:
- points = [p*SCALE_FACTOR for p in points]
- #print 'points=', points #---------
- dxfFACE = Face(points)
- entities.append(dxfFACE)
- else: #export 3D as LINEs
- for e in me.edges:
- #print 'edge=', e #---------
- points=[]
- points = [e.v1.co*mx, e.v2.co*mx]
- if SCALE_FACTOR!=1.0:
- points = [p*SCALE_FACTOR for p in points]
- if FLATTEN:
-# for p in points: p[FLATTEN-1]=0.0
- for i,v in enumerate(points):
- v = projected_co(v, mw)
- points[i]=v
- #print 'flatten points=', points #---------
- dxfLINE = Line(points)
- entities.append(dxfLINE)
- elif (ob.type == 'Curve'):
- curve = ob.getData()
- for cur in curve:
- #print 'deb: START cur=', cur #--------------
- if 1: #not cur.isNurb():
- #print 'deb: START points' #--------------
- points = []
- org_point = [0.0,0.0,0.0]
- for point in cur:
- #print 'point=', point #---------
- if cur.isNurb():
- vec = point[0:3]
- else:
- point = point.getTriple()
- #print 'point=', point #---------
- vec = point[1]
- #print 'vec=', vec #---------
- pkt = Mathutils.Vector(vec) * mx
- #print 'pkt=', pkt #---------
- pkt *= SCALE_FACTOR
- if FLATTEN:
- pkt = projected_co(pkt, mw)
- points.append(pkt)
- if cur.isCyclic(): closed = 1
- else: closed = 0
- if len(points)>1:
- #print 'deb: points', points #--------------
- if POLYLINES: dxfPLINE = PolyLine(points,org_point,closed)
- else: dxfPLINE = LineList(points,org_point,closed)
- entities.append(dxfPLINE)
- for e in entities:
- d.append(e)
- something_ready = True
- if something_ready:
- d.saveas(filepath)
- Window.WaitCursor(0)
- #Draw.PupMenu('DXF Exporter: job finished|search for blend_test.dxf in current project directory')
- print 'exported to %s' % filepath
- print 'finished in %.2f seconds' % (sys.time()-t)
- else:
- print "Abort: no supported object types selected, nothing exported!"
- Draw.PupMenu('DXF Exporter: Abort!|Not-supported object types selected.')
+ if sel_group: do_export(sel_group, filepath)
else:
print "Abort: selection was empty, no object to export!"
- Draw.PupMenu('DXF Exporter: Abort!|empty selection, no object to export!')
+ Draw.PupMenu('DXF Exporter: nothing exported!|empty selection!')
# Timing the script is a good way to be aware on any speed hits when scripting
-#-----------------------------------------------------
-def test():
- #Blocks
- b=Block('test')
- b.append(Solid(points=[(0,0,0),(1,0,0),(1,1,0),(0,1,0)],color=1))
- b.append(Arc(center=(1,0,0),color=2))
-
- #Drawing
- d=Drawing()
- #tables
- d.blocks.append(b) #table blocks
- d.styles.append(Style()) #table styles
- d.views.append(View('Normal')) #table view
- d.views.append(ViewByWindow('Window',leftBottom=(1,0),rightTop=(2,1))) #idem
-
- #entities
- d.append(Circle(center=(1,1,0),color=3))
- d.append(Face(points=[(0,0,0),(1,0,0),(1,1,0),(0,1,0)],color=4))
- d.append(Insert('test',point=(3,3,3),cols=5,colspacing=2))
- d.append(Line(points=[(0,0,0),(1,1,1)]))
- d.append(Mtext('Click on Ads\nmultiple lines with mtext',point=(1,1,1),color=5,rotation=90))
- d.append(Text('Please donate!',point=(3,0,1)))
- d.append(Rectangle(point=(2,2,2),width=4,height=3,color=6,solid=Solid(color=2)))
- d.append(Solid(points=[(4,4,0),(5,4,0),(7,8,0),(9,9,0)],color=3))
- d.append(PolyLine(points=[(1,1,1),(2,1,1),(2,2,1),(1,2,1)],closed=1,color=1))
-
- #d.saveas('c:\\test.dxf')
- d.saveas('test.dxf')
-
#-----------------------------------------------------
if __name__=='__main__':
def parse_script_line(l):
+ tip = 'No tooltip'
try:
pieces = l.split("'")
name = pieces[1].replace('...','')
- version, fname, userdir = pieces[2].strip().split()
- tip = pieces[3]
+ data = pieces[2].strip().split()
+ version = data[0]
+ userdir = data[-1]
+ fname = data[1]
+ i = 1
+ while not fname.endswith('.py'):
+ i += 1
+ fname = '%s %s' % (fname, data[i])
+ if len(pieces) > 3: tip = pieces[3]
except:
return None
if scene != inlines[0]:
return
else:
- for i in range(allinlines):
+ for i in xrange(allinlines):
nameinline=inlines[i].getName()
if (nameinline not in self.namesStandard) and (i > 0):
self.writeIndented("DEF %s Inline {\n" % \
def writeScript(self):
textEditor = Blender.Text.Get()
alltext = len(textEditor)
- for i in range(alltext):
+ for i in xrange(alltext):
nametext = textEditor[i].getName()
nlines = textEditor[i].getNLines()
if (self.proto == 1):
nametext == "proto.txt") and (nlines != None):
nalllines = len(textEditor[i].asLines())
alllines = textEditor[i].asLines()
- for j in range(nalllines):
+ for j in xrange(nalllines):
self.writeIndented(alllines[j] + "\n")
elif (self.proto == 0):
if (nametext == "route" or nametext == "route.js" or \
nametext == "route.txt") and (nlines != None):
nalllines = len(textEditor[i].asLines())
alllines = textEditor[i].asLines()
- for j in range(nalllines):
+ for j in xrange(nalllines):
self.writeIndented(alllines[j] + "\n")
self.writeIndented("\n")
issmooth = 0
maters = me.materials
- nummats = self.getNumMaterials(me)
+ nummats = len(me.materials)
# Vertex and Face colors trump materials and image textures
if (self.facecolors or self.vcolors):
if nummats > 0:
- if maters[0]:
- self.writeShape(ob, me, 0, None)
- else:
- self.writeShape(ob, me, -1, None)
+ self.writeShape(ob, me, 0, None)
else:
self.writeShape(ob, me, -1, None)
- # Do meshes with materials, possible with image textures
+
+ # Do meshes with materials, possibly with image textures
elif nummats > 0:
- for matnum in range(len(maters)):
- if maters[matnum]:
- images = []
- if me.faceUV:
- images = self.getImages(me, matnum)
- if len(images) > 0:
- for image in images:
- self.writeShape(ob, me, matnum, image)
- else:
- self.writeShape(ob, me, matnum, None)
+ for matnum in xrange(len(maters)):
+ images = []
+ if me.faceUV:
+ images = self.getImages(me, matnum)
+ if len(images) > 0:
+ for image in images:
+ self.writeShape(ob, me, matnum, image)
else:
self.writeShape(ob, me, matnum, None)
+ else:
+ self.writeShape(ob, me, matnum, None)
else:
if me.faceUV:
images = self.getImages(me, -1)
imageNames[imName]=1
return images
- def getNumMaterials(self, me):
- # Oh silly Blender, why do you sometimes have 'None' as
- # a member of the me.materials array?
- num = 0
- for mat in me.materials:
- if mat:
- num = num + 1
- return num
-
def writeCoordinates(self, me, meshName):
coordName = "coord_%s" % (meshName)
# look up coord name, use it if available
self.writeIndented("}\n", -1)
self.writeIndented("\n")
+ def testShape(self, ob, me, matnum, image):
+ if ( (matnum == -1) and (image == None) ):
+ if ( len(me.faces) > 0 ):
+ return True
+ # Check if any faces the material or image
+ for face in me.faces:
+ if (matnum == -1):
+ if (f.image == image):
+ return True
+ elif (image == None):
+ if (face.mat == matnum):
+ return True
+ else:
+ if ((face.image == image) and (face.mat == matnum)):
+ return True
+
+ return False
+
def writeShape(self, ob, me, matnum, image):
- # Note: at this point it is assumed for matnum!=-1 that the
- # material in me.materials[matnum] is not equal to 'None'.
- # Such validation should be performed by the function that
- # calls this one.
+ # matnum == -1 means don't check the face.mat
+ # image == None means don't check face.image
+
+ if ( not self.testShape(ob, me, matnum, image) ):
+ return False
+
self.writeIndented("Shape {\n",1)
self.writeIndented("appearance Appearance {\n", 1)
if (matnum != -1):
mater = me.materials[matnum]
- self.writeMaterial(mater, self.cleanStr(mater.name,''))
- if (mater.mode & Blender.Material.Modes['TEXFACE']):
- if image != None:
- self.writeImageTexture(image.name, image.filename)
+ if (mater):
+ self.writeMaterial(mater, self.cleanStr(mater.name,''))
+ if (mater.mode & Blender.Material.Modes['TEXFACE']):
+ if image != None:
+ self.writeImageTexture(image.name, image.filename)
+ else:
+ self.writeDefaultMaterial()
else:
if image != None:
self.writeImageTexture(image.name, image.filename)
self.writeIndented("}\n", -1)
+ return True
+
def writeGeometry(self, ob, me, matnum, image):
#-- IndexedFaceSet or IndexedLineSet
indexStr = ""
if (matnum == -1) or (face.mat == matnum):
if (face.image == image):
- for i in range(len(face.verts)):
+ for i in xrange(len(face.verts)):
uv = face.uv[i]
indexStr += "%s " % (j)
coordStr += "%s %s, " % \
cols = [None] * len(me.verts)
for face in me.faces:
- for vind in range(len(face.v)):
+ for vind in xrange(len(face.v)):
vertex = face.v[vind]
i = vertex.index
if cols[i] == None:
cols[i] = face.col[vind]
- for i in range(len(me.verts)):
+ for i in xrange(len(me.verts)):
aColor = self.rgbToFS(cols[i])
self.writeUnindented("%s\n" % aColor)
self.writeIndented("]\n",-1)
self.writeIndented("}\n",-1)
+ def writeDefaultMaterial(self):
+ matName = "default"
+
+ # look up material name, use it if available
+ if self.matNames.has_key(matName):
+ self.writeIndented("material USE MA_%s\n" % matName)
+ self.matNames[matName]+=1
+ return;
+
+ self.matNames[matName]=1
+ self.writeIndented("material DEF MA_%s Material {\n" % matName, 1)
+ self.writeIndented("diffuseColor 0.8 0.8 0.8\n")
+ self.writeIndented("specularColor 1.0 1.0 1.0\n")
+ self.writeIndented("shininess 0.5\n")
+ self.writeIndented("transparency 0.0\n")
+ self.writeIndented("}\n",-1)
+
def writeMaterial(self, mat, matName):
# look up material name, use it if available
if self.matNames.has_key(matName):
-PSF LICENSE AGREEMENT FOR PYTHON 2.3
-------------------------------------
+PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
+--------------------------------------------
1. This LICENSE AGREEMENT is between the Python Software Foundation
("PSF"), and the Individual or Organization ("Licensee") accessing and
-otherwise using Python 2.3 software in source or binary form and its
-associated documentation.
+otherwise using this software ("Python") in source or binary form and
+its associated documentation.
2. Subject to the terms and conditions of this License Agreement, PSF
hereby grants Licensee a nonexclusive, royalty-free, world-wide
license to reproduce, analyze, test, perform and/or display publicly,
-prepare derivative works, distribute, and otherwise use Python 2.3
+prepare derivative works, distribute, and otherwise use Python
alone or in any derivative version, provided, however, that PSF's
License Agreement and PSF's notice of copyright, i.e., "Copyright (c)
-2001, 2002, 2003 Python Software Foundation; All Rights Reserved" are
-retained in Python 2.3 alone or in any derivative version prepared by
-Licensee.
+2001, 2002, 2003, 2004, 2005, 2006 Python Software Foundation; All Rights
+Reserved" are retained in Python alone or in any derivative version
+prepared by Licensee.
3. In the event Licensee prepares a derivative work that is based on
-or incorporates Python 2.3 or any part thereof, and wants to make
+or incorporates Python or any part thereof, and wants to make
the derivative work available to others as provided herein, then
Licensee hereby agrees to include in any such work a brief summary of
-the changes made to Python 2.3.
+the changes made to Python.
-4. PSF is making Python 2.3 available to Licensee on an "AS IS"
+4. PSF is making Python available to Licensee on an "AS IS"
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
-FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.3 WILL NOT
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
INFRINGE ANY THIRD PARTY RIGHTS.
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
-2.3 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
-A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.3,
+FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
+A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
6. This License Agreement will automatically terminate upon a material
trademarks or trade name in a trademark sense to endorse or promote
products or services of Licensee, or any third party.
-8. By copying, installing or otherwise using Python 2.3, Licensee
+8. By copying, installing or otherwise using Python, Licensee
agrees to be bound by the terms and conditions of this License
Agreement.
+
struct MemFile;
#define BLENDER_VERSION 247
-#define BLENDER_SUBVERSION 9
+#define BLENDER_SUBVERSION 10
#define BLENDER_MINVERSION 245
#define BLENDER_MINSUBVERSION 15
#define DL_FRONT_CURVE 4
#define DL_BACK_CURVE 8
-#define DL_SURFINDEX(cyclu, cyclv, sizeu, sizev) \
-\
-if( (cyclv)==0 && a==(sizev)-1) break; \
-if(cyclu) { \
- p1= sizeu*a; \
- p2= p1+ sizeu-1; \
- p3= p1+ sizeu; \
- p4= p2+ sizeu; \
- b= 0; \
-} \
-else { \
- p2= sizeu*a; \
- p1= p2+1; \
- p4= p2+ sizeu; \
- p3= p1+ sizeu; \
- b= 1; \
-} \
-if( (cyclv) && a==sizev-1) { \
- p3-= sizeu*sizev; \
- p4-= sizeu*sizev; \
-}
-
/* prototypes */
extern void shadeDispList(struct Base *base);
extern void shadeMeshMCol(struct Object *ob, struct Mesh *me);
+int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4);
void imagestodisplist(void);
void reshadeall_displist(void);
void filldisplist(struct ListBase *dispbase, struct ListBase *to);
/* **************** GLOBAL ********************* */
/* G.f */
-#define G_DISABLE_OK (1 << 0)
+#define G_RENDER_OGL (1 << 0)
#define G_PLAYANIM (1 << 1)
/* also uses G_FILE_AUTOPLAY */
-#define G_SIMULATION (1 << 3)
+#define G_RENDER_SHADOW (1 << 3)
#define G_BACKBUFSEL (1 << 4)
#define G_PICKSEL (1 << 5)
#define G_DRAWNORMALS (1 << 6)
#define FFMPEG_XVID 7
#define FFMPEG_FLV 8
#define FFMPEG_MKV 9
-
-#define FFMPEG_CODEC_MPEG1 0
-#define FFMPEG_CODEC_MPEG2 1
-#define FFMPEG_CODEC_MPEG4 2
-#define FFMPEG_CODEC_HUFFYUV 3
-#define FFMPEG_CODEC_DV 4
-#define FFMPEG_CODEC_H264 5
-#define FFMPEG_CODEC_XVID 6
-#define FFMPEG_CODEC_FLV1 7
+#define FFMPEG_OGG 10
#define FFMPEG_PRESET_NONE 0
#define FFMPEG_PRESET_DVD 1
if( (G.f & G_WEIGHTPAINT) && ob==obact ) {
MCol *wpcol = (MCol*)calc_weightpaint_colors(ob);
int layernum = CustomData_number_of_layers(&me->fdata, CD_MCOL);
+ int prevactive = CustomData_get_active_layer(&me->fdata, CD_MCOL);
+ int prevrender = CustomData_get_render_layer(&me->fdata, CD_MCOL);
/* ugly hack here, we temporarily add a new active mcol layer with
weightpaint colors in it, that is then duplicated in CDDM_from_mesh */
CustomData_add_layer(&me->fdata, CD_MCOL, CD_ASSIGN, wpcol, me->totface);
CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum);
+ CustomData_set_layer_render(&me->fdata, CD_MCOL, layernum);
mesh_calc_modifiers(ob, NULL, &ob->derivedDeform,
&ob->derivedFinal, 0, 1,
needMapping, dataMask, -1);
CustomData_free_layer_active(&me->fdata, CD_MCOL, me->totface);
+ CustomData_set_layer_active(&me->fdata, CD_MCOL, prevactive);
+ CustomData_set_layer_render(&me->fdata, CD_MCOL, prevrender);
} else {
mesh_calc_modifiers(ob, NULL, &ob->derivedDeform,
&ob->derivedFinal, G.rendering, 1,
bsb->kSHR = 1.0f;
bsb->kAHR = 0.7f;
+
bsb->collisionflags = 0;
//bsb->collisionflags = OB_BSB_COL_CL_RS + OB_BSB_COL_CL_SS;
bsb->numclusteriterations = 64;
if(len==0) return;
sum= (float *)MEM_callocN(sizeof(float)*len, "makeNurbcurve1");
- resolu= (resolu*SEGMENTSU(nu))+1;
+ resolu= (resolu*SEGMENTSU(nu));
+ if((nu->flagu & CU_CYCLIC)==0) resolu++;
+
if(resolu==0) {
MEM_freeN(sum);
return;
ustart= fp[nu->orderu-1];
if(nu->flagu & CU_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1];
else uend= fp[nu->pntsu];
- ustep= (uend-ustart)/(resolu-1);
+ ustep= (uend-ustart)/(resolu - ((nu->flagu & CU_CYCLIC) ? 0 : 1));
+
basisu= (float *)MEM_mallocN(sizeof(float)*KNOTSU(nu), "makeNurbcurve3");
if(nu->flagu & CU_CYCLIC) cycl= nu->orderu-1;
/* check if we will calculate tilt data */
do_tilt = ((nu->type & CU_2D) && (cu->flag & CU_3D)==0) ? 0 : 1;
- do_radius = do_tilt; /* normal display uses the radius, better just to calculate them */
+ do_radius = (do_tilt || cu->bevobj) ? 1 : 0; /* normal display uses the radius, better just to calculate them */
/* check we are a single point? also check we are not a surface and that the orderu is sane,
* enforced in the UI but can go wrong possibly */
}
else if((nu->type & 7)==CU_NURBS) {
if(nu->pntsv==1) {
- len= (resolu*SEGMENTSU(nu))+1;
+ len= (resolu*SEGMENTSU(nu));
+ if((nu->flagu & CU_CYCLIC)==0) len++;
+
bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList3");
BLI_addtail(&(cu->bev), bl);
bl->nr= len;
ndata= dl->nors;
for(a=0; a<dl->parts; a++) {
-
- DL_SURFINDEX(dl->flag & DL_CYCL_U, dl->flag & DL_CYCL_V, dl->nr, dl->parts);
+
+ if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0)
+ break;
v1= vdata+ 3*p1;
n1= ndata+ 3*p1;
}
}
+int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4)
+{
+ if((dl->flag & DL_CYCL_V)==0 && a==(dl->parts)-1) {
+ return 0;
+ }
+
+ if(dl->flag & DL_CYCL_U) {
+ (*p1)= dl->nr*a;
+ (*p2)= (*p1)+ dl->nr-1;
+ (*p3)= (*p1)+ dl->nr;
+ (*p4)= (*p2)+ dl->nr;
+ (*b)= 0;
+ } else {
+ (*p2)= dl->nr*a;
+ (*p1)= (*p2)+1;
+ (*p4)= (*p2)+ dl->nr;
+ (*p3)= (*p1)+ dl->nr;
+ (*b)= 1;
+ }
+
+ if( (dl->flag & DL_CYCL_V) && a==dl->parts-1) { \
+ (*p3)-= dl->nr*dl->parts; \
+ (*p4)-= dl->nr*dl->parts; \
+ }
+
+ return 1;
+}
/* ***************************** shade displist. note colors now are in rgb(a) order ******************** */
}
}
else if((nu->type & 7)==CU_NURBS) {
- len= (resolu*SEGMENTSU(nu))+1;
+ len= (resolu*SEGMENTSU(nu));
+ if((nu->flagu & CU_CYCLIC)==0) len++;
dl= MEM_callocN(sizeof(DispList), "makeDispListsurf");
dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts");
BLI_addtail(dispbase, dl);
dl->parts= 1;
+
dl->nr= len;
dl->col= nu->mat_nr;
dl->charidx = nu->charidx;
for (; md; md=md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
-
+
if ((md->mode & required_mode) != required_mode) continue;
if (mti->isDisabled && mti->isDisabled(md)) continue;
if (mti->type!=eModifierTypeType_OnlyDeform && mti->type!=eModifierTypeType_DeformOrConstruct) continue;
- for (dl=dispbase->first; dl; dl=dl->next) {
- mti->deformVerts(md, ob, NULL, (float(*)[3]) dl->verts, (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr);
+ /* need to put all verts in 1 block for curve deform */
+ if(md->type==eModifierType_Curve) {
+ float *allverts, *fp;
+ int totvert= 0;
+
+ for (dl=dispbase->first; dl; dl=dl->next)
+ totvert+= (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr;
+
+ fp= allverts= MEM_mallocN(totvert*sizeof(float)*3, "temp vert");
+ for (dl=dispbase->first; dl; dl=dl->next) {
+ int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr);
+ memcpy(fp, dl->verts, sizeof(float) * offs);
+ fp+= offs;
+ }
+
+ mti->deformVerts(md, ob, NULL, (float(*)[3]) allverts, totvert);
+
+ fp= allverts;
+ for (dl=dispbase->first; dl; dl=dl->next) {
+ int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr);
+ memcpy(dl->verts, fp, sizeof(float) * offs);
+ fp+= offs;
+ }
+ MEM_freeN(allverts);
+ }
+ else {
+ for (dl=dispbase->first; dl; dl=dl->next) {
+ mti->deformVerts(md, ob, NULL, (float(*)[3]) dl->verts, (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr);
+ }
}
}
for(a=0; a<dl->parts; a++) {
- DL_SURFINDEX(dl->flag & DL_CYCL_U, dl->flag & DL_CYCL_V, dl->nr, dl->parts);
+ if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0)
+ break;
for(; b<dl->nr; b++, index+=4) {
index[0]= p1;
}
for(a=0; a<dl->parts; a++) {
-
- DL_SURFINDEX(dl->flag & DL_CYCL_U, dl->flag & DL_CYCL_V, dl->nr, dl->parts);
+
+ if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0)
+ break;
+
p1+= startve;
p2+= startve;
p3+= startve;
if(!fss)
return;
- fss->type = 0;
+ fss->type = OB_FSBND_NOSLIP;
fss->show_advancedoptions = 0;
fss->resolutionxyz = 50;
newp->type = prop->type;
newp->flag = prop->flag;
newp->data.val = prop->data.val;
+ newp->data.val2 = prop->data.val2;
return newp;
}
return newp;
}
+/*
+ replaces a property with the same name in a group, or adds
+ it if the propery doesn't exist.
+*/
void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
{
IDProperty *loop;
BLI_remlink(&group->data.group, loop);
IDP_FreeProperty(loop);
- MEM_freeN(loop);
-
+ MEM_freeN(loop);
return;
}
}
}
group->len++;
-
+
BLI_insertlink(&group->data.group, previous, pnew);
return 1;
}
if (create_if_needed) {
id->properties = MEM_callocN(sizeof(IDProperty), "IDProperty");
id->properties->type = IDP_GROUP;
+ /* dont overwite the data's name and type
+ * some functions might need this if they
+ * dont have a real ID, should be named elsewhere - Campbell */
+ /* strcpy(id->name, "top_level_group");*/
}
return id->properties;
}
return prop;
}
-/*NOTE: this will free all child properties of list arrays and groups!
+/*NOTE: this will free all child properties including list arrays and groups!
Also, note that this does NOT unlink anything! Plus it doesn't free
the actual IDProperty struct either.*/
void IDP_FreeProperty(IDProperty *prop)
}
}
-/*Unlinks any IDProperty<->ID linkage that might be going on.*/
+/*Unlinks any IDProperty<->ID linkage that might be going on.
+ note: currently unused.*/
void IDP_UnlinkProperty(IDProperty *prop)
{
switch (prop->type) {
ibuf->channels= rpass->channels;
image_initialize_after_load(ima, ibuf);
- image_assign_ibuf(ima, ibuf, iuser->multi_index, frame);
+ image_assign_ibuf(ima, ibuf, iuser?iuser->multi_index:0, frame);
}
// else printf("pass not found\n");
}
else if(type==KEY_BSPLINE) {
- data[0]= -0.1666f*d3 +0.5f*d2 -0.5f*d +0.16666f;
- data[1]= 0.5f*d3 -d2 +0.6666f;
- data[2]= -0.5f*d3 +0.5f*d2 +0.5f*d +0.1666f;
- data[3]= 0.1666f*d3 ;
+ data[0]= -0.16666666f*d3 +0.5f*d2 -0.5f*d +0.16666666f;
+ data[1]= 0.5f*d3 -d2 +0.6666666f;
+ data[2]= -0.5f*d3 +0.5f*d2 +0.5f*d +0.16666666f;
+ data[3]= 0.16666666f*d3 ;
}
}
}
}
else if(type==KEY_BSPLINE) {
- data[0]= -0.1666f*3.0f*d2 +d -0.5f;
+ data[0]= -0.16666666f*3.0f*d2 +d -0.5f;
data[1]= 1.5f*d2 -2.0f*d;
data[2]= -1.5f*d2 +d +0.5f;
- data[3]= 0.1666f*3.0f*d2 ;
+ data[3]= 0.16666666f*3.0f*d2 ;
}
}
}
lb= wich_libbase(G.main, GS(id->name));
idn= alloc_libblock(lb, GS(id->name), id->name+2);
+ if(idn==NULL) {
+ printf("ERROR: Illegal ID name for %s (Crashing now)\n", id->name);
+ }
+
idn_len= MEM_allocN_len(idn);
if(idn_len - sizeof(ID) > 0) {
cp= (char *)id;
tsmd->keepDist = smd->keepDist;
tsmd->shrinkType= smd->shrinkType;
tsmd->shrinkOpts= smd->shrinkOpts;
+ tsmd->projAxis = smd->projAxis;
+ tsmd->subsurfLevels = smd->subsurfLevels;
}
CustomDataMask shrinkwrapModifier_requiredDataMask(ModifierData *md)
MultiApplyData data;
int i, j;
+ /* XXX added this to prevent crash, but if it works? (ton) */
+ if(me->mr->verts==NULL)
+ return;
+
/* Prepare deltas */
pr_deltas= MEM_callocN(sizeof(vec3f)*last_lvl->totvert, "multires deltas 1");
cr_deltas= MEM_callocN(sizeof(vec3f)*last_lvl->totvert, "multires deltas 2");
col.md = ( CollisionModifierData * ) ( modifiers_findByType ( ec->ob, eModifierType_Collision ) );
col.ob_t = ob;
- if(col.md->bvhtree)
+ if(col.md && col.md->bvhtree)
BLI_bvhtree_ray_cast(col.md->bvhtree, col.co1, ray_dir, radius, &hit, particle_intersect_face, &col);
}
}
}
pa->size=psys_get_size(ob,ma,psmd,icu_esize,psys,part,pa,vg_size);
- if(part->type==PART_REACTOR)
- initialize_particle(pa,p,ob,psys,psmd);
-
reset_particle(pa,psys,psmd,ob,dtime,cfra,vg_vel,vg_tan,vg_rot);
if(cfra>pa->time && part->flag & PART_LOOP && part->type!=PART_HAIR){
#include <unistd.h>
#endif
+#ifdef _WIN32
+#ifndef snprintf
+#define snprintf _snprintf
+#endif
+#endif
+
/* Creating ID's */
void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb)
- stack_index: index in the modifier stack. we can have cache for more then one stack_index
*/
+#define MAX_PTCACHE_PATH FILE_MAX
+#define MAX_PTCACHE_FILE ((FILE_MAXDIR+FILE_MAXFILE)*2)
+
static int ptcache_path(PTCacheID *pid, char *filename)
{
Library *lib;
lib= (pid)? pid->ob->id.lib: NULL;
if (G.relbase_valid || lib) {
- char file[FILE_MAX]; /* we dont want the dir, only the file */
+ char file[MAX_PTCACHE_PATH]; /* we dont want the dir, only the file */
char *blendfilename;
blendfilename= (lib)? lib->filename: G.sce;
if (i > 6)
file[i-6] = '\0';
- sprintf(filename, "//"PTCACHE_PATH"%s", file); /* add blend file name to pointcache dir */
+ snprintf(filename, MAX_PTCACHE_PATH, "//"PTCACHE_PATH"%s", file); /* add blend file name to pointcache dir */
BLI_convertstringcode(filename, blendfilename);
BLI_add_slash(filename);
return strlen(filename);
/* use the temp path. this is weak but better then not using point cache at all */
/* btempdir is assumed to exist and ALWAYS has a trailing slash */
- sprintf(filename, "%s"PTCACHE_PATH"%d", btempdir, abs(getpid()));
+ snprintf(filename, MAX_PTCACHE_PATH, "%s"PTCACHE_PATH"%d", btempdir, abs(getpid()));
BLI_add_slash(filename);
return strlen(filename);
}
idname = (pid->ob->id.name+2);
/* convert chars to hex so they are always a valid filename */
while('\0' != *idname) {
- sprintf(newname, "%02X", (char)(*idname++));
+ snprintf(newname, MAX_PTCACHE_FILE, "%02X", (char)(*idname++));
newname+=2;
len += 2;
}
if (do_ext) {
- sprintf(newname, "_%06d_%02d"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */
+ snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02d"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */
len += 16;
}
/* mode is same as fopen's modes */
DIR *dir;
struct dirent *de;
- char path[FILE_MAX];
- char filename[(FILE_MAXDIR+FILE_MAXFILE)*2];
- char path_full[(FILE_MAXDIR+FILE_MAXFILE)*2];
+ char path[MAX_PTCACHE_PATH];
+ char filename[MAX_PTCACHE_FILE];
+ char path_full[MAX_PTCACHE_FILE];
+ char ext[MAX_PTCACHE_PATH];
if(!pid->cache)
return;
dir = opendir(path);
if (dir==NULL)
return;
+
+ snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, pid->stack_index);
while ((de = readdir(dir)) != NULL) {
- if (strstr(de->d_name, PTCACHE_EXT)) { /* do we have the right extension?*/
+ if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */
if (mode == PTCACHE_CLEAR_ALL) {
BLI_join_dirfile(path_full, path, de->d_name);
/* read the number of the file */
int frame, len2 = strlen(de->d_name);
char num[7];
+
if (len2 > 15) { /* could crash if trying to copy a string out of this range*/
- strncpy(num, de->d_name + (strlen(de->d_name) - 15), 6);
+ BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num));
frame = atoi(num);
if((mode==PTCACHE_CLEAR_BEFORE && frame < cfra) ||
int BKE_ptcache_id_exist(PTCacheID *pid, int cfra)
{
- char filename[(FILE_MAXDIR+FILE_MAXFILE)*2];
+ char filename[MAX_PTCACHE_FILE];
if(!pid->cache)
return 0;
/* Use this when quitting blender, with unsaved files */
void BKE_ptcache_remove(void)
{
- char path[FILE_MAX];
- char path_full[FILE_MAX];
+ char path[MAX_PTCACHE_PATH];
+ char path_full[MAX_PTCACHE_PATH];
int rmdir = 1;
ptcache_path(NULL, path);
static const char * rv[] = { ".mkv", NULL };
return rv;
}
+ case FFMPEG_OGG: {
+ static const char * rv[] = { ".ogg", ".ogv", NULL };
+ return rv;
+ }
default:
return NULL;
}
AVPacket packet;
av_init_packet(&packet);
+ if (c->coded_frame->pts != AV_NOPTS_VALUE) {
#ifdef FFMPEG_CODEC_TIME_BASE
- packet.pts = av_rescale_q(c->coded_frame->pts,
- c->time_base,
- video_stream->time_base);
+ packet.pts = av_rescale_q(c->coded_frame->pts,
+ c->time_base,
+ video_stream->time_base);
#else
- packet.pts = c->coded_frame->pts;
+ packet.pts = c->coded_frame->pts;
#endif
- fprintf(stderr, "Video Frame PTS: %lld\n", packet.pts);
+ fprintf(stderr, "Video Frame PTS: %lld\n", packet.pts);
+ } else {
+ fprintf(stderr, "Video Frame PTS: not set\n");
+ }
if (c->coded_frame->key_frame)
packet.flags |= PKT_FLAG_KEY;
packet.stream_index = video_stream->index;
switch(ffmpeg_type) {
case FFMPEG_AVI:
case FFMPEG_MOV:
+ case FFMPEG_OGG:
+ case FFMPEG_MKV:
fmt->video_codec = ffmpeg_codec;
break;
case FFMPEG_DV:
/* if lib is NULL reset the last error code */
err= GetLastError();
- if (!lib) {
- SetLastError(ERROR_SUCCESS);
- err = ERROR_SUCCESS;
- }
+ if (!lib) SetLastError(ERROR_SUCCESS);
if (err) {
static char buf[1024];
return buf;
}
- return "unrecognized error";
+ return err;
}
void PIL_dynlib_close(PILdynlib *lib) {
int BLI_rename(char *from, char *to) {
if (!BLI_exists(from)) return 0;
- if (BLI_exists(to))
+ /* make sure the filenames are different (case insensitive) before removing */
+ if (BLI_exists(to) && BLI_strcasecmp(from, to))
if(BLI_delete(to, 0, 0)) return 1;
return rename(from, to);
*/
#ifdef WIN32
- if(dir[0]=='.') { /* happens for example in FILE_MAIN */
+
+ /* Note, this should really be moved to the file selector,
+ * since this function is used in many areas */
+ if(strcmp(dir, ".")==0) { /* happens for example in FILE_MAIN */
get_default_root(dir);
return;
}
* Add a / prefix and lowercase the driveletter, remove the :
* C:\foo.JPG -> /c/foo.JPG */
- if (tmp[1] == ':' && isalpha(tmp[0]) && (tmp[2]=='\\' || tmp[2]=='/') ) {
+ if (isalpha(tmp[0]) && tmp[1] == ':' && (tmp[2]=='\\' || tmp[2]=='/') ) {
tmp[1] = tolower(tmp[0]); /* replace ':' with driveletter */
tmp[0] = '/';
/* '\' the slash will be converted later */
la->sky_exposure= 1.0f;
}
}
+
+ /* BGE message actuators needed OB prefix, very confusing */
+ if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 10)) {
+ bActuator *act;
+ Object *ob;
-
-
+ for(ob = main->object.first; ob; ob= ob->id.next) {
+ for(act= ob->actuators.first; act; act= act->next) {
+ if (act->type == ACT_MESSAGE) {
+ bMessageActuator *msgAct = (bMessageActuator *) act->data;
+ if (strlen(msgAct->toPropName) > 2) {
+ /* strip first 2 chars, would have only worked if these were OB anyway */
+ strncpy(msgAct->toPropName, msgAct->toPropName+2, sizeof(msgAct->toPropName));
+ } else {
+ msgAct->toPropName[0] = '\0';
+ }
+ }
+ }
+ }
+ }
+
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
input->texid = GET_INT_FROM_POINTER(BLI_ghash_lookup(bindhash, input->ima));
}
else {
- /* input is user created texture, we know there there is
- only one, so assign new texid */
- input->bindtex = 1;
- input->texid = texid++;
+ if (!BLI_ghash_haskey(bindhash, input->tex)) {
+ /* input is user created texture, check tex pointer */
+ input->texid = texid++;
+ input->bindtex = 1;
+ BLI_ghash_insert(bindhash, input->tex, SET_INT_IN_POINTER(input->texid));
+ }
+ else
+ input->texid = GET_INT_FROM_POINTER(BLI_ghash_lookup(bindhash, input->tex));
}
/* make sure this pixel is defined exactly once */
if (input->ima)
input->tex = GPU_texture_from_blender(input->ima, input->iuser, time);
- if(input->ima || input->tex) {
- if(input->tex) {
- GPU_texture_bind(input->tex, input->texid);
- GPU_shader_uniform_texture(shader, input->shaderloc, input->tex);
- }
+ if(input->tex && input->bindtex) {
+ GPU_texture_bind(input->tex, input->texid);
+ GPU_shader_uniform_texture(shader, input->shaderloc, input->tex);
}
}
}
return;
for (input=inputs->first; input; input=input->next) {
- if (input->tex)
- if(input->bindtex)
- GPU_texture_unbind(input->tex);
+ if(input->tex && input->bindtex)
+ GPU_texture_unbind(input->tex);
+
if (input->ima)
input->tex = 0;
}
return GTS.domipmap && (!(G.f & G_TEXTUREPAINT));
}
-static GLenum gpu_get_mipmap_filter()
+static GLenum gpu_get_mipmap_filter(int mag)
{
- /* linearmipmap is off by default
- * when mipmapping is off, use unfiltered display */
- return GTS.linearmipmap? GL_LINEAR_MIPMAP_LINEAR :
- (GTS.domipmap ? GL_LINEAR_MIPMAP_NEAREST : GL_NEAREST);
+ /* linearmipmap is off by default *when mipmapping is off,
+ * use unfiltered display */
+ if(mag) {
+ if(GTS.linearmipmap || GTS.domipmap)
+ return GL_LINEAR;
+ else
+ return GL_NEAREST;
+ }
+ else {
+ if(GTS.linearmipmap)
+ return GL_LINEAR_MIPMAP_LINEAR;
+ else if(GTS.domipmap)
+ return GL_LINEAR_MIPMAP_NEAREST;
+ else
+ return GL_NEAREST;
+ }
}
/* Set OpenGL state for an MTFace */
else
GTS.tile= tftile;
+ GTS.tile = MAX2(0, GTS.tile);
+
if(ima) {
GTS.tileXRep = ima->xrep;
GTS.tileYRep = ima->yrep;
if (!gpu_get_mipmap()) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter());
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
}
else {
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter());
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter());
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
ima->tpageflag |= IMA_MIPMAP_COMPLETE;
}
if(ima->bindcode) {
if(ima->tpageflag & IMA_MIPMAP_COMPLETE) {
glBindTexture(GL_TEXTURE_2D, ima->bindcode);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter());
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter());
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0));
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
}
else
GPU_free_image(ima);
if(ima->bindcode) {
glBindTexture(GL_TEXTURE_2D, ima->bindcode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter());
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1));
}
}
}
if(la->type==LA_SUN) {
/* sun lamp */
- VECCOPY(position, base->object->obmat[2]);
+ VECCOPY(direction, base->object->obmat[2]);
direction[3]= 0.0;
glLightfv(GL_LIGHT0+count, GL_POSITION, direction);
shr->spec, &shr->spec);
add_user_list(&mat->lamps, lamp);
- add_user_list(&lamp->materials, ma);
+ add_user_list(&lamp->materials, shi->gpumat->ma);
return;
}
}
else if((G.fileflags & G_FILE_GLSL_NO_SHADOWS) && (lamp->mode & LA_ONLYSHADOW)) {
add_user_list(&mat->lamps, lamp);
- add_user_list(&lamp->materials, ma);
+ add_user_list(&lamp->materials, shi->gpumat->ma);
return;
}
else
}
add_user_list(&mat->lamps, lamp);
- add_user_list(&lamp->materials, ma);
+ add_user_list(&lamp->materials, shi->gpumat->ma);
}
static void material_lights(GPUShadeInput *shi, GPUShadeResult *shr)
else if(mtex->texco==TEXCO_OBJECT)
texco= texco_object;
else if(mtex->texco==TEXCO_NORM)
- texco= texco_norm;
+ texco= orn;
else if(mtex->texco==TEXCO_TANGENT)
texco= texco_object;
else if(mtex->texco==TEXCO_GLOB)
if((G.fileflags & G_FILE_GLSL_NO_LIGHTS) || (ma->mode & MA_SHLESS)) {
shr->combined = shi->rgb;
shr->alpha = shi->alpha;
+ GPU_link(mat, "set_rgb", shi->rgb, &shr->diff);
+ GPU_link(mat, "set_rgb_zero", &shr->spec);
}
else {
if(GPU_link_changed(shi->emit) || ma->emit != 0.0f) {
static void cineon_conversion_parameters(LogImageByteConversionParameters *params)
{
- params->blackPoint = G.scene->r.cineonblack;
- params->whitePoint = G.scene->r.cineonwhite;
- params->gamma = G.scene->r.cineongamma;
- params->doLogarithm = G.scene->r.subimtype & R_CINEON_LOG;
+ params->blackPoint = G.scene?G.scene->r.cineonblack:95;
+ params->whitePoint = G.scene?G.scene->r.cineonwhite:685;
+ params->gamma = G.scene?G.scene->r.cineongamma:1.7f;
+ params->doLogarithm = G.scene?G.scene->r.subimtype & R_CINEON_LOG:0;
}
static struct ImBuf *imb_load_dpx_cineon(unsigned char *mem, int use_cineon, int size, int flags)
cineon->file = 0;
cineon->reading = 1;
- verbose = 1;
+ verbose = 0;
if (size < sizeof(CineonGenericHeader)) {
if (verbose) d_printf("Not enough data for header!\n");
cineonClose(cineon);
#endif
}
-static int verbose = 1;
+static int verbose = 0;
void
dpxSetVerbose(int verbosity) {
verbose = verbosity;
assert(libtiff != NULL);
symbol = PIL_dynlib_find_symbol(libtiff, name);
if (symbol == NULL) {
- printf("libtiff_findsymbol: error %s\n",
- PIL_dynlib_get_error_as_string(libtiff));
+ char *err = PIL_dynlib_get_error_as_string(libtiff);
+
+ if (err) printf("libtiff_findsymbol: error %s\n",err);
+ else printf("libtiff_findsymbol: error Unknown.\n");
+
libtiff = NULL;
G.have_libtiff = (0);
return NULL;
void make_links_menu(void);
void make_links(short event);
void make_duplilist_real(void);
+void make_object_duplilist_real(struct Base *base);
void apply_objects_locrot(void);
void apply_objects_scale(void);
void apply_objects_rot(void);
/**
- * $Id: BDR_gpencil.h 14444 2008-04-16 22:40:48Z aligorith $
+ * $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
struct bGPDlayer *gpencil_layer_addnew(struct bGPdata *gpd);
struct bGPdata *gpencil_data_addnew(void);
+struct bGPDframe *gpencil_frame_duplicate(struct bGPDframe *src);
+struct bGPDlayer *gpencil_layer_duplicate(struct bGPDlayer *src);
struct bGPdata *gpencil_data_duplicate(struct bGPdata *gpd);
struct bGPdata *gpencil_data_getactive(struct ScrArea *sa);
short gpencil_data_setactive(struct ScrArea *sa, struct bGPdata *gpd);
+struct ScrArea *gpencil_data_findowner(struct bGPdata *gpd);
void gpencil_frame_delete_laststroke(struct bGPDframe *gpf);
void gpencil_convert_operation(short mode);
void gpencil_convert_menu(void);
-//short gpencil_paint(short mousebutton);
short gpencil_do_paint(struct ScrArea *sa, short mousebutton);
#endif /* BDR_GPENCIL_H */
/**
- * $Id: BIF_drawgpencil.h 14444 2008-04-16 22:40:48Z aligorith $
+ * $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
void delete_gplayer_frames(struct bGPDlayer *gpl);
void duplicate_gplayer_frames(struct bGPDlayer *gpd);
+void free_gpcopybuf(void);
+void copy_gpdata(void);
+void paste_gpdata(void);
+
void snap_gplayer_frames(struct bGPDlayer *gpl, short mode);
void mirror_gplayer_frames(struct bGPDlayer *gpl, short mode);
/**
- * $Id: BIF_keyframing.h 14444 2008-04-16 22:40:48Z aligorith $
+ * $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
/* -------- */
/* Main Keyframing API calls:
- * Use this to create any necessary animation data,, and then insert a keyframe
+ * Use this to create any necessary animation data, and then insert a keyframe
* using the current value being keyframed, in the relevant place. Returns success.
*/
// TODO: adapt this for new data-api -> this blocktype, etc. stuff is evil!
/* ************ Keyframe Checking ******************** */
-/* Checks whether a keyframe exists for the given ID-block one the given frame */
-short id_cfra_has_keyframe(struct ID *id, short filter);
+/* Main Keyframe Checking API call:
+ * Checks whether a keyframe exists for the given ID-block one the given frame.
+ * - It is recommended to call this method over the other keyframe-checkers directly,
+ * in case some detail of the implementation changes...
+ * - frame: the value of this is quite often result of frame_to_float(CFRA)
+ */
+short id_frame_has_keyframe(struct ID *id, float frame, short filter);
-/* filter flags fr id_cfra_has_keyframe */
+/* filter flags for id_cfra_has_keyframe
+ *
+ * WARNING: do not alter order of these, as also stored in files
+ * (for v3d->keyflags)
+ */
enum {
/* general */
- ANIMFILTER_ALL = 0, /* include all available animation data */
ANIMFILTER_LOCAL = (1<<0), /* only include locally available anim data */
+ ANIMFILTER_MUTED = (1<<1), /* include muted elements */
+ ANIMFILTER_ACTIVE = (1<<2), /* only include active-subelements */
/* object specific */
- ANIMFILTER_MAT = (1<<1), /* include material keyframes too */
- ANIMFILTER_SKEY = (1<<2), /* shape keys (for geometry) */
+ ANIMFILTER_NOMAT = (1<<9), /* don't include material keyframes */
+ ANIMFILTER_NOSKEY = (1<<10), /* don't include shape keys (for geometry) */
} eAnimFilterFlags;
#endif /* BIF_KEYFRAMING_H */
#ifndef BSE_SEQAUDIO_H
#define BSE_SEQAUDIO_H
+#ifndef DISABLE_SDL
#include "SDL.h"
+#endif
+
/* muha, we don't init (no SDL_main)! */
#ifdef main
# undef main
#endif
#include "DNA_sound_types.h"
+#include "BLO_sys_types.h"
void audio_mixdown();
void audio_makestream(bSound *sound);
-void audiostream_play(Uint32 startframe, Uint32 duration, int mixdown);
-void audiostream_fill(Uint8* mixdown, int len);
-void audiostream_start(Uint32 frame);
-void audiostream_scrub(Uint32 frame);
+void audiostream_play(uint32_t startframe, uint32_t duration, int mixdown);
+void audiostream_fill(uint8_t* mixdown, int len);
+void audiostream_start(uint32_t frame);
+void audiostream_scrub(uint32_t frame);
void audiostream_stop(void);
int audiostream_pos(void);
short flag, type;
int sta, end;
char name[32];
+ char frameProp[32]; /* Set this property to the actions current frame */
short pad1, cur, butsta, butend;
#define ACT_CONST_PERMANENT 256
#define ACT_CONST_DISTANCE 512
#define ACT_CONST_LOCAL 1024
+#define ACT_CONST_DOROTFH 2048
/* constraint mode */
#define ACT_CONST_DIRPX 1
#define ACT_CONST_TYPE_LOC 0
#define ACT_CONST_TYPE_DIST 1
#define ACT_CONST_TYPE_ORI 2
+#define ACT_CONST_TYPE_FH 3
/* editObjectActuator->type */
#define ACT_EDOB_ADD_OBJECT 0
/* Rigid-Body Constraint */
#define CONSTRAINT_DRAW_PIVOT 0x40
+#define CONSTRAINT_DISABLE_LINKED_COLLISION 0x80
/* important: these defines need to match up with PHY_DynamicTypes headerfile */
#define CONSTRAINT_RB_BALL 1
/**
- * $Id: DNA_gpencil_types.h 8768 2006-11-07 00:10:37Z aligorith $
+ * $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
#define OB_FLUIDSIM_PARTICLE 64
#define OB_FLUIDSIM_CONTROL 128
-#define OB_TYPEFLAG_START 0
+#define OB_TYPEFLAG_START 7
#define OB_FSGEO_THIN (1<<(OB_TYPEFLAG_START+1))
#define OB_FSBND_NOSLIP (1<<(OB_TYPEFLAG_START+2))
#define OB_FSBND_PARTSLIP (1<<(OB_TYPEFLAG_START+3))
typedef struct bJoystickSensor {
char name[32];
- short type;
- short joyindex;
+ char type;
+ char joyindex;
+ short flag;
int axis;
int axisf;
int button;
- int buttonf;
int hat;
int hatf;
int precision;
#define BL_SENS_MOUSE_MOUSEOVER 16
#define BL_SENS_MOUSE_MOUSEOVER_ANY 32
+#define SENS_JOY_ANY_EVENT 1
+
#define SENS_JOY_BUTTON 0
#define SENS_JOY_BUTTON_PRESSED 0
#define SENS_JOY_BUTTON_RELEASED 1
#define SENS_JOY_HAT 2
#define SENS_JOY_HAT_DIR 0
+
#define SENS_DELAY_REPEAT 1
// should match JOYINDEX_MAX in SCA_JoystickDefines.h */
#define SENS_JOY_MAXINDEX 8
struct ListBase themes;
short undosteps;
short undomemory;
- short gp_manhattendist, gp_euclideandist, pad;
- short curssize;
+ short gp_manhattendist, gp_euclideandist, gp_eraser;
+ short gp_settings;
short tb_leftmouse, tb_rightmouse;
struct SolidLight light[3];
short tw_hotspot, tw_flag, tw_handlesize, tw_size;
short smooth_viewtx; /* miliseconds to spend spinning the view */
short glreslimit;
short ndof_pan, ndof_rotate;
- short pads[2];
+ short curssize, pad;
// char pad[8];
char versemaster[160];
char verseuser[160];
/* tw_flag (transform widget) */
+/* gp_settings (Grease Pencil Settings) */
+#define GP_PAINT_DOSMOOTH (1<<0)
+#define GP_PAINT_DOSIMPLIFY (1<<1)
+
#endif
short gridsubdiv; /* Number of subdivisions in the grid between each highlighted grid line */
- short pad3;
+ short keyflags; /* flags for display of keyframes */
char ndofmode; /* mode of transform for 6DOF devices -1 not found, 0 normal, 1 fly, 2 ob transform */
char ndoffilter; /*filter for 6DOF devices 0 normal, 1 dominant */
PyObject *bpy_pydriver_Dict = NULL;
PyObject *bpy_orig_syspath_List = NULL;
+
/*
* set up a weakref list for Armatures
* creates list in __main__ module dict
//stuff for Registry module
bpy_registryDict = PyDict_New( );/* check comment at start of this file */
if( !bpy_registryDict )
- printf( "Error: Couldn't create the Registry Python Dictionary!" );
+ printf( "Warning: Couldn't create the Registry Python Dictionary!" );
Py_SetProgramName( "blender" );
/* Py_Initialize() will attempt to import the site module and
//Start the interpreter
Py_Initialize( );
+
PySys_SetArgv( argc_copy, argv_copy );
-
/* Initialize thread support (also acquires lock) */
PyEval_InitThreads();
-
+
//Overrides __import__
init_ourImport( );
init_ourReload( );
//Look for a python installation
init_syspath( first_time ); /* not first_time: some msgs are suppressed */
-
py_tstate = PyGILState_GetThisThreadState();
PyEval_ReleaseThread(py_tstate);
{
PyObject *mod_sys= NULL, *dict= NULL, *path= NULL, *dir= NULL;
short ok=1;
- PyErr_Clear( );
-
- dir = PyString_FromString( dirname );
mod_sys = PyImport_ImportModule( "sys" ); /* new ref */
}
} else {
/* cant get the sys module */
+ /* PyErr_Clear(); is called below */
ok = 0;
}
- if (PySequence_Contains(path, dir)==0) { /* Only add if we need to */
- if (ok && PyList_Append( path, dir ) != 0) /* decref below */
- ok = 0; /* append failed */
+ dir = PyString_FromString( dirname );
- if( (ok==0) || PyErr_Occurred( ) )
- Py_FatalError( "could import or build sys.path, can't continue" );
+ if (ok && PySequence_Contains(path, dir)==0) { /* Only add if we need to */
+ if (PyList_Append( path, dir ) != 0) /* decref below */
+ ok = 0; /* append failed */
}
+
+ if( (ok==0) || PyErr_Occurred( ) )
+ fprintf(stderr, "Warning: could import or build sys.path\n" );
+
+ PyErr_Clear();
Py_DECREF( dir );
Py_XDECREF( mod_sys );
}
d = PyModule_GetDict( mod );
EXPP_dict_set_item_str( d, "progname", PyString_FromString( bprogname ) );
Py_DECREF( mod );
- } else
- printf( "Warning: could not set Blender.sys.progname\n" );
+ } else {
+ printf( "Warning: could not set Blender.sys\n" );
+ PyErr_Clear();
+ }
progname = BLI_last_slash( bprogname ); /* looks for the last dir separator */
Py_DECREF( mod );
} else{
- printf("import of sys module failed\n");
+ PyErr_Clear( );
+ printf("Warning: import of sys module failed\n");
}
}
mod = PyImport_ImportModule( "sys" );
if (!mod) {
- printf("error: could not import python sys module. some modules may not import.\n");
+ printf("Warning: could not import python sys module. some modules may not import.\n");
+ PyErr_Clear( );
PyGILState_Release(gilstate);
return;
}
if (!bpy_orig_syspath_List) { /* should never happen */
- printf("error refershing python path\n");
+ printf("Warning: cant refresh python path, bpy_orig_syspath_List is NULL\n");
Py_DECREF(mod);
PyGILState_Release(gilstate);
return;
PyDict_SetItemString(d, "Blender", mod);
PyDict_SetItemString(d, "b", mod);
Py_DECREF(mod);
+ } else {
+ PyErr_Clear();
}
mod = PyImport_ImportModule("math");