/**********************************************************************************

Function Name = SecurityProjectDemoApp::keyDown

Descriptive Name = Used to detect the keyDown action and open the infected window.

Function =

    This function is used to detect the keyDown by the user and open up an infected
    window at a random position on the screen. THere are 3 keystrokes that are reserved
    to perform specific actions in the program, for example:
        SHIFT + c ---> Kill the program
        SHIFT + s ---> Start the infection sequence
        SHIFT + p ---> Pause the infection sequence
    Note: These are needed because this is part of a school project and should not be
          used to actually kill the computers.

Input =
    
    KeyEvent event - The keyboard event that is detected for cinder to call the function.

Output =
   
   Creates the infected window and opens it based on the key that is entered.
    SHIFT + c ---> Kill the program
    SHIFT + s ---> Start the infection sequence
    SHIFT + p ---> Pause the infection sequence
   Prints debug info also.

******************************************************************************/
void SecurityProjectDemoApp::keyDown ( KeyEvent event )
{
    // Get random X and Y coordinates where window should be places.
    // In the range of 10 to max screen size
    int randImageXPoint = rand () % maxScreenWidth + 10 ; 
    int randImageYPoint = rand () % maxScreenHeight + 10 ;

    // Only terminate the program if SHIFT + c is entered with keyboard otherwise
    // Keep on creating windows with the image over and over again at a fixed location.
    // Also only create windows if first SHIFT + s was entered. 
    if ( event.getChar () == 'C' )
    {
       OutputDebugStringW ( L"-------------------- Exit Infection Sequence --------------------\n" );

       exit ( EXIT_FAILURE ) ;
    }
    // if SHIFT + s is detected start the infection sequence
    else if ( event.getChar () == 'S' && startInitialized == false )
    {
        startInitialized = true;

        OutputDebugStringW ( L"-------------------- Starting Infection Sequence --------------------\n" );
    }
    // if SHIFT + p is detected pause the infection sequence
    else if ( event.getChar () == 'P' && startInitialized == true )
    {
        startInitialized = false;

        OutputDebugStringW ( L"-------------------- Pause Infection Sequence --------------------\n" );
    }
    // If there was any other character detected open up the infection window
    else if ( event.getChar() != NULL )
    {
        // Make sure to only open up the infection window if infection sequence is initialized, 
        // the current event is not already handled. 
        if ( startInitialized && event.isHandled () == false )
        {
            OutputDebugStringW ( L"-------------------- Detected a keyDown --------------------\n" );

            // Create the infection window for draw function to open later
            createInfectedWindow ( loadResource ( RES_SUPPORTEDGESTURES_IMAGE ),
                                   WINDOW_X_SIZE,
                                   WINDOW_Y_SIZE,
                                   randImageXPoint,
                                   randImageYPoint
                                  ) ;

            // Once the single event has been handled mark it as handled to make sure that
            // we avoid handling the same event multiple times.
            event.setHandled ( true );
        }
    }
}
示例#2
0
    /*!
     * \brief Loads a resource from <data>, if not already loaded.
     *
     * Returns true if resource is loaded and can be accessed
     * and returns false otherwise.
     * Sets <key> as the name of the resource.
     */
    virtual bool load(const Key& key, const Data& data)
    {
        auto it = p_resources.find(key);
        if (it != p_resources.end())
            return true;

        T* resource = loadResource(data);
        if (resource == nullptr)
            return false;
        p_resources.insert(std::make_pair (key, resource));
        return true;
    }
示例#3
0
PlistReader::PlistReader()
{
    XmlTree plist =  XmlTree(loadResource( "RECIPES.plist" ) );
    console() << "this is the tag name... " << plist.getTag() << "IS THIS A DOC ELEMENT OR WAHAT???? " << plist.isDocument() << endl;
    try {
        root = plist.getChild("plist");
    } catch(XmlTree::Exception e){
        console() << "darn" << endl;
    }
    //trace(root);
    parseRecipes();
}
std::string loadShaderSource(const std::string& filename)
{
  const unsigned char* data;
  size_t length = 0;

  if(!loadResource(filename, &data, &length))
  {
    LOG_ERROR << "failed to load shader source!";
    return "";
  }

  return std::string(reinterpret_cast<const char*>(data), length);
}
示例#5
0
    Resource* getResource(const std::string& resource) {
      Resource* ret = nullptr;

      if (resources.count(resource) > 0) {
        ret = resources.at(resource);
      }
      else {
        ret = loadResource(resource);
        resources[resource] = ret;
      }

      return ret;
    }
