Example #1
0
CLIPPER c_fwrite (void)
{
   int  file_handle;
   char *line;
   USHORT  line_size;
   
   if (PCOUNT == 3 && ISNUM(FILE_HANDLE) && ISCHAR(WRITE_LINE)
                   && ISNUM(LINE_SIZE) && ISBYREF(LINE_SIZE))
   {
      /* convert clipper parameters into C types... */
      file_handle = _parni(FILE_HANDLE);
      line_size = _parni(LINE_SIZE);
      line = _parc(WRITE_LINE);
      
      /* call C write function... */
      if ( _fsWrite(file_handle, line, line_size) < line_size ) 
      {
        _storni (0, LINE_SIZE);
        _ret();
        return;
      }
      
      /* flush the data to file without closing it... */
      if (asm_commit(file_handle))  
        _storni (0, LINE_SIZE);
   }
   else
      /* update line_size to zero... */
      _storni (0, LINE_SIZE);                   

   _ret();  /* returns NIL */
}
Example #2
0
CLIPPER CharCount( void )
{
   USHORT uiChars = 0;
   USHORT uiLen;
   USHORT i;
   HANDLE vmhString;

   BYTEP  cStringP;
   BYTE   cFindMe;

   ITEM   itemString, itemFindMe, itemRet;
   

   if (PCOUNT != 2)
   {
      _ret();           // NOTE: Withhold service
      return;           // Early return!
   }

   itemRet    = _itemPutNL( NULL, 0 );
   itemString = _itemParam( 1 );
   itemFindMe = _itemParam( 2 );

   if ( (_itemType( itemString ) == CHARACTER) &&
        (_itemType( itemFindMe ) == CHARACTER) )
   {
      _itemCopyC( itemFindMe, &cFindMe, 1 );
   
      vmhString = _xvalloc( _itemSize( itemString ), NULL );
      cStringP = _xvlock( vmhString );

      uiLen = _itemCopyC( itemString, cStringP, NULL );

      for( i = 0; i < uiLen; i++ )
      {
         if ( cStringP[i] == cFindMe )
            uiChars++;
      }
      
      _xvunlock( vmhString );   
      _xvfree( vmhString );


      itemRet = _itemPutNL( itemRet, (long)uiChars );
      
   }

   _itemReturn( itemRet );

   _itemRelease( itemRet );
   _itemRelease( itemString );
   _itemRelease( itemFindMe );

   return;
}
Example #3
0
 // Interfaz
    CLIPPER  ALIBOFFSET( void ){
       WORD i;
       if (wLib!=0xffff){
          _reta(wModules);
          for (i=0;i<wModules;i++){
             _stornl(alOffsets[i],-1,i+1);
          }
          return;
       }
       _ret();
       return;
    }
Example #4
0
 CLIPPER  ALIBMODULE( void ){
    BYTE acBuffer[300];
    WORD i;
    if (wLib!=0xffff){
       _reta(wModules);
       _tlseek(wLib,0,0);
       for (i=0;i<wModules;i++){
          _tlseek(wLib,alOffsets[i],0);
          if (ReadByte() == THEADR){
             if (ReadHdrRecord(acBuffer)){
                _storc(acBuffer,-1,i+1);
             }
          }else{
             _ret();
             return;
          }
       }
       return;
    }
    _ret();
    return;
 }
Example #5
0
 CLIPPER  AMODPUBLIC( void ){
    WORD wModule,i,wPublics;
    if ((PCOUNT() >= 1) && ISNUM(1) && (wLib != 0xffff) && ((wModule=_parni(1)-1)  < wModules)){
       wPublics=ScanModPublics(wModule);
       if (wPublics > 0){
          _reta(wPublics);
          for(i=0;i <= wPublics; i++){
             _storc(pcStrings[i],-1,i+1);
          }
          FreeStrings(wPublics);
          return;
       }
       _ret();
       return;
    }
 }
Example #6
0
 CLIPPER  AMODEXTERN( void ){
    WORD wModule,i,wExternals;
    if ((PCOUNT() >= 1) && ISNUM(1) && (wLib != 0xffff) && ((wModule=_parni(1)-1)  < wModules)){
       wExternals=ScanModExternals(wModule);
       if (wExternals > 0){
          _reta(wExternals);
          for(i=0;i <= wExternals; i++){
             _storc(pcStrings[i],-1,i+1);
          }
          FreeStrings(wExternals);
          return;
       }
       _ret();
       return;
    }
 }
