Code Search for Developers
 
 
  

kobject3d.cpp from Spatial Knowledge Experiments at Krugle


Show kobject3d.cpp syntax highlighted

/*
    Copyright (C) 2003, 2004, 2005 by Luca Cappa 
    Written by Luca Cappa groton@users.sourceforge.net
  
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.
  
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.
  
    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

//
//???Till this code is not finished, do not generate it.
#if 0

#include "cssysdef.h"

#include "csutil/sysfunc.h"
#include "csutil/cscolor.h"
#include "csutil/cmdhelp.h"
#include "csutil/cspmeter.h"
#include "csutil/csstring.h"
#include "csutil/scfstr.h"

#include "cstool/csview.h"
#include "cstool/initapp.h"
#include "cstool/collider.h"

#include "iutil/vfs.h"
#include "iutil/eventq.h"
#include "iutil/event.h"
#include "iutil/objreg.h"
#include "iutil/csinput.h"
#include "iutil/virtclk.h"
#include "iutil/plugin.h"
#include "iutil/string.h"

#include "iengine/sector.h"
#include "iengine/engine.h"
#include "iengine/camera.h"
#include "iengine/light.h"
#include "iengine/texture.h"
#include "iengine/mesh.h"
#include "iengine/movable.h"
#include "iengine/material.h"

#include "imesh/object.h"
#include "imesh/genmesh.h"


#include "ivideo/graph3d.h"
#include "ivideo/graph2d.h"
#include "ivideo/natwin.h"
#include "ivideo/txtmgr.h"
#include "ivideo/texture.h"
#include "ivideo/material.h"
#include "ivideo/fontserv.h"

#include "igraphic/imageio.h"

#include "ivaria/reporter.h"
#include "ivaria/stdrep.h"
#include "ivaria/conout.h"
#include "ivaria/reporter.h"
#include "ivaria/stdrep.h"
#include "ivaria/collider.h"

#include "csgeom/quaterni.h"
#include "csgeom/transfrm.h"
#include "csgeom/math3d_d.h"
#include "csgeom/math3d.h"

#include "igeom/polymesh.h"
#include "igeom/objmodel.h"

#include "imap/loader.h"


#include "iaws/aws.h"
#include "iaws/awscnvs.h"

#include "korientation.h"
#include "kblock.h"
#include "kmap.h"
#include "kblockid.h"
#include "kflags.h"
#include "kappstate.h"
#include "ske.h"
#include "ksprite3d.h"
#include "ksprite3dlist.h"

#include "KObject3D.h"


SCF_IMPLEMENT_IBASE_EXT (KObject3D)
  SCF_IMPLEMENTS_INTERFACE (KObject3D)
SCF_IMPLEMENT_IBASE_EXT_END


KObject3D::KObject3D (const char* p_name) : 
  mPosition (0, 0, 0), mYRotation (0),
  m_visible (true)
{
  mGenMeshList = new KGenMeshList ();

  m_name.AttachNew (new scfString (p_name));
}

KObject3D::~KObject3D ()
{
  //I do this cause the ObjAdd in the Create method does an 
  //increfing of the KObject3D..
  this->ObjRemoveAll ();

  delete mGenMeshList;
}

void KObject3D::AddKSprite3D (KSprite3D* p_sprite, const csVector3& p_offset)
{
  this->ObjAdd (p_sprite);
  m_s3dList->Add (p_sprite);
  if (p_offset != NULL)
    m_offsets.Push (csVector3 (p_offset));
  else
    m_offsets.Push (csVector3 (0, 0, 0));
}


void KObject3D::SetSector (iSector* p_sector)
{
  int i;
  for (i = 0; i < m_s3dList->GetCount (); i++)
  {
    //get the sprite3d.
    csRef<KSprite3D> l_s3d = m_s3dList->Get (i);
    l_s3d->SetSector (p_sector);
  }//for
}

csVector3& KObject3D::GetPosition ()
{
  return m_position;
}

csVector3 KObject3D::GetOffset (int p_i)
{
  return m_offsets.Get (p_i);
}

float KObject3D::GetYRotation ()
{
  return m_yRotation;
}

void KObject3D::SetPosition (csVector3& p_pos)
{
  m_position = p_pos;
  int i;
  for (i = 0; i < m_s3dList->GetCount(); i++)
  {
    csRef<KSprite3D> l_s3d = m_s3dList->Get (i);

    csReversibleTransform l_transf (csYRotMatrix3 (this->m_yRotation), this->m_position);
    const csVector3 l_curVec = this->m_offsets.Get (i);
    l_s3d->SetYRotationPosition (m_yRotation, m_position + 
      l_transf.Other2ThisRelative (l_curVec));
    l_s3d->UpdateMove ();
  }//for
}

void KObject3D::SetYRotation (float p_yRotation)
{
  m_yRotation = p_yRotation;
  int i;
  for (i = 0; i < m_s3dList->GetCount(); i++)
  {
    csRef<KSprite3D> l_s3d = m_s3dList->Get (i);

    csYRotMatrix3 l_m (p_yRotation);
    csReversibleTransform l_transf (l_m, this->m_position);
    const csVector3 l_curVec = this->m_offsets.Get (i);
    l_s3d->SetYRotationPosition (m_yRotation, m_position + 
      l_transf.Other2ThisRelative (l_curVec));
    l_s3d->UpdateMove ();
  }//for
}

/* //?????????????????
void KObject3D::DeferUpdateLighting (int p_flags, int p_num)
{
  int i;
  for (i = 0; i < m_s3dList->GetCount(); i++)
  {
    csRef<KSprite3D> l_s3d = m_s3dList->Get (i);
    l_s3d->GetMeshWrapper ().DeferUpdateLighting (p_flags, p_num);
  }//for
}
*/

