void plAvBrainCritter::SightCone(float coneRad) { fSightConeAngle = coneRad; // calculate the minimum dot product for the cone of sight (angle/2 vector dotted with straight ahead) hsVector3 straightVector(1, 0, 0), viewVector(1, 0, 0), up(0, 1, 0); hsQuat rotation(fSightConeAngle/2, &up); viewVector = hsVector3(rotation.Rotate(&viewVector)); viewVector.Normalize(); fSightConeDotMin = straightVector * viewVector; }
void ShaderSilhouetteSimple::findTangent(const unsigned int i) { gmVector3 ni, posi; posi = position->getPosition(i); ni = impInt->grad(i); ni.normalize(); gmVector3 viewVector(*myCameraPosition - posi); viewVector.normalize(); gmVector3 tangent = impInt->hess(i) * viewVector; tangent = cross(ni, tangent); if(tangent.lengthSquared() > gmEPSILON) tangent.normalize(); tangentAttr->setVector(i,tangent); }
void GLWidget3D::inferRuleFromSketch() { int face_index; std::vector<glm::vec3> face_points; // ワールド座標系でのカメラ座標 glm::vec3 cameraPos = camera.cameraPosInWorld(); // 視線ベクトル glm::vec3 view_v1 = viewVector(strokes[0].points[0], camera.mvMatrix, camera.f(), camera.aspect()); // faceを取得 cga::Face face; if (cga_system.hitFace(cameraPos, view_v1, face)) { // strokeの3d座標を計算 for (int i = 0; i < strokes.size(); ++i) { if (strokes[i].points3d.size() == strokes[i].points.size()) continue; for (int k = 0; k < strokes[i].points.size(); ++k) { strokes[i].points3d.push_back(unprojectByPlane(strokes[i].points[k], face.points[0], face.normals[0])); } } // strokeから、ルールを探す face.shape->findRule(strokes, sketch_step, &cga_system); // CGAモデルを生成しなおす cga_system.generateProposal(); // 描画する cga_system.render(&renderManager, true); } strokes.clear(); update(); }