irrlib

irrlib Mercurial Source Tree


Root/WIP/Irr3D.cpp

#include "Irr3D.h"
#include "Irr3DObj.h"
#include <cstdlib>
#include "Newton.h"
 
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
Irr3D::Irr3D()
{
    this->nObjects = 0;
}
 
Irr3DObj    Irr3D::create()
{
    Irr3DObj obj;
    obj.setObjectID(this->nObjects);
    this->nObjects++;
    return obj;
}
 
Irr3DObj    Irr3D::create(irr::core::stringc fmesh)
{
    IMeshSceneNode * node = this->device->getSceneManager()->addMeshSceneNode(this->device->getSceneManager()->getMesh(fmesh.c_str())->getMesh(0));
    Irr3DObj obj;
    obj.setObjectID(this->objects.size());
    this->objects.push_back(node);
    return obj;
 
}
 
void        Irr3D::setTexture(Irr3DObj & obj, irr::core::stringw fname)
{
 
}
 
void        Irr3D::setMesh(Irr3DObj & obj, irr::core::stringc fmesh)
{
    //this->irr_node = smgr->addMeshSceneNode(smgr->getMesh(this->texture.c_str())->getMesh(0));
    this->objects.push_back(this->device->getSceneManager()->addMeshSceneNode(this->device->getSceneManager()->getMesh(fmesh.c_str())->getMesh(0)));
}
 
vector3df   Irr3D::getPosition(Irr3DObj & obj)
{
    if (obj.getObjectID() == -1)
        return vector3df(0,0,0);
    else
        return this->objects[obj.getObjectID()]->getPosition();
}
 
void        Irr3D::setPosition(Irr3DObj & obj, irr::f32 x,irr::f32 y,irr::f32 z)
{
    if (obj.getObjectID() != -1)
        this->objects[obj.getObjectID()]->setPosition(vector3df(x, y, z));
}
 
void        Irr3D::move(Irr3DObj & obj, float dx, float dy, float dz)
{
    vector3df mv(dx, dy, dz);
    mv += this->getPosition(obj);
    this->setPosition(obj, mv.X, mv.Y, mv.Z);
}
 
void    Irr3D::setDevice(IrrlichtDevice* dev)
{
    this->device = dev;
}
 
void Irr3D::setColor(Irr3DObj & obj, irr::u32 a, irr::u32 r, irr::u32 g, irr::u32 b)
{
    this->objects[obj.getObjectID()]->getMaterial(0).EmissiveColor.set(a, r, g, b);
}

Archive Download this file

Branches

Tags

Page rendered in 0.76856s using 11 queries.