mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-18 05:11:42 +00:00
Merge with develop
--HG-- branch : compatibility
This commit is contained in:
commit
eb05c962de
233 changed files with 1910 additions and 2672 deletions
|
@ -69,14 +69,48 @@ FIND_PATH(LUABIND_INCLUDE_DIR
|
|||
/opt/include
|
||||
)
|
||||
|
||||
SET(LIBRARY_NAME_RELEASE luabind libluabind)
|
||||
SET(LIBRARY_NAME_DEBUG luabind_d luabindd libluabind_d libluabindd)
|
||||
SET(LIBRARY_NAME_RELEASE)
|
||||
SET(LIBRARY_NAME_DEBUG)
|
||||
|
||||
IF(WITH_LUA52)
|
||||
IF(WITH_STLPORT)
|
||||
LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua52)
|
||||
LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua52d)
|
||||
ENDIF(WITH_STLPORT)
|
||||
|
||||
LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua52)
|
||||
LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua52d)
|
||||
ENDIF()
|
||||
|
||||
IF(WITH_LUA51)
|
||||
IF(WITH_STLPORT)
|
||||
LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua51)
|
||||
LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua51d)
|
||||
ENDIF(WITH_STLPORT)
|
||||
|
||||
LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua51)
|
||||
LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua51d)
|
||||
ENDIF()
|
||||
|
||||
IF(WITH_LUA50)
|
||||
IF(WITH_STLPORT)
|
||||
LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua50)
|
||||
LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua50d)
|
||||
ENDIF(WITH_STLPORT)
|
||||
|
||||
LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua50)
|
||||
LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua50d)
|
||||
ENDIF()
|
||||
|
||||
IF(WITH_STLPORT)
|
||||
SET(LIBRARY_NAME_RELEASE luabind_stlport ${LIBRARY_NAME_RELEASE})
|
||||
SET(LIBRARY_NAME_DEBUG luabind_stlportd ${LIBRARY_NAME_DEBUG})
|
||||
LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport)
|
||||
LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlportd)
|
||||
ENDIF(WITH_STLPORT)
|
||||
|
||||
# generic libraries names
|
||||
LIST(APPEND LIBRARY_NAME_RELEASE luabind libluabind)
|
||||
LIST(APPEND LIBRARY_NAME_DEBUG luabind_d luabindd libluabind_d libluabindd)
|
||||
|
||||
FIND_LIBRARY(LUABIND_LIBRARY_RELEASE
|
||||
NAMES ${LIBRARY_NAME_RELEASE}
|
||||
PATHS
|
||||
|
|
|
@ -363,6 +363,7 @@ MACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS)
|
|||
###
|
||||
OPTION(WITH_LUA51 "Build Ryzom Core using Lua 5.1" ON )
|
||||
OPTION(WITH_LUA52 "Build Ryzom Core using Lua 5.2" OFF)
|
||||
OPTION(WITH_RYZOM_CLIENT_UAC "Ask to run as Administrator" OFF)
|
||||
ENDMACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS)
|
||||
|
||||
MACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS)
|
||||
|
|
|
@ -493,7 +493,7 @@ public:
|
|||
*
|
||||
* NB: you must setupViewMatrix() BEFORE setupModelMatrix(), or else undefined results.
|
||||
*/
|
||||
virtual void setupViewMatrix(const CMatrix &mtx)=0;
|
||||
virtual void setupViewMatrix(const CMatrix &mtx) = 0;
|
||||
|
||||
/** setup the view matrix (inverse of camera matrix).
|
||||
* Extended: give a cameraPos (mtx.Pos() is not taken into account but for getViewMatrix()),
|
||||
|
@ -1422,7 +1422,6 @@ protected:
|
|||
|
||||
private:
|
||||
bool _StaticMemoryToVRAM;
|
||||
|
||||
};
|
||||
|
||||
// --------------------------------------------------
|
||||
|
|
|
@ -50,6 +50,8 @@ namespace NLGUI
|
|||
// see interface.txt for meaning of auto
|
||||
_ToolTipParentPosRef= Hotspot_TTAuto;
|
||||
_ToolTipPosRef= Hotspot_TTAuto;
|
||||
_EventX = 0;
|
||||
_EventY = 0;
|
||||
resizer = false;
|
||||
}
|
||||
|
||||
|
@ -70,6 +72,9 @@ namespace NLGUI
|
|||
|
||||
bool handleEvent (const NLGUI::CEventDescriptor &event);
|
||||
|
||||
sint32 getEventX() { return _EventX; }
|
||||
sint32 getEventY() { return _EventY; }
|
||||
|
||||
virtual CCtrlBase *getSubCtrl (sint32 /* x */, sint32 /* y */) { return this; }
|
||||
|
||||
/// Debug
|
||||
|
@ -181,6 +186,9 @@ namespace NLGUI
|
|||
static std::map< std::string, std::map< std::string, std::string > > AHCache;
|
||||
|
||||
bool resizer;
|
||||
|
||||
sint32 _EventX;
|
||||
sint32 _EventY;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace NLGUI
|
|||
void refresh();
|
||||
|
||||
// submit form
|
||||
void submitForm (uint formId, const char *submitButtonName);
|
||||
void submitForm (uint formId, const char *submitButtonType, const char *submitButtonName, const char *submitButtonValue, sint32 x, sint32 y);
|
||||
|
||||
// Browse error
|
||||
void browseError (const char *msg);
|
||||
|
@ -328,7 +328,11 @@ namespace NLGUI
|
|||
bool _BrowseNextTime;
|
||||
bool _PostNextTime;
|
||||
uint _PostFormId;
|
||||
std::string _PostFormSubmitType;
|
||||
std::string _PostFormSubmitButton;
|
||||
std::string _PostFormSubmitValue;
|
||||
sint32 _PostFormSubmitX;
|
||||
sint32 _PostFormSubmitY;
|
||||
|
||||
// Browsing..
|
||||
bool _Browsing;
|
||||
|
|
|
@ -39,9 +39,9 @@ class CPThread : public IThread
|
|||
public:
|
||||
enum TThreadState
|
||||
{
|
||||
ThreadStateNone,
|
||||
ThreadStateRunning,
|
||||
ThreadStateFinished,
|
||||
ThreadStateNone,
|
||||
ThreadStateRunning,
|
||||
ThreadStateFinished,
|
||||
};
|
||||
|
||||
/// Constructor
|
||||
|
|
|
@ -343,7 +343,7 @@ public:
|
|||
/** Adds a search path.
|
||||
* The path is a directory "c:/temp" all files in the directory will be included (and recursively if asked)
|
||||
*
|
||||
* Alternative directories are not pre-cached (instead of non Alternative files) and will used when a file is not found in the standard directories.
|
||||
* Alternative directories are not pre-cached (instead of non Alternative files) and will be used when a file is not found in the standard directories.
|
||||
* For example, local data will be in the cached directories and server repository files will be in the Alternative files. If a new file is not
|
||||
* found in the local data, we'll try to find it on the repository.
|
||||
*
|
||||
|
|
|
@ -218,13 +218,13 @@ public:
|
|||
static bool isServiceInitialized() { return _Instance != NULL; }
|
||||
|
||||
/// Returns the current service short name (ie: TS)
|
||||
const std::string &getServiceShortName () const { return _ShortName; };
|
||||
const std::string &getServiceShortName () const { return _ShortName; }
|
||||
|
||||
/// Returns the current service long name (ie: test_serivce)
|
||||
const std::string &getServiceLongName () const { return _LongName; };
|
||||
const std::string &getServiceLongName () const { return _LongName; }
|
||||
|
||||
/// Returns the current service alias name setted by AES
|
||||
const std::string &getServiceAliasName () const { return _AliasName; };
|
||||
const std::string &getServiceAliasName () const { return _AliasName; }
|
||||
|
||||
/// Returns the current service unified name that is alias/short-id or short-id if alias is empty
|
||||
std::string getServiceUnifiedName () const;
|
||||
|
@ -242,10 +242,10 @@ public:
|
|||
uint32 getLaunchingDate () const;
|
||||
|
||||
/// Return true if this service don't use the NS (naming service)
|
||||
bool getDontUseNS() const { return _DontUseNS; };
|
||||
bool getDontUseNS() const { return _DontUseNS; }
|
||||
|
||||
/// Return true if this service don't use the AES (admin executor service)
|
||||
bool getDontUseAES() const { return _DontUseAES; };
|
||||
bool getDontUseAES() const { return _DontUseAES; }
|
||||
|
||||
/// Returns arguments of the program pass from the user to the program using parameters (ie: "myprog param1 param2")
|
||||
const NLMISC::CVectorSString &getArgs () const { return _Args; }
|
||||
|
|
|
@ -543,14 +543,14 @@ ColorPickerPopup::ColorPickerPopup(int width, bool withColorDialog,
|
|||
setMouseTracking(true);
|
||||
cols = width;
|
||||
|
||||
if (withColorDialog)
|
||||
if (withColorDialog)
|
||||
{
|
||||
moreButton = new ColorPickerButton(this);
|
||||
moreButton->setFixedWidth(24);
|
||||
moreButton->setFixedHeight(21);
|
||||
moreButton->setFrameRect(QRect(2, 2, 20, 17));
|
||||
connect(moreButton, SIGNAL(clicked()), SLOT(getColorFromDialog()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
moreButton = 0;
|
||||
|
|
|
@ -1509,9 +1509,6 @@ bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool r
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// _D3D->CreateDevice (adapter, _Rasterizer, _HWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, ¶meters, &_DeviceInterface);
|
||||
|
||||
// Check some caps
|
||||
D3DCAPS9 caps;
|
||||
if (_DeviceInterface->GetDeviceCaps(&caps) == D3D_OK)
|
||||
|
|
|
@ -435,11 +435,7 @@ bool CDriverGL::setupDisplay()
|
|||
glViewport(0,0,_CurrentMode.Width,_CurrentMode.Height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
#ifdef USE_OPENGLES
|
||||
glOrthof(0.f,_CurrentMode.Width,_CurrentMode.Height,0.f,-1.0f,1.0f);
|
||||
#else
|
||||
glOrtho(0,_CurrentMode.Width,_CurrentMode.Height,0,-1.0f,1.0f);
|
||||
#endif
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
#ifndef USE_OPENGLES
|
||||
|
@ -725,11 +721,7 @@ bool CDriverGL::activeFrameBufferObject(ITexture * tex)
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
|
||||
#else
|
||||
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2178,7 +2170,7 @@ void CDriverGL::flush()
|
|||
// ***************************************************************************
|
||||
void CDriverGL::setSwapVBLInterval(uint interval)
|
||||
{
|
||||
H_AUTO_OGL(CDriverGL_setSwapVBLInterval)
|
||||
H_AUTO_OGL(CDriverGL_setSwapVBLInterval);
|
||||
|
||||
if (!_Initialized)
|
||||
return;
|
||||
|
|
|
@ -40,6 +40,24 @@ extern "C" {
|
|||
#define GL_ADD_SIGNED_EXT GL_ADD_SIGNED
|
||||
#define GL_INTERPOLATE_EXT GL_INTERPOLATE
|
||||
#define GL_BUMP_ENVMAP_ATI GL_INTERPOLATE
|
||||
#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER_OES
|
||||
#define GL_RENDERBUFFER_EXT GL_RENDERBUFFER_OES
|
||||
#define GL_DEPTH24_STENCIL8_EXT GL_DEPTH24_STENCIL8_OES
|
||||
#define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES
|
||||
#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0_OES
|
||||
#define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT_OES
|
||||
#define GL_STENCIL_ATTACHMENT_EXT GL_STENCIL_ATTACHMENT_OES
|
||||
#define GL_ARRAY_BUFFER_ARB GL_ARRAY_BUFFER
|
||||
#define GL_TEXTURE0_ARB GL_TEXTURE0
|
||||
|
||||
#define GL_ALPHA8 GL_ALPHA
|
||||
#define GL_LUMINANCE8_ALPHA8 GL_LUMINANCE_ALPHA
|
||||
#define GL_LUMINANCE8 GL_LUMINANCE
|
||||
#define GL_RGBA8 GL_RGBA
|
||||
#define GL_RGB8 GL_RGB
|
||||
|
||||
#define GL_STATIC_DRAW_ARB GL_STATIC_DRAW
|
||||
#define GL_DYNAMIC_DRAW_ARB GL_DYNAMIC_DRAW
|
||||
|
||||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES
|
||||
|
@ -48,6 +66,31 @@ extern "C" {
|
|||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES
|
||||
|
||||
#define nglGenRenderbuffersEXT nglGenRenderbuffersOES
|
||||
#define nglBindRenderbufferEXT nglBindRenderbufferOES
|
||||
#define nglDeleteRenderbuffersEXT nglDeleteRenderbuffersOES
|
||||
#define nglRenderbufferStorageEXT nglRenderbufferStorageOES
|
||||
#define nglGenFramebuffersEXT nglGenFramebuffersOES
|
||||
#define nglBindFramebufferEXT nglBindFramebufferOES
|
||||
#define nglFramebufferTexture2DEXT nglFramebufferTexture2DOES
|
||||
#define nglFramebufferRenderbufferEXT nglFramebufferRenderbufferOES
|
||||
#define nglCheckFramebufferStatusEXT nglCheckFramebufferStatusOES
|
||||
#define nglDeleteBuffersARB glDeleteBuffers
|
||||
#define nglIsBufferARB glIsBuffer
|
||||
#define nglDeleteRenderbuffersEXT nglDeleteRenderbuffersOES
|
||||
#define nglBindFramebufferEXT nglBindFramebufferOES
|
||||
#define nglDeleteFramebuffersEXT nglDeleteFramebuffersOES
|
||||
#define nglUnmapBufferARB nglUnmapBufferOES
|
||||
#define nglActiveTextureARB glActiveTexture
|
||||
#define nglClientActiveTextureARB glClientActiveTexture
|
||||
#define nglBindBufferARB glBindBuffer
|
||||
#define nglGenBuffersARB glGenBuffers
|
||||
#define nglBufferDataARB glBufferData
|
||||
|
||||
#define glFrustum glFrustumf
|
||||
#define glOrtho glOrthof
|
||||
#define glDepthRange glDepthRangef
|
||||
|
||||
#else
|
||||
|
||||
#if defined(NL_OS_MAC)
|
||||
|
|
|
@ -403,7 +403,7 @@ bool CDriverGL::setupMaterial(CMaterial& mat)
|
|||
// Must setup textures each frame. (need to test if touched).
|
||||
// Must separate texture setup and texture activation in 2 "for"...
|
||||
// because setupTexture() may disable all stage.
|
||||
if (matShader != CMaterial::Water
|
||||
if (matShader != CMaterial::Water
|
||||
&& ((matShader != CMaterial::Program) || (_LastSetuppedPP->features().MaterialFlags & CProgramFeatures::TextureStages))
|
||||
)
|
||||
{
|
||||
|
|
|
@ -37,19 +37,11 @@ void CDriverGL::setFrustum(float left, float right, float bottom, float top, flo
|
|||
|
||||
if (perspective)
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
glFrustumf(left,right,bottom,top,znear,zfar);
|
||||
#else
|
||||
glFrustum(left,right,bottom,top,znear,zfar);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
glOrthof(left,right,bottom,top,znear,zfar);
|
||||
#else
|
||||
glOrtho(left,right,bottom,top,znear,zfar);
|
||||
#endif
|
||||
}
|
||||
|
||||
_ProjMatDirty = true;
|
||||
|
|
|
@ -155,11 +155,7 @@ void CDriverGLStates::forceDefaults(uint nbStages)
|
|||
for(stage=0;stage<nbStages; stage++)
|
||||
{
|
||||
// disable texturing.
|
||||
#ifdef USE_OPENGLES
|
||||
glActiveTexture(GL_TEXTURE0+stage);
|
||||
#else
|
||||
nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
|
||||
#endif
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
|
@ -188,13 +184,8 @@ void CDriverGLStates::forceDefaults(uint nbStages)
|
|||
}
|
||||
|
||||
// ActiveTexture current texture to 0.
|
||||
#ifdef USE_OPENGLES
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
#else
|
||||
nglActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
nglClientActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
#endif
|
||||
|
||||
_CurrentActiveTextureARB= 0;
|
||||
_CurrentClientActiveTextureARB= 0;
|
||||
|
@ -622,11 +613,7 @@ void CDriverGLStates::updateDepthRange()
|
|||
|
||||
float delta = _ZBias * (_DepthRangeFar - _DepthRangeNear);
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
glDepthRangef(delta + _DepthRangeNear, delta + _DepthRangeFar);
|
||||
#else
|
||||
glDepthRange(delta + _DepthRangeNear, delta + _DepthRangeFar);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
@ -767,7 +754,7 @@ void CDriverGLStates::setTextureMode(TTextureMode texMode)
|
|||
{
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
else if(oldTexMode == TextureRect)
|
||||
else if (oldTexMode == TextureRect)
|
||||
{
|
||||
#ifndef USE_OPENGLES
|
||||
if(_TextureRectangleSupported)
|
||||
|
@ -780,7 +767,7 @@ void CDriverGLStates::setTextureMode(TTextureMode texMode)
|
|||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
else if(oldTexMode == TextureCubeMap)
|
||||
else if (oldTexMode == TextureCubeMap)
|
||||
{
|
||||
if(_TextureCubeMapSupported)
|
||||
{
|
||||
|
@ -835,11 +822,7 @@ void CDriverGLStates::activeTextureARB(uint stage)
|
|||
|
||||
if( _CurrentActiveTextureARB != stage )
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
glActiveTexture(GL_TEXTURE0+stage);
|
||||
#else
|
||||
nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
|
||||
#endif
|
||||
|
||||
_CurrentActiveTextureARB= stage;
|
||||
}
|
||||
|
@ -850,11 +833,7 @@ void CDriverGLStates::forceActiveTextureARB(uint stage)
|
|||
{
|
||||
H_AUTO_OGL(CDriverGLStates_forceActiveTextureARB);
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
glActiveTexture(GL_TEXTURE0+stage);
|
||||
#else
|
||||
nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
|
||||
#endif
|
||||
|
||||
_CurrentActiveTextureARB= stage;
|
||||
}
|
||||
|
@ -958,11 +937,7 @@ void CDriverGLStates::clientActiveTextureARB(uint stage)
|
|||
|
||||
if( _CurrentClientActiveTextureARB != stage )
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
glClientActiveTexture(GL_TEXTURE0+stage);
|
||||
#else
|
||||
nglClientActiveTextureARB(GL_TEXTURE0_ARB+stage);
|
||||
#endif
|
||||
_CurrentClientActiveTextureARB= stage;
|
||||
}
|
||||
}
|
||||
|
@ -1121,11 +1096,7 @@ void CDriverGLStates::forceBindARBVertexBuffer(uint objectID)
|
|||
{
|
||||
H_AUTO_OGL(CDriverGLStates_forceBindARBVertexBuffer)
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
glBindBuffer(GL_ARRAY_BUFFER, objectID);
|
||||
#else
|
||||
nglBindBufferARB(GL_ARRAY_BUFFER_ARB, objectID);
|
||||
#endif
|
||||
|
||||
_CurrARBVertexBuffer = objectID;
|
||||
}
|
||||
|
|
|
@ -93,19 +93,6 @@ CTextureDrvInfosGL::~CTextureDrvInfosGL()
|
|||
{
|
||||
_Driver->_TextureUsed[TextureUsedIdx] = NULL;
|
||||
}
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
if (InitFBO)
|
||||
{
|
||||
nglDeleteFramebuffersOES(1, &FBOId);
|
||||
if(AttachDepthStencil)
|
||||
{
|
||||
nglDeleteRenderbuffersOES(1, &DepthFBOId);
|
||||
if(!UsePackedDepthStencil)
|
||||
nglDeleteRenderbuffersOES(1, &StencilFBOId);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
CDepthStencilFBO::CDepthStencilFBO(CDriverGL *driver, uint width, uint height)
|
||||
|
@ -175,56 +162,9 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex)
|
|||
AttachDepthStencil = !((CTextureBloom*)tex)->isMode2D();
|
||||
}
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
// generate IDs
|
||||
nglGenFramebuffersOES(1, &FBOId);
|
||||
if(AttachDepthStencil)
|
||||
{
|
||||
nglGenRenderbuffersOES(1, &DepthFBOId);
|
||||
if(UsePackedDepthStencil)
|
||||
StencilFBOId = DepthFBOId;
|
||||
else
|
||||
nglGenRenderbuffersOES(1, &StencilFBOId);
|
||||
}
|
||||
|
||||
//nldebug("3D: using depth %d and stencil %d", DepthFBOId, StencilFBOId);
|
||||
|
||||
// initialize FBO
|
||||
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, FBOId);
|
||||
nglFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, TextureMode, ID, 0);
|
||||
|
||||
// attach depth/stencil render to FBO
|
||||
// note: for some still unkown reason it's impossible to add
|
||||
// a stencil buffer as shown in the respective docs (see
|
||||
// opengl.org extension registry). Until a safe approach to add
|
||||
// them is found, there will be no attached stencil for the time
|
||||
// being, aside of using packed depth+stencil buffers.
|
||||
if(AttachDepthStencil)
|
||||
{
|
||||
if(UsePackedDepthStencil)
|
||||
{
|
||||
//nldebug("3D: using packed depth stencil");
|
||||
nglBindRenderbufferOES(GL_RENDERBUFFER_OES, StencilFBOId);
|
||||
nglRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH24_STENCIL8_OES, tex->getWidth(), tex->getHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
nglBindRenderbufferOES(GL_RENDERBUFFER_OES, DepthFBOId);
|
||||
nglRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT24_OES, tex->getWidth(), tex->getHeight());
|
||||
/*
|
||||
nglBindRenderbufferEXT(GL_RENDERBUFFER_OES, StencilFBOId);
|
||||
nglRenderbufferStorageEXT(GL_RENDERBUFFER_OES, GL_STENCIL_INDEX8_EXT, tex->getWidth(), tex->getHeight());
|
||||
*/
|
||||
}
|
||||
nglFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, DepthFBOId);
|
||||
nldebug("3D: glFramebufferRenderbufferExt(depth:24) = %X", nglCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
|
||||
nglFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, StencilFBOId);
|
||||
nldebug("3D: glFramebufferRenderbufferExt(stencil:8) = %X", nglCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
|
||||
}
|
||||
#else
|
||||
// generate IDs
|
||||
nglGenFramebuffersEXT(1, &FBOId);
|
||||
|
||||
|
||||
//nldebug("3D: using depth %d and stencil %d", DepthFBOId, StencilFBOId);
|
||||
|
||||
// initialize FBO
|
||||
|
@ -253,15 +193,10 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex)
|
|||
GL_RENDERBUFFER_EXT, DepthStencilFBO->StencilFBOId);
|
||||
nldebug("3D: glFramebufferRenderbufferExt(stencil:8) = %X", nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));
|
||||
}
|
||||
#endif
|
||||
|
||||
// check status
|
||||
GLenum status;
|
||||
#ifdef USE_OPENGLES
|
||||
status = (GLenum) nglCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
|
||||
#else
|
||||
status = (GLenum) nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
#endif
|
||||
GLenum status = (GLenum) nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
|
||||
switch(status) {
|
||||
#ifdef GL_FRAMEBUFFER_COMPLETE_EXT
|
||||
case GL_FRAMEBUFFER_COMPLETE_EXT:
|
||||
|
@ -361,11 +296,8 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex)
|
|||
// clean up resources if allocation failed
|
||||
if (!InitFBO)
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
nglDeleteFramebuffersOES(1, &FBOId);
|
||||
#else
|
||||
nglDeleteFramebuffersEXT(1, &FBOId);
|
||||
#endif
|
||||
|
||||
if (AttachDepthStencil)
|
||||
{
|
||||
DepthStencilFBO = NULL;
|
||||
|
@ -385,22 +317,14 @@ bool CTextureDrvInfosGL::activeFrameBufferObject(ITexture * tex)
|
|||
if(initFrameBufferObject(tex))
|
||||
{
|
||||
glBindTexture(TextureMode, 0);
|
||||
#ifdef USE_OPENGLES
|
||||
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, FBOId);
|
||||
#else
|
||||
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBOId);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
|
||||
#else
|
||||
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -508,11 +432,7 @@ GLint CDriverGL::getGlTextureFormat(ITexture& tex, bool &compressed)
|
|||
break;
|
||||
}
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
return GL_RGBA;
|
||||
#else
|
||||
return GL_RGBA8;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
@ -521,11 +441,7 @@ static GLint getGlSrcTextureFormat(ITexture &tex, GLint glfmt)
|
|||
H_AUTO_OGL(getGlSrcTextureFormat)
|
||||
|
||||
// Is destination format is alpha or lumiance ?
|
||||
#ifdef USE_OPENGLES
|
||||
if ((glfmt==GL_ALPHA)||(glfmt==GL_LUMINANCE_ALPHA)||(glfmt==GL_LUMINANCE))
|
||||
#else
|
||||
if ((glfmt==GL_ALPHA8)||(glfmt==GL_LUMINANCE8_ALPHA8)||(glfmt==GL_LUMINANCE8))
|
||||
#endif
|
||||
{
|
||||
switch(tex.getPixelFormat())
|
||||
{
|
||||
|
@ -578,19 +494,9 @@ uint CDriverGL::computeMipMapMemoryUsage(uint w, uint h, GLint glfmt) const
|
|||
H_AUTO_OGL(CDriverGL_computeMipMapMemoryUsage)
|
||||
switch(glfmt)
|
||||
{
|
||||
#ifdef GL_RGBA8
|
||||
case GL_RGBA8: return w*h* 4;
|
||||
#endif
|
||||
#ifdef GL_RGBA
|
||||
case GL_RGBA: return w*h* 4;
|
||||
#endif
|
||||
// Well this is ugly, but simple :). GeForce 888 is stored as 32 bits.
|
||||
#ifdef GL_RGB8
|
||||
case GL_RGB8: return w*h* 4;
|
||||
#endif
|
||||
#ifdef GL_RGB
|
||||
case GL_RGB: return w*h* 4;
|
||||
#endif
|
||||
#ifdef GL_RGBA4
|
||||
case GL_RGBA4: return w*h* 2;
|
||||
#endif
|
||||
|
@ -600,24 +506,9 @@ uint CDriverGL::computeMipMapMemoryUsage(uint w, uint h, GLint glfmt) const
|
|||
#ifdef GL_RGB5
|
||||
case GL_RGB5: return w*h* 2;
|
||||
#endif
|
||||
#ifdef GL_LUMINANCE8
|
||||
case GL_LUMINANCE8: return w*h* 1;
|
||||
#endif
|
||||
#ifdef GL_LUMINANCE
|
||||
case GL_LUMINANCE: return w*h* 1;
|
||||
#endif
|
||||
#ifdef GL_ALPHA8
|
||||
case GL_ALPHA8: return w*h* 1;
|
||||
#endif
|
||||
#ifdef GL_ALPHA
|
||||
case GL_ALPHA: return w*h* 1;
|
||||
#endif
|
||||
#ifdef GL_LUMINANCE8_ALPHA8
|
||||
case GL_LUMINANCE8_ALPHA8: return w*h* 2;
|
||||
#endif
|
||||
#ifdef GL_LUMINANCE_ALPHA
|
||||
case GL_LUMINANCE_ALPHA: return w*h* 2;
|
||||
#endif
|
||||
#ifdef GL_COMPRESSED_RGB_S3TC_DXT1_EXT
|
||||
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: return w*h /2;
|
||||
#endif
|
||||
|
|
|
@ -1216,11 +1216,7 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
|
|||
GLuint vertexBufferID;
|
||||
glGetError();
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
glGenBuffers(1, &vertexBufferID);
|
||||
#else
|
||||
nglGenBuffersARB(1, &vertexBufferID);
|
||||
#endif
|
||||
|
||||
if (glGetError() != GL_NO_ERROR) return NULL;
|
||||
_Driver->_DriverGLStates.forceBindARBVertexBuffer(vertexBufferID);
|
||||
|
@ -1229,7 +1225,8 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
|
|||
{
|
||||
case CVertexBuffer::AGPVolatile:
|
||||
#ifdef USE_OPENGLES
|
||||
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STREAM_DRAW);
|
||||
// TODO: GL_STREAM_DRAW doesn't exist in OpenGL ES 1.x
|
||||
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
|
||||
#else
|
||||
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STREAM_DRAW_ARB);
|
||||
#endif
|
||||
|
@ -1259,11 +1256,7 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
|
|||
}
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
#ifdef USE_OPENGLES
|
||||
glDeleteBuffers(1, &vertexBufferID);
|
||||
#else
|
||||
nglDeleteBuffersARB(1, &vertexBufferID);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1306,13 +1299,10 @@ void CVertexArrayRangeARB::updateLostBuffers()
|
|||
{
|
||||
nlassert((*it)->_VertexObjectId);
|
||||
GLuint id = (GLuint) (*it)->_VertexObjectId;
|
||||
#ifdef USE_OPENGLES
|
||||
nlassert(glIsBuffer(id));
|
||||
glDeleteBuffers(1, &id);
|
||||
#else
|
||||
|
||||
nlassert(nglIsBufferARB(id));
|
||||
nglDeleteBuffersARB(1, &id);
|
||||
#endif
|
||||
|
||||
(*it)->_VertexObjectId = 0;
|
||||
(*it)->VB->setLocation(CVertexBuffer::NotResident);
|
||||
}
|
||||
|
@ -1361,13 +1351,8 @@ CVertexBufferHardARB::~CVertexBufferHardARB()
|
|||
if (_VertexObjectId)
|
||||
{
|
||||
GLuint id = (GLuint) _VertexObjectId;
|
||||
#ifdef USE_OPENGLES
|
||||
nlassert(glIsBuffer(id));
|
||||
glDeleteBuffers(1, &id);
|
||||
#else
|
||||
nlassert(nglIsBufferARB(id));
|
||||
nglDeleteBuffersARB(1, &id);
|
||||
#endif
|
||||
}
|
||||
if (_VertexArrayRange)
|
||||
{
|
||||
|
@ -1412,12 +1397,7 @@ void *CVertexBufferHardARB::lock()
|
|||
}
|
||||
// recreate a vb
|
||||
GLuint vertexBufferID;
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
glGenBuffers(1, &vertexBufferID);
|
||||
#else
|
||||
nglGenBuffersARB(1, &vertexBufferID);
|
||||
#endif
|
||||
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
|
@ -1429,42 +1409,30 @@ void *CVertexBufferHardARB::lock()
|
|||
{
|
||||
case CVertexBuffer::AGPVolatile:
|
||||
#ifdef USE_OPENGLES
|
||||
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STREAM_DRAW);
|
||||
// TODO: GL_STREAM_DRAW doesn't exist in OpenGL ES 1.x
|
||||
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
|
||||
#else
|
||||
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STREAM_DRAW_ARB);
|
||||
#endif
|
||||
break;
|
||||
case CVertexBuffer::StaticPreferred:
|
||||
if (_Driver->getStaticMemoryToVRAM())
|
||||
#ifdef USE_OPENGLES
|
||||
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STATIC_DRAW);
|
||||
#else
|
||||
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB);
|
||||
#endif
|
||||
else
|
||||
#ifdef USE_OPENGLES
|
||||
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
|
||||
#else
|
||||
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
|
||||
#endif
|
||||
break;
|
||||
// case CVertexBuffer::AGPPreferred:
|
||||
default:
|
||||
#ifdef USE_OPENGLES
|
||||
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
|
||||
#else
|
||||
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
_Driver->incrementResetCounter();
|
||||
#ifdef USE_OPENGLES
|
||||
glDeleteBuffers(1, &vertexBufferID);
|
||||
#else
|
||||
|
||||
nglDeleteBuffersARB(1, &vertexBufferID);
|
||||
#endif
|
||||
|
||||
return &_DummyVB[0];;
|
||||
}
|
||||
_VertexObjectId = vertexBufferID;
|
||||
|
@ -1567,12 +1535,10 @@ void CVertexBufferHardARB::unlock()
|
|||
|
||||
#ifdef USE_OPENGLES
|
||||
if (_Driver->_Extensions.OESMapBuffer)
|
||||
{
|
||||
unmapOk = nglUnmapBufferOES(GL_ARRAY_BUFFER);
|
||||
}
|
||||
#else
|
||||
unmapOk = nglUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
|
||||
#endif
|
||||
{
|
||||
unmapOk = nglUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
|
||||
}
|
||||
|
||||
#ifdef NL_DEBUG
|
||||
_Unmapping = false;
|
||||
|
|
|
@ -453,7 +453,6 @@ bool CDriverGL::setupEXTVertexShader(const CVPParser::TProgram &program, GLuint
|
|||
// clear last error
|
||||
GLenum glError = glGetError();
|
||||
|
||||
//variants[EVSSecondaryColorVariant] = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_NORMALIZED_RANGE_EXT, 1);
|
||||
//variants[EVSSecondaryColorVariant] = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_NORMALIZED_RANGE_EXT, 1);
|
||||
|
||||
// allocate the symbols
|
||||
|
|
|
@ -627,10 +627,15 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
|
|||
// Offscreen mode ?
|
||||
if (_CurrentMode.OffScreen)
|
||||
{
|
||||
#if 0
|
||||
if (!createWindow(mode))
|
||||
return false;
|
||||
if (!createWindow(mode)) return false;
|
||||
|
||||
HWND tmpHWND = _win;
|
||||
int width = mode.Width;
|
||||
int height = mode.Height;
|
||||
|
||||
#ifdef USE_OPENGLES
|
||||
// TODO: implement for OpenGL ES 1.x
|
||||
#else
|
||||
// resize the window
|
||||
RECT rc;
|
||||
SetRect (&rc, 0, 0, width, height);
|
||||
|
@ -1437,8 +1442,17 @@ bool CDriverGL::createWindow(const GfxMode &mode)
|
|||
#ifdef NL_OS_WINDOWS
|
||||
|
||||
// create the OpenGL window
|
||||
window = CreateWindowW(L"NLClass", L"NeL Window", WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, mode.Width, mode.Height, HWND_DESKTOP, NULL, GetModuleHandle(NULL), NULL);
|
||||
DWORD dwStyle = WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_CLIPSIBLINGS;
|
||||
int pos = CW_USEDEFAULT;
|
||||
HWND hwndParent = HWND_DESKTOP;
|
||||
if (mode.OffScreen)
|
||||
{
|
||||
dwStyle &= ~WS_VISIBLE;
|
||||
pos = 0;
|
||||
hwndParent = NULL;
|
||||
}
|
||||
window = CreateWindowW(L"NLClass", L"NeL Window", dwStyle,
|
||||
pos, pos, mode.Width, mode.Height, hwndParent, NULL, GetModuleHandle(NULL), NULL);
|
||||
|
||||
if (window == EmptyWindow)
|
||||
{
|
||||
|
@ -1469,7 +1483,7 @@ bool CDriverGL::createWindow(const GfxMode &mode)
|
|||
[[CocoaApplicationDelegate alloc] initWithDriver:this];
|
||||
|
||||
// set the application delegate, this will handle window/app close events
|
||||
[NSApp setDelegate:appDelegate];
|
||||
[NSApp setDelegate:(id<NSFileManagerDelegate>)appDelegate];
|
||||
|
||||
// bind the close button of the window to applicationShouldTerminate
|
||||
id closeButton = [cocoa_window standardWindowButton:NSWindowCloseButton];
|
||||
|
|
|
@ -270,28 +270,14 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
|
|||
return false;
|
||||
}
|
||||
|
||||
// first event about mouse movement after setting to emulateRawMode
|
||||
if(_setToEmulateRawMode &&
|
||||
(event.type == NSMouseMoved ||
|
||||
event.type == NSLeftMouseDragged ||
|
||||
event.type == NSRightMouseDragged))
|
||||
{
|
||||
// do not report because it reflects wrapping pointer to 0.5/0.5
|
||||
_setToEmulateRawMode = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// convert the modifiers for nel to pass them with the events
|
||||
NLMISC::TKeyButton modifiers =
|
||||
modifierFlagsToNelKeyButton([event modifierFlags]);
|
||||
NLMISC::TKeyButton modifiers = modifierFlagsToNelKeyButton([event modifierFlags]);
|
||||
|
||||
switch(event.type)
|
||||
{
|
||||
case NSLeftMouseDown:
|
||||
{
|
||||
server->postEvent(new NLMISC::CEventMouseDown(
|
||||
mousePos.x, mousePos.y,
|
||||
(NLMISC::TMouseButton)(NLMISC::leftButton | modifiers), this));
|
||||
server->postEvent(new NLMISC::CEventMouseDown(mousePos.x, mousePos.y, (NLMISC::TMouseButton)(NLMISC::leftButton | modifiers), this));
|
||||
}
|
||||
break;
|
||||
case NSLeftMouseUp:
|
||||
|
@ -319,15 +305,7 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
|
|||
{
|
||||
NLMISC::CEvent* nelEvent;
|
||||
|
||||
// when emulating raw mode, send the delta in a CGDMouseMove event
|
||||
if(_emulateRawMode)
|
||||
nelEvent = new NLMISC::CGDMouseMove(
|
||||
this, NULL /* no mouse device */, event.deltaX, -event.deltaY);
|
||||
|
||||
// normally send position in a CEventMouseMove
|
||||
else
|
||||
nelEvent = new NLMISC::CEventMouseMove(
|
||||
mousePos.x, mousePos.y, (NLMISC::TMouseButton)modifiers, this);
|
||||
nelEvent = new NLMISC::CEventMouseMove(mousePos.x, mousePos.y, (NLMISC::TMouseButton)modifiers, this);
|
||||
|
||||
server->postEvent(nelEvent);
|
||||
break;
|
||||
|
@ -336,15 +314,7 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
|
|||
{
|
||||
NLMISC::CEvent* nelEvent;
|
||||
|
||||
// when emulating raw mode, send the delta in a CGDMouseMove event
|
||||
if(_emulateRawMode)
|
||||
nelEvent = new NLMISC::CGDMouseMove(
|
||||
this, NULL /* no mouse device */, event.deltaX, -event.deltaY);
|
||||
|
||||
// normally send position in a CEventMouseMove
|
||||
else
|
||||
nelEvent = new NLMISC::CEventMouseMove(mousePos.x, mousePos.y,
|
||||
(NLMISC::TMouseButton)(NLMISC::leftButton | modifiers), this);
|
||||
nelEvent = new NLMISC::CEventMouseMove(mousePos.x, mousePos.y, (NLMISC::TMouseButton)(NLMISC::leftButton | modifiers), this);
|
||||
|
||||
server->postEvent(nelEvent);
|
||||
break;
|
||||
|
@ -353,15 +323,7 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
|
|||
{
|
||||
NLMISC::CEvent* nelEvent;
|
||||
|
||||
// when emulating raw mode, send the delta in a CGDMouseMove event
|
||||
if(_emulateRawMode)
|
||||
nelEvent = new NLMISC::CGDMouseMove(
|
||||
this, NULL /* no mouse device */, event.deltaX, -event.deltaY);
|
||||
|
||||
// normally send position in a CEventMouseMove
|
||||
else
|
||||
nelEvent = new NLMISC::CEventMouseMove(mousePos.x, mousePos.y,
|
||||
(NLMISC::TMouseButton)(NLMISC::rightButton | modifiers), this);
|
||||
nelEvent = new NLMISC::CEventMouseMove(mousePos.x, mousePos.y, (NLMISC::TMouseButton)(NLMISC::rightButton | modifiers), this);
|
||||
|
||||
server->postEvent(nelEvent);
|
||||
break;
|
||||
|
@ -434,12 +396,6 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
|
|||
}
|
||||
}
|
||||
|
||||
if(_emulateRawMode && _driver && (event.type == NSMouseMoved ||
|
||||
event.type == NSLeftMouseDragged || event.type == NSRightMouseDragged))
|
||||
{
|
||||
_driver->setMousePos(0.5, 0.5);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -492,17 +448,4 @@ void CCocoaEventEmitter::submitEvents(CEventServer& server, bool /* allWins */)
|
|||
_server = &server;
|
||||
}
|
||||
|
||||
void CCocoaEventEmitter::emulateMouseRawMode(bool enable)
|
||||
{
|
||||
_emulateRawMode = enable;
|
||||
|
||||
if(_emulateRawMode)
|
||||
{
|
||||
_setToEmulateRawMode = true;
|
||||
|
||||
if(_driver)
|
||||
_driver->setMousePos(0.5, 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,8 +31,6 @@ namespace NLMISC
|
|||
|
||||
class CCocoaEventEmitter : public IEventEmitter
|
||||
{
|
||||
bool _emulateRawMode;
|
||||
bool _setToEmulateRawMode;
|
||||
bool _eventLoop;
|
||||
NL3D::IDriver* _driver;
|
||||
CocoaOpenGLView* _glView;
|
||||
|
@ -42,8 +40,6 @@ class CCocoaEventEmitter : public IEventEmitter
|
|||
|
||||
public:
|
||||
CCocoaEventEmitter() :
|
||||
_emulateRawMode(false),
|
||||
_setToEmulateRawMode(false),
|
||||
_driver(NULL),
|
||||
_glView(nil),
|
||||
_server(NULL) { }
|
||||
|
|
|
@ -100,7 +100,6 @@ private:
|
|||
std::map<TKey, bool> _PressedKeys;
|
||||
XIM _im;
|
||||
XIC _ic;
|
||||
bool _emulateRawMode;
|
||||
NL3D::IDriver* _driver;
|
||||
CUnixEventServer _InternalServer;
|
||||
ucstring _CopiedString;
|
||||
|
|
|
@ -583,7 +583,6 @@ void CLandscape::setDriver(IDriver *drv)
|
|||
// Does the driver has sufficient requirements for Vegetable???
|
||||
// only if VP supported by GPU, and Only if max vertices allowed.
|
||||
_DriverOkForVegetable = _VertexShaderOk && (_Driver->getMaxVerticesByVertexBufferHard()>=(uint)NL3D_LANDSCAPE_VEGETABLE_MAX_AGP_VERTEX_MAX);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -611,7 +611,6 @@ void CLandscapeVBAllocator::setupVBFormatAndVertexProgram(bool withVertexProgr
|
|||
nlverify(_Driver->compileVertexProgram(_VertexProgram[1]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -392,7 +392,6 @@ bool CMeshVPWindTree::begin(IDriver *driver, CScene *scene, CMeshBaseInstance *m
|
|||
sint numPls= renderTrav->getNumVPLights()-1;
|
||||
clamp(numPls, 0, CRenderTrav::MaxVPLight-1);
|
||||
|
||||
|
||||
// Enable normalize only if requested by user. Because lighting don't manage correct "scale lighting"
|
||||
uint idVP= (SpecularLighting?2:0) + (driver->isForceNormalize()?1:0) ;
|
||||
// correct VP id for correct unmber of pls.
|
||||
|
@ -523,7 +522,7 @@ void CMeshVPWindTree::beginMBRInstance(IDriver *driver, CScene *scene, CMeshBase
|
|||
idVP = numPls*4 + idVP;
|
||||
|
||||
// re-activate VP if idVP different from last setup
|
||||
if(idVP != _LastMBRIdVP)
|
||||
if (idVP != _LastMBRIdVP)
|
||||
{
|
||||
_LastMBRIdVP= idVP;
|
||||
driver->activeVertexProgram(_VertexProgram[_LastMBRIdVP]);
|
||||
|
|
|
@ -158,7 +158,7 @@ CScene::CScene(bool bSmallScene) : LightTrav(bSmallScene)
|
|||
|
||||
_MaxSkeletonsInNotCLodForm= 20;
|
||||
|
||||
_FilterRenderFlags= std::numeric_limits<uint32>::max();
|
||||
_FilterRenderFlags = std::numeric_limits<uint32>::max();
|
||||
|
||||
_NextRenderProfile= false;
|
||||
|
||||
|
@ -592,11 +592,9 @@ void CScene::renderPart(UScene::TRenderPart rp, bool doHrcPass, bool doTrav, boo
|
|||
//
|
||||
nlassert(CurrentCamera);
|
||||
|
||||
|
||||
// update models.
|
||||
updateModels();
|
||||
|
||||
|
||||
// Use the camera to setup Clip / Render pass.
|
||||
float left, right, bottom, top, znear, zfar;
|
||||
CurrentCamera->getFrustum(left, right, bottom, top, znear, zfar);
|
||||
|
|
|
@ -244,7 +244,7 @@ void CShadowMapManager::addShadowReceiver(CTransform *model)
|
|||
void CShadowMapManager::renderGenerate(CScene *scene)
|
||||
{
|
||||
H_AUTO( NL3D_ShadowManager_Generate );
|
||||
|
||||
|
||||
// Each frame, do a small garbage collector for unused free textures.
|
||||
garbageShadowTextures(scene);
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ CTransform::CTransform()
|
|||
_StateFlags= IsOpaque | IsUserLightable;
|
||||
|
||||
// By default, always allow rendering of Transform Models.
|
||||
_RenderFilterType= std::numeric_limits<uint32>::max();
|
||||
_RenderFilterType = std::numeric_limits<uint32>::max();
|
||||
|
||||
// By default, don't suport fast intersection detection
|
||||
_SupportFastIntersect= false;
|
||||
|
|
|
@ -44,19 +44,19 @@ NLMISC_COMMAND(setWaterPool, "Setup a pool of water in the water pool manager",
|
|||
}
|
||||
if (numArgs == 3)
|
||||
{
|
||||
whmb.FilterWeight = ::atof(args[2].c_str());
|
||||
NLMISC::fromString(args[2], whmb.FilterWeight);
|
||||
}
|
||||
if (numArgs == 4)
|
||||
{
|
||||
whmb.UnitSize = ::atof(args[3].c_str());
|
||||
NLMISC::fromString(args[3], whmb.UnitSize);
|
||||
}
|
||||
if (numArgs == 5)
|
||||
{
|
||||
whmb.WaveIntensity = ::atof(args[4].c_str());
|
||||
NLMISC::fromString(args[4], whmb.WaveIntensity);
|
||||
}
|
||||
if (numArgs == 4)
|
||||
{
|
||||
whmb.WavePeriod = ::atof(args[5].c_str());
|
||||
NLMISC::fromString(args[5], whmb.WavePeriod);
|
||||
}
|
||||
// create the water pool
|
||||
GetWaterPoolManager().createWaterPool(whmb);
|
||||
|
|
|
@ -707,7 +707,7 @@ bool CFormDfn::getEntryIndexByName (uint &entry, const std::string &name) const
|
|||
}
|
||||
entryIndex++;
|
||||
}
|
||||
entry=std::numeric_limits<uint>::max();
|
||||
entry = std::numeric_limits<uint>::max();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -701,6 +701,11 @@ namespace NLGUI
|
|||
//pIM->submitEvent ("button_click:"+getId());
|
||||
}
|
||||
*/
|
||||
|
||||
// top-right corner is EventX=0, EventY=0
|
||||
_EventX = eventDesc.getX() - _XReal;
|
||||
_EventY = (_YReal + _HReal) - eventDesc.getY();
|
||||
|
||||
runLeftClickAction();
|
||||
if (CWidgetManager::getInstance()->getCapturePointerLeft() == NULL) return true; // event handler may release cpature from this object (if it is removed for example)
|
||||
|
||||
|
|
|
@ -999,7 +999,8 @@ namespace NLGUI
|
|||
break;
|
||||
// OTHER
|
||||
default:
|
||||
if ((rEDK.getChar() == KeyRETURN) && !_WantReturn)
|
||||
bool isKeyRETURN = !rEDK.getKeyCtrl() && rEDK.getChar() == KeyRETURN;
|
||||
if (isKeyRETURN && !_WantReturn)
|
||||
{
|
||||
// update historic.
|
||||
if(_MaxHistoric)
|
||||
|
@ -1030,9 +1031,9 @@ namespace NLGUI
|
|||
// If the char is not alphanumeric -> return.
|
||||
// if(!isalnum(ec.Char))
|
||||
// return
|
||||
if( (rEDK.getChar()>=32) || (rEDK.getChar() == KeyRETURN) )
|
||||
if( (rEDK.getChar()>=32) || isKeyRETURN )
|
||||
{
|
||||
if (rEDK.getChar() == KeyRETURN)
|
||||
if (isKeyRETURN)
|
||||
{
|
||||
ucstring copyStr= _InputString;
|
||||
if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn)
|
||||
|
@ -1049,7 +1050,7 @@ namespace NLGUI
|
|||
cutSelection();
|
||||
}
|
||||
|
||||
ucchar c = (rEDK.getChar() == KeyRETURN)?'\n':rEDK.getChar();
|
||||
ucchar c = isKeyRETURN ? '\n' : rEDK.getChar();
|
||||
if (isFiltered(c)) return;
|
||||
switch(_EntryType)
|
||||
{
|
||||
|
@ -1128,7 +1129,7 @@ namespace NLGUI
|
|||
++ _CursorPos;
|
||||
triggerOnChangeAH();
|
||||
}
|
||||
if (rEDK.getChar() == KeyRETURN)
|
||||
if (isKeyRETURN)
|
||||
{
|
||||
CAHManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams);
|
||||
}
|
||||
|
|
|
@ -1217,7 +1217,7 @@ namespace NLGUI
|
|||
normal = value[MY_HTML_INPUT_SRC];
|
||||
|
||||
// Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name"
|
||||
string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name;
|
||||
string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name + "|submit_button_type=image";
|
||||
|
||||
// Add the ctrl button
|
||||
addButton (CCtrlButton::PushButton, name, normal, pushed.empty()?normal:pushed, over,
|
||||
|
@ -1241,7 +1241,15 @@ namespace NLGUI
|
|||
text = value[MY_HTML_INPUT_VALUE];
|
||||
|
||||
// Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name"
|
||||
string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name;
|
||||
string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name + "|submit_button_type=submit";
|
||||
if (text.size() > 0)
|
||||
{
|
||||
// escape AH param separator
|
||||
string tmp = text;
|
||||
while(NLMISC::strFindReplace(tmp, "|", "|"))
|
||||
;
|
||||
param = param + "|submit_button_value=" + tmp;
|
||||
}
|
||||
|
||||
// Add the ctrl button
|
||||
if (!_Paragraph)
|
||||
|
@ -3638,14 +3646,18 @@ namespace NLGUI
|
|||
|
||||
// ***************************************************************************
|
||||
|
||||
void CGroupHTML::submitForm (uint formId, const char *submitButtonName)
|
||||
void CGroupHTML::submitForm (uint formId, const char *submitButtonType, const char *submitButtonName, const char *submitButtonValue, sint32 x, sint32 y)
|
||||
{
|
||||
// Form id valid ?
|
||||
if (formId < _Forms.size())
|
||||
{
|
||||
_PostNextTime = true;
|
||||
_PostFormId = formId;
|
||||
_PostFormSubmitType = submitButtonType;
|
||||
_PostFormSubmitButton = submitButtonName;
|
||||
_PostFormSubmitValue = submitButtonValue;
|
||||
_PostFormSubmitX = x;
|
||||
_PostFormSubmitY = y;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3918,9 +3930,22 @@ namespace NLGUI
|
|||
}
|
||||
}
|
||||
|
||||
// Add the button coordinates
|
||||
HTParseFormInput(formfields, (_PostFormSubmitButton + "_x=0").c_str());
|
||||
HTParseFormInput(formfields, (_PostFormSubmitButton + "_y=0").c_str());
|
||||
if (_PostFormSubmitType == "image")
|
||||
{
|
||||
// Add the button coordinates
|
||||
if (_PostFormSubmitButton.find_first_of("[") == string::npos)
|
||||
{
|
||||
HTParseFormInput(formfields, (_PostFormSubmitButton + "_x=" + NLMISC::toString(_PostFormSubmitX)).c_str());
|
||||
HTParseFormInput(formfields, (_PostFormSubmitButton + "_y=" + NLMISC::toString(_PostFormSubmitY)).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
HTParseFormInput(formfields, (_PostFormSubmitButton + "=" + NLMISC::toString(_PostFormSubmitX)).c_str());
|
||||
HTParseFormInput(formfields, (_PostFormSubmitButton + "=" + NLMISC::toString(_PostFormSubmitY)).c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
HTParseFormInput(formfields, (_PostFormSubmitButton + "=" + _PostFormSubmitValue).c_str());
|
||||
|
||||
// Add custom params
|
||||
addHTTPPostParams(formfields, _TrustedDomain);
|
||||
|
|
|
@ -2207,7 +2207,7 @@ namespace NLGUI
|
|||
}
|
||||
|
||||
// Manage complex "Enter"
|
||||
if (eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == NLMISC::KeyRETURN)
|
||||
if( eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == NLMISC::KeyRETURN && !eventDesc.getKeyCtrl() )
|
||||
{
|
||||
// If the top window has Enter AH
|
||||
CInterfaceGroup *tw= getTopWindow();
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
#include "stdmisc.h"
|
||||
|
||||
#include <nel/misc/types_nl.h>
|
||||
#include <nel/misc/debug.h>
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/debug.h"
|
||||
|
||||
#ifdef NL_OS_UNIX
|
||||
|
||||
|
|
|
@ -858,6 +858,8 @@ string getname (dirent *de)
|
|||
void CPath::getPathContent (const string &path, bool recurse, bool wantDir, bool wantFile, vector<string> &result, class IProgressCallback *progressCallBack, bool showEverything)
|
||||
{
|
||||
getInstance()->_FileContainer.getPathContent(path, recurse, wantDir, wantFile, result, progressCallBack, showEverything);
|
||||
|
||||
sort(result.begin(), result.end());
|
||||
}
|
||||
|
||||
void CFileContainer::getPathContent (const string &path, bool recurse, bool wantDir, bool wantFile, vector<string> &result, class IProgressCallback *progressCallBack, bool showEverything)
|
||||
|
@ -960,8 +962,6 @@ void CFileContainer::getPathContent (const string &path, bool recurse, bool want
|
|||
progressCallBack->popCropedValues ();
|
||||
}
|
||||
}
|
||||
|
||||
sort(result.begin(), result.end());
|
||||
}
|
||||
|
||||
void CPath::removeAllAlternativeSearchPath ()
|
||||
|
|
|
@ -217,7 +217,7 @@ bool CSheetId::buildSheetId(const std::string& sheetName)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID
|
||||
if (a_NoSoundSheetId && sheetName.find(".sound") != std::string::npos)
|
||||
{
|
||||
|
@ -236,7 +236,7 @@ bool CSheetId::buildSheetId(const std::string& sheetName)
|
|||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -417,10 +417,10 @@ void CSheetId::initWithoutSheet()
|
|||
nlassert(_DontHaveSheetKnowledge);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
_Initialised = true;
|
||||
_DontHaveSheetKnowledge = true;
|
||||
|
||||
|
||||
// Initialize id 0,0 as unknown.unknown
|
||||
CSheetId unknownunknown = CSheetId("unknown.unknown");
|
||||
nlassert(unknownunknown == CSheetId::Unknown);
|
||||
|
@ -525,7 +525,7 @@ bool CSheetId::operator < (const CSheetId& sheetRef ) const
|
|||
string CSheetId::toString(bool ifNotFoundUseNumericId) const
|
||||
{
|
||||
if (!_Initialised) init(false);
|
||||
|
||||
|
||||
if (_DontHaveSheetKnowledge)
|
||||
{
|
||||
// FIXME: When someone punches in a fake sheet id this will
|
||||
|
@ -564,7 +564,7 @@ string CSheetId::toString(bool ifNotFoundUseNumericId) const
|
|||
void CSheetId::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
|
||||
{
|
||||
nlassert(!_DontHaveSheetKnowledge);
|
||||
|
||||
|
||||
f.serial( _Id.Id );
|
||||
|
||||
#ifdef NL_DEBUG_SHEET_ID
|
||||
|
|
|
@ -1731,7 +1731,9 @@ namespace NLMISC
|
|||
|
||||
double CSString::atof() const
|
||||
{
|
||||
return ::atof(c_str());
|
||||
double val;
|
||||
NLMISC::fromString(*this, val);
|
||||
return val;
|
||||
}
|
||||
|
||||
bool CSString::readFromFile(const CSString& fileName)
|
||||
|
|
|
@ -198,7 +198,7 @@ void CWinThread::start ()
|
|||
{
|
||||
if (isRunning())
|
||||
throw EThread("Starting a thread that is already started, existing thread will continue running, this should not happen");
|
||||
|
||||
|
||||
// ThreadHandle = (void *) ::CreateThread (NULL, _StackSize, ProxyFunc, this, 0, (DWORD *)&ThreadId);
|
||||
ThreadHandle = (void *) ::CreateThread (NULL, 0, ProxyFunc, this, 0, (DWORD *)&ThreadId);
|
||||
// nldebug("NLMISC: thread %x started for runnable '%x'", typeid( Runnable ).name());
|
||||
|
|
|
@ -80,7 +80,7 @@ enum TSourceDSoundEndState
|
|||
class CSourceDSound : public ISource
|
||||
{
|
||||
friend class CSoundDriverDSound;
|
||||
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
CSourceDSound(uint sourcename = 0);
|
||||
|
@ -446,7 +446,7 @@ private:
|
|||
|
||||
// Set the 'used' state of the source. Managed by the driver.
|
||||
void setUsed(bool v) { _IsUsed = v; }
|
||||
|
||||
|
||||
// Return the 'used' state of the source
|
||||
bool isUsed() { return _IsUsed; }
|
||||
*/
|
||||
|
|
|
@ -419,7 +419,7 @@ void CSourceFMod::setMinMaxDistances( float mindist, float maxdist, bool /* defe
|
|||
nlwarning("SOUND_DEV (FMod): Ridiculously high max distance set on source");
|
||||
maxdist = maxSqrt;
|
||||
}
|
||||
|
||||
|
||||
_MinDist= mindist;
|
||||
_MaxDist= maxdist;
|
||||
if(_FModChannel!=-1)
|
||||
|
|
|
@ -121,7 +121,7 @@ bool CBufferAL::unlock(uint size)
|
|||
// Error handling
|
||||
if (alGetError() == AL_NO_ERROR)
|
||||
_IsLoaded = true; // ->lock() set it to false
|
||||
|
||||
|
||||
return _IsLoaded;
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ bool CBufferAL::fill(const uint8 *src, uint size)
|
|||
|
||||
// Error handling
|
||||
_IsLoaded = (alGetError() == AL_NO_ERROR);
|
||||
|
||||
|
||||
return _IsLoaded;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ void CSimpleSource::play()
|
|||
|
||||
// and play the sound
|
||||
bool play = pSource->play();
|
||||
|
||||
|
||||
#ifdef NL_DEBUG
|
||||
nlassert(play);
|
||||
#else
|
||||
|
|
|
@ -176,7 +176,10 @@ void CSoundAnimation::load()
|
|||
throw NLMISC::Exception("Invalid sound animation marker");
|
||||
}
|
||||
|
||||
marker->setTime((float) atof(time));
|
||||
float val;
|
||||
NLMISC::fromString(time, val);
|
||||
|
||||
marker->setTime(val);
|
||||
xmlFree ((void*)time);
|
||||
|
||||
|
||||
|
|
|
@ -1739,14 +1739,14 @@ bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, c
|
|||
float posY = config.CellSize * (float)ymin;
|
||||
|
||||
// Use NELU
|
||||
if (CNELU::init (oversampledWidth, oversampledHeight, CViewport(), 32, true, NULL, true))
|
||||
if (CNELU::init (oversampledWidth, oversampledHeight, CViewport(), 32, true, NULL, false, true)) // FIXME: OpenGL not working correctly, offscreen not available in Direct3D
|
||||
{
|
||||
// Setup the camera
|
||||
CNELU::Camera->setTransformMode (ITransformable::DirectMatrix);
|
||||
CMatrix view;
|
||||
view.setPos (CVector (width/2 + posX, height/2 + posY, width));
|
||||
view.setRot (CVector::I, -CVector::K, CVector::J);
|
||||
CNELU::Camera->setFrustum (width, height, 0.1f, 1000.f, false);
|
||||
CNELU::Camera->setFrustum (width, height, 0.1f, 10000.f, false);
|
||||
CNELU::Camera->setMatrix (view);
|
||||
|
||||
// Create a Landscape.
|
||||
|
@ -1766,12 +1766,17 @@ bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, c
|
|||
theLand->enableAdditive (true);
|
||||
theLand->Landscape.setRefineMode (true);
|
||||
|
||||
// theLand->Landscape.setupStaticLight(CRGBA(255, 255, 255), CRGBA(0, 0, 0), 1.0f);
|
||||
// theLand->Landscape.setThreshold(0.0005);
|
||||
|
||||
// Enbable automatique lighting
|
||||
#ifndef NL_DEBUG
|
||||
theLand->Landscape.enableAutomaticLighting (true);
|
||||
theLand->Landscape.setupAutomaticLightDir (CVector (0, 0, -1));
|
||||
// theLand->Landscape.enableAutomaticLighting (true);
|
||||
// theLand->Landscape.setupAutomaticLightDir (CVector (0, 0, -1));
|
||||
#endif // NL_DEBUG
|
||||
|
||||
// theLand->Landscape.updateLightingAll();
|
||||
|
||||
// Clear the backbuffer and the alpha
|
||||
CNELU::clearBuffers(CRGBA(255,0,255,0));
|
||||
|
||||
|
@ -1851,7 +1856,7 @@ bool MakeSnapShot (NLMISC::CBitmap &snapshot, const NL3D::CTileBank &tileBank, c
|
|||
Value* make_snapshot_cf (Value** arg_list, int count)
|
||||
{
|
||||
// Make sure we have the correct number of arguments (7)
|
||||
check_arg_count(check_zone_with_template, 7, count);
|
||||
check_arg_count(NeLLigoMakeSnapShot, 7, count);
|
||||
|
||||
// Check to see if the arguments match up to what we expect
|
||||
char *message = "NeLLigoMakeSnapShot [Object] [Snapshot filename] [xMin] [xMax] [yMin] [yMax] [Error in dialog]";
|
||||
|
@ -1903,11 +1908,11 @@ Value* make_snapshot_cf (Value** arg_list, int count)
|
|||
else
|
||||
{
|
||||
// Build a filename
|
||||
char drive[512];
|
||||
char path[512];
|
||||
char name[512];
|
||||
char ext[512];
|
||||
_splitpath (fileName.c_str(), drive, path, name, ext);
|
||||
char drivetga[512];
|
||||
char pathtga[512];
|
||||
char nametga[512];
|
||||
char exttga[512];
|
||||
_splitpath (fileName.c_str(), drivetga, pathtga, nametga, exttga);
|
||||
|
||||
// Build the zone
|
||||
CZone zone;
|
||||
|
@ -1970,7 +1975,7 @@ Value* make_snapshot_cf (Value** arg_list, int count)
|
|||
{
|
||||
// Build the snap shot filename
|
||||
char outputFilenameSnapShot[512];
|
||||
_makepath (outputFilenameSnapShot, drive, path, name, ".tga");
|
||||
_makepath (outputFilenameSnapShot, drivetga, pathtga, nametga, ".tga");
|
||||
|
||||
// Output the snap shot
|
||||
COFile outputSnapShot;
|
||||
|
@ -2011,10 +2016,10 @@ Value* make_snapshot_cf (Value** arg_list, int count)
|
|||
|
||||
// Write the zone
|
||||
COFile outputLigoZone;
|
||||
_makepath (outputFilenameSnapShot, drive, path, name, ".ligozone");
|
||||
_makepath (outputFilenameSnapShot, drivetga, pathtga, nametga, ".ligozone");
|
||||
|
||||
// Catch exception
|
||||
try
|
||||
/*try
|
||||
{
|
||||
// Open the selected zone file
|
||||
if (outputLigoZone.open (outputFilenameSnapShot))
|
||||
|
@ -2043,7 +2048,7 @@ Value* make_snapshot_cf (Value** arg_list, int count)
|
|||
char tmp[512];
|
||||
smprintf (tmp, 512, "Error while loading the file %s : %s", fileName, e.what());
|
||||
CMaxToLigo::errorMessage (tmp, "NeL Ligo export zone", *MAXScript_interface, errorInDialog);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -2144,6 +2144,8 @@ void appendLightmapLog (COFile &outputLog, const char *lightmapName, const vecto
|
|||
bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshBaseBuild *pZeMeshBaseBuild, INode& ZeNode,
|
||||
TimeValue tvTime, uint firstMaterial, bool outputLightmapLog)
|
||||
{
|
||||
nldebug("Calculate LM: '%s'", ZeNode.GetName());
|
||||
|
||||
DWORD t = timeGetTime();
|
||||
|
||||
uint32 i, j;
|
||||
|
|
|
@ -338,6 +338,8 @@ get_selected_tile_cf(Value** arg_list, int count)
|
|||
if (tri->rpatch->tileSel[i])
|
||||
array->append(Integer::intern(i+1));
|
||||
}
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -383,6 +385,8 @@ get_selected_patch_cf(Value** arg_list, int count)
|
|||
if (tri->patch.patchSel[i])
|
||||
array->append(Integer::intern(i+1));
|
||||
}
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -428,6 +432,8 @@ get_selected_vertex_cf(Value** arg_list, int count)
|
|||
if (tri->patch.vertSel[i])
|
||||
array->append(Integer::intern(i+1));
|
||||
}
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -617,6 +623,8 @@ set_vertex_count_cf(Value** arg_list, int count)
|
|||
{
|
||||
nRet=tri->patch.numVerts;
|
||||
}
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
}
|
||||
|
||||
return Integer::intern(nRet);
|
||||
|
@ -655,6 +663,8 @@ set_vector_count_cf(Value** arg_list, int count)
|
|||
{
|
||||
nRet=tri->patch.numVecs;
|
||||
}
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
}
|
||||
|
||||
return Integer::intern(nRet);
|
||||
|
@ -702,6 +712,8 @@ set_vertex_pos_cf(Value** arg_list, int count)
|
|||
node->NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE);
|
||||
ip->RedrawViews(ip->GetTime());
|
||||
}
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -750,6 +762,8 @@ set_vector_pos_cf(Value** arg_list, int count)
|
|||
node->NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE);
|
||||
ip->RedrawViews(ip->GetTime());
|
||||
}
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -792,6 +806,8 @@ get_vertex_pos_cf(Value** arg_list, int count)
|
|||
{
|
||||
vRet=new Point3Value (tri->patch.verts[nVertex].p);
|
||||
}
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -834,6 +850,8 @@ get_vector_pos_cf(Value** arg_list, int count)
|
|||
{
|
||||
vRet=new Point3Value (tri->patch.vecs[nVertex].p);
|
||||
}
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -877,6 +895,8 @@ get_edge_vect1_cf(Value** arg_list, int count)
|
|||
{
|
||||
nVert=tri->patch.edges[nEdge].vec12;
|
||||
}
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -919,6 +939,8 @@ get_edge_vect2_cf(Value** arg_list, int count)
|
|||
{
|
||||
nVert=tri->patch.edges[nEdge].vec21;
|
||||
}
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -961,6 +983,8 @@ get_edge_vert1_cf(Value** arg_list, int count)
|
|||
{
|
||||
nVert=tri->patch.edges[nEdge].v1;
|
||||
}
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1004,6 +1028,8 @@ get_edge_vert2_cf(Value** arg_list, int count)
|
|||
{
|
||||
nVert=tri->patch.edges[nEdge].v2;
|
||||
}
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1050,6 +1076,8 @@ get_sel_edge_cf(Value** arg_list, int count)
|
|||
array->append(Integer::intern(i+1));
|
||||
//array->data[j++]=;
|
||||
}
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1158,6 +1186,8 @@ set_tile_steps_cf(Value** arg_list, int count)
|
|||
nTess=5;
|
||||
tri->rpatch->rTess.TileTesselLevel=nTess;
|
||||
tri->rpatch->InvalidateChannels (PART_ALL);
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
}
|
||||
if (bRet)
|
||||
{
|
||||
|
|
|
@ -755,6 +755,7 @@ class EditPatchMod : public Modifier, IPatchOps, IPatchSelect, ISubMtlAPI, Attac
|
|||
TCHAR *GetObjectName() { return GetString(IDS_TH_EDITPATCH); }
|
||||
void ActivateSubobjSel(int level, XFormModes& modes );
|
||||
int NeedUseSubselButton() { return 0; }
|
||||
void SelectSubPatch(int index);
|
||||
void SelectSubComponent( HitRecord *hitRec, BOOL selected, BOOL all, BOOL invert );
|
||||
void ClearSelection(int selLevel);
|
||||
void SelectAll(int selLevel);
|
||||
|
|
|
@ -84,6 +84,31 @@
|
|||
*> Copyright(c) 1994, All Rights Reserved.
|
||||
**********************************************************************/
|
||||
#include "stdafx.h"
|
||||
|
||||
#if MAX_VERSION_MAJOR >= 14
|
||||
# include <maxscript/maxscript.h>
|
||||
# include <maxscript/foundation/3dmath.h>
|
||||
# include <maxscript/foundation/numbers.h>
|
||||
# include <maxscript/maxwrapper/maxclasses.h>
|
||||
# include <maxscript/foundation/streams.h>
|
||||
# include <maxscript/foundation/mxstime.h>
|
||||
# include <maxscript/maxwrapper/mxsobjects.h>
|
||||
# include <maxscript/compiler/parser.h>
|
||||
# include <maxscript/macros/define_instantiation_functions.h>
|
||||
#else
|
||||
# include <MaxScrpt/maxscrpt.h>
|
||||
# include <MaxScrpt/3dmath.h>
|
||||
// Various MAX and MXS includes
|
||||
# include <MaxScrpt/Numbers.h>
|
||||
# include <MaxScrpt/MAXclses.h>
|
||||
# include <MaxScrpt/Streams.h>
|
||||
# include <MaxScrpt/MSTime.h>
|
||||
# include <MaxScrpt/MAXObj.h>
|
||||
# include <MaxScrpt/Parser.h>
|
||||
// define the new primitives using macros from SDK
|
||||
# include <MaxScrpt/definsfn.h>
|
||||
#endif
|
||||
|
||||
#include "editpat.h"
|
||||
#include "../nel_patch_lib/vertex_neighborhood.h"
|
||||
|
||||
|
@ -855,3 +880,67 @@ void ResetVert (PatchMesh *patch)
|
|||
patch->computeInteriors();
|
||||
patch->InvalidateGeomCache ();
|
||||
}
|
||||
|
||||
def_visible_primitive(turn_patch, "RykolTurnPatch");
|
||||
|
||||
Value *turn_patch_cf (Value** arg_list, int count)
|
||||
{
|
||||
// Make sure we have the correct number of arguments (2)
|
||||
check_arg_count(RykolTurnPatch, 3, count);
|
||||
|
||||
// Check to see if the arguments match up to what we expect
|
||||
// We want to use 'TurnAllTexturesOn <object to use>'
|
||||
type_check(arg_list[0], MAXNode, "RykolTurnPatch [Node] [Modifier] [Patch]");
|
||||
type_check(arg_list[1], MAXModifier, "RykolTurnPatch [Node] [Modifier] [Patch]");
|
||||
type_check(arg_list[2], Integer, "RykolTurnPatch [Node] [Modifier] [Patch]");
|
||||
|
||||
// Get a good interface pointer
|
||||
Interface *ip = MAXScript_interface;
|
||||
|
||||
// Get a INode pointer from the argument passed to us
|
||||
INode *node = arg_list[0]->to_node();
|
||||
nlassert (node);
|
||||
|
||||
// Get a Object pointer
|
||||
ObjectState os = node->EvalWorldState(ip->GetTime());
|
||||
|
||||
// ok ?
|
||||
bool bRet=false;
|
||||
|
||||
if (os.obj)
|
||||
{
|
||||
// Get class id
|
||||
if (os.obj->CanConvertToType(RYKOLPATCHOBJ_CLASS_ID))
|
||||
{
|
||||
bRet = true;
|
||||
RPO *tri = (RPO *)os.obj->ConvertToType(ip->GetTime(), RYKOLPATCHOBJ_CLASS_ID);
|
||||
if (tri)
|
||||
{
|
||||
Modifier *mod = arg_list[1]->to_modifier();
|
||||
if (mod)
|
||||
{
|
||||
EditPatchMod *epmod = (EditPatchMod *)mod;
|
||||
epmod->ClearSelection(EP_PATCH);
|
||||
epmod->SelectSubPatch(arg_list[2]->to_int() - 1);
|
||||
epmod->DoPatchTurn(true);
|
||||
epmod->ClearSelection(EP_PATCH);
|
||||
}
|
||||
else
|
||||
{
|
||||
bRet = false;
|
||||
}
|
||||
}
|
||||
// Note that the TriObject should only be deleted
|
||||
// if the pointer to it is not equal to the object
|
||||
// pointer that called ConvertToType()
|
||||
if (os.obj != tri)
|
||||
delete tri;
|
||||
|
||||
// redraw and update
|
||||
node->NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE);
|
||||
ip->RedrawViews(ip->GetTime());
|
||||
}
|
||||
}
|
||||
|
||||
return bRet?&true_value:&false_value;
|
||||
}
|
|
@ -236,6 +236,50 @@ void EditPatchMod::SetSelLevel(DWORD level)
|
|||
|
||||
// ------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void EditPatchMod::SelectSubPatch(int index)
|
||||
{
|
||||
if (!ip)
|
||||
return;
|
||||
TimeValue t = ip->GetTime();
|
||||
|
||||
ip->ClearCurNamedSelSet();
|
||||
|
||||
ModContextList mcList;
|
||||
INodeTab nodes;
|
||||
ip->GetModContexts(mcList, nodes);
|
||||
|
||||
for (int i = 0; i < mcList.Count(); i++)
|
||||
{
|
||||
EditPatchData *patchData =(EditPatchData*)mcList[i]->localData;
|
||||
|
||||
if (!patchData)
|
||||
return;
|
||||
|
||||
RPatchMesh *rpatch;
|
||||
PatchMesh *patch = patchData->TempData(this)->GetPatch(t, rpatch);
|
||||
if (!patch)
|
||||
return;
|
||||
|
||||
patchData->BeginEdit(t);
|
||||
if (theHold.Holding())
|
||||
theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "SelectSubComponent"));
|
||||
|
||||
patch->patchSel.Set(index);
|
||||
|
||||
patchData->UpdateChanges(patch, rpatch, FALSE);
|
||||
if (patchData->tempData)
|
||||
{
|
||||
patchData->tempData->Invalidate(PART_SELECT);
|
||||
}
|
||||
}
|
||||
PatchSelChanged();
|
||||
|
||||
UpdateSelectDisplay();
|
||||
NotifyDependents(FOREVER, PART_SELECT, REFMSG_CHANGE);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Select a subcomponent within our object(s). WARNING! Because the HitRecord list can
|
||||
// indicate any of the objects contained within the group of patches being edited, we need
|
||||
// to watch for control breaks in the patchData pointer within the HitRecord!
|
||||
|
|
|
@ -176,6 +176,7 @@ LockBorders = KeyL;
|
|||
ZoomIn = Key1;
|
||||
ZoomOut = Key2;
|
||||
GetState = Key3;
|
||||
ResetPatch = KeyF10;
|
||||
|
||||
/***************
|
||||
*This is the the light settings
|
||||
|
|
|
@ -145,7 +145,7 @@ std::vector<CZoneSymmetrisation> symVector;
|
|||
|
||||
// Painter modes
|
||||
enum TModePaint { ModeTile, ModeColor, ModeDisplace};
|
||||
enum TModeMouse { ModePaint, ModeSelect, ModePick, ModeFill, ModeGetState };
|
||||
enum TModeMouse { ModePaint, ModeSelect, ModePick, ModeFill, ModeGetState, ModeResetPatch };
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
|
@ -2585,6 +2585,13 @@ void mainproc(CScene& scene, CEventListenerAsync& AsyncListener, CEvent3dMouseLi
|
|||
// Set mode
|
||||
modeSelect=ModeGetState;
|
||||
|
||||
// Mode reset zone
|
||||
if (AsyncListener.isKeyDown ((TKey)PainterKeys[ResetPatch]))
|
||||
{
|
||||
// Set mode
|
||||
modeSelect=ModeResetPatch;
|
||||
}
|
||||
|
||||
// Mode picking
|
||||
if (AsyncListener.isKeyDown ((TKey)PainterKeys[Fill0]))
|
||||
{
|
||||
|
@ -2891,6 +2898,8 @@ void mainproc(CScene& scene, CEventListenerAsync& AsyncListener, CEvent3dMouseLi
|
|||
SetCursor (bankCont->HFill);
|
||||
else if (pData->pobj->TileTrick)
|
||||
SetCursor (bankCont->HTrick);
|
||||
else if (modeSelect==ModeResetPatch)
|
||||
SetCursor (LoadCursor (NULL, IDC_NO));
|
||||
else
|
||||
SetCursor (LoadCursor (NULL, IDC_ARROW));
|
||||
|
||||
|
@ -3034,7 +3043,7 @@ private:
|
|||
// Callback on mouse events
|
||||
virtual void operator ()(const CEvent& event)
|
||||
{
|
||||
if (event==EventDestroyWindowId)
|
||||
if (event==EventDestroyWindowId || event==EventCloseWindowId)
|
||||
{
|
||||
WindowActive=false;
|
||||
}
|
||||
|
@ -3140,9 +3149,30 @@ private:
|
|||
_FillTile.fillColor (mesh1, patch, _VectMesh, maxToNel (color1), (uint16)(256.f*opa1), PaintColor);
|
||||
|
||||
else if (nModeTexture==ModeDisplace)
|
||||
// Fill this patch with the current color
|
||||
// Fill this patch with the current displace
|
||||
_FillTile.fillDisplace (mesh1, patch, _VectMesh, bank);
|
||||
}
|
||||
else if (modeSelect==ModeResetPatch)
|
||||
{
|
||||
int np = _VectMesh[mesh1].PMesh->numPatches;
|
||||
for (int pp = 0; pp < np; ++pp)
|
||||
{
|
||||
// Fill default tile
|
||||
_FillTile.fillTile (mesh1, pp, _VectMesh, -1, 0, 0, true, bank);
|
||||
|
||||
// Fill default color
|
||||
_FillTile.fillColor (mesh1, pp, _VectMesh, CRGBA(255, 255, 255), 256, PaintColor);
|
||||
|
||||
// Backup current displace, fill default, restore
|
||||
int bkdt = _Pobj->DisplaceTile;
|
||||
int bkdts = _Pobj->DisplaceTileSet;
|
||||
_Pobj->DisplaceTile = 0;
|
||||
_Pobj->DisplaceTileSet = -1;
|
||||
_FillTile.fillDisplace (mesh1, pp, _VectMesh, bank);
|
||||
_Pobj->DisplaceTile = bkdt;
|
||||
_Pobj->DisplaceTileSet = bkdts;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Pick with right mouse
|
||||
|
@ -4095,7 +4125,7 @@ DWORD WINAPI myThread (LPVOID vData)
|
|||
|
||||
// Create a Landscape.
|
||||
CLandscapeModel *TheLand= (CLandscapeModel*)CNELU::Scene->createModel(LandscapeModelId);
|
||||
TheLand->Landscape.setTileNear (1000.f);
|
||||
TheLand->Landscape.setTileNear (10000.f);
|
||||
TheLand->Landscape.TileBank=bank;
|
||||
|
||||
// Enbable automatique lighting
|
||||
|
@ -4192,7 +4222,7 @@ DWORD WINAPI myThread (LPVOID vData)
|
|||
mat.setPos(P);
|
||||
CNELU::Camera->setTransformMode (ITransformable::DirectMatrix);
|
||||
CNELU::Camera->setMatrix (mat);
|
||||
CNELU::Camera->setPerspective( 75.f*(float)Pi/180.f/*vp->GetFOV()*/, 1.33f, 0.1f, 1000.f);
|
||||
CNELU::Camera->setPerspective( 75.f*(float)Pi/180.f/*vp->GetFOV()*/, 1.33f, 0.1f, 10000.f);
|
||||
|
||||
// Resize the sym vector
|
||||
symVector.resize (pData->VectMesh.size());
|
||||
|
@ -4257,6 +4287,7 @@ DWORD WINAPI myThread (LPVOID vData)
|
|||
CNELU::EventServer.addListener (EventMouseUpId, &listener);
|
||||
CNELU::EventServer.addListener (EventMouseDblClkId, &listener);
|
||||
CNELU::EventServer.addListener (EventDestroyWindowId, &listener);
|
||||
CNELU::EventServer.addListener (EventCloseWindowId, &listener);
|
||||
CNELU::EventServer.addListener (EventKeyDownId, &listener);
|
||||
|
||||
// Camera position
|
||||
|
@ -4326,6 +4357,7 @@ DWORD WINAPI myThread (LPVOID vData)
|
|||
CNELU::EventServer.removeListener (EventMouseDblClkId, &listener);
|
||||
CNELU::EventServer.removeListener (EventKeyDownId, &listener);
|
||||
CNELU::EventServer.removeListener (EventDestroyWindowId, &listener);
|
||||
CNELU::EventServer.removeListener (EventCloseWindowId, &listener);
|
||||
|
||||
// End.
|
||||
//========
|
||||
|
|
|
@ -43,6 +43,7 @@ uint PainterKeys[KeyCounter]=
|
|||
Key1,
|
||||
Key2,
|
||||
KeyI,
|
||||
KeyF10,
|
||||
};
|
||||
|
||||
// Keys
|
||||
|
@ -77,6 +78,7 @@ const char* PainterKeysName[KeyCounter]=
|
|||
"ZoomIn",
|
||||
"ZoomOut",
|
||||
"GetState",
|
||||
"ResetPatch",
|
||||
};
|
||||
|
||||
// Light settings
|
||||
|
|
|
@ -122,6 +122,7 @@ enum PainterKeysType
|
|||
ZoomIn,
|
||||
ZoomOut,
|
||||
GetState,
|
||||
ResetPatch,
|
||||
KeyCounter
|
||||
};
|
||||
|
||||
|
|
124
code/nel/tools/3d/plugin_max/scripts/nel_orient_zones.ms
Normal file
124
code/nel/tools/3d/plugin_max/scripts/nel_orient_zones.ms
Normal file
|
@ -0,0 +1,124 @@
|
|||
|
||||
gc()
|
||||
nodes = getCurrentSelection()
|
||||
max select none
|
||||
clearselection()
|
||||
|
||||
undo off
|
||||
(
|
||||
for cnode in nodes do
|
||||
(
|
||||
if (classof cnode) == Editable_Patch or (classof cnode) == RklPatch then
|
||||
(
|
||||
print cnode.name
|
||||
selectmore cnode
|
||||
if (classof cnode) == Editable_Patch and (classof cnode) != RklPatch then
|
||||
(
|
||||
modPanel.addModToSelection (NeL_Convert ()) ui:on
|
||||
)
|
||||
modPanel.addModToSelection (NeL_Edit ()) ui:on
|
||||
setCommandPanelTaskMode #modify
|
||||
cmod = modpanel.getCurrentObject()
|
||||
pcount = (GetRykolPatchCount cnode)
|
||||
print pcount
|
||||
for p = 1 to pcount do
|
||||
(
|
||||
--print p
|
||||
vbegin = (NeLGetPatchVertex cnode p 1)
|
||||
vend = (NeLGetPatchVertex cnode p 2)
|
||||
vref = (NeLGetPatchVertex cnode p 3)
|
||||
begin = (GetRykolVertexPos cnode vbegin)
|
||||
end = (GetRykolVertexPos cnode vend)
|
||||
ref = (GetRykolVertexPos cnode vref)
|
||||
normal = (cross (end - begin) (ref - begin))
|
||||
normal = (normalize normal)
|
||||
|
||||
rotnormal = (point3 0 0 0)
|
||||
if (normal.z > 0.9) then
|
||||
(
|
||||
--print "x normal"
|
||||
rotnormal = (normal * (rotateXMatrix -90))
|
||||
)
|
||||
else
|
||||
(
|
||||
normal.z = 0
|
||||
normal = (normalize normal)
|
||||
rotnormal = (normal * (rotateZMatrix -90))
|
||||
)
|
||||
--print rotnormal
|
||||
|
||||
-- print normal
|
||||
-- print rotnormal
|
||||
-- print begin
|
||||
-- print end
|
||||
dir = (normalize (end - begin))
|
||||
-- print dir
|
||||
score1 = (dot dir rotnormal)
|
||||
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
vbegin = (NeLGetPatchVertex cnode p 1)
|
||||
vend = (NeLGetPatchVertex cnode p 2)
|
||||
begin = (GetRykolVertexPos cnode vbegin)
|
||||
end = (GetRykolVertexPos cnode vend)
|
||||
dir = (normalize (end - begin))
|
||||
score2 = (dot dir rotnormal)
|
||||
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
vbegin = (NeLGetPatchVertex cnode p 1)
|
||||
vend = (NeLGetPatchVertex cnode p 2)
|
||||
begin = (GetRykolVertexPos cnode vbegin)
|
||||
end = (GetRykolVertexPos cnode vend)
|
||||
dir = (normalize (end - begin))
|
||||
score3 = (dot dir rotnormal)
|
||||
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
vbegin = (NeLGetPatchVertex cnode p 1)
|
||||
vend = (NeLGetPatchVertex cnode p 2)
|
||||
begin = (GetRykolVertexPos cnode vbegin)
|
||||
end = (GetRykolVertexPos cnode vend)
|
||||
dir = (normalize (end - begin))
|
||||
score4 = (dot dir rotnormal)
|
||||
|
||||
-- print score1
|
||||
-- print score2
|
||||
-- print score3
|
||||
-- print score4
|
||||
|
||||
if (score1 > score2 and score1 > score3 and score1 > score4) then
|
||||
(
|
||||
-- print "score 1"
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
)
|
||||
else if (score2 > score3 and score2 > score4) then
|
||||
(
|
||||
-- print "score 2"
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
)
|
||||
else if (score3 > score4) then
|
||||
(
|
||||
-- print "score 3"
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
RykolTurnPatch cnode cmod (p)
|
||||
)
|
||||
else
|
||||
(
|
||||
-- print "score 4"
|
||||
)
|
||||
)
|
||||
maxOps.CollapseNode cnode off
|
||||
max select none
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
max select none
|
||||
clearselection()
|
||||
undo off
|
||||
(
|
||||
for cnode in nodes do
|
||||
(
|
||||
selectmore cnode
|
||||
)
|
||||
)
|
68
code/nel/tools/3d/plugin_max/scripts/nel_zone_namer.ms
Normal file
68
code/nel/tools/3d/plugin_max/scripts/nel_zone_namer.ms
Normal file
|
@ -0,0 +1,68 @@
|
|||
-- This script sets proper centered zone positions and generates their names
|
||||
-- Use after cutting the zone into 160m by 160m pieces
|
||||
|
||||
cell_size = 160.0
|
||||
offset_x = 7680 / 2
|
||||
offset_y = -(20480 + (5120 / 2))
|
||||
|
||||
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
-- http://proofofprogress.blogspot.be/2011/03/solution-align-pivot-to-world-without.html
|
||||
Function alignPivotToWorld &theObject = (
|
||||
--VLM = Visible Local Matrix.
|
||||
--The matrix/pivot you see when selecting object and "Local" axis is selected as viewable.
|
||||
VLM = theObject.Transform;
|
||||
IP_LocalRot = theObject.objectOffsetRot; --Rotation to be used later.
|
||||
IP_LOCAL = theObject.objectOffsetPos; --Invisible Pivot Local coordinates
|
||||
--In relation to VLM matrix.
|
||||
IP_WORLD = IP_LOCAL * VLM; --World Coordinates of Invisible Pivot. [Local To World Transform]
|
||||
VLM_0 = matrix3 1; --Reset Visible Local matrix coordinates.
|
||||
|
||||
NEW_IP_LOCAL = IP_WORLD * inverse(VLM_0); --[World To local Transform]
|
||||
|
||||
theObject.Transform = VLM_0;
|
||||
theObject.objectOffsetPos = NEW_IP_LOCAL;
|
||||
|
||||
--Now Handle Rotation:
|
||||
--Since rotation of visible local matrix has been zeroed out,
|
||||
--You must add that loss to the invisible pivot rotation.
|
||||
GeomWorldRot = VLM.RotationPart + IP_LocalRot;
|
||||
theObject.objectOffsetRot = GeomWorldRot;
|
||||
)
|
||||
|
||||
-- Convert a coordinate in a name
|
||||
-- name = coordToName #(x, y)
|
||||
fn coordToName coord =
|
||||
(
|
||||
up = floor(coord[1] / 26) + 1
|
||||
down = floor(coord[1] - ((up-1) * 26)) + 1
|
||||
return (((-coord[2] + 1) as integer) as string) + "_" + alphabet[up] + alphabet[down]
|
||||
)
|
||||
|
||||
fn realCoordToName coord =
|
||||
(
|
||||
return coordToName(#(((coord[1] + offset_x) / cell_size) + 0.5, ((coord[2] + offset_y) / cell_size) + 0.5))
|
||||
)
|
||||
|
||||
fn roundedCoord coord =
|
||||
(
|
||||
return #(ceil(coord[1] / cell_size) * cell_size - (cell_size / 2), ceil(coord[2] / cell_size) * cell_size - (cell_size / 2))
|
||||
)
|
||||
|
||||
max select none
|
||||
clearselection()
|
||||
|
||||
for node in geometry do
|
||||
(
|
||||
if (classof node) == RklPatch or (classof node) == Editable_Patch then
|
||||
(
|
||||
newcoords = roundedCoord(#(node.center.x, node.center.y))
|
||||
newname = realCoordToName(newcoords)
|
||||
node.name = newname
|
||||
alignPivotToWorld &node
|
||||
node.pivot.x = newcoords[1]
|
||||
node.pivot.y = newcoords[2]
|
||||
resetxform node
|
||||
maxOps.CollapseNode node off
|
||||
)
|
||||
)
|
162
code/nel/tools/3d/plugin_max/scripts/nel_zone_snapshot.ms
Normal file
162
code/nel/tools/3d/plugin_max/scripts/nel_zone_snapshot.ms
Normal file
|
@ -0,0 +1,162 @@
|
|||
-- Use to take the snapshots of a large manually created zone
|
||||
|
||||
from_x = 160
|
||||
size_x = 7680-320
|
||||
from_y = -25600+160
|
||||
size_y = 5120-320
|
||||
|
||||
targetdir = "W:/database/landscape/ligo/asteroids/max"
|
||||
snapshotdir = "W:/database/landscape/ligo/asteroids/zonebitmaps"
|
||||
zonename = "anne"
|
||||
resumeonly = true
|
||||
|
||||
cell_size = 160.0
|
||||
|
||||
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
fn lowercase instring = -- beginning of function definition
|
||||
(
|
||||
local upper, lower, outstring -- declare variables as local
|
||||
upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ" -- set variables to literals
|
||||
lower="abcdefghijklmnopqrstuvwxyz"
|
||||
outstring=copy instring
|
||||
for i=1 to outstring.count do
|
||||
(
|
||||
j=findString upper outstring[i]
|
||||
if (j != undefined) do outstring[i]=lower[j]
|
||||
)
|
||||
return outstring -- value of outstring will be returned as function result
|
||||
)
|
||||
|
||||
fn existFile fname = (getfiles fname).count != 0
|
||||
|
||||
-- Convert a coordinate in a name
|
||||
-- name = coordToName #(x, y)
|
||||
fn coordToName coord =
|
||||
(
|
||||
up = floor(coord[1] / 26) + 1
|
||||
down = floor(coord[1] - ((up-1) * 26)) + 1
|
||||
return (((-coord[2] + 1) as integer) as string) + "_" + alphabet[up] + alphabet[down]
|
||||
)
|
||||
|
||||
fn roundedCoord coord =
|
||||
(
|
||||
return #(ceil(coord[1] / cell_size) * cell_size - (cell_size / 2), ceil(coord[2] / cell_size) * cell_size - (cell_size / 2))
|
||||
)
|
||||
|
||||
fn coordId coord =
|
||||
(
|
||||
coordr = (roundedCoord coord)
|
||||
return #(((coordr[1]) / cell_size) + 0.5, ((coordr[2]) / cell_size) + 0.5)
|
||||
)
|
||||
|
||||
from_coord = (coordId #(from_x, from_y))
|
||||
to_coord = (coordId #(from_x + size_x, from_y + size_y))
|
||||
|
||||
print from_coord
|
||||
print to_coord
|
||||
|
||||
print (coordToName from_coord)
|
||||
|
||||
undo off
|
||||
(
|
||||
for x=from_coord[1] to to_coord[1] do
|
||||
(
|
||||
for y=from_coord[2] to to_coord[2] do
|
||||
(
|
||||
ny=y+1
|
||||
sy=y-1
|
||||
ex=x+1
|
||||
wx=x-1
|
||||
zc = coordToName #(x, y)
|
||||
zn = coordToName #(x, ny)
|
||||
zne = coordToName #(ex, ny)
|
||||
ze = coordToName #(ex, y)
|
||||
zse = coordToName #(ex, sy)
|
||||
zs = coordToName #(x, sy)
|
||||
zsw = coordToName #(wx, sy)
|
||||
zw = coordToName #(wx, y)
|
||||
znw = coordToName #(wx, ny)
|
||||
maxc = targetdir + "/zonematerial-" + zonename + "-" + (lowercase zc) + ".max"
|
||||
csnapfile = snapshotdir + "/" + zonename + "-" + (lowercase zc) + ".tga"
|
||||
if existFile maxc and (not resumeonly or not (existFile csnapfile)) then
|
||||
(
|
||||
print zc
|
||||
resetMAXFile #noprompt
|
||||
gc()
|
||||
mergeMAXFile maxc #(zc)
|
||||
ccenter = getnodebyname zc
|
||||
maxn = targetdir + "/zonematerial-" + zonename + "-" + (lowercase zn) + ".max"
|
||||
if existFile maxn then
|
||||
(
|
||||
mergeMAXFile maxn #(zn)
|
||||
cnode = getnodebyname zn
|
||||
cnode.position.y = cnode.position.y + 160
|
||||
NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
maxne = targetdir + "/zonematerial-" + zonename + "-" + (lowercase zne) + ".max"
|
||||
if existFile maxne then
|
||||
(
|
||||
mergeMAXFile maxne #(zne)
|
||||
cnode = getnodebyname zne
|
||||
cnode.position.x = cnode.position.x + 160
|
||||
cnode.position.y = cnode.position.y + 160
|
||||
NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
maxe = targetdir + "/zonematerial-" + zonename + "-" + (lowercase ze) + ".max"
|
||||
if existFile maxe then
|
||||
(
|
||||
mergeMAXFile maxe #(ze)
|
||||
cnode = getnodebyname ze
|
||||
cnode.position.x = cnode.position.x + 160
|
||||
NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
maxse = targetdir + "/zonematerial-" + zonename + "-" + (lowercase zse) + ".max"
|
||||
if existFile maxse then
|
||||
(
|
||||
mergeMAXFile maxse #(zse)
|
||||
cnode = getnodebyname zse
|
||||
cnode.position.x = cnode.position.x + 160
|
||||
cnode.position.y = cnode.position.y - 160
|
||||
NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
maxs = targetdir + "/zonematerial-" + zonename + "-" + (lowercase zs) + ".max"
|
||||
if existFile maxs then
|
||||
(
|
||||
mergeMAXFile maxs #(zs)
|
||||
cnode = getnodebyname zs
|
||||
cnode.position.y = cnode.position.y - 160
|
||||
NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
maxsw = targetdir + "/zonematerial-" + zonename + "-" + (lowercase zsw) + ".max"
|
||||
if existFile maxsw then
|
||||
(
|
||||
mergeMAXFile maxsw #(zsw)
|
||||
cnode = getnodebyname zsw
|
||||
cnode.position.x = cnode.position.x - 160
|
||||
cnode.position.y = cnode.position.y - 160
|
||||
--NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
maxw = targetdir + "/zonematerial-" + zonename + "-" + (lowercase zw) + ".max"
|
||||
if existFile maxw then
|
||||
(
|
||||
mergeMAXFile maxw #(zw)
|
||||
cnode = getnodebyname zw
|
||||
cnode.position.x = cnode.position.x - 160
|
||||
NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
maxnw = targetdir + "/zonematerial-" + zonename + "-" + (lowercase znw) + ".max"
|
||||
if existFile maxnw then
|
||||
(
|
||||
mergeMAXFile maxnw #(znw)
|
||||
cnode = getnodebyname znw
|
||||
cnode.position.x = cnode.position.x - 160
|
||||
cnode.position.y = cnode.position.y + 160
|
||||
NeLAttachPatchMesh cnode ccenter
|
||||
)
|
||||
NeLWeldPatchMesh ccenter 1.0
|
||||
NeLLigoMakeSnapShot ccenter csnapfile 0 1 0 1 false
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
|
@ -885,7 +885,7 @@ void Browse::OnChangeVariety()
|
|||
void Browse::OnBatchLoad ()
|
||||
{
|
||||
CFileDialog sFile (true, NULL, NULL, OFN_ENABLESIZING,
|
||||
"Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||",NULL);
|
||||
"PNG Bitmap (*.png)|*.png|Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||",NULL);
|
||||
|
||||
if (sFile.DoModal()==IDOK)
|
||||
{
|
||||
|
@ -1365,7 +1365,7 @@ void Browse::OnExportBorder()
|
|||
{
|
||||
// Select a file
|
||||
CFileDialog sFile (false, NULL, NULL, OFN_ENABLESIZING,
|
||||
"Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||",NULL);
|
||||
"PNG Bitmap (*.png)|*.png|Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||",NULL);
|
||||
if (sFile.DoModal()==IDOK)
|
||||
{
|
||||
// Get the border of the bank
|
||||
|
@ -1431,7 +1431,7 @@ void Browse::OnImportBorder()
|
|||
{
|
||||
// Select a file
|
||||
CFileDialog sFile (true, NULL, NULL, OFN_ENABLESIZING,
|
||||
"Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||",NULL);
|
||||
"PNG Bitmap (*.png)|*.png|Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||",NULL);
|
||||
if (sFile.DoModal()==IDOK)
|
||||
{
|
||||
// Get the border of the bank
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FILE(GLOB SRC *.cpp *.h PIC/*.cpp PIC/*.h)
|
||||
FILE(GLOB SRC *.cpp *.h)
|
||||
|
||||
FILE(GLOB SRC2 cpu.cpp DllEntry.cpp Popup.* thread_win32.* TileCtrl.* TileList.* TileView.*)
|
||||
LIST(REMOVE_ITEM SRC ${SRC2})
|
||||
|
|
|
@ -1,126 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#define PIC_ERRSIZE 256
|
||||
|
||||
static unsigned long PIC_Sys_MEM_Allocated;
|
||||
static unsigned long PIC_Sys_MEM_NbAllocs;
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void *Pic_malloc(unsigned long size)
|
||||
{
|
||||
void *mem;
|
||||
mem=malloc(size);
|
||||
if (mem)
|
||||
{
|
||||
PIC_Sys_MEM_Allocated+=size;
|
||||
PIC_Sys_MEM_NbAllocs++;
|
||||
}
|
||||
return(mem);
|
||||
}
|
||||
// -----
|
||||
void *Pic_calloc(unsigned long count, unsigned long size)
|
||||
{
|
||||
void *mem;
|
||||
mem=calloc(count,size);
|
||||
if (mem)
|
||||
{
|
||||
PIC_Sys_MEM_Allocated+=(size*count);
|
||||
PIC_Sys_MEM_NbAllocs++;
|
||||
}
|
||||
return(mem);
|
||||
}
|
||||
// -----
|
||||
void Pic_free(void *memblock)
|
||||
{
|
||||
unsigned long size;
|
||||
size=(unsigned long)_msize(memblock);
|
||||
PIC_Sys_MEM_Allocated-=size;
|
||||
PIC_Sys_MEM_NbAllocs--;
|
||||
free(memblock);
|
||||
}
|
||||
// -----
|
||||
unsigned long Pic__msize(void *memblock)
|
||||
{
|
||||
return(unsigned long)(_msize(memblock));
|
||||
}
|
||||
// -----
|
||||
unsigned long PIC_GetMemNbAllocs(void)
|
||||
{
|
||||
return(PIC_Sys_MEM_NbAllocs);
|
||||
}
|
||||
// -----
|
||||
unsigned long PIC_GetMemAllocated(void)
|
||||
{
|
||||
return(PIC_Sys_MEM_Allocated);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
static char PIC_ErrorFlag;
|
||||
static char PIC_ErrorString[PIC_ERRSIZE];
|
||||
static unsigned char PIC_Sys_FnctActive=0;
|
||||
static void (*PIC_Sys_Fnct)(void);
|
||||
|
||||
void Pic_SetError(const char *msg, ...)
|
||||
{
|
||||
char curerr[PIC_ERRSIZE],olderr[PIC_ERRSIZE];
|
||||
va_list args;
|
||||
|
||||
va_start(args,msg);
|
||||
vsprintf(curerr,msg,args);
|
||||
va_end(args);
|
||||
if ( (strlen(curerr)+strlen(PIC_ErrorString))>PIC_ERRSIZE ) return;
|
||||
|
||||
if (PIC_ErrorFlag)
|
||||
{
|
||||
strcpy(olderr,PIC_ErrorString);
|
||||
sprintf(PIC_ErrorString,"--- [PIC#%03d] :\n%s",PIC_ErrorFlag,curerr);
|
||||
strcat(PIC_ErrorString,"\n");
|
||||
strcat(PIC_ErrorString,olderr);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(PIC_ErrorString,"--- [PIC#%03d] :\n%s",PIC_ErrorFlag,curerr);
|
||||
}
|
||||
PIC_ErrorFlag++;
|
||||
if (PIC_Sys_FnctActive) PIC_Sys_Fnct();
|
||||
return;
|
||||
}
|
||||
// -----
|
||||
char* PIC_GetError(void)
|
||||
{
|
||||
return(PIC_ErrorString);
|
||||
}
|
||||
// -----
|
||||
unsigned char PIC_Error(void)
|
||||
{
|
||||
return(PIC_ErrorFlag);
|
||||
}
|
||||
// -----
|
||||
void PIC_ResetError(void)
|
||||
{
|
||||
strcpy(PIC_ErrorString,"");
|
||||
PIC_ErrorFlag=0;
|
||||
}
|
||||
// -----
|
||||
unsigned char PIC_OnErrorCall( void pFnct(void) )
|
||||
{
|
||||
if (pFnct != NULL)
|
||||
{
|
||||
PIC_Sys_Fnct=pFnct;
|
||||
PIC_Sys_FnctActive=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
PIC_Sys_FnctActive=0;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
|
@ -1,215 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pic_private.h"
|
||||
#include "pic.h"
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct BMP_HEADER
|
||||
{
|
||||
unsigned short bfType;
|
||||
unsigned long bfSize;
|
||||
unsigned short Res1;
|
||||
unsigned short Res2;
|
||||
unsigned long bfOffBits;
|
||||
unsigned long biSize;
|
||||
unsigned long biWidth;
|
||||
unsigned long biHeight;
|
||||
unsigned short biPlanes;
|
||||
unsigned short biBitCount;
|
||||
unsigned long biCompression;
|
||||
unsigned long biSizeImage;
|
||||
unsigned long biXPelsPerMeter;
|
||||
unsigned long biYPelsPerMeter;
|
||||
unsigned long biClrUsed;
|
||||
unsigned long biClrImportant;
|
||||
} BMP_HEADER;
|
||||
#pragma pack()
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long Pic_BMP_Write( const char *FileName,
|
||||
char *pPal, char *pDatas,
|
||||
unsigned long w, unsigned long h, unsigned long d)
|
||||
|
||||
{
|
||||
FILE *file;
|
||||
BMP_HEADER bmph;
|
||||
unsigned long slsize;
|
||||
unsigned char *scanline;
|
||||
unsigned long i;
|
||||
long x,y,rest;
|
||||
unsigned char r,g,b;
|
||||
|
||||
file=fopen(FileName,"wb");
|
||||
if (!file)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
memset(&bmph,0,sizeof(BMP_HEADER));
|
||||
bmph.bfType=19778;
|
||||
bmph.bfSize=sizeof(BMP_HEADER);
|
||||
bmph.bfSize+=w*h*d/8;
|
||||
if (pPal)
|
||||
{
|
||||
bmph.bfSize+=(256*4);
|
||||
}
|
||||
bmph.bfOffBits=sizeof(BMP_HEADER);
|
||||
if (pPal)
|
||||
{
|
||||
bmph.bfOffBits+=(256*4);
|
||||
}
|
||||
bmph.biSize=40;//sizeof(BMP_HEADER);
|
||||
bmph.biWidth=w;
|
||||
bmph.biHeight=h;
|
||||
bmph.biPlanes=1;
|
||||
bmph.biBitCount=(unsigned short)d;
|
||||
bmph.biCompression=0;
|
||||
bmph.biSizeImage=w*h*d/8;
|
||||
|
||||
fwrite(&bmph,1,sizeof(BMP_HEADER),file);
|
||||
if (pPal)
|
||||
{
|
||||
for(i=0 ; i<256 ; i++)
|
||||
{
|
||||
fwrite(&pPal[i*3+0],1,1,file);
|
||||
fwrite(&pPal[i*3+1],1,1,file);
|
||||
fwrite(&pPal[i*3+2],1,1,file);
|
||||
fwrite(&pPal[i*3+2],1,1,file);
|
||||
}
|
||||
}
|
||||
slsize=w*d/8;
|
||||
scanline=(unsigned char*)Pic_calloc(1,slsize);
|
||||
if (!scanline)
|
||||
{
|
||||
Pic_SetError("BMP_Write, not enough memory for scanline");
|
||||
return(0);
|
||||
}
|
||||
for(rest=0 ; ((w*d/8)+rest)%4!=0 ; rest++);
|
||||
for(y=0 ; y<(long)h ; y++)
|
||||
{
|
||||
memcpy(scanline,&pDatas[(h-y-1)*slsize],slsize);
|
||||
if (d==24)
|
||||
{
|
||||
for(x=0 ; x<(long)w ; x++)
|
||||
{
|
||||
b=scanline[x*3+0];
|
||||
g=scanline[x*3+1];
|
||||
r=scanline[x*3+2];
|
||||
scanline[x*3+0]=b;
|
||||
scanline[x*3+1]=g;
|
||||
scanline[x*3+2]=r;
|
||||
}
|
||||
}
|
||||
fwrite(scanline,1,slsize,file);
|
||||
if (rest)
|
||||
{
|
||||
fwrite(scanline,1,rest,file);
|
||||
}
|
||||
}
|
||||
Pic_free(scanline);
|
||||
fclose(file);
|
||||
return(1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long Pic_BMP_Read( const char *FileName,
|
||||
char **ppPal, char **ppDatas,
|
||||
unsigned long *pWidth, unsigned long *pHeight,
|
||||
unsigned long *pDepth)
|
||||
{
|
||||
FILE *file;
|
||||
BMP_HEADER bmph;
|
||||
char *pPal;
|
||||
char *pDatas;
|
||||
unsigned char *scanline;
|
||||
long w,h,d;
|
||||
long i,x,y,rest;
|
||||
unsigned char r,g,b;
|
||||
unsigned char pad[4];
|
||||
|
||||
pPal=NULL;
|
||||
pDatas=NULL;
|
||||
file=fopen(FileName,"rb");
|
||||
if (!file)
|
||||
{
|
||||
Pic_SetError("BMP_Read, unable to open %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
fread(&bmph,1,sizeof(BMP_HEADER),file);
|
||||
*pWidth=w=bmph.biWidth;
|
||||
*pHeight=h=bmph.biHeight;
|
||||
*pDepth=d=bmph.biBitCount;
|
||||
if (d!=8 && d!=24)
|
||||
{
|
||||
Pic_SetError("BMP_Read, number of bits per pixel unsupported");
|
||||
return(0);
|
||||
}
|
||||
if (*pDepth==8)
|
||||
{
|
||||
pPal=(char*)Pic_calloc(1,256*3);
|
||||
if (!pPal)
|
||||
{
|
||||
Pic_SetError("BMP_Read, not enough memory for palette");
|
||||
return(0);
|
||||
}
|
||||
for(i=0 ; i<256 ; i++)
|
||||
{
|
||||
fread(&pPal[i*3+2],1,1,file);
|
||||
fread(&pPal[i*3+1],1,1,file);
|
||||
fread(&pPal[i*3+0],1,1,file);
|
||||
fread(&pad[0],1,1,file);
|
||||
}
|
||||
}
|
||||
pDatas=(char*)Pic_calloc(1,w*h*d/8);
|
||||
if (!pDatas)
|
||||
{
|
||||
if (pPal)
|
||||
{
|
||||
Pic_free(pPal);
|
||||
}
|
||||
Pic_SetError("BMP_Read, not enough memory for datas");
|
||||
return(0);
|
||||
}
|
||||
scanline=(unsigned char*)Pic_calloc(1,w*h*d/8);
|
||||
if (!scanline)
|
||||
{
|
||||
if (pPal)
|
||||
{
|
||||
Pic_free(pPal);
|
||||
}
|
||||
Pic_free(pDatas);
|
||||
Pic_SetError("BMP_Read, not enough memory for scanline");
|
||||
return(0);
|
||||
}
|
||||
for(rest=0 ; (w+rest)%4!=0 ; rest++);
|
||||
for(y=0 ; y<h ; y++)
|
||||
{
|
||||
fread(scanline,w,d/8,file);
|
||||
if (d==24)
|
||||
{
|
||||
for(x=0 ; x<w ; x++)
|
||||
{
|
||||
r=scanline[x*3+0];
|
||||
g=scanline[x*3+1];
|
||||
b=scanline[x*3+2];
|
||||
scanline[x*3+0]=b;
|
||||
scanline[x*3+1]=g;
|
||||
scanline[x*3+2]=r;
|
||||
}
|
||||
}
|
||||
memcpy(&pDatas[(h-y-1)*w*d/8],scanline,w*d/8);
|
||||
fread(pad,rest,d/8,file);
|
||||
}
|
||||
fclose(file);
|
||||
Pic_free(scanline);
|
||||
*ppPal=pPal;
|
||||
*ppDatas=pDatas;
|
||||
return(1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
|
@ -1,160 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <jpeglib.h>
|
||||
#include "pic_private.h"
|
||||
#include "pic.h"
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
struct my_error_mgr
|
||||
{
|
||||
struct jpeg_error_mgr pub;
|
||||
jmp_buf setjmp_buffer;
|
||||
};
|
||||
typedef struct my_error_mgr * my_error_ptr;
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
static unsigned char error;
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void my_error_exit(j_common_ptr cinfo)
|
||||
{
|
||||
my_error_ptr myerr = (my_error_ptr) cinfo->err;
|
||||
error=1;
|
||||
longjmp(myerr->setjmp_buffer, 1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long Pic_JPG_Read(const char *FileName, char **ppPal, char **ppDatas, unsigned long *w, unsigned long *h)
|
||||
{
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *file;
|
||||
JSAMPARRAY buffer;
|
||||
int row_stride,i;
|
||||
char *pDatas,*pPal;
|
||||
unsigned long ptr;
|
||||
|
||||
error=0;
|
||||
ptr=0;
|
||||
file=fopen(FileName, "rb");
|
||||
if (!file)
|
||||
{
|
||||
Pic_SetError("JPG_Read, unable to open %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
cinfo.err = jpeg_std_error(&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
setjmp(jerr.setjmp_buffer);
|
||||
if (error)
|
||||
{
|
||||
Pic_SetError("JPG_Read, internal decompression error");
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
return(0);
|
||||
}
|
||||
jpeg_create_decompress(&cinfo);
|
||||
jpeg_stdio_src(&cinfo, file);
|
||||
(void) jpeg_read_header(&cinfo, TRUE);
|
||||
*w=cinfo.image_width;
|
||||
*h=cinfo.image_height;
|
||||
if (!ppPal)
|
||||
{
|
||||
pDatas=(char*)Pic_calloc(1,(*w)*(*h)*3);
|
||||
}
|
||||
else
|
||||
{
|
||||
pDatas=(char*)Pic_calloc(1,(*w)*(*h));
|
||||
pPal=(char*)Pic_calloc(1,256*3);
|
||||
if (!pPal)
|
||||
{
|
||||
Pic_SetError("JPG_Read, not enough memory for palette");
|
||||
return(0);
|
||||
}
|
||||
cinfo.desired_number_of_colors = 256;
|
||||
cinfo.quantize_colors = TRUE;
|
||||
cinfo.dither_mode = JDITHER_ORDERED;
|
||||
}
|
||||
if (!pDatas)
|
||||
{
|
||||
Pic_SetError("JPG_Read, not enough memory for pic");
|
||||
return(0);
|
||||
}
|
||||
(void) jpeg_start_decompress(&cinfo);
|
||||
row_stride = cinfo.output_width * cinfo.output_components;
|
||||
buffer = (*cinfo.mem->alloc_sarray)
|
||||
((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
|
||||
while (cinfo.output_scanline < cinfo.output_height)
|
||||
{
|
||||
(void) jpeg_read_scanlines(&cinfo, buffer, 1);
|
||||
memcpy(&pDatas[ptr],buffer[0],row_stride);
|
||||
ptr+=row_stride;
|
||||
}
|
||||
*ppDatas=pDatas;
|
||||
if (ppPal)
|
||||
{
|
||||
for(i=0 ; i<256 ; i++)
|
||||
{
|
||||
pPal[i*3+0]=cinfo.colormap[2][i];
|
||||
pPal[i*3+1]=cinfo.colormap[1][i];
|
||||
pPal[i*3+2]=cinfo.colormap[0][i];
|
||||
}
|
||||
*ppPal=pPal;
|
||||
}
|
||||
(void) jpeg_finish_decompress(&cinfo);
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
fclose(file);
|
||||
return(1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long Pic_JPG_Write(const char *FileName, unsigned long Qual, char *pDatas, unsigned long w, unsigned long h)
|
||||
{
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *file;
|
||||
JSAMPROW row_pointer[1];
|
||||
int row_stride;
|
||||
|
||||
error=0;
|
||||
file=fopen(FileName,"wb");
|
||||
if (!file)
|
||||
{
|
||||
Pic_SetError("JPG_Write, unable to open %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
jpeg_create_compress(&cinfo);
|
||||
cinfo.err = jpeg_std_error(&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
setjmp(jerr.setjmp_buffer);
|
||||
if (error)
|
||||
{
|
||||
Pic_SetError("JPG_Write, internal compression error");
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
return(0);
|
||||
}
|
||||
jpeg_stdio_dest(&cinfo, file);
|
||||
cinfo.image_width = w;
|
||||
cinfo.image_height = h;
|
||||
cinfo.input_components = 3;
|
||||
cinfo.in_color_space = JCS_RGB;
|
||||
jpeg_set_defaults(&cinfo);
|
||||
jpeg_set_quality(&cinfo, Qual, TRUE);
|
||||
jpeg_start_compress(&cinfo, TRUE);
|
||||
row_stride = w * 3;
|
||||
while(cinfo.next_scanline<cinfo.image_height)
|
||||
{
|
||||
row_pointer[0] = (JSAMPROW)& pDatas[cinfo.next_scanline * row_stride];
|
||||
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
|
||||
}
|
||||
jpeg_finish_compress(&cinfo);
|
||||
fclose(file);
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
return(1);
|
||||
}
|
|
@ -1,637 +0,0 @@
|
|||
#include <string.h>
|
||||
#include "pic_private.h"
|
||||
#include "pic.h"
|
||||
|
||||
static unsigned long NbPics=0;
|
||||
static PIC_PICTURE *HeadPic=NULL;
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
static PIC_PICTURE *GetPic(unsigned long id)
|
||||
{
|
||||
PIC_PICTURE *pic;
|
||||
|
||||
for(pic=HeadPic ; pic ; pic=pic->Next)
|
||||
{
|
||||
if (pic->ID==id)
|
||||
{
|
||||
return(pic);
|
||||
}
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long PIC_Load(char* FileName, unsigned char Quantize)
|
||||
{
|
||||
char ext[4];
|
||||
unsigned long type;
|
||||
unsigned long i,taken,id;
|
||||
PIC_PICTURE *pic;
|
||||
char *pDatas;
|
||||
char *pPal;
|
||||
unsigned long w,h,Depth;
|
||||
unsigned long ret;
|
||||
|
||||
// --- Init
|
||||
ret=0;
|
||||
type=0;
|
||||
id=0;
|
||||
taken=0;
|
||||
w=0;
|
||||
h=0;
|
||||
Depth=0;
|
||||
pic=NULL;
|
||||
pDatas=NULL;
|
||||
pPal=NULL;
|
||||
// --- Get 1st available ID
|
||||
for(i=1 ; i<=NbPics+1 ; i++)
|
||||
{
|
||||
taken=0;
|
||||
for(pic=HeadPic ; pic ; pic=pic->Next)
|
||||
{
|
||||
if (pic->ID==i)
|
||||
{
|
||||
taken=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!taken)
|
||||
{
|
||||
id=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!id)
|
||||
{
|
||||
Pic_SetError("Load, unable to create ID");
|
||||
return(0);
|
||||
}
|
||||
// --- Load pic
|
||||
if (FileName)
|
||||
{
|
||||
ext[0]=FileName[strlen(FileName)-3];
|
||||
ext[1]=FileName[strlen(FileName)-2];
|
||||
ext[2]=FileName[strlen(FileName)-1];
|
||||
ext[3]=0;
|
||||
strupr(ext);
|
||||
if ( !strcmp(ext,"JPG") )
|
||||
{
|
||||
type=1;
|
||||
}
|
||||
else if ( !strcmp(ext,"TGA") )
|
||||
{
|
||||
type=2;
|
||||
}
|
||||
else if ( !strcmp(ext,"BMP") )
|
||||
{
|
||||
type=3;
|
||||
}
|
||||
|
||||
switch(type)
|
||||
{
|
||||
// - JPG
|
||||
case 1:
|
||||
if (!Quantize)
|
||||
{
|
||||
Depth=24;
|
||||
ret=Pic_JPG_Read(FileName,NULL,&pDatas,&w,&h);
|
||||
}
|
||||
else
|
||||
{
|
||||
Depth=8;
|
||||
ret=Pic_JPG_Read(FileName,&pPal,&pDatas,&w,&h);
|
||||
}
|
||||
if (!ret)
|
||||
{
|
||||
Pic_SetError("Load, unable to load JPG file %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
break;
|
||||
// - TGA
|
||||
case 2:
|
||||
ret=Pic_TGA_Read(FileName,&pPal,&pDatas,&w,&h,&Depth);
|
||||
if (!ret)
|
||||
{
|
||||
Pic_SetError("Load, unable to load TGA file %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
break;
|
||||
// - BMP
|
||||
case 3:
|
||||
ret=Pic_BMP_Read(FileName,&pPal,&pDatas,&w,&h,&Depth);
|
||||
if (!ret)
|
||||
{
|
||||
Pic_SetError("Load, unable to load BMP file %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
break;
|
||||
// - Unknown
|
||||
default:
|
||||
Pic_SetError("Load, unknown extension for %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Create and place new pic struct
|
||||
pic=(PIC_PICTURE *)Pic_calloc(1,sizeof(PIC_PICTURE));
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("Load, not enough memory for internal structure");
|
||||
return(0);
|
||||
}
|
||||
pic->Next=HeadPic;
|
||||
HeadPic=pic;
|
||||
NbPics++;
|
||||
pic->ID=id;
|
||||
pic->pDatas=pDatas;
|
||||
pic->pPal=pPal;
|
||||
pic->Width=w;
|
||||
pic->Height=h;
|
||||
pic->Depth=Depth;
|
||||
return(id);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long PIC_Create(char* pPal, char* pDatas, unsigned long w, unsigned long h, unsigned long d)
|
||||
{
|
||||
unsigned long i,taken,id;
|
||||
PIC_PICTURE *pic;
|
||||
|
||||
// --- Init
|
||||
id=0;
|
||||
taken=0;
|
||||
pic=NULL;
|
||||
// --- Get 1st available ID
|
||||
for(i=1 ; i<=NbPics+1 ; i++)
|
||||
{
|
||||
taken=0;
|
||||
for(pic=HeadPic ; pic ; pic=pic->Next)
|
||||
{
|
||||
if (pic->ID==i)
|
||||
{
|
||||
taken=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!taken)
|
||||
{
|
||||
id=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!id)
|
||||
{
|
||||
Pic_SetError("Create, unable to create ID");
|
||||
return(0);
|
||||
}
|
||||
// --- Create pic
|
||||
if (!pDatas)
|
||||
{
|
||||
pDatas=(char *)Pic_calloc(1,w*h*d/8);
|
||||
if (!pDatas)
|
||||
{
|
||||
Pic_SetError("Create, not enough memory for datas");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
if (d==8)
|
||||
{
|
||||
if (!pPal)
|
||||
{
|
||||
pPal=(char *)Pic_calloc(1,256*3);
|
||||
if (!pPal)
|
||||
{
|
||||
Pic_SetError("Create, not enough memory for palette");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pPal=NULL;
|
||||
}
|
||||
// --- Create and place new pic struct
|
||||
pic=(PIC_PICTURE *)Pic_calloc(1,sizeof(PIC_PICTURE));
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("Create, not enough memory for internal structure");
|
||||
return(0);
|
||||
}
|
||||
pic->Next=HeadPic;
|
||||
HeadPic=pic;
|
||||
NbPics++;
|
||||
pic->ID=id;
|
||||
pic->pDatas=pDatas;
|
||||
pic->pPal=pPal;
|
||||
pic->Width=w;
|
||||
pic->Height=h;
|
||||
pic->Depth=d;
|
||||
return(id);
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long PIC_GetInfos( unsigned long id,
|
||||
char **ppPal, char **ppDatas,
|
||||
unsigned long *pW, unsigned long *pH, unsigned long *pD)
|
||||
{
|
||||
PIC_PICTURE *pic;
|
||||
|
||||
pic=GetPic(id);
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("GetInfos, picture internal structure not found");
|
||||
return(0);
|
||||
}
|
||||
if (ppPal)
|
||||
{
|
||||
*ppPal=pic->pPal;
|
||||
}
|
||||
if (ppDatas)
|
||||
{
|
||||
*ppDatas=pic->pDatas;
|
||||
}
|
||||
if (pW)
|
||||
{
|
||||
*pW=pic->Width;
|
||||
}
|
||||
if (pH)
|
||||
{
|
||||
*pH=pic->Height;
|
||||
}
|
||||
if (pD)
|
||||
{
|
||||
*pD=pic->Depth;
|
||||
}
|
||||
return(id);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
static char* Conv8To24(unsigned long id)
|
||||
{
|
||||
PIC_PICTURE *pic;
|
||||
char *buf;
|
||||
unsigned long i;
|
||||
|
||||
pic=GetPic(id);
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("Conv8To24, picture internal structure not found");
|
||||
return(NULL);
|
||||
}
|
||||
buf=(char *)Pic_malloc(pic->Width*pic->Height*3);
|
||||
if (!buf)
|
||||
{
|
||||
Pic_SetError("Conv8To24, not enough memory for temporary buffer");
|
||||
return(NULL);
|
||||
}
|
||||
for(i=0 ; i<pic->Width*pic->Height ; i++)
|
||||
{
|
||||
buf[i*3+0]=pic->pPal[pic->pDatas[i]*3+0];
|
||||
buf[i*3+1]=pic->pPal[pic->pDatas[i]*3+1];
|
||||
buf[i*3+2]=pic->pPal[pic->pDatas[i]*3+2];
|
||||
}
|
||||
return(buf);
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
static char* Conv8To16(unsigned long id)
|
||||
{
|
||||
PIC_PICTURE *pic;
|
||||
unsigned short *buf;
|
||||
unsigned long i;
|
||||
unsigned short r,g,b,pix16;
|
||||
|
||||
pic=GetPic(id);
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("Conv8To24, picture internal structure not found");
|
||||
return(NULL);
|
||||
}
|
||||
buf=(unsigned short*)Pic_malloc(pic->Width*pic->Height*2);
|
||||
if (!buf)
|
||||
{
|
||||
Pic_SetError("Conv8To24, not enough memory for temporary buffer");
|
||||
return(NULL);
|
||||
}
|
||||
for(i=0 ; i<pic->Width*pic->Height ; i++)
|
||||
{
|
||||
b=pic->pPal[pic->pDatas[i]*3+0];
|
||||
g=pic->pPal[pic->pDatas[i]*3+1];
|
||||
r=pic->pPal[pic->pDatas[i]*3+2];
|
||||
r>>=3;
|
||||
g>>=3; g&=0x3E;
|
||||
b>>=3;
|
||||
pix16=(r<<10)+(g<<5)+b;
|
||||
buf[i]=pix16;
|
||||
}
|
||||
return (char*)buf;
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
|
||||
static char* Conv16To24(unsigned long id)
|
||||
{
|
||||
PIC_PICTURE *pic;
|
||||
unsigned short *pDatas;
|
||||
unsigned char *buf;
|
||||
unsigned long i;
|
||||
unsigned short r,g,b;
|
||||
|
||||
pic=GetPic(id);
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("Conv16To24, picture internal structure not found");
|
||||
return(NULL);
|
||||
}
|
||||
buf=(unsigned char *)Pic_malloc(pic->Width*pic->Height*3);
|
||||
if (!buf)
|
||||
{
|
||||
Pic_SetError("Conv16To24, not enough memory for temporary buffer");
|
||||
return(NULL);
|
||||
}
|
||||
pDatas=(unsigned short*)pic->pDatas;
|
||||
for(i=0 ; i<pic->Width*pic->Height ; i++)
|
||||
{
|
||||
r=(pDatas[i] & 0x7C00)>>(10-3);
|
||||
g=(pDatas[i] & 0x03E0)>>(5-3);
|
||||
b=(pDatas[i] & 0x001F)<<3;
|
||||
buf[i*3+0]=(unsigned char)r;
|
||||
buf[i*3+1]=(unsigned char)g;
|
||||
buf[i*3+2]=(unsigned char)b;
|
||||
}
|
||||
return (char*)buf;
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
|
||||
static char* Conv24To16(unsigned long id)
|
||||
{
|
||||
PIC_PICTURE *pic;
|
||||
unsigned short *buf;
|
||||
unsigned long i;
|
||||
unsigned short r,g,b;
|
||||
unsigned short pix16;
|
||||
|
||||
pic=GetPic(id);
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("Conv24To16, picture internal structure not found");
|
||||
return(NULL);
|
||||
}
|
||||
buf=(unsigned short*)Pic_malloc(pic->Width*pic->Height*2);
|
||||
if (!buf)
|
||||
{
|
||||
Pic_SetError("Conv24To16, not enough memory for temporary buffer");
|
||||
return(NULL);
|
||||
}
|
||||
for(i=0 ; i<pic->Width*pic->Height ; i++)
|
||||
{
|
||||
r=pic->pDatas[i*3+0];
|
||||
g=pic->pDatas[i*3+1];
|
||||
b=pic->pDatas[i*3+2];
|
||||
// r : 5 bits forts (0x7C)
|
||||
// g : 5 bits (6e zapped) (0x3E)
|
||||
// b : 5 bits faibles (0x1F)
|
||||
r>>=3;
|
||||
g>>=3; g&=0x3E;
|
||||
b>>=3;
|
||||
pix16=(r<<10)+(g<<5)+b;
|
||||
buf[i]=pix16;
|
||||
}
|
||||
return (char*)buf;
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
|
||||
static char* ConvPic(PIC_PICTURE *pic, unsigned long type, char* pErr)
|
||||
{
|
||||
char *buf;
|
||||
unsigned long src,dst;
|
||||
|
||||
*pErr=0;
|
||||
buf=NULL;
|
||||
src=pic->Depth;
|
||||
if (type==PIC_TYPE_TGA8 || type==PIC_TYPE_BMP8)
|
||||
{
|
||||
dst=8;
|
||||
}
|
||||
if (type==PIC_TYPE_TGA16)
|
||||
{
|
||||
dst=16;
|
||||
}
|
||||
if (type==PIC_TYPE_JPG || type==PIC_TYPE_TGA24 || type==PIC_TYPE_BMP24)
|
||||
{
|
||||
dst=24;
|
||||
}
|
||||
// ---
|
||||
if (src==dst)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
// ---
|
||||
if (src==8 && dst==24)
|
||||
{
|
||||
buf=Conv8To24(pic->ID);
|
||||
if (!buf)
|
||||
{
|
||||
*pErr=1;
|
||||
}
|
||||
return(buf);
|
||||
}
|
||||
if (src==8 && dst==16)
|
||||
{
|
||||
buf=Conv8To16(pic->ID);
|
||||
if (!buf)
|
||||
{
|
||||
*pErr=1;
|
||||
}
|
||||
return(buf);
|
||||
}
|
||||
// ---
|
||||
if (src==16 && dst==24)
|
||||
{
|
||||
buf=Conv16To24(pic->ID);
|
||||
if (!buf)
|
||||
{
|
||||
*pErr=1;
|
||||
}
|
||||
return(buf);
|
||||
}
|
||||
// ---
|
||||
if (src==24 && dst==16)
|
||||
{
|
||||
buf=Conv24To16(pic->ID);
|
||||
if (!buf)
|
||||
{
|
||||
*pErr=1;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
// ---
|
||||
if (src==24 && dst==8)
|
||||
{
|
||||
Pic_SetError("ConvPic, downsampling 24 to 8 bits unsupported");
|
||||
*pErr=1;
|
||||
return(NULL);
|
||||
}
|
||||
Pic_SetError("ConvPic, conversion %d to %d unsupported",src,dst);
|
||||
*pErr=1;
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
|
||||
unsigned long PIC_Save(unsigned long id, char* FileName, unsigned long type, unsigned long qual)
|
||||
{
|
||||
PIC_PICTURE *pic;
|
||||
char err;
|
||||
char *buf;
|
||||
char *freeit;
|
||||
unsigned long depth;
|
||||
|
||||
freeit=NULL;
|
||||
pic=GetPic(id);
|
||||
if (!pic)
|
||||
{
|
||||
Pic_SetError("Save %s, picture internal structure not found",FileName);
|
||||
return(0);
|
||||
}
|
||||
freeit = ConvPic(pic,type,&err);
|
||||
if (err)
|
||||
{
|
||||
Pic_SetError("Save %s, error while converting picture",FileName);
|
||||
return(0);
|
||||
}
|
||||
if (!freeit)
|
||||
{
|
||||
buf=pic->pDatas;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf=freeit;
|
||||
}
|
||||
err=0;
|
||||
switch(type)
|
||||
{
|
||||
// ---
|
||||
case PIC_TYPE_JPG:
|
||||
if ( !Pic_JPG_Write(FileName,qual,buf,pic->Width,pic->Height) )
|
||||
{
|
||||
if (freeit)
|
||||
{
|
||||
Pic_free(buf);
|
||||
}
|
||||
Pic_SetError("Save %s, error while saving JPG file",FileName);
|
||||
err=1;
|
||||
}
|
||||
break;
|
||||
// ---
|
||||
case PIC_TYPE_TGA8:
|
||||
case PIC_TYPE_TGA16:
|
||||
case PIC_TYPE_TGA24:
|
||||
if (type==PIC_TYPE_TGA8)
|
||||
{
|
||||
depth=8;
|
||||
}
|
||||
if (type==PIC_TYPE_TGA16)
|
||||
{
|
||||
depth=16;
|
||||
}
|
||||
if (type==PIC_TYPE_TGA24)
|
||||
{
|
||||
depth=24;
|
||||
}
|
||||
if ( !Pic_TGA_Write(FileName,pic->pPal,buf,pic->Width,pic->Height,depth) )
|
||||
{
|
||||
if (freeit)
|
||||
{
|
||||
Pic_free(freeit);
|
||||
}
|
||||
Pic_SetError("Save %s, error while saving TGA file",FileName);
|
||||
err=1;
|
||||
}
|
||||
break;
|
||||
// ---
|
||||
case PIC_TYPE_BMP8:
|
||||
case PIC_TYPE_BMP24:
|
||||
if (type==PIC_TYPE_BMP8)
|
||||
{
|
||||
depth=8;
|
||||
}
|
||||
if (type==PIC_TYPE_BMP24)
|
||||
{
|
||||
depth=24;
|
||||
}
|
||||
if ( !Pic_BMP_Write(FileName,pic->pPal,buf,pic->Width,pic->Height,depth) )
|
||||
{
|
||||
if (freeit)
|
||||
{
|
||||
Pic_free(freeit);
|
||||
}
|
||||
Pic_SetError("Save %s, error while saving BMP file",FileName);
|
||||
err=1;
|
||||
}
|
||||
break;
|
||||
// ---
|
||||
default:
|
||||
Pic_SetError("Save %s, unknow save format/type",FileName);
|
||||
err=1;
|
||||
break;
|
||||
}
|
||||
if (freeit)
|
||||
{
|
||||
Pic_free(freeit);
|
||||
}
|
||||
return(err-1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long PIC_Destroy(unsigned long id)
|
||||
{
|
||||
PIC_PICTURE *prevpic,*pic;
|
||||
unsigned long found;
|
||||
|
||||
prevpic=NULL;
|
||||
found=0;
|
||||
for(pic=HeadPic ; pic ; pic=pic->Next)
|
||||
{
|
||||
if (pic->ID==id)
|
||||
{
|
||||
found=1;
|
||||
break;
|
||||
}
|
||||
prevpic=pic;
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
Pic_SetError("Destroy, picture internal structure not found");
|
||||
return(0);
|
||||
}
|
||||
if (prevpic)
|
||||
{
|
||||
prevpic->Next=pic->Next;
|
||||
}
|
||||
if (pic->pDatas)
|
||||
{
|
||||
Pic_free(pic->pDatas);
|
||||
}
|
||||
if (pic->pPal)
|
||||
{
|
||||
Pic_free(pic->pPal);
|
||||
}
|
||||
if (pic==HeadPic)
|
||||
{
|
||||
HeadPic=pic->Next;
|
||||
}
|
||||
Pic_free(pic);
|
||||
return(1);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
|
@ -1,215 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pic_private.h"
|
||||
#include "pic.h"
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct TGA_HEADER
|
||||
{
|
||||
unsigned char LengthID;
|
||||
unsigned char CMapType;
|
||||
unsigned char ImageType;
|
||||
unsigned short Origin;
|
||||
unsigned short Length;
|
||||
unsigned char Depth;
|
||||
unsigned short XOrg;
|
||||
unsigned short YOrg;
|
||||
unsigned short Width;
|
||||
unsigned short Height;
|
||||
unsigned char ImageDepth;
|
||||
unsigned char Desc;
|
||||
} TGA_HEADER;
|
||||
#pragma pack()
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long Pic_TGA_Read( const char *FileName,
|
||||
char **ppPal, char **ppDatas,
|
||||
unsigned long *pWidth, unsigned long *pHeight,
|
||||
unsigned long *pDepth)
|
||||
{
|
||||
FILE *file;
|
||||
TGA_HEADER tgah;
|
||||
long w,h,d;
|
||||
unsigned long size;
|
||||
char *pDatas;
|
||||
char *pPal;
|
||||
long x,y;
|
||||
long slsize;
|
||||
unsigned char *scanline;
|
||||
unsigned char r,g,b;
|
||||
long i;
|
||||
int upSideDown;
|
||||
|
||||
pDatas=NULL;
|
||||
pPal=NULL;
|
||||
file=fopen(FileName,"rb");
|
||||
if (!file)
|
||||
{
|
||||
Pic_SetError("TGA_Read, unable to open %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
fread(&tgah,1,sizeof(TGA_HEADER),file);
|
||||
if (tgah.ImageType>3)
|
||||
{
|
||||
Pic_SetError("TGA_Read, unsupported TGA format");
|
||||
return(0);
|
||||
}
|
||||
*pWidth=w=tgah.Width;
|
||||
*pHeight=h=tgah.Height;
|
||||
*pDepth=d=tgah.ImageDepth;
|
||||
upSideDown = ((tgah.Desc & (1 << 5))==0);
|
||||
|
||||
size=tgah.Width*tgah.Height*(tgah.ImageDepth/8);
|
||||
pDatas=(char*)Pic_malloc(size);
|
||||
if (!pDatas)
|
||||
{
|
||||
Pic_SetError("TGA_Read, not enough memory");
|
||||
return(0);
|
||||
}
|
||||
if (*pDepth==8)
|
||||
{
|
||||
if (!ppPal)
|
||||
{
|
||||
Pic_free(pDatas);
|
||||
Pic_SetError("TGA_Read, need a pointer to palette");
|
||||
return(0);
|
||||
}
|
||||
pPal=(char*)Pic_calloc(1,256*3);
|
||||
if (!pPal)
|
||||
{
|
||||
Pic_SetError("TGA_Read, not enough memory for palette");
|
||||
return(0);
|
||||
}
|
||||
if (tgah.ImageType==1)
|
||||
{
|
||||
for(i=0 ; i<256*3 ; i+=3)
|
||||
{
|
||||
fread(&pPal[i+2],1,1,file);
|
||||
fread(&pPal[i+1],1,1,file);
|
||||
fread(&pPal[i+0],1,1,file);
|
||||
}
|
||||
}
|
||||
*ppPal=pPal;
|
||||
}
|
||||
|
||||
slsize=w*d/8;
|
||||
scanline=(unsigned char*)Pic_calloc(1,slsize);
|
||||
if (!scanline)
|
||||
{
|
||||
if (pPal)
|
||||
{
|
||||
Pic_free(pPal);
|
||||
}
|
||||
Pic_free(pDatas);
|
||||
Pic_SetError("TGA_Read, not enough memory for scanline");
|
||||
return(0);
|
||||
}
|
||||
for(y=0 ; y<h ; y++)
|
||||
{
|
||||
fread(scanline,1,slsize,file);
|
||||
if (d==24 || d==32)
|
||||
{
|
||||
long mult=3;
|
||||
if(d==32) mult=4;
|
||||
for(x=0 ; x<w ; x++)
|
||||
{
|
||||
r=scanline[x*mult+0];
|
||||
g=scanline[x*mult+1];
|
||||
b=scanline[x*mult+2];
|
||||
scanline[x*mult+0]=b;
|
||||
scanline[x*mult+1]=g;
|
||||
scanline[x*mult+2]=r;
|
||||
}
|
||||
}
|
||||
if (upSideDown)
|
||||
memcpy(&pDatas[(h-y-1)*slsize], scanline, slsize);
|
||||
else
|
||||
memcpy(&pDatas[(y)*slsize], scanline, slsize);
|
||||
}
|
||||
Pic_free(scanline);
|
||||
fclose(file);
|
||||
*ppDatas=pDatas;
|
||||
return(1);
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned long Pic_TGA_Write( const char *FileName,
|
||||
char *pPal, char *pDatas,
|
||||
unsigned long w, unsigned long h, unsigned long d)
|
||||
{
|
||||
FILE *file;
|
||||
TGA_HEADER tgah;
|
||||
long x,y;
|
||||
long slsize;
|
||||
unsigned char *scanline;
|
||||
unsigned char r,g,b;
|
||||
|
||||
file=fopen(FileName,"wb");
|
||||
if (!file)
|
||||
{
|
||||
Pic_SetError("TGA_Write, unable to open %s",FileName);
|
||||
return(0);
|
||||
}
|
||||
memset(&tgah,0,sizeof(TGA_HEADER));
|
||||
tgah.LengthID=0;
|
||||
if (d>8)
|
||||
{
|
||||
tgah.CMapType=0;
|
||||
tgah.ImageType=2;
|
||||
tgah.Length=0;
|
||||
tgah.Depth=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
tgah.CMapType=1;
|
||||
tgah.ImageType=1;
|
||||
tgah.Length=256;
|
||||
tgah.Depth=24;
|
||||
}
|
||||
tgah.Origin=0;
|
||||
tgah.XOrg=0;
|
||||
tgah.YOrg=0;
|
||||
tgah.Width=(unsigned short)w;
|
||||
tgah.Height=(unsigned short)h;
|
||||
tgah.ImageDepth=(unsigned char)d;
|
||||
tgah.Desc=0;
|
||||
fwrite(&tgah,1,sizeof(TGA_HEADER),file);
|
||||
if (d==8)
|
||||
{
|
||||
fwrite(pPal,1,256*3,file);
|
||||
}
|
||||
slsize=w*d/8;
|
||||
scanline=(unsigned char*)Pic_calloc(1,slsize);
|
||||
if (!scanline)
|
||||
{
|
||||
Pic_SetError("TGA_Write, not enough memory for scanline");
|
||||
return(0);
|
||||
}
|
||||
for(y=0 ; y<(long)h ; y++)
|
||||
{
|
||||
memcpy(scanline,&pDatas[(h-y-1)*slsize],slsize);
|
||||
if (d==24)
|
||||
{
|
||||
for(x=0 ; x<(long)w ; x++)
|
||||
{
|
||||
r=scanline[x*3+0];
|
||||
g=scanline[x*3+1];
|
||||
b=scanline[x*3+2];
|
||||
scanline[x*3+0]=b;
|
||||
scanline[x*3+1]=g;
|
||||
scanline[x*3+2]=r;
|
||||
}
|
||||
}
|
||||
fwrite(scanline,1,slsize,file);
|
||||
}
|
||||
Pic_free(scanline);
|
||||
fclose(file);
|
||||
return(1);
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef _PIC_H_
|
||||
#define _PIC_H_
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#define PIC_TYPE_JPG 1
|
||||
#define PIC_TYPE_TGA8 2
|
||||
#define PIC_TYPE_TGA16 3
|
||||
#define PIC_TYPE_TGA24 4
|
||||
#define PIC_TYPE_BMP8 5
|
||||
#define PIC_TYPE_BMP24 6
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Basic API
|
||||
//
|
||||
extern unsigned long PIC_Load(char* FileName, unsigned char Quantize);
|
||||
|
||||
extern unsigned long PIC_Create(char* pPal, char* pDatas, unsigned long w, unsigned long h, unsigned long d);
|
||||
|
||||
extern unsigned long PIC_Save(unsigned long id, char* FileName, unsigned long type, unsigned long qual);
|
||||
|
||||
extern unsigned long PIC_GetInfos( unsigned long id,
|
||||
char **ppPal, char **ppDatas,
|
||||
unsigned long *pW, unsigned long *pH, unsigned long *pD);
|
||||
|
||||
|
||||
extern unsigned long PIC_Destroy(unsigned long id);
|
||||
//
|
||||
// System
|
||||
//
|
||||
extern unsigned long PIC_GetMemNbAllocs(void);
|
||||
extern unsigned long PIC_GetMemAllocated(void);
|
||||
extern char* PIC_GetError(void);
|
||||
extern unsigned char PIC_Error(void);
|
||||
extern void PIC_ResetError(void);
|
||||
extern unsigned char PIC_OnErrorCall( void pFnct(void) );
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#endif
|
|
@ -1,81 +0,0 @@
|
|||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef _PIC_PRIVATE_H_
|
||||
#define _PIC_PRIVATE_H_
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
typedef struct PIC_PICTURE
|
||||
{
|
||||
unsigned long ID;
|
||||
unsigned long Width;
|
||||
unsigned long Height;
|
||||
unsigned long Depth;
|
||||
char *pDatas;
|
||||
char *pPal;
|
||||
struct PIC_PICTURE *Next;
|
||||
} PIC_PICTURE;
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//
|
||||
// JPG
|
||||
//
|
||||
|
||||
|
||||
extern unsigned long Pic_JPG_Read( const char *FileName,
|
||||
char **ppPal, char **ppDatas,
|
||||
unsigned long *w, unsigned long *h);
|
||||
|
||||
extern unsigned long Pic_JPG_Write( const char *FileName,
|
||||
unsigned long Qual,
|
||||
char *pDatas,
|
||||
unsigned long w, unsigned long h);
|
||||
//
|
||||
// TGA
|
||||
//
|
||||
extern unsigned long Pic_TGA_Read( const char *FileName,
|
||||
char **ppPal, char **ppDatas,
|
||||
unsigned long *pWidth, unsigned long *pHeight,
|
||||
unsigned long *pDepth);
|
||||
extern unsigned long Pic_TGA_Write( const char *FileName,
|
||||
char *pPal, char *pDatas,
|
||||
unsigned long w, unsigned long h, unsigned long d);
|
||||
//
|
||||
// BMP
|
||||
//
|
||||
extern unsigned long Pic_BMP_Read( const char *FileName,
|
||||
char **ppPal, char **ppDatas,
|
||||
unsigned long *pWidth, unsigned long *pHeight,
|
||||
unsigned long *pDepth);
|
||||
|
||||
extern unsigned long Pic_BMP_Write( const char *FileName,
|
||||
char *pPal, char *pDatas,
|
||||
unsigned long w, unsigned long h, unsigned long d);
|
||||
//
|
||||
// System
|
||||
//
|
||||
extern void* Pic_malloc(unsigned long size);
|
||||
extern void* Pic_calloc(unsigned long count, unsigned long size);
|
||||
extern void Pic_free(void *memblock);
|
||||
extern unsigned long Pic__msize(void *memblock);
|
||||
extern void Pic_SetError(const char *msg, ...);
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#endif
|
|
@ -1,84 +0,0 @@
|
|||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <algorithm>
|
||||
#include "readpic.h"
|
||||
#include "pic.h"
|
||||
#include <nel/misc/rgba.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//============================================================
|
||||
// Image API.
|
||||
//============================================================
|
||||
|
||||
|
||||
bool PIC_LoadPic(string path, vector<NLMISC::CBGRA> &tampon, uint &Width, uint &Height)
|
||||
{
|
||||
uint32 id;
|
||||
char *pal, *data;
|
||||
unsigned long w,h,depth;
|
||||
uint i;
|
||||
|
||||
|
||||
// Loadons l'image.
|
||||
id= PIC_Load((char*)path.c_str(), 0);
|
||||
if(id==0)
|
||||
return false;
|
||||
PIC_GetInfos( id, &pal, &data, &w, &h, &depth);
|
||||
Width=w;
|
||||
Height=h;
|
||||
|
||||
// On traduit en RGBA.
|
||||
tampon.resize(w*h);
|
||||
switch(depth)
|
||||
{
|
||||
case 8:
|
||||
for(i=0;i<w*h;i++)
|
||||
{
|
||||
tampon[i].R= data[i];
|
||||
tampon[i].G= data[i];
|
||||
tampon[i].B= data[i];
|
||||
tampon[i].A= data[i];
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
for(i=0;i<w*h;i++)
|
||||
{
|
||||
tampon[i].R= data[i*3+ 0];
|
||||
tampon[i].G= data[i*3+ 1];
|
||||
tampon[i].B= data[i*3+ 2];
|
||||
tampon[i].A= 255;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
for(i=0;i<w*h;i++)
|
||||
{
|
||||
tampon[i].R= data[i*4+ 0];
|
||||
tampon[i].G= data[i*4+ 1];
|
||||
tampon[i].B= data[i*4+ 2];
|
||||
tampon[i].A= data[i*4+ 3];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// On ferme.
|
||||
PIC_Destroy(id);
|
||||
|
||||
return true;
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef _READPIC_H_
|
||||
#define _READPIC_H_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <nel/misc/types_nl.h>
|
||||
#include <nel/misc/rgba.h>
|
||||
|
||||
//============================================================
|
||||
// API.
|
||||
//============================================================
|
||||
|
||||
|
||||
bool PIC_LoadPic(std::string Path, std::vector<NLMISC::CBGRA> &Tampon, uint &Width, uint &Height);
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -24,7 +24,7 @@
|
|||
#include <direct.h>
|
||||
//#include "ListGroup.h"
|
||||
//#include "ViewPopup.h"
|
||||
#include "pic/readpic.h"
|
||||
//#include "pic/readpic.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NL3D;
|
||||
|
@ -74,6 +74,37 @@ void rotateBuffer (uint &Width, uint &Height, std::vector<NLMISC::CBGRA>& Tampon
|
|||
Height=tmp;
|
||||
}
|
||||
|
||||
static bool loadPic(const string &path, std::vector<NLMISC::CBGRA> &tampon, uint &width, uint &height)
|
||||
{
|
||||
try
|
||||
{
|
||||
NLMISC::CIFile file;
|
||||
if (file.open(path.c_str()))
|
||||
{
|
||||
NLMISC::CBitmap bitmap;
|
||||
bitmap.load(file);
|
||||
width = bitmap.getWidth();
|
||||
height = bitmap.getHeight();
|
||||
tampon.resize(width * height);
|
||||
bitmap.convertToType(NLMISC::CBitmap::RGBA);
|
||||
for (uint y = 0; y < height; ++y)
|
||||
{
|
||||
for (uint x = 0; x < width; ++x)
|
||||
{
|
||||
NLMISC::CRGBA c = bitmap.getPixelColor(x, y, 0);
|
||||
c.R = (c.R * c.A) / 255;
|
||||
c.G = (c.G * c.A) / 255;
|
||||
c.B = (c.B * c.A) / 255;
|
||||
tampon[(y * width) + x] = c;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (NLMISC::Exception& ) { }
|
||||
return false;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CTView
|
||||
//Attention : windows veut que le buffer image commence du bas vers le haut
|
||||
|
@ -82,7 +113,7 @@ int _LoadBitmap(const std::string& path,LPBITMAPINFO BitmapInfo, std::vector<NLM
|
|||
//vector<NLMISC::CBGRA> Tampon;
|
||||
uint Width;
|
||||
uint Height;
|
||||
if (PIC_LoadPic(path, Tampon, Width, Height))
|
||||
if (loadPic(path, Tampon, Width, Height))
|
||||
{
|
||||
BitmapInfo->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
|
||||
BitmapInfo->bmiHeader.biWidth=Width;
|
||||
|
@ -207,7 +238,7 @@ int TileList::setTile128 (int tile, const std::string& name, NL3D::CTile::TBitma
|
|||
vector<NLMISC::CBGRA> tampon;
|
||||
uint Width;
|
||||
uint Height;
|
||||
if (!PIC_LoadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height))
|
||||
if (!loadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height))
|
||||
{
|
||||
return (int)(MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), "Can't load bitmap.", MB_YESNO|MB_ICONEXCLAMATION)==IDYES);
|
||||
}
|
||||
|
@ -272,7 +303,7 @@ int TileList::setTile256 (int tile, const std::string& name, NL3D::CTile::TBitma
|
|||
vector<NLMISC::CBGRA> tampon;
|
||||
uint Width;
|
||||
uint Height;
|
||||
if (!PIC_LoadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height))
|
||||
if (!loadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height))
|
||||
{
|
||||
return (int)(MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), "Can't load bitmap.", MB_YESNO|MB_ICONEXCLAMATION)==IDYES);
|
||||
}
|
||||
|
@ -338,7 +369,7 @@ int TileList::setTileTransition (int tile, const std::string& name, NL3D::CTile:
|
|||
vector<NLMISC::CBGRA> tampon;
|
||||
uint Width;
|
||||
uint Height;
|
||||
if (!PIC_LoadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height))
|
||||
if (!loadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height))
|
||||
{
|
||||
return (int)(MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), "Can't load bitmap.", MB_YESNO|MB_ICONEXCLAMATION)==IDYES);
|
||||
}
|
||||
|
@ -451,7 +482,7 @@ int TileList::setTileTransitionAlpha (int tile, const std::string& name, int rot
|
|||
vector<NLMISC::CBGRA> tampon;
|
||||
uint Width;
|
||||
uint Height;
|
||||
if (!PIC_LoadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height))
|
||||
if (!loadPic(tileBank2.getAbsPath ()+troncated, tampon, Width, Height))
|
||||
{
|
||||
return MessageBox (NULL, ((tileBank2.getAbsPath ()+troncated)+"\nContinue ?").c_str(), "Can't load bitmap.", MB_YESNO|MB_ICONEXCLAMATION)==IDYES;
|
||||
}
|
||||
|
@ -1490,7 +1521,7 @@ LRESULT CTView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
{
|
||||
_chdir (LastPath.c_str());
|
||||
CFileDialog load(true, NULL, LastPath.c_str(), OFN_ENABLESIZING | OFN_ALLOWMULTISELECT,
|
||||
"Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||",NULL);
|
||||
"PNG Bitmap (*.png)|*.png|Targa bitmap (*.tga)|*.tga|All files (*.*)|*.*||",NULL);
|
||||
load.m_ofn.lpstrFile = new char[10000]; // buffer contains filenames list
|
||||
load.m_ofn.lpstrFile[0] = 0;
|
||||
// with 10 KB we should be large enough...
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# Don't add other subdirectories if only max plugins are selected.
|
||||
IF(WITH_NEL_TOOLS)
|
||||
ADD_SUBDIRECTORY(misc)
|
||||
|
|
|
@ -49,6 +49,7 @@ fn runNelMaxExport inputMaxFile =
|
|||
tagThisFile = true
|
||||
|
||||
-- Unhide category
|
||||
unhidelayers()
|
||||
unhidecategory()
|
||||
|
||||
-- Unhide
|
||||
|
|
|
@ -54,6 +54,7 @@ fn runNelMaxExport inputMaxFile =
|
|||
tagThisFile = true
|
||||
|
||||
-- Unhide category
|
||||
unhidelayers()
|
||||
unhidecategory()
|
||||
|
||||
-- Unhide
|
||||
|
|
|
@ -187,11 +187,14 @@ fn haveCoarseMesh node =
|
|||
return false
|
||||
)
|
||||
|
||||
fn getRoot node = if isvalidnode node.parent then getRoot node.parent else node
|
||||
|
||||
fn runNelMaxExportSub inputMaxFile retryCount =
|
||||
(
|
||||
tagThisFile = false
|
||||
|
||||
-- Unhide category
|
||||
unhidelayers()
|
||||
unhidecategory()
|
||||
|
||||
-- Unhide
|
||||
|
@ -273,55 +276,51 @@ fn runNelMaxExportSub inputMaxFile retryCount =
|
|||
-- For each node
|
||||
for node in array_node do
|
||||
(
|
||||
-- It is root ?
|
||||
if (node.parent == undefined) then
|
||||
-- Is not a skeleton ?
|
||||
if (((substring node.name 1 3) != "Bip") and ((substring (getRoot node).name 1 3) != "Bip")) then
|
||||
(
|
||||
-- Is not a skeleton ?
|
||||
if (node.name != "Bip01") then
|
||||
-- Can be exported ?
|
||||
if (isToBeExported node == true) then
|
||||
(
|
||||
-- Can be exported ?
|
||||
if (isToBeExported node == true) then
|
||||
-- Not a lod ?
|
||||
if ((isLod node) == false) then
|
||||
(
|
||||
-- Not a lod ?
|
||||
if ((isLod node) == false) then
|
||||
-- Output directory
|
||||
if (haveCoarseMesh node) == true then
|
||||
output = ("%OutputDirectoryWithCoarseMesh%/" + (node.name) + ".shape")
|
||||
else
|
||||
output = ("%OutputDirectoryWithoutCoarseMesh%/" + (node.name) + ".shape")
|
||||
|
||||
-- Compare file date
|
||||
if (NeLTestFileDate output inputMaxFile) == true then
|
||||
(
|
||||
-- Output directory
|
||||
if (haveCoarseMesh node) == true then
|
||||
output = ("%OutputDirectoryWithCoarseMesh%/" + (node.name) + ".shape")
|
||||
else
|
||||
output = ("%OutputDirectoryWithoutCoarseMesh%/" + (node.name) + ".shape")
|
||||
|
||||
-- Compare file date
|
||||
if (NeLTestFileDate output inputMaxFile) == true then
|
||||
try
|
||||
(
|
||||
try
|
||||
-- Export the shape
|
||||
if (NelExportShapeEx node output %ShapeExportOptShadow% %ShapeExportOptExportLighting% "%OutputDirectoryLightmap%" %ShapeExportOptLightingLimit% %ShapeExportOptLumelSize% %ShapeExportOptOversampling% true false %ShapeExportOptLightmapLog%) == true then
|
||||
(
|
||||
-- Export the shape
|
||||
if (NelExportShapeEx node output %ShapeExportOptShadow% %ShapeExportOptExportLighting% "%OutputDirectoryLightmap%" %ShapeExportOptLightingLimit% %ShapeExportOptLumelSize% %ShapeExportOptOversampling% true false %ShapeExportOptLightmapLog%) == true then
|
||||
(
|
||||
nlerror("OK "+output)
|
||||
exported = exported +1
|
||||
)
|
||||
else
|
||||
(
|
||||
-- Error
|
||||
nlerror("ERROR exporting shape " + node.name + " in file " + inputMaxFile)
|
||||
tagThisFile = false
|
||||
)
|
||||
nlerror("OK "+output)
|
||||
exported = exported +1
|
||||
)
|
||||
catch
|
||||
else
|
||||
(
|
||||
-- Error
|
||||
nlerror("ERROR fatal error exporting shape " + node.name + " in file " + inputMaxFile)
|
||||
nlerror("ERROR exporting shape " + node.name + " in file " + inputMaxFile)
|
||||
tagThisFile = false
|
||||
)
|
||||
)
|
||||
else
|
||||
catch
|
||||
(
|
||||
nlerror("SKIPPED " + output)
|
||||
exported = exported + 1
|
||||
-- Error
|
||||
nlerror("ERROR fatal error exporting shape " + node.name + " in file " + inputMaxFile)
|
||||
tagThisFile = false
|
||||
)
|
||||
)
|
||||
else
|
||||
(
|
||||
nlerror("SKIPPED " + output)
|
||||
exported = exported + 1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -39,6 +39,7 @@ fn runNelMaxExport inputMaxFile =
|
|||
tagThisFile = true
|
||||
|
||||
-- Unhide category
|
||||
unhidelayers()
|
||||
unhidecategory()
|
||||
|
||||
-- Unhide
|
||||
|
|
|
@ -13,6 +13,16 @@ nlErrorStream = openFile nlErrorFilename mode:"a"
|
|||
if nlErrorStream == undefined then
|
||||
nlErrorStream = createFile nlErrorFilename
|
||||
|
||||
-- Unhide layers
|
||||
fn unhidelayers =
|
||||
(
|
||||
for i = 0 to (LayerManager.count - 1) do
|
||||
(
|
||||
layer = (LayerManager.getLayer i)
|
||||
layer.ishidden = false
|
||||
)
|
||||
)
|
||||
|
||||
-- Unhide category
|
||||
fn unhidecategory =
|
||||
(
|
||||
|
|
|
@ -16,6 +16,16 @@ nlErrorStream = openFile nlErrorFilename mode:"a"
|
|||
if nlErrorStream == undefined then
|
||||
nlErrorStream = createFile nlErrorFilename
|
||||
|
||||
-- Unhide layers
|
||||
fn unhidelayers =
|
||||
(
|
||||
for i = 0 to (LayerManager.count - 1) do
|
||||
(
|
||||
layer = (LayerManager.getLayer i)
|
||||
layer.ishidden = false
|
||||
)
|
||||
)
|
||||
|
||||
-- Unhide category
|
||||
fn unhidecategory =
|
||||
(
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#
|
||||
# \file 1_export.py
|
||||
# \brief Export anim
|
||||
# \date 2011-09-21-20-51-GMT
|
||||
# \date 2015-01-06-16-31-GMT
|
||||
# \author Jan Boon (Kaetemi)
|
||||
# Python port of game data build pipeline.
|
||||
# Export anim
|
||||
|
|
|
@ -16,6 +16,16 @@ nlErrorStream = openFile nlErrorFilename mode:"a"
|
|||
if nlErrorStream == undefined then
|
||||
nlErrorStream = createFile nlErrorFilename
|
||||
|
||||
-- Unhide layers
|
||||
fn unhidelayers =
|
||||
(
|
||||
for i = 0 to (LayerManager.count - 1) do
|
||||
(
|
||||
layer = (LayerManager.getLayer i)
|
||||
layer.ishidden = false
|
||||
)
|
||||
)
|
||||
|
||||
-- Unhide category
|
||||
fn unhidecategory =
|
||||
(
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#
|
||||
# \file 1_export.py
|
||||
# \brief Export clodbank
|
||||
# \date 2011-09-21-20-51-GMT
|
||||
# \date 2015-01-06-16-31-GMT
|
||||
# \author Jan Boon (Kaetemi)
|
||||
# Python port of game data build pipeline.
|
||||
# Export clodbank
|
||||
|
|
|
@ -16,6 +16,16 @@ nlErrorStream = openFile nlErrorFilename mode:"a"
|
|||
if nlErrorStream == undefined then
|
||||
nlErrorStream = createFile nlErrorFilename
|
||||
|
||||
-- Unhide layers
|
||||
fn unhidelayers =
|
||||
(
|
||||
for i = 0 to (LayerManager.count - 1) do
|
||||
(
|
||||
layer = (LayerManager.getLayer i)
|
||||
layer.ishidden = false
|
||||
)
|
||||
)
|
||||
|
||||
-- Unhide category
|
||||
fn unhidecategory =
|
||||
(
|
||||
|
@ -115,6 +125,7 @@ fn runNelMaxExport inputMaxFile =
|
|||
tagThisFile = true
|
||||
|
||||
-- Unhide category
|
||||
unhidelayers()
|
||||
unhidecategory()
|
||||
|
||||
-- Unhide
|
||||
|
|
|
@ -16,6 +16,16 @@ nlErrorStream = openFile nlErrorFilename mode:"a"
|
|||
if nlErrorStream == undefined then
|
||||
nlErrorStream = createFile nlErrorFilename
|
||||
|
||||
-- Unhide layers
|
||||
fn unhidelayers =
|
||||
(
|
||||
for i = 0 to (LayerManager.count - 1) do
|
||||
(
|
||||
layer = (LayerManager.getLayer i)
|
||||
layer.ishidden = false
|
||||
)
|
||||
)
|
||||
|
||||
-- Unhide category
|
||||
fn unhidecategory =
|
||||
(
|
||||
|
@ -120,6 +130,7 @@ fn runNelMaxExport inputMaxFile =
|
|||
tagThisFile = true
|
||||
|
||||
-- Unhide category
|
||||
unhidelayers()
|
||||
unhidecategory()
|
||||
|
||||
-- Unhide
|
||||
|
|
|
@ -17,6 +17,16 @@ NEL3D_APPDATA_IGNAME = 1423062564 -- string : name of the Instance Group
|
|||
|
||||
tagThisFile = true
|
||||
|
||||
-- Unhide layers
|
||||
fn unhidelayers =
|
||||
(
|
||||
for i = 0 to (LayerManager.count - 1) do
|
||||
(
|
||||
layer = (LayerManager.getLayer i)
|
||||
layer.ishidden = false
|
||||
)
|
||||
)
|
||||
|
||||
-- Unhide category
|
||||
fn unhidecategory =
|
||||
(
|
||||
|
@ -307,6 +317,10 @@ fn buildTransitionMatrixObj mt transitionZone cellSize =
|
|||
-- Export instance groups from the current loaded zone
|
||||
fn exportInstanceGroupFromZone inputFile outputPath igName transitionZone cellSize =
|
||||
(
|
||||
-- Unhide category
|
||||
unhidelayers()
|
||||
unhidecategory()
|
||||
|
||||
-- Unhide
|
||||
max unhide all
|
||||
|
||||
|
@ -501,6 +515,7 @@ try
|
|||
objXRefMgr.UpdateAllRecords()
|
||||
|
||||
-- Unhide category
|
||||
unhidelayers()
|
||||
unhidecategory()
|
||||
|
||||
DeleteDebugMarkersFn ()
|
||||
|
@ -648,6 +663,7 @@ try
|
|||
objXRefMgr.UpdateAllRecords()
|
||||
|
||||
-- Unhide category
|
||||
unhidelayers()
|
||||
unhidecategory()
|
||||
|
||||
DeleteDebugMarkersFn ()
|
||||
|
@ -863,6 +879,7 @@ try
|
|||
objXRefMgr.UpdateAllRecords()
|
||||
|
||||
-- Unhide category
|
||||
unhidelayers()
|
||||
unhidecategory()
|
||||
|
||||
DeleteDebugMarkersFn ()
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#
|
||||
# \file 1_export.py
|
||||
# \brief Export pacs_prim
|
||||
# \date 2013-07-24-14-21-GMT
|
||||
# \date 2015-01-06-16-31-GMT
|
||||
# \author Jan Boon (Kaetemi)
|
||||
# Python port of game data build pipeline.
|
||||
# Export pacs_prim
|
||||
|
@ -130,6 +130,13 @@ if MaxAvailable:
|
|||
|
||||
|
||||
|
||||
# Remove bad file from previous script version
|
||||
listPath = ExportBuildDirectory + "/" + PacsPrimExportDirectory + "/landscape_col_prim_pacs_list.txt"
|
||||
if os.path.isfile(listPath):
|
||||
os.remove(listPath)
|
||||
|
||||
|
||||
|
||||
log.close()
|
||||
if os.path.isfile("log.log"):
|
||||
os.remove("log.log")
|
||||
|
|
|
@ -16,6 +16,16 @@ nlErrorStream = openFile nlErrorFilename mode:"a"
|
|||
if nlErrorStream == undefined then
|
||||
nlErrorStream = createFile nlErrorFilename
|
||||
|
||||
-- Unhide layers
|
||||
fn unhidelayers =
|
||||
(
|
||||
for i = 0 to (LayerManager.count - 1) do
|
||||
(
|
||||
layer = (LayerManager.getLayer i)
|
||||
layer.ishidden = false
|
||||
)
|
||||
)
|
||||
|
||||
-- Unhide category
|
||||
fn unhidecategory =
|
||||
(
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#
|
||||
# \file 1_export.py
|
||||
# \brief Export rbank
|
||||
# \date 2011-09-21-20-51-GMT
|
||||
# \date 2015-01-06-16-31-GMT
|
||||
# \author Jan Boon (Kaetemi)
|
||||
# Python port of game data build pipeline.
|
||||
# Export rbank
|
||||
|
|
|
@ -16,6 +16,16 @@ nlErrorStream = openFile nlErrorFilename mode:"a"
|
|||
if nlErrorStream == undefined then
|
||||
nlErrorStream = createFile nlErrorFilename
|
||||
|
||||
-- Unhide layers
|
||||
fn unhidelayers =
|
||||
(
|
||||
for i = 0 to (LayerManager.count - 1) do
|
||||
(
|
||||
layer = (LayerManager.getLayer i)
|
||||
layer.ishidden = false
|
||||
)
|
||||
)
|
||||
|
||||
-- Unhide category
|
||||
fn unhidecategory =
|
||||
(
|
||||
|
|
|
@ -16,6 +16,16 @@ nlErrorStream = openFile nlErrorFilename mode:"a"
|
|||
if nlErrorStream == undefined then
|
||||
nlErrorStream = createFile nlErrorFilename
|
||||
|
||||
-- Unhide layers
|
||||
fn unhidelayers =
|
||||
(
|
||||
for i = 0 to (LayerManager.count - 1) do
|
||||
(
|
||||
layer = (LayerManager.getLayer i)
|
||||
layer.ishidden = false
|
||||
)
|
||||
)
|
||||
|
||||
-- Unhide category
|
||||
fn unhidecategory =
|
||||
(
|
||||
|
@ -253,11 +263,14 @@ fn haveCoarseMesh node =
|
|||
return false
|
||||
)
|
||||
|
||||
fn getRoot node = if isvalidnode node.parent then getRoot node.parent else node
|
||||
|
||||
fn runNelMaxExportSub inputMaxFile retryCount =
|
||||
(
|
||||
tagThisFile = false
|
||||
|
||||
-- Unhide category
|
||||
unhidelayers()
|
||||
unhidecategory()
|
||||
|
||||
-- Unhide
|
||||
|
@ -339,55 +352,51 @@ fn runNelMaxExportSub inputMaxFile retryCount =
|
|||
-- For each node
|
||||
for node in array_node do
|
||||
(
|
||||
-- It is root ?
|
||||
if (node.parent == undefined) then
|
||||
-- Is not a skeleton ?
|
||||
if (((substring node.name 1 3) != "Bip") and ((substring (getRoot node).name 1 3) != "Bip")) then
|
||||
(
|
||||
-- Is not a skeleton ?
|
||||
if (node.name != "Bip01") then
|
||||
-- Can be exported ?
|
||||
if (isToBeExported node == true) then
|
||||
(
|
||||
-- Can be exported ?
|
||||
if (isToBeExported node == true) then
|
||||
-- Not a lod ?
|
||||
if ((isLod node) == false) then
|
||||
(
|
||||
-- Not a lod ?
|
||||
if ((isLod node) == false) then
|
||||
-- Output directory
|
||||
if (haveCoarseMesh node) == true then
|
||||
output = ("%OutputDirectoryWithCoarseMesh%/" + (node.name) + ".shape")
|
||||
else
|
||||
output = ("%OutputDirectoryWithoutCoarseMesh%/" + (node.name) + ".shape")
|
||||
|
||||
-- Compare file date
|
||||
if (NeLTestFileDate output inputMaxFile) == true then
|
||||
(
|
||||
-- Output directory
|
||||
if (haveCoarseMesh node) == true then
|
||||
output = ("%OutputDirectoryWithCoarseMesh%/" + (node.name) + ".shape")
|
||||
else
|
||||
output = ("%OutputDirectoryWithoutCoarseMesh%/" + (node.name) + ".shape")
|
||||
|
||||
-- Compare file date
|
||||
if (NeLTestFileDate output inputMaxFile) == true then
|
||||
try
|
||||
(
|
||||
try
|
||||
-- Export the shape
|
||||
if (NelExportShapeEx node output %ShapeExportOptShadow% %ShapeExportOptExportLighting% "%OutputDirectoryLightmap%" %ShapeExportOptLightingLimit% %ShapeExportOptLumelSize% %ShapeExportOptOversampling% true false %ShapeExportOptLightmapLog%) == true then
|
||||
(
|
||||
-- Export the shape
|
||||
if (NelExportShapeEx node output %ShapeExportOptShadow% %ShapeExportOptExportLighting% "%OutputDirectoryLightmap%" %ShapeExportOptLightingLimit% %ShapeExportOptLumelSize% %ShapeExportOptOversampling% true false %ShapeExportOptLightmapLog%) == true then
|
||||
(
|
||||
nlerror("OK "+output)
|
||||
exported = exported +1
|
||||
)
|
||||
else
|
||||
(
|
||||
-- Error
|
||||
nlerror("ERROR exporting shape " + node.name + " in file " + inputMaxFile)
|
||||
tagThisFile = false
|
||||
)
|
||||
nlerror("OK "+output)
|
||||
exported = exported +1
|
||||
)
|
||||
catch
|
||||
else
|
||||
(
|
||||
-- Error
|
||||
nlerror("ERROR fatal error exporting shape " + node.name + " in file " + inputMaxFile)
|
||||
nlerror("ERROR exporting shape " + node.name + " in file " + inputMaxFile)
|
||||
tagThisFile = false
|
||||
)
|
||||
)
|
||||
else
|
||||
catch
|
||||
(
|
||||
nlerror("SKIPPED " + output)
|
||||
exported = exported + 1
|
||||
-- Error
|
||||
nlerror("ERROR fatal error exporting shape " + node.name + " in file " + inputMaxFile)
|
||||
tagThisFile = false
|
||||
)
|
||||
)
|
||||
else
|
||||
(
|
||||
nlerror("SKIPPED " + output)
|
||||
exported = exported + 1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#
|
||||
# \file 1_export.py
|
||||
# \brief Export skel
|
||||
# \date 2011-09-28-07-42-GMT
|
||||
# \date 2015-01-06-16-31-GMT
|
||||
# \author Jan Boon (Kaetemi)
|
||||
# Python port of game data build pipeline.
|
||||
# Export skel
|
||||
|
|
|
@ -13,6 +13,16 @@ nlErrorStream = openFile nlErrorFilename mode:"a"
|
|||
if nlErrorStream == undefined then
|
||||
nlErrorStream = createFile nlErrorFilename
|
||||
|
||||
-- Unhide layers
|
||||
fn unhidelayers =
|
||||
(
|
||||
for i = 0 to (LayerManager.count - 1) do
|
||||
(
|
||||
layer = (LayerManager.getLayer i)
|
||||
layer.ishidden = false
|
||||
)
|
||||
)
|
||||
|
||||
-- Unhide category
|
||||
fn unhidecategory =
|
||||
(
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#
|
||||
# \file 1_export.py
|
||||
# \brief Export swt
|
||||
# \date 2011-09-28-07-42-GMT
|
||||
# \date 2015-01-06-16-31-GMT
|
||||
# \author Jan Boon (Kaetemi)
|
||||
# Python port of game data build pipeline.
|
||||
# Export swt
|
||||
|
|
|
@ -13,6 +13,16 @@ nlErrorStream = openFile nlErrorFilename mode:"a"
|
|||
if nlErrorStream == undefined then
|
||||
nlErrorStream = createFile nlErrorFilename
|
||||
|
||||
-- Unhide layers
|
||||
fn unhidelayers =
|
||||
(
|
||||
for i = 0 to (LayerManager.count - 1) do
|
||||
(
|
||||
layer = (LayerManager.getLayer i)
|
||||
layer.ishidden = false
|
||||
)
|
||||
)
|
||||
|
||||
-- Unhide category
|
||||
fn unhidecategory =
|
||||
(
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#
|
||||
# \file 1_export.py
|
||||
# \brief Export veget
|
||||
# \date 2011-09-21-20-51-GMT
|
||||
# \date 2015-01-06-16-31-GMT
|
||||
# \author Jan Boon (Kaetemi)
|
||||
# Python port of game data build pipeline.
|
||||
# Export veget
|
||||
|
|
|
@ -16,6 +16,16 @@ nlErrorStream = openFile nlErrorFilename mode:"a"
|
|||
if nlErrorStream == undefined then
|
||||
nlErrorStream = createFile nlErrorFilename
|
||||
|
||||
-- Unhide layers
|
||||
fn unhidelayers =
|
||||
(
|
||||
for i = 0 to (LayerManager.count - 1) do
|
||||
(
|
||||
layer = (LayerManager.getLayer i)
|
||||
layer.ishidden = false
|
||||
)
|
||||
)
|
||||
|
||||
-- Unhide category
|
||||
fn unhidecategory =
|
||||
(
|
||||
|
@ -105,6 +115,7 @@ fn runNelMaxExport inputMaxFile =
|
|||
tagThisFile = true
|
||||
|
||||
-- Unhide category
|
||||
unhidelayers()
|
||||
unhidecategory()
|
||||
|
||||
-- Unhide
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#
|
||||
# \file 1_export.py
|
||||
# \brief Export zone
|
||||
# \date 2011-09-28-07-42-GMT
|
||||
# \date 2015-01-06-16-31-GMT
|
||||
# \author Jan Boon (Kaetemi)
|
||||
# Python port of game data build pipeline.
|
||||
# Export zone
|
||||
|
|
|
@ -13,6 +13,16 @@ nlErrorStream = openFile nlErrorFilename mode:"a"
|
|||
if nlErrorStream == undefined then
|
||||
nlErrorStream = createFile nlErrorFilename
|
||||
|
||||
-- Unhide layers
|
||||
fn unhidelayers =
|
||||
(
|
||||
for i = 0 to (LayerManager.count - 1) do
|
||||
(
|
||||
layer = (LayerManager.getLayer i)
|
||||
layer.ishidden = false
|
||||
)
|
||||
)
|
||||
|
||||
-- Unhide category
|
||||
fn unhidecategory =
|
||||
(
|
||||
|
|
11
code/nel/tools/build_gamedata/sky_dev.bat
Normal file
11
code/nel/tools/build_gamedata/sky_dev.bat
Normal file
|
@ -0,0 +1,11 @@
|
|||
title Ryzom Core: 1_export.py (LEVELDESIGN)
|
||||
1_export.py -ipj common/sky common/sfx common/gamedev common/data_common common/data_shard common/leveldesign common/exedll common/cfg shard/data_shard shard/data_language shard/data_leveldesign shard/data_game_share
|
||||
title Ryzom Core: 2_build.py (LEVELDESIGN)
|
||||
2_build.py -ipj common/sky common/sfx common/gamedev common/data_common common/data_shard common/leveldesign common/exedll common/cfg shard/data_shard shard/data_language shard/data_leveldesign shard/data_game_share
|
||||
title Ryzom Core: 3_install.py (LEVELDESIGN)
|
||||
3_install.py -ipj common/sky common/sfx common/gamedev common/data_common common/data_shard common/leveldesign common/exedll common/cfg shard/data_shard shard/data_language shard/data_leveldesign shard/data_game_share
|
||||
title Ryzom Core: b1_client_dev.py (LEVELDESIGN)
|
||||
b1_client_dev.py
|
||||
title Ryzom Core: b2_shard_data.py (LEVELDESIGN)
|
||||
b2_shard_data.py
|
||||
title Ryzom Core: Ready
|
|
@ -126,7 +126,7 @@ retry:
|
|||
|
||||
// now the user is on the database
|
||||
|
||||
uid = atoi(row[0]);
|
||||
NLMISC::fromString(row[0], uid);
|
||||
|
||||
if(cpassword != row[2])
|
||||
{
|
||||
|
|
|
@ -52,7 +52,7 @@ BOOL CConfiguration::Load()
|
|||
|
||||
// Reading the configuration file version
|
||||
GetValue(csBuffer, KEY_VERSION, csValue);
|
||||
m_dVersion = atof(csValue);
|
||||
NLMISC::fromString(csValue, m_dVersion);
|
||||
nlinfo("Config' version %s", csValue);
|
||||
|
||||
if(m_dVersion < APP.m_dVersion)
|
||||
|
|
|
@ -324,7 +324,7 @@ void CNel_launcherApp::LoadVersion()
|
|||
else
|
||||
{
|
||||
nlinfo("Launcher' version %s", csVersion);
|
||||
m_dVersion = atof(csVersion);
|
||||
NLMISC::fromString(csVersion, m_dVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,9 +57,10 @@ void cbNotesChanged()
|
|||
Notes.Notes.clear();
|
||||
return;
|
||||
}
|
||||
pos.x = (float)atof(posstr[0].c_str());
|
||||
pos.y = (float)atof(posstr[1].c_str());
|
||||
pos.z = (float)atof(posstr[2].c_str());
|
||||
|
||||
NLMISC::fromString(posstr[0], pos.x);
|
||||
NLMISC::fromString(posstr[1], pos.y);
|
||||
NLMISC::fromString(posstr[2], pos.z);
|
||||
|
||||
string note(var.asString(i+2));
|
||||
if(note.empty())
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue