예제 #1
0
//-----------------------------------------------------------------------------
// Purpose: Updates the cached pointers to our start and end entities by looking
//			for them in the given world.
// Input  : pWorld - World to search.
//-----------------------------------------------------------------------------
void CMapLine::UpdateDependencies(CMapWorld *pWorld, CMapClass *pObject)
{
	CMapClass::UpdateDependencies(pWorld, pObject);

	if (pWorld == NULL)
	{
		return;
	}

	CMapEntity *pEntity = dynamic_cast <CMapEntity *> (m_pParent);
	Assert(pEntity != NULL);

	if (pEntity != NULL)
	{
		const char *pszValue = pEntity->GetKeyValue(m_szStartValueKey);
		m_pStartEntity = (CMapEntity *)UpdateDependency(m_pStartEntity, pWorld->FindChildByKeyValue(m_szStartKey, pszValue));

		if (m_szEndValueKey[0] != '\0')
		{
			pszValue = pEntity->GetKeyValue(m_szEndValueKey);
			m_pEndEntity = (CMapEntity *)UpdateDependency(m_pEndEntity, pWorld->FindChildByKeyValue(m_szEndKey, pszValue));
		}
		else
		{
			// We don't have an end entity specified, use our parent as the end point.
			m_pEndEntity = (CMapEntity *)UpdateDependency(m_pEndEntity, GetParent());
		}

		BuildLine();
	}
}
예제 #2
0
파일: chat_keydefs.c 프로젝트: d3x0r/SACK
int CPROC KeyGetGatheredLine( PCHAT_LIST list, LOGICAL sendAlt, PUSER_INPUT_BUFFER pci )
{
	PTEXT tmp_input = GetUserInputLine( pci );
	PTEXT line = BuildLine( tmp_input );
	// input is in segments of 256 characters... collapse into a single line.
	list->input.command_mark_start = list->input.command_mark_end = 0;
	if( line && GetTextSize( line ) )
	{
		list->input.phb_Input->pBlock->pLines[0].flags.nLineLength = (int)LineLengthExEx( list->input.CommandInfo->CollectionBuffer, FALSE, 8, NULL );
		list->input.phb_Input->pBlock->pLines[0].pLine = list->input.CommandInfo->CollectionBuffer;
		list->input.phb_Input->flags.bUpdated = 1;
		BuildDisplayInfoLines( list->input.phb_Input, 0, list->input_font );
		if( line ) {
			if( sendAlt ) list->AltInputData( list->psvAltInputData, line );
			else list->InputData( list->psvInputData, line );
		}
	}
	else if( line )
		LineRelease( line );

	if( !line ) {
		if( sendAlt ) list->AltInputData( list->psvAltInputData, NULL );
		else list->InputData( list->psvInputData, NULL );
	}

	return UPDATE_COMMAND; 
}
예제 #3
0
void CTrajectory::Update()
{
	if( mPoints.size() > 0 )
	{
		mLineVertices.clear();
		mQuadVertices.clear();

		for( unsigned int i=0; i<mPoints.size(); i++ )
		{
			if( mPoints.size() > 1 && i > 0 )
				BuildLine( mPoints[i-1], mPoints[i], mColour, 1.f );
			DrawPoint( mPoints[i] );
		}

		mMesh->beginUpdate( 0 );
		mMesh->estimateVertexCount( mLineVertices.size() );
		for( std::vector<VertexPair>::iterator i = mLineVertices.begin(); i != mLineVertices.end(); ++i )
		{
			mMesh->position( i->first );
			mMesh->colour( i->second );
		}
		mMesh->end();
 
		mMesh->beginUpdate( 1 );
		mMesh->estimateVertexCount( mQuadVertices.size() );
		for( std::vector<VertexPair>::iterator i = mQuadVertices.begin(); i != mQuadVertices.end(); ++i )
		{
			mMesh->position(i->first);
			mMesh->colour( i->second.r, i->second.g, i->second.b, 0.5f );
		}
		mMesh->end();
	}
}
예제 #4
0
CORE_PROC(int, RelayInput)( PDATAPATH pdp
												, PTEXT (CPROC *Datacallback)( PDATAPATH pdp, PTEXT pLine ) )
{
	extern int gbTrace;
	if( pdp->pPrior )
	{
		PTEXT p;
		int moved = 0;

		if( gbTrace )
			xlprintf(LOG_NOISE+1)( WIDE("Relay input from %s to %s..........")
										, GetText( pdp->pPrior->pName )
										, GetText( pdp->pName ) );
		do
		{
			if( pdp->pPrior->Read )
			{
				pdp->pPrior->Read( pdp->pPrior );
			}
			if( IsQueueEmpty( &pdp->pPrior->Input ) )
				break;
			//Log( WIDE("Has some input to handle...") );
			while( ( p = (PTEXT)DequeLink( &pdp->pPrior->Input ) ) )
			{
				if( gbTrace )
					lprintf( WIDE("Data is: %s"), GetText( p ) );
				if( Datacallback && !( ( p->flags & TF_RELAY ) == TF_RELAY ) )
				{
					//lprintf( WIDE("Data callback...") );
					for( p = Datacallback( pdp, p ); p; p = Datacallback( pdp, NULL ) )
					{
						moved++;
						if( p != (POINTER)1 )
							EnqueLink( &pdp->Input, p );
						else
							lprintf( WIDE("Data was consumed by datapath.") );
					}
				}
				else
				{
					 PTEXT out = BuildLine( p );
					 Log1( WIDE("Relay In: %s"), GetText( out ) );
					 LineRelease( out );
					moved++;
					EnqueLink( &pdp->Input, p );
				}
			}
			if( gbTrace && !moved && !pdp->pPrior->flags.Closed )
			{
				lprintf( WIDE("Did not result in data, try reading source again, rerelay. %s %s"), GetText( pdp->pName ), GetText( pdp->pPrior->pName ) );
			}
		  } while( !moved &&
					 !pdp->pPrior->flags.Closed );
		// stop relaying closes at datasource points
		//if( !pdp->pPrior->flags.Data_Source )
		pdp->flags.Closed |= pdp->pPrior->flags.Closed;
		return moved;
	}
	return 0;
}
예제 #5
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : key - 
//			value - 
//-----------------------------------------------------------------------------
void CMapLine::OnParentKeyChanged( const char* key, const char* value )
{
	CMapWorld *pWorld = (CMapWorld *)GetWorldObject(this);
	if (pWorld != NULL)
	{
		if (stricmp(key, m_szStartValueKey) == 0)
		{
			m_pStartEntity = (CMapEntity *)UpdateDependency(m_pStartEntity, pWorld->FindChildByKeyValue(m_szStartKey, value));
			BuildLine();
		}
		else if (stricmp(key, m_szEndValueKey) == 0)
		{
			m_pEndEntity = (CMapEntity *)UpdateDependency(m_pEndEntity, pWorld->FindChildByKeyValue(m_szEndKey, value));
			BuildLine();
		}
	}
}
예제 #6
0
CORE_PROC(int, RelayOutput)( PDATAPATH pdp
									, PTEXT (CPROC *Datacallback)( PDATAPATH pdp, PTEXT pLine ) )
{
	extern int gbTrace;
	if( pdp->pPrior )
	{
		int moved = 0;
		PTEXT p;
		//if( gbTrace )
		//	lprintf( WIDE("Relay output from %s to %s..........")
		//			 , GetText( pdp->pName )
		//			 , GetText( pdp->pPrior->pName )
		//			 );
		while( ( p = (PTEXT)DequeLink( &pdp->Output ) ) )
		{
			//if( gbTrace )
			//	lprintf( WIDE("Data is: %s"), GetText( p ) );
			if( Datacallback && !( ( p->flags & TF_RELAY ) == TF_RELAY ) )
			{
				for( p = Datacallback( pdp, p ); p; p = Datacallback( pdp, NULL ) )
				{
					EnqueLink( &pdp->pPrior->Output, p );
				}
			}
			else
			{
#ifdef _DEBUG
				//PTEXT out = BuildLine( p );
				//Log1( WIDE("Relay Out: %s"), GetText( out ) );
				//LineRelease( out );
#endif
				EnqueLink( &pdp->pPrior->Output, p );
			}
		}
		// stop relaying closes at datasource points
		//if( !pdp->pPrior->flags.Data_Source )
		pdp->flags.Closed |= pdp->pPrior->flags.Closed;
		if( pdp->pPrior->Write )
			moved = pdp->pPrior->Write( pdp->pPrior );
		return moved;
	}
	else
	{
		PTEXT p;
		while( ( p = (PTEXT)DequeLink( &pdp->Output ) ) )
		{
			if( gbTrace )
			{
				PTEXT pLine = BuildLine( p );
				lprintf( WIDE("Relay to dev NULL... Data is: %s"), GetText( pLine ) );
				LineRelease( pLine );
			}
			LineRelease( p );
		}
	}
	return 0;
}
예제 #7
0
void CTrajectory::DrawPoint( const Ogre::Vector3& Pos )
{
	Ogre::Vector3 dx = mPointSize/2*Ogre::Vector3::UNIT_X;
	Ogre::Vector3 dy = mPointSize/2*Ogre::Vector3::UNIT_Y;
	Ogre::Vector3 dz = mPointSize/2*Ogre::Vector3::UNIT_Z;

	Ogre::Vector3 Vertices[8];
	Vertices[0] = Pos + dx + dy + dz;
	Vertices[1] = Pos + dx - dy + dz;
	Vertices[2] = Pos + dx - dy - dz;
	Vertices[3] = Pos + dx + dy - dz;
	Vertices[4] = Pos - dx + dy + dz;
	Vertices[5] = Pos - dx + dy - dz;
	Vertices[6] = Pos - dx - dy - dz;
	Vertices[7] = Pos - dx - dy + dz;

	BuildQuad( Vertices, mColour );
	BuildQuad( Vertices + 4, mColour );
 
	BuildLine( Vertices[1], Vertices[7], mColour );
	BuildLine( Vertices[2], Vertices[6], mColour );
 
	BuildLine( Vertices[0], Vertices[4], mColour);
	BuildLine( Vertices[3], Vertices[5], mColour);
 
	
	Ogre::Vector3 Top[4] = { Vertices[0], Vertices[4], Vertices[7], Vertices[1] };
	Ogre::Vector3 Bottom[4] = { Vertices[2], Vertices[6], Vertices[5], Vertices[3] };
 
	Ogre::Vector3 Left[4] = { Vertices[1], Vertices[7], Vertices[6], Vertices[2] };
	Ogre::Vector3 Right[4] = { Vertices[0], Vertices[3], Vertices[5], Vertices[4] };
 
	BuildFilledQuad( Vertices, mColour, 0.5f );
	BuildFilledQuad( Vertices + 4, mColour, 0.5f );
	BuildFilledQuad( Top, mColour, 0.5f );
	BuildFilledQuad( Bottom, mColour, 0.5f );
	BuildFilledQuad( Left, mColour, 0.5f );
	BuildFilledQuad( Right, mColour, 0.5f );
}
예제 #8
0
파일: newldis.c 프로젝트: mingpen/OpenNT
void DisTopDown( void )
{
    ULONG   ulRow;
    char    *pt;

    pData = vpBlockTop->Data;
    pData += vOffTop;
    ulBlkOffset = vOffTop;

    pt = vScrBuf+vWidth;

    for (ulRow=0; ulRow < (ULONG)vLines; ulRow++ ) {
	BuildLine (ulRow, pt);
	pt += vWidth;
    }
}
예제 #9
0
// поставить стрелочку в точке i j 
uint32_t SetPoint(cad_route_map *self, uint32_t i, uint32_t j, uint32_t ArrowType)
{
	if (i < 0 || j < 0 || i >= self->height || j >= self->width) return MORE_ACTIONS_IN_DEMO_MODE;
	if (i == self->sys->current_start_x && j == self->sys->current_start_y) return MORE_ACTIONS_IN_DEMO_MODE;

	if ( self->sys->EndPoints.empty() && 
		(MapElement3D(self, i, j, self->currerntLayer) == (MAP_PIN | (*self->sys->CurrentWire)->number)) ||
		self->sys->EndPoints.find(((0LL + i) << 32) | j) != self->sys->EndPoints.end())
	{
		// конец волны. исходныая позиция подключается к конечной в точке i j
		int x = (MapElement3D(self, i, j, self->currerntLayer));	
		bool c = self->sys->EndPoints.empty() && 
		(MapElement3D(self, i, j, self->currerntLayer) == (MAP_PIN | (*self->sys->CurrentWire)->number));
		BuildLine(self, i,j, ArrowType);
		self->sys->queue.clear();
		return FindWireToTrace( self );
	}

	uint32_t val = MapElement3D(self, i, j, self->currerntLayer);
	uint32_t val2 = MapElement3D(self, i+1, j, self->currerntLayer);

	if ( val & MAP_PIN ) return MORE_ACTIONS_IN_DEMO_MODE;

	if ( val != MAP_EMPTY &&
		 val != MAP_WIRE_HORIZONTAL &&
		 val != MAP_WIRE_VERTICAL )
	{
		return MORE_ACTIONS_IN_DEMO_MODE;
	}
	
	self->sys->queue.push_back(((0LL + i) << 32) | j);

	if ( (val == MAP_WIRE_VERTICAL || val == MAP_WIRE_HORIZONTAL) )
	{
		uint32_t num = ArrowType & NUMBER_MASK;
		ArrowType =  (MAP_ARROW_RIGHT | MAP_NUMBER) | num;
		if (((val2 & MAP_WIRE_VERTICAL)==MAP_WIRE_VERTICAL) && ((val & MAP_WIRE_VERTICAL)==MAP_WIRE_VERTICAL))
		ArrowType += 0;
		else ArrowType += 1;
	}
	
	val |= (ArrowType | MAP_NUMBER); 
	MapElement3D(self, i, j, self->currerntLayer) = val;

	return MORE_ACTIONS_IN_DEMO_MODE;
}
예제 #10
0
void StoreMacros( FILE *pFile, PSENTIENT ps )
{

   {
      INDEX idx;
      PLIST pVars;
      PTEXT pVar, pVal;
      pVars = ps->Current->pVars;
      fprintf( pFile, WIDE("\n## Begin Variables\n") );
      LIST_FORALL( pVars, idx, PTEXT, pVar )
      {
         fprintf( pFile, WIDE("/Declare %s "), GetText( pVar ) );
         pVal = BuildLine( GetIndirect( NEXTLINE( pVar ) ) );
         if( pVal )
            fprintf( pFile, WIDE("%s\n"), GetText( pVal ) );
         else
            fprintf( pFile, WIDE("\n") );
      }
      fprintf( pFile, WIDE("\n## Begin Macros\n") );
   }
예제 #11
0
int CPROC CHANGEDIR( PSENTIENT ps, PTEXT parameters )
{
   PTEXT pDir, pDir1;
   pDir1 = MacroDuplicateEx( ps, parameters, TRUE, TRUE );
   if( pDir1 )
      pDir = BuildLine( pDir1 );
   else
      return FALSE;
   LineRelease( pDir1 );
   if( SetCurrentPath( GetText( pDir ) ) )
   {
      if( ps->CurrentMacro )
         ps->CurrentMacro->state.flags.bSuccess = TRUE;
      else
      {
			DECLTEXT( msg, WIDE("Changed directory successfully.") );
			{
            TEXTCHAR buf[257];
				GetCurrentPath( buf, sizeof( buf ) );
				SetDefaultFilePath( buf );
			}
         EnqueLink( &ps->Command->Output, &msg );
      }
   }
   else
   {
      if( !ps->CurrentMacro )
      {
         DECLTEXT( msg, WIDE("Failed to change directory.") );
         EnqueLink( &ps->Command->Output, &msg );
      }
   }
   LineRelease( pDir );

   return FALSE;
}
예제 #12
0
// поставить стрелочку в точке i j 
uint32_t SetPoint(cad_route_map *self, uint32_t i, uint32_t j, uint32_t ArraowType)
{
	if (i < 0 || j < 0 || i >= self->height || j >= self->width) return MORE_ACTIONS_IN_DEMO_MODE;
	if (i == self->sys->current_start_x && j == self->sys->current_start_y) return MORE_ACTIONS_IN_DEMO_MODE;

	if ( self->sys->EndPoints.empty() && 
		(MapElement3D(self, i, j, self->currerntLayer) == (MAP_PIN | (*self->sys->CurrentWire)->number)) ||
		self->sys->EndPoints.find(((0LL + i) << 32) | j) != self->sys->EndPoints.end())
	{
		// конец волны. исходныая позиция подключается к конечной в точке i j
		int x = (MapElement3D(self, i, j, self->currerntLayer));	
		bool c = self->sys->EndPoints.empty() && 
		(MapElement3D(self, i, j, self->currerntLayer) == (MAP_PIN | (*self->sys->CurrentWire)->number));
		BuildLine(self, i,j, ArraowType);
		self->sys->queue.clear();
		return FindWireToTrace( self );
	}

	if (MapElement3D(self, i, j, self->currerntLayer) != MAP_EMPTY) return MORE_ACTIONS_IN_DEMO_MODE;

	self->sys->queue.push_back(((0LL + i) << 32) | j);
	MapElement3D(self, i, j, self->currerntLayer) = ArraowType;
	return MORE_ACTIONS_IN_DEMO_MODE;
}
예제 #13
0
static PTEXT CPROC ParseCommand( PMYDATAPATH pdp, PTEXT buffer )
{
	if( buffer )
	{
		PTEXT pCommand;
     	//Log2( WIDE("buffer: %s(%d)"), GetText( buffer ), GetTextSize( buffer ) );
     	//LogBinary( buffer );
      pCommand = burst( buffer );
      LineRelease( buffer );
      if( pCommand )
      {
         PTEXT pTemp, pStart;
         int bEscaped = FALSE;
         pStart = pTemp = pCommand;
         while( pTemp )
         {
            if( TextIs( pTemp, WIDE("\\") ) )
            {
               if( !bEscaped )
               {
                  PTEXT pNext;
                  pNext = NEXTLINE( pTemp );
                  pNext->format.position.offset.spaces = pTemp->format.position.offset.spaces;
                  LineRelease( SegGrab( pTemp ) );
                  bEscaped = TRUE;
                  pTemp = pNext;
                  continue;
               }
            }
            if( !bEscaped && TextIs( pTemp, WIDE(";") ) )
            {
               PTEXT pPrior;
	           	//Log( WIDE("Splitting the line and enqueing it...") );
               pPrior = pTemp;
               SegBreak( pTemp );
               if( pStart != pTemp )
               {
               	// end of line included!
               	pStart = SegAppend( pStart, SegCreate(0) ); 
                  EnqueLink( &pdp->output, pStart );
               }
               pStart = pTemp = NEXTLINE( pTemp );
               SegBreak( pTemp );
               LineRelease( pPrior ); // remove ';'
               bEscaped = FALSE;
               continue;
            }
            bEscaped = FALSE;
            pTemp = NEXTLINE( pTemp );
         }
         if( pStart )
         {
         	PTEXT line;
         	line = BuildLine( pStart );
         	//Log1( WIDE("Enqueu: %s"), GetText( line ) );
         	LineRelease( line );
            EnqueLink( &pdp->output, pStart );
         }
      }
      else
      {
         // well what now?  I guess pLine got put into Partial...
         // next pass through this all for command recall will blow...
         Log( WIDE("No information from the burst!") );
      }
	}
	return (PTEXT)DequeLink( &pdp->output );
}
예제 #14
0
void HTTPCollapse( PTEXT *ppText )
{
	PTEXT output;
	PTEXT input = *ppText;
	while( input )
	{
		if( GetText( input )[0] == '+' )
		{
			PTEXT subst;
			// sometimes a + can be attached to a number
			// so much for the natural language parser dealing with
         // a machine oriented protocol...
			if( GetTextSize( input ) > 1 )
			{
            SegSplit( &input, 1 );
			}
         subst = GetSubst( '+' );
			SegInsert( subst, input );
			LineRelease( SegGrab( input ) );
         input = subst;
			if( !PRIORLINE( input ) )
            (*ppText) = input;
		}
		else if( TextIs( input, WIDE("%") ) )
		{
			PTEXT next = NEXTLINE( input );
			if( next )
			{
				PTEXT subst;
				SegSplit( &next, 2 );
				subst = GetSubst( *(unsigned short*)GetText( next ) );
				if( subst )
				{
					PTEXT nextnext = NEXTLINE( next );
					PTEXT prior = SegBreak( input );
					if( !prior )
					{
						*ppText = SegAppend( subst, nextnext );
					}
					if( nextnext )
					{
						SegBreak( nextnext );
						if( !prior )
							*ppText = nextnext;
						else
							SegAppend( prior, nextnext );
						SegInsert( subst, nextnext );
						input = nextnext;
						continue;
					}
					else
					{
						SegAppend( prior, (PTEXT)&subst );
						input = NULL;
						continue;
					}
				}
            // if not subst... just continue stepping, no replacement nessecary?
			}
		}
      input = NEXTLINE( input );
	}
	output = BuildLine( *ppText );
	LineRelease( *ppText );
   (*ppText) = output;
}
예제 #15
0
int main()
{
    Frustum frustum;

    osgViewer::CompositeViewer viewer;
    viewer.setThreadingModel(osgViewer::ViewerBase::SingleThreaded);

    // Circle
    Circle c;
    c.normal = osg::Vec3d(1,1,1);
    c.normal.normalize();

    c.center = osg::Vec3d(1,3,4);
    c.radius = 25;
    auto gp_circle = BuildCircle(c,osg::Vec4(0.5,0.5,0.5,1.0));

    // View0 root
    osg::ref_ptr<osg::Group> gp_root0 = new osg::Group;
    gp_root0->addChild(gp_circle);

    // View1 root
    osg::ref_ptr<osg::Group> gp_root1 = new osg::Group;
    gp_root1->addChild(gp_circle);

    // disable lighting and enable blending
    gp_root0->getOrCreateStateSet()->setMode( GL_LIGHTING,osg::StateAttribute::OFF);
    gp_root0->getOrCreateStateSet()->setMode( GL_BLEND,osg::StateAttribute::ON);
    gp_root0->getOrCreateStateSet()->setMode( GL_DEPTH_TEST,osg::StateAttribute::OFF);

    gp_root1->getOrCreateStateSet()->setMode( GL_LIGHTING,osg::StateAttribute::OFF);
    gp_root1->getOrCreateStateSet()->setMode( GL_BLEND,osg::StateAttribute::ON);
    gp_root1->getOrCreateStateSet()->setMode( GL_DEPTH_TEST,osg::StateAttribute::OFF);

    // Create View 0
    {
        osgViewer::View* view = new osgViewer::View;
        viewer.addView( view );

        view->setUpViewInWindow( 10, 10, 640, 480 );
        view->setSceneData( gp_root0.get() );
        view->getCamera()->setClearColor(osg::Vec4(0.1,0.1,0.1,1.0));

        osg::ref_ptr<osgGA::TrackballManipulator> view_manip =
                new osgGA::TrackballManipulator;
        view_manip->setMinimumDistance(100);

        view->setCameraManipulator(view_manip);

    }

    // Create view 1 (this view shows View0's frustum)
    {
        osgViewer::View* view = new osgViewer::View;
        viewer.addView( view );

        view->setUpViewInWindow( 10, 510, 640, 480 );
        view->setSceneData( gp_root1.get() );
        view->getCamera()->setClearColor(osg::Vec4(0.1,0.1,0.1,1.0));

        osg::ref_ptr<osgGA::TrackballManipulator> view_manip =
                new osgGA::TrackballManipulator;
        view_manip->setMinimumDistance(100);

        view->setCameraManipulator(view_manip);
    }

    while(!viewer.done())
    {
        osg::Camera * camera = viewer.getView(0)->getCamera();
        osg::Vec3d eye,vpt,up;
        double fovy,ar,near,far;
        camera->getViewMatrixAsLookAt(eye,vpt,up);
        camera->getProjectionMatrixAsPerspective(fovy,ar,near,far);
        osg::Vec3d viewdirn = vpt-eye;
        viewdirn.normalize();

        // new frustum
        auto new_frustum = BuildFrustumNode(camera,frustum);

        // new viewdirn
        auto new_viewdirn = BuildLine(eye,eye+(viewdirn*far),K_COLOR_GRAY);
        new_viewdirn->setName("viewdirn");

        // new closest point circle/point
        osg::Vec3d const cp_circle_pt = ClosestPointCirclePoint(c,eye);
        auto new_cp_circle_pt = BuildFacingCircle(cp_circle_pt,
                                                  eye.length()/150.0,
                                                  8,K_COLOR_RED);
        new_cp_circle_pt->setName("cp_circle_pt");

        // Update gp_root0
        {
            for(size_t i=0; i < gp_root0->getNumChildren(); i++) {
                std::string const name = gp_root0->getChild(i)->getName();
                // Remove prev camera node
                if(name == "cp_circle_pt") {
                    gp_root0->removeChild(i);
                    i--;
                }
            }
            // Add new nodes
            gp_root0->addChild(new_cp_circle_pt);
        }

        // Update gp_root1
        {
            for(size_t i=0; i < gp_root1->getNumChildren(); i++) {
                std::string const name = gp_root1->getChild(i)->getName();
                // Remove prev camera node
                if(name == "frustum") {
                    gp_root1->removeChild(i);
                    i--;
                }
                else if(name == "viewdirn") {
                    gp_root1->removeChild(i);
                    i--;
                }
                else if(name == "cp_circle_pt") {
                    gp_root1->removeChild(i);
                    i--;
                }
            }
            // Add new nodes
            gp_root1->addChild(new_frustum);
            gp_root1->addChild(new_viewdirn);
            gp_root1->addChild(new_cp_circle_pt);
        }

        viewer.frame();

    }
    return 0;
}
예제 #16
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pTransBox - 
//-----------------------------------------------------------------------------
void CMapLine::DoTransform(const VMatrix &matrix)
{
	BaseClass::DoTransform(matrix);
	BuildLine();
}
//
//	Override the abstract Create function to make this
//	a real class.
//	Create works its way through the text in the scanner one
//	line at a time. Each line must contain a command and a set
//	of arguments. Create examines the command and then calls
//	on helper functions to do the right things with the arguments.
//
bool CGLAList::Create() {
	if (mScan == NULL) {	// Quit if there is no scanner
		return false;
	}
	// 
	//	Work through the file.
	//	Each line should begin with a command and then be
	//	followed by a set of numeric arguments.
	//
	Lexeme* cLex;
	CSymbol* cSym = NULL;
  bool finished = false;
	Start();
	while ((cLex = mScan->NextLex())->lex != LEof) {
    if (cLex->lex == LNewLine || cLex->lex==LSpace) continue;
		if (cLex->lex == LWord) {	// Hope we have a command
#ifdef DEBUG
eprintf("Word %s ", cLex->sVal);
wxLogMessage(gMsgBuff);
#endif
			cSym = gSymTab->LookUpWord(cLex->sVal);
			//
			//	Now read in the arguments.
			//
			int nArg = GetArgList();
#ifdef DEBUG
      eprintf("Found %d arguments",nArg);
      wxLogMessage(gMsgBuff);
				for (int ii = 0; ii < nArg; ++ii) {
          eprintf(" %f", gArguments[ii]);
          wxLogMessage(gMsgBuff);
				}
      wxLogMessage("\r\n");
#endif
			if (cSym != NULL) {
				//
				//	Found a valid command, dispatch a function
				//	to handle it.
				//
#ifdef DEBUG
        eprintf("matches symbol %d\r\n",cSym->mSym);
        wxLogMessage(gMsgBuff);
#endif
				switch (cSym->mSym) {
					case kGLColor:
						if (nArg >= 3) {
							GLfloat color[4];
							color[0] = gArguments[0];
							color[1] = gArguments[1];
							color[2] = gArguments[2];
							if (nArg > 3) {
								color[3] = gArguments[3];
							} else {
								color[3] = 1.0f;
							}
							glMaterialfv(GL_FRONT, GL_AMBIENT, color);
							glMaterialfv(GL_FRONT, GL_SPECULAR, color);
              glColor3fv(color);
						}
						break;

					case kGLPoint:
						if (nArg >= 3) {
							glBegin(GL_POINTS);
							glVertex3fv(gArguments);
							glEnd();
							mBounds->AddPoint3fv(&gArguments[0]);
						}
						break;

					case kGLTranslate:
						if (nArg >= 3) {
							glTranslatef(gArguments[0],gArguments[1],gArguments[2]);
						}
						break;

					case kGLLine:
						BuildLine(nArg);
						break;

					case kGLPolyLine:
						BuildPolyLine(nArg);
						break;

					case kGLSphere:
						BuildSphere(nArg);
						break;

					case kGLBox:
						BuildBox(nArg);
						break;

					case kGLTriangle:
						BuildTriangle(nArg);
						break;
            
          case kGLCylinder:
            BuildCylinder(nArg);
            break;

          case kGLCap:
            BuildCap(nArg);
            break;
            
          case kGLEnd:
            finished = true;
            break;
            
					default:
            eprintf("CGLAList.Create: Unimplemented GLA verb %s.\r\n", cSym->mName);
						break;
				}
			} else {
        eprintf("CGLAList.Create: %s is an unrecognised GLA verb.\r\n", cLex->sVal);
			}
		} else {	// Did not find a command
			//
			//	Print a message.
			//
      eprintf("CGLAList.Create: Cound not find a command on line %lu.\r\n", mScan->LineNumber());
      eprintf("%s", mScan->GetLine());
		}
    if (finished) break;
		//
		//	Eat tokens til we get to the
		//	end of the line (or a premature EOF)
		//
		while ((cLex = mScan->NextLex())->lex != LNewLine && cLex->lex != LEof);
		} // end while
	End();
	ReleaseScanner();
	return true;
}
예제 #18
0
/*****************************************************************************
 * Function: GetSelectedText
 *
 *****************************************************************************/
static int
GetSelectedText(
    _DtCanvasStruct	*canvas,
    _DtCvSelectData next,
    _DtCvSelectData end,
    unsigned int         mask,
    _DtCvPointer	*ret_data)
{
    _DtCvUnit   maxY;
    _DtCvUnit   botY;
    int    i;
    int    lineCnt  = 0;
    int    junk;
    int    result   = 0;
    int    cpyCnt   = 0;
    int    txtCnt   = canvas->txt_cnt;
    _DtCvFlags endFlag;
    _DtCvValue  processing = True;
    _DtCvDspLine   *lines = canvas->txt_lst;

    for (i = 0; i < txtCnt; i++)
	_DtCvClearProcessed(lines[i]);

    MarkLinesOutsideBoundary(canvas, next.y, next.x, end.y, end.x);

    maxY = next.y;
    if (next.line_idx == -1)
      {
	/*
	 * find the first selected line
	 */
	if (FindNextMinY(lines, txtCnt, -1, &next.y) == False)
	    return 0;

	next.x  = 0;
	lineCnt = FindMinX(lines, txtCnt, next.y, &next.line_idx);
	next.char_idx = 0;
      }
    else
	lineCnt = FindMinX(lines, txtCnt, next.y, &junk);

    while (processing == True && result == 0)
      {
	/*
	 * process the next line of text.
	 */
	do
	  {
	    endFlag = 0;
	    cpyCnt  = lines[next.line_idx].length - next.char_idx;
	    if (next.line_idx == end.line_idx)
		cpyCnt = cpyCnt - lines[next.line_idx].length + end.char_idx;
	    else if (lineCnt == 1)
		endFlag = _DtCvEND_OF_LINE;

	    result  = BuildLine(canvas, mask, maxY, next.x,
					next.line_idx, next.char_idx,
					cpyCnt, endFlag,
					&next.x, &botY, ret_data);

	    if (botY > maxY)
		maxY = botY;

	    next.char_idx = 0;
	    lineCnt       = FindMinX(lines, txtCnt, next.y, &next.line_idx);

	  } while (result == 0 && lineCnt > 0);

	if (result == 0)
	  {
	    next.x = 0;
	    processing = FindNextMinY(lines, txtCnt, -1, &next.y);
	    if (processing == True)
		lineCnt = FindMinX(lines, txtCnt, next.y, &next.line_idx);
	  }
      }

    return result;

} /* End GetSelectedText */
예제 #19
0
int CPROC MakeProcess( PSENTIENT ps, PENTITY peInit, PTEXT parameters )
{
	// parameters specify command and parameters to launch...
	// perhaps a working directory? May or may not want it
	// in the current directory...
	// /make process test WIDE("command arguments") WIDE("work path") <attributes?>
	// /make process test WIDE("notepad trigger.txt") 
	PSENTIENT ps2;
	PPROCESS process = New( PROCESS );
	TEXTCHAR MyPath[256];
	GetCurrentPath( MyPath, sizeof( MyPath ) );
	ps2 = CreateAwareness( peInit );
	MemSet( process, 0, sizeof( PROCESS ) );
	Log( WIDE("Have a process, and woke it up... setting the link") );
	SetLink( &peInit->pPlugin, iProcess, process );
	SetLink( &peInit->pDestroy, iProcess, DestroyProcess );
	Log( WIDE("Set the link, getting params...") );
	{
		PTEXT text, cmd = NULL;
		text = GetParam( ps, &parameters );
		if( text && TextIs( text, WIDE("\"") ) )
		{
	      Log( WIDE("Found a quote, getting command line") );
			while( (text = GetParam( ps, &parameters )) && !TextIs( text, WIDE("\"") ) )
			{
				cmd = SegAppend( cmd, SegDuplicate( text ) );
			}
			cmd->format.position.offset.spaces = 0;
			process->command = BuildLine( cmd );
			if( text ) // closed, and may have start path....
			{
				text = GetParam( ps, &parameters );
		   	if( text && TextIs( text, WIDE("\"") ) )
				{
					Log( WIDE("Found a quote, getting the path") );
					while( (text = GetParam( ps, &parameters )) && !TextIs( text, WIDE("\"") ) )
					{
						cmd = SegAppend( cmd, SegDuplicate( text ) );
		   		}
		   		cmd->format.position.offset.spaces = 0;
		   		process->directory = BuildLine( cmd );
				}
			}
		}
		else
		{
			DECLTEXT( msg, WIDE("Must specify process to execute in quotes (\")") );
			EnqueLink( &ps->Command->Output, &msg );
		WakeAThread( ps2 );
			return -1; // abort creation.
		}
	}
	Log2( WIDE("Starting %s in %s"), GetText( process->command ), GetText( process->directory ) );
	process->si.cb = sizeof( process->si );
	// remaining startup info members are NULL - specifying we do NOT care
	// why why when where how the process starts.
	if( StartProcess( process ) )
	{
		DECLTEXTSZ( msg, 256 );
		msg.data.size = snprintf( msg.data.data, 256*sizeof(TEXTCHAR), WIDE("Failed to start \"%s\" in \"%s\" error: %ld"),
										 GetText( process->command ),
										 GetText( process->directory ),
										 GetLastError() );
		EnqueLink( &ps->Command->Output, SegDuplicate( (PTEXT)&msg ) );
		WakeAThread( ps2 );
		return -1; // abort creation.
	}
	// well otherwise would seem we've launched a valid application
	// we have valid process and thread handles to it which can be monitored
	// and well that's about that.
	WakeAThread( ps2 );
	return 0;
}