Exemplo n.º 1
0
void WGLWidget::addJavaScriptMatrix4(JavaScriptMatrix4x4 &mat)
{
  if (mat.hasContext())
    throw WException("The given matrix is already associated with a WGLWidget!");
  mat.assignToContext(jsValues_++, this);

  jsMatrixList_.push_back(jsMatrixMap(mat.id(), WMatrix4x4()));
}
Exemplo n.º 2
0
void WGLWidget::setJavaScriptMatrix4(JavaScriptMatrix4x4 &jsm,
				     const WGenericMatrix<double, 4, 4> &m)
{
  if (jsm.id() == -1)
    throw WException("JavaScriptMatrix4x4: matrix not initialized");
  if (jsm.hasOperations())
    throw WException("JavaScriptMatrix4x4: matrix was allready operated on");

  // set the server-side copy
  for (unsigned i = 0; i < jsMatrixList_.size(); i++)
    if (jsMatrixList_[i].id == jsm.id())
      jsMatrixList_[i].serverSideCopy = m;

  pImpl_->setJavaScriptMatrix4(jsm, m);
}
Exemplo n.º 3
0
void WGLWidget::uniformMatrix4(const UniformLocation &location,
			       const JavaScriptMatrix4x4 &jsm)
{
  if (!jsm.initialized())
    throw WException("JavaScriptMatrix4x4: matrix not initialized");

  pImpl_->uniformMatrix4(location, jsm);
}
Exemplo n.º 4
0
void WGLWidget::setClientSideWalkHandler(const JavaScriptMatrix4x4 &m, double frontStep, double rotStep)
{
  mouseWentDownSlot_.setJavaScript("function(o, e){" + glObjJsRef() + ".mouseDown(o, e);}");
  mouseWentUpSlot_.setJavaScript("function(o, e){" + glObjJsRef() + ".mouseUp(o, e);}");
  mouseDraggedSlot_.setJavaScript("function(o, e){" + glObjJsRef() + ".mouseDragWalk(o, e);}");
  mouseWheelSlot_.setJavaScript("function(o, e){}");
  std::stringstream ss;
  ss << "(function(){var o = " << glObjJsRef() << ";"
    "if(o.ctx == null) return;"
    "o.setWalkParams(o."
    << m.jsRef() << ","
    << frontStep << "," << rotStep << ");})()";
  if (this->isRendered()) {
    doJavaScript(ss.str());
  } else {
    delayedJavaScript_ << ss.str();
  }
}
Exemplo n.º 5
0
void WGLWidget::setClientSideLookAtHandler(const JavaScriptMatrix4x4 &m,
                                           double centerX, double centerY, double centerZ,
                                           double uX, double uY, double uZ,
                                           double pitchRate, double yawRate)
{
  mouseWentDownSlot_.setJavaScript("function(o, e){" + glObjJsRef() + ".mouseDown(o, e);}");
  mouseWentUpSlot_.setJavaScript("function(o, e){" + glObjJsRef() + ".mouseUp(o, e);}");
  mouseDraggedSlot_.setJavaScript("function(o, e){" + glObjJsRef() + ".mouseDragLookAt(o, e);}");
  mouseWheelSlot_.setJavaScript("function(o, e){" + glObjJsRef() + ".mouseWheelLookAt(o, e);}");
  js_ <<
    "obj.setLookAtParams("
    << m.jsRef()
    << ",[" << centerX << "," << centerY << "," << centerZ << "],"
    << "[" << uX << "," << uY << "," << uZ << "],"
    << pitchRate << "," << yawRate << ");";
//  if (this->isRendered()) {
//    doJavaScript(ss.str());
//  } else {
//    delayedJavaScript_ << ss.str();
//  }
}