OSX下的paper3d安装和开发

 

安装

  1. 下载tech和paper3d最新稳定版本,techpaper3d
  2. 将两个安装zip解压到特定目录,比如/Users/someone/projects/tech和/Users/someone/projects/paper3d
  3. 运行tech目录中的install.sh和paper3d目录中的install.sh,重启系统
  4. 打开tech/configs/ios/Tech.xcodeproj,选择build all作为build Scheme(如下图),编译。
  5. 点击上图的buildall,选择Edit Scheme->Run->Build Configuration,将build Configuration更改为Release(如下图),再次编译。
  6. 步骤4和步骤6会编译出tech的Debug版本和Release版本的静态库, libfoundation.a和libplatform.a。其路径在tech/libs/ios/下。
  7. 打开paper3d/configs/ios/Paper3D.xcodeproj,同样的方式编译出Debug和Release版本
  8. 到此为止,paper3d安装完毕
  9. 为了测试paper3d的正确安装,我们可以通过一个example来测试。打开paper3d/examples/loadscene/configs/ios/loadscene.xcodeproj,选择loadscene作为Build Scheme,然后Destination选择Simulator iPhone Retina (3.5-inch),编译运行。如果成功,那么可以看到模拟器中运行了一个蓝天白云绿地的场景。

创建一个新的iOS paper3d程序

paper3d目前还没有为pmake提供xcode版本,所以创建一个新的paper3d程序需要手工创建,最简单的方式是从已有的项目中拷贝。

  1. 拷贝paper3d/examples/loadscene,将其重命名为新的项目名,例如newproject,这个项目可以放在任何路径中,无需放在paper3d/examples底下。
  2. 将newproject/application/res下的资源文件替换成你所要的
  3. 编辑newproject/application/src的cpp和h文件
  4. 从项目中删除resources/loadscene.par,将newproject/application/res/newproject.par(编译一次后会生成)拖入到resources下。如下图
  5. 编译运行

如果需要从头开始创建一个paper3d程序,需要注意这么几个地方

  1. 将$(FITECH)/include和$(FIPAPER3D)/include加入到Header Search Paths
  2. 将-lfoundation -ltinyxml -lplatform -lpaper3d -lpng -lz加入到Other Linker Flags
  3. 将$(FIPAPER3D)/lib/ios/Debug $(FITECH)/lib/ios/ES20_Debug $(FITECH)/3rdparty/platforms/ios/tinyxml/lib/Debug $(FITECH)/3rdparty/platforms/ios/libpng/lib/Debug $(FITECH)/3rdparty/platforms/ios/zlib/lib/Debug加入到Library Search Paths
  4. 在Build Phases中添加一个Run Script,如下图。注意Run Script需要在build前执行(将其拖动到Compile Sources之前)
    ${FIPAPER3D}/tools/bin/xcode/archiver -o ${PROJECT_DIR}/../../res/${TARGET_NAME}.par ${PROJECT_DIR}/../../res
Posted in Download

从FBX创建一个安卓动态壁纸

paper3d提供了非常方便的方式来创建一个安卓动态壁纸,只需要简单敲击几个命令,我们就可以从一个Autodesk的FBX文件中创建出一个安卓APK动态壁纸。

如果还没有安装好paper3d,请参考这里

在%FIPAPER3D%\tools\bin\msvc2012\下面,我提供了一个pmake.exe的win32可执行程序,借助这个程序我们可以创建出一个apk

  1. 打开dos窗口,键入pmake.exe some.fbx(我们希望这个fbx中包含了一个以上的3D物体,和一个照相机)
  2. 如果运行成功,会在当前目录下创建一个some的文件夹,我们可以把这个文件夹移动到任何路径中
  3. 如果fbx中引用了纹理,pmake需要这些纹理图片和some.fbx在同一个目录下,pmake仅支持jpg和png纹理图片格式
  4. cd some\application\configs\android中,然后键入build.bat debug,就会在some\application\bin\android\下创建出一个apk文件

 

 

 

Posted in Download Tagged with:

Architecture overview

  1. Overview
  2. Modules
  3. The Life cycle
  4. Inside a Paper3D context

Overview

