I found that loading meshes from xml .mesh files take a very long time in my project.
Is there any possibility in maratis to store meshes in binary format and load them with SDK from that format?
26 2012-09-11 12:31:50
Re: XML to binary... (is possible?) (9 replies, posted in General)
27 2012-09-10 14:16:55
Re: importing textures (12 replies, posted in General)
Hello!
I exported simple scene (box with texture) with 3d s max exporter ( http://forum.maratis3d.com/viewtopic.php?id=134&p=5 ). Export was successful.
When trying to open it in Maratis.app (Mac , 3.1 beta) , I see black box without texture. I tried to change path to texture in Box.mesh file, and to change parameters of texture.
I also tried to load this scene in iPhonePunlishing example. I saw the same result.
Can you look at this scene, what is wrong with it? Scene
28 2012-09-07 11:21:51
Re: Smoothly move the M3Object3d with custom behavior (5 replies, posted in Engine)
Thanks a lot!
29 2012-09-07 09:29:51
Re: Smoothly move the M3Object3d with custom behavior (5 replies, posted in Engine)
I think its ok with MVector3 newPosition = parent->getPosition() + dpos; ,
dpos - distance that object moved from last update.
Code works now, but movement is not smooth. its very jerky.
App works very slow.
How can I get current fps from engine? I want to experiment with different effects on/off and different meshes
I will try to use
engine->getSystemContext()->getSystemTick()
also
30 2012-09-07 09:18:09
Re: Smoothly move the M3Object3d with custom behavior (5 replies, posted in Engine)
I've found and fix the error ,code works now.
31 2012-09-07 08:36:24
Topic: Smoothly move the M3Object3d with custom behavior (5 replies, posted in Engine)
In my maratis project I have invisible Target object, and Camera, which has Follow Target behavior and Looks At target behavior.
I want to move target from my C++ code, thus force Camera follows this object.
I want to achieve effect of smooth moving the camera.
I create custom MoveTo behavior. Objects are initialized with new position , and the time during which they have to move. (If you familiar with cocos2d actions - I want to realize analogue of CCMoveTo for maratis).
I add behavior to my target object:
target = scene->getObjectByName("Target");
float animationDuration = 1.5;
MoveToBehaviour *moveToBeh = new MoveToBehaviour(target, categoryTargetPosition, animationDuration);
target->addBehavior( moveToBeh );
// delete behavior after delay
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, animationDuration*1.1 * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
target->deleteBehavior(0);
});
When this code executed, the camera instantly move to new position, without smooth movement.
What I'm doing wrong?
How to do this correctly?
Does MBehavior::update() is called periodically by engine , or should I manually call MBehavior::update() on every frame?
Code of MoveTo behavior class:
#ifndef _MB_MOVETO_H
#define _MB_MOVETO_H
#include <sys/time.h>
class MoveToBehaviour : public MBehavior
{
public:
// constructors / destructors
MoveToBehaviour(MObject3d * parentObject, MVector3 _pos, float _tm);
MoveToBehaviour(MoveToBehaviour & behavior, MObject3d * parentObject);
~MoveToBehaviour(void);
private:
float tm, elapsedTime;
MVector3 pos;
MVector3 initialPos;
struct timeval lastCallTime;
// M
public:
// destroy
void destroy(void);
// get new
static MBehavior * getNew(MObject3d * parentObject);
// get copy
MBehavior * getCopy(MObject3d * parentObject);
// name
static const char * getStaticName(void){ return "MoveTo"; }
const char * getName(void){ return getStaticName(); }
// events
void update(void);
void runEvent(int param){}
// variables
unsigned int getVariablesNumber(void);
MVariable getVariable(unsigned int id);
};
#endif
.cpp:
#include <MEngine.h>
#include "MoveToBehaviour.h"
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Init
/////////////////////////////////////////////////////////////////////////////////////////////////////////
MoveToBehaviour::MoveToBehaviour(MObject3d * parentObject, MVector3 _pos, float _tm) :
MBehavior(parentObject),
tm (_tm),
pos (_pos),
elapsedTime (0.0)
{
gettimeofday(&lastCallTime, NULL);
initialPos = MVector3();
if (parentObject) {
initialPos = parentObject->getPosition();
}
}
MoveToBehaviour::MoveToBehaviour(MoveToBehaviour & behavior, MObject3d * parentObject) :
MBehavior(parentObject),
tm (behavior.tm),
pos (behavior.pos),
elapsedTime (behavior.elapsedTime),
lastCallTime(behavior.lastCallTime),
initialPos (behavior.initialPos)
{}
MoveToBehaviour::~MoveToBehaviour(void) {}
void MoveToBehaviour::destroy(void)
{
delete this;
}
MBehavior * MoveToBehaviour::getNew(MObject3d * parentObject)
{
return new MoveToBehaviour(parentObject, MVector3() , 0.0 );
}
MBehavior * MoveToBehaviour::getCopy(MObject3d * parentObject)
{
return new MoveToBehaviour(*this, parentObject);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Variables
/////////////////////////////////////////////////////////////////////////////////////////////////////////
unsigned int MoveToBehaviour::getVariablesNumber(void){
return 2;
}
MVariable MoveToBehaviour::getVariable(unsigned int id)
{
switch(id)
{
default:
return MVariable("NULL", NULL, M_VARIABLE_NULL);
case 0:
return MVariable("time", &tm, M_VARIABLE_FLOAT);
case 1:
return MVariable("moveToPosition", &pos, M_VARIABLE_VEC3);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Events
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void MoveToBehaviour::update(void)
{
if (elapsedTime >= tm*1000.0) {
return;
}
MEngine * engine = MEngine::getInstance();
MGame * game = engine->getGame();
MLevel * level = engine->getLevel();
MScene * scene = level->getCurrentScene();
MObject3d * parent = getParentObject();
long lastMillis = lastCallTime.tv_sec * 1000 + lastCallTime.tv_usec / 1000;
struct timeval tv ;
gettimeofday(&tv, NULL);
long millis = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
long dt = millis - lastMillis;
lastCallTime = tv;
MVector3 dpos = (pos - initialPos) * ( ((float)dt) / (tm*1000.0) );
MVector3 newPosition = parent->getPosition() + dpos;
parent->setPosition( newPosition );
parent->updateMatrix();
elapsedTime += dt;
if (elapsedTime >= tm*1000.0) {
parent->setPosition( pos );
parent->updateMatrix();
}
}
32 2012-09-06 07:24:16
Re: Use of lua in maratis3d iOS project for hit testing (8 replies, posted in Scripting)
I cannot find method for hit testing in lua maratis3d docs. I found method RayHit, but I cannot understand fhow can I use it to determine on which mesh touch occurs.
SDK has functionality for this?
33 2012-09-06 06:21:03
Re: Fullscreen shaders and effects. (48 replies, posted in General)
Thanks!
From which object should I obtain the current FPS?
About post-processing:
Since I used SCREEN_WIDTH * SCREEN_HEIGHT (768 * 1204 on iPad , 640*960 on Retina iPhone ) as texture dimensions, I added
render->setTextureUWrapMode(M_WRAP_CLAMP);
render->setTextureVWrapMode(M_WRAP_CLAMP);
in
render->createTexture(&m_depthTextureId);
render->bindTexture(m_depthTextureId);
render->setTextureFilterMode(M_TEX_FILTER_NEAREST, M_TEX_FILTER_NEAREST);
render->texImage(0, SCREEN_WIDTH, SCREEN_HEIGHT, M_UINT, M_DEPTH, 0);
after render->bindTexture(m_depthTextureId);
34 2012-09-05 14:52:07
Re: Fullscreen shaders and effects. (48 replies, posted in General)
About performance - what is the best way to display FPS on screen?
I want to see it during development of my app.
Other statistics are also useful.
35 2012-09-05 14:26:31
Re: Use of lua in maratis3d iOS project for hit testing (8 replies, posted in Scripting)
Ok, thank you.
36 2012-09-05 09:14:15
Topic: Use of lua in maratis3d iOS project for hit testing (8 replies, posted in Scripting)
I make a 3D gallery app.
In that app I have three meshes on the first "screen".
Each mesh represents category of 3D models to view.
When user tap on one of these meshes, camera should translate to next screen with several meshes.
Can I use lua for mesh hit testing (ie determine to what the mesh user touched)?
Can I send (trigger) events from lua to my Objective C iOS code?
For example, when user select one of the categories and camera translates to it, I need to change UI (buttons, labels) in app.
37 2012-09-05 08:26:20
Re: Fullscreen shaders and effects. (48 replies, posted in General)
I added post-process DoF to iOS example.
38 2012-09-03 14:21:26
Re: Fullscreen shaders and effects. (48 replies, posted in General)
Ok
For retina support I added
self.contentScaleFactor = [UIScreen mainScreen].scale;
in initRenderingContext in EAGLView,
#define SCREEN_WIDTH ( [UIScreen mainScreen].bounds.size.width * [UIScreen mainScreen].scale)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height * [UIScreen mainScreen].scale)
to MyGame , and change all occurrences of screenWidth/ screenHeight and RESOL macro with these macroses.
Its now works on Retina.
I've also found a bug on iPad 1 with iOS 4.3.3, where short after launches program crashes with EXC_BAD_ACCESS.
I will deploy my app on 5.* and newer firmwares, so I leave this bug for now.
39 2012-09-03 13:22:38
Re: Fullscreen shaders and effects. (48 replies, posted in General)
I change M_UBYTE to M_UINT
render->texImage(0, RESOL, RESOL, M_UBYTE, M_DEPTH, 0); , and program began to work.
Now project works on 4.3.3 and 5.1 devices, and on simulator.
On Retina display, image takes only quarter of screen.
I will fix this now, and then I'll start to add Depth of Field to this app
40 2012-09-03 09:52:12
Re: Fullscreen shaders and effects. (48 replies, posted in General)
I add glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer); at start of the resizeFromLayer: , and buffers are created on 5.*
Now I have to deal with 0x500 in render->texImage(0, RESOL, RESOL, M_UBYTE, M_DEPTH, 0); in MyGame.
41 2012-09-03 09:05:32
Re: Fullscreen shaders and effects. (48 replies, posted in General)
I've found that
glCheckFramebufferStatus(GL_FRAMEBUFFER) returns error after
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
[context renderbufferStorage:GL_RENDERBUFFER fromDrawable:layer];
in resizeFromLayer: in ES2Renderer.
42 2012-09-03 08:13:15
Re: Fullscreen shaders and effects. (48 replies, posted in General)
I not found the error for now.
I tried to compare initialization code in maratis ios project with initialization code in Cocos2D v 2.0.
In Cocos2d 2.0 init and creation of ramebuffer (with depth attachment) is ok both on 4.* and on 5.*.
Code in both projects looks equally, but in maratis I still have " Failed to make complete framebuffer object 8cdd" in glCheckFramebufferStatus(GL_FRAMEBUFFER).
I think that reason may be in maratis 3d code, which executed between calls to [ES2Renderer init] and [ES2Renderer resizeFromLayer:]
I will try to find it now.
43 2012-08-31 13:43:58
Re: Fullscreen shaders and effects. (48 replies, posted in General)
On iOS 5.* I also get 0x8cdd (GL_FRAMEBUFFER_UNSUPPORTED) in glCheckFramebufferStatus(GL_FRAMEBUFFER) in
- (BOOL) resizeFromLayer:(CAEAGLLayer *)layer;
in ES2Renderer.mm.
44 2012-08-31 13:03:39
Re: Fullscreen shaders and effects. (48 replies, posted in General)
On 4.3 devices all is ok.
On iPhone 4 (with retina display) image occupies a quarter of the screen (I think I must set contentScalFactor somewhere)
45 2012-08-31 12:44:47
Re: Fullscreen shaders and effects. (48 replies, posted in General)
I used simulator 4.3.
The errors looks like opengl is not initialized properly, something different to do with the more recent os ?
Looks like so.
I will try to run program on 4.* devices, and on Simulator 5.0 (when I download it).
I will try to google that.
46 2012-08-31 12:41:22
Re: Fullscreen shaders and effects. (48 replies, posted in General)
I installed Simulator 4.3, and program runs ok on it, without gl errors.
Before that, I ran the program on simulator 5.1
47 2012-08-31 12:05:01
Re: Fullscreen shaders and effects. (48 replies, posted in General)
last two errors occurs on each frame
I think there is some errors in creation of depth attachment texture in my project.
I will try to research this now.
48 2012-08-31 11:48:31
Re: Fullscreen shaders and effects. (48 replies, posted in General)
I've got OpenGL error 0x500 in MyGame::MyGame() in
render->texImage(0, RESOL, RESOL, M_UBYTE, M_DEPTH, 0);
Also I've got OpenGL error 0x506 in MyGame::draw() in
render->clear(M_BUFFER_COLOR | M_BUFFER_DEPTH);
in if(camera) .. block.
Also I've got 0x506 in MyGame::draw() scene->draw(camera); in
glDrawElements(returnPrimitiveType(type), size, returnGLType(indicesType), indices);
49 2012-08-31 11:07:15
Re: Fullscreen shaders and effects. (48 replies, posted in General)
I made checkout from svn and add last MyGame.h/.cpp,
and move
game = new MyGame();
engine->setGame(game);
after
[self loadMaratisProject:filename];
What version of Simulator/Device you use?
50 2012-08-31 08:41:34
Re: Fullscreen shaders and effects. (48 replies, posted in General)
I got gray and black image (like stones or wall texture) both on Simulator and on the device.
I will try now to look whats wrong and debug opengl.