About Store Forum Documentation Contact



Post Reply 
question Game::Item
Author Message
Driklyn Offline
Member

Post: #16
RE: question Game::Item
Same here. Leave off the "->is()" part then.

What that means is that ObjItem[0].skeleton does not contain a skeleton (i.e. skeleton path is NOT set in World Editor).

If you have 5 OBJ_ITEM's and only 1 of those has a skeleton, that item may not necessarily be ObjItem[0]. It could be [1], [2], [3], or [4].
06-04-2011 09:56 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #17
RE: question Game::Item
(06-04-2011 09:56 PM)Driklyn Wrote:  Same here. Leave off the "->is()" part then.

What that means is that ObjItem[0].skeleton does not contain a skeleton (i.e. skeleton path is NOT set in World Editor).

If you have 5 OBJ_ITEM's and only 1 of those has a skeleton, that item may not necessarily be ObjItem[0]. It could be [1], [2], [3], or [4].

Ie I can not use a one skeleton? I need to create skeletons with different names for each object?

PS I just have five dice and use the same skeleton. I thought that it can be used for all objects in the WE ...
(This post was last modified: 06-04-2011 11:11 PM by Babulesnik.)
06-04-2011 11:10 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #18
RE: question Game::Item
You can use 1 skeleton like you're doing with the dice.

You need to set the same skeleton on each of the 5 OBJ_ITEM's and use ObjItem[i].skeleton, not ObjItem[0].skeleton.
06-05-2011 01:10 AM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #19
RE: question Game::Item
(06-05-2011 01:10 AM)Driklyn Wrote:  You can use 1 skeleton like you're doing with the dice.

You need to set the same skeleton on each of the 5 OBJ_ITEM's and use ObjItem[i].skeleton, not ObjItem[0].skeleton.

If I write ObjItem [0]. skeleton-> is (); or ObjItem [1]. skeleton-> is (); or ObjItem [2]. skeleton-> is (); ..... still crash

Code:
Bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   CamHandle(3.0f,22,CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT));

   Game::World.update(Cam.at);

   Gui.update();
  
   UpdateFrames(0.0035);

   if(Kb.bp(KB_SPACE))
   {
      
       Pos[0]=Vec(29.641,17,-2.182);Pos[1]=Vec(29.641,17,-1.574);Pos[2]=Vec(29.021,17,-2.156);Pos[3]=Vec(29.021,17,-1.552);Pos[4]=Vec(28.378,17,-1.870); //устанавливаем стартовые позиции кубиков для броска
       FREP(ObjItem.elms())
       {
         ObjItem[i].matrix(Matrix(ObjItem[i].matrix().rotateXY(Random.f(45),Random.f(45)))); //рандомно крутим матрицу кубика
         ObjItem[i].pos(Pos[i]);ObjItem[i].actor.active(true);
        // ObjItem[i].actor.mass(10);
         ObjItem[i].actor.addImpulse(Vec(0,-2,0));
       }
   }

   ObjItem[4].skeleton->is();

   UpdateAnim(&ObjAnimatable[0],Anim1,Frame);
   UpdateAnim(&ObjAnimatable[1],Anim2,Frame);
   UpdateAnim(&ObjAnimatable[2],Anim3,Frame);
   return true;
}

The screenshot shows that the skeleton is set


Attached File(s) Image(s)
   
06-05-2011 01:55 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #20
RE: question Game::Item
Just use:

Code:
ObjItem[4].skeleton();

Do you have more items in the world besides just those 5 dice? If so, you should probably create a custom object type, like OBJ_DIE, and use ObjDie[4] instead of ObjItem[4].
06-05-2011 06:57 AM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #21
RE: question Game::Item
(06-05-2011 06:57 AM)Driklyn Wrote:  Do you have more items in the world besides just those 5 dice?
no,only for the 5 cubes are visible in the screenshot. To them, I use a skeleton kubik.skel in WE.

PS Thank you for helping me.
06-05-2011 09:54 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #22
RE: question Game::Item
No problem. So, does the problem still exist? Do you know the exact line that's causing the error?
06-05-2011 08:47 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #23
RE: question Game::Item
(06-05-2011 08:47 PM)Driklyn Wrote:  No problem. So, does the problem still exist? Do you know the exact line that's causing the error?

Completion of the program comes when I add the line ObjItem[4].skeleton->is();
06-05-2011 09:44 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #24
RE: question Game::Item
That's because ObjItem[4] does not contain a skeleton.

Do not use "ObjItem[4].skeleton->is()", just use "ObjItem[4].skeleton" like so:

Code:
if (ObjItem[4].skeleton)
06-05-2011 11:06 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #25
RE: question Game::Item
(06-05-2011 11:06 PM)Driklyn Wrote:  That's because ObjItem[4] does not contain a skeleton.

Do not use "ObjItem[4].skeleton->is()", just use "ObjItem[4].skeleton" like so:

Code:
if (ObjItem[4].skeleton)

as now I get to the skeleton, find the point? The problem is this
06-05-2011 11:24 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #26
RE: question Game::Item
Do all 5 dice have a skeleton? Make it so they all do and just access the skeleton by using ObjItem[i].skeleton as you loop through the items.

If it still crashes, the problem is somewhere else.
06-05-2011 11:30 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #27
RE: question Game::Item
(06-05-2011 11:30 PM)Driklyn Wrote:  Do all 5 dice have a skeleton? Make it so they all do and just access the skeleton by using ObjItem[i].skeleton as you loop through the items.

