About Store Forum Documentation Contact



Post Reply 
Create object without base
Author Message
Lancer Offline
Member

Post: #1
Create object without base
Hello,

is it possible to create an object without the base?

Example:

Code:
Object op;
op.base(EE::UIDZero);
op.type(true, ObjType.getID("OBJ_AVATAR"));
op.align(true, ALIGN_NONE, ALIGN_NONE, ALIGN_NONE);
Game::World.objCreateNear(op, Matrix(1.f, EE::Vec(0,0,0)));
02-15-2020 05:11 PM
Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Member

Post: #2
RE: Create object without base
i'm pretty sure you can create an obj with an empty base, but not with no base smile

for that just create an obj and leave it empty
02-15-2020 05:28 PM
Find all posts by this user Quote this message in a reply
Lancer Offline
Member

Post: #3
RE: Create object without base
Hello,

it seems to work fine with op.base(EE::UIDZero);
I'm able to spawn my character.

I just have 1 question and 1 issue (probably can be solved together).

Question:
How can I rotate my character?

Issue:
Whenever I call this
Code:
m_skel.updateBegin(); // begin update
        m_skel.clear();       // clear skeleton animation
        m_skel.animate(m_uidAnimation, Time.time()); // animate animation and current time position
        m_skel.updateMatrix(); // update skeleton animation matrixes
        m_skel.updateEnd(); // end update
then the character is no longer visible (I guess his pos changes)

Update:
I fixed the issue by changing
Code:
m_skel.updateMatrix(); // update skeleton animation matrixes
to this
Code:
m_skel.updateMatrix(Matrix()); // update skeleton animation matrixes
Is this good or bad?

Also any idea how to rotate the character? I tried
Code:
Matrix m = T.matrix();
m.orn().rotateY(60);
m.setPos(pos());
m_skel.updateMatrix(m);
but this doesn't change anything

I noticed the following:
if I call it like this
Code:
m.orn().rotateY(60);
m.setPos(pos());
m_skel.updateMatrix(m);
then rotateY does not work.

but if I call it like this,
Code:
m.setPos(pos());
m.orn().rotateY(60);
m_skel.updateMatrix(m);
then it works..

However, my solution now is:
Code:
Matrix m = T.matrix();

OrientP orn(m.pos, m.z, m.y); // convert matrix to positioned orientation
orn.rotateY(DegToRad(270));
orn.fix(); // normalize and realign

T.matrix(Matrix(orn)); // set matrix from positioned orientation
(This post was last modified: 02-17-2020 06:58 PM by Lancer.)
02-17-2020 06:07 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #4
RE: Create object without base
Hi Lancer,

Regarding updateMatrix() - yes it is correct. When you provide no argument then the default identity matrix is used, which is a (0,0,0) position without rotation.

To correctly create matrix you have to remember about two concepts EE is using:
- set(Pos/Rotate/Scale) functions reset matrix to identity one and then performs transformation
- move/scale/rotate functions does not reset matrix and apply transformations on top of existing ones.

Remember that order of transformations does matter. Rotating and moving matrix will give different results than moving and then rotating.

For your purposes you can try something like this:
Code:
Matrix m = Matrix().setPos(pos()).rotateY(DegToRad(60));
m_skel.updateBegin().clear().animate(m_uidAnimation, Time.time()).updateMatrix(m).updateEnd();
(This post was last modified: 02-17-2020 08:16 PM by Harry.)
02-17-2020 08:16 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Lancer Offline
Member

Post: #5
RE: Create object without base
Thank you
02-17-2020 10:58 PM
Find all posts by this user Quote this message in a reply
Post Reply