zhengwenxin Posted June 16, 2021 Share Posted June 16, 2021 Hello , I am using the Unignie Sim 2.6 version to do the CAVE with plugin Syncker. I want to check the intersection node when the mouse clicked on the screen. It's good if I don't use the plugin of Syncker, but if I use the views mesh of my, the check is not right. I have a test,find it has releationshif with the caveHead. But I need to move the caveHead ,so if it has some way to solve this problems? Below is the mesh file of my. Thanks! views.mesh Link to comment
cash-metall Posted June 16, 2021 Share Posted June 16, 2021 Hello! tell us more, 1. How exactly do you do intersection under the cursor? (maybe some piece of code) 2. in which place of execution (SystemLogic/WorldLogic udpate/render/flush) most likely this is due to the fact that `Game::get()->getPlayer ()` this is not the camera that will end up being rendered (because Syncker make addtional transformation for player in accordance with CAVE) you can get a real camera and try to get intersection in AppWorldLogic::flush Link to comment
zhengwenxin Posted June 16, 2021 Author Share Posted June 16, 2021 Hello! Thank you for your reply. I am using the intersection in the update() of SystejmLogic. The intersection code is below: Vec3 p0,p1; // get the current player (camera) PlayerPtr player = Game::get()->getPlayer(); if (player.get() == NULL) return 0; // get width and height of the current application window int width = App::get()->getWidth(); int height = App::get()->getHeight(); // get the current X and Y coordinates of the mouse pointer int mouse_x = App::get()->getMouseX(); int mouse_y = App::get()->getMouseY(); // get the mouse direction from the player's position (p0) to the mouse cursor pointer (p1) player->getDirectionFromScreen(p0, p1, mouse_x, mouse_y, width, height); // create an instance of the WorldIntersection class to get the result WorldIntersectionPtr intersection = WorldIntersection::create(); // create an instance for intersected object and check the intersection ObjectPtr object = World::get()->getIntersection(p0,p1,1,intersection); // if the intersection has been occurred, change the parameter of the object's material if(object) { for (int i = 0; i < object->getNumSurfaces(); i++) { object->setMaterialParameter("albedo_color", vec4(1.0f, 0.0f, 0.0f, 1.0f),i); // show intersection details in console Log::message("point: (%f %f %f) index: %i \n", intersection->getPoint().x, intersection->getPoint().y, intersection->getPoint().z, intersection->getIndex()); } } /* ... */ Link to comment
cash-metall Posted June 16, 2021 Share Posted June 16, 2021 OK, it looks right try calling this code from AppWorldLogic::flush. or save the player in the flash and in the update take the direction from this player (not from Game :: getPlayer) PlayerPtr p; int AppWorldLogic::update() { if (p) { //..... p->getDirectionFromScreen(...); //..... } } int AppWorldLogic::flush() { p = Game::get()->getPlayer(); } Link to comment
Recommended Posts