About Store Forum Documentation Contact



Post Reply 
[Solved] Mesh disappears on specific angles
Author Message
xzessmedia Offline
Member

Post: #1
[Solved] Mesh disappears on specific angles
Hi, i have read a thread about this topic, but i couldn't find it anymore..

my mesh disappears on specific angles, i guess it has to be something with sunrays or camera.
if the camera is fixed on same position (no rotation or movement) the mesh is always visible on all angles.

if i let the camera follow the mesh, on specific angles it disappears.
i tried with cull on and off, both the same

any ideas?

edit: problem has been solved.
the reason was that my T.pos() and T.matrix() did return the wrong values..
also i used actor.matrix().normalize which is unnecessary since actor.matrix() always return normalized values
(This post was last modified: 06-23-2013 07:00 PM by xzessmedia.)
06-13-2013 11:52 PM
Find all posts by this user Quote this message in a reply
xzessmedia Offline
Member

Post: #2
RE: Mesh disappears on specific angles
06-16-2013 12:39 PM
Find all posts by this user Quote this message in a reply
Abruzzi Offline
Member

Post: #3
RE: Mesh disappears on specific angles
Yes I have the same problem. Also I have problem with disappears game area(world area) around start pos(0,0,0) . Before update all was fine. This problem shown only when you launch the game(not in world editor). EE 1.0 (and android, and pc). I can take some screenshots if necessarysmile thanks in advance
06-16-2013 06:26 PM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #4
RE: Mesh disappears on specific angles
Xzess, the first link was because he didn't update his editor. The second was because he had messed up pos/matrix code, and it was probably doing a bad calculation for the frustum. The third link is because the building is too big, and the culling/frustum calculations become unreliable.
You could also try using
if (Renderer.rebuildDepthNeededForDebugDraw­ing()) Renderer.rebuildDepth();

Try posting some screenshots or a short video of it happening, and/or some code.
06-16-2013 08:56 PM
Find all posts by this user Quote this message in a reply
xzessmedia Offline
Member

Post: #5
RE: Mesh disappears on specific angles
well after adding this line of code into the draw function, nothing gets rendered..

anyways this is a bit source code... the question is, how do i sync the actor of the class with the pos / matrix ?
actually if i need a matrix or a position i take the actors one... i guess i have to sync those values so i can do this.pos() to get the real position or this.matrix() to get the matrix...
i guess i did something wrong here...

another question: my rotation axis of my actor is not right as in the mesh editor / object editor.. is it possible to fix it, how could it happen?
last thing: i want to create a addforce bomb so every actor in the radius of the bomb should apply forces i guess by substr. those positions (bomb and the target), normalize and multiply by intensity float!?
actually i iterate through all ships in this case, but how should the loop look like? should i do it this way?
pseudocode:

Code:
void ForceBomb(Vec pos, flt radius, flt energy)
{
   REPA(ships)
   {
      if(Dist(pos, ships[i].pos) <= radius)
      {
         Vec tmpos = bomb.pos() - ships[i].pos();
         tmpos.normalize();
         tmpos.mul(energy);
         ships[i].actor.addforce(tmpos);
      }
   }
}

Thank you for your help!

/******************************************************************************/
#include "stdafx.h"
/******************************************************************************/
/********************************************************************************​***********
* Tauri Defense Mine Class
* written by Tim Koepsel <tim.koepsel@xzessmedia.de>
********************************************************************************​***********/
class Mine : public Game::Obj
{

public:
Mine();
~Mine();

void create(Game::ObjParams &obj);
bool update();

uint drawPrepare();
void drawShadow();
void draw2D();
Actor* getActor() { return &actor; }

Matrix getactormatrix();
Vec getactorpos();
int getspeed();

virtual Vec pos ( ) { return _matrix.pos ;} // get position
virtual Matrix matrix ( ) { return _matrix ;} // get matrix
Matrix matrixscaled( ) { return _matrixscaled ;} // get matrix
virtual void pos (C Vec &pos ) { _matrix.pos = pos; _matrixscaled.pos = pos; } // set position
virtual void matrix(C Matrix &matrix) { _matrix = matrix; _matrixscaled = _matrix; _matrixscaled.scaleOrn(scale); } // set matrix, for most classes 'matrix' should be normalized

private:
Matrix _matrix;
Matrix _matrixscaled;

Vec scale;
MeshPtr mesh;
MaterialPtr material;
PhysBodyPtr phys;
Actor actor;


bool isAlive;

// Custom Parameters
Str shipname;
int hull;
int shield;
int attack;
int defense;
int speed;
flt angle;
bool isPlayer;


}



Mine::Mine()
{
// Read Custom Parameters
shipname = "Unbenannt";
hull = 10;
shield = 10;
attack = 10;
defense = 10;

angle = 0;
speed = 5;

isAlive = true;
isPlayer = false;
}

Mine::~Mine()
{

}