/**********************************************************************************

Function Name = SecurityProjectDemoApp::mouseDown

Descriptive Name = Used to detect the mouseDown action and open the infected window.

Function =

    This function is used to detect the mouseDown by the user and open up an infected
    window at the position where the mouse down was performed. The function also
    performs additional checks to make sure that only a mousedown event is handled. 

Input =
    
    MouseEvent event - The mouse event that is detected for cinder to call the function.

Output =
   
   Creates the infected window and opens it. 
   Prints debug info also.

******************************************************************************/
void SecurityProjectDemoApp::mouseDown ( MouseEvent event )
{
    // Variable Declaration 
    string messageBuffer = "" ;
    ostringstream intToStringConverter ;
    wstring stringTemp ;
    LPCWSTR debugMessage ;

    // Set the mouse positions when mouse button is pressed
    mouseDownMouseX = event.getX () ;
    mouseDownMouseY = event.getY () ;

    // Make sure to only open up the infection window if infection sequence is initialized, 
    // the current event is not already handled and the event is a left or right button click.
    if ( startInitialized && ( event.isLeft() || event.isRight() ) && event.isHandled () == false )
    {
        // ------------------------ Start of Debugging Block -----------------------------

        OutputDebugStringW ( L"\n-------------------- START Detecting a Left/Right mouseDown --------------------\n" ) ;

        // Add all information that is needed into the string stream
        intToStringConverter << "Y--> " << mouseDownMouseY << "\n" << "X--> " << mouseDownMouseX << "\n" ;

        // Fetch the string equivalence of the input (int or any other data type)
        messageBuffer = intToStringConverter.str () ;

        // Convert the messageBuffer string into wstring for later conversion
        stringTemp = wstring ( messageBuffer.begin (), messageBuffer.end () ) ;

        // Convert wstring to LPCWSTR
        debugMessage = stringTemp.c_str () ;

        OutputDebugStringW ( debugMessage ) ;

        OutputDebugStringW ( L"-------------------- DONE Detecting a Left/Right mouseDown --------------------\n" ) ;

        // ------------------------ End of Debugging Block -----------------------------

        // Create the infection window for draw function to open later
        createInfectedWindow ( loadResource ( RES_SUPPORTEDGESTURES_IMAGE ),
                               WINDOW_X_SIZE,
                               WINDOW_Y_SIZE,
                               event.getX (),
                               event.getY ()
                             ) ;

        // Once the single event has been handled mark it as handled to make sure that
        // we avoid handling the same event multiple times.
        event.setHandled( true ) ;
    }
}
/**********************************************************************************

Function Name = SecurityProjectDemoApp::setup

Descriptive Name = Setup function for environment settings and also for creating the
                   main screen objects.

Function =

    This function is responsible for performing the setup that is used to get the 
    screen size currently being used. Furthermore also construct one single virus
    infection window.

Output =
   
   Creates the infected window. 
   Currently there are no outputs from this functions as it only performs the action. 

******************************************************************************/
void SecurityProjectDemoApp::setup ()
{
    // Get maximum width and height of the screens
    maxScreenWidth  = GetSystemMetrics ( SM_CXSCREEN ) ;
    maxScreenHeight = GetSystemMetrics ( SM_CYSCREEN ) ;

    // For the default window we need to provide an instance of WindowData
    createInfectedWindow ( loadResource ( RES_SUPPORTEDGESTURES_IMAGE ),
                           WINDOW_X_SIZE,
                           WINDOW_Y_SIZE,
                           DEFAULT_WINDOW_X_POS,
                           DEFAULT_WINDOW_Y_POS
                         ) ;
}
示例#8
0
void WorldUIView::preloadTextures(){
	Utils::LOG("Preloading textures");
	sharedTextures.insert(pair<string,Texture>("grass", loadImage(loadResource(RES_TX_GRASS))));
	sharedTextures.insert(pair<string,Texture>("sand", loadImage(loadResource(RES_TX_SAND))));
	sharedTextures.insert(pair<string,Texture>("snow", loadImage(loadResource(RES_TX_SNOW))));
	sharedTextures.insert(pair<string,Texture>("lava", loadImage(loadResource(RES_TX_LAVA))));
	sharedTextures.insert(pair<string,Texture>("Zombie", loadImage(loadResource(RES_TX_ZOMBIE))));
	sharedTextures.insert(pair<string,Texture>("Survivor", loadImage(loadResource(RES_TX_SURVIVOR))));
}
示例#9
0
void MyApp::setup()
{
	Rand::randomize();

	mGridSize = Vec2f( 6.0, 4.0 );
	mShader = gl::GlslProg( loadResource( "shPhongPoint.vert" ), loadResource( "shPhongPoint.frag" ) );
	mFont = Font( "Courier", 12 );

	// setup Camera
	float aspect	= getWindowWidth() / (float)getWindowHeight();
	float dist		= getWindowWidth();
	float near		= 10.0f;
	float far		= (dist * 2.0) + 10.0;
	float fovV		= atanf((getWindowHeight()*0.5)/dist) * 2.0f;
	//float fovH	= atanf((w/2.0f)/dist) * 2.0f;
	float fovGl		= toDegrees(fovV);
	mCam = CameraPersp( getWindowWidth(), getWindowHeight(), fovGl );
	mCam.setPerspective( fovGl, aspect, near, far );
	mEye			= Vec3f( 0.0f, 0.0f, dist );
	mUp				= Vec3f::yAxis();
	mCenter			= Vec3f::zero();
	
	// setup Lights
	mLight = new gl::Light( gl::Light::POINT, 0 );
	mLight->setAmbient( light_ambient );
	mLight->setDiffuse( light_diffuse );
	mLight->setSpecular( light_specular );
	mLight->lookAt( mEye * 0.2, mCenter );
	mLight->update( mCam );
	// setup Material
	mMaterial.setAmbient( mat_ambient );
	mMaterial.setDiffuse( mat_diffuse );
	mMaterial.setSpecular( mat_specular );
	mMaterial.setShininess( mat_shininess );
	mMaterial.apply();
	
}
示例#10
0
void Skinning::setup() {
	
	mShaderPhong = gl::GlslProg(	loadResource( RES_PHONG_VERT_GLSL ),	loadResource( RES_PHONG_FRAG_GLSL ) );
			
	// Set params
	mParams = params::InterfaceGl( "Parameters", Vec2i( 200, 400 ) );
	mParams.addParam( "Scene Rotation", &gConfigScene.orientation );
	
	gConfigScene.eye = Vec3f(0,0,10);
	
	mParams.addParam( "Bone Rotation", &mTestBoneRot );
	mParams.addParam( "BoneID", &mBoneID);
	mParams.addParam( "Zoom ", &gConfigScene.eye.z, "min=5.0 max=100.0 step=1.0");
	mParams.addParam( "Scale ", &gConfigScene.scale, "min=0.001 max=10.0 step=0.001");
	
	gConfigScene.scale = 0.04;
	
	mShowParams = false;
	mBoneID = mPrevBoneID = -1;
	mDrawFilled = true;
	mDrawNormals = false;
	// OpenGL Constants
	
	gl::enableDepthRead();
	gl::enableDepthWrite();
	
	glEnable(GL_TEXTURE_2D);
	
	cout << getAppPath() + "/../skinning_config.xml" << endl;
	
	XmlTree doc( loadFile(getAppPath() + "/../skinning_config.xml"));
	string fbxpath = doc.getChild("/skinning/fbx").getValue();
		
	pDrawable = mFBXLoader.load(getAppPath() + "/../" + fbxpath.c_str());
	
}
示例#11
0
KCHMNetworkReply::KCHMNetworkReply( const QNetworkRequest &request, const QUrl &url )
{
	setRequest( request );
	setOpenMode( QIODevice::ReadOnly );

	m_data = loadResource( url );
	m_length = m_data.length();

	setHeader( QNetworkRequest::ContentLengthHeader, QByteArray::number(m_data.length()) );
	QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection);

	if ( m_length )
		QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection);

	QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
}
void MapTile::init()
{
    
    image = gl::Texture(loadImage(loadResource(MAP_IMG)));
    
    std::cout << "Image size " << image.getSize() << std::endl;
    
    maporigin.x = cinder::app::getWindowWidth()/2;
    maporigin.y = cinder::app::getWindowHeight()/2;
    
    //my vars
    
    track_mode = MODE_IDLE;
    
    currW = 0;
    
    zoom = 0.5;
    offset_zoom = 0.0;
    
    color = ColorA(0.2,0.3,0.4,0.7);
    
    int pad = getWindowWidth()/5;
    

    
    
    sliders.push_back( Slider( Vec2f(getWindowWidth()*0.1, getWindowHeight()/2) , Vec2f(30, 500),  ColorA(0.9,0.4,0.5,0.5), GEST_EL,  Slider::VERTICAL )  );

    
    hide_all_sliders();
    
    
    timer.start();
    
    
    //init pointers
    ref_pos = cv::Point3f(-1,-1,-1);
    empty_hand = new gestoos::nui::Hand();
    empty_hand2 = new gestoos::nui::Hand();
    empty_hand->clear();
    empty_hand2->clear();
    hand_g = empty_hand;
    hand_slider = empty_hand2;

    //std::cout<<" hand_g present "<<hand_g->is_present()<<std::endl;
    
}
    void PretzelColorPicker::setup(){
        
        bDragging = false;
        
        // load images
        mArrowTex = mGlobal->getTextureFromSkin( Rectf(28, 0, 42, 12) );
        mCrosshairTex = mGlobal->getTextureFromSkin( Rectf(44, 0, 52, 8) );
        
        mHueSurf = ci::Surface( loadImage( loadResource(PRETZEL_HSL_BAR) ) );
        mHueStrip = gl::Texture::create( mHueSurf );
        
        mBoxFbo = gl::Fbo::create(256, 256);
        mBoxShader = gl::GlslProg::create( loadAsset("shaders/colorpicker/colorpicker.vert"), loadAsset("shaders/colorpicker/colorpicker.frag") );
        redrawBox();
        
        // set rects
        mCollapsedRect.set(0, 0, mBounds.getWidth(), 23);
        mExpandedRect.set( 0, 0, mBounds.getWidth(), 23+150);
        
        int boxW = 36, boxH = 19;
        mColorPickRect = Rectf( mBounds.x2 - boxW, 0, mBounds.x2, boxH );
        mColorPickRect.offset( vec2(-10, -1) );
        
        int swatchSize = 150;
        mColorSwatchRect = Rectf(mColorPickRect.x2 - swatchSize, mColorPickRect.y2, mColorPickRect.x2, mColorPickRect.y2 + swatchSize);
        mColorSwatchRect.offset( vec2(-1,1) );
        
        Surface checkerSurf( mColorPickRect.getWidth(), mColorPickRect.getHeight(), false);
        ip::fill(&checkerSurf, Color(1,1,1) );
        
        // draw the checkboard pattern
        gl::color(Color::white());
        gl::drawSolidRect(mColorPickRect);
        for( int k=0; k<mColorPickRect.getHeight(); k+=4){
            int i = ((k/4)%2) * 4;
            for( ; i<mColorPickRect.getWidth(); i+=8){
                Rectf tmp(0,0,4,4);
                tmp.offset( vec2(i, k) );
                ip::fill(&checkerSurf, Color::gray(198.0/255.0), Area(tmp));
            }
        }

        mCheckerPat = gl::Texture::create(checkerSurf);
        
        mCrosshairPos = vec2(1,0);
    }
示例#14
0
 /** Requests a Resource. If it doesn't exist, create with loadResource().
  * @param key used to identify resource
  */
 virtual R* request ( const K& key )
 {
     auto search = _resources.find ( key );
     if ( search == _resources.end() )
     {
         std::pair<R*, uint32_t> c;
         c.first = loadResource ( key );
         c.second = 1;
         _resources.insert ( std::pair<K, std::pair<R*, uint32_t>> ( key, c ) );
         return c.first;
     }
     else
     {
         std::pair<R*, uint32_t> c = search->second;
         ++search->second.second;
         return c.first;
     }
 }
void OpenGLDepthPacketProcessor::loadXTableFromFile(const char* filename)
{
  ChangeCurrentOpenGLContext ctx(impl_->opengl_context_ptr);

  impl_->x_table.allocate(512, 424);
  const unsigned char *data;
  size_t length;

  if(loadResource("xTable.bin", &data, &length))
  {
    std::copy(data, data + length, impl_->x_table.data);
    impl_->x_table.upload();
  }
  else
  {
    LOG_ERROR << "Loading xtable from resource 'xTable.bin' failed!";
  }
}
示例#16
0
void ResourceManager::addManifest(const char *filename)
{
    if (finalized)
        throwError1(HQLERR_ResourceAddAfterFinalManifest, "MANIFEST");
    Owned<IPropertyTree> manifestSrc = createPTreeFromXMLFile(filename);

    StringBuffer dir; 
    splitDirTail(filename, dir);

    ensureManifestInfo();
    Owned<IAttributeIterator> aiter = manifestSrc->getAttributes();
    ForEach (*aiter)
        manifest->setProp(aiter->queryName(), aiter->queryValue());
    Owned<IPropertyTreeIterator> iter = manifestSrc->getElements("*");
    ForEach(*iter)
    {
        IPropertyTree &item = iter->query();
        if (streq(item.queryName(), "Resource") && item.hasProp("@filename"))
        {
            if (!item.hasProp("@type"))
                item.setProp("@type", "UNKNOWN");
            const char *filename = item.queryProp("@filename");
            int id;
            if (getDuplicateResourceId(item.queryProp("@type"), filename, id))
            {
                item.setPropInt("@id", id);
                manifest->addPropTree("Resource", LINK(&item));
            }
            else
            {
                StringBuffer fullpath;
                if (!isAbsolutePath(filename))
                    fullpath.append(dir);
                fullpath.append(filename);

                MemoryBuffer content;
                loadResource(fullpath.str(), content);
                addCompress(item.queryProp("@type"), content.length(), content.toByteArray(), &item);
            }
        }
        else
            manifest->addPropTree(item.queryName(), LINK(&item));
    }
}
void OpenGLDepthPacketProcessor::load11To16LutFromFile(const char* filename)
{
  ChangeCurrentOpenGLContext ctx(impl_->opengl_context_ptr);

  impl_->lut11to16.allocate(2048, 1);

  const unsigned char *data;
  size_t length;

  if(loadResource("11to16.bin", &data, &length))
  {
    std::copy(data, data + length, impl_->lut11to16.data);
    impl_->lut11to16.upload();
  }
  else
  {
    LOG_ERROR << "Loading 11to16 lut from resource '11to16.bin' failed!";
  }
}
示例#18
0
char *System::readSource(const char *fileName) {
  _activeFile.clear();
  char *buffer;
  if (!_mainBas && _editor != NULL && _loadPath.equals(fileName)) {
    buffer = _editor->getTextSelection();
  } else {
    buffer = loadResource(fileName);
    if (!buffer) {
      int h = open(fileName, O_BINARY | O_RDONLY, 0644);
      if (h != -1) {
        struct stat st;
        if (fstat(h, &st) == 0) {
          int len = st.st_size;
          buffer = (char *)malloc(len + 1);
          len = read(h, buffer, len);
          buffer[len] = '\0';
          _modifiedTime = st.st_mtime;
          char fullPath[PATH_MAX + 1];
          char *path = realpath(fileName, fullPath);
          if (path != NULL) {
            // set full path for getModifiedTime()
            _activeFile = fullPath;
          } else {
            _activeFile = fileName;
          }
        }
        close(h);
      }
    }
  }
  if (buffer != NULL) {
    delete [] _programSrc;
    int len = strlen(buffer);
    _programSrc = new char[len + 1];
    strncpy(_programSrc, buffer, len);
    _programSrc[len] = '\0';
    _srcRendered = false;
    systemPrint("Opened: %s %d bytes\n", fileName, len);
  }
  return buffer;
}
void FlashPlayerPlugin::build(NSIS *installer, Version version)
{
    Q_UNUSED(version);

    isError = false;
    download();
    if (!isError) {
        QStringList blockingProcesses(browsers());
        blockingProcesses.removeAll("chrome.exe");
        isError = !installer->build(
                    objectName(),
                    getOutputFile(),
                    NSIS::Zlib,
                    40,
                    blockingProcesses,
                    tempFiles,
                    loadResource(":NSIS/FlashPlayerPlugin/main.nsh")
                    );
    }
    cleanup();
}
void FlashPlayerActiveX::build(NSIS *installer, Version version)
{
    Q_UNUSED(version);

    isError = false;
    download(version);
    if (!isError) {
        installer->build(
                    objectName(),
                    getOutputFile(),
                    NSIS::Zlib,
                    40,
                    QStringList(),
                    tempFiles,
                    loadResource(":NSIS/FlashPlayerActiveX/main.nsh").replace(
                        "${Installer}",
                        QFileInfo(tempFiles.first()).fileName())
                    );
    }
    cleanup();
}
void ImageDecoder::loadGifFromResource(const WCHAR *name, const WCHAR *type, std::vector<AnimatedGifFrame *> &frames)
{
	unsigned char *bytes = NULL;
	DWORD size = 0;
	loadResource(name, type, bytes, size);

	IWICStream *stream = createStreamFromBytes(bytes, size);
	IWICBitmapDecoder *decoder = createDecoderFromStream(stream);

	unsigned int frameCount = 0;
	if (FAILED(decoder->GetFrameCount(&frameCount)))
	{
		throw Exception("could not get gif frame count");
	}

	if (frameCount <= 1)
	{
		throw Exception("not a gif animation");
	}

	for (unsigned int frameIndex = 0; frameIndex < frameCount; frameIndex++)
	{
		IWICBitmapFrameDecode *bitmapFrame = NULL;
		if (FAILED(decoder->GetFrame(frameIndex, &bitmapFrame)))
		{
			throw Exception("could not get frame");
		}

		HBITMAP bitmap = convertFrameToBitmap(bitmapFrame);
		bitmapFrame->Release();

		AnimatedGifFrame *frame = new AnimatedGifFrame(bitmap);
		frames.push_back(frame);

	}

	decoder->Release();
	stream->Release();
}
示例#22
0
	bool AssetManager::loadResourceFolder(const gfs::Path& folder)
	{
		if(!folder)
		{
			Logger::get() << "[ERROR]: Could not read folder: \"" << folder << "\"\n";
			return false;
		}

		gfs::PathContents resources = gfs::contents(folder);
		
		for(auto& p : resources)
		{
			if(p.type() == gfs::Path::Type::Directory)
			{
				loadResourceFolder(p);
			}
			else if(p.type() == gfs::Path::Type::File)
			{
				loadResource(p);
			}
		}

		return true;
	}
示例#23
0
void ResourceManifest::addToArchive(IPropertyTree *archive)
{
    IPropertyTree *additionalFiles = ensurePTree(archive, "AdditionalFiles");

    //xsi namespace required for proper representaion after PTree::setPropBin()
    if (!additionalFiles->hasProp("@xmlns:xsi"))
        additionalFiles->setProp("@xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");

    Owned<IPropertyTreeIterator> resources = manifest->getElements("Resource[@resourcePath]");
    ForEach(*resources)
    {
        IPropertyTree &item = resources->query();
        const char *respath = item.queryProp("@resourcePath");

        VStringBuffer xpath("Resource[@resourcePath='%s']", respath);
        if (!additionalFiles->hasProp(xpath.str()))
        {
            IPropertyTree *resTree = additionalFiles->addPropTree("Resource", createPTree("Resource"));

            const char *filepath = item.queryProp("@originalFilename");
            resTree->setProp("@originalFilename", filepath);
            resTree->setProp("@resourcePath", respath);

            MemoryBuffer content;
            loadResource(filepath, content);
            resTree->setPropBin(NULL, content.length(), content.toByteArray());
        }
    }

    StringBuffer xml;
    toXML(manifest, xml);

    IPropertyTree *manifest = additionalFiles->addPropTree("Manifest", createPTree("Manifest", ipt_none));
    manifest->setProp("@originalFilename", absFilename.str());
    manifest->setProp(NULL, xml.str());
}
示例#24
0
ServerLBA1ModelClass::ServerLBA1ModelClass(entitiesTableStruct* entitiesData, const std::string &bodyPath,
								const std::string &animPath, int entityNum,int bodyNum)
