/*
 * PVVMUD a 3D MUD
 * Copyright (C) 1998-1999  Programvareverkstedet (pvv@pvv.org)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
#include "pvvmud.H"
#include "cliobject.H"
#include "geometry.H"
#include "material.H"
#include "texture.H"
#include "renderer.H"
#include "pvvmudclient.H"

CCliObject::CCliObject(DWORD objectId, CWorldWorld * world, DWORD geometryId,const CPosition & position, const CDirection & direction )
  :CWorldObject(objectId,world,geometryId,position,direction){

}

CCliObject::CCliObject(DWORD objectId, CWorldObject * parent, DWORD geometryId,const CPosition & position, const CDirection & direction )
  :CWorldObject(objectId,parent,geometryId,position,direction){

}

CListener * CCliObject::getListener(){
  return NULL;
}


void CCliObject::draw(CRenderer * renderer){
  CGeometryCache * objGeoCache = renderer->getClient()->getGeometryCache();
  CTextureCache * materialCache = renderer->getClient()->getTextureCache();
  CMaterialCache * textureCache = renderer->getClient()->getMaterialCache();

  CGeometry * objGeo = objGeoCache->get( getGeometryId() );

  renderer->prepareDraw(this);

  renderer->transform(getPosition(), getDirection());

  if (objGeo != NULL) objGeo->draw( textureCache, materialCache);

  CObjectListItem * item = getFirst();
  while (item != NULL){
    CCliObject * object = (CCliObject*)item->getObject();
    item = item->getNext();
    object->draw( renderer );
  }

  renderer->postDraw();
}