void Mine::create(Game::ObjParams &obj)
{
scale = obj.scale3();
mesh = obj.mesh();
material = obj.material();
phys = obj.phys();

_matrix = obj.matrixFinal().normalize();
_matrixscaled = _matrix;
_matrixscaled.scaleOrn(scale);

angle = Angle(obj.matrixFinal().z.xz())-PI_2;
speed = 5;

if(phys)
{
actor.create(*phys, 1, scale).matrix(_matrix);
actor.obj(this);
actor.group(AG_MINE);
}


// Read Custom Parameters
if(Param *par=obj.findParam(L"schiffname" ))shipname =par->asText();
if(Param *par=obj.findParam(L"huelle"))hull=par->asInt ();
if(Param *par=obj.findParam(L"angriff"))attack=par->asInt ();
if(Param *par=obj.findParam(L"verteidigung"))defense=par->asInt ();
if(Param *par=obj.findParam(L"schild"))shield=par->asInt ();
if(Param *par=obj.findParam(L"maxspeed"))speed=par->asFlt();
if(Param *par=obj.findParam(L"isPlayer"))isPlayer=par->asBool();


}

void Mine::draw2D()
{
//getactormatrix().draw();
actor.matrix().normalize().axis().drawP(RED, 0.005);
_matrixscaled.axis().drawP(BLUE, 0.005);
}

Bool Mine::update()
{

if(T.actor.cuts(AG_SHIP) || T.actor.cuts(AG_ASTEROID) || T.actor.cuts(AG_PLANET) || T.actor.cuts(AG_STATION))
{
// BOMB
}


if(Dist(playership.pos(), T.pos()) < 15)
{
// If Player is near mine
Vec dir = playership.pos()-T.pos();
dir.normalize();
T.actor.addVel(dir*1.5);
}

_matrixscaled.normalize();
actor.matrix().normalize();

return isAlive;

if(hull == 0)
{
isAlive = false;
return isAlive;
}

}


uint Mine::drawPrepare()
{
if(mesh && Frustum(mesh->box, actor.matrix().normalize()))
{
MaterialLock = material();
mesh->draw(getactormatrix());

MaterialLock = NULL;
}
return NULL;
}

void Mine::drawShadow()
{
if(mesh && Frustum(mesh->box, actor.matrix().normalize()))
{
MaterialLock = material();
mesh->drawShadow(getactormatrix());
MaterialLock = NULL;
}
}

Matrix Mine::getactormatrix()
{
Matrix m = actor.matrix().normalize();
return m;
}
Vec Mine::getactorpos()
{
Vec m = actor.pos();
return m;
}

int Mine::getspeed()
{
return speed;
}


void ForceBomb(Vec pos, flt radius, flt energy)
{
REPA(Ships)
{

}
}
(This post was last modified: 06-18-2013 09:14 PM by xzessmedia.)
06-17-2013 04:55 PM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #6
RE: Mesh disappears on specific angles
(06-17-2013 04:55 PM)xzessmedia Wrote:  anyways this is a bit source code... the question is, how do i sync the actor of the class with the pos / matrix ?
actually if i need a matrix or a position i take the actors one... i guess i have to sync those values so i can do this.pos() to get the real position or this.matrix() to get the matrix...
i guess i did something wrong here...

another question: my rotation axis of my actor is not right as in the mesh editor / object editor.. is it possible to fix it, how could it happen?

You want to use your actor matrix only. For the this.pos() function, just have it return actor.pos().

For the rotation axis, you can try setting the model to the right position in the Object editor-Transform -> move mesh to <0, 0, 0> or something like that. If that doesn't work or can't be done for some reason, you can use actor.massCenterL (something similar I think) to set the angular velocity rotational origin.

As for the collisions question, I will be looking into that after I finish a couple other tasks, so I'm not sure at the moment what the best way to go about it is, yet.
06-18-2013 10:16 AM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #7
RE: Mesh disappears on specific angles
Quote:another question: my rotation axis of my actor is not right as in the mesh editor / object editor.. is it possible to fix it, how could it happen?
I recommend looking into Game.Item, Game.Static, Game.Kinematic source code which handles correct object matrix rotation and scaling.

If you're object is dynamic (movable), then there's no need for class members _matrix _matrixscaled, but just always operate on actor.matrix (eventually scale that when using for drawing matrix)

please don't call actor.matrix().normalize(); as matrix from actor is always normalized.
06-23-2013 01:39 PM
Find all posts by this user Quote this message in a reply
xzessmedia Offline
Member

Post: #8
RE: Mesh disappears on specific angles
(06-16-2013 06:26 PM)Abruzzi Wrote:  Yes I have the same problem. Also I have problem with disappears game area(world area) around start pos(0,0,0) . Before update all was fine. This problem shown only when you launch the game(not in world editor). EE 1.0 (and android, and pc). I can take some screenshots if necessarysmile thanks in advance

yes indeed i noticed that to, this problem still exists for me the solution for me is to stop debugger and compile again (on mac)



(06-23-2013 01:39 PM)Esenthel Wrote:  
Quote:another question: my rotation axis of my actor is not right as in the mesh editor / object editor.. is it possible to fix it, how could it happen?
I recommend looking into Game.Item, Game.Static, Game.Kinematic source code which handles correct object matrix rotation and scaling.

If you're object is dynamic (movable), then there's no need for class members _matrix _matrixscaled, but just always operate on actor.matrix (eventually scale that when using for drawing matrix)

please don't call actor.matrix().normalize(); as matrix from actor is always normalized.
thanks for the info this helped a lot, also thank you rubeus, your answer solved my issue
(This post was last modified: 06-23-2013 07:05 PM by xzessmedia.)
06-23-2013 07:02 PM
Find all posts by this user Quote this message in a reply
Post Reply