About Store Forum Documentation Contact
Donations:
327$/mo



Post Reply 
can i scale 1x1x1 cube to make it i.e. 1x2x3?
Author Message
dziablo Offline
Member

Post: #1
can i scale 1x1x1 cube to make it i.e. 1x2x3?
Code:
Game.Obj* obiekt = Game.World.objCreateNear(*obj, Matrix(Vec(1, 2, 3), Vec(0, -2, 0)));
i thought i can do it by scalling by Vec but it does not work.
10-16-2013 04:38 PM
Find all posts by this user Quote this message in a reply
Pherael Offline
Silver Supporter

Post: #2
RE: can i scale 1x1x1 cube to make it i.e. 1x2x3?
If you cube is Static (or any other default Esenthel Obj type)

Code:
void Static::create(ObjParams &obj)
{
   scale   =obj.scale3     (); //<--- THERE
   mesh    =obj.mesh       ();
   material=obj.material   ();
   phys    =obj.phys       ();
  _matrix  =obj.matrixFinal().normalize(); _matrix_scaled=_matrix; _matrix_scaled.scaleOrn(scale); <-- AND THERE

   if(phys)actor.create(*phys, 0, scale).matrix(_matrix)
                .obj   (this)
                .group (AG_STATIC);
}

as you see above funtion create() rescale object to obj.scale3()
(This post was last modified: 10-16-2013 06:55 PM by Pherael.)
10-16-2013 06:54 PM
Find all posts by this user Quote this message in a reply
dziablo Offline
Member

Post: #3
RE: can i scale 1x1x1 cube to make it i.e. 1x2x3?
Tested it on static object and it works, but my object is extended from Game::Item and variable 'scale' is flt there, so i cant scale it in 3 dimensions? only kinematik objects can be scaled in 3d?
10-16-2013 10:06 PM
Find all posts by this user Quote this message in a reply
dziablo Offline
Member

Post: #4
RE: can i scale 1x1x1 cube to make it i.e. 1x2x3?
Code:
class Item : Game.Item
{
   Vec scale;
   Matrix matrix()                  {return _matrix;}
   void matrix(C Matrix &matrix)    {_matrix=matrix; _matrix_scaled=_matrix; _matrix_scaled.scaleOrn(scale); }
   Matrix matrixScaled(){return _matrix_scaled;}
   void pos(C Vec &pos) {_matrix.pos=pos; _matrix_scaled.pos=pos;}
  
   Vec pos() {return _matrix.pos;}
  
   virtual void create(Game.ObjParams &obj)
   {
      super.create(obj);
      scale   =obj.scale3     (); //<--- THERE
      mesh    =obj.mesh       ();
      material=obj.material   ();
      phys    =obj.phys       ();
      _matrix  =obj.matrixFinal().normalize();
      _matrix_scaled=_matrix;
      _matrix_scaled.scaleOrn(scale); //<-- AND THERE
      if(phys)actor.create(*phys, 1, scale).matrix(_matrix).obj   (this);
      actor.group(5);
      if(Param *par=obj.findParam("fizyka"))fizyka=par.asBool();
   }
   virtual uint drawPrepare() // extend drawing to include requesting for RM_BEHIND mode
   {
      return super.drawPrepare() | IndexToFlag(RM_OUTLINE);
   }
   virtual void drawOutline() // extend drawing to include rendering "behind effect"
   {
      if(mesh)
      {
         //SetBehindBias(mesh->box.h());
        
         //mesh->drawOutline(Color(64, 128, 255, 255), matrix());
      }
   }
   Bool update()
   {
      //this->pos(actor.pos());
      return true;  
   }  
   protected:
   Matrix _matrix, _matrix_scaled;
}

so... pfft i made class like this and object is scalled and everything works till i set .kinematic(false), after that actor works like it should(falls down) but mesh is not following actor. Any help?

[Image: xVyoSl.jpg]
10-17-2013 03:25 PM
Find all posts by this user Quote this message in a reply
Pherael Offline
Silver Supporter

Post: #5
RE: can i scale 1x1x1 cube to make it i.e. 1x2x3?
Change your pos and matrix function similar to this.
Code:
Vec    pos         (                ) {return actor.pos   (      );                }
void   pos         (C Vec    &pos   ) {       actor.pos   (pos   );                }
Matrix matrix      (                ) {return actor.matrix(      );                }
Matrix matrixScaled(                ) {return actor.matrix(      ).scaleOrn(scale);}
void  matrix      (C Matrix &matrix) {       actor.matrix(matrix);                }

Also, the code from Item.create is
Code:
scale   =obj.scale   ();
   mesh    =obj.mesh    ();
   material=obj.material();
   phys    =obj.phys    ();

   if(phys)actor.create  (*phys, 1, scale).matrix(obj.matrixFinal().normalize())
                .adamping(5   )
                .obj     (this)
                .ccd     (true);
So you set some things two times (like mesh), you don't need to call super.create(obj);

I highly recommended to study Object Source Code, you will find a lot of useful information there.

Edit: Also sorry about my first post, it was litle confusing, but I'm glad you figure it out.
(This post was last modified: 10-17-2013 04:15 PM by Pherael.)
10-17-2013 04:05 PM
Find all posts by this user Quote this message in a reply
dziablo Offline
Member

Post: #6
RE: can i scale 1x1x1 cube to make it i.e. 1x2x3?
thank you very much it works, Object source code yeah id love to study that but where can i find it?
10-17-2013 04:14 PM
Find all posts by this user Quote this message in a reply
Pherael Offline
Silver Supporter

Post: #7
RE: can i scale 1x1x1 cube to make it i.e. 1x2x3?
Ah, sorry, I just remember is probably available only for licensed developers.
10-17-2013 04:17 PM
Find all posts by this user Quote this message in a reply
dziablo Offline
Member

Post: #8
RE: can i scale 1x1x1 cube to make it i.e. 1x2x3?
I had another problem with that. When i rotated scaled object mesh was in right position but rotation was out of sync with actor this time. i fixed it by changing scaleOrn to scaleOrnL there:
Code:
Matrix matrixScaled(                ) {return actor.matrix(      ).scaleOrnL(scale);}
just mentioning smile
10-22-2013 10:35 PM
Find all posts by this user Quote this message in a reply
Post Reply