Paper3D is a cross platform rendering engine. It is built upon a fundamental library, named Tech, which is also a Future Interface’s product. Tech is shared by many Future Interface engine products, like Paper3D and Panel3D. It provides many low level utilities and platform encapsulation, and leaves the upper engine module focusing on the specific functionality. The following figure depicts the high-level module view of the Paper3D engine.

arch

Tech. The platform module takes charge of wrapping up the details of window management, the input, and EGL surface management and providing a unified interface to the underneath layers so that these layers don’t need to worry about platform specific stuff. In the ver0.9 pre, platform module has included the support of Android and win32. The support of iOS is planned in ver0.91 pre. To implement a new platform support module for Paper3D, TBD is the best reference. Next is paper3d layer, it contains particular functionality of Paper3D engine, like animation, scene graph and so on. We will cover the detail in section 2.Modules. foundation is a second major module of Tech. It contains a variant of utilities, the lifecycle management and wrappers to system calls on different platforms. Again, it will be detailed in section 2.Modules. Paper3D relies on OpenGL ES 2.0 and C runtime library to carry out its functionality. On Win32 platform, we use OpenGL ES 2.0 simulator from Imagination.

Modules

modules

Paper3D contains four major modules, from top to bottom, platform, paper3d, foundation and 3rd-party library. They are wired up in a layer-like structure. The top layer is dependent on the bottom one but not the other way around. That means a top layer can call functions in the  bottom layer but bottom layer cannot. For example, paper3d layer can use math functions in the foundation layer, but foundation layer doesn’t ever call function in the paper3d layer.

The topmost layer platform is essentially a wrapper of the window system. It has three modules, window, input and EGL surface. Each of these modules encapsulates the different usage of system and provides a uniform interface and data format to the layers underneath. Window module wraps up the creating a window, the main loop of the window, destroying a window and specific window events, e.g., window resizing. Each change to the window will notify the corresponding paper3d application context the by the window module. For the lifecycle of a paper3d application, one can refer to Section lifecycle, The EGL surface module namely takes charge to creating a EGL surface, initializing the OpenGL context, destroying surface and context, and swap buffers at every frame. It doesn’t have any linkage to the bottom layers. The input module translates the system input event to the paper3d one. For example, the mouse event in win32 platform is translated to a touch event in paper3d. 

paper3d layer contains all the specific functionality of paper3d. It has the scene graph, the animation, the particle system, resource management and a few others. Each module tackles the functionality that their names explain.

The foundation layer has two types of modules. One is context-related module (in dark purple) and the other is helper functions or classes (in light purple). The first type of modules serve the context directly. For example, the event module manages the event queue in an application context and lists all event types supported by paper3d. Runtime module is a core module in paper3d architecture. It is the interface of paper3d layer to the platform layer and drives the operation of an the paper3d application. In Section XXX, we will describe more about it. The second type of module are utility functions or classes. They are either system function wrappers or algorithm collections to be called by other modules at the top. For example, math module provides all kinds of vector math in C++ and a few other common math functions in graphics.

paper3d adopts four 3rd-party libraries, libpng, libz, tinyxml and inih. libpng and libz are for PNG image loading and saving. The tinyxml is a XML parser and inih is INI file parser.

The Life cycle

lifecycle

Paper3D has embedded the main function of each OS into the engine. For example, the main function on win32 platform can be found at platform\win32\main.cpp. The main function initiates a paper3d application, enters a main event loop and destroy the application when the event looping breaks. The whole life cycle of Paper3D is depicted in above figure.

As we already said, after operating system boots up the application and enters the main function, the platform layer of Paper3D takes over. It first creates a window and an EGL surface. Either of these two steps fails, the application will stop. Otherwise, it calls the foundation layer to create a PActivity instance and a PContext instance using parameters given by user. Then platform enters the main loop. At each iteration of the main loop, the input and other events including resume, pause and change to the window surface from operating system will translated into native events of paper3d and passed to PContext instance, and also PContext instance will call its update routing to update the context status and do the rendering afterwards.  When the mainloop breaks by either the execution error and quit event issued by PContext instance, platform layer will first call foundation layer to destroy PContext and PActivity instance and then it does its own cleanup and return the control to the operating system.

