JNIEXPORT void JNICALL Java_be_yildiz_module_graphic_ogre_OgreLine_setMaterial( JNIEnv* env, jobject, POINTER pointer, POINTER matPointer) { LOG_FUNCTION DynamicLines* line = DynamicLines::get(pointer); YZ::Material* material = YZ::Material::get(matPointer); line->setMaterial(material); }
void LocationModelManager::updateDebugLine(ModelPair const &key) { if(!(isValid(key.first) && isValid(key.second))) return; DynamicLines *line = nullptr; if(getDebugLine(key, line)) { line->clear(); line->addPoint(at(key.first)->position()); line->addPoint(at(key.second)->position()); line->update(); } }
JNIEXPORT void JNICALL Java_be_yildiz_module_graphic_ogre_OgreLine_update( JNIEnv*, jobject, POINTER pointer, jfloat beginX, jfloat beginY, jfloat beginZ, jfloat endX, jfloat endY, jfloat endZ) { LOG_FUNCTION DynamicLines* line = DynamicLines::get(pointer); line->setPoint(0, beginX, beginY, beginZ); line->setPoint(1, endX, endY, endZ); line->update(); }
void LocationModelManager::removeDebugLine(ModelPair const &key) { if(INVALID_ID == key.first || INVALID_ID == key.second) return; DynamicLines *line; if(getDebugLine(key, line)) { line->clear(); line->update(); mLevel->levelRoot()->detachObject(line); delete line; } mDebugLines.erase(key); }
void CreateRing::create(const std::string& strName, SceneManager *mSceneMgr, Vector3 origin, Vector3 up, unsigned int radius, unsigned int samplePoints) { DynamicLines *lines = new DynamicLines(RenderOperation::OT_LINE_STRIP); // 0. finding an orthogonal Vector3 to 'up' // std::cout << " UP: " << up << std::endl; Vector3 orthoToUp; // thanks very much to Christian Reitwiessner (reitwiessner.de) for the next 4 lines of code! if (up.x / up.length() < 0.5) { orthoToUp=Vector3(0, up.z, -up.y); } else { orthoToUp=Vector3(-up.z, 0, up.x); } // std::cout << orthoToUp.normalisedCopy()<< std::endl; // exit(0); // 1. n_orthoToUp := norm(orthoToUp) Vector3 n_orthoToUp = orthoToUp.normalisedCopy(); // 2. expand n_orthoToUp by the radius setting n_orthoToUp *= radius; // 3. find out the rotation angle per step float angle = (float)360/samplePoints; // std::cout << "rotation by: " << angle << " with " << samplePoints << " sample points"; Vector3 renderedPoint = n_orthoToUp; lines->addPoint(renderedPoint+origin); // 5. create the rotation matrix q which rotates by 'angle' degrees, see // http://www.ogre3d.org/wiki/index.php/Quaternion_and_Rotation_Primer Quaternion q(Degree(angle), up.normalisedCopy()); for (int i=0; i < samplePoints; ++i) { // 6. finally sample all points renderedPoint = q * renderedPoint; // std::cout << renderedPoint << std::endl; lines->addPoint(renderedPoint+origin); } lines->update(); SceneNode *linesNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(strName); linesNode->attachObject(lines); }