Example #7
0
CLIPPER JW_SCRAM(void)
{
    char *temp;
    char *str;
    unsigned int len;
    int i;
    char c;

    if ( PCOUNT == 2 && ISCHAR(1) && ISNUM(2))
	{
	/* get pointer to param */
	str = _parc(1);

	/* get strings length */
	len = _parclen(1);

	/* allocate temp buffer */
	temp = _xgrab(len+1);

	/* put null byte */
	temp[len] = '\0';

	/* get encrypting value */
	i = _parni(2);

	/* convert to char */
	c = (char)i;

	/* copy input string to buffer XORing and 2's complementing as we go */
	for (i = 0; i < len; i++)
	    {
	    temp[i] = ~(str[i] ^ c);
	    }
	/* post modified value as CLIPPER return */
	_retclen(temp, len);

	/* free buffer */
	_xfree(temp);
	}
    else
    {
	     /* bad param */
	     _ret();
    }
}
Example #8
0
static gint _setopt(lua_State *l, const _quvi_t q, const CURLoption copt,
                    const _cookie_opts_t co, const gboolean croak_if_error)
{
  CURLcode r;

  if (co->mode == COOKIE_MODE_SESSION)
    r = curl_easy_setopt(q->handle.curl, copt, (glong) g_strtod(co->s, NULL));
  else
    r = curl_easy_setopt(q->handle.curl, copt, co->s);

  if (r != CURLE_OK)
    {
      g_string_printf(q->status.errmsg, "%s", curl_easy_strerror(r));
      q->status.rc = QUVI_ERROR_CALLBACK;

      if (croak_if_error == TRUE)
        luaL_error(l, "%s", q->status.errmsg->str);
    }
  return (_ret(l, q));
}
Example #9
0
CLIPPER userDO( void )
{
   EVALINFO info;
   USHORT   uiParam;
   ITEM     retP;

   /* Get evaluation expression */

   if ( PCOUNT < 1 )
   {
      _ret();
      return;
   }
   else
   {
      _evalNew( &info, _itemParam( 1 ) );
   }

   /* Get parameters */

   for ( uiParam = 2; uiParam <= PCOUNT; uiParam++ )
   {
      _evalPutParam( &info, _itemParam( uiParam ) );
   }

   /* Launch evaluation information */

   retP = _evalLaunch( &info );

   /* Release ITEMs associated with the evaluation info */
   
   _evalRelease( &info );

   _itemReturn ( retP );
   _itemRelease( retP );

   return;
}
Example #10
0
CLIPPER HB_NIL1()
{
   _ret();
}
Example #11
0
int     roar_vio_dstr_build_chain(struct roar_vio_dstr_chain * chain, struct roar_vio_calls * calls,
                                  struct roar_vio_calls * vio) {
    struct _roar_vio_dstr_type * type;
    struct roar_vio_dstr_chain * c;
    struct roar_vio_defaults   * def;
    struct roar_vio_calls      * tc, * prev;
    int i;

    ROAR_DBG("roar_vio_dstr_build_chain(*) = ?");

    if ( chain == NULL || calls == NULL )
        return -1;

    if ( roar_vio_open_stack(calls) == -1 )
        return -1;

    ROAR_DBG("roar_vio_dstr_build_chain(*): chain=%p", chain);

    if ( (def = chain->def) != NULL ) {
        if ( (tc = malloc(sizeof(struct roar_vio_calls))) == NULL ) {
            _ret(-1);
        }

        if ( roar_vio_init_calls(tc) == -1 ) {
            free(tc);
            _ret(-1);
        }

        if ( roar_vio_stack_add(calls, tc) == -1 ) {
            _ret(-1);
        }

        if ( chain->opts == NULL ) {
            if ( chain[1].type != ROAR_VIO_DSTR_OBJT_EOL ) {
                chain->opts = chain[1].opts;
            }
        }

        if ( roar_vio_open_default(tc, def, chain->opts) == -1 ) {
            _ret(-1);
        }

        prev = tc;
    } else {
        prev = vio;
    }

    for (i = 0; (c = &chain[i])->type != ROAR_VIO_DSTR_OBJT_EOL; i++) {
        ROAR_DBG("roar_vio_dstr_build_chain(*): i=%i, c->type=0x%.4x(%s): need_vio=%i, def->o_flags=%i", i,
                 c->type & 0xFFFF, roar_vio_dstr_get_name(c->type), c->need_vio, c->def->o_flags);

        if ( c->need_vio ) {
            if ( (tc = malloc(sizeof(struct roar_vio_calls))) == NULL ) {
                _ret(-1);
            }

            if ( roar_vio_init_calls(tc) == -1 ) {
                free(tc);
                _ret(-1);
            }

            if ( roar_vio_stack_add(calls, tc) == -1 ) {
                _ret(-1);
            }


            switch (c->type) {
            case ROAR_VIO_DSTR_OBJT_PASS:
                if ( roar_vio_open_pass(tc, prev) == -1 ) {
                    _ret(-1);
                }
                break;
            case ROAR_VIO_DSTR_OBJT_RE:
                if ( roar_vio_open_re(tc, prev) == -1 ) {
                    _ret(-1);
                }
                break;
            case ROAR_VIO_DSTR_OBJT_GZIP:
                if ( roar_vio_open_gzip(tc, prev, -1) == -1 ) {
                    _ret(-1);
                }
                break;
            case ROAR_VIO_DSTR_OBJT_BZIP2:
            case ROAR_VIO_DSTR_OBJT_PGP:
                if ( roar_vio_open_pgp_decrypt(tc, prev, NULL) == -1 ) {
                    _ret(-1);
                }
                break;
            case ROAR_VIO_DSTR_OBJT_HTTP09:
            case ROAR_VIO_DSTR_OBJT_HTTP10:
            case ROAR_VIO_DSTR_OBJT_HTTP11:
                if ( roar_vio_open_proto(tc, prev, c->dst, ROAR_VIO_PROTO_P_HTTP, c->def) == -1 ) {
                    _ret(-1);
                }
                break;
            case ROAR_VIO_DSTR_OBJT_GOPHER:
            case ROAR_VIO_DSTR_OBJT_GOPHER_PLUS:
                if ( roar_vio_open_proto(tc, prev, c->dst, ROAR_VIO_PROTO_P_GOPHER, c->def) == -1 ) {
                    _ret(-1);
                }
                break;
            case ROAR_VIO_DSTR_OBJT_ICY:
                if ( roar_vio_open_proto(tc, prev, c->dst, ROAR_VIO_PROTO_P_ICY, c->def) == -1 ) {
                    _ret(-1);
                }
                break;
            case ROAR_VIO_DSTR_OBJT_RTP2:
                if ( roar_vio_open_rtp(tc, prev, c->dst, c->def) == -1 ) {
                    _ret(-1);
                }
                break;
            case ROAR_VIO_DSTR_OBJT_PGP_ENC:
            case ROAR_VIO_DSTR_OBJT_PGP_STORE:
                if ( roar_vio_open_pgp_store(tc, prev, ROAR_VIO_PGP_OPTS_NONE) == -1 ) {
                    _ret(-1);
                }
                break;
            case ROAR_VIO_DSTR_OBJT_TANTALOS:
                if ( roar_vio_open_tantalos(tc, prev, c->dst, c->def) == -1 ) {
                    _ret(-1);
                }
                break;
            case ROAR_VIO_DSTR_OBJT_SSL1:
            case ROAR_VIO_DSTR_OBJT_SSL2:
            case ROAR_VIO_DSTR_OBJT_SSL3:
            case ROAR_VIO_DSTR_OBJT_TLS:
            case ROAR_VIO_DSTR_OBJT_MAGIC:
                _ret(-1);
                break;
            default:
                if ( (type = roar_vio_dstr_get_by_type(c->type)) == NULL ) {
                    _ret(-1);
                }

                if ( type->openvio == NULL )
                    _roar_vio_dstr_init_otherlibs();

                if ( type->openvio == NULL ) {
                    _ret(-1);
                }

                if ( type->openvio(tc, prev, c) == -1 ) {
                    _ret(-1);
                }
            }

            prev = tc;
        } // else we can skip to the next :)
    }

    ROAR_DBG("roar_vio_dstr_build_chain(*) = 0");
    return 0;
}
	chrono::ChVector<> ECGUIPanel::getPosition() {
		chrono::ChVector<> _ret((double)m_pPanel->getLeft(), (double)m_pPanel->getTop(), 0);
		return _ret;
	}
Example #13
0
gint l_quvi_http_cookie(lua_State *l)
{
  struct _cookie_opts_s co;
  gboolean croak_if_error;
  CURLoption copt;
  GSList *opts;
  _quvi_t q;

  /* quvi handle */

  q = (_quvi_t) l_get_reg_userdata(l, USERDATA_QUVI_T);
  g_assert(q != NULL);

  if (q->opt.allow_cookies == QUVI_FALSE)
    return (_ret(l, q)); /* Do nothing if cookies have been disabled. */

  /* arg1 */

  memset(&co, 0, sizeof(struct _cookie_opts_s));
  co.s = luaL_checkstring(l, 1);
  lua_pop(l, 1);

  /* options */

  opts = l_quvi_object_opts_new(l, 2);
  croak_if_error = l_quvi_object_opts_croak_if_error(l, opts);

  _chk_cookie_opts(l, opts, &co);
  l_quvi_object_opts_free(opts);

  /* mode */

  switch (co.mode)
    {
    case COOKIE_MODE_SESSION:
      copt = CURLOPT_COOKIESESSION;
      break;

    case COOKIE_MODE_FILE:
      copt = CURLOPT_COOKIEFILE;
      break;

    case COOKIE_MODE_LIST:
      copt = CURLOPT_COOKIELIST;
      break;

    case COOKIE_MODE_JAR:
      copt = CURLOPT_COOKIEJAR;
      break;

    default:
      g_string_printf(q->status.errmsg,
                      "[%s] invalid cookie function `0x%02x'",
                      __func__, co.mode);

      q->status.rc = QUVI_ERROR_CALLBACK;
      copt = CURLOPT_COOKIESESSION;

      g_warning("%s", q->status.errmsg->str);
    }
  return (_setopt(l, q, copt, &co, croak_if_error));
}
Example #14
0
void VMDriver::execute(){
	if( this->m_state == STATE_IDLE ){
		printf( "Error: state is idle. \n");
		return;
	}

	assert( this->currentAssembly() );
	while( this->isActive() ){
		if( this->isBreak() ){
			break;
		}
		unsigned char content = this->getByte( m_funcAddr , m_pc );
		m_pc++;
		switch( content ){
			case EMnemonic::MovPtr :
				_mov_ptr();
				break;
			case EMnemonic::Mov :
				_mov();
				break;
			case EMnemonic::Add :
				_add();
				break;
			case EMnemonic::Sub :
				_sub();
				break;
			case EMnemonic::Mul :
				_mul();
				break;
			case EMnemonic::Div :
				_div();
				break;
			case EMnemonic::Rem :
				_rem();
				break;
			case EMnemonic::Inc :
				_inc();
				break;
			case EMnemonic::Dec :
				_dec();
				break;
			case EMnemonic::Push :
				_push();
				break;
			case EMnemonic::PushPtr :
				_push_ptr();
				break;
			case EMnemonic::Pop :
				_pop();
				break;
			case EMnemonic::Call :
				_call();
				break;
			case EMnemonic::ST :
				_st();
				break;
			case EMnemonic::LD :
				_ld();
				break;
			case EMnemonic::EndFunc :
				_endFunc();
				break;

			case EMnemonic::CmpGeq : 
			case EMnemonic::CmpG :
			case EMnemonic::CmpLeq : 
			case EMnemonic::CmpL :
			case EMnemonic::CmpEq : 
			case EMnemonic::CmpNEq :
				_cmp( content );
				break;
			case EMnemonic::Not :
				_not();
				break;
			case EMnemonic::Minus :
				_minus();
				break;
			case EMnemonic::LogOr :
			case EMnemonic::LogAnd :
				_log( content );
				break;
			case EMnemonic::Jmp :
				_jmp();
				break;
			case EMnemonic::JumpZero :
				_jumpzero();
				break;
			case EMnemonic::JumpNotZero :
				_jumpnotzero();
				break;
			case EMnemonic::RET :
				_ret();
				break;
		}
	}
}
Example #15
0
	ECBody& ECScene::loadHeightMap(
	      std::string FilePath,
	      const chrono::ChVector<>& Scale) {
		Ogre::TexturePtr l_tex = Ogre::TextureManager::getSingleton().load(FilePath, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);

		if (l_tex->getFormat() != Ogre::PF_L16 && l_tex->getFormat() != Ogre::PF_L8) {
			l_tex->unload();
			l_tex = Ogre::TextureManager::getSingleton().load(FilePath, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, -1, 1.0f, false, Ogre::PF_L8);
		}

		Ogre::HardwarePixelBufferSharedPtr l_pixels = l_tex->getBuffer();
		size_t l_byte_size = l_pixels->getSizeInBytes();
		Ogre::PixelFormat l_format = l_tex->getFormat();

		assert(l_format == Ogre::PF_L16 || l_format == Ogre::PF_L8); // Garuntee grayscale

		size_t l_vertex_count = l_pixels->getHeight() * l_pixels->getWidth();
		std::vector<Ogre::Real> l_vertex_heights;
		Ogre::PixelBox l_temp_pixel_buffer(l_tex->getWidth(), l_tex->getHeight(), l_tex->getDepth(), l_format);
		void* l_pPixels = nullptr;
		bool catfish = l_tex->isLoaded();

		
		l_pPixels = new unsigned char[l_byte_size];


		//l_pixels->lock(l_temp_pixel_buffer, Ogre::HardwareBuffer::HBL_NORMAL);

		//Ogre::PixelBox const &pixel_box = l_pixels->getCurrentLock();
		//l_pixels->blitToMemory(pixel_box);
		//l_pixels->unlock();
		//l_pPixels = pixel_box.data;

		

		memcpy(l_pPixels, l_pixels->lock(Ogre::HardwareBuffer::HBL_NORMAL), l_byte_size);

		double l_height_w = l_format == Ogre::PF_L16 ? (double)USHRT_MAX : (double)UCHAR_MAX;

		for (unsigned int i = 0; i < l_vertex_count; i++) { // Fill vector with normalized heights
			if (l_format == Ogre::PF_L8) {
				l_vertex_heights.push_back( (Ogre::Real) ( ( (double)( (unsigned char*)l_pPixels )[i] ) / l_height_w ) );
			}
			else {
				l_vertex_heights.push_back( (Ogre::Real) ( ( (double)( (unsigned short*)l_pPixels )[i] ) / l_height_w ) );
			}
		}

		delete[] l_pPixels;

		std::vector<Ogre::Vector3> l_vertices;
		l_vertices.resize(l_vertex_count);

		typedef struct {
			unsigned int a;
			unsigned int b;
			unsigned int c;
		} triangle_index_set;

		std::vector<triangle_index_set> l_indices;
		unsigned int l_square_width = l_pixels->getWidth() - 1;
		unsigned int l_square_height = l_pixels->getHeight() - 1;
		unsigned int l_square_count = l_square_width * l_square_height;
		l_indices.resize(l_square_count * 2);

		std::vector<Ogre::Vector3> l_triangle_normals;
		l_triangle_normals.resize(l_square_count * 2);

		std::vector<Ogre::Vector3> l_vertex_normals;
		l_vertex_normals.resize(l_vertex_count);

		for (unsigned int i = 0; i < l_vertex_count; i++) { // Fill vertices

			unsigned int l_w = (i % l_pixels->getWidth());
			unsigned int l_h = (i / l_pixels->getWidth());

			Ogre::Real l_wa = (Ogre::Real)l_w - (Ogre::Real)(l_pixels->getWidth()) / 2.0;
			Ogre::Real l_ha = (Ogre::Real)l_h - (Ogre::Real)(l_pixels->getHeight()) / 2.0;

			l_vertices[i] = Ogre::Vector3(l_wa, std::abs(l_vertex_heights[i]), l_ha);
		}

		for (unsigned int i = 0; i < l_square_count * 2; i += 2) { // Fill indices
			unsigned int l_triangle_width = l_square_width * 2;
			unsigned int l_iteration_y_position = i / l_triangle_width;
			unsigned int l_triangle_to_pixel = (i + (2 * l_iteration_y_position)) / 2;

			l_indices[i + 0].a = l_triangle_to_pixel;
			l_indices[i + 0].b = l_triangle_to_pixel + l_pixels->getWidth();
			l_indices[i + 0].c = l_triangle_to_pixel + 1;
			l_indices[i + 1].a = l_triangle_to_pixel + 1;
			l_indices[i + 1].b = l_triangle_to_pixel + l_pixels->getWidth();
			l_indices[i + 1].c = l_triangle_to_pixel + l_pixels->getWidth() + 1;
		}

		for (unsigned int i = 0; i < l_triangle_normals.size(); i++) { // Calculate normals of all triangles
			Ogre::Vector3 _t1(l_vertices[l_indices[i].a]);
			Ogre::Vector3 _t2(l_vertices[l_indices[i].b]);
			Ogre::Vector3 _t3(l_vertices[l_indices[i].c]);
			Ogre::Vector3 _ret = (_t1 - _t2).crossProduct(_t1 - _t3);
			_ret.normalise();
			l_triangle_normals[i] = _ret;
		}

		//!!!!
		//	This algorithm takes ungodly long single-threaded in larger heightmaps.
		//!!!!
		{ // Calculate normals of all vertices
			typedef struct __thread_set_t {
				size_t _start;
				size_t _end;
				std::thread _thread;
			} __thread_set;

			size_t _thread_count = std::thread::hardware_concurrency();

			std::function<void(size_t, size_t)> _worker_thread = [&](size_t start, size_t end) {
				Ogre::Vector3 _ret(0, 0, 0);
				for (unsigned int i = start; i < end; i++) {
					for (unsigned int j = 0; j < l_indices.size(); j++) {
						if (l_indices[j].a == i || l_indices[j].b == i || l_indices[j].c == i) {
							_ret = _ret + l_triangle_normals[j];
						}
					}
					_ret.normalise();
					l_vertex_normals[i] = _ret;
				}
			};

			std::vector<__thread_set*> threads;

			for (unsigned int i = 0; i < _thread_count; i++) {
				__thread_set* pthread = new __thread_set;

				if (i == 0) {
					pthread->_start = 0;
					pthread->_end = l_vertex_count / _thread_count;
				}
				else {
					pthread->_start = threads[i - 1]->_end + 1;
					pthread->_end = (l_vertex_count / _thread_count) * (i + 1);
				}

				if (i == _thread_count) {
					pthread->_end = l_vertex_count;
				}

				pthread->_thread = std::thread(_worker_thread, pthread->_start, pthread->_end);
				threads.push_back(pthread);
			}

			for (unsigned int i = 0; i < threads.size(); i++) {
				threads[i]->_thread.join();
				delete threads[i];
				threads[i] = nullptr;
			}

		}

		/*for (unsigned int i = 0; i < l_vertex_normals.size(); i++) {
			Ogre::Vector3 _ret(0, 0, 0);
			for (unsigned int j = 0; j < l_indices.size(); j++) {
				if (l_indices[j].a == i || l_indices[j].b == i || l_indices[j].c == i) {
					_ret = _ret + l_triangle_normals[j];
				}
			}
			_ret.normalise();
			l_vertex_normals[i] = _ret;
		}*/

		Ogre::ManualObject* terrain_object = m_pSceneManager->createManualObject("");

		terrain_object->begin("lambert1", Ogre::RenderOperation::OT_TRIANGLE_LIST);

		for (unsigned int i = 0; i < l_vertex_count; i++) {
			Ogre::Real _x = (Ogre::Real)(i % l_tex->getWidth());
			Ogre::Real _y = (Ogre::Real)(i / l_tex->getWidth());

			terrain_object->position(l_vertices[i]);
			terrain_object->normal(l_vertex_normals[i]);
			terrain_object->colour(Ogre::ColourValue(0.5, 0.5, 0.5));
			terrain_object->textureCoord(_x/(Ogre::Real)l_tex->getWidth(), _y/(Ogre::Real)l_tex->getHeight());
		}

		for (unsigned int i = 0; i < l_indices.size(); i++) {
			terrain_object->index(l_indices[i].a);
			terrain_object->index(l_indices[i].b);
			terrain_object->index(l_indices[i].c);
		}

		terrain_object->end();

		//terrain_object->getSection(0)->getMaterial()->getTechnique(0)->getPass(0)->createTextureUnitState("white.png");
		//terrain_object->getSection(0)->getMaterial()->getTechnique(0)->getPass(0)->setLightingEnabled(true);

		ECBody& _ret = createBody();

		_ret.setMesh(terrain_object, Scale);

		chrono::geometry::ChTriangleMeshConnected l_triangle_mesh;

		for (unsigned int i = 0; i < l_indices.size(); i++) {
			l_triangle_mesh.addTriangle(
				chrono::ChVector<>(									// Vertex 0
				(double)l_vertices[l_indices[i].a].x,					// Index a.x
				(double)l_vertices[l_indices[i].a].y,					// Index a.y
				(double)l_vertices[l_indices[i].a].z					// Index a.z
				) * Scale,
				chrono::ChVector<>(									// Vertex 1
				(double)l_vertices[l_indices[i].b].x,					// Index b.x
				(double)l_vertices[l_indices[i].b].y,					// Index b.y
				(double)l_vertices[l_indices[i].b].z					// Index b.z
				) * Scale,
				chrono::ChVector<>(									// Vertex 2
				(double)l_vertices[l_indices[i].c].x,					// Index c.x
				(double)l_vertices[l_indices[i].c].y,					// Index c.y
				(double)l_vertices[l_indices[i].c].z					// Index c.z
				) * Scale
				);
		}

		_ret->GetCollisionModel()->ClearModel();
		_ret->GetCollisionModel()->AddTriangleMesh(l_triangle_mesh, true, false, chrono::ChVector<>(), chrono::QUNIT);
		_ret->GetCollisionModel()->BuildModel();
		_ret->SetCollide(true);
		_ret->SetBodyFixed(true);

		return _ret;
	}
	chrono::ChVector<> ECGUIPanel::getSize() {
		chrono::ChVector<> _ret((double)m_pPanel->getWidth(), (double)m_pPanel->getHeight(), 0);
		return _ret;
	}
