Пример #1
0
vec3 Transform::getGlobalScale()
{
	vec3 out = getLocalScale();
	if (object->parent != nullptr)
	{
		vec3 p = object->parent->getTransform()->getGlobalScale();
		out = vec3(out.x * p.x, out.y * p.y, out.z * p.z);
	}
	return out;
}
Пример #2
0
void SE_NewGeometry::updateWorldTransform()
{
    SE_Spatial::updateWorldTransform();
    SE_Matrix4f localM;
    localM.set(getLocalRotate().toMatrix3f(), getLocalScale(), getLocalTranslate());
    mWorldTransform = getPrevMatrix().mul(localM).mul(getPostMatrix());
    SE_NewGeometry::_Impl::SimObjectList::iterator it;
    for(it = mImpl->attachObject.begin() ; it != mImpl->attachObject.end() ; it++)
    {
        (*it)->doTransform(getWorldTransform());
    }
    std::list<SE_Spatial*>::iterator itchild = mImplchild->children.begin();
    for(; itchild != mImplchild->children.end() ; itchild++)
    {
        SE_Spatial* s = *itchild;
        s->updateWorldTransform();
    }
}
bool EntityComponent::getProperty( Property* const inOutProperty )
{
    bool result(true);
    const he::FixedString& name(inOutProperty->getName());
    if (name == HEFS::strTranslate)
    {
        inOutProperty->set<vec3>(getLocalTranslate());
    }
    else if (name == HEFS::strRotate)
    {
        inOutProperty->set<vec3>(getLocalRotate().getEulerAngles());       
    }
    else if (name == HEFS::strScale)
    {
        inOutProperty->set<vec3>(getLocalScale());
    }
    else
    {
        result = false;
    }
    return result;
}
Пример #4
0
static void generateStyles(ofstream &fout, bool withTbl, const list<TextInfo> &TL,
                           map< pair<gdiFonts, string>, pair<string, string> > &styles) {
  fout << "<style type=\"text/css\">\n";
  fout << "body {background-color: rgb(250,250,255)}\n";
  fout << "h1 {font-family:arial,sans-serif;font-size:24px;font-weight:normal;white-space:nowrap}\n";
  fout << "h2 {font-family:arial,sans-serif;font-size:20px;font-weight:normal;white-space:nowrap}\n";
  fout << "h3 {font-family:arial,sans-serif;font-size:16px;font-weight:normal;white-space:nowrap}\n";
  fout << "p {font-family:arial,sans-serif;font-size:12px;font-weight:normal}\n";
  fout << "div {font-family:arial,sans-serif;font-size:12px;font-weight:normal}\n";

  if (withTbl) {
    fout << "td {font-family:arial,sans-serif;font-size:12px;font-weight:normal;white-space:nowrap}\n";
    fout << "td.e0 {background-color: rgb(238,238,255)}\n";
    fout << "td.e1 {background-color: rgb(245,245,255)}\n";
    fout << "td.header {line-height:1.8;height:40px}\n";
    fout << "td.freeheader {line-height:1.2}\n";
  }
  list<TextInfo>::const_iterator it=TL.begin();
  int styleList = 1;
  while (it != TL.end()) {
    gdiFonts font = it->getGdiFont();

    if (!it->font.empty() || (font == italicMediumPlus)
                          || (font == fontMediumPlus)) {

      if (styles.find(make_pair(font, it->font)) != styles.end()) {
        ++it;
        continue;
      }

      string style = "sty" + itos(styleList++);
      string element = "div";
      double baseSize = 12;
      switch (font) {
        case boldHuge:
          element = "h1";
          baseSize = 24;
          break;
        case boldLarge:
        case fontLarge:
          element = "h2";
          baseSize = 20;
          break;
        case fontMedium:
          element = "h3";
          baseSize = 16;
          break;
        case fontMediumPlus:
        case italicMediumPlus:
          baseSize = 18;
          break;
        case fontSmall:
        case italicSmall:
        case boldSmall:
          baseSize = 10;
         break;
      }

      string faceName;
      double scale = 1.0;
      if (it->font.empty()) {
        faceName = "arial,sans-serif";
      }
      else
        scale = getLocalScale(it->font, faceName);

      fout << element << "." <<  style
           << "{font-family:" << faceName << ";font-size:"
           << itos(int(floor(scale * baseSize + 0.5)))
           << "px;font-weight:normal;white-space:nowrap}\n";

      styles[make_pair(font, it->font)] = make_pair(element, style);
    }
    ++it;
  }
  fout << "</style>\n";
}
Пример #5
0
SE_Spatial *SE_Geometry::clone(SE_Spatial* parent,  int index,bool createNewMesh,const char* statuslist)
{
    if(!parent)
    {
        if(SE_Application::getInstance()->SEHomeDebug)
        LOGI("No parent,clone fail.!!!!");
        return NULL;
    }

    SE_Geometry * dest = new SE_Geometry();

    SE_SimObject* destobj = getCurrentAttachedSimObj()->clone(index,createNewMesh);

    dest->setSpatialName(this->getSpatialName());
    dest->setCloneIndex(index);
    
    
    //attach obj
    dest->attachSimObject(destobj);    

    //set spatial property

    dest->setBVType(getBVType());

    SE_Vector3f a = getLocalTranslate();
    dest->setLocalTranslate(a);

    dest->setLocalRotate(getLocalRotate());

    dest->setLocalScale(getLocalScale());

    dest->setPrevMatrix(getPrevMatrix());

    dest->setPostMatrix(getPostMatrix());

    dest->setParent(parent);

    SE_Layer* l = this->getWorldLayer();
    SE_Layer* destL = dest->getWorldLayer();
    destL->setLayer(l->getLayer());    

    //set render state
    dest->setRenderState(DEPTHTESTSTATE ,this->getRenderState(DEPTHTESTSTATE));
    

    //SE_Application::getInstance()->getSceneManager()->updateSpatialIDMap();
    SE_Scene* scene = getScene();
    scene->addSpatial(parent, dest);

    parent->updateWorldTransform();
    parent->updateBoundingVolume();
    parent->updateRenderState();
    //parent->updateWorldLayer();

    //copy geometry para
    dest->setHasInflate(true);
    
    dest->setAlpha(this->getAlpha());
    

    unsigned int status = 0;
    if(statuslist)
    {
        status = SE_Util::stringToInt(statuslist);
    }
    dest->setEffectState(status);

    dest->setSpatialState(this->getSpatialState());

    dest->setSpatialEffectData(this->getSpatialEffectData());

    std::vector<std::string> lights;
    this->getLightsNameList(lights);
    for(int i = 0; i < lights.size(); ++i)
    {
        dest->addLightNameToList(lights[i].c_str());
    }

    scene->sceneApplyLight();
    
    //return clone object
    return dest;
}