void* init( const void* params){ xen::ModuleApiGraphics* mod_ren = xen::getModuleApi<xen::ModuleApiGraphics>(); xen::ModuleApiWindow* mod_win = xen::getModuleApi<xen::ModuleApiWindow>(); XenAssert(mod_ren != nullptr, "Graphics module must be loaded before cornell-box"); XenAssert(mod_win != nullptr, "Window module must be loaded before cornell-box"); state = (State*)xen::kernelAlloc(sizeof(State)); state->window = mod_win->createWindow({600, 600}, "line-test"); state->window_target = mod_ren->createWindowRenderTarget(state->window); state->render_params.camera.z_near = 0.001; state->render_params.camera.z_far = 1000; state->render_params.camera.fov_y = 70_deg; state->render_params.camera.up_dir = Vec3r::UnitY; state->render_params.camera.look_dir = -Vec3r::UnitZ; state->render_params.camera.position = Vec3r{0, 0, 50}; state->render_params.ambient_light = {1,1,1}; initMeshes(mod_ren); initRenderCommands(); return state; }
ShapeCylinder::ShapeCylinder(double _radius, double _height) : Shape(P_CYLINDER), mRadius(_radius), mHeight(_height) { initMeshes(); if (mRadius > 0.0 && mHeight > 0.0) { computeVolume(); } }
MeshShape::MeshShape(Eigen::Vector3d _dim, const aiScene *_mesh) : Shape(P_MESH), mMesh(_mesh), mDisplayList(0) { mDim = _dim; initMeshes(); if (mDim != Eigen::Vector3d::Zero()) computeVolume(); }
BoxShape::BoxShape(const Eigen::Vector3d& _size) : Shape(BOX), mSize(_size) { assert(_size[0] > 0.0); assert(_size[1] > 0.0); assert(_size[2] > 0.0); mBoundingBoxDim = _size; initMeshes(); computeVolume(); }
void PreloaderSystem::initialize() { m_entityFactory = static_cast<EntityFactory*>(m_world->getSystem( SystemType::EntityFactory)); initAssemblages(); m_gfxBackend = static_cast<GraphicsBackendSystem*>(m_world->getSystem( SystemType::GraphicsBackendSystem)); initMeshes(); }
ShapeEllipsoid::ShapeEllipsoid(Vector3d _dim, double _mass) : Shape(P_ELLIPSOID, _mass) { mDim = _dim; initMeshes(); if (mDim != Vector3d::Zero()) computeVolume(); if (mMass != 0){ mInertia = computeInertia(mMass); } }
MeshShape::MeshShape(const Eigen::Vector3d& _scale, const aiScene* _mesh) : Shape(MESH), mScale(_scale), mMesh(_mesh), mDisplayList(0) { assert(_scale[0] > 0.0); assert(_scale[1] > 0.0); assert(_scale[2] > 0.0); _updateBoundingBoxDim(); computeVolume(); initMeshes(); }
void THIS::create_mesh_instance() { printv_func(DEBUG); /// @TODO fix this //if(!hasScene()) return; auto p = getParent(); auto scene = dynamic_cast<neb::gfx::core::scene::base*>(p->getScene()); if(!mesh_slot_) { //LOG(lg, neb::gfx::sl, debug) << "mesh registered"; auto model = p->getPoseGlobal().mat4_cast() * glm::scale(p->scale_); auto dif = neb::fnd::math::color::ucolor8888::rand(); auto amb = neb::fnd::math::color::color::gray(0.2); auto spc = neb::fnd::math::color::color::white(); auto emi = neb::fnd::math::color::color::black(); /* LOG(lg, neb::gfx::sl, debug) << "diffuse " << std::hex << dif; LOG(lg, neb::gfx::sl, debug) << "diffuse r " << std::hex << (unsigned int)dif.r; LOG(lg, neb::gfx::sl, debug) << "diffuse g " << std::hex << (unsigned int)dif.g; LOG(lg, neb::gfx::sl, debug) << "diffuse b " << std::hex << (unsigned int)dif.b; LOG(lg, neb::gfx::sl, debug) << "diffuse a " << std::hex << (unsigned int)dif.a; //dif.print(); LOG(lg, neb::gfx::sl, debug) << "ambient"; //amb.print(); LOG(lg, neb::gfx::sl, debug) << "specular"; //spc.print(); LOG(lg, neb::gfx::sl, debug) << "emission"; //emi.print(); */ scene->initMeshes(); assert(scene->meshes_.cuboid_); mesh_slot_ = scene->meshes_.cuboid_->instances_->reg( model, glm::vec4(-1.0,-1.0,-1.0,-1.0), (unsigned int)dif, amb, spc, emi, 100.0 ); } }
ShapeMesh::ShapeMesh(Vector3d _dim, const aiScene *_mesh) : Shape(P_MESH, 0), mMesh(_mesh), mDisplayList(0) { mDim = _dim; initMeshes(); if (mDim != Vector3d::Zero()) computeVolume(); if (mMass != 0){ mInertia = computeInertia(mMass); } }
void* init( const void* params){ xen::ModuleApiGraphics* mod_ren = xen::getModuleApi<xen::ModuleApiGraphics>(); xen::ModuleApiWindow* mod_win = xen::getModuleApi<xen::ModuleApiWindow>(); XenAssert(mod_ren != nullptr, "Graphics module must be loaded before cornell-box"); XenAssert(mod_win != nullptr, "Window module must be loaded before cornell-box"); state = (State*)xen::kernelAlloc(sizeof(State) + xen::kilobytes(1)); state->arena.start = xen::ptrGetAdvanced(state, sizeof(State)); state->arena.end = xen::ptrGetAdvanced(state->arena.start, xen::kilobytes(1)); state->arena.next_byte = state->arena.start; state->window = mod_win->createWindow({600, 600}, "cornell-box"); state->window_target = mod_ren->createWindowRenderTarget(state->window); initCamera(); initSceneLights(); initMeshes(mod_ren); initRenderCommands(mod_ren, state->arena); return state; }