예제 #1
0
int CInterpreter::GetMove( void )
{
	CBlock	block;

	block.Create( ID_MOVE );

	if (!Match( TK_OPEN_PARENTHESIS ))
		return Error("syntax error : '(' not found");

	if ( GetVector( &block ) == false )
		return false;

	//Angles are optional
	if ( LookAhead( TK_VECTOR_START ) || LookAhead( TK_IDENTIFIER ) )
	{
		if ( GetVector( &block ) == false )
			return false;
	}

	if ( GetFloat( &block ) == false )
		return false;

	if (!Match( TK_CLOSED_PARENTHESIS ))
		return Error("move : too many parameters");

	m_blockStream->WriteBlock( &block );

	return true;
}
    TRef<IObject> Apply(ObjectStack& stack)
    {
        TRef<FrameDataListValue> plistValue = new FrameDataListValue();

        TRef<IObjectList> plist;
        CastTo(plist, (IObject*)stack.Pop());

        while (plist->GetCurrent()) {
            IObjectPair* ppair;
            CastTo(ppair, plist->GetCurrent());

            ZString strName     = GetString(ppair->GetNth(0));
            Vector  vecPosition = GetVector(ppair->GetNth(1));
            Vector  vecForward  = GetVector(ppair->GetNth(2));
            Vector  vecUp       = GetVector(ppair->GetLastNth(3));

            plistValue->GetList().PushEnd(
                FrameData(
                    strName,
                    vecPosition,
                    vecForward,
                    vecUp
                )
            );

            plist->GetNext();
        }

        return plistValue;
    }
int main () {
    
    while (true) {
        CellT * list1 = NULL;
        CellT * list2 = NULL;
        
        Vector<int> vector1 = GetVector("Give me a 1st list of numbers (-1 to quit)");
        list1 = ConvertToListR(vector1);
        PrintLinkedList(list1);
        cout << SumList(list1) << endl;
        
        Vector<int> vector2 = GetVector("Give me a 2nd list of numbers (-1 to quit)");
        list2 = ConvertToListR(vector2);
        PrintLinkedList(list2);
        cout << SumList(list2) << endl;
        
        cout << "Appending the list now..." << endl;
        //AppendList(list1, list2);
        Append(list1, list2);
        PrintLinkedList(list1);
        cout << SumList(list1) << endl;
        
        vector1.clear();
        vector2.clear();
        Deallocate(list1);
        //Deallocate(list2);
        
        cout << "******************** OK WE ARE DONE **********************" << endl;
    }
    
    return 0;
}
예제 #4
0
static errcode GetFCylinder(FILE * dfile) {
  apiflt rad;
  vector ctr, axis;
  vector pnt1, pnt2;
  void * tex;
  float a;
  errcode rc;

  rc = GetString(dfile, "BASE");
  rc |= GetVector(dfile, &pnt1);
  rc |= GetString(dfile, "APEX");
  rc |= GetVector(dfile, &pnt2);

  ctr=pnt1;
  axis.x=pnt2.x - pnt1.x; 
  axis.y=pnt2.y - pnt1.y;
  axis.z=pnt2.z - pnt1.z;

  rc |= GetString(dfile, "RAD");
  fscanf(dfile, "%f", &a);
  rad=a;

  rc |= GetTexture(dfile, &tex);
  rt_fcylinder(tex, ctr, axis, rad); 

  return rc;
}
static errcode GetFCylinder(parsehandle * ph, SceneHandle scene) {
  apiflt rad;
  apivector ctr, axis;
  apivector pnt1, pnt2;
  void * tex;
  float a;
  errcode rc;

  rc = GetString(ph, "BASE");
  rc |= GetVector(ph, &pnt1);
  rc |= GetString(ph, "APEX");
  rc |= GetVector(ph, &pnt2);

  ctr=pnt1;
  axis.x=pnt2.x - pnt1.x; 
  axis.y=pnt2.y - pnt1.y;
  axis.z=pnt2.z - pnt1.z;

  rc |= GetString(ph, "RAD");
  fscanf(ph->ifp, "%f", &a);
  rad=a;

  rc |= GetTexture(ph, scene, &tex);
  rt_fcylinder(scene, tex, ctr, axis, rad); 

  return rc;
}
예제 #6
0
float CTrack::GetVector(unsigned char sel, unsigned n) {

  KEY   kn_1, kn, kn1;
  float pn_1, pn, pn1;

  kn = keys[n];
  pn = kn.data;

  if (sel == 2) return pn;

  if (n == 0) {
    //first key
    kn1 = keys[1];
    pn1 = kn1.data;

    if (numkey == 2) {
      //2 keys
      return (pn1 - pn)*(1.0 - TENS);
    };
    if (!LOOP) {
      //first key, no loop
      return ((pn1 - pn)*1.5 - GetVector(0,1)*0.5)*(1.0 - TENS);
    } else {
      //first key, loop
      kn_1 = keys[numkey-2];
    };
  } else if (n == numkey-1) {
    //last key
    kn_1 = keys[n-1];
    pn_1 = kn_1.data;

    if (numkey == 2) {
      //2 keys
      return (pn - pn_1)*(1.0 - TENS);
    };
    if (!LOOP) {
      //last key, no loop
      return ((pn - pn_1)*1.5 - GetVector(1,n-1)*0.5)*(1.0 - TENS);
    } else {
      //last key, loop
      kn1 = keys[1];
    };
  } else {
    //middle keys
    kn_1= keys[n-1];
    kn1 = keys[n+1];
  };
  pn_1= kn_1.data;
  pn1 = kn1 .data;

  float f = (sel == 0) ? 0.5 : -0.5;

  float g1 = (pn  - pn_1)*(1.0 + BIAS);
  float g2 = (pn1 - pn  )*(1.0 - BIAS);

  return (g1 + (g2-g1)*(0.5 + f*CONT))*(1.0 - TENS);

}
static errcode GetSpotLight(parsehandle * ph, SceneHandle scene) {
  char tmp[255];
  apiflt rad, Kc, Kl, Kq;
  apivector ctr;
  apitexture tex;
  apivector direction;
  apiflt start, end;
  float r, g, b, a;
  errcode rc;
  void * li;

  memset(&tex, 0, sizeof(apitexture)); 

  rc = GetString(ph, "CENTER"); 
  rc |= GetVector(ph, &ctr); 
  rc |= GetString(ph,"RAD");
  fscanf(ph->ifp, "%f", &a);  /* read in radius */ 
  rad=a;
 
  rc |= GetString(ph, "DIRECTION"); 
  rc |= GetVector(ph, &direction); 
  rc |= GetString(ph, "FALLOFF_START");
  fscanf(ph->ifp, "%f",&a);
  start=a;
  rc |= GetString(ph, "FALLOFF_END");
  fscanf(ph->ifp, "%f", &a);
  end=a;
   
  fscanf(ph->ifp, "%s", tmp);
  if (!stringcmp(tmp, "COLOR")) {
    fscanf(ph->ifp, "%f %f %f", &r, &g, &b);
    tex.col.r=r;
    tex.col.g=g;
    tex.col.b=b;

    li = rt_spotlight(scene, rt_texture(scene, &tex), ctr, rad, direction, start, end);
  } 
  else {
    if (stringcmp(tmp, "ATTENUATION"))
      return -1;
    rc |= GetString(ph, "CONSTANT");
    fscanf(ph->ifp, "%f", &a);
    Kc=a;
    rc |= GetString(ph, "LINEAR");
    fscanf(ph->ifp, "%f", &a);
    Kl=a;
    rc |= GetString(ph, "QUADRATIC");
    fscanf(ph->ifp, "%f", &a);
    Kq=a;
    rc |= GetColor(ph, &tex.col);

    li = rt_spotlight(scene, rt_texture(scene, &tex), ctr, rad, direction, start, end);
    rt_light_attenuation(li, Kc, Kl, Kq);
  }

  return rc;
}
예제 #8
0
void  CTrack::InitVectors() {
 int i;
 if (numkey==1) return;
 for (i=0; i<numkey; i++) {
  keys[i].an=GetVector(0,i);
  keys[i].bn=GetVector(1,i);
 }

}
예제 #9
0
float DenseDenseFeatureDotProduct(const AbstractFeature<float>& f1,
    const AbstractFeature<float>& f2) {
  CHECK_EQ(f1.GetFeatureDim(), f2.GetFeatureDim());
  auto f1_dense_ptr = static_cast<const DenseFeature<float>*>(&f1);
  auto f2_dense_ptr = static_cast<const DenseFeature<float>*>(&f2);
  const std::vector<float>& v1 = f1_dense_ptr->GetVector();
  const std::vector<float>& v2 = f2_dense_ptr->GetVector();
  Eigen::Map<const Eigen::VectorXf> e1(v1.data(), v1.size());
  Eigen::Map<const Eigen::VectorXf> e2(v2.data(), v2.size());
  return e1.dot(e2);
}
예제 #10
0
static PRBool WellOrdered(const void* addr1, const void* addr2,
                          const void *callsite2, PRUint32* index2p,
                          nsNamedVector** vec1p, nsNamedVector** vec2p)
{
    PRBool rv = PR_TRUE;
    PLHashTable* table = OrderTable;
    if (!table) return rv;
    PR_Lock(OrderTableLock);

    // Check whether we've already asserted (addr1 < addr2).
    nsNamedVector* vec1 = GetVector(table, addr1);
    if (vec1) {
        PRUint32 i, n;

        for (i = 0, n = vec1->Count(); i < n; i++)
            if (vec1->ElementAt(i) == addr2)
                break;

        if (i == n) {
            // Now check for (addr2 < addr1) and return false if so.
            nsNamedVector* vec2 = GetVector(table, addr2);
            if (vec2) {
                for (i = 0, n = vec2->Count(); i < n; i++) {
                    void* addri = vec2->ElementAt(i);
                    PR_ASSERT(addri);
                    if (addri == addr1 || Reachable(table, addr1, addri)) {
                        *index2p = i;
                        *vec1p = vec1;
                        *vec2p = vec2;
                        rv = PR_FALSE;
                        break;
                    }
                }

                if (rv) {
                    // Assert (addr1 < addr2) into the order table.
                    // XXX fix plvector/nsVector to use const void*
                    vec1->AppendElement((void*) addr2);
#ifdef NS_TRACE_MALLOC_XXX
                    vec1->mInnerSites.AppendElement((void*) callsite2);
#endif
                }
            }
        }
    }

    PR_Unlock(OrderTableLock);
    return rv;
}
static errcode GetBox(parsehandle * ph, SceneHandle scene) {
  apivector min, max;
  void * tex;
  errcode rc;

  rc = GetString(ph, "MIN");
  rc |= GetVector(ph, &min);
  rc |= GetString(ph, "MAX");
  rc |= GetVector(ph, &max);
  rc |= GetTexture(ph, scene, &tex);

  rt_box(scene, tex, min, max);

  return rc;
}
예제 #12
0
static errcode GetBox(FILE * dfile) {
  vector min, max;
  void * tex;
  errcode rc;

  rc = GetString(dfile, "MIN");
  rc |= GetVector(dfile, &min);
  rc |= GetString(dfile, "MAX");
  rc |= GetVector(dfile, &max);
  rc |= GetTexture(dfile, &tex);

  rt_box(tex, min, max);

  return rc;
}
예제 #13
0
static errcode GetPlane(FILE * dfile) {
  vector normal;
  vector ctr;
  void * tex;
  errcode rc;

  rc = GetString(dfile, "CENTER");
  rc |= GetVector(dfile, &ctr);
  rc |= GetString(dfile, "NORMAL");
  rc |= GetVector(dfile, &normal);
  rc |= GetTexture(dfile, &tex);

  rt_plane(tex, ctr, normal);

  return rc;
}
예제 #14
0
static errcode GetPolyCylinder(FILE * dfile) {
  apiflt rad;
  vector * temp;
  void * tex;
  float a;
  int numpts, i;
  errcode rc;

  rc = GetString(dfile, "POINTS");
  fscanf(dfile, "%d", &numpts);

  temp = (vector *) malloc(numpts * sizeof(vector));

  for (i=0; i<numpts; i++) {
    rc |= GetVector(dfile, &temp[i]);
  }         

  rc |= GetString(dfile, "RAD");
  fscanf(dfile, "%f", &a);
  rad=a;

  rc |= GetTexture(dfile, &tex);
  rt_polycylinder(tex, temp, numpts, rad); 

  free(temp);

  return rc;
}
예제 #15
0
int main(int argc, char *argv[])
{
  FILE *picture, *picture_ref;
  int ref_block_num, width, height, graymax;;
  byte ref_block[16][16], *picture_blocks;
  int i, read;
  char buffer[100], *token, file_type[2];

  ref_block_num = atoi(argv[1]);
  picture_ref = fopen("lenna.pgm", "r");
  picture = fopen("lenna1.pgm", "r");

  fscanf(picture_ref, "%2c%d%d%d\n", file_type, &width, &height, &graymax);  //proèitaj header 
  fseek(picture_ref, 256 * ref_block_num , SEEK_CUR);                        //pozicioniraj se na odgovarajuæi referentni blok
  //printf("%d\n", ftell(picture_ref));
  fread(ref_block, sizeof(ref_block), 1, picture_ref);                     //proèitaj referentni blok

  fscanf(picture, "%2c%d%d%d\n", file_type, &width, &height, &graymax);  //proèitaj header
  picture_blocks = (byte*) malloc(width*height);                       //rezerviraj memoriju
  //printf("%d\n", ftell(picture));
  fread(picture_blocks, width*height, 1, picture);                     //uèitaj datoteku u memoriju

  GetVector(picture_blocks, width, height, ref_block, ref_block_num);

  free(picture_blocks);
  return 0;
}
예제 #16
0
static errcode GetLandScape(FILE * dfile) {
  void * tex;
  vector ctr;
  apiflt wx, wy;
  int m, n;
  float a,b;
  errcode rc;

  rc = GetString(dfile, "RES");
  fscanf(dfile, "%d %d", &m, &n);

  rc |= GetString(dfile, "SCALE");
  fscanf(dfile, "%f %f", &a, &b);   
  wx=a;
  wy=b;

  rc |= GetString(dfile, "CENTER");
  rc |= GetVector(dfile, &ctr);

  rc |= GetTexture(dfile, &tex);

  rt_landscape(tex, m, n, ctr, wx, wy);

  return rc;
}
static errcode GetPolyCylinder(parsehandle * ph, SceneHandle scene) {
  apiflt rad;
  apivector * temp;
  void * tex;
  float a;
  int numpts, i;
  errcode rc;

  rc = GetString(ph, "POINTS");
  fscanf(ph->ifp, "%d", &numpts);

  temp = (apivector *) malloc(numpts * sizeof(apivector));

  for (i=0; i<numpts; i++) {
    rc |= GetVector(ph, &temp[i]);
  }         

  rc |= GetString(ph, "RAD");
  fscanf(ph->ifp, "%f", &a);
  rad=a;

  rc |= GetTexture(ph, scene, &tex);
  rt_polycylinder(scene, tex, temp, numpts, rad); 

  free(temp);

  return rc;
}
    TRef<IObject> Apply(ObjectStack& stack)
    {
        TRef<LightsGeo> plights = new LightsGeo(m_pmodeler, m_ptime);

        TRef<IObjectList> plist;
        CastTo(plist, (IObject*)stack.Pop());

        while (plist->GetCurrent() != NULL) {
            IObjectPair* ppair;
            CastTo(ppair, plist->GetCurrent());

            Color  color    =  GetColor(ppair->GetNth(0));
            Vector vector   = GetVector(ppair->GetNth(1));
            float  period   = GetNumber(ppair->GetNth(2));
            float  phase    = GetNumber(ppair->GetNth(3));
            float  rampUp   = GetNumber(ppair->GetNth(4));
            float  hold     = GetNumber(ppair->GetNth(5));
            float  rampDown = GetNumber(ppair->GetLastNth(6));

            plights->AddLight(color, vector, period, phase, rampUp, hold, rampDown);

            plist->GetNext();
        }

        return plights;
    }
static errcode GetPlane(parsehandle * ph, SceneHandle scene) {
  apivector normal;
  apivector ctr;
  void * tex;
  errcode rc;

  rc = GetString(ph, "CENTER");
  rc |= GetVector(ph, &ctr);
  rc |= GetString(ph, "NORMAL");
  rc |= GetVector(ph, &normal);
  rc |= GetTexture(ph, scene, &tex);

  rt_plane(scene, tex, ctr, normal);

  return rc;
}
static errcode GetLandScape(parsehandle * ph, SceneHandle scene) {
  void * tex;
  apivector ctr;
  apiflt wx, wy;
  int m, n;
  float a,b;
  errcode rc;

  rc = GetString(ph, "RES");
  fscanf(ph->ifp, "%d %d", &m, &n);

  rc |= GetString(ph, "SCALE");
  fscanf(ph->ifp, "%f %f", &a, &b);   
  wx=a;
  wy=b;

  rc |= GetString(ph, "CENTER");
  rc |= GetVector(ph, &ctr);

  rc |= GetTexture(ph, scene, &tex);

  rt_landscape(scene, tex, m, n, ctr, wx, wy);

  return rc;
}
예제 #21
0
/*********************************************************************\
	Function name    : CCustomSubDialog::Command
	Description      :
	Created at       : 27.03.02, @ 12:41:37
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
Bool CCustomSubDialog::Command(Int32 id,const BaseContainer &msg)
{
    if (!m_pElement) return true;

    CCustomElements* pElement = g_pCustomElements->GetItem(m_pElement->m_lElement);
    if (!pElement) return true;

    if (!m_pElement->m_pbcGUI) return true;
    BaseContainer* pBC = &m_pElement->m_pbcGUI[m_pElement->m_lElement];

    if (id == IDC_CUSTOM_OPEN_CLOSE)
    {
        GetBool(IDC_CUSTOM_OPEN_CLOSE, pElement->m_bIsOpen);
        m_pElement->ItemChanged();
        return true;
    }

    if (id >= FIRST_CUSTOM_ELEMENT_ID)
    {
        // find the correct property
        Int32 lID = FIRST_CUSTOM_ELEMENT_ID;
        Int32 s=0;
        CustomProperty* pProp = nullptr;
        for (Int32 i = 0; m_pProp && m_pProp[i].type != CUSTOMTYPE_END; i++)
        {
            switch (pElement->m_pProp[id - FIRST_CUSTOM_ELEMENT_ID].type)
            {
            case CUSTOMTYPE_FLAG:
            case CUSTOMTYPE_LONG:
            case CUSTOMTYPE_REAL:
            case CUSTOMTYPE_STRING:
                s = 1;
                break;
            case CUSTOMTYPE_VECTOR:
                s = 3;
                break;
            }
            if (lID <= id && id < lID + s)
            {
                pProp = &pElement->m_pProp[i];
                break;
            }
            lID += s;
        }
        if (pProp)
        {
            if (pProp->type == CUSTOMTYPE_FLAG) GetBool(lID, pBC, pProp->id);
            else if (pProp->type == CUSTOMTYPE_LONG) GetInt32(lID, pBC, pProp->id);
            else if (pProp->type == CUSTOMTYPE_REAL) GetFloat(lID, pBC, pProp->id);
            else if (pProp->type == CUSTOMTYPE_STRING) GetString(lID, pBC, pProp->id);
            else if (pProp->type == CUSTOMTYPE_VECTOR) GetVector(lID, lID + 1, lID + 2, pBC, pProp->id);
        }

        m_pElement->ItemChanged();
    }
    return true;
}
예제 #22
0
static errcode GetTri(FILE * dfile) {
  vector v0,v1,v2;
  void * tex;
  errcode rc;

  rc = GetString(dfile, "V0");
  rc |= GetVector(dfile, &v0);

  rc |= GetString(dfile, "V1");
  rc |= GetVector(dfile, &v1);

  rc |= GetString(dfile, "V2");
  rc |= GetVector(dfile, &v2);

  rc |= GetTexture(dfile, &tex);

  rt_tri(tex, v0, v1, v2);

  return rc;
}
예제 #23
0
void task4_5::solution::thread_fun()
{
    auto it = GetVector();

	while(it != data_.end())
	{
		auto minmax = std::minmax_element(it->begin(), it->end());
		boost::mutex::scoped_lock lock(mtx_minmax_);
		if (min_ > *minmax.first)
		{
			min_ = *minmax.first;
		}
		if (max_ < *minmax.second)
		{
			max_ = *minmax.second;
		}

		it = GetVector();
	}
}
static errcode GetCylinder(parsehandle * ph, SceneHandle scene) {
  apiflt rad;
  apivector ctr, axis;
  void * tex;
  float a;
  errcode rc;

  rc = GetString(ph, "CENTER");
  rc |= GetVector(ph, &ctr);
  rc |= GetString(ph, "AXIS");
  rc |= GetVector(ph, &axis);
  rc |= GetString(ph, "RAD");
  fscanf(ph->ifp, "%f", &a);
  rad=a;

  rc |= GetTexture(ph, scene, &tex);
  rt_cylinder(scene, tex, ctr, axis, rad); 

  return rc;
}
예제 #25
0
static errcode GetCylinder(FILE * dfile) {
  apiflt rad;
  vector ctr, axis;
  void * tex;
  float a;
  errcode rc;

  rc = GetString(dfile, "CENTER");
  rc |= GetVector(dfile, &ctr);
  rc |= GetString(dfile, "AXIS");
  rc |= GetVector(dfile, &axis);
  rc |= GetString(dfile, "RAD");
  fscanf(dfile, "%f", &a);
  rad=a;

  rc |= GetTexture(dfile, &tex);
  rt_cylinder(tex, ctr, axis, rad); 

  return rc;
}
static errcode GetTri(parsehandle * ph, SceneHandle scene) {
  apivector v0,v1,v2;
  void * tex;
  errcode rc;

  rc = GetString(ph, "V0");
  rc |= GetVector(ph, &v0);

  rc |= GetString(ph, "V1");
  rc |= GetVector(ph, &v1);

  rc |= GetString(ph, "V2");
  rc |= GetVector(ph, &v2);

  rc |= GetTexture(ph, scene, &tex);

  rt_tri(scene, tex, v0, v1, v2);

  return rc;
}
예제 #27
0
void ParticleSystemLoader::ProcessTransform (TiXmlElement* xmlElem, Emiter* emiter)
{
	TiXmlElement* content = xmlElem->FirstChildElement ();

	while (content) {
		std::string name = content->Value ();

		if (name == "Position") {
			emiter->GetTransform ()->SetPosition (GetVector (content));
		}
		else if (name == "Scale") {
			emiter->GetTransform ()->SetScale (GetVector (content));
		}
		else if (name == "Rotation") {
			emiter->GetTransform ()->SetRotation (GetQuaternion (content));
		}

		content = content->NextSiblingElement ();
	}
}
static errcode GetVol(parsehandle * ph, SceneHandle scene) {
  apivector min, max;
  int x,y,z;  
  char fname[255];
  void * tex;
  errcode rc;
 
  rc = GetString(ph, "MIN");
  rc |= GetVector(ph, &min);
  rc |= GetString(ph, "MAX");
  rc |= GetVector(ph, &max);
  rc |= GetString(ph, "DIM");
  fscanf(ph->ifp, "%d %d %d ", &x, &y, &z);
  rc |= GetString(ph, "FILE");
  fscanf(ph->ifp, "%s", fname);  
  rc |= GetTexture(ph, scene, &tex);
 
  rt_scalarvol(scene, tex, min, max, x, y, z, fname, NULL); 

  return rc;
}
static errcode GetRing(parsehandle * ph, SceneHandle scene) {
  apivector normal;
  apivector ctr;
  void * tex;
  float a,b;
  errcode rc;
 
  rc = GetString(ph, "CENTER");
  rc |= GetVector(ph, &ctr);
  rc |= GetString(ph, "NORMAL");
  rc |= GetVector(ph, &normal);
  rc |= GetString(ph, "INNER");
  fscanf(ph->ifp, " %f ", &a);
  rc |= GetString(ph, "OUTER");
  fscanf(ph->ifp, " %f ", &b);
  rc |= GetTexture(ph, scene, &tex);
 
  rt_ring(scene, tex, ctr, normal, a, b);

  return rc;
}
예제 #30
0
static errcode GetRing(FILE * dfile) {
  vector normal;
  vector ctr;
  void * tex;
  float a,b;
  errcode rc;
 
  rc = GetString(dfile, "CENTER");
  rc |= GetVector(dfile, &ctr);
  rc |= GetString(dfile, "NORMAL");
  rc |= GetVector(dfile, &normal);
  rc |= GetString(dfile, "INNER");
  fscanf(dfile, " %f ", &a);
  rc |= GetString(dfile, "OUTER");
  fscanf(dfile, " %f ", &b);
  rc |= GetTexture(dfile, &tex);
 
  rt_ring(tex, ctr, normal, a, b);

  return rc;
}