Commit c73f0d94 authored by kaetemi's avatar kaetemi

Add max file library

parent a0902365
# - Try to find GLib2
# Once done this will define
#
# GLIB2_FOUND - system has GLib2
# GLIB2_INCLUDE_DIRS - the GLib2 include directory
# GLIB2_LIBRARIES - Link these to use GLib2
#
# HAVE_GLIB_GREGEX_H glib has gregex.h header and
# supports g_regex_match_simple
#
# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
# Copyright (c) 2006 Philippe Bernery <philippe.bernery@gmail.com>
# Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
# Copyright (c) 2007 Alban Browaeys <prahal@yahoo.com>
# Copyright (c) 2008 Michael Bell <michael.bell@web.de>
# Copyright (c) 2008 Bjoern Ricks <bjoern.ricks@googlemail.com>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
IF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS )
# in cache already
SET(GLIB2_FOUND TRUE)
ELSE (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS )
INCLUDE(FindPkgConfig)
## Glib
IF ( GLIB2_FIND_REQUIRED )
SET( _pkgconfig_REQUIRED "REQUIRED" )
ELSE ( GLIB2_FIND_REQUIRED )
SET( _pkgconfig_REQUIRED "" )
ENDIF ( GLIB2_FIND_REQUIRED )
IF ( GLIB2_MIN_VERSION )
PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0>=${GLIB2_MIN_VERSION} )
ELSE ( GLIB2_MIN_VERSION )
PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0 )
ENDIF ( GLIB2_MIN_VERSION )
IF ( PKG_CONFIG_FOUND )
IF ( GLIB2_FOUND )
SET ( GLIB2_CORE_FOUND TRUE )
ELSE ( GLIB2_FOUND )
SET ( GLIB2_CORE_FOUND FALSE )
ENDIF ( GLIB2_FOUND )
ENDIF ( PKG_CONFIG_FOUND )
# Look for glib2 include dir and libraries w/o pkgconfig
IF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND )
FIND_PATH(
_glibconfig_include_DIR
NAMES
glibconfig.h
PATHS
/opt/gnome/lib64
/opt/gnome/lib
/opt/lib/
/opt/local/lib
/sw/lib/
/usr/lib64
/usr/lib
/usr/local/include
${CMAKE_LIBRARY_PATH}
PATH_SUFFIXES
glib-2.0/include
)
FIND_PATH(
_glib2_include_DIR
NAMES
glib.h
PATHS
/opt/gnome/include
/opt/local/include
/sw/include
/usr/include
/usr/local/include
PATH_SUFFIXES
glib-2.0
)
#MESSAGE(STATUS "Glib headers: ${_glib2_include_DIR}")
FIND_LIBRARY(
_glib2_link_DIR
NAMES
glib-2.0
glib
PATHS
/opt/gnome/lib
/opt/local/lib
/sw/lib
/usr/lib
/usr/local/lib
)
IF ( _glib2_include_DIR AND _glib2_link_DIR )
SET ( _glib2_FOUND TRUE )
ENDIF ( _glib2_include_DIR AND _glib2_link_DIR )
IF ( _glib2_FOUND )
SET ( GLIB2_INCLUDE_DIRS ${_glib2_include_DIR} ${_glibconfig_include_DIR} )
SET ( GLIB2_LIBRARIES ${_glib2_link_DIR} )
SET ( GLIB2_CORE_FOUND TRUE )
ELSE ( _glib2_FOUND )
SET ( GLIB2_CORE_FOUND FALSE )
ENDIF ( _glib2_FOUND )
# Handle dependencies
# libintl
IF ( NOT LIBINTL_FOUND )
FIND_PATH(LIBINTL_INCLUDE_DIR
NAMES
libintl.h
PATHS
/opt/gnome/include
/opt/local/include
/sw/include
/usr/include
/usr/local/include
)
FIND_LIBRARY(LIBINTL_LIBRARY
NAMES
intl
PATHS
/opt/gnome/lib
/opt/local/lib
/sw/lib
/usr/local/lib
/usr/lib
)
IF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR)
SET (LIBINTL_FOUND TRUE)
ENDIF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR)
ENDIF ( NOT LIBINTL_FOUND )
# libiconv
IF ( NOT LIBICONV_FOUND )
FIND_PATH(LIBICONV_INCLUDE_DIR
NAMES
iconv.h
PATHS
/opt/gnome/include
/opt/local/include
/opt/local/include
/sw/include
/sw/include
/usr/local/include
/usr/include
PATH_SUFFIXES
glib-2.0
)
FIND_LIBRARY(LIBICONV_LIBRARY
NAMES
iconv
PATHS
/opt/gnome/lib
/opt/local/lib
/sw/lib
/usr/lib
/usr/local/lib
)
IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR)
SET (LIBICONV_FOUND TRUE)
ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR)
ENDIF ( NOT LIBICONV_FOUND )
IF (LIBINTL_FOUND)
SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBINTL_LIBRARY})
SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBINTL_INCLUDE_DIR})
ENDIF (LIBINTL_FOUND)
IF (LIBICONV_FOUND)
SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY})
SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR})
ENDIF (LIBICONV_FOUND)
ENDIF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND )
##
IF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES)
SET (GLIB2_FOUND TRUE)
ENDIF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES)
IF (GLIB2_FOUND)
IF (NOT GLIB2_FIND_QUIETLY)
MESSAGE (STATUS "Found GLib2: ${GLIB2_LIBRARIES} ${GLIB2_INCLUDE_DIRS}")
ENDIF (NOT GLIB2_FIND_QUIETLY)
ELSE (GLIB2_FOUND)
IF (GLIB2_FIND_REQUIRED)
MESSAGE (SEND_ERROR "Could not find GLib2")
ENDIF (GLIB2_FIND_REQUIRED)
ENDIF (GLIB2_FOUND)
# show the GLIB2_INCLUDE_DIRS and GLIB2_LIBRARIES variables only in the advanced view
MARK_AS_ADVANCED(GLIB2_INCLUDE_DIRS GLIB2_LIBRARIES)
MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARY)
MARK_AS_ADVANCED(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY)
ENDIF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS)
IF ( GLIB2_FOUND )
# Check if system has a newer version of glib
# which supports g_regex_match_simple
INCLUDE( CheckIncludeFiles )
SET( CMAKE_REQUIRED_INCLUDES ${GLIB2_INCLUDE_DIRS} )
CHECK_INCLUDE_FILES ( glib/gregex.h HAVE_GLIB_GREGEX_H )
# Reset CMAKE_REQUIRED_INCLUDES
SET( CMAKE_REQUIRED_INCLUDES "" )
ENDIF( GLIB2_FOUND )
# - Try to find libGSF
#
# Once done this will define
#
# LIBGSF_FOUND - System has LibGSF
# LIBGSF_INCLUDE_DIR - The LibGSF include directory
# LIBGSF_LIBRARIES - The libraries needed to use LibGSF
# LIBGSF_DEFINITIONS - Compiler switches required for using LibGSF
# LIBGSF_GSF_EXECUTABLE - The archive utility
# LIBGSF_GSFOFFICETHUMBNAILER_EXECUTABLE - The office files thumbnailer for the GNOME desktop
# LIBGSF_GSFVBADUMP_EXECUTABLE - The utility to extract Visual Basic for Applications macros
# Copyright (c) 2009, Pau Garcia i Quiles <pgquiles@elpauer.org>
# Based off FindLibXml2.cmake from CMake 2.6.4 by Alexander Neundorf <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
IF (LIBGSF_INCLUDE_DIR AND LIBGSF_LIBRARIES)
# in cache already
SET(LIBGSF_FIND_QUIETLY TRUE)
ENDIF (LIBGSF_INCLUDE_DIR AND LIBGSF_LIBRARIES)
IF (NOT WIN32)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_LIBGSF libgsf-1)
SET(LIBGSF_DEFINITIONS ${PC_LIBGSF_CFLAGS_OTHER})
ENDIF (NOT WIN32)
FIND_PATH(LIBGSF_INCLUDE_DIR gsf/gsf.h
HINTS
${PC_LIBGSF_INCLUDEDIR}
${PC_LIBGSF_INCLUDE_DIRS}
PATH_SUFFIXES libgsf-1
)
FIND_LIBRARY(LIBGSF_LIBRARIES NAMES gsf-1 libgsf-1
HINTS
${PC_LIBGSF_LIBDIR}
${PC_LIBGSF_LIBRARY_DIRS}
)
FIND_PROGRAM(LIBGSF_GSF_EXECUTABLE gsf)
FIND_PROGRAM(LIBGSF_GSFOFFICETHUMBNAILER_EXECUTABLE gsf-office-thumbnailer)
FIND_PROGRAM(LIBGSF_GSFVBADUMP_EXECUTABLE gsf-vba-dump)
INCLUDE(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBGSF_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBGSF DEFAULT_MSG LIBGSF_LIBRARIES LIBGSF_INCLUDE_DIR)
MARK_AS_ADVANCED(LIBGSF_INCLUDE_DIR LIBGSF_LIBRARIES LIBGSF_GSF_EXECUTABLE LIBGSF_GSFOFFICETHUMBNAILER_EXECUTABLE LIBGSF_GSFVBADUMP_EXECUTABLE )
......@@ -247,6 +247,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
OPTION(WITH_INSTALL_LIBRARIES "Install development files." ON )
OPTION(WITH_ASSIMP "Use assimp exporter" OFF)
OPTION(WITH_LIBGSF "Use libgsf for max file library" OFF)
###
# GUI toolkits
......
......@@ -23,6 +23,7 @@
namespace NLMISC
{
class IStream;
// ***************************************************************************
/**
......@@ -52,6 +53,13 @@ public:
//CClassId& operator=(const CClassId &o) { Uid = o.Uid; return *this;}
operator uint64() const {return Uid;}
inline uint32 a() const { return (uint32)(Uid >> 32); }
inline uint32 b() const { return (uint32)(Uid & 0xFFFFFFFFL); }
inline void setA(uint32 a) { Uid = ((uint64)a<<32) | (Uid & 0xFFFFFFFFL); }
inline void setB(uint32 b) { Uid = (Uid & 0xFFFFFFFF00000000L) | b; }
void serial(NLMISC::IStream &s);
std::string toString() const;
};
/**
......
......@@ -18,7 +18,10 @@
#include "nel/misc/class_id.h"
#include <sstream>
#include <iomanip>
#include "nel/misc/stream.h"
#ifdef DEBUG_NEW
#define new DEBUG_NEW
......@@ -30,6 +33,39 @@ namespace NLMISC
const CClassId CClassId::Null(0);
void CClassId::serial(NLMISC::IStream &s)
{
// s.serial(Uid);
// Backwards.
uint32 va = a();
uint32 vb = b();
s.serial(va);
s.serial(vb);
setA(va);
setB(vb);
}
std::string CClassId::toString() const
{
std::stringstream ss;
ss << "(0x";
{
std::stringstream ss1;
ss1 << std::hex << std::setfill('0');
ss1 << std::setw(8) << a();
ss << ss1.str();
}
ss << ", 0x";
{
std::stringstream ss1;
ss1 << std::hex << std::setfill('0');
ss1 << std::setw(8) << b();
ss << ss1.str();
}
ss << ")";
return ss.str();
}
}
......@@ -6,6 +6,12 @@ IF(WITH_NEL_TOOLS)
mesh_utils
mesh_export)
ENDIF()
IF(WITH_LIBGSF)
SUBDIRS(
pipeline_max
pipeline_max_dump
pipeline_max_rewrite_assets)
ENDIF()
SUBDIRS(
anim_builder
animation_set_builder
......
FILE(GLOB SRC *.cpp *.h)
SOURCE_GROUP("" FILES ${SRC})
ADD_EXECUTABLE(build_interface ${SRC})
TARGET_LINK_LIBRARIES(build_interface nelmisc)
......
FIND_PACKAGE(LIBGSF)
IF (NOT (LIBGSF_INCLUDE_DIR AND LIBGSF_LIBRARIES))
MESSAGE(FATAL_ERROR "LIBGSF not found!")
ENDIF (NOT (LIBGSF_INCLUDE_DIR AND LIBGSF_LIBRARIES))
FIND_PACKAGE(GLIB2)
if (NOT GLIB2_FOUND)
MESSAGE(FATAL_ERROR "GLIB2 not found!")
ENDIF (NOT GLIB2_FOUND)
INCLUDE_DIRECTORIES(${GLIB2_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${LIBGSF_INCLUDE_DIR})
FILE(GLOB SRCS *.cpp builtin/*.cpp builtin/storage/*.cpp update1/*.cpp epoly/*.cpp)
FILE(GLOB HDRS *.h builtin/*.h builtin/storage/*.h update1/*.h epoly/*.h)
NL_TARGET_LIB(pipeline_max
${SRCS}
${HDRS}
)
TARGET_LINK_LIBRARIES(pipeline_max
${LIBGSF_LIBRARIES}
${GLIB2_LIBRARIES}
nelmisc
)
SET_TARGET_PROPERTIES(pipeline_max PROPERTIES LINK_INTERFACE_LIBRARIES "")
NL_DEFAULT_PROPS(pipeline_max "NeL, Tools, 3D: Pipeline Max (Library)")
NL_ADD_LIB_SUFFIX(pipeline_max)
NL_ADD_RUNTIME_FLAGS(pipeline_max)
IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)
INSTALL(TARGETS pipeline_max LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)
/**
* \file animatable.cpp
* \brief CAnimatable
* \date 2012-08-22 08:52GMT
* \author Jan Boon (Kaetemi)
* CAnimatable
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE PIPELINE.
* RYZOM CORE PIPELINE 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.
*
* RYZOM CORE PIPELINE 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 RYZOM CORE PIPELINE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include <nel/misc/types_nl.h>
#include "animatable.h"
// STL includes
// NeL includes
// #include <nel/misc/debug.h>
// Project includes
#include "storage/app_data.h"
using namespace std;
// using namespace NLMISC;
#define PBM_ANIMATABLE_UNKNOWN2140_CHUNK_ID 0x2140
namespace PIPELINE {
namespace MAX {
namespace BUILTIN {
CAnimatable::CAnimatable(CScene *scene) : CSceneClass(scene), m_AppData(NULL)
{
}
CAnimatable::~CAnimatable()
{
if (!m_ChunksOwnsPointers)
{
delete m_Unknown2140;
m_Unknown2140 = NULL;
delete m_AppData;
m_AppData = NULL;
}
}
const ucstring CAnimatable::DisplayName = ucstring("Animatable");
const char *CAnimatable::InternalName = "Animatable";
const char *CAnimatable::InternalNameUnknown = "AnimatableUnknown";
const NLMISC::CClassId CAnimatable::ClassId = NLMISC::CClassId(0x3101497b, 0x24af711b); /* Not official, please correct */
const TSClassId CAnimatable::SuperClassId = 0x77a60fbd; /* Not official, please correct */
const CAnimatableClassDesc AnimatableClassDesc(&DllPluginDescBuiltin);
const CAnimatableSuperClassDesc AnimatableSuperClassDesc(&AnimatableClassDesc);
void CAnimatable::parse(uint16 version, uint filter)
{
CSceneClass::parse(version);
if (!m_ChunksOwnsPointers)
{
m_Unknown2140 = getChunk(PBM_ANIMATABLE_UNKNOWN2140_CHUNK_ID);
if (m_Unknown2140)
{
// nldebug("Found unknown 0x2140");
// TODO: Put std::cout code here
}
m_AppData = static_cast<STORAGE::CAppData *>(getChunk(PMBS_APP_DATA_CHUNK_ID));
}
}
void CAnimatable::clean()
{
CSceneClass::clean();
if (m_AppData) m_AppData->clean();
}
void CAnimatable::build(uint16 version, uint filter)
{
CSceneClass::build(version);
if (m_Unknown2140)
{
putChunk(PBM_ANIMATABLE_UNKNOWN2140_CHUNK_ID, m_Unknown2140);
}
if (m_AppData)
{
if (m_AppData->entries().size() == 0)
{
// Discard appdata if it has no entries
delete m_AppData;
m_AppData = NULL;
}
else
{
putChunk(PMBS_APP_DATA_CHUNK_ID, m_AppData);
}
}
}
void CAnimatable::disown()
{
m_Unknown2140 = NULL;
m_AppData = NULL;
CSceneClass::disown();
}
void CAnimatable::init()
{
CSceneClass::init();
}
bool CAnimatable::inherits(const NLMISC::CClassId classId) const
{
if (classId == classDesc()->classId()) return true;
return CSceneClass::inherits(classId);
}
const ISceneClassDesc *CAnimatable::classDesc() const
{
return &AnimatableClassDesc;
}
void CAnimatable::toStringLocal(std::ostream &ostream, const std::string &pad, uint filter) const
{
CSceneClass::toStringLocal(ostream, pad);
if (m_AppData && m_AppData->entries().size() != 0)
{
ostream << "\n" << pad << "AppData: ";
m_AppData->toString(ostream, pad + "\t");
}
}
STORAGE::CAppData *CAnimatable::appData()
{
if (m_ChunksOwnsPointers) { nlerror("Not parsed"); return NULL; }
if (!m_AppData)
{
m_AppData = new STORAGE::CAppData();
m_AppData->init();
}
return m_AppData;
}
IStorageObject *CAnimatable::createChunkById(uint16 id, bool container)
{
switch (id)
{
case PMBS_APP_DATA_CHUNK_ID:
return new STORAGE::CAppData;
}
return CSceneClass::createChunkById(id, container);
}
} /* namespace BUILTIN */
} /* namespace MAX */
} /* namespace PIPELINE */
/* end of file */
/**
* \file animatable.h
* \brief CAnimatable
* \date 2012-08-22 08:52GMT
* \author Jan Boon (Kaetemi)
* CAnimatable
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE PIPELINE.
* RYZOM CORE PIPELINE 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.
*
* RYZOM CORE PIPELINE 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 RYZOM CORE PIPELINE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINE_ANIMATABLE_H
#define PIPELINE_ANIMATABLE_H
#include <nel/misc/types_nl.h>
// STL includes
// NeL includes
// Project includes
#include "../scene.h"
#include "../scene_class.h"
#include "../super_class_desc.h"
namespace PIPELINE {
namespace MAX {
namespace BUILTIN {
namespace STORAGE {
class CAppData;
}
/**
* \brief CAnimatable
* \date 2012-08-22 08:52GMT
* \author Jan Boon (Kaetemi)
* This scene class owns the AppData chunk
*/
class CAnimatable : public CSceneClass
{
public:
CAnimatable(CScene *scene);
virtual ~CAnimatable();
// class desc
static const ucstring DisplayName;
static const char *InternalName;
static const char *InternalNameUnknown;
static const NLMISC::CClassId ClassId;
static const TSClassId SuperClassId;
// inherited
virtual void parse(uint16 version, uint filter = 0);
virtual void clean();
virtual void build(uint16 version, uint filter = 0);
virtual void disown();
virtual void init();
virtual bool inherits(const NLMISC::CClassId classId) const;
virtual const ISceneClassDesc *classDesc() const;
virtual void toStringLocal(std::ostream &ostream, const std::string &pad = "", uint filter = 0) const;
// public
STORAGE::CAppData *appData();
protected:
// inherited
virtual IStorageObject *createChunkById(uint16 id, bool container);