: bodyPtr(NULL), animPtr(NULL), m_currentSpeedX(0), m_currentSpeedY(0), m_currentSpeedZ(0),
	m_animationspeed(1), cumutime(0), rotTablePtr(rotTable)
{

	HQRHandler HQH(Lba1ModelDataPath()+"RESS.HQR");
	unsigned int paletteSize;
	m_paletteRGB = HQH.Load_HQR(0, paletteSize);

	m_animPath = animPath;
	m_softShade = true;
	m_wireFrame = 0;

	m_showSelectedPolygon=false;
	m_showBones=false;
	m_showPoint=false;
	m_showLine=false;
	m_showSphere=false;
	m_showCollisionBox=false;
	m_useAnimSteps=false;

	Points=NULL;
	Elements=NULL;
	entitiesTableEntry* localEntry;

	speed=15;
	angle=0;

	globalAngleX=0;
	globalAngleY=0;
	globalAngleZ=0;

	lightPosition[0]=0;
	lightPosition[1]=40;
	lightPosition[2]=40;

	currentBone=0;

	if(!entitiesData) // no entities data, can't load model...
	{
		LogHandler::getInstance()->LogToFile("No entity data, can not load the model...");
		return;
	}

	localEntry=&(entitiesData->entitiesTable[entityNum]);

	for(int i=0;i<localEntry->numOfBody;i++)
	{
		if(localEntry->bodyList[i].body==bodyNum)
		{
			if(bodyPtr)
				free(bodyPtr);

            filesize = loadResource(bodyPath.c_str(),localEntry->bodyList[i].index,&bodyPtr);

			if(localEntry->bodyList[i].useColBox)
			{
				X1=localEntry->bodyList[i].X1;
				Z1=localEntry->bodyList[i].Z1;
				Y1=localEntry->bodyList[i].Y1;
				X2=localEntry->bodyList[i].X2;
				Z2=localEntry->bodyList[i].Z2;
				Y2=localEntry->bodyList[i].Y2;
			}


            if(*((short int *)bodyPtr) & 0x02)
                useAnim = true;
            else
                useAnim = false;

            LoadModel(bodyPtr);

            currentEntity=entityNum;
			break;
		}
	}

	lastCurrentX =0;
	lastCurrentY =0;
	lastCurrentZ =0;
}
示例#25
0
void MagicTowerLoader::loadGame(const QString& gamePath)
{
	SLGCResourceManager::init();
    loadResource(gamePath+"/res");
    loadPreset(gamePath + "/startup.mtpreset.ini");
}
示例#26
0
void EnemyShip2::init(){
	shipTexture = Texture(loadImage(loadResource(RES_ENEMY2)));
	EnemyShip::init();
}
示例#27
0
/**
 * \class ds::App
 */