Inside a Paper3D context

Paper3D assigns a PContext instance to each window (or view in Android), or say each PContext is associated with one EGL context. One Paper3D application may contain more than one PContext instances and all these PContext instances are managed by PActivity instance which is unique in one application. 

Each PContext instance contains a few module instances. All these module class are inheriting PModule which has 5 virtual interface functions.

  • initialize
  • uninitialize
  • update
  • pause
  • resume

At specific event, e.g., update, PContext will iterate all these modules one by one and call their update function if any. The order of module traversal is determined by the module’s index in the module array. initialize, update and pause iterate modules in forward direction, while uninitialize and resume iterate modules in the reversed direction.

  • PSceneManager: organizes the scene graph, updates the each node of scene graph at every frame, and does the rendering.
  • PEffectManager: manages the full screen posteffects and execute these effects
  • PAnimationManager: manages all animations in the scene, play and stop animations 
  • PResourceManager: load and destroy mesh, texture, material and animation resource in the scene. 
  • PEventManager: the event queue of all events in the context.
  • PGestureManager: decipher the touch events into gesture events.

context

Posted in Document Tagged with:

Create a new Paper3D project

Paper3D has provided a few utility tools for Paper3D application development. With a only few key strokes, we can create a new Paper3D project. Just follow these steps.

  • Open cmd.exe and change directory to anywhere you want to create the project.
  • Create a file called project.mak (you can copy it from %FIPAPER3D%\examples\example.mak). 
    • Change the value of project_name to your desired one
    • Change the project_desc‘s value to the description of your project
    • Change company, author and email
    • width and height are the window resolution of Paper3D application on Windows platform. On Android, the Paper3D applications will detect and automatically fit the hardware screen resolution.
  • Enter %FIPAPER3D%\tools\bin\msvc2012\pmake.exe -f project.mak
  • Open OneExample\application\configs\msvc2012\oneexample.sln, and start your first Paper3D application development. Enjoy!
Posted in Document Tagged with:

Installation

The development of Paper3D supports Windows 7 and OSX only for now.

Download

Download latest stable Tech and Paper3D archives.

Installation of 3rd-party packages

  1. Download and install Microsoft Visual Studio 2012 Express at http://www.microsoft.com/en-us/download/details.aspx?id=34673
  2. Install the Android SDK and Eclipse bundle 32bit at http://dl.google.com/android/adt/adt-bundle-windows-x86-20131030.zip 64bit: TODO
  3. Install ANT from http://ant.apache.org/bindownload.cgi?Preferred=http%3A%2F%2Fmirrors.cnnic.cn%2Fapache%2F
  4. Install JDK 1.7 from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html Needs to be installed to C:\JDK
  5. Install the latest Android NDK https://developer.android.com/tools/sdk/ndk/index.html#Installing
  6. Setup environment variables
    JAVA_HOME=<JDK installation dir>
    ANT_HOME=<ANT installation dir>
    ANDROID_SDK=<Android SDK path>

    Add

    <ANT installation dir>\bin;<Android NDK installation dir>\;<Android SDK installation dir>\platform-tools\

    to PATH

Build 

  1. Inside the installation of tech folder, run install.bat if Windows, or install.sh otherwise.
  2. Inside the installation of paper3d folder, run install.bat if Windows, or install.sh otherwise.

Build first example

  1. Open MSVC 2012 and open %FIPAPER3D%/examples/hellopaper3d/configs/msvc2012/hello3d.sln
  2. Compile and run
  3. One should see following rendering window

paper3d

  1. Build the Android live wallpaper APK
  2. Open cmd.exe (the dos window)
  3. cd %FIPaper3D%/examples/hellopaper3d/application/configs/android/
  4. Enter build.bat debug
  5. If successful, the APK will be at %FIPaper3D%/examples/hellopaper3d/application/bin, named hellopaper3d-debug.apk
  6. Install the apk into your phone by entering adb install -r hellpaper3d-debug.apk

Congrats! You have built your first live wallpaper. For any questions, please drop an comment here or email to lihw81[@]gmail.com. Thanks a lot.

Posted in Document Tagged with: