About Store Forum Documentation Contact



Post Reply 
Actor creation query
Author Message
3DRaddict Offline
Member

Post: #1
Actor creation query
Using the Object Editor I've created a Floor Object consisting of Mesh and a Static PhysBody, and a Teapot Object consisting of Mesh and a Convex16 PhysBody.
Now, in code, I'm trying to create Actors from them, as follows:
Code:
// ---------
// floor
// ---------
MeshPtr floor;
PhysBodyPtr floor_phys;
Actor floor_actor;
Matrix floor_matrix;
// ---------
// teapot
// ---------
MeshPtr teapot_mesh;
PhysBodyPtr teapot_phys;
Actor teapot_actor;
Matrix teapot_matrix;

Code:
// floor
   floor=Game.ObjParamsPtr(UID(2938843032, 1109976187, 1028363138, 4228731008))->mesh();
   floor_matrix.setPosUp(Vec(0, 0, 0), Vec(0, 1, 0));
   floor_phys=Game.ObjParamsPtr(UID(2938843032, 1109976187, 1028363138, 4228731008))->phys();
   floor_actor.create(floor_phys, 1.0, &Vec(1.0, 1.0, 1.0), false);
  
   // teapot
   teapot_mesh=Game.ObjParamsPtr(UID(423304190, 1123228208, 3563003826, 1677812398))->mesh();
   teapot_matrix.setPosUp(Vec(0, 3, 0), Vec(0, 1, 0));
   teapot_phys=Game.ObjParamsPtr(UID(423304190, 1123228208, 3563003826, 1677812398))->phys();
   teapot_actor.create(teapot_phys, 1.0, &Vec(1.0, 1.0, 1.0), false);

But I'm getting the following error on Build:
[Image: ActorCreationError.jpg]

Commenting out the 'actor.create' lines, building and running gives what I would expect:

[Image: ActorCreationQuery.jpg]

The teapot stays suspended in mid-air, but my intention is to drag it around as an Actor.

I can not seem to find any clear documentation on how to create the Actor via code. I thought that what I've done here was correct, but the error indicates not so.
07-22-2014 08:42 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #2
RE: Actor creation query
without looking through visual studio or code editor myself at the moment
floor_actor.create(
and
teapot_actor.create(
Wants EE::Box not PhysBodyPtr as first argument.
(This post was last modified: 07-22-2014 09:20 PM by Zervox.)
07-22-2014 09:19 PM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #3
RE: Actor creation query
I use the equivelant of
teapot_actor.create( *teapot_phys, 1.0, Vec( 1.0, 1.0, 1.0 ) );
VS is probably confused about PhysBodyPtr versus *PhysBodyPtr and trying to use the first available overload. If that's not it, I'd have to do a bit more in-depth digging.

BTW, for all intents and purposes, the Ptr objects in EE *are* pointers.
(This post was last modified: 07-22-2014 09:35 PM by Rubeus.)
07-22-2014 09:34 PM
Find all posts by this user Quote this message in a reply
3DRaddict Offline
Member

Post: #4
RE: Actor creation query
Thanks for your replies.

No, Rubeus, your suggestion doesn't work.

Funny how it wants Box, when the Actor documentation show clearly that PhysBody is acceptable:

Code:
Actor& create (C ActorShapes &shapes , Flt density=1,                     Bool kinematic=false); // create from actor shapes, Exit on fail, 'density'=density multiplier,                                 'kinematic'=if create actor as kinematic
   Actor& create (C Plane       &plane                                                           ); // create from plane       , Exit on fail
   Actor& create (C Box         &box    , Flt density=1, C Vec *anchor=NULL, Bool kinematic=false); // create from box         , Exit on fail, 'density'=density           , 'anchor'=custom actor position, 'kinematic'=if create actor as kinematic
   Actor& create (C OBox        &obox   , Flt density=1, C Vec *anchor=NULL, Bool kinematic=false); // create from oriented box, Exit on fail, 'density'=density           , 'anchor'=custom actor position, 'kinematic'=if create actor as kinematic
   Actor& create (C Ball        &ball   , Flt density=1, C Vec *anchor=NULL, Bool kinematic=false); // create from ball        , Exit on fail, 'density'=density           , 'anchor'=custom actor position, 'kinematic'=if create actor as kinematic
   Actor& create (C Capsule     &capsule, Flt density=1, C Vec *anchor=NULL, Bool kinematic=false); // create from capsule     , Exit on fail, 'density'=density           , 'anchor'=custom actor position, 'kinematic'=if create actor as kinematic
   Actor& create (C Tube        &tube   , Flt density=1, C Vec *anchor=NULL, Bool kinematic=false); // create from tube        , Exit on fail, 'density'=density           , 'anchor'=custom actor position, 'kinematic'=if create actor as kinematic
   Actor& create (C Shape       &shape  , Flt density=1, C Vec *anchor=NULL, Bool kinematic=false); // create from shape       , Exit on fail, 'density'=density           , 'anchor'=custom actor position, 'kinematic'=if create actor as kinematic
   Actor& create (C PhysPart    &part   , Flt density=1, C Vec &scale =1   , Bool kinematic=false); // create from PhysPart    , Exit on fail, 'density'=density multiplier, 'scale '=custom body  scale   , 'kinematic'=if create actor as kinematic
   Actor& create (C PhysBody    &phys   , Flt density=1, C Vec &scale =1   , Bool kinematic=false); // create from PhysBody    , Exit on fail, 'density'=density multiplier, 'scale '=custom body  scale   , 'kinematic'=if create actor as kinematic
07-23-2014 07:23 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #5
RE: Actor creation query
Hi,

Rubeus's suggestion is good,
you have PhysBodyPtr, but the functions accept PhysBody, so you need to use the '*' operator.
teapot_actor.create(*teapot_phys);

Also the method with the PhysBody version accepts 3rd parameter as Vec, but you're passing a pointer to that (Vec*).
07-23-2014 08:39 AM
Find all posts by this user Quote this message in a reply
3DRaddict Offline
Member

Post: #6
RE: Actor creation query
Thank you, folks! I've now got me a couple of Actors! grin

(Pointers always confuse the hell out of me)
07-23-2014 10:37 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply