[DEV] try to have an example of low poly
This commit is contained in:
parent
183a0020d7
commit
a0132c0090
@ -122,7 +122,7 @@ class ExportEMF(bpy.types.Operator, ExportHelper):
|
|||||||
# generate binary file
|
# generate binary file
|
||||||
use_binary = BoolProperty(
|
use_binary = BoolProperty(
|
||||||
name="Binary",
|
name="Binary",
|
||||||
description="Export the filein binary mode",
|
description="Export the file in binary mode",
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -423,8 +423,8 @@ def write_file(filepath,
|
|||||||
###########################################################
|
###########################################################
|
||||||
## UV
|
## UV
|
||||||
###########################################################
|
###########################################################
|
||||||
fw('\t\tUV-mapping :\n\t\t\t')
|
|
||||||
if faceuv:
|
if faceuv:
|
||||||
|
fw('\t\tUV-mapping :\n\t\t\t')
|
||||||
# in case removing some of these dont get defined.
|
# in case removing some of these dont get defined.
|
||||||
uv = uvkey = uv_dict = f_index = uv_index = None
|
uv = uvkey = uv_dict = f_index = uv_index = None
|
||||||
uv_face_mapping = [None] * len(face_index_pairs)
|
uv_face_mapping = [None] * len(face_index_pairs)
|
||||||
@ -443,12 +443,17 @@ def write_file(filepath,
|
|||||||
uv_unique_count = len(uv_dict)
|
uv_unique_count = len(uv_dict)
|
||||||
del uv, uvkey, uv_dict, f_index, uv_index, uv_ls, uv_k
|
del uv, uvkey, uv_dict, f_index, uv_index, uv_ls, uv_k
|
||||||
# Only need uv_unique_count and uv_face_mapping
|
# Only need uv_unique_count and uv_face_mapping
|
||||||
fw('\n')
|
fw('\n')
|
||||||
|
else:
|
||||||
|
print("does not use UV-MAPPING")
|
||||||
###########################################################
|
###########################################################
|
||||||
## NORMAL
|
## NORMAL
|
||||||
###########################################################
|
###########################################################
|
||||||
if f.use_smooth:
|
if len(face_index_pairs) > 0:
|
||||||
localIsSmooth = 'vertex'
|
if face_index_pairs[0][0].use_smooth:
|
||||||
|
localIsSmooth = 'vertex'
|
||||||
|
else:
|
||||||
|
localIsSmooth = 'face'
|
||||||
else:
|
else:
|
||||||
localIsSmooth = 'face'
|
localIsSmooth = 'face'
|
||||||
fw('\t\tNormal(%s) : %d\n\t\t\t' % (localIsSmooth, len(face_index_pairs)) )
|
fw('\t\tNormal(%s) : %d\n\t\t\t' % (localIsSmooth, len(face_index_pairs)) )
|
||||||
@ -606,18 +611,18 @@ def _write(context,
|
|||||||
):
|
):
|
||||||
#
|
#
|
||||||
base_name, ext = os.path.splitext(filepath)
|
base_name, ext = os.path.splitext(filepath)
|
||||||
# create the output name :
|
# create the output name:
|
||||||
context_name = [base_name, '', '', ext] # Base name, scene name, frame number, extension
|
context_name = [base_name, '', '', ext] # Base name, scene name, frame number, extension
|
||||||
# get the curent scene :
|
# get the curent scene:
|
||||||
scene = context.scene
|
scene = context.scene
|
||||||
# Exit edit mode before exporting, so current object states are exported properly.
|
# Exit edit mode before exporting, so current object states are exported properly.
|
||||||
if bpy.ops.object.mode_set.poll():
|
if bpy.ops.object.mode_set.poll():
|
||||||
bpy.ops.object.mode_set(mode='OBJECT')
|
bpy.ops.object.mode_set(mode='OBJECT')
|
||||||
# get the curent frame selected :
|
# get the curent frame selected:
|
||||||
frame = scene.frame_current
|
frame = scene.frame_current
|
||||||
# Loop through all frames in the scene and export.
|
# Loop through all frames in the scene and export.
|
||||||
scene.frame_set(frame, 0.0)
|
scene.frame_set(frame, 0.0)
|
||||||
# get only the object that are selected or all ...
|
# get only the object that are selected or all...
|
||||||
if EXPORT_SEL_ONLY:
|
if EXPORT_SEL_ONLY:
|
||||||
objects = context.selected_objects
|
objects = context.selected_objects
|
||||||
else:
|
else:
|
||||||
|
@ -13,3 +13,4 @@ sample/Particle
|
|||||||
sample/RayTest
|
sample/RayTest
|
||||||
sample/Script
|
sample/Script
|
||||||
sample/StereoVision
|
sample/StereoVision
|
||||||
|
sample/LowPoly
|
1
sample/LowPoly/README.md
Normal file
1
sample/LowPoly/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
Camera position sample example
|
140
sample/LowPoly/appl/Windows.cpp
Normal file
140
sample/LowPoly/appl/Windows.cpp
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE-2 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ewol/ewol.hpp>
|
||||||
|
#include <appl/debug.hpp>
|
||||||
|
#include <appl/Windows.hpp>
|
||||||
|
#include <ewol/widget/Label.hpp>
|
||||||
|
#include <ewol/object/Manager.hpp>
|
||||||
|
#include <ege/widget/Scene.hpp>
|
||||||
|
#include <ege/camera/View.hpp>
|
||||||
|
#include <etk/tool.hpp>
|
||||||
|
#include <ege/elements/ElementBase.hpp>
|
||||||
|
#include <ege/elements/ElementPhysic.hpp>
|
||||||
|
|
||||||
|
appl::Windows::Windows() {
|
||||||
|
addObjectType("appl::Windows");
|
||||||
|
propertyTitle.setDirectCheck("example ege : LowPoly");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ememory::SharedPtr<ege::resource::Mesh> createViewBoxStar() {
|
||||||
|
ememory::SharedPtr<ege::resource::Mesh> out = ege::resource::Mesh::create("viewBoxStar", "DATA:texturedNoMaterial.prog");
|
||||||
|
if (out != nullptr) {
|
||||||
|
ememory::SharedPtr<ege::Material> material = ememory::makeShared<ege::Material>();
|
||||||
|
// set the element material properties :
|
||||||
|
material->setAmbientFactor(vec4(1,1,1,1));
|
||||||
|
material->setDiffuseFactor(vec4(0,0,0,1));
|
||||||
|
material->setSpecularFactor(vec4(0,0,0,1));
|
||||||
|
material->setShininess(1);
|
||||||
|
// 1024 == > 1<<9
|
||||||
|
// 2048 == > 1<<10
|
||||||
|
// 4096 == > 1<<11
|
||||||
|
int32_t size = 1<<11;
|
||||||
|
//material->setTexture0(""); //"
|
||||||
|
material->setTexture0Magic(ivec2(size,size));
|
||||||
|
out->addMaterial("basics", material);
|
||||||
|
//material->setImageSize(ivec2(size,size));
|
||||||
|
egami::Image* myImage = material->get();
|
||||||
|
if (nullptr == myImage) {
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
myImage->clear(etk::color::black);
|
||||||
|
ivec2 tmpPos;
|
||||||
|
for (int32_t iii=0; iii<6000; iii++) {
|
||||||
|
tmpPos.setValue(etk::tool::frand(0,size), etk::tool::frand(0,size)) ;
|
||||||
|
myImage->set(tmpPos, etk::color::white);
|
||||||
|
}
|
||||||
|
material->flush();
|
||||||
|
// basis on cube :
|
||||||
|
out->createViewBox("basics", 1000/* distance */);
|
||||||
|
// generate the VBO
|
||||||
|
out->generateVBO();
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace appl {
|
||||||
|
class Tree : public ege::ElementPhysic {
|
||||||
|
public:
|
||||||
|
Tree(const ememory::SharedPtr<ege::Environement>& _env) :
|
||||||
|
ege::ElementPhysic(_env, false) {
|
||||||
|
m_group = 1;
|
||||||
|
m_life = 100;
|
||||||
|
m_radius = 10;
|
||||||
|
loadMesh("DATA:tree_1.emf");
|
||||||
|
|
||||||
|
createRigidBody(10000);
|
||||||
|
///never deactivate the vehicle
|
||||||
|
m_body->setActivationState(DISABLE_DEACTIVATION);
|
||||||
|
// set the Element as an IA:
|
||||||
|
iaEnable();
|
||||||
|
}
|
||||||
|
void iaAction(float _step) {
|
||||||
|
|
||||||
|
}
|
||||||
|
void onLifeChange() {
|
||||||
|
APPL_DEBUG("Looze life " << m_life);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static ememory::SharedPtr<ege::Element> createTree(const ememory::SharedPtr<ege::Environement>& _env) {
|
||||||
|
return ememory::makeShared<appl::Tree>(_env);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void appl::Windows::init() {
|
||||||
|
ewol::widget::Windows::init();
|
||||||
|
|
||||||
|
getObjectManager().periodicCall.connect(sharedFromThis(), &appl::Windows::onCallbackPeriodicUpdateCamera);
|
||||||
|
|
||||||
|
m_env = ege::Environement::create();
|
||||||
|
// Create basic Camera
|
||||||
|
m_camera = ememory::makeShared<ege::camera::View>(vec3(30,30,-100), vec3(0,0,0));
|
||||||
|
m_env->addCamera("basic", m_camera);
|
||||||
|
|
||||||
|
ememory::SharedPtr<ege::widget::Scene> tmpWidget = ege::widget::Scene::create();
|
||||||
|
if (tmpWidget == nullptr) {
|
||||||
|
APPL_ERROR("Can not allocate widget ==> display might be in error");
|
||||||
|
} else {
|
||||||
|
tmpWidget->setEnv(m_env);
|
||||||
|
tmpWidget->propertyExpand.set(bvec2(true,true));
|
||||||
|
tmpWidget->propertyFill.set(bvec2(true,true));
|
||||||
|
tmpWidget->setCamera("basic");
|
||||||
|
setSubWidget(tmpWidget);
|
||||||
|
}
|
||||||
|
ememory::SharedPtr<ege::resource::Mesh> myMesh;
|
||||||
|
// Create an external box :
|
||||||
|
myMesh = createViewBoxStar();
|
||||||
|
if (myMesh != nullptr) {
|
||||||
|
m_env->addStaticMeshToDraw(myMesh);
|
||||||
|
}
|
||||||
|
myMesh = ege::resource::Mesh::createGrid(10, vec3(0,0,0), 5);
|
||||||
|
if (myMesh != nullptr) {
|
||||||
|
m_env->addStaticMeshToDraw(myMesh);
|
||||||
|
}
|
||||||
|
if (true) {
|
||||||
|
ememory::SharedPtr<ege::Element> myElement = createTree(m_env);
|
||||||
|
if (myElement != nullptr) {
|
||||||
|
m_env->addElement(myElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_env->propertyStatus.set(ege::gameStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void appl::Windows::onCallbackPeriodicUpdateCamera(const ewol::event::Time& _event) {
|
||||||
|
static float offset = 0;
|
||||||
|
offset += 0.01;
|
||||||
|
static float offset2 = 0;
|
||||||
|
offset2 += 0.003;
|
||||||
|
m_camera->setEye(vec3(100*std::sin(offset),100*std::cos(offset),40*std::cos(offset2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
29
sample/LowPoly/appl/Windows.hpp
Normal file
29
sample/LowPoly/appl/Windows.hpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE-2 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <ewol/widget/Windows.hpp>
|
||||||
|
#include <ege/Environement.hpp>
|
||||||
|
#include <ege/camera/View.hpp>
|
||||||
|
|
||||||
|
namespace appl {
|
||||||
|
class Windows : public ewol::widget::Windows {
|
||||||
|
private:
|
||||||
|
ememory::SharedPtr<ege::Environement> m_env;
|
||||||
|
ememory::SharedPtr<ege::camera::View> m_camera;
|
||||||
|
protected:
|
||||||
|
Windows();
|
||||||
|
void init();
|
||||||
|
public:
|
||||||
|
DECLARE_FACTORY(Windows);
|
||||||
|
virtual ~Windows() { };
|
||||||
|
private:
|
||||||
|
void onCallbackPeriodicUpdateCamera(const ewol::event::Time& _event);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
15
sample/LowPoly/appl/debug.cpp
Normal file
15
sample/LowPoly/appl/debug.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE-2 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <appl/debug.hpp>
|
||||||
|
|
||||||
|
int32_t appl::getLogId() {
|
||||||
|
static int32_t g_val = elog::registerInstance("GP-spaceShip");
|
||||||
|
return g_val;
|
||||||
|
}
|
40
sample/LowPoly/appl/debug.hpp
Normal file
40
sample/LowPoly/appl/debug.hpp
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE-2 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <elog/log.hpp>
|
||||||
|
|
||||||
|
namespace appl {
|
||||||
|
int32_t getLogId();
|
||||||
|
}
|
||||||
|
#define APPL_BASE(info,data) ELOG_BASE(appl::getLogId(),info,data)
|
||||||
|
|
||||||
|
#define APPL_PRINT(data) APPL_BASE(-1, data)
|
||||||
|
#define APPL_CRITICAL(data) APPL_BASE(1, data)
|
||||||
|
#define APPL_ERROR(data) APPL_BASE(2, data)
|
||||||
|
#define APPL_WARNING(data) APPL_BASE(3, data)
|
||||||
|
#ifdef DEBUG
|
||||||
|
#define APPL_INFO(data) APPL_BASE(4, data)
|
||||||
|
#define APPL_DEBUG(data) APPL_BASE(5, data)
|
||||||
|
#define APPL_VERBOSE(data) APPL_BASE(6, data)
|
||||||
|
#define APPL_TODO(data) APPL_BASE(4, "TODO : " << data)
|
||||||
|
#else
|
||||||
|
#define APPL_INFO(data) do { } while(false)
|
||||||
|
#define APPL_DEBUG(data) do { } while(false)
|
||||||
|
#define APPL_VERBOSE(data) do { } while(false)
|
||||||
|
#define APPL_TODO(data) do { } while(false)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define APPL_ASSERT(cond,data) \
|
||||||
|
do { \
|
||||||
|
if (!(cond)) { \
|
||||||
|
APPL_CRITICAL(data); \
|
||||||
|
assert(!#cond); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
68
sample/LowPoly/appl/main.cpp
Normal file
68
sample/LowPoly/appl/main.cpp
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE-2 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/types.hpp>
|
||||||
|
#include <ewol/ewol.hpp>
|
||||||
|
#include <gale/context/commandLine.hpp>
|
||||||
|
|
||||||
|
#include <appl/debug.hpp>
|
||||||
|
#include <appl/Windows.hpp>
|
||||||
|
#include <ewol/object/Object.hpp>
|
||||||
|
#include <ewol/widget/Manager.hpp>
|
||||||
|
#include <ewol/context/Context.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
class MainApplication : public ewol::context::Application {
|
||||||
|
public:
|
||||||
|
void onCreate(ewol::Context& _context) override {
|
||||||
|
APPL_INFO(" == > CREATE ... " << PROJECT_NAME << " v" << APPL_VERSION << " (START) [" << gale::getBoardType() << "] (" << gale::getCompilationMode() << ") (BEGIN)");
|
||||||
|
for( int32_t iii=0 ; iii<_context.getCmd().size(); iii++) {
|
||||||
|
std::string tmpppp = _context.getCmd().get(iii);
|
||||||
|
if ( tmpppp == "-h"
|
||||||
|
|| tmpppp == "--help") {
|
||||||
|
APPL_INFO(" -h/--help display this help" );
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO : Remove this : Move if in the windows properties
|
||||||
|
_context.setSize(vec2(800, 600));
|
||||||
|
|
||||||
|
// select internal data for font ...
|
||||||
|
_context.getFontDefault().setUseExternal(true);
|
||||||
|
_context.getFontDefault().set("FreeSerif;DejaVuSansMono", 19);
|
||||||
|
|
||||||
|
ememory::SharedPtr<ewol::widget::Windows> basicWindows = appl::Windows::create();
|
||||||
|
// create the specific windows
|
||||||
|
_context.setWindows(basicWindows);
|
||||||
|
APPL_INFO("==> CREATE ... " PROJECT_NAME " (END)");
|
||||||
|
}
|
||||||
|
|
||||||
|
void onStart(ewol::Context& _context) override {
|
||||||
|
APPL_INFO("==> START ... " PROJECT_NAME " (BEGIN)");
|
||||||
|
// nothing to do ...
|
||||||
|
APPL_INFO("==> START ... " PROJECT_NAME " (END)");
|
||||||
|
}
|
||||||
|
void onStop(ewol::Context& _context) override {
|
||||||
|
APPL_INFO("==> STOP ... " PROJECT_NAME " (START)");
|
||||||
|
// nothing to do ...
|
||||||
|
APPL_INFO("==> STOP ... " PROJECT_NAME " (END)");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Main of the program (This can be set in every case, but it is not used in Andoid...).
|
||||||
|
* @param std IO
|
||||||
|
* @return std IO
|
||||||
|
*/
|
||||||
|
int main(int _argc, const char *_argv[]) {
|
||||||
|
// second possibility
|
||||||
|
return ewol::run(new MainApplication(), _argc, _argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
9
sample/LowPoly/appl/main.hpp
Normal file
9
sample/LowPoly/appl/main.hpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE-2 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
BIN
sample/LowPoly/data/BlenderNatureAsset.blend
Normal file
BIN
sample/LowPoly/data/BlenderNatureAsset.blend
Normal file
Binary file not shown.
BIN
sample/LowPoly/data/tree_1.blend
Normal file
BIN
sample/LowPoly/data/tree_1.blend
Normal file
Binary file not shown.
BIN
sample/LowPoly/data/tree_1.blend1
Normal file
BIN
sample/LowPoly/data/tree_1.blend1
Normal file
Binary file not shown.
58
sample/LowPoly/data/tree_1.emf
Normal file
58
sample/LowPoly/data/tree_1.emf
Normal file
File diff suppressed because one or more lines are too long
56
sample/LowPoly/lutin_ege-sample-low-poly.py
Normal file
56
sample/LowPoly/lutin_ege-sample-low-poly.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
import lutin.debug as debug
|
||||||
|
import lutin.tools as tools
|
||||||
|
|
||||||
|
|
||||||
|
def get_type():
|
||||||
|
return "BINARY"
|
||||||
|
|
||||||
|
def get_sub_type():
|
||||||
|
return "SAMPLE"
|
||||||
|
|
||||||
|
def get_name():
|
||||||
|
return "ege-sample-CameraPosition"
|
||||||
|
|
||||||
|
def get_desc():
|
||||||
|
return "ege sample : CameraPisition"
|
||||||
|
|
||||||
|
def get_licence():
|
||||||
|
return "APACHE-2"
|
||||||
|
|
||||||
|
def get_compagny_type():
|
||||||
|
return "com"
|
||||||
|
|
||||||
|
def get_compagny_name():
|
||||||
|
return "atria-soft"
|
||||||
|
|
||||||
|
def get_maintainer():
|
||||||
|
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||||
|
|
||||||
|
def get_version():
|
||||||
|
return [0,1]
|
||||||
|
|
||||||
|
def configure(target, my_module):
|
||||||
|
|
||||||
|
my_module.add_src_file([
|
||||||
|
'appl/debug.cpp',
|
||||||
|
'appl/main.cpp',
|
||||||
|
'appl/Windows.cpp'
|
||||||
|
])
|
||||||
|
|
||||||
|
my_module.add_depend('ege')
|
||||||
|
|
||||||
|
my_module.add_path(".")
|
||||||
|
|
||||||
|
my_module.copy_path("data/*.emf")
|
||||||
|
|
||||||
|
my_module.add_flag('c++', [
|
||||||
|
"-DPROJECT_NAME=\"\\\"" + my_module.get_name() + "\\\"\"",
|
||||||
|
"-DAPPL_VERSION=\"\\\"" + tools.version_to_string(get_version()) + "\\\"\""
|
||||||
|
])
|
||||||
|
|
||||||
|
# set the package properties:
|
||||||
|
my_module.set_pkg("SECTION", ["Game"])
|
||||||
|
my_module.set_pkg("PRIORITY", "optional")
|
||||||
|
return True
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user