Example #17
0
int     roar_vio_open_dstr_vio(struct roar_vio_calls * calls,
                               char * dstr, struct roar_vio_defaults * def, int dnum,
                               struct roar_vio_calls * vio) {
#ifndef ROAR_WITHOUT_VIO_DSTR
    struct roar_vio_dstr_chain chain[ROAR_VIO_DSTR_MAX_OBJ_PER_CHAIN];
    char * next;
    char * this;
    char * name;
    char * opts;
    char * dst;
    char * c;
    int    inopts;
    int    type;
    int    cc = 1; // current chain element

    if ( calls == NULL || dstr == NULL )
        return -1;

    if ( dnum != 0 && def == NULL )
        return -1;

    if ( (dstr = roar_mm_strdup(dstr)) == NULL )
        return -1;

    memset(chain, 0, sizeof(chain));

    chain[0].type = ROAR_VIO_DSTR_OBJT_INTERNAL;

    next = dstr;

    while (next != NULL) {
        if ( (cc+1) == ROAR_VIO_DSTR_MAX_OBJ_PER_CHAIN ) {
            _ret(-1);
        }

        this = next;
        next = strstr(next, "##");

        if (next != NULL) {
            *next = 0;
            next += 2;
        }

        // we have the current token in 'this'.

        opts   = NULL;
        dst    = NULL;

        if ( strstr(this, ":") != NULL ) {
            name   = this;
            inopts = 0;
            for (c = this; *c != 0; c++) {
                if ( *c == '[' ) {
                    *c     = 0;
                    opts   = c + 1;
                    inopts = 1;
                } else if ( *c == ']' &&  inopts ) {
                    *c     = 0;
                    inopts = 0;
                } else if ( *c == ':' && !inopts ) {
                    *c     = 0;
                    dst    = *(c+1) == 0 ? NULL : c + 1;
                    break;
                }
            }
        } else {
            // we need to guess that this is here...
            // currently we guess this is a file in all cases
            name = "file";
            dst  = this;
        }

        ROAR_DBG("roar_vio_open_dstr_vio(*): name='%s', opts='%s', dst='%s'", name, opts, dst);

        if ( (type = roar_vio_dstr_get_type(name)) == -1 ) {
            _ret(-1);
        }

        ROAR_DBG("roar_vio_open_dstr_vio(*): type=0x%.4x(%s)", type, roar_vio_dstr_get_name(type));

        chain[cc].type     = type;
        chain[cc].opts     = opts;
        chain[cc].dst      = dst;
        chain[cc].def      = NULL;
        chain[cc].vio      = NULL;
        chain[cc].need_vio = -1;
        cc++;

    }

    chain[cc].type = ROAR_VIO_DSTR_OBJT_EOL;

    ROAR_DBG("roar_vio_open_dstr_vio(*): chain=%p", chain);

    if ( roar_vio_dstr_parse_opts(chain) == -1 ) {
        _ret(-1);
    }

    if ( roar_vio_dstr_set_defaults(chain, cc, def, dnum) == -1 ) {
        _ret(-1);
    }

    if ( roar_vio_dstr_build_chain(chain, calls, vio) == -1 ) {
        _ret(-1);
    }

    _ret(0);
#else
    return -1;
#endif
}