App::App(const RootList& roots)
	: mInitializer(getAppPath().generic_string())
	, mShowConsole(false)
	, mEngineSettings()
	, mEngineData(mEngineSettings)
	, mEngine(new_engine(*this, mEngineSettings, mEngineData, roots))
	, mCtrlDown(false)
	, mSecondMouseDown(false)
	, mQKeyEnabled(true)
	, mEscKeyEnabled(true)
	, mArrowKeyCameraStep(mEngineSettings.getFloat("camera:arrow_keys", 0, -1.0f))
	, mArrowKeyCameraControl(mArrowKeyCameraStep > 0.025f)
{
	add_dll_path();

	// Initialize each sprite type with a unique blob handler for network communication.
	mEngine.installSprite(	[](ds::BlobRegistry& r){ds::ui::Sprite::installAsServer(r);},
							[](ds::BlobRegistry& r){ds::ui::Sprite::installAsClient(r);});
	mEngine.installSprite(	[](ds::BlobRegistry& r){ds::ui::Gradient::installAsServer(r);},
							[](ds::BlobRegistry& r){ds::ui::Gradient::installAsClient(r);});
	mEngine.installSprite(	[](ds::BlobRegistry& r){ds::ui::Image::installAsServer(r);},
							[](ds::BlobRegistry& r){ds::ui::Image::installAsClient(r);});
	mEngine.installSprite(	[](ds::BlobRegistry& r){ds::ui::NinePatch::installAsServer(r);},
							[](ds::BlobRegistry& r){ds::ui::NinePatch::installAsClient(r);});
	mEngine.installSprite(	[](ds::BlobRegistry& r){ds::ui::Text::installAsServer(r);},
							[](ds::BlobRegistry& r){ds::ui::Text::installAsClient(r);});
	mEngine.installSprite(	[](ds::BlobRegistry& r){EngineStatsView::installAsServer(r);},
							[](ds::BlobRegistry& r){EngineStatsView::installAsClient(r);});

	// Initialize the engine image generator typess.
	ds::ui::ImageArc::install(mEngine.getImageRegistry());
	ds::ui::ImageFile::install(mEngine.getImageRegistry());
	ds::ui::ImageGlsl::install(mEngine.getImageRegistry());
	ds::ui::ImageResource::install(mEngine.getImageRegistry());

	// Install the framework services
	mEngine.addService(ds::glsl::IMAGE_SERVICE, *(new ds::glsl::ImageService(mEngine)));
	mEngine.addService(ds::MESH_CACHE_SERVICE_NAME, *(new ds::MeshCacheService()));

	if (mArrowKeyCameraControl) {
		// Currently this is necessary for the keyboard commands
		// that change the screen rect. I don't understand things
		// well enough to know why this is a problem or what turning
		// it off could be doing, but everything LOOKS fine.
		mEngine.setToUserCamera();
	}

	// Verify that the application has included the framework resources.
	try {
		ci::DataSourceRef ds = loadResource(RES_ARC_DROPSHADOW);
	} catch (std::exception&) {
		std::cout << "ERROR Failed to load framework resource -- did you include FrameworkResources.rc in your application project?" << std::endl;
	}

	// Run all the statically-created initialization code.
	std::vector<std::function<void(ds::Engine&)>>& startups = get_startups();
	for (auto it=startups.begin(), end=startups.end(); it!=end; ++it) {
		if (*it) (*it)(mEngine);
	}
	startups.clear();
}
/**********************************************************************************

Function Name = SecurityProjectDemoApp::mouseMove

Descriptive Name = Used to detect the mouseMove action and open the infected window.

Function =

    This function is used to detect the mouse move by the user and open up an infected
    window at the position where the mouse moved to. The function also
    performs additional checks to make sure that only a mousemove event is handled. 
    There are some glitches in the cinder mouse down and mouse move detection therefore
    require additional checks to make sure that it was a mouse move and not anything else.

Input =
    
    MouseEvent event - The mouse event that is detected for cinder to call the function.

Output =
   
   Creates the infected window and opens it. 
   Prints debug info also.

******************************************************************************/
void SecurityProjectDemoApp::mouseMove ( MouseEvent event )
{
    // Variable Declaration
    int mouseXDifference ;
    int mouseYDifference ;
    string messageBuffer = "" ;
    ostringstream intToStringConverter ;
    wstring stringTemp ;
    LPCWSTR debugMessage ;

    // In the case that the program has just started set the current mouse position as previous
    if ( previousMouseX == NULL && previousMouseY == NULL && startInitialized )
    {
        previousMouseX = event.getX () ;
        previousMouseY = event.getY () ;
    }
    else
    {
        // Calculate the difference between previous mouse location and current mouse location.
        mouseXDifference = abs ( previousMouseX - event.getX () ) ;
        mouseYDifference = abs ( previousMouseY - event.getY () ) ;

        // Only create the infected windows if it is initialized, the event has not already been handled, there is at least a
        // pixel difference of 5 between mouse y coordinates or mouse x coordinates, the event is not left or right click and the
        // mouseDownX and mouseDownY positions are not the same as the mouse move events.
        if ( startInitialized && event.isHandled () == false && ( mouseYDifference > 10 || mouseXDifference > 10 ) && 
             event.isLeft () == false && event.isRight () == false && mouseDownMouseX != event.getX () && mouseDownMouseY != event.getY ()
           )
        {
            // Increase the mouse move counter to show that this function was called to open up a infection window.
            // This counter will be used to allow not to open too many windows too fast or else can not actually
            // see the windows images as they open. Also the program will crash too fast as there will be a lot of
            // mouse movements. 
            mouseMoveCounter++ ;

            // ------------------------ Start of Debugging Block -----------------------------

            OutputDebugStringW ( L"\n-------------------- START Detecting the mouse moving --------------------\n" ) ;

            // Add all information that is needed into the string stream
            intToStringConverter << "Y--> " << mouseYDifference << "\n" << "X--> " << mouseXDifference << "\n" << "Mouse Move Counter--> " << mouseMoveCounter << "\n" ;

            // Fetch the string equivalence of the input (int or any other data type)
            messageBuffer = intToStringConverter.str () ;

            // Convert the messageBuffer string into wstring for later conversion
            stringTemp = wstring ( messageBuffer.begin (), messageBuffer.end () ) ;

            // Convert wstring to LPCWSTR
            debugMessage = stringTemp.c_str () ;

            OutputDebugStringW ( debugMessage ) ;
            
            OutputDebugStringW ( L"-------------------- END Detecting the mouse moving --------------------\n" );

            // ------------------------ End of Debugging Block -----------------------------

            // Only open the infection window if more then 5 mouseMoves are detected.
            if ( mouseMoveCounter > 5 )
            {
                // Create the infection window for draw function to open later
                createInfectedWindow ( loadResource ( RES_SUPPORTEDGESTURES_IMAGE ),
                                       WINDOW_X_SIZE,
                                       WINDOW_Y_SIZE,
                                       event.getX (),
                                       event.getY ()
                                     ) ;

                // Reset the mouseMove counter to 0 once a single window is opened for every 5 mouse moves.
                mouseMoveCounter = 0 ;
            }

            // Once the single event has been handled mark it as handled to make sure that
            // we avoid handling the same event multiple times.
            event.setHandled ( true );

            // Set the current mouse x and y coordinates as previous for later comparisons
            previousMouseX = event.getX ();
            previousMouseY = event.getY ();
        }
    }
}
示例#29
0
bool LevelLayer::init()
{
	if (!Layer::init())
	{
		return false;
	}

	loadResource();

	Size visibleSize = Director::getInstance()->getVisibleSize();
	Vec2 origin = Director::getInstance()->getVisibleOrigin();
	m_screenWidth = visibleSize.width;
	m_screenHeight = visibleSize.height;

	//背景图片精灵
	auto bgSprite = Sprite::create("pic/levelSelect.png");
	bgSprite->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2));
	this->addChild(bgSprite);

	//返回图片
	auto back = Sprite::create("pic/back.png");
	back->setPosition(40, 40);
	back->setScale(0.5f);
	back->setTag(100);
	this->addChild(back);

	m_successLevel = LevelUtils::readLevelFromFile();

	//显示8个关卡
	std::string imagepath = "";
	for (int i = 0; i < 8; i++) {
		//i小于读到关卡数,说明当前关卡已经通关
		if (i < m_successLevel) {
			imagepath = "pic/level.png";
			//加入卡通关卡数字
			std::string str = StringUtils::format("%d", i + 1);
			auto num = Label::createWithSystemFont(str, "Arial", 40, Size(70, 70), TextHAlignment::CENTER);
			// 一排放4个关卡图标,所以i % 4
			float x = 100 + i % 4 * 300;
			float y = m_screenHeight - 180 - i / 4 * 150;
			num->setPosition(x, y);
			this->addChild(num, 2);
		}
		else {  //加锁的关卡图片
			imagepath = "pic/lock.png";
		}

		auto level = Sprite::create(imagepath);
		// 设置关卡精灵
		level->setTag(i + 1);
		// 设置每一个关卡图片一定的距离
		float x = 100 + i % 4 * 300;
		float y = m_screenHeight - 180 - i / 4 * 150;
		level->setPosition(x, y);
		level->setScale(0.5f);
		this->addChild(level, 1);
	}

	addTouchListener();

	return true;
}
示例#30
0
gep::IResource* gep::CollisionMeshFileLoader::loadResource(IResource* pInPlace)
{
    return loadResource(dynamic_cast<CollisionMesh*>(pInPlace));
}