If it still crashes, the problem is somewhere else.

I checked my index an array on all five dice. No result...
06-05-2011 11:33 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #28
RE: question Game::Item
So it's not crashing but nothing's happening?

What's your code now? And what exactly are you trying to achieve?
06-05-2011 11:46 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #29
RE: question Game::Item
(06-05-2011 11:46 PM)Driklyn Wrote:  So it's not crashing but nothing's happening?

What's your code now? And what exactly are you trying to achieve?

I need access to the points of the skeleton

All my code:
Code:
#include "stdafx.h"
#include "Chat.h"
#include "../Data/enum/_enums.h"

Str i;
Str Anim1="Anim/Kosti/p1_wait.anim",
    Anim2="Anim/Kosti/p2_wait.anim",
    Anim3="Anim/Kosti/p3_wait.anim";
Flt Frame,gon;
Struct_Chat Chat;
Flt point;
Skeleton *skel;

Vec Pos[4],gon_vec;

Motion Motions;

void UpdateAnim(Game::Animatable *ObjAnimatable,Str PathAnimation,Flt Time)
{
ObjAnimatable->cskel.clear().animate(PathAnimation,Time).updateMatrix(ObjAnimatable->matrix()).updateVelocities(false);
}
void UpdateFrames(Flt Speed)
{
   if(Time.time()){ Frame=Frame+Speed;if (Frame>(0.999))Frame=0.000;}
}
Game::ObjMemx<Game::Static> Statics;
Game::ObjMemx<Game::Animatable>ObjAnimatable;
Game::ObjMemx<Game::ObjParticles> ObjParticles;
Game::ObjMemx<Game::Item> ObjItem;
Game::ObjMemx<Game::ObjLightPoint> ObjLightPoint;


void InitPre()
{
   App.name("World Manager");
   App.flag=APP_MS_EXCLUSIVE|APP_FULL_TOGGLE;
   DataPath("../data");
   Paks.add("engine.pak");

   D.full(true).hpRt(true).hdr(true).volLight(true).sync(true);//.superSample(4);

}
Bool Init()
{
   Cam.set(Vec(29,15,-3)).dist=22;
   Cam.yaw=0.910;Cam.pitch=-0.650;

   Physics.create(CSS_NONE,true,"../Installation/PhysX");

   Game::World.init();

   Game::World.setObjType(Statics,OBJ_STATIC)
              .setObjType(ObjParticles,OBJ_PARTICLES)
              .setObjType(ObjLightPoint,OBJ_LIGHT_POINT)
              .setObjType(ObjItem,OBJ_ITEM)
              .setObjType(ObjAnimatable,OBJ_ANIMATABLE);
   Game::World.New("World/worldkosti.world");
   Game::World.update(Cam.at);

    Gui.kb_lit.zero();

    Chat.Init_Chat();
    Chat.Chat_Obj.getWindow("window_chat").pos(Vec2(  (D.w()-(D.w()*2)+0.057 ) ,D.h()-1.32 ));

   Physics.gravity(Vec(0,-40,0));
   FREP(5){ObjItem[i].actor.active(false);}

   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   CamHandle(3.0f,22,CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT));

   Game::World.update(Cam.at);

   Gui.update();
  
   UpdateFrames(0.0035);

   if(Kb.bp(KB_S))Renderer.screenShots("C:/scrin/","jpg");

   if(Kb.bp(KB_SPACE))
   {
      
       Pos[0]=Vec(29.641,17,-2.182);Pos[1]=Vec(29.641,17,-1.574);Pos[2]=Vec(29.021,17,-2.156);Pos[3]=Vec(29.021,17,-1.552);Pos[4]=Vec(28.378,17,-1.870); //устанавливаем стартовые позиции кубиков для броска
       FREP(ObjItem.elms())
       {
         ObjItem[i].matrix(Matrix(ObjItem[i].matrix().rotateXY(Random.f(45),Random.f(45)))); //рандомно крутим матрицу кубика
         ObjItem[i].pos(Pos[i]);ObjItem[i].actor.active(true);
        // ObjItem[i].actor.mass(10);
         ObjItem[i].actor.addImpulse(Vec(0,-2,0));
       }
   }

   // skel=ObjItem[4].skeleton;
    //point=skel->findPoint("1")->pos.x;

     point=ObjItem[4].skeleton->findPoint("1")->pos.x;
    

   UpdateAnim(&ObjAnimatable[0],Anim1,Frame);
   UpdateAnim(&ObjAnimatable[1],Anim2,Frame);
   UpdateAnim(&ObjAnimatable[2],Anim3,Frame);
   return true;
}
/******************************************************************************/
void Render()
{
Game::World.draw();
}
void Draw()
{
   Renderer(Render);
   D.text(0,0,S+point);
  // D.text(0,0.1,S+Time.fps());

   Gui.draw();
}
/******************************************************************************/
06-06-2011 12:05 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #30
RE: question Game::Item
Code:
point=ObjItem[4].skeleton->findPoint("1")->pos.x;

This line should work provided that you know for sure that: a) ObjItem[4] has a skeleton, and b) that skeleton has a point named 1. If either case is not true, the game will crash.

If you absolutely positive that both cases are true, then the game is crashing for some other reason.
06-06-2011 01:01 AM
Find all posts by this user Quote this message in a reply
Post Reply