iString* KObject3D::GetName ()
{
  return m_name;
}

void KObject3D::SetVisible (bool p_visible)
{
  m_visible = p_visible;
  int i;
  for (i = 0; i < m_s3dList->GetCount (); i++)
  {
    csRef<KSprite3D> l_s3d = m_s3dList->Get (i);
    l_s3d->SetVisible (p_visible);
  }//for
}

bool KObject3D::IsVisible ()
{
  return m_visible;
}

//???
#endif



See more files for this project here

Spatial Knowledge Experiments

A simulation of 3D virtual worlds for psychological experiments

Project homepage: http://sourceforge.net/projects/ske
Programming language(s): C,C++,Perl
License: other

  isense/
  joystick/
  Jamfile
  KImageCardinalDirection.h
  SKE.cpp
  SKE.h
  eulerangles.c
  eulerangles.h
  ikdraggable.cpp
  ikdraggable.h
  ikdraghandler.h
  ikmission.h
  ikxmlreader.h
  ikxmlwriter.h
  kappstate.cpp
  kappstate.h
  kbasedraggable.cpp
  kbasedraggable.h
  kbasedraghandler.cpp
  kbasedraghandler.h
  kblock.cpp
  kblock.h
  kblockId.h
  kblockid.cpp
  kcamera.cpp
  kcamera.h
  kcollision.cpp
  kcommandprocessor.cpp
  kcommandprocessor.h
  kconstant.cpp
  kconstant.h
  kcursor3d.cpp
  kcursor3d.h
  kdata.cpp
  kdata.h
  kdatalist.cpp
  kdatalist.h
  kdragmanager.cpp
  kdragmanager.h
  keventhandlermanager.cpp
  keventhandlermanager.h
  kflags.cpp
  kflags.h
  kimagecardinaldirection.cpp
  kkeys.cpp
  kkeys.h
  kkeystate.cpp
  kkeystate.h
  klandmark.cpp
  klandmark.h
  klandmarklist.cpp
  klandmarklist.h
  klight.cpp
  klight.h
  klightlist.cpp
  klightlist.h
  kmap.cpp
  kmap.h
  kmission.cpp
  kmission.h
  kmissiontype.cpp
  kmissiontype.h
  kmode.cpp
  kmode.h
  kmousemanager.cpp
  kmousemanager.h
  kobject3d.cpp
  kobject3d.h
  korientation.cpp
  korientation.h
  kpath.cpp
  kpath.h
  kpathfollower.cpp
  kpathfollower.h
  kplayer.cpp
  kplayer.h
  kposition.cpp
  kposition.h
  kquaternion.cpp
  kquaternion.h
  ksaveddatamanager.cpp
  ksaveddatamanager.h
  ksegment3.h
  ksign.cpp
  ksign.h
  ksprite3d.cpp
  ksprite3d.h
  ksprite3dlist.cpp
  ksprite3dlist.h
  kterrain.cpp
  kterrain.h
  kthing.cpp
  kthing.h
  kutil.cpp
  kutil.h
  kwireframe.cpp
  kwireframe.h
  kxmlhelper.h
  movement1d.h
  movement3d.h
  quattypes.h