Closed RameshRavone closed 9 years ago
I just created a 3d model and imported to minko3, but bullet::collider not applying.
this is my code.
#include "minko/Minko.hpp" #include "minko/MinkoSDL.hpp" #include "minko/MinkoJPEG.hpp" #include "minko/MinkoPNG.hpp" #include "minko/MinkoASSIMP.hpp" #include "minko/MinkoBullet.hpp" using namespace minko; using namespace minko::scene; using namespace minko::component; using namespace minko::math; const uint WINDOW_WIDTH = 800; const uint WINDOW_HEIGHT = 600; const std::string M_MONSTER = "model/monster-Walk.dae"; int main (int argc, char** argv) { auto canvas = Canvas::create("Monster-run", WINDOW_WIDTH, WINDOW_HEIGHT); auto sceneManager = SceneManager::create(canvas->context()); sceneManager->assets() ->registerParser<file::ASSIMPParser>("dae") ->registerParser<file::JPEGParser>("jpg") ->registerParser<file::PNGParser>("png"); sceneManager->assets()->load("effect/Phong.effect"); sceneManager->assets() ->queue(M_MONSTER) ->queue("effect/Phong.effect") ->geometry("cube", geometry::CubeGeometry::create(sceneManager->assets()->context())); sceneManager->assets()->defaultOptions() ->resizeSmoothly(true) ->generateMipmaps(true) ->effect(sceneManager->assets()->effect("effect/Phong.effect")); auto root = scene::Node::create("root") ->addComponent(sceneManager) ->addComponent(bullet::PhysicsWorld::create()); auto camera = scene::Node::create("camera") ->addComponent(Renderer::create(0x7f7f7fff)) ->addComponent(Transform::create( Matrix4x4::create()->lookAt(Vector3::zero(), Vector3::create(0.f, 0.f, 5.f)))) ->addComponent(PerspectiveCamera::create( (float)WINDOW_WIDTH / (float)WINDOW_HEIGHT, (float)M_PI * 0.25f, .1f, 1000.f)); auto ambientLight = scene::Node::create("ambientLight") ->addComponent(AmbientLight::create(0.5f)); ambientLight->component<AmbientLight>()->color()->setTo(1.0f, 1.0f, 1.0f); auto dirLight = scene::Node::create("dirLight") ->addComponent(DirectionalLight::create()->specular(0.5f)) ->addComponent(Transform::create(Matrix4x4::create()->lookAt( Vector3::zero(), Vector3::create(3.0f, 2.0f, 3.0f)))); root->addChild(camera) ->addChild(ambientLight) ->addChild(dirLight); auto _ = sceneManager->assets()->complete()->connect([=](file::AssetLibrary::Ptr assets) { bullet::Collider::Ptr collider = nullptr; auto boxCollData = bullet::ColliderData::create( 5.0f, bullet::BoxShape::create(0.5f, 0.5f, 0.5f)); collider = bullet::Collider::create(boxCollData); auto monster = assets->symbol(M_MONSTER) ->addComponent(collider); monster->component<Transform>()->matrix()->appendScale(0.25f); root->addChild(monster); }); Signal<input::Mouse::Ptr, int, int>::Slot mouseMove; float cameraRotationSpeed = 0.f; auto mouseDown = canvas->mouse()->leftButtonDown()->connect( [&](input::Mouse::Ptr mouse) { mouseMove = canvas->mouse()->move()->connect( [&](input::Mouse::Ptr mouse, int dx, int dy){ cameraRotationSpeed = (float) -dx * .01f; }); }); auto mouseUP = canvas->mouse()->leftButtonUp()->connect( [&](input::Mouse::Ptr mouse) { mouseMove = nullptr; }); auto KeyDown = canvas->keyboard()->keyDown()->connect([&](input::Keyboard::Ptr k){ if (k->keyIsDown(input::Keyboard::ScanCode::ESCAPE)) { canvas->quit(); } if (k->keyIsDown(input::Keyboard::ScanCode::SPACE)) { std::cout << "cooool" << std::endl; } }); auto resized = canvas->resized()->connect([&](AbstractCanvas::Ptr canvas, uint w, uint h){ camera->component<PerspectiveCamera>()->aspectRatio((float) w / (float) h); }); auto enterFrame = canvas->enterFrame()->connect([&](Canvas::Ptr canvas, float t, float dt){ camera->component<Transform>()->matrix()->appendRotationY(cameraRotationSpeed); sceneManager->nextFrame(t, dt); }); sceneManager->assets()->load(); canvas->run(); return 0; }
Hello,
please fix your post to use code highlighting.
Regards,
I didn't know what, but Beta 2 seems to working..!
And i'm moving to dev..
I just created a 3d model and imported to minko3, but bullet::collider not applying.
this is my code.