blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 5
146
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
7
| license_type
stringclasses 2
values | repo_name
stringlengths 6
79
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 4
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.07k
426M
โ | star_events_count
int64 0
27
| fork_events_count
int64 0
12
| gha_license_id
stringclasses 3
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 6
values | src_encoding
stringclasses 26
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 1
class | length_bytes
int64 20
6.28M
| extension
stringclasses 20
values | content
stringlengths 20
6.28M
| authors
listlengths 1
16
| author_lines
listlengths 1
16
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8f30e1a3acb7874e1673bab0da3cb590ebe1e422 | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /Engine/sdk/inc/cuilist.h | 7c55713b4e2c87ed29a1ef97af800cb3580e4490 | []
| no_license | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,244 | h | //-------------------------------------------------------------------
//
// MODULE : CUIList.H
//
// PURPOSE : defines the CUIList bridge class
//
// CREATED : 1/01
//
// COPYRIGHT : (C) 2001 LithTech Inc
//
//-------------------------------------------------------------------
#ifndef __CUILIST_H__
#define __CUILIST_H__
#ifndef __CUIWIDGET_H__
#include "cuiwidget.h"
#endif
#ifndef __CUIFONT_H__
#include "cuifont.h"
#endif
/*!
CUIList class. This class is uses a collection of CUIPolyStrings to display a
list of text items over a background.
CUIE_BG
\see class CUIPolyString
Used for: Text and UI. */
class CUIList : public CUIWidget
{
public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// CUIWidgets should not be created with new and delete, but should instead
// be created via the ILTWindowManager's CreateWidget() and DestroyWidget()
// management functions.
CUIList();
CUIList(CUIGUID guid);
virtual ~CUIList();
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
/*!
\return current font
Use this function to retrieve the address of the CUIFont which is being used
by the CUIList widget.
Used for: Text and UI. */
virtual CUIFont* GetFont();
/*!
\param pFont address of font to set
Use this function to set the CUIFont used by the CUIList widget.
Used for: Text and UI. */
virtual CUI_RESULTTYPE SetFont(CUIFont* pFont);
/*!
\param height height of text
Use this function to set the height of text items displayed by the CUIList
widget.
Used for: Text and UI. */
virtual CUI_RESULTTYPE SetCharHeight(uint8 height);
/*!
\param pText text item to add
\param index (optional) position at which to add the new item.
Use this function to add a text item to the CUIList widget. If \e index
is \b -1, the item will be added at the end of the list. If \e index is
greater than the number of items currently in the list, the new item will
be added at the end.
Used for: Text and UI. */
virtual CUI_RESULTTYPE AddItem(const char* pText, int32 index = -1);
/*!
\param index index of item to remove
Use this function to remove a list item. \e Index is a zero-based (i.e., the
first item is index zero).
Used for: Text and UI. */
virtual CUI_RESULTTYPE RemoveItem(int32 index);
/*!
\param pText text item to find
Use this function to locate a text item in the list. The entire string is
matched and the match is case sensitive.
\return index of the matching item, or -1 if the search item does not exist
in the list.
Used for: Text and UI. */
virtual int32 FindItem(const char* pText);
/*!
\param index item to retrieve
Use this function to retrieve the text of an item in the list.
\return item text
Used for: Text and UI. */
virtual const char* GetItem(int32 index);
/*!
\param index index of the item to select
Use this function to set the current selection in the list. Only one item can
be selected at a time.
Used for: Text and UI. */
virtual CUI_RESULTTYPE SetSelection(int32 index);
/*!
Use this function to get the current selection in the list. Only one item can
be selected at a time.
\return index of the currently selected item.
Used for: Text and UI. */
virtual int32 GetSelection();
/*!
Use this function to get the total number of items in the list.
\return number of items
Used for: Text and UI. */
virtual uint32 GetItemCount();
/*!
\param x horizontal coordinate to test
\param y vertical coordinate to test
Use this function to test whether a point on the screen is within list items.
\return index of the item containing specified coords. or -1 if \e x and \e y
do not lie inside an item's bounding box.
Used for: Text and UI. */
virtual int32 QueryPoint(float x, float y);
/*!
\param number number of lines to scroll
Use this function to scroll the list up (\e number is negative) or down
(\e number is positive). You cannot scroll past the beginning or the end
of the list.
Used for: Text and UI. */
virtual CUI_RESULTTYPE Scroll(int32 number);
};
#endif //__CUILIST_H__
| [
"[email protected]"
]
| [
[
[
1,
172
]
]
]
|
fde2f06c0adac2d27f26e3ef18372fb710cd407e | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/_Interface/WndGuildWarRequest.cpp | 562a54d805d1d29bae0917796852d5a8fabfb135 | []
| no_license | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UHC | C++ | false | false | 2,762 | cpp | #include "stdafx.h"
#include "ResData.h"
#include "DefineText.h"
#include "WndGuildWarRequest.h"
#include "dpclient.h"
extern CDPClient g_DPlay;
/****************************************************
WndId : APP_GUILD_WARREQUEST - ๊ธธ๋์ ์์ฒญ์ฐฝ
CtrlId : WIDC_EDIT1 -
CtrlId : WIDC_YES - Button
CtrlId : WIDC_NO - No
****************************************************/
CWndGuildWarRequest::CWndGuildWarRequest()
{
m_idEnemyGuild = 0;
}
CWndGuildWarRequest::~CWndGuildWarRequest()
{
m_idEnemyGuild = 0;
}
void CWndGuildWarRequest::OnDraw( C2DRender* p2DRender )
{
}
void CWndGuildWarRequest::OnInitialUpdate()
{
CWndNeuz::OnInitialUpdate();
// ์ฌ๊ธฐ์ ์ฝ๋ฉํ์ธ์
CGuild *pEnemyGuild = g_GuildMng.GetGuild( m_idEnemyGuild );
if( pEnemyGuild )
{
CWndEdit *pWndEdit = (CWndEdit *)GetDlgItem( WIDC_EDIT1 );
CString strText;
strText.Format( prj.GetText( TID_GAME_GUILDWARREQUEST ), pEnemyGuild->m_szGuild, m_szMaster );
pWndEdit->SetString( strText );
pWndEdit->EnableWindow( FALSE );
}
// ์๋๋ฅผ ์ค์์ผ๋ก ์ฎ๊ธฐ๋ ๋ถ๋ถ.
CRect rectRoot = m_pWndRoot->GetLayoutRect();
CRect rectWindow = GetWindowRect();
CPoint point( rectRoot.right - rectWindow.Width(), 110 );
Move( point );
MoveParentCenter();
}
// ์ฒ์ ์ด ํจ์๋ฅผ ๋ถ๋ฅด๋ฉด ์๋๊ฐ ์ด๋ฆฐ๋ค.
BOOL CWndGuildWarRequest::Initialize( CWndBase* pWndParent, DWORD /*dwWndId*/ )
{
// Daisy์์ ์ค์ ํ ๋ฆฌ์์ค๋ก ์๋๋ฅผ ์ฐ๋ค.
return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_GUILD_WARREQUEST, 0, CPoint( 0, 0 ), pWndParent );
}
/*
์ง์ ์๋๋ฅผ ์ด๋ ์ฌ์ฉ
BOOL CWndGuildWarRequest::Initialize( CWndBase* pWndParent, DWORD dwWndId )
{
CRect rectWindow = m_pWndRoot->GetWindowRect();
CRect rect( 50 ,50, 300, 300 );
SetTitle( _T( "title" ) );
return CWndNeuz::Create( WBS_THICKFRAME | WBS_MOVE | WBS_SOUND | WBS_CAPTION, rect, pWndParent, dwWndId );
}
*/
BOOL CWndGuildWarRequest::OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase )
{
return CWndNeuz::OnCommand( nID, dwMessage, pWndBase );
}
void CWndGuildWarRequest::OnSize( UINT nType, int cx, int cy ) \
{
CWndNeuz::OnSize( nType, cx, cy );
}
void CWndGuildWarRequest::OnLButtonUp( UINT nFlags, CPoint point )
{
}
void CWndGuildWarRequest::OnLButtonDown( UINT nFlags, CPoint point )
{
}
BOOL CWndGuildWarRequest::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult )
{
switch( nID )
{
case WIDC_YES:
// ์ ์์ ์๋ฝํจ.
g_DPlay.SendAcptWar( g_pPlayer->m_idPlayer, m_idEnemyGuild );
Destroy();
break;
case WIDC_NO:
Destroy();
break;
}
return CWndNeuz::OnChildNotify( message, nID, pLResult );
}
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
96
]
]
]
|
d48148b5ca6c4cdb3affe26b1c79215f636d9033 | 9eb5d41a47af0c543595f07a04461894ca343ae5 | /PPMouseFollower.h | 56b3b7fe7bc6cf1e767fe79b74aa99b4a3a2cb7b | []
| no_license | saturn1mc/picpix | 394ffd2f97d87ef0f8c2bd37fde778fef24b809a | def3dad1e71457dcddb9686bb6d332ff6ab95465 | refs/heads/master | 2020-06-06T22:52:03.785867 | 2011-05-30T17:01:29 | 2011-05-30T17:01:29 | 33,185,931 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,026 | h | #ifndef PP_MOUSE_FOLLOWER_H
#define PP_MOUSE_FOLLOWER_H
#include "PPBot.h"
class PPMouseFollower : public PPBot{
private:
PPMouseFollower(const PPMouseFollower&) {}
protected:
virtual void updatePersonalSpace(void){
_personalSpace->clear();
(*_personalSpace) << QPointF((*_position) + ((*_side) * _radius * 10.0).toPointF() - ((*_forward) * _radius * 2.0).toPointF());
(*_personalSpace) << QPointF((*_position) - ((*_side) * _radius * 10.0).toPointF() - ((*_forward) * _radius * 2.0).toPointF());
(*_personalSpace) << QPointF((*_position) - ((*_side) * _radius * 10.0).toPointF() + ((*_forward) * _radius * 20.0).toPointF());
(*_personalSpace) << QPointF((*_position) + ((*_side) * _radius * 10.0).toPointF() + ((*_forward) * _radius * 20.0).toPointF());
}
public:
PPMouseFollower(void) : PPBot() {}
virtual void setMousePosition(const QPoint& pos){
setTarget(pos);
}
virtual void draw(QPainter* painter) const{
PPBot::draw(painter);
}
};
#endif //PP_MOUSE_FOLLOWER_H | [
"[email protected]@fac5e847-8771-6dee-5d94-998d05010f92"
]
| [
[
[
1,
31
]
]
]
|
e6a02457d1e23a96dabd1c3b95d01afa7539cf2e | ad33a51b7d45d8bf1aa900022564495bc08e0096 | /DES/DES_GOBSTG/Header/Process.h | 8dc35f3ea9f5accfb66466586982e0bbc63862d5 | []
| no_license | CBE7F1F65/e20671a6add96e9aa3551d07edee6bd4 | 31aff43df2571d334672929c88dfd41315a4098a | f33d52bbb59dfb758b24c0651449322ecd1b56b7 | refs/heads/master | 2016-09-11T02:42:42.116248 | 2011-09-26T04:30:32 | 2011-09-26T04:30:32 | 32,192,691 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,708 | h | #ifndef _PROCESS_H
#define _PROCESS_H
#include "Main.h"
#include "Export.h"
#include "Const.h"
#include "ProcessDefine.h"
#include "../../../src/hge/HGEExport.h"
class Process
{
public:
Process();
~Process();
void Release();
bool reload();
int getInput();
char getInputNowChar(bool wide);
int processStart();
int processPause();
int processContinue();
int processClear();
int processEnding();
int processTitle();
int processMatchSelect();
int processPlayerSelect();
int processSceneSelect();
int processOver();
int processSpell();
int processReplay();
int processResult();
int processOption();
int processMusic();
int processInit();
int processPreInitial();
int frame();
int render();
void _Render(BYTE renderflag=M_RENDER_NULL);
void _RenderTar();
int renderInit();
void startPrep(bool callinit = true);
void clearPrep(bool bclearkey = true);
void frameStart();
void frameEnd();
void playSE(const char * sample_name,int pan = 0);
void musicChange(int ID=-1, bool force = false);
void musicSlide(float slidetime, int tovol = 0, int pan = -101, float pitch = -1);
void SnapShot();
void SetShake(BYTE playerindex, BYTE round, bool force=false);
void WorldShake();
void SyncInput();
void SetState(int state, int time = 0);
void SetScene(BYTE scene);
void SetReturnValue(int retval);
void SetInputSwap();
void SetLastMatchChara(BYTE playerindex, WORD ID, WORD ID_sub_1=0xffff, WORD ID_sub_2=0xffff);
int AccessIP();
bool SetLatency(int latency);
void SetMatchMode(BYTE mode);
BYTE GetMatchMode();
bool IsInGame();
void SetStop(DWORD stopflag, int stoptime);
DWORD GetStopFlag(int index=-1);
void ClearAll();
bool LoadTextureSet(int texset=-1);
bool FreeTextureSet(int texset=-1);
public:
union{
struct{
int keyUp;
int keyDown;
int keyLeft;
int keyRight;
int keyFire;
int keyQuick;
int keySlow;
int keyDrain;
int keyPause;
int keySkip;
int keyEnter;
int keyEscape;
int keyCapture;
} keyKS[M_PL_MATCHMAXPLAYER];
int keyKey[M_PL_MATCHMAXPLAYER][13];
};
union{
struct{
int joyFire;
int joyQuick;
int joySlow;
int joyDrain;
int joyPause;
int debug_joySpeedUp;
} keyJS[M_PL_MATCHMAXPLAYER];
int joyKey[M_PL_MATCHMAXPLAYER][6];
};
//texture
hgeTextureInfo texinfo[TEXMAX];
//read ini
char username[M_PL_MATCHMAXPLAYER][RPYINFO_USERNAMEMAX];
int screenmode;
int turnoffflag;
int bgmvol;
int sevol;
int lastmatchchara[M_PL_MATCHMAXPLAYER][M_PL_ONESETPLAYER];
//replay
char rpyfilename[M_PATHMAX];
DWORD seed;
int framecounter;
int frameskip;
int renderskip;
bool replaymode;
bool replayend;
//playtime
LONGLONG playtimeStart;
bool playing;
//music
HSTREAM stream;
HCHANNEL channel;
int musicID;
hgeChannelSyncInfo channelsyncinfo;
//shake
int worldshaketimer[M_PL_MATCHMAXPLAYER];
BYTE worldshakeround[M_PL_MATCHMAXPLAYER];
float worldx[M_PL_MATCHMAXPLAYER];
float worldy[M_PL_MATCHMAXPLAYER];
float worldz[M_PL_MATCHMAXPLAYER];
//main
int lasttime;
int alltime;
bool active;
DWORD stopflag[FRAME_STOPINFOMAX];
int stoptimer[FRAME_STOPINFOMAX];
int retvalue;
//pause return
bool pauseinit;
//Replayinfo
float replayFPS;
//error
int errorcode;
//indicator
BYTE titleselect;
BYTE state;
BYTE scene;
//Init
HTEXTURE texInit;
//
int latency;
BYTE matchmode;
//
/* HTARGET rendertar[M_PL_MATCHMAXPLAYER];*/
hgeSprite * sprendertar[M_PL_MATCHMAXPLAYER];
static Process mp;
};
#endif | [
"CBE7F1F65@b503aa94-de59-8b24-8582-4b2cb17628fa"
]
| [
[
[
1,
188
]
]
]
|
36ba04a73e47eb34f763faff66c77366f0339e90 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/os/cellularsrv/IsvTelephonyTest/inc/IsvTelephonyTestMessageHandler.h | 059a11a5f45c27bb142bba4e4308c4e825ee5f7d | []
| no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,627 | h | /*
* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
#ifndef ISVTELEPHONYTESTMESSAGEHANDLER_H
#define ISVTELEPHONYTESTMESSAGEHANDLER_H
// INCLUDES
#include <e32base.h>
// CONSTANTS
// Message max length, currently limited by Stif logger and Ui
const TInt KMessageHandlerMaxMessageSize = 254;
// CLASS DECLARATION
/**
* Interface for log/UI message printing.
*
* @lib
* @since
*/
class MIsvTelephonyTestMessageHandler
{
public:
/**
* Enumeration for log/UI output selection
*/
enum TMessageOption
{
EMessagesOff = 0,
EMessagesLog,
EMessagesUi,
EMessagesLogAndUi
};
public:
/**
* Pure virtual functions
*/
/**
* Outputs messages to Stif UI or log
* @param aMessage Contains the message
*/
virtual void PrintMessage( const TDesC& aMessage ) = 0;
/**
* Outputs messages to Stif UI or log
* @param aMessage Contains the message
*/
virtual void PrintMessage( TRefByValue<const TDesC> aMessage,... ) = 0;
};
#endif // ISVTELEPHONYTESTMESSAGEHANDLER_H
// End of File
| [
"none@none"
]
| [
[
[
1,
72
]
]
]
|
61ee0ed417311f3d029dd6d812afcc94d8832a30 | f25e9e8fd224f81cefd6d900f6ce64ce77abb0ae | /Exercises/OpenGL6/DDEngine/windowManager.h | cac4b89c6e7dd82991be27a6b9e390c3a65a3d73 | []
| no_license | giacomof/gameengines2010itu | 8407be66d1aff07866d3574a03804f2f5bcdfab1 | bc664529a429394fe5743d5a76a3d3bf5395546b | refs/heads/master | 2016-09-06T05:02:13.209432 | 2010-12-12T22:18:19 | 2010-12-12T22:18:19 | 35,165,366 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,459 | h | #ifdef __DDEngine
# define WindowManager_D __declspec(dllexport)
#else
# define WindowManager_D __declspec(dllimport)
#endif
#ifndef WindowManager__H__
#define WindowManager__H__
#include <SDL.h> // Header File for the SDL library
#include <SDL_opengl.h> // Header File for OpenGL through SDL
class WindowManager_D WindowManager
{
public:
int screenWidth; // Window Width
int screenHeight; // Window Height
int screenColorDepth; // Color Depth
int isActive; // is the window Active?
int videoFlags; // property of the window
SDL_Surface * surface; // Pointer to SDL rendering surface
const SDL_VideoInfo *videoInfo; // information retrieved from pc hardware
// Singleton Definitions
static WindowManager _instance;
WindowManager(void) { &getInstance(); };
~WindowManager(void) {};
WindowManager(const WindowManager & getInstance());
WindowManager & operator=(WindowManager & getInstance());
static WindowManager & getInstance();
void WindowManager::createWindow(int w, int h, int b);
int WindowManager::resizeWindow(int width, int height);
void WindowManager::setActive(int a);
int WindowManager::getActive(void);
void WindowManager::setTitle(const char * t, const char * i);
SDL_Surface * WindowManager::setVideoMode(int w, int h, int b, Uint32 f);
Uint32 WindowManager::getVideoFlags(void);
SDL_Surface * WindowManager::getSurface(void);
};
#endif | [
"[email protected]@1a5f623d-5e27-cfcb-749e-01bf3eb0ad9d",
"[email protected]@1a5f623d-5e27-cfcb-749e-01bf3eb0ad9d"
]
| [
[
[
1,
6
],
[
9,
16
],
[
25,
25
],
[
28,
42
],
[
44,
47
]
],
[
[
7,
8
],
[
17,
24
],
[
26,
27
],
[
43,
43
]
]
]
|
190292f3cbd7d7485d6246ef7fbc0bc0af3ecfb8 | 2112057af069a78e75adfd244a3f5b224fbab321 | /branches/refactor/src_root/include/ireon_client/Ogre/paging_landscape/OgrePagingLandScapeData2DManager.h | c2b53ec80efa118b72da8ff885b98dd961b18c1e | []
| no_license | blockspacer/ireon | 120bde79e39fb107c961697985a1fe4cb309bd81 | a89fa30b369a0b21661c992da2c4ec1087aac312 | refs/heads/master | 2023-04-15T00:22:02.905112 | 2010-01-07T20:31:07 | 2010-01-07T20:31:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,747 | h | /***************************************************************************
OgrePagingLandScapeData2DManager.h - description
-------------------
begin : Mon Jun 16 2003
copyright : (C) 2003-2005 by Jose A. Milan and Tuan Kuranes
email : [email protected] && [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
***************************************************************************/
#ifndef PAGINGLANDSCAPEDATA2DMANAGER_H
#define PAGINGLANDSCAPEDATA2DMANAGER_H
#include "OgrePagingLandScapePrerequisites.h"
#include "OgreSingleton.h"
namespace Ogre
{
class _OgrePagingLandScapeExport PagingLandScapeData2DManager : public Singleton< PagingLandScapeData2DManager >
{
public:
PagingLandScapeData2DManager( void );
~PagingLandScapeData2DManager( void );
void load( void );
void clear( void );
void WorldDimensionChange( void );
void reset( void );
PagingLandScapeData2D* allocateData2D( ) const;
bool load( const uint dataX, const uint dataZ );
void unload( const uint dataX, const uint dataZ );
bool isLoaded( const uint dataX, const uint dataZ ) const;
const Real getHeight( const uint dataX, const uint dataZ, const Real x, const Real z ) const;
const Real getHeight( const uint dataX, const uint dataZ, const uint x, const uint z ) const;
const Real getHeightAtPage( const uint dataX, const uint dataZ, const Real x, const Real z ) const;
const Real getHeightAtPage( const uint dataX, const uint dataZ, const int x, const int z) const;
bool DeformHeight( const Vector3& deformationPoint, const Real modificationHeight, const PagingLandScapeTileInfo* info );
// bool addNewHeight( const Sphere newSphere );
//
// bool removeNewHeight( const Sphere oldSphere );
//This function will return the max possible value of height base on the current 2D Data implementation
const Real getMaxHeight( const uint x, const uint z ) const;
const Real getMaxHeight( void ) const;
/** Get the real world height at a particular position
@remarks
Method is used to get the terrain height at a world position based on x and z.
This method just figures out what page the position is on and then asks the page node
to do the dirty work of getting the height.
@par
the Real returned is the real world height based on the scale of the world. If the height could
not be determined then -1 is returned and this would only occur if the page was not preloaded or loaded
@param x x world position
@param z z world position
*/
const Real getRealWorldHeight( const Real x, const Real z ) const;
const Real getRealWorldHeight( const Real x, const Real z, const PagingLandScapeTileInfo* info ) const;
const Real getWorldHeight(const Real x, const Real z) const;
const Real getRealPageHeight( const Real x, const Real z, const uint pageX, const uint pageZ, const uint Lod ) const;
const ColourValue getCoverageAt( const uint dataX, const uint dataZ, const Real x, const Real z );
const ColourValue getBaseAt( const uint dataX, const uint dataZ, const Real x, const Real z );
const Real getShadowAt( const uint dataX, const uint dataZ, const uint x, const uint z, const bool& positive );
const Vector3 getNormalAt( const uint dataX, const uint dataZ, const uint x, const uint z, bool upperTri = false ) const;
const Vector3 getNormal( Real x, Real z ) const;
void getTriInfo( Real x, Real z, uint& ix, uint& iz, bool& upper ) const;
PagingLandScapeData2D* getData2d( const uint x, const uint z );
void setPageManager( void );
static PagingLandScapeData2DManager& getSingleton( void );
static PagingLandScapeData2DManager* getSingletonPtr( void );
void registerDataType(PagingLandScapeData2D* source)
{
mData2DTypeMap.push_back(source);
// LogManager::getSingleton().logMessage(
// "PagingLandScape: Registered a new Data2DType for "
// "type " + typeName);
}
protected:
PagingLandScapeOptions* mOptions;
uint mData2DType;
String mData2DFormat;
uint mWidth;
uint mHeight;
Real mMaxHeight;
PagingLandScapeData2DPages mData2D;
PagingLandScapePageManager* mPageManager;
/// Map of Data2d source type
PagingLandScapeData2DMap mData2DTypeMap;
/// The currently active page Data2d source
PagingLandScapeData2D* mActiveData2DType;
};
} //namespace
#endif
| [
"[email protected]"
]
| [
[
[
1,
135
]
]
]
|
9f177bc12e0c0039da895131afc4e5e50c9a561d | b67d58bd5bfe13b32bebe83dec22904243a52223 | /FlashDBSimDll_Sample/LRUWSRManager.h | bc73076eefbb033812472d5e1d49cfebd7f8aa36 | []
| no_license | maheshdharhari/flash-sim | b8929efc83a65ee6d5e782b835106ca36228c6c8 | d04eb0e34bb44e7356f5c1b0e1f1af6097339225 | refs/heads/master | 2021-01-10T07:48:37.820361 | 2010-05-22T09:19:20 | 2010-05-22T09:19:20 | 43,440,579 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,023 | h | #ifndef _LRUWSR_BUFFER_MANAGER_H_
#define _LRUWSR_BUFFER_MANAGER_H_
#pragma managed(push, off)
#include <memory>
#include <list>
#include <hash_map>
#include "BufferManagerBase.h"
class LRUWSRManager : public BufferManagerBase
{
public:
LRUWSRManager(std::tr1::shared_ptr<class IBlockDevice> pDevice, size_t nPages, size_t maxCold = 1);
virtual ~LRUWSRManager();
protected:
virtual void DoRead(size_t pageid, void *result);
virtual void DoWrite(size_t pageid, const void *data);
virtual void DoFlush();
private:
std::tr1::shared_ptr<struct LRUWSRFrame> AccessFrame_(size_t pageid);
std::tr1::shared_ptr<struct LRUWSRFrame> AcquireFrame_(size_t pageid);
void AcquireSlot_();
void WriteIfDirty(std::tr1::shared_ptr<struct LRUWSRFrame> pFrame);
private:
size_t maxcold_;
typedef std::list<std::tr1::shared_ptr<struct LRUWSRFrame> > QueueType;
typedef stdext::hash_map<size_t, QueueType::iterator> MapType;
QueueType queue_;
MapType map_;
};
#pragma managed(pop)
#endif | [
"lvyanfeihappy@9895585c-9ddb-11de-bf4a-bd5be0e2b6d7",
"hiYoungCat@9895585c-9ddb-11de-bf4a-bd5be0e2b6d7",
"hiyoungcat@9895585c-9ddb-11de-bf4a-bd5be0e2b6d7"
]
| [
[
[
1,
2
],
[
4,
5
],
[
8,
9
],
[
11,
12
],
[
15,
16
],
[
19,
21
],
[
34,
35
],
[
37,
37
]
],
[
[
3,
3
],
[
6,
7
],
[
10,
10
],
[
13,
14
],
[
22,
33
],
[
36,
36
]
],
[
[
17,
18
]
]
]
|
7be89dc7702c5f35f8d0f585d8b005e3e5f5d4f6 | bef7d0477a5cac485b4b3921a718394d5c2cf700 | /nanobots/src/demo/DemoUI.h | e67cfd5a15c68e813e059285b4f68bfc18050728 | [
"MIT"
]
| permissive | TomLeeLive/aras-p-dingus | ed91127790a604e0813cd4704acba742d3485400 | 22ef90c2bf01afd53c0b5b045f4dd0b59fe83009 | refs/heads/master | 2023-04-19T20:45:14.410448 | 2011-10-04T10:51:13 | 2011-10-04T10:51:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,210 | h | #ifndef __DEMO_UI_H
#define __DEMO_UI_H
#include <dingus/dxutils/D3DSettings.h>
#include <dingus/gfx/gui/Gui.h>
#include "DemoResources.h"
// --------------------------------------------------------------------------
class CDemoSettingsDialog : public CAbstractD3DSettingsDialog {
public:
enum eDlgState { STATE_ACTIVE, STATE_OK, STATE_CANCEL };
public:
CDemoSettingsDialog( const CD3DEnumeration& enumeration, const CD3DSettings& settings );
~CDemoSettingsDialog();
void showDialog( const CD3DSettings& settings );
void hideDialog() { mState = STATE_CANCEL; }
CUIDialog& getDialog() { return *mDlg; }
eDlgState getState() const { return mState; }
const SAppSettings& getAppSettings() const { return mAppSettings; }
SAppSettings& getAppSettings() { return mAppSettings; }
static void CALLBACK dialogCallback( UINT evt, int ctrlID, CUIControl* ctrl );
protected:
virtual void enableWindow( int id, bool enabled );
virtual void checkButton( int id, bool checked );
virtual bool isChecked( int id );
virtual void comboBoxAdd( int id, const void* pData, const TCHAR* pstrDesc );
virtual void comboBoxSelect( int id, const void* pData );
virtual const void* comboBoxSelected( int id );
virtual bool comboBoxSomethingSelected( int id );
virtual int comboBoxCount( int id );
virtual void comboBoxSelectIndex( int id, int index );
virtual void comboBoxClear( int id );
virtual bool comboBoxContainsText( int id, const TCHAR* pstrText );
private:
static CDemoSettingsDialog* mSingleInstance;
SAppSettings mAppSettings;
CUIDialog* mDlg;
eDlgState mState;
};
// --------------------------------------------------------------------------
class CDemoHelpDialog : public boost::noncopyable {
public:
CDemoHelpDialog();
~CDemoHelpDialog();
void showDialog();
void hideDialog() { mActive = false; }
CUIDialog& getDialog() { return *mDlg; }
bool isActive() const { return mActive; }
static void CALLBACK dialogCallback( UINT evt, int ctrlID, CUIControl* ctrl );
private:
static CDemoHelpDialog* mSingleInstance;
CUIDialog* mDlg;
bool mActive;
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
77
]
]
]
|
b7c41ddde9fd56cc751c325b2104f1bc0aea24b4 | 0b66a94448cb545504692eafa3a32f435cdf92fa | /tags/0.7/cbear.berlios.de/meta/if.hpp | c8bf39ca2e13f40d433e4ba0b8db0dbd8f9b2029 | [
"MIT"
]
| permissive | BackupTheBerlios/cbear-svn | e6629dfa5175776fbc41510e2f46ff4ff4280f08 | 0109296039b505d71dc215a0b256f73b1a60b3af | refs/heads/master | 2021-03-12T22:51:43.491728 | 2007-09-28T01:13:48 | 2007-09-28T01:13:48 | 40,608,034 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,239 | hpp | #ifndef CBEAR_BERLIOS_DE_META_IF_HPP_INCLUDED
#define CBEAR_BERLIOS_DE_META_IF_HPP_INCLUDED
namespace cbear_berlios_de
{
namespace meta
{
namespace detail
{
class no_else;
}
template<bool C, class T = void, class E = detail::no_else>
class if_c;
namespace detail
{
template<bool C, class T>
class if_c
{
public:
typedef if_c o;
template<bool C1, class T1 = void, class E1 = no_else>
class else_if_c:
public meta::if_c<C || C1, typename meta::if_c<C, T, T1>::type, E1>
{
};
template<class C1, class T1 = void, class E1 = no_else>
class else_if: public else_if_c<C1::value, T1, E1> {};
template<class E>
class else_: public meta::if_c<C, T, E> {};
};
}
template<class T, class E>
class if_c<false, T, E>
{
public:
typedef E type;
};
template<class T, class E>
class if_c<true, T, E>
{
public:
typedef T type;
};
template<class T>
class if_c<false, T, detail::no_else>: public detail::if_c<false, T>
{
};
template<class T>
class if_c<true, T, detail::no_else>: public detail::if_c<true, T>
{
public:
typedef T type;
};
template<class C, class T = void, class E = detail::no_else>
class if_: public if_c<C::value, T, E> {};
}
}
#endif
| [
"sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838"
]
| [
[
[
1,
75
]
]
]
|
7ee7c185609df4299432c918af3eb84ce95b91ba | 031009bf00a8d7cd564e0f768ff3649907bd5b65 | /TorrentBuild_CPPFunctions.cpp | a8bb5dc3442ce690611986b4ab619fd71fd08849 | []
| no_license | usertex/autov | 237ab3b655be2dffcb7292cd212fe2b6d95907a7 | b470a96072484afe73ab0ae6ab7096970e34d973 | refs/heads/master | 2020-04-19T02:45:34.548955 | 2006-07-03T01:37:24 | 2006-07-03T01:37:24 | 67,372,523 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,685 | cpp | //---------------------------------------------------------------------------
//
// Name: TorrentBuild_CPPFunctions.cpp
// Author: Harold Feit
// Created: 5/19/2006 11:09:52 AM
// Description:
//
//---------------------------------------------------------------------------
#include "atom.h"
#include "bencode.h"
#include "util.h"
#include "stringsplit.h"
#include "SHA1.h"
#include "TorrentBuild_CPPFunctions.h"
#include <cstdlib>
#include <iostream>
#include <fstream>
__int64 FileSize(const char* sFileName)
{
std::ifstream f;
f.open(sFileName, std::ios_base::binary | std::ios_base::in);
if (!f.good() || f.eof() || !f.is_open()) { return 0; }
f.seekg(0, std::ios_base::beg);
std::ifstream::pos_type begin_pos = f.tellg();
f.seekg(0, std::ios_base::end);
return static_cast<int>(f.tellg() - begin_pos);
}
int GetAutoPieceSize ( unsigned long TotalSize )
{
int64 fiftymeg = 50*1024*1024;
int64 onefiftymeg = 150*1024*1024;
int64 threefiftymeg = 350*1024*1024;
int64 halfgig = 512*1024*1024;
int64 onegig = 1024*1024*1024;
int64 twogig = 2048*1024*1024;
if( TotalSize < fiftymeg )
return ( 32768 );
else if ( TotalSize < onefiftymeg )
return ( 65536 );
else if ( TotalSize < threefiftymeg )
return ( 131072 );
else if ( TotalSize < halfgig )
return ( 262144 );
else if ( TotalSize < onegig )
return ( 524288 );
else if ( TotalSize < twogig )
return ( 1048576 );
else
return ( 2097152 );
}
CAtom *GetConfig()
{
return DecodeFile( "tgen.configure" );
}
| [
"[email protected]"
]
| [
[
[
1,
64
]
]
]
|
b719795a2e3efa0f21b9538d4ae33aa1c554b913 | 1033609e705e0b432f8a0760d32befa92c2b9cb5 | /trunk/svncvsrunner.cpp | 4e3cb2797c179a7b283ace7f35281a3c93591cd3 | []
| no_license | BackupTheBerlios/cb-svn-svn | 5b89c2c5445cf7a51575cf08c0eaaf832074b266 | 6b512f58bbb56fbc186ca26d5c934e1fe83173af | refs/heads/master | 2020-04-02T00:14:00.063607 | 2005-10-26T13:52:08 | 2005-10-26T13:52:08 | 40,614,579 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,874 | cpp | /*
* This file is part of the Code::Blocks SVN Plugin
* Copyright (C) 2005 Thomas Denk
*
* This program is licensed under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* $HeadURL$
* $Id$
*/
#include "toolrunner.h"
#include "svncvsrunner.h"
#include "svn.h"
#include "log.h"
#include "dialogs.h"
#include <wx/regex.h>
extern const wxEventType EVT_WX_SUCKS;
int SVNRunner::Run(wxString cmd)
{
wxString ia(" --non-interactive ");
wxString force;
if(subcommand.IsSameAs("add") || subcommand.IsSameAs("cleanup") || subcommand.IsSameAs("info")
|| subcommand.IsSameAs("resolved") || subcommand.IsSameAs("revert"))
ia = "";
if(do_force)
{
do_force = false;
force = " --force";
}
cmd.Replace("\\", "/");
Manager::Get()->GetAppWindow()->SetStatusText("svn " +cmd);
wxString runCmd(cmd);
if(username > "" && password > "")
{
runCmd << "--username" << Q(username) << "--password" << Q(password) << ia << force;
username = password = "";
}
else
runCmd << ia << force;
ToolRunner::Run(runCmd);
if(lastExitCode == 0)
return false;
return lastExitCode;
}
void SVNRunner::OutputHandler()
{
Manager::Get()->GetAppWindow()->SetStatusText("");
if(blob.Contains("Connection is read-only"))
{
Log::Instance()->Red("Subversion returned 'Connection is read-only'.");
Log::Instance()->Add(" This means you either provided no authentication tokens at all (try 'Set User...'), \n"
" or you are correctly logged in but do not have write access enabled (check conf/svnserve.conf).");
Fail();
return;
}
// Transmitting file data .svn: Commit failed (details follow):
// svn: Cannot verify lock on path '/base.cpp'; no matching lock-token available
if(blob.Contains("no matching lock-token available"))
{
Log::Instance()->Red("Someone else is holding a lock which prevents you from committing your changes.");
EmptyQueue();
Info(GetTarget(), false);
Send(RUN_NEXT_IN_QUEUE);
}
wxRegEx reg("Authentication realm|password", wxRE_ICASE);
if(reg.Matches(blob))
{
PasswordDialog p(Manager::Get()->GetAppWindow());
p.Centre();
if(p.ShowModal() == wxID_CANCEL || p.username == "")
{
Log::Instance()->Add("User cancelled authentication.");
return ;
}
username = p.username;
password = p.password;
std_err.Empty();
if(lastCommand.Contains("--username"))
lastCommand = lastCommand.Left(lastCommand.Index("--username"));
lastCommand << " --username " << p.username << " --password \"" << p.password;
Send(RUN_AGAIN);
return;
}
if(remoteStatusHandler)
{
remoteStatusHandler = false;
RemoteStatusHandler();
}
ToolRunner::OutputHandler();
}
void SVNRunner::RemoteStatusHandler()
{
// L some_dir # svn left a lock in the .svn area of some_dir
//M bar.c # the content in bar.c has local modifications
//M *bar.c # the content in bar.c has local and remote modifications
// M baz.c # baz.c has property but no content modifications
//X 3rd_party # dir is part of an externals definition
//? foo.o # svn doesn't manage foo.o
//! some_dir # svn manages this, but it's missing or incomplete
//~ qux # versioned as file/dir/link, but type has changed
//I .screenrc # svn doesn't manage this, and is set to ignore it
//A + moved_dir # added with history of where it came from
//M + moved_dir/README # added with history and has local modifications
//D stuff/fish.c # file is scheduled for deletion
//A stuff/loot/bloo.h # file is scheduled for addition
//C stuff/loot/lump.c # file has textual conflicts from an update
// C stuff/loot/glub.c # file has property conflicts from an update
//R xyz.c # file is scheduled for replacement
// S stuff/squawk # file or dir has been switched to a branch
// K dog.jpg # file is locked locally; lock-token present
// O cat.jpg # file is locked in the repository by other user
// B bird.jpg # file is locked locally, but lock has been broken
// T fish.jpg # file is locked locally, but lock has been stolen
bool need_update = 0;
int conflict = 0;
int broken = 0;
int stolen = 0;
int locked = 0;
for(unsigned int i = 0; i < std_out.Count(); ++i)
{
if(std_out[i][(size_t)7] == '*')
need_update = true;
if(std_out[i][(size_t)5] == 'C')
++conflict;
if(std_out[i][(size_t)5] == 'B')
++broken;
if(std_out[i][(size_t)5] == 'T')
++stolen;
if(std_out[i][(size_t)5] == 'O' && ( std_out[i][(size_t)0] == 'M' || std_out[i][(size_t)0] == 'D'))
++locked;
}
if(need_update)
{
wxBell();
InsertFirst();
Implicit();
Update(GetTarget());
return;
}
}
int SVNRunner::Status(const wxString& selected, bool minusU)
{
SetTarget(selected);
if(minusU)
{
SetCommand("status");
Run("status" + Q(selected) + " -u");
return 0;
}
return RunBlocking("status" + Q(selected));
}
int SVNRunner::Revert(const wxString& selected)
{
SetTarget(selected);
SetCommand("revert");
return Run("revert" + Q(selected));
}
int SVNRunner::Move(const wxString& selected, const wxString& to)
{
SetTarget(selected);
return RunBlocking("move" + Q(selected) + Q(to) );
}
int SVNRunner::Add(const wxString& selected)
{
SetTarget(selected);
return RunBlocking("add" + Q(selected));
}
int SVNRunner::Delete(const wxString& selected)
{
SetTarget(selected);
return Run("delete" + Q(selected));
}
int SVNRunner::Checkout(const wxString& repo, const wxString& dir, const wxString& revision, bool noExternals)
{
SetTarget(dir);
SetCommand("checkout");
return Run("checkout" + Q(repo) + Q(dir) + "-r " + revision + (noExternals ? " --ignore-externals" : ""));
}
int SVNRunner::Import(const wxString& repo, const wxString& dir, const wxString &message)
{
SetTarget(dir);
SetCommand("import");
TempFile c(message);
return Run("import" + Q(dir) + Q(repo) + "-F" + Q(c.name));
}
int SVNRunner::Update(const wxString& selected, const wxString& revision)
{
SetTarget(selected);
SetCommand("update");
return Run("update" + Q(selected) + "-r " + revision);
}
int SVNRunner::Commit(const wxString& selected, const wxString& message, bool safeCast)
{
TempFile c(message);
SetTarget(selected);
SetCommand("commit");
if(safeCast)
{
EnableRemoteStatusHandler();
Status(selected, true);
}
return Run("commit" + Q(selected) + "-F" + Q(c.name));
}
int SVNRunner::Lock(const wxString& selected, bool force)
{
SetTarget(selected);
SetCommand("lock");
return Run("lock" + Q(selected) + (force ? " --force" : ""));
}
int SVNRunner::UnLock(const wxString& selected, bool force)
{
SetTarget(selected);
SetCommand("unlock");
return Run("unlock" + Q(selected) + (force ? " --force" : ""));
}
wxArrayString SVNRunner::GetPropertyList(const wxString& selected)
{
SetTarget(selected);
wxArrayString ret;
RunBlocking("proplist" + Q(selected));
int n = std_out.Count();
for(int i = 0; i < n; ++i)
if(std_out[i].StartsWith(" "))
ret.Add(std_out[i].Mid(2));
return ret;
}
wxString SVNRunner::PropGet(const wxString& selected, const wxString& prop)
{
SetTarget(selected);
RunBlocking("propget" + Q(prop) + Q(selected));
return out;
}
int SVNRunner::PropSet(const wxString& selected, const wxString& prop, const wxString& value, bool recursive)
{
SetTarget(selected);
SetCommand("propset");
TempFile t(value);
return Run("propset" + Q(prop) + "-F" + Q(t.name) + Q(selected) + (recursive ? "-R" : ""));
}
int SVNRunner::PropDel(const wxString& selected, const wxString& prop)
{
SetTarget(selected);
SetCommand("propdel");
return Run("propdel" + Q(prop) + Q(selected));
}
wxString SVNRunner::Diff(const wxString& selected, const wxString& rev)
{
SetTarget(selected);
SetCommand("diff");
if(rev.IsEmpty())
Run("diff" + Q(selected));
else
Run("diff" + Q(selected) + "-r" +Q(rev) );
return out;
}
int SVNRunner::Info(const wxString& selected, bool minusR)
{
SetTarget(selected);
SetCommand("info");
return Run("info" + Q(selected) + (minusR ? "-R" : ""));
}
int SVNRunner::Resolved(const wxString& selected)
{
SetTarget(selected);
SetCommand("resolved");
return Run("resolved" + Q(selected));
}
void SVNRunner::Export(const wxString& src, const wxString& dest, const wxString& rev, const wxString why)
{
assert(!src.IsSameAs(dest));
SetTarget(src + "*" + dest);
SetCommand(wxString("export:") + why);
Run("export" + Q(src) + Q(dest) + "-r" +Q(rev));
}
void SVNRunner::ExportToTemp(const wxString& src, const wxString& rev, const wxString why)
{
TempFile dest("");
SetTarget(src + "*" + dest.name);
SetCommand(wxString("export:") + why);
Run("export" + Q(src) + Q(dest.name) + "-r" +Q(rev));
}
| [
"thomasdenk@96b225bb-4cfa-0310-88f5-88b948d20ad7"
]
| [
[
[
1,
351
]
]
]
|
604eec15572edaf640a5aabc2dbebb15f7b50b05 | 5fb9b06a4bf002fc851502717a020362b7d9d042 | /developertools/GumpEditor/entity/GumpEdit.cpp | 5857c5fa002d9cbe9051eabda60443eb9490f975 | []
| no_license | bravesoftdz/iris-svn | 8f30b28773cf55ecf8951b982370854536d78870 | c03438fcf59d9c788f6cb66b6cb9cf7235fbcbd4 | refs/heads/master | 2021-12-05T18:32:54.525624 | 2006-08-21T13:10:54 | 2006-08-21T13:10:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,828 | cpp | #include "stdafx.h"
#include "GumpEditor.h"
#include "GumpEditorDoc.h"
#include "GumpEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGumpEdit
CGumpEdit::CGumpEdit(int hueId, int fontId, TEXT_ALIGN textAlign, bool passwordMode)
: CGumpStatic(hueId, fontId, textAlign)
, m_passwordMode(passwordMode)
{
SetMinimumSize( CSize( 1, 1 ) );
SetTitle( "edit" );
SetType( "edit" );
//SetName( "edit" );
SetDefaultEntityName();
m_eEventType = ONCHANGE;
AddPropertyPage( &m_page );
}
CGumpEntity* CGumpEdit::Clone()
{
CGumpEdit* obj = new CGumpEdit(GetHueId(), GetFontId(), GetTextAlign(), IsPasswordMode());
obj->Copy( this );
return obj;
}
void CGumpEdit::Draw( CDC* dc, CRect rect )
{
CString strText = GetTitle();
if (m_passwordMode) SetTitle(CString('*', strText.GetLength()));
CGumpStatic::Draw(dc,rect);
if (m_passwordMode) SetTitle(strText);
}
CGumpEntity* CGumpEdit::CreateFromNode( XML::Node* node )
{
CGumpEdit* obj = new CGumpEdit;
if (!obj->FromString( node ))
{
delete obj;
obj = NULL;
}
return obj;
}
BOOL CGumpEdit::FromString( XML::Node* node )
{
if (!CGumpStatic::FromString(node)) return FALSE;
int password=0;
XML::Node* passwd_node = node->findNode("password");
if (passwd_node) {
password = passwd_node->asBool();
}
m_passwordMode = (bool)password;
return TRUE;
}
CString CGumpEdit::GetString(BOOL bBegin) const
{
CString ret, str;
if (bBegin) {
ret += CGumpStatic::GetString(TRUE) + "\n";
str.Format(" <password>%d</password>", IsPasswordMode());
ret += str;
} else {
ret += CGumpStatic::GetString(FALSE);
}
return ret;
}
| [
"sience@a725d9c3-d2eb-0310-b856-fa980ef11a19"
]
| [
[
[
1,
89
]
]
]
|
1bb1b633626a5950c10c06e44b8483f4f24a2691 | 5ac13fa1746046451f1989b5b8734f40d6445322 | /minimangalore/Nebula2/code/mangalore/msg/playvisualeffect.cc | 57207106d3a95fcd2181fb99c0b511b8ad0c567d | []
| no_license | moltenguy1/minimangalore | 9f2edf7901e7392490cc22486a7cf13c1790008d | 4d849672a6f25d8e441245d374b6bde4b59cbd48 | refs/heads/master | 2020-04-23T08:57:16.492734 | 2009-08-01T09:13:33 | 2009-08-01T09:13:33 | 35,933,330 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 444 | cc | //------------------------------------------------------------------------------
// msg/playvisualeffect.cc
// (C) 2005 Radon Labs GmbH
//------------------------------------------------------------------------------
#include "msg/playvisualeffect.h"
namespace Message
{
ImplementRtti(Message::PlayVisualEffect, Message::Msg);
ImplementFactory(Message::PlayVisualEffect);
ImplementMsgId(PlayVisualEffect);
} // namespace Message
| [
"BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c"
]
| [
[
[
1,
12
]
]
]
|
1f073c7b96d0e2402e780bcd94233b381c64c3b1 | b8fbe9079ce8996e739b476d226e73d4ec8e255c | /src/engine/rb_physics/jforcecontrol.cpp | cf8caf157ba7fb3b40b76fbec8779f9014c53d59 | []
| no_license | dtbinh/rush | 4294f84de1b6e6cc286aaa1dd48cf12b12a467d0 | ad75072777438c564ccaa29af43e2a9fd2c51266 | refs/heads/master | 2021-01-15T17:14:48.417847 | 2011-06-16T17:41:20 | 2011-06-16T17:41:20 | 41,476,633 | 1 | 0 | null | 2015-08-27T09:03:44 | 2015-08-27T09:03:44 | null | UTF-8 | C++ | false | false | 2,281 | cpp | /***********************************************************************************/
// File: JForceControl.cpp
// Date: 25.08.2005
// Author: Ruslan Shestopalyuk
/***********************************************************************************/
#include "stdafx.h"
#include "JForceControl.h"
#include "IPhysicsServer.h"
#include "OdeUtil.h"
#include "JModelInstance.h"
/***********************************************************************************/
/* JForceControl implementation
/***********************************************************************************/
decl_class(JForceControl);
JForceControl::JForceControl()
{
m_PhysObjInstID = -1;
m_Magnitude = 1.0f;
m_JumpImpulse = 10.0f;
} // JForceControl::JForceControl
JForceControl::~JForceControl()
{
} // JForceControl::~JForceControl
void JForceControl::Init()
{
}
void JForceControl::Render()
{
JAnimation::Render();
float dt = GetContext().m_TimeDelta;
if (dt == 0.0f) return;
Vec3 force = Vec3::null;
Mat4 viewTM = g_pRenderServer->GetViewTM();
Vec3 dir( viewTM.e02, viewTM.e12, viewTM.e22 );
dir.z = 0.0f;
dir.normalize();
Vec3 right( -dir.y, dir.x, 0.0f );
Vec3 up( 0.0f, 0.0f, 1.0f );
if (GetKeyState( 'W' ) < 0)
{
force += dir;
}
if (GetKeyState( 'S' ) < 0)
{
force -= dir;
}
if (GetKeyState( 'A' ) < 0)
{
force -= right;
}
if (GetKeyState( 'D' ) < 0)
{
force += right;
}
if (GetKeyState( ' ' ) < 0)
{
force += up*m_JumpImpulse;
}
force *= m_Magnitude*dt;
g_pPhysicsServer->SetObjectForce( m_PhysObjInstID, force );
}
void JForceControl::OnPlay()
{
if (!m_pModelInst || m_PhysObjInstID == -1)
{
m_pModelInst = g_pObjectServer->FindObject<JModelInstance>( m_ModelInstance.c_str(), this );
if (!m_pModelInst)
{
return;
}
m_pModelInst->ResInit();
int modelInstID = m_pModelInst->GetInstanceID();
m_PhysObjInstID = g_pPhysicsServer->GetObjectID( modelInstID );
}
}
void JForceControl::OnStop()
{
}
void JForceControl::DrawBounds()
{
}
| [
"[email protected]"
]
| [
[
[
1,
95
]
]
]
|
14638171f17b02c9848901ff6ad2b27fb1d26cc2 | a6a5c29ab75e58093e813afc951f08222001c38d | /TCC/game/Item.cpp | 2811623b6fb089c0a2ee3330392cafb9e8cf5a85 | []
| no_license | voidribeiro/jogoshadow | b066bc75cc24c0f50b6243f91d91e286c0d997c7 | 946a4648ac420cb8988267f69c42688a0bc5ba6f | refs/heads/master | 2016-09-05T23:42:09.869743 | 2010-02-25T12:17:06 | 2010-02-25T12:17:06 | 32,122,243 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 917 | cpp | #include "Item.h"
Item::Item(){
}
Item::Item(string _name, bool _modelIsVisible, bool _isInPlayerPosession)
:name(_name), modelIsVisible(_modelIsVisible), imageIsVisible(false), isInPlayerPosession(_isInPlayerPosession){
}
Item::~Item(){
}
void Item::addDescription(const string description){
descriptionList.push_back(description);
}
string Item::getDescription(const int idx){
list<string>::iterator it;
it = descriptionList.begin();
if(descriptionList.size() <= idx)
it = descriptionList.end();
else
for(int i=0 ; i < idx; i++)
it++;
return (*it);
}
void Item::drawImage(int posX, int posY){
if (!imageIsVisible)
return;
irr::video::IVideoDriver* driver = DeviceManager::GetDriver();
driver->draw2DImage(TextureManager::GetTexture(imageName),
core::position2d<s32>(posX, posY)
);
} | [
"suisen.no.ryuu@17fd7b7e-20b4-11de-a108-cd2f117ce590"
]
| [
[
[
1,
41
]
]
]
|
d6c47b7e3151db4640f0b39fc940ce5af8c89f5a | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/ipappprotocols/sip/sipcodec/src/t_csipeventheader.cpp | 9695dc68d5048385bf13742c8cb6ffd48d69954d | []
| no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,559 | cpp | /*
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
// This contains CT_DataSIPToHeader
#include "t_csipeventheader.h"
#include "T_SIPUtil.h"
#include <utf.h>
#include <s32file.h>
// Epoc Includes
/*@{*/
_LIT(KCmdNewL, "NewL");
_LIT(KCmdNewLC, "NewLC");
_LIT(KCmdDisown, "Disown");
_LIT(KCmdDecoderL, "DecodeL");
_LIT(KCmdInternalizeValueL, "InternalizeValueL");
_LIT(KCmdEventPackage, "EventPackage");
_LIT(KCmdEventTemplates, "EventTemplates");
_LIT(KCmdSetEventPackageL, "SetEventPackageL");
_LIT(KCmdSetEventTemplatesL, "SetEventTemplatesL");
_LIT(KCmdCompare, "==");
_LIT(KDestructor, "~");
_LIT(KFldSIPEventHeader, "eventheader");
_LIT(KFldValue, "value");
_LIT(KFldEventPackage, "eventpackage");
_LIT(KFldEventTemplates, "eventtemplates");
_LIT(KFldExpected, "expected");
_LIT(KFldFileName, "filename");
_LIT(KLogError, "Error=%d");
_LIT(KLogMissingParameter, "Missing parameter '%S'");
_LIT(KLogNotExpectedValue, "Not expected value, actual=%d, expect=%d");
CT_DataSIPEventHeader* CT_DataSIPEventHeader::NewL()
{
CT_DataSIPEventHeader* ret=new (ELeave) CT_DataSIPEventHeader();
CleanupStack::PushL(ret);
ret->ConstructL();
CleanupStack::Pop(ret);
return ret;
}
CT_DataSIPEventHeader::CT_DataSIPEventHeader():CT_DataSIPParameterHeaderBase(),
iSIPEventHeader(NULL), iIsOwner(ETrue)
{
}
void CT_DataSIPEventHeader::ConstructL()
{
}
CT_DataSIPEventHeader::~CT_DataSIPEventHeader()
{
DestroyData();
}
/**
* Return a pointer to the object that the data wraps
*
* @return pointer to the object that the data wraps
*/
TAny* CT_DataSIPEventHeader::GetObject()
{
return iSIPEventHeader;
}
void CT_DataSIPEventHeader::SetObjectL(TAny* aAny)
{
iSIPEventHeader=static_cast<CSIPEventHeader*> (aAny);
}
void CT_DataSIPEventHeader::DisownObjectL()
{
iSIPEventHeader=NULL;
iIsOwner = EFalse;
}
void CT_DataSIPEventHeader::DestroyData()
{
if (iIsOwner)
{
delete iSIPEventHeader;
iSIPEventHeader = NULL;
iIsOwner = EFalse;
}
}
CSIPHeaderBase* CT_DataSIPEventHeader::GetSIPHeaderBase() const
{
return iSIPEventHeader;
}
/**
Delegates the commands to a function
* @internalComponent
* @param aCommand Current command
* @param aSection Current ini file command section
* @param aAsyncErrorIndex index of command for SetAsyncError()
* @return TBool Returns whether the command was executed or not
*/
TBool CT_DataSIPEventHeader::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
{
TBool retVal = ETrue;
if( aCommand == KDestructor )
{
DestroyData();
}
else if( aCommand == KCmdNewL )
{
DoCmdNewL(aSection);
}
else if( aCommand == KCmdNewLC )
{
DoCmdNewLC(aSection);
}
else if( aCommand == KCmdDecoderL )
{
DoCmdDecodeL(aSection);
}
else if( aCommand == KCmdInternalizeValueL )
{
DoCmdInternalizeValueL(aSection);
}
else if( aCommand == KCmdEventPackage)
{
DoCmdEventPackage(aSection);
}
else if( aCommand == KCmdEventTemplates)
{
DoCmdEventTemplates(aSection);
}
else if( aCommand == KCmdSetEventPackageL)
{
DoCmdSetEventPackageL(aSection);
}
else if( aCommand == KCmdSetEventTemplatesL)
{
DoCmdSetEventTemplatesL(aSection);
}
else if( aCommand == KCmdCompare)
{
DoCmdCompare(aSection);
}
else if( aCommand == KCmdDisown )
{
DisownObjectL();
}
else
{
retVal = CT_DataSIPParameterHeaderBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
}
return retVal;
}
void CT_DataSIPEventHeader::DoCmdNewL(const TTEFSectionName& aSection)
{
delete iSIPEventHeader;
iSIPEventHeader = NULL;
TPtrC str;
if(!GetStringFromConfig(aSection, KFldEventPackage, str))
{
ERR_PRINTF2(KLogMissingParameter, &KFldEventPackage());
SetBlockResult(EFail);
return;
}
TBuf8<KMaxTestExecuteCommandLength> eventPackage;
CnvUtfConverter::ConvertFromUnicodeToUtf8(eventPackage, str);
INFO_PRINTF1(_L("call CSIPEventHeader::NewL(const TDesC8 &)"));
TRAPD(err, iSIPEventHeader = CSIPEventHeader::NewL(eventPackage));
if(KErrNone != err)
{
ERR_PRINTF2(KLogError, err);
SetError(err);
}
}
void CT_DataSIPEventHeader::DoCmdNewLC(const TTEFSectionName& aSection)
{
delete iSIPEventHeader;
iSIPEventHeader = NULL;
TPtrC str;
if(!GetStringFromConfig(aSection, KFldEventPackage, str))
{
ERR_PRINTF2(KLogMissingParameter, &KFldEventPackage());
SetBlockResult(EFail);
return;
}
TBuf8<KMaxTestExecuteCommandLength> eventPackage;
CnvUtfConverter::ConvertFromUnicodeToUtf8(eventPackage, str);
INFO_PRINTF1(_L("call CSIPEventHeader::NewLC(const TDesC8 &)"));
TRAPD(err, iSIPEventHeader = CSIPEventHeader::NewLC(eventPackage); CleanupStack::Pop(iSIPEventHeader));
if(KErrNone != err)
{
ERR_PRINTF2(KLogError, err);
SetError(err);
}
}
void CT_DataSIPEventHeader::DoCmdDecodeL(const TTEFSectionName& aSection)
{
delete iSIPEventHeader;
iSIPEventHeader = NULL;
TPtrC str;
if(!GetStringFromConfig(aSection, KFldValue, str))
{
ERR_PRINTF2(KLogMissingParameter, &KFldValue());
SetBlockResult(EFail);
return;
}
TBuf8<KMaxTestExecuteCommandLength> value;
CnvUtfConverter::ConvertFromUnicodeToUtf8(value, str);
INFO_PRINTF1(_L("call CSIPEventHeader::DecodeL(const TDesC8 &)"));
TRAPD(err, iSIPEventHeader = CSIPEventHeader::DecodeL(value));
if(KErrNone != err)
{
ERR_PRINTF2(KLogError, err);
SetError(err);
}
}
void CT_DataSIPEventHeader::DoCmdInternalizeValueL(const TTEFSectionName& aSection)
{
delete iSIPEventHeader;
iSIPEventHeader = NULL;
TPtrC datFileName;
if( !GetStringFromConfig(aSection, KFldFileName, datFileName) )
{
ERR_PRINTF2(KLogMissingParameter, &KFldFileName);
SetBlockResult(EFail);
}
else
{
CDirectFileStore* readstore = CDirectFileStore::OpenL(FileServer(), datFileName, EFileStream | EFileRead);
CleanupStack::PushL(readstore);
TStreamId headerid = readstore->Root();
RStoreReadStream readstrm;
readstrm.OpenL(*readstore, headerid);
CleanupClosePushL(readstrm);
INFO_PRINTF1(_L("call CSIPEventHeader::InternalizeValueL(RReadStream &)"));
TRAPD(err, iSIPEventHeader = (CSIPEventHeader*)CSIPEventHeader::InternalizeValueL(readstrm));
if(KErrNone != err)
{
ERR_PRINTF2(KLogError, err);
SetError(err);
}
CleanupStack::PopAndDestroy(2);
}
}
void CT_DataSIPEventHeader::DoCmdEventPackage(const TTEFSectionName& aSection)
{
INFO_PRINTF1(_L("call CSIPEventHeader::EventPackageL()"));
const TDesC8& eventPackage = iSIPEventHeader->EventPackage();
TBuf<KMaxTestExecuteCommandLength> str;
CnvUtfConverter::ConvertToUnicodeFromUtf8(str, eventPackage);
INFO_PRINTF2(_L("The actual event package is: %S "), &str);
TPtrC expected;
if(GetStringFromConfig(aSection, KFldExpected, expected))
{
if(expected != str)
{
ERR_PRINTF2(_L("The expected event package is: %S"), &expected);
SetBlockResult(EFail);
}
}
}
void CT_DataSIPEventHeader::DoCmdSetEventPackageL(const TTEFSectionName& aSection)
{
TPtrC str;
if(!GetStringFromConfig(aSection, KFldEventPackage, str))
{
ERR_PRINTF2(KLogMissingParameter, &KFldEventPackage());
SetBlockResult(EFail);
return;
}
TBuf8<KMaxTestExecuteCommandLength> eventPackage;
CnvUtfConverter::ConvertFromUnicodeToUtf8(eventPackage, str);
INFO_PRINTF1(_L("call CSIPEventHeader::SetEventPackageL(const TDesC8 &)"));
TRAPD(err, iSIPEventHeader->SetEventPackageL(eventPackage));
if(KErrNone != err)
{
ERR_PRINTF2(KLogError, err);
SetError(err);
}
}
void CT_DataSIPEventHeader::DoCmdEventTemplates(const TTEFSectionName& aSection)
{
INFO_PRINTF1(_L("call CSIPEventHeader::SetEventPackageL(const TDesC8 &)"));
const CDesC8Array& eventTemplates = (const CDesC8Array&)iSIPEventHeader->EventTemplates();
CDesC8ArraySeg* expecedValues = new (ELeave) CDesC8ArraySeg(1);
TBool checkExpectedValues = CT_SIPUtil::GetMDesC8ArrayL(*this, aSection, KFldExpected, (MDesC8Array*)expecedValues);
for(TInt i=0; i < eventTemplates.Count(); i++)
{
TBuf<KMaxTestExecuteCommandLength> templates;
CnvUtfConverter::ConvertToUnicodeFromUtf8(templates, eventTemplates[i]);
INFO_PRINTF3(_L("The event template[%d]: %S"), i, &templates);
if(checkExpectedValues && i <expecedValues->Count())
{
if(eventTemplates[i].Compare((*expecedValues)[i]) != 0)
{
CnvUtfConverter::ConvertToUnicodeFromUtf8(templates, (*expecedValues)[i]);
ERR_PRINTF3(_L("Expected event template[%d]: %S"), i, &templates);
SetBlockResult(EFail);
}
}
}
}
void CT_DataSIPEventHeader::DoCmdSetEventTemplatesL(const TTEFSectionName& aSection)
{
CDesC8ArraySeg* array = new (ELeave) CDesC8ArraySeg(1);
CleanupStack::PushL(array);
if(CT_SIPUtil::GetMDesC8ArrayL(*this, aSection, KFldEventTemplates, (MDesC8Array*)array))
{
INFO_PRINTF1(_L("call CSIPEventHeader::SetEventTemplatesL(const MDesC8Array &)"));
TRAPD(err, iSIPEventHeader->SetEventTemplatesL(*array));
if(err != KErrNone)
{
ERR_PRINTF2(KLogError, err);
SetError(err);
}
}
else
{
ERR_PRINTF2(KLogMissingParameter, &KFldEventTemplates());
SetBlockResult(EFail);
}
CleanupStack::PopAndDestroy(1);
}
void CT_DataSIPEventHeader::DoCmdCompare(const TTEFSectionName& aSection)
{
CSIPEventHeader* eventHeader = NULL;
if( !CT_SIPUtil::GetSIPEventHeaderL(*this, aSection, KFldSIPEventHeader, eventHeader) )
{
ERR_PRINTF2(KLogMissingParameter, &KFldSIPEventHeader());
SetBlockResult(EFail);
}
else
{
INFO_PRINTF1(_L("call CSIPEventHeader::==(const CSIPEventHeader&)"));
TBool ret = (*iSIPEventHeader == *eventHeader);
TBool expected;
if( GetBoolFromConfig(aSection, KFldExpected, expected) )
{
if(!ret != !expected)
{
ERR_PRINTF3(KLogNotExpectedValue, (TInt)ret, (TInt)expected);
SetBlockResult(EFail);
}
}
}
}
void CT_DataSIPEventHeader::SetIsOwner(TBool aOwner)
{
iIsOwner = aOwner;
}
| [
"none@none"
]
| [
[
[
1,
402
]
]
]
|
dd4540337956acbf4012ee775fd7cea9886a8b5b | d1dc408f6b65c4e5209041b62cd32fb5083fe140 | /src/player/cPlayer.h | 0511d71961ac65c300d07345c81d032fee11e2ac | []
| no_license | dmitrygerasimuk/dune2themaker-fossfriendly | 7b4bed2dfb2b42590e4b72bd34bb0f37f6c81e37 | 89a6920b216f3964241eeab7cf1a631e1e63f110 | refs/heads/master | 2020-03-12T03:23:40.821001 | 2011-02-19T12:01:30 | 2011-02-19T12:01:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,033 | h | /*
Dune II - The Maker
Author : Stefan Hendriks
Contact: [email protected]
Website: http://dune2themaker.fundynamic.com
2001 - 2011 (c) code by Stefan Hendriks
A player has a sidebar. The sidebar contains lists of items that can be built. These
items can be structures/units but also special weapons, etc.
In order to build items, a player has an itemBuilder.
A player can upgrade the sidebar lists. Therefore a cBuildingListUpgrader is used.
The state of upgrades is held by a cPlayerUpgradeState object.
*/
#ifndef PLAYER_H
#define PLAYER_H
class cPlayer {
public:
cPlayer();
~cPlayer();
PALETTE pal; // each player has its own 256 color scheme (used for coloring units)
void init();
int iTeam;
int use_power;
int has_power;
float credits; // the credits this player has
float max_credits; // max credits a player can have (influenced by silo's)
int focus_cell; // this is the cell that will be showed in the game centralized upon map loading
int iPrimaryBuilding[MAX_STRUCTURETYPES]; // remember the primary ID (structure id) of each structure type
int iStructures[MAX_STRUCTURETYPES]; // remember what is built for each type of structure
bool bEnoughPower();
int TIMER_think; // timer for thinking itself (calling main routine)
int TIMER_attack; // -1 = determine if its ok to attack, > 0 is , decrease timer, 0 = attack
// set
void setItemBuilder(cItemBuilder *theItemBuilder);
void setSideBar(cSideBar *theSideBar);
void setBuildingListUpdater(cBuildingListUpdater *theBuildingListUpgrader);
void setTechLevel(int theTechLevel) { techLevel = theTechLevel; }
void setHouse(int iHouse);
void setId(int theId);
void setStructurePlacer(cStructurePlacer *theStructurePlacer);
void setUpgradeBuilder(cUpgradeBuilder *theUpgradeBuilder);
void setOrderProcesser(cOrderProcesser *theOrderProcesser);
void setGameControlsContext(cGameControlsContext *theGameControlsContext);
// get
cBuildingListUpdater *getBuildingListUpdater() { return buildingListUpdater; }
cPlayerDifficultySettings *getDifficultySettings() { return difficultySettings; }
cItemBuilder *getItemBuilder() { return itemBuilder; }
cSideBar *getSideBar() { return sidebar; }
int getHouse() { return house; }
int getTechLevel() { return techLevel; }
int getId() { return id; }
cStructurePlacer * getStructurePlacer() { return structurePlacer; }
cUpgradeBuilder * getUpgradeBuilder() { return upgradeBuilder; }
cOrderProcesser * getOrderProcesser() { return orderProcesser; }
cGameControlsContext * getGameControlsContext() { return gameControlsContext; }
int getMinimapColor() { return minimapColor; }
int getAmountOfStructuresForType(int structureType);
// delete
void deleteSideBar() { if (sidebar) delete sidebar; }
private:
int getRGBColorForHouse(int houseId);
// TODO: in the end this should be redundant.. perhaps remove it now/soon anyway?
// TODO: redundant? OBSELETE. Since we're getting more properties for units and thereby
// can/should create units specific for houses.
cPlayerDifficultySettings *difficultySettings;
// these have all state, and need to be recreated for each mission.
cSideBar * sidebar; // each player has a sidebar (lists of what it can build)
cItemBuilder * itemBuilder; // each player can build items
cUpgradeBuilder * upgradeBuilder; // each player can upgrade lists
cBuildingListUpdater * buildingListUpdater; // modifies list of sidebar on upgrades
cStructurePlacer * structurePlacer; // used to place structures and handle updates in sidebar accordingly
cOrderProcesser * orderProcesser; // process orders for starport
cGameControlsContext * gameControlsContext;
int techLevel; // technology level
int house;
int minimapColor; // color of this team on minimap;
int id; // this id is the reference to the player array
};
#endif
| [
"stefanhen83@52bf4e17-6a1c-0410-83a1-9b5866916151"
]
| [
[
[
1,
109
]
]
]
|
5df5f41f4201b61d8483b017c0ddcc9402a697ea | cc97070bb192c613fae05f301713a9ed47e89278 | /json.h | 001b892d256390abc49810d298b834120075c0fc | []
| no_license | username0x0a/facebook-protocol | 257f39264ad801b3108d5d97c6ec7216d34053e3 | a97982e0187330326f1c40c709cba5eef60ceea9 | refs/heads/master | 2021-06-15T06:45:42.371823 | 2011-04-20T02:16:48 | 2011-04-20T02:16:48 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 1,347 | h | /*
Facebook plugin for Miranda Instant Messenger
_____________________________________________
Copyright ยฉ 2009-11 Michal Zelinka
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File name : $HeadURL: https://[email protected]/svn/trunk/facebook/json.h $
Revision : $Revision: 91 $
Last change by : $Author: n3weRm0re.ewer $
Last change on : $Date: 2011-01-08 11:10:34 +0100 (Sat, 08 Jan 2011) $
*/
#pragma once
// Parser front-end
class facebook_json_parser
{
private:
Json::Reader reader;
public:
FacebookProto* proto;
int parse_buddy_list( void*, List::List< facebook_user >* );
int parse_messages( void*, std::vector< facebook_message* >*, std::vector< facebook_notification* >* );
};
| [
"[email protected]"
]
| [
[
[
1,
40
]
]
]
|
be22da6804be169613cac4a10143b6c6bdaa09bb | fd518ed0226c6a044d5e168ab50a0e4a37f8efa9 | /iAuthor/Author/Crc16.cpp | 9cfb903521b42c5d7cef3ca1a8892731855d21bb | []
| no_license | shilinxu/iprojects | e2e2394df9882afaacfb9852332f83cbef6a8c93 | 79bc8e45596577948c45cf2afcff331bc71ab026 | refs/heads/master | 2020-05-17T19:15:43.197685 | 2010-04-02T15:58:11 | 2010-04-02T15:58:11 | 41,959,151 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,360 | cpp | // Crc16.cpp: implementation of the CCrc16 class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Crc16.h"
WORD CRC16Table[256] = {
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
};
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCrc16::CCrc16()
{
m_crc16 = 0x00;
}
CCrc16::CCrc16(const BYTE* src, int Length)
{
m_crc16 = MakeCRC16(src, 0, Length);
}
CCrc16::CCrc16(const BYTE* src, int idxStart, int Length)
{
m_crc16 = MakeCRC16(src, idxStart, Length);
}
CCrc16::~CCrc16()
{
}
//////////////////////////////////////////////////////////////////////
// 16bit CRC
//////////////////////////////////////////////////////////////////////
WORD CCrc16::MakeCRC16(const BYTE* src, int idxStart, int Length)
{
WORD crc_16;
crc_16 = 0xffff;
int idxEnd = idxStart + Length;
for (int i = idxStart; i < idxEnd; i++)
{
crc_16 = (crc_16 >> 8) ^ CRC16Table[BYTE((crc_16 ^ src[i])) & 0xFF];
}
crc_16 = ~(crc_16);
return(crc_16);
}
bool CCrc16::CheckCRC16(const BYTE* src, int sz, WORD crc)
{
return(MakeCRC16(src, 0, sz) == crc);
}
| [
"[email protected]"
]
| [
[
[
1,
97
]
]
]
|
94809b30b7c93492f9e61b430d8cdd1e781ddb6d | 0dba4a3016f3ad5aa22b194137a72efbc92ab19e | /tools/mapeditor/map.cpp | 36231375e0b07083db043ab5fbcaf88f1f4ce3c9 | []
| no_license | BackupTheBerlios/albion2 | 11e89586c3a2d93821b6a0d3332c1a7ef1af6abf | bc3d9ba9cf7b8f7579a58bc190a4abb32b30c716 | refs/heads/master | 2020-12-30T10:23:18.448750 | 2007-01-26T23:58:42 | 2007-01-26T23:58:42 | 39,515,887 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,703 | cpp | /*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "map.h"
cmap::cmap(engine* e) {
cmap::e = e;
cmap::m = e->get_msg();
cmap::f = e->get_file_io();
map_opened = false;
}
cmap::~cmap() {
}
bool cmap::open_map(char* filename) {
if(map_opened) {
// TODO: close and save old map
}
map_opened = true;
// open map
f->open_file(filename, file_io::OT_READ_BINARY);
f->get_block(map_type, 6);
map_type[6] = 0;
if(strcmp(map_type, "A2EMAP") != 0) {
m->print(msg::MERROR, "map.cpp", "open_map(): wrong map type (%s)!", map_type);
return false;
}
// get the amount of map objects
object_count = f->get_uint();
// reserve memory for the objects
map_objects = new map_object[object_count];
// load objects
for(unsigned int i = 0; i < object_count; i++) {
// model name
f->get_terminated_block(&map_objects[i].model_name, (char)0xFF);
// model filename
f->get_terminated_block(&map_objects[i].model_filename, (char)0xFF);
// animation filename
f->get_terminated_block(&map_objects[i].ani_filename, (char)0xFF);
// model type
map_objects[i].model_type = f->get_char() == 0x00 ? false : true;
// mat filename
f->get_terminated_block(&map_objects[i].mat_filename, (char)0xFF);
// position
map_objects[i].position.x = f->get_float();
map_objects[i].position.y = f->get_float();
map_objects[i].position.z = f->get_float();
// orientation
map_objects[i].orientation.x = f->get_float();
map_objects[i].orientation.y = f->get_float();
map_objects[i].orientation.z = f->get_float();
// scale
map_objects[i].scale.x = f->get_float();
map_objects[i].scale.y = f->get_float();
map_objects[i].scale.z = f->get_float();
// physical properties
map_objects[i].phys_type = f->get_uint();
// gravity flag
map_objects[i].gravity = f->get_char() == 0x00 ? false : true;
// collision model flag
map_objects[i].collision_model = f->get_char() == 0x00 ? false : true;
// auto mass flag
map_objects[i].auto_mass = f->get_char() == 0x00 ? false : true;
// mass
map_objects[i].mass = f->get_float();
// physical object scale
map_objects[i].phys_scale.x = f->get_float();
map_objects[i].phys_scale.y = f->get_float();
map_objects[i].phys_scale.z = f->get_float();
}
f->close_file();
return true;
}
bool cmap::save_map(char* filename) {
f->open_file(filename, file_io::OT_WRITE_BINARY);
f->write_block("A2EMAP", 6);
f->put_uint(object_count);
for(unsigned int i = 0; i < object_count; i++) {
f->write_terminated_block(&map_objects[i].model_name, (char)0xFF);
f->write_terminated_block(&map_objects[i].model_filename, (char)0xFF);
f->write_terminated_block(&map_objects[i].ani_filename, (char)0xFF);
f->put_bool(map_objects[i].model_type);
f->write_terminated_block(&map_objects[i].mat_filename, (char)0xFF);
f->put_float(map_objects[i].position.x);
f->put_float(map_objects[i].position.y);
f->put_float(map_objects[i].position.z);
f->put_float(map_objects[i].orientation.x);
f->put_float(map_objects[i].orientation.y);
f->put_float(map_objects[i].orientation.z);
f->put_float(map_objects[i].scale.x);
f->put_float(map_objects[i].scale.y);
f->put_float(map_objects[i].scale.z);
f->put_uint(map_objects[i].phys_type);
f->put_bool(map_objects[i].gravity);
f->put_bool(map_objects[i].collision_model);
f->put_bool(map_objects[i].auto_mass);
f->put_float(map_objects[i].mass);
f->put_float(map_objects[i].phys_scale.x);
f->put_float(map_objects[i].phys_scale.y);
f->put_float(map_objects[i].phys_scale.z);
}
f->close_file();
return true;
}
bool cmap::close_map() {
map_opened = false;
delete [] map_objects;
object_count = 0;
return true;
}
void cmap::new_map(char* filename) {
f->open_file(filename, file_io::OT_WRITE_BINARY);
f->write_block("A2EMAP", 6);
f->put_uint(0);
f->close_file();
}
| [
"[email protected]"
]
| [
[
[
1,
162
]
]
]
|
42a1c8182266a1a43a6161868e8525b592ecaf89 | f89e32cc183d64db5fc4eb17c47644a15c99e104 | /pcsx2-rr/pcsx2/x86/microVU_Execute.inl | d9ef323d744ac4b4163e358c59525659b576b91f | []
| no_license | mauzus/progenitor | f99b882a48eb47a1cdbfacd2f38505e4c87480b4 | 7b4f30eb1f022b08e6da7eaafa5d2e77634d7bae | refs/heads/master | 2021-01-10T07:24:00.383776 | 2011-04-28T11:03:43 | 2011-04-28T11:03:43 | 45,171,114 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,894 | inl | /* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2010 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
//------------------------------------------------------------------
// Dispatcher Functions
//------------------------------------------------------------------
// Generates the code for entering recompiled blocks
void mVUdispatcherA(mV) {
mVU->startFunct = x86Ptr;
// Backup cpu state
xPUSH(ebp);
xPUSH(ebx);
xPUSH(esi);
xPUSH(edi);
// Align the stackframe (GCC only, since GCC assumes stackframe is always aligned)
#ifdef __GNUC__
xSUB(esp, 12);
#endif
// __fastcall = The caller has already put the needed parameters in ecx/edx:
if (!isVU1) { xCALL(mVUexecuteVU0); }
else { xCALL(mVUexecuteVU1); }
// Load VU's MXCSR state
xLDMXCSR(g_sseVUMXCSR);
// Load Regs
#if 1 // CHECK_MACROVU0 - Always on now
xMOV(gprF0, ptr32[&mVU->regs().VI[REG_STATUS_FLAG].UL]);
xMOV(gprF1, gprF0);
xMOV(gprF2, gprF0);
xMOV(gprF3, gprF0);
#else
mVUallocSFLAGd((uptr)&mVU->regs().VI[REG_STATUS_FLAG].UL, 1);
#endif
xMOVAPS(xmmT1, ptr128[&mVU->regs().VI[REG_MAC_FLAG].UL]);
xSHUF.PS(xmmT1, xmmT1, 0);
xMOVAPS(ptr128[mVU->macFlag], xmmT1);
xMOVAPS(xmmT1, ptr128[&mVU->regs().VI[REG_CLIP_FLAG].UL]);
xSHUF.PS(xmmT1, xmmT1, 0);
xMOVAPS(ptr128[mVU->clipFlag], xmmT1);
xMOVAPS(xmmT1, ptr128[&mVU->regs().VI[REG_P].UL]);
xMOVAPS(xmmPQ, ptr128[&mVU->regs().VI[REG_Q].UL]);
xSHUF.PS(xmmPQ, xmmT1, 0); // wzyx = PPQQ
// Jump to Recompiled Code Block
xJMP(eax);
}
// Generates the code to exit from recompiled blocks
void mVUdispatcherB(mV) {
mVU->exitFunct = x86Ptr;
// Load EE's MXCSR state
xLDMXCSR(g_sseMXCSR);
// __fastcall = The first two DWORD or smaller arguments are passed in ECX and EDX registers;
// all other arguments are passed right to left.
if (!isVU1) { xCALL(mVUcleanUpVU0); }
else { xCALL(mVUcleanUpVU1); }
// Unalign the stackframe:
#ifdef __GNUC__
xADD( esp, 12 );
#endif
// Restore cpu state
xPOP(edi);
xPOP(esi);
xPOP(ebx);
xPOP(ebp);
xRET();
mVUcacheCheck(x86Ptr, mVU->dispCache, mVUdispCacheSize);
}
//------------------------------------------------------------------
// Execution Functions
//------------------------------------------------------------------
// Executes for number of cycles
_mVUt void* __fastcall mVUexecute(u32 startPC, u32 cycles) {
microVU* mVU = mVUx;
//DevCon.WriteLn("microVU%x: startPC = 0x%x, cycles = 0x%x", vuIndex, startPC, cycles);
mVU->cycles = cycles;
mVU->totalCycles = cycles;
xSetPtr(mVU->prog.x86ptr); // Set x86ptr to where last program left off
return mVUsearchProg<vuIndex>(startPC, (uptr)&mVU->prog.lpState); // Find and set correct program
}
//------------------------------------------------------------------
// Cleanup Functions
//------------------------------------------------------------------
_mVUt void mVUcleanUp() {
microVU* mVU = mVUx;
//mVUprint("microVU: Program exited successfully!");
//mVUprint("microVU: VF0 = {%x,%x,%x,%x}", mVU->regs().VF[0].UL[0], mVU->regs().VF[0].UL[1], mVU->regs().VF[0].UL[2], mVU->regs().VF[0].UL[3]);
//mVUprint("microVU: VI0 = %x", mVU->regs().VI[0].UL);
mVU->prog.x86ptr = x86Ptr;
mVUcacheCheck(x86Ptr, mVU->prog.x86start, (uptr)(mVU->prog.x86end - mVU->prog.x86start));
mVU->cycles = mVU->totalCycles - mVU->cycles;
mVU->regs().cycle += mVU->cycles;
cpuRegs.cycle += ((mVU->cycles < 3000) ? mVU->cycles : 3000) * EmuConfig.Speedhacks.VUCycleSteal;
//static int ax = 0; ax++;
//if (!(ax % 100000)) {
// for (u32 i = 0; i < (mVU->progSize / 2); i++) {
// if (mVUcurProg.block[i]) {
// mVUcurProg.block[i]->printInfo(i*8);
// }
// }
//}
}
//------------------------------------------------------------------
// Caller Functions
//------------------------------------------------------------------
void* __fastcall mVUexecuteVU0(u32 startPC, u32 cycles) { return mVUexecute<0>(startPC, cycles); }
void* __fastcall mVUexecuteVU1(u32 startPC, u32 cycles) { return mVUexecute<1>(startPC, cycles); }
void __fastcall mVUcleanUpVU0() { mVUcleanUp<0>(); }
void __fastcall mVUcleanUpVU1() { mVUcleanUp<1>(); }
| [
"koeiprogenitor@bfa1b011-20a7-a6e3-c617-88e5d26e11c5"
]
| [
[
[
1,
147
]
]
]
|
dd56fafca93f195cee41328a7dc2d5559780a64b | 1ac3920c854ebd1f591412d0f93b55a5c2b96521 | /GTL Draw/stdafx.cpp | e095e9367cbe1d93834ed5f839171efc821f0c9e | []
| no_license | vatai/gtldraw | fe1d9181f033dcda833342c4388f0adb0cdbf871 | 89c288f15cabe4bca348ee93688e995b1a9708bd | refs/heads/master | 2020-05-30T23:14:20.159427 | 2007-05-22T13:39:34 | 2007-05-22T13:39:34 | 32,105,809 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 208 | cpp | // stdafx.cpp : source file that includes just the standard includes
// GTL Draw.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
| [
"emil.vatai@e8fff1a5-fc30-0410-bed7-e1c51b34c90e"
]
| [
[
[
1,
7
]
]
]
|
ba76f7388bd88438396dcbee449a4cd033677439 | c8999a8d12d67db8efd246e244effbe295fe7c09 | /source/client/life_expert/src/WeatherReportContainer.cpp | de83bc3cd89efebccd9a7afcebb2ce4b91840086 | []
| no_license | sleep651/life-expert | 968ada69efb070e54df40c999b46c5738d8555d1 | 32df3f4f720c5e9f2d89ccb4785d1071e8a81d80 | refs/heads/master | 2016-09-06T13:15:38.938705 | 2010-03-05T14:32:19 | 2010-03-05T14:32:19 | 42,040,784 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,311 | cpp | /*
========================================================================
Name : WeatherReportContainer.cpp
Author : ZhangJiawei
Copyright :
Description :
========================================================================
*/
// [[[ begin generated region: do not modify [Generated System Includes]
#include <aknviewappui.h>
#include <eikappui.h>
#include <life_expert.rsg>
// ]]] end generated region [Generated System Includes]
// [[[ begin generated region: do not modify [Generated User Includes]
#include "WeatherReportContainer.h"
#include "WeatherReportContainerView.h"
#include "life_expert.hrh"
// ]]] end generated region [Generated User Includes]
// [[[ begin generated region: do not modify [Generated Constants]
// ]]] end generated region [Generated Constants]
/**
* First phase of Symbian two-phase construction. Should not
* contain any code that could leave.
*/
CWeatherReportContainer::CWeatherReportContainer()
{
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
}
/**
* Destroy child controls.
*/
CWeatherReportContainer::~CWeatherReportContainer()
{
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
}
/**
* Construct the control (first phase).
* Creates an instance and initializes it.
* Instance is not left on cleanup stack.
* @param aRect bounding rectangle
* @param aParent owning parent, or NULL
* @param aCommandObserver command observer
* @return initialized instance of CWeatherReportContainer
*/
CWeatherReportContainer* CWeatherReportContainer::NewL(
const TRect& aRect,
const CCoeControl* aParent,
MEikCommandObserver* aCommandObserver )
{
CWeatherReportContainer* self = CWeatherReportContainer::NewLC(
aRect,
aParent,
aCommandObserver );
CleanupStack::Pop( self );
return self;
}
/**
* Construct the control (first phase).
* Creates an instance and initializes it.
* Instance is left on cleanup stack.
* @param aRect The rectangle for this window
* @param aParent owning parent, or NULL
* @param aCommandObserver command observer
* @return new instance of CWeatherReportContainer
*/
CWeatherReportContainer* CWeatherReportContainer::NewLC(
const TRect& aRect,
const CCoeControl* aParent,
MEikCommandObserver* aCommandObserver )
{
CWeatherReportContainer* self = new ( ELeave ) CWeatherReportContainer();
CleanupStack::PushL( self );
self->ConstructL( aRect, aParent, aCommandObserver );
return self;
}
/**
* Construct the control (second phase).
* Creates a window to contain the controls and activates it.
* @param aRect bounding rectangle
* @param aCommandObserver command observer
* @param aParent owning parent, or NULL
*/
void CWeatherReportContainer::ConstructL(
const TRect& aRect,
const CCoeControl* aParent,
MEikCommandObserver* aCommandObserver )
{
if ( aParent == NULL )
{
CreateWindowL();
}
else
{
SetContainerWindowL( *aParent );
}
iFocusControl = NULL;
iCommandObserver = aCommandObserver;
InitializeControlsL();
SetRect( aRect );
ActivateL();
// [[[ begin generated region: do not modify [Post-ActivateL initializations]
// ]]] end generated region [Post-ActivateL initializations]
}
/**
* Return the number of controls in the container (override)
* @return count
*/
TInt CWeatherReportContainer::CountComponentControls() const
{
return ( int ) ELastControl;
}
/**
* Get the control with the given index (override)
* @param aIndex Control index [0...n) (limited by #CountComponentControls)
* @return Pointer to control
*/
CCoeControl* CWeatherReportContainer::ComponentControl( TInt aIndex ) const
{
// [[[ begin generated region: do not modify [Generated Contents]
switch ( aIndex )
{
}
// ]]] end generated region [Generated Contents]
// handle any user controls here...
return NULL;
}
/**
* Handle resizing of the container. This implementation will lay out
* full-sized controls like list boxes for any screen size, and will layout
* labels, editors, etc. to the size they were given in the UI designer.
* This code will need to be modified to adjust arbitrary controls to
* any screen size.
*/
void CWeatherReportContainer::SizeChanged()
{
CCoeControl::SizeChanged();
LayoutControls();
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
}
// [[[ begin generated function: do not modify
/**
* Layout components as specified in the UI Designer
*/
void CWeatherReportContainer::LayoutControls()
{
}
// ]]] end generated function
/**
* Handle key events.
*/
TKeyResponse CWeatherReportContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent,
TEventCode aType )
{
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
if ( iFocusControl != NULL
&& iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
{
return EKeyWasConsumed;
}
return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
}
// [[[ begin generated function: do not modify
/**
* Initialize each control upon creation.
*/
void CWeatherReportContainer::InitializeControlsL()
{
}
// ]]] end generated function
/**
* Handle global resource changes, such as scalable UI or skin events (override)
*/
void CWeatherReportContainer::HandleResourceChange( TInt aType )
{
CCoeControl::HandleResourceChange( aType );
SetRect( iAvkonViewAppUi->View( TUid::Uid( EWeatherReportContainerViewId ) )->ClientRect() );
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
}
/**
* Draw container contents.
*/
void CWeatherReportContainer::Draw( const TRect& aRect ) const
{
// [[[ begin generated region: do not modify [Generated Contents]
CWindowGc& gc = SystemGc();
gc.Clear( aRect );
// ]]] end generated region [Generated Contents]
}
| [
"[email protected]"
]
| [
[
[
1,
222
]
]
]
|
afb46970108c4baad10860d02f2e0c74033518aa | fac8de123987842827a68da1b580f1361926ab67 | /inc/physics/Common/Serialize/Util/hkLoader.h | 0f26706ba24c3d584fb8ca8d66ff30cd896c31c4 | []
| no_license | blockspacer/transporter-game | 23496e1651b3c19f6727712a5652f8e49c45c076 | 083ae2ee48fcab2c7d8a68670a71be4d09954428 | refs/heads/master | 2021-05-31T04:06:07.101459 | 2009-02-19T20:59:59 | 2009-02-19T20:59:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,897 | h | /*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent.This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2008 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
#ifndef LOADER_H
#define LOADER_H
#include <Common/Serialize/Packfile/hkPackfileData.h>
class hkTypeInfoRegistry;
class hkClassNameRegistry;
class hkVersionRegistry;
/// Utility class to load and manage packfiles.
class hkLoader : public hkReferencedObject
{
public:
HK_DECLARE_CLASS_ALLOCATOR(HK_MEMORY_CLASS_SERIALIZE);
/// Releases the references to all loaded memory
~hkLoader();
/// Loads from a file, Explicitly allocates and keeps a handle to the memory allocated
/// This method is usually called multiple times to load several different assets.
/// Implicitly uses the built-in registry
class hkRootLevelContainer* load( const char* filename );
/// Loads from a stream, Explicitly allocates and keeps a handle to the memory allocated
/// This method is usually called multiple times to load several different assets.
/// Implicitly uses the built-in registry
class hkRootLevelContainer* load( class hkStreamReader* reader );
/// Loads from a file, Explicitly allocates and keeps a handle to the memory allocated
/// This method is usually called multiple times to load several different assets.
/// The hkVersionRegistry may be null which disables versioning.
/// Uses the registries passed explicitly.
class hkRootLevelContainer* load( const char* filename, hkTypeInfoRegistry* finish, hkVersionRegistry* version );
/// Loads from a stream, Explicitly allocates and keeps a handle to the memory allocated
/// This method is usually called multiple times to load several different assets.
/// The hkVersionRegistry may be null which disables versioning.
/// Uses the registries passed explicitly.
class hkRootLevelContainer* load( class hkStreamReader* reader, hkTypeInfoRegistry* finish, hkVersionRegistry* version );
/// Loads from a file, Explicitly allocates and keeps a handle to the memory allocated
/// This method is usually called multiple times to load several different assets.
/// Does not assume that the hkRoootLevelContainer is the top level class.
/// Implicitly uses the built-in registry
void* load( const char* filename, const hkClass& expectedTopLevelClass );
/// Loads from a stream, Explicitly allocates and keeps a handle to the memory allocated
/// This method is usually called multiple times to load several different assets.
/// Does not assume that the hkRoootLevelContainer is the top level class.
/// Implicitly uses the built-in registry
void* load( class hkStreamReader* reader, const hkClass& expectedTopLevelClass );
/// Loads from a file, Explicitly allocates and keeps a handle to the memory allocated
/// This method is usually called multiple times to load several different assets.
/// Does not assume that the hkRoootLevelContainer is the top level class.
/// The hkVersionRegistry may be null which disables versioning.
/// Uses the registries passed explicitly.
void* load( const char* filename, const hkClass& expectedTopLevelClass, hkTypeInfoRegistry* finish, hkVersionRegistry* version );
/// Loads from a stream, Explicitly allocates and keeps a handle to the memory allocated
/// This method is usually called multiple times to load several different assets.
/// Does not assume that the hkRoootLevelContainer is the top level class.
/// The hkVersionRegistry may be null which disables versioning.
/// Uses the registries passed explicitly.
void* load( class hkStreamReader* reader, const hkClass& expectedTopLevelClass, hkTypeInfoRegistry* finish, hkVersionRegistry* version );
public:
hkArray<hkPackfileData*> m_loadedData;
};
#endif // LOADER_H
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20080529)
*
* Confidential Information of Havok. (C) Copyright 1999-2008
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at
* www.havok.com/tryhavok
*
*/
| [
"uraymeiviar@bb790a93-564d-0410-8b31-212e73dc95e4"
]
| [
[
[
1,
97
]
]
]
|
7a846d78cfbbb176fa6717955a1cb2a4f0e4852e | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /Game/ClientShellDLL/ClientShellShared/PlayerVehicleFX.h | ae0e53227133db62b46b5e23fef2b42b9387dd89 | []
| no_license | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 895 | h | // ----------------------------------------------------------------------- //
//
// MODULE : PlayerVehicleFX.h
//
// PURPOSE : Tracer special fx class - Definition
//
// CREATED : 6/8/00
//
// (c) 2000 Monolith Productions, Inc. All Rights Reserved
//
// ----------------------------------------------------------------------- //
#ifndef __PLAYER_VEHICLE_FX_H__
#define __PLAYER_VEHICLE_FX_H__
#include "SpecialFX.h"
#include "SharedFXStructs.h"
class CPlayerVehicleFX : public CSpecialFX
{
public :
CPlayerVehicleFX() : CSpecialFX()
{
}
virtual LTBOOL Init(HLOCALOBJ hServObj, ILTMessage_Read *pMsg);
virtual LTBOOL Init(SFXCREATESTRUCT* psfxCreateStruct);
virtual LTBOOL Update();
virtual uint32 GetSFXID() { return SFX_PLAYERVEHICLE_ID; }
protected :
PVCREATESTRUCT m_cs;
};
#endif // __PLAYER_VEHICLE_FX_H__ | [
"[email protected]"
]
| [
[
[
1,
38
]
]
]
|
df63911691038a2c1b7addbe968370c414fc29bd | a77c496f4faefb2c030e6c97deed4d4aa9a3bc0a | /rcracki_mt/branches/rcracki_mt_0.6.1/CrackEngine.cpp | 5cc9a996339d4b48b94cc74d4a44fc0d1b7ed6d9 | []
| no_license | 0wnrepo/rcracki_mt | 7cc26abdcc53479cd163bf797645297840643542 | 9e59303c1abd08544b67443df37c2bc5778db94d | refs/heads/master | 2021-01-20T01:11:31.891122 | 2011-01-14T06:08:07 | 2011-01-14T06:08:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 38,338 | cpp | /*
RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
Copyright (C) Zhu Shuanglei <[email protected]>
*/
#ifdef _WIN32
#pragma warning(disable : 4786 4267 4018)
#endif
#include "CrackEngine.h"
#include <time.h>
// Code comes from nmap, used for the linux implementation of kbhit()
#ifndef _WIN32
#include <unistd.h>
#include <termios.h>
#include <fcntl.h>
static int tty_fd = 0;
static struct termios saved_ti;
static int tty_getchar()
{
int c, numChars;
if (tty_fd && tcgetpgrp(tty_fd) == getpid()) {
c = 0;
numChars = read(tty_fd, &c, 1);
if (numChars > 0) return c;
}
return -1;
}
static void tty_done()
{
if (!tty_fd) return;
tcsetattr(tty_fd, TCSANOW, &saved_ti);
close(tty_fd);
tty_fd = 0;
}
void tty_init()
{
struct termios ti;
if (tty_fd)
return;
if ((tty_fd = open("/dev/tty", O_RDONLY | O_NONBLOCK)) < 0) return;
tcgetattr(tty_fd, &ti);
saved_ti = ti;
ti.c_lflag &= ~(ICANON | ECHO);
ti.c_cc[VMIN] = 1;
ti.c_cc[VTIME] = 0;
tcsetattr(tty_fd, TCSANOW, &ti);
atexit(tty_done);
}
static void tty_flush(void)
{
/* we don't need to test for tty_fd==0 here because
* * this isn't called unless we succeeded
* */
tcflush(tty_fd, TCIFLUSH);
}
#endif
CCrackEngine::CCrackEngine()
{
ResetStatistics();
writeOutput = false;
resumeSession = false;
debug = false;
keepPrecalcFiles = false;
sSessionPathName = "";
sProgressPathName = "";
}
CCrackEngine::~CCrackEngine()
{
}
//////////////////////////////////////////////////////////////////////
void CCrackEngine::ResetStatistics()
{
m_fTotalDiskAccessTime = 0.0f;
m_fTotalCryptanalysisTime = 0.0f;
m_nTotalChainWalkStep = 0;
m_nTotalFalseAlarm = 0;
m_nTotalChainWalkStepDueToFalseAlarm = 0;
// m_nTotalFalseAlarmSkipped = 0;
}
int CCrackEngine::BinarySearchOld(RainbowChainO* pChain, int nRainbowChainCount, uint64 nIndex)
{
int nLow = 0;
int nHigh = nRainbowChainCount - 1;
while (nLow <= nHigh)
{
int nMid = (nLow + nHigh) / 2;
if (nIndex == pChain[nMid].nIndexE)
return nMid;
else if (nIndex < pChain[nMid].nIndexE)
nHigh = nMid - 1;
else
nLow = nMid + 1;
}
return -1;
}
RainbowChain *CCrackEngine::BinarySearch(RainbowChain *pChain, int nChainCountRead, uint64 nIndex, IndexChain *pIndex, int nIndexSize, int nIndexStart)
{
uint64 nPrefix = nIndex >> 16;
int nLow, nHigh;
bool found = false;
int nChains = 0;
if(nPrefix > (pIndex[nIndexSize-1].nPrefix & 0x000000FFFFFFFFFFULL)) // check if its in the index file
{
return NULL;
}
int nBLow = 0;
int nBHigh = nIndexSize - 1;
while (nBLow <= nBHigh)
{
int nBMid = (nBLow + nBHigh) / 2;
if (nPrefix == (pIndex[nBMid].nPrefix & 0x000000FFFFFFFFFFULL))
{
//nLow = nChains;
int nChains = 0;
nLow = pIndex[nBMid].nFirstChain;
nHigh = nLow + pIndex[nBMid].nChainCount;
if(nLow >= nIndexStart && nLow <= nIndexStart + nChainCountRead)
{
if(nHigh > nIndexStart + nChainCountRead)
nHigh = nIndexStart + nChainCountRead;
}
else if(nLow < nIndexStart && nHigh >= nIndexStart)
{
nLow = nIndexStart;
}
else break;
found = true;
break;
}
else if (nPrefix < (pIndex[nBMid].nPrefix & 0x000000FFFFFFFFFFULL))
nBHigh = nBMid - 1;
else
nBLow = nBMid + 1;
}
if(found == true)
{
for(int i = nLow - nIndexStart; i < nHigh - nIndexStart; i++)
{
int nSIndex = ((int)nIndex) & 0x0000FFFF;
if (nSIndex == pChain[i].nIndexE)
{
return &pChain[i];
}
else if(pChain[i].nIndexE > nSIndex)
break;
}
}
return NULL;
}
// not used currently, leaving code for future checkpoints
//bool CCrackEngine::CheckAlarm(RainbowChain* pChain, int nGuessedPos, unsigned char* pHash, CHashSet& hs)
//{
// CChainWalkContext cwc;
// //uint64 nIndexS = pChain->nIndexS >> 16;
// uint64 nIndexS = pChain->nIndexS & 0x0000FFFFFFFFFFFFULL; // for first 6 bytes
// cwc.SetIndex(nIndexS);
// int nPos;
// for (nPos = 0; nPos < nGuessedPos; nPos++)
// {
// cwc.IndexToPlain();
// cwc.PlainToHash();
// cwc.HashToIndex(nPos);
// // Not using checkpoints atm
// /*
// switch(nPos)
// {
// case 5000:
// if((cwc.GetIndex() & 0x00000001) != (pChain->nCheckPoint & 0x00000080) >> 7)
// {
// m_nTotalFalseAlarmSkipped += 10000 - 5000;
//// printf("CheckPoint caught false alarm at position 7600\n");
// return false;
// }
// break;
// case 6000:
// if((cwc.GetIndex() & 0x00000001) != (pChain->nCheckPoint & 0x00000040) >> 6)
// {
//// printf("CheckPoint caught false alarm at position 8200\n");
// m_nTotalFalseAlarmSkipped += 10000 - 6000;
// return false;
// }
// break;
//
// case 7600:
// if((cwc.GetIndex() & 0x00000001) != (pChain->nCheckPoint & 0x00000020) >> 5)
// {
//// printf("CheckPoint caught false alarm at position 8700\n");
// m_nTotalFalseAlarmSkipped += 10000 - 7600;
// return false;
// }
// break;
//
// case 8200:
// if((cwc.GetIndex() & 0x00000001) != (pChain->nCheckPoint & 0x00000010) >> 4)
// {
//// printf("CheckPoint caught false alarm at position 9000\n");
// m_nTotalFalseAlarmSkipped += 10000 - 8200;
// return false;
// }
// break;
//
// case 8700:
// if((cwc.GetIndex() & 0x00000001) != (pChain->nCheckPoint & 0x00000008) >> 3)
// {
//// printf("CheckPoint caught false alarm at position 9300\n");
// m_nTotalFalseAlarmSkipped += 10000 - 8700;
// return false;
// }
//
// break;
// case 9000:
// if((cwc.GetIndex() & 0x00000001) != (pChain->nCheckPoint & 0x00000004) >> 2)
// {
//// printf("CheckPoint caught false alarm at position 9600\n");
// m_nTotalFalseAlarmSkipped += 10000 - 9000;
// return false;
// }
//
// break;
// case 9300:
// if((cwc.GetIndex() & 0x00000001) != (pChain->nCheckPoint & 0x00000002) >> 1)
// {
//// printf("CheckPoint caught false alarm at position 9600\n");
// m_nTotalFalseAlarmSkipped += 10000 - 9300;
// return false;
// }
// break;
// case 9600:
// if((cwc.GetIndex() & 0x00000001) != (pChain->nCheckPoint & 0x00000001))
// {
//// printf("CheckPoint caught false alarm at position 9600\n");
// m_nTotalFalseAlarmSkipped += 10000 - 9600;
// return false;
// }
// break;
//
// }*/
// }
// cwc.IndexToPlain();
// cwc.PlainToHash();
// if (cwc.CheckHash(pHash))
// {
// printf("plaintext of %s is %s\n", cwc.GetHash().c_str(), cwc.GetPlain().c_str());
// hs.SetPlain(cwc.GetHash(), cwc.GetPlain(), cwc.GetBinary());
// return true;
// }
//
// return false;
//}
//bool CCrackEngine::CheckAlarmOld(RainbowChainO* pChain, int nGuessedPos, unsigned char* pHash, CHashSet& hs)
//{
// CChainWalkContext cwc;
// cwc.SetIndex(pChain->nIndexS);
// int nPos;
// for (nPos = 0; nPos < nGuessedPos; nPos++)
// {
// cwc.IndexToPlain();
// cwc.PlainToHash();
// cwc.HashToIndex(nPos);
// }
// cwc.IndexToPlain();
// cwc.PlainToHash();
// if (cwc.CheckHash(pHash))
// {
// printf("plaintext of %s is %s\n", cwc.GetHash().c_str(), cwc.GetPlain().c_str());
// hs.SetPlain(cwc.GetHash(), cwc.GetPlain(), cwc.GetBinary());
// return true;
// }
//
// return false;
//}
void CCrackEngine::GetChainIndexRangeWithSameEndpoint(RainbowChainO* pChain,
int nRainbowChainCount,
int nMatchingIndexE,
int& nMatchingIndexEFrom,
int& nMatchingIndexETo)
{
nMatchingIndexEFrom = nMatchingIndexE;
nMatchingIndexETo = nMatchingIndexE;
while (nMatchingIndexEFrom > 0)
{
if (pChain[nMatchingIndexEFrom - 1].nIndexE == pChain[nMatchingIndexE].nIndexE)
nMatchingIndexEFrom--;
else
break;
}
while (nMatchingIndexETo < nRainbowChainCount - 1)
{
if (pChain[nMatchingIndexETo + 1].nIndexE == pChain[nMatchingIndexE].nIndexE)
nMatchingIndexETo++;
else
break;
}
}
void CCrackEngine::SearchTableChunkOld(RainbowChainO* pChain, int nRainbowChainLen, int nRainbowChainCount, CHashSet& hs)
{
vector<string> vHash;
hs.GetLeftHashWithLen(vHash, CChainWalkContext::GetHashLen());
printf("searching for %d hash%s...\n", vHash.size(),
vHash.size() > 1 ? "es" : "");
int nChainWalkStep = 0;
int nFalseAlarm = 0;
int nChainWalkStepDueToFalseAlarm = 0;
vector<rcrackiThread*> threadPool;
vector<pthread_t> pThreads;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
#ifdef _WIN32
sched_param param;
param.sched_priority = THREAD_PRIORITY_BELOW_NORMAL;
pthread_attr_setschedparam (&attr, ¶m);
#endif
// else set it to 5 or something (for linux)?
bool pausing = false;
int nHashIndex;
for (nHashIndex = 0; nHashIndex < vHash.size(); nHashIndex++)
{
#ifdef _WIN32
if (_kbhit())
{
int ch = _getch();
ch = toupper(ch);
if (ch == 'P')
{
pausing = true;
printf( "\nPausing, press P again to continue... ");
clock_t t1 = clock();
while (pausing)
{
if (_kbhit())
{
ch = _getch();
ch = toupper(ch);
if (ch == 'P')
{
printf( " [Continuing]\n");
pausing = false;
clock_t t2 = clock();
float fTime = 1.0f * (t2 - t1) / CLOCKS_PER_SEC;
m_fTotalCryptanalysisTime -= fTime;
}
}
Sleep(500);
}
}
else
{
printf( "\nPress 'P' to pause...\n");
}
}
#else
int c = tty_getchar();
if (c >= 0) {
tty_flush();
if (c==112) { // = p
pausing = true;
printf( "\nPausing, press 'p' again to continue... ");
clock_t t1 = clock();
while (pausing)
{
if ((c = tty_getchar()) >= 0)
{
tty_flush();
if (c == 112)
{
printf( " [Continuing]\n");
pausing = false;
clock_t t2 = clock();
float fTime = 1.0f * (t2 - t1) / CLOCKS_PER_SEC;
m_fTotalCryptanalysisTime -= fTime;
}
}
usleep(500*1000);
}
}
else {
printf( "\nPress 'p' to pause...\n");
}
}
#endif
unsigned char TargetHash[MAX_HASH_LEN];
int nHashLen;
ParseHash(vHash[nHashIndex], TargetHash, nHashLen);
if (nHashLen != CChainWalkContext::GetHashLen())
printf("debug: nHashLen mismatch\n");
// Rqeuest ChainWalk
bool fNewlyGenerated;
uint64* pStartPosIndexE = m_cws.RequestWalk(TargetHash,
nHashLen,
CChainWalkContext::GetHashRoutineName(),
CChainWalkContext::GetPlainCharsetName(),
CChainWalkContext::GetPlainLenMin(),
CChainWalkContext::GetPlainLenMax(),
CChainWalkContext::GetRainbowTableIndex(),
nRainbowChainLen,
fNewlyGenerated,
debug,
sPrecalcPathName);
//printf("debug: using %s walk for %s\n", fNewlyGenerated ? "newly generated" : "existing",
// vHash[nHashIndex].c_str());
// Walk
if (fNewlyGenerated)
{
//printf("Pre-calculating hash %d of %d.\t\t\r", nHashIndex+1, vHash.size());
printf("Pre-calculating hash %d of %d.%-20s\r", nHashIndex+1, vHash.size(), "");
threadPool.clear();
pThreads.clear();
int thread_ID;
for (thread_ID = 0; thread_ID < maxThreads; thread_ID++)
{
rcrackiThread* r_Thread = new rcrackiThread(TargetHash, thread_ID, nRainbowChainLen, maxThreads, pStartPosIndexE);
if (r_Thread)
{
pthread_t pThread;
int returnValue = pthread_create( &pThread, &attr, rcrackiThread::rcrackiThreadStaticEntryPointPthread, (void *) r_Thread);
if( returnValue != 0 )
{
printf("pThread creation failed, returnValue: %d\n", returnValue);
}
else
{
pThreads.push_back(pThread);
}
threadPool.push_back(r_Thread);
}
else
{
printf("r_Thread creation failed!\n");
}
}
//printf("%d r_Threads created\t\t\n", threadPool.size());
for (thread_ID = 0; thread_ID < threadPool.size(); thread_ID++)
{
pthread_t pThread = pThreads[thread_ID];
int returnValue = pthread_join(pThread, NULL);
if( returnValue != 0 )
{
printf("pThread join failed, returnValue: %d\n", returnValue);
}
rcrackiThread* rThread = threadPool[thread_ID];
nChainWalkStep += rThread->GetChainWalkStep();
}
//printf("\t\t\t\t\r");
printf("%-50s\r", "");
}
//printf("Checking false alarms for hash %d of %d.\t\t\r", nHashIndex+1, vHash.size());
printf("Checking false alarms for hash %d of %d.%-20s\r", nHashIndex+1, vHash.size(), "");
threadPool.clear();
pThreads.clear();
int i;
for (i = 0; i < maxThreads; i++)
{
rcrackiThread* r_Thread = new rcrackiThread(TargetHash, true);
threadPool.push_back(r_Thread);
}
int thread_ID = 0;
int nPos;
for (nPos = nRainbowChainLen - 2; nPos >= 0; nPos--)
{
uint64 nIndexEOfCurPos = pStartPosIndexE[nPos];
// Search matching nIndexE
int nMatchingIndexE = BinarySearchOld(pChain, nRainbowChainCount, nIndexEOfCurPos);
if (nMatchingIndexE != -1)
{
int nMatchingIndexEFrom, nMatchingIndexETo;
GetChainIndexRangeWithSameEndpoint(pChain, nRainbowChainCount,
nMatchingIndexE,
nMatchingIndexEFrom, nMatchingIndexETo);
int i;
for (i = nMatchingIndexEFrom; i <= nMatchingIndexETo; i++)
{
rcrackiThread* rThread = threadPool[thread_ID];
rThread->AddAlarmCheckO(pChain + i, nPos);
if (thread_ID < maxThreads - 1 ) {
thread_ID++;
} else {
thread_ID = 0;
}
}
}
}
for (thread_ID = 0; thread_ID < maxThreads; thread_ID++)
{
rcrackiThread* r_Thread = threadPool[thread_ID];
pthread_t pThread;
int returnValue = pthread_create( &pThread, &attr, rcrackiThread::rcrackiThreadStaticEntryPointPthread, (void *) r_Thread);
if( returnValue != 0 )
{
printf("pThread creation failed, returnValue: %d\n", returnValue);
}
else
{
pThreads.push_back(pThread);
}
}
//printf("%d r_Threads created\t\t\n", threadPool.size());
bool foundHashInThread = false;
for (thread_ID = 0; thread_ID < threadPool.size(); thread_ID++)
{
rcrackiThread* rThread = threadPool[thread_ID];
pthread_t pThread = pThreads[thread_ID];
int returnValue = pthread_join(pThread, NULL);
if( returnValue != 0 )
{
printf("pThread join failed, returnValue: %d\n", returnValue);
}
nChainWalkStepDueToFalseAlarm += rThread->GetChainWalkStepDueToFalseAlarm();
nFalseAlarm += rThread->GetnFalseAlarm();
if (rThread->FoundHash() && !foundHashInThread) {
//printf("\t\t\t\t\t\t\r");
printf("%-50s\r", "");
printf("plaintext of %s is %s\n", rThread->GetHash().c_str(), rThread->GetPlain().c_str());
if (writeOutput)
{
if (!writeResultLineToFile(outputFile, rThread->GetHash(), rThread->GetPlain(), rThread->GetBinary()))
printf("Couldn't write this result to file!\n");
}
hs.SetPlain(rThread->GetHash(), rThread->GetPlain(), rThread->GetBinary());
FILE* file = fopen(sSessionPathName.c_str(), "a");
if (file!=NULL)
{
string buffer = "sHash=" + rThread->GetHash() + ":" + rThread->GetBinary() + ":" + rThread->GetPlain() + "\n";
fputs (buffer.c_str(), file);
fclose (file);
}
m_cws.DiscardWalk(pStartPosIndexE);
foundHashInThread = true;
}
}
pThreads.clear();
threadPool.clear();
}
//printf("\t\t\t\t\t\t\t\r");
printf("%-50s\r", "");
pThreads.clear();
threadPool.clear();
pthread_attr_destroy(&attr);
//printf("debug: chain walk step: %d\n", nChainWalkStep);
//printf("debug: false alarm: %d\n", nFalseAlarm);
//printf("debug: chain walk step due to false alarm: %d\n", nChainWalkStepDueToFalseAlarm);
m_nTotalChainWalkStep += nChainWalkStep;
m_nTotalFalseAlarm += nFalseAlarm;
m_nTotalChainWalkStepDueToFalseAlarm += nChainWalkStepDueToFalseAlarm;
}
void CCrackEngine::SearchTableChunk(RainbowChain* pChain, int nRainbowChainLen, int nRainbowChainCount, CHashSet& hs, IndexChain *pIndex, int nIndexSize, int nChainStart)
{
vector<string> vHash;
//vector<uint64 *> vIndices;
//vector<RainbowChain *> vChains;
hs.GetLeftHashWithLen(vHash, CChainWalkContext::GetHashLen());
printf("searching for %d hash%s...\n", vHash.size(),
vHash.size() > 1 ? "es" : "");
int nChainWalkStep = 0;
int nFalseAlarm = 0;
int nChainWalkStepDueToFalseAlarm = 0;
vector<rcrackiThread*> threadPool;
vector<pthread_t> pThreads;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
#ifdef _WIN32
sched_param param;
param.sched_priority = THREAD_PRIORITY_BELOW_NORMAL;
pthread_attr_setschedparam (&attr, ¶m);
#endif
// else set it to 5 or something (for linux)?
bool pausing = false;
int nHashIndex;
for (nHashIndex = 0; nHashIndex < vHash.size(); nHashIndex++)
{
#ifdef _WIN32
if (_kbhit())
{
int ch = _getch();
ch = toupper(ch);
if (ch == 'P')
{
pausing = true;
printf( "\nPausing, press P again to continue... ");
clock_t t1 = clock();
while (pausing)
{
if (_kbhit())
{
ch = _getch();
ch = toupper(ch);
if (ch == 'P')
{
printf( " [Continuing]\n");
pausing = false;
clock_t t2 = clock();
float fTime = 1.0f * (t2 - t1) / CLOCKS_PER_SEC;
m_fTotalCryptanalysisTime -= fTime;
}
}
Sleep(500);
}
}
else
{
printf( "\nPress 'P' to pause...\n");
}
}
#else
int c = tty_getchar();
if (c >= 0) {
tty_flush();
if (c==112) { // = p
pausing = true;
printf( "\nPausing, press 'p' again to continue... ");
clock_t t1 = clock();
while (pausing)
{
if ((c = tty_getchar()) >= 0)
{
tty_flush();
if (c == 112)
{
printf( " [Continuing]\n");
pausing = false;
clock_t t2 = clock();
float fTime = 1.0f * (t2 - t1) / CLOCKS_PER_SEC;
m_fTotalCryptanalysisTime -= fTime;
}
}
usleep(500*1000);
}
}
else {
printf( "\nPress 'p' to pause...\n");
}
}
#endif
unsigned char TargetHash[MAX_HASH_LEN];
int nHashLen;
ParseHash(vHash[nHashIndex], TargetHash, nHashLen);
if (nHashLen != CChainWalkContext::GetHashLen())
printf("debug: nHashLen mismatch\n");
// Request ChainWalk
bool fNewlyGenerated;
// printf("Requesting walk...");
uint64* pStartPosIndexE = m_cws.RequestWalk(TargetHash,
nHashLen,
CChainWalkContext::GetHashRoutineName(),
CChainWalkContext::GetPlainCharsetName(),
CChainWalkContext::GetPlainLenMin(),
CChainWalkContext::GetPlainLenMax(),
CChainWalkContext::GetRainbowTableIndex(),
nRainbowChainLen,
fNewlyGenerated,
debug,
sPrecalcPathName);
// printf("done!\n");
// printf("debug: using %s walk for %s\n", fNewlyGenerated ? "newly generated" : "existing",
// vHash[nHashIndex].c_str());
if (fNewlyGenerated)
{
//printf("Pre-calculating hash %d of %d.\t\t\r", nHashIndex+1, vHash.size());
printf("Pre-calculating hash %d of %d.%-20s\r", nHashIndex+1, vHash.size(), "");
threadPool.clear();
pThreads.clear();
int thread_ID;
for (thread_ID = 0; thread_ID < maxThreads; thread_ID++)
{
rcrackiThread* r_Thread = new rcrackiThread(TargetHash, thread_ID, nRainbowChainLen, maxThreads, pStartPosIndexE);
if (r_Thread)
{
pthread_t pThread;
int returnValue = pthread_create( &pThread, &attr, rcrackiThread::rcrackiThreadStaticEntryPointPthread, (void *) r_Thread);
if( returnValue != 0 )
{
printf("pThread creation failed, returnValue: %d\n", returnValue);
}
else
{
pThreads.push_back(pThread);
}
threadPool.push_back(r_Thread);
}
else
{
printf("r_Thread creation failed!\n");
}
}
//printf("%d r_Threads created\t\t\n", threadPool.size());
for (thread_ID = 0; thread_ID < threadPool.size(); thread_ID++)
{
pthread_t pThread = pThreads[thread_ID];
int returnValue = pthread_join(pThread, NULL);
if( returnValue != 0 )
{
printf("pThread join failed, returnValue: %d\n", returnValue);
}
rcrackiThread* rThread = threadPool[thread_ID];
nChainWalkStep += rThread->GetChainWalkStep();
}
m_cws.StoreToFile(pStartPosIndexE, TargetHash, nHashLen);
//printf("\npStartPosIndexE[0]: %s\n", uint64tostr(pStartPosIndexE[0]).c_str());
//printf("\npStartPosIndexE[nRainbowChainLen-2]: %s\n", uint64tostr(pStartPosIndexE[nRainbowChainLen-2]).c_str());
printf("%-50s\r", "");
}
threadPool.clear();
pThreads.clear();
//printf("Checking false alarms for hash %d of %d.\t\t\r", nHashIndex+1, vHash.size());
printf("Checking false alarms for hash %d of %d.%-20s\r", nHashIndex+1, vHash.size(), "");
int i;
for (i = 0; i < maxThreads; i++)
{
rcrackiThread* r_Thread = new rcrackiThread(TargetHash);
threadPool.push_back(r_Thread);
}
int thread_ID = 0;
int nPos;
for (nPos = nRainbowChainLen - 2; nPos >= 0; nPos--)
{
uint64 nIndexEOfCurPos = pStartPosIndexE[nPos];
// Search matching nIndexE
RainbowChain *pChainFound = BinarySearch(pChain, nRainbowChainCount, nIndexEOfCurPos, pIndex, nIndexSize, nChainStart);
if (pChainFound != NULL) // For perfected indexed tables we only recieve 1 result (huge speed increase!)
{
rcrackiThread* rThread = threadPool[thread_ID];
rThread->AddAlarmCheck(pChainFound, nPos);
if (thread_ID < maxThreads - 1 ) {
thread_ID++;
} else {
thread_ID = 0;
}
}
}
for (thread_ID = 0; thread_ID < maxThreads; thread_ID++)
{
rcrackiThread* r_Thread = threadPool[thread_ID];
pthread_t pThread;
int returnValue = pthread_create( &pThread, &attr, rcrackiThread::rcrackiThreadStaticEntryPointPthread, (void *) r_Thread);
if( returnValue != 0 )
{
printf("pThread creation failed, returnValue: %d\n", returnValue);
}
else
{
pThreads.push_back(pThread);
}
}
//printf("%d r_Threads created\t\t\n", threadPool.size());
bool foundHashInThread = false;
for (thread_ID = 0; thread_ID < threadPool.size(); thread_ID++)
{
rcrackiThread* rThread = threadPool[thread_ID];
pthread_t pThread = pThreads[thread_ID];
int returnValue = pthread_join(pThread, NULL);
if( returnValue != 0 )
{
printf("pThread join failed, returnValue: %d\n", returnValue);
}
nChainWalkStepDueToFalseAlarm += rThread->GetChainWalkStepDueToFalseAlarm();
nFalseAlarm += rThread->GetnFalseAlarm();
if (rThread->FoundHash() && !foundHashInThread) {
//printf("\t\t\t\t\t\t\r");
printf("%-50s\r", "");
printf("plaintext of %s is %s\n", rThread->GetHash().c_str(), rThread->GetPlain().c_str());
if (writeOutput)
{
if (!writeResultLineToFile(outputFile, rThread->GetHash(), rThread->GetPlain(), rThread->GetBinary()))
printf("Couldn't write this result to file!\n");
}
hs.SetPlain(rThread->GetHash(), rThread->GetPlain(), rThread->GetBinary());
FILE* file = fopen(sSessionPathName.c_str(), "a");
if (file!=NULL)
{
string buffer = "sHash=" + rThread->GetHash() + ":" + rThread->GetBinary() + ":" + rThread->GetPlain() + "\n";
fputs (buffer.c_str(), file);
fclose (file);
}
m_cws.DiscardWalk(pStartPosIndexE);
foundHashInThread = true;
}
//pthread
delete rThread;
}
pThreads.clear();
threadPool.clear();
//printf("\t\t\t\t\r");
//printf("pChainFounds: %d\n", pChainsFound.size());
//NEXT_HASH:;
}
//printf("\t\t\t\t\t\t\t\r");
printf("%-50s\r", "");
pThreads.clear();
threadPool.clear();
pthread_attr_destroy(&attr);
//printf("debug: chain walk step: %d\n", nChainWalkStep);
//printf("debug: false alarm: %d\n", nFalseAlarm);
//printf("debug: chain walk step due to false alarm: %d\n", nChainWalkStepDueToFalseAlarm);
m_nTotalChainWalkStep += nChainWalkStep;
m_nTotalFalseAlarm += nFalseAlarm;
m_nTotalChainWalkStepDueToFalseAlarm += nChainWalkStepDueToFalseAlarm;
}
void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs)
{
// Did we already go through this file in this session?
if (resumeSession)
{
vector<string> sessionFinishedPathNames;
if (ReadLinesFromFile(sProgressPathName.c_str(), sessionFinishedPathNames))
{
int i;
for (i = 0; i < sessionFinishedPathNames.size(); i++)
{
if (sessionFinishedPathNames[i] == sPathName)
{
printf("Skipping %s\n", sPathName.c_str());
return;
}
}
}
}
// FileName
#ifdef _WIN32
int nIndex = sPathName.find_last_of('\\');
#else
int nIndex = sPathName.find_last_of('/');
#endif
string sFileName;
if (nIndex != -1)
sFileName = sPathName.substr(nIndex + 1);
else
sFileName = sPathName;
// Info
printf("%s:\n", sFileName.c_str());
// Setup
int nRainbowChainLen, nRainbowChainCount;
if (!CChainWalkContext::SetupWithPathName(sPathName, nRainbowChainLen, nRainbowChainCount))
return;
//printf("keyspace: %u\n", CChainWalkContext::GetPlainSpaceTotal());
// Already finished?
if (!hs.AnyHashLeftWithLen(CChainWalkContext::GetHashLen()))
{
printf("this table contains hashes with length %d only\n", CChainWalkContext::GetHashLen());
return;
}
// Open
FILE* file = fopen(sPathName.c_str(), "rb");
if (file != NULL)
{
// File length check
bool doOldFormat = CChainWalkContext::isOldFormat();
int sizeOfChain;
bool fVerified = false;
unsigned int nFileLen = GetFileLen(file);
if (doOldFormat)
sizeOfChain = 16;
else
sizeOfChain = 8;
//if (nFileLen % 8 != 0 || nRainbowChainCount * 8 != nFileLen)
if (nFileLen % sizeOfChain != 0 || nRainbowChainCount * sizeOfChain != nFileLen)
printf("file length mismatch\n");
else
{
fseek(file, 0, SEEK_SET);
unsigned int bytesForChainWalkSet = hs.GetStatHashTotal() * (nRainbowChainLen-1) * 8;
if (debug) printf("Debug: Saving %u bytes of memory for chainwalkset.\n", bytesForChainWalkSet);
static CMemoryPool mp(bytesForChainWalkSet);
unsigned int nAllocatedSize;
if (doOldFormat)
{
if (debug) printf("Debug: This is a table in the old .rt format.\n");
RainbowChainO* pChain = (RainbowChainO*)mp.Allocate(nFileLen, nAllocatedSize);
if (debug) printf("Allocated %u bytes, filelen %u\n", nAllocatedSize, nFileLen);
if (pChain != NULL)
{
nAllocatedSize = nAllocatedSize / sizeOfChain * sizeOfChain; // Round to sizeOfChain boundary
//fseek(file, 0, SEEK_SET);
//bool fVerified = false;
while (true) // Chunk read loop
{
if (ftell(file) == nFileLen)
break;
// Load table chunk
if (debug) printf("reading...\n");
clock_t t1 = clock();
unsigned int nDataRead = fread(pChain, 1, nAllocatedSize, file);
clock_t t2 = clock();
float fTime = 1.0f * (t2 - t1) / CLOCKS_PER_SEC;
printf("%u bytes read, disk access time: %.2f s\n", nDataRead, fTime);
m_fTotalDiskAccessTime += fTime;
int nRainbowChainCountRead = nDataRead / 16;
// Verify table chunk
if (!fVerified)
{
printf("verifying the file...\n");
// Chain length test
int nIndexToVerify = nRainbowChainCountRead / 2;
CChainWalkContext cwc;
cwc.SetIndex(pChain[nIndexToVerify].nIndexS);
int nPos;
for (nPos = 0; nPos < nRainbowChainLen - 1; nPos++)
{
cwc.IndexToPlain();
cwc.PlainToHash();
cwc.HashToIndex(nPos);
}
if (cwc.GetIndex() != pChain[nIndexToVerify].nIndexE)
{
printf("rainbow chain length verify fail\n");
break;
}
// Chain sort test
int i;
for (i = 0; i < nRainbowChainCountRead - 1; i++)
{
if (pChain[i].nIndexE > pChain[i + 1].nIndexE)
break;
}
if (i != nRainbowChainCountRead - 1)
{
printf("this file is not sorted\n");
break;
}
fVerified = true;
}
// Search table chunk
t1 = clock();
SearchTableChunkOld(pChain, nRainbowChainLen, nRainbowChainCountRead, hs);
t2 = clock();
fTime = 1.0f * (t2 - t1) / CLOCKS_PER_SEC;
printf("cryptanalysis time: %.2f s\n", fTime);
m_fTotalCryptanalysisTime += fTime;
// Already finished?
if (!hs.AnyHashLeftWithLen(CChainWalkContext::GetHashLen()))
break;
}
}
else
printf("memory allocation fail\n");
//delete pChain;
}
else
{
static CMemoryPool mpIndex(bytesForChainWalkSet);
unsigned int nAllocatedSizeIndex;
//int nIndexSize = 0;
//IndexChain *pIndex = NULL;
FILE* fIndex = fopen(((string)(sPathName + string(".index"))).c_str(), "rb");
if(fIndex != NULL)
{
// File length check
unsigned int nFileLenIndex = GetFileLen(fIndex);
unsigned int nRows = nFileLenIndex / 11;
unsigned int nSize = nRows * sizeof(IndexChain);
//printf("Debug: 8\n");
if (nFileLenIndex % 11 != 0)
printf("index file length mismatch (%u bytes)\n", nFileLenIndex);
else
{
//printf("index nSize: %d\n", nSize);
//pIndex = (IndexChain*)new unsigned char[nSize];
IndexChain *pIndex = (IndexChain*)mpIndex.Allocate(nFileLenIndex, nAllocatedSizeIndex);
if (debug) printf("Debug: Allocated %u bytes for index with filelen %u\n", nAllocatedSizeIndex, nFileLenIndex);
if (pIndex != NULL && nAllocatedSizeIndex > 0)
{
nAllocatedSizeIndex = nAllocatedSizeIndex / sizeof(IndexChain) * sizeof(IndexChain); // Round to sizeOfIndexChain boundary
fseek(fIndex, 0, SEEK_SET);
int nProcessedIndexChains = 0;
while (true) // Index chunk read loop
{
if (ftell(fIndex) == nFileLenIndex)
break;
// Load index chunk
if (debug) printf("Debug: Setting index to 0x00 in memory, %u bytes\n", nAllocatedSizeIndex);
memset(pIndex, 0x00, nAllocatedSizeIndex);
printf("reading index... ");
clock_t t1 = clock();
unsigned int nDataRead = fread(pIndex, 1, nAllocatedSizeIndex, fIndex);
clock_t t2 = clock();
float fTime = 1.0f * (t2 - t1) / CLOCKS_PER_SEC;
printf("%u bytes read, disk access time: %.2f s\n", nDataRead, fTime);
m_fTotalDiskAccessTime += fTime;
//nIndexSize = nFileLenIndex / 11;
int nIndexChainCountRead = nDataRead / sizeof(IndexChain);
//fclose(fIndex);
unsigned int nCoveredRainbowTableChains = 0;
for(int i = 0; i < nIndexChainCountRead; i++)
{
nCoveredRainbowTableChains += pIndex[i].nChainCount;
}
//RainbowChain* pChain = (RainbowChain*)mp.Allocate(nFileLen, nAllocatedSize);
RainbowChain* pChain = (RainbowChain*)mp.Allocate(nCoveredRainbowTableChains * sizeOfChain, nAllocatedSize);
if (debug) printf("Debug: Allocated %u bytes for %u chains, filelen %u\n", nAllocatedSize, nCoveredRainbowTableChains, nFileLen);
if (pChain != NULL && nAllocatedSize > 0)
{
nAllocatedSize = nAllocatedSize / sizeOfChain * sizeOfChain; // Round to sizeOfChain boundary
//fseek(file, 0, SEEK_SET);
//bool fVerified = false;
int nProcessedChains = 0;
while (true) // Chunk read loop
{
if (ftell(file) == nFileLen)
break;
if (nProcessedChains >= nCoveredRainbowTableChains)
break;
// Load table chunk
if (debug) printf("Debug: Setting pChain to 0x00 in memory\n");
memset(pChain, 0x00, nAllocatedSize);
printf("reading table... ");
clock_t t1 = clock();
unsigned int nDataRead = fread(pChain, 1, nAllocatedSize, file);
clock_t t2 = clock();
float fTime = 1.0f * (t2 - t1) / CLOCKS_PER_SEC;
printf("%u bytes read, disk access time: %.2f s\n", nDataRead, fTime);
m_fTotalDiskAccessTime += fTime;
int nRainbowChainCountRead = nDataRead / sizeOfChain;
// Verify table chunk (Too lazy to implement this)
if (!fVerified)
{
printf("verifying the file...\n");
// Chain length test
int nIndexToVerify = nRainbowChainCountRead / 2;
CChainWalkContext cwc;
uint64 nIndexS;
nIndexS = pChain[nIndexToVerify].nIndexS & 0x0000FFFFFFFFFFFFULL; // for first 6 bytes
//printf("nIndexS: %s\n", uint64tostr(nIndexS).c_str());
cwc.SetIndex(nIndexS);
int nPos;
for (nPos = 0; nPos < nRainbowChainLen - 1; nPos++)
{
cwc.IndexToPlain();
cwc.PlainToHash();
cwc.HashToIndex(nPos);
}
uint64 nEndPoint = 0;
//for(int i = 0; i < nIndexSize; i++)
for(int i = 0; i < nIndexChainCountRead; i++)
{
if(nIndexToVerify >= pIndex[i].nFirstChain && nIndexToVerify < pIndex[i].nFirstChain + pIndex[i].nChainCount) // We found the matching index
{ // Now we need to seek nIndexToVerify into the chains
nEndPoint += (pIndex[i].nPrefix & 0x000000FFFFFFFFFFULL) << 16; // & 0x000000FFFFFFFFFFULL for first 5 bytes
//printf("nPrefix: %s\n", uint64tostr(pIndex[i].nPrefix & 0x000000FFFFFFFFFF).c_str());
//printf("nFirstChain: %d\n", pIndex[i].nFirstChain);
//printf("nChainCount: %d\n", pIndex[i].nChainCount);
nEndPoint += pChain[nIndexToVerify].nIndexE;
break;
}
}
if (cwc.GetIndex() != nEndPoint)
{
printf("rainbow chain length verify fail\n");
break;
}
fVerified = true;
}
// Search table chunk
t1 = clock();
float preTime = m_fTotalCryptanalysisTime;
SearchTableChunk(pChain, nRainbowChainLen, nRainbowChainCountRead, hs, pIndex, nIndexChainCountRead, nProcessedChains);
float postTime = m_fTotalCryptanalysisTime;
t2 = clock();
fTime = 1.0f * (t2 - t1) / CLOCKS_PER_SEC;
printf("cryptanalysis time: %.2f s\n", fTime + postTime - preTime);
m_fTotalCryptanalysisTime += fTime;
nProcessedChains += nRainbowChainCountRead;
// Already finished?
if (!hs.AnyHashLeftWithLen(CChainWalkContext::GetHashLen()))
break;
}
}
else printf("memory allocation failed for rainbow table\n");
//delete pChain;
}
}
else printf("memory allocation failed for index\n");
}
}
else
{
printf("Can't load index\n");
return;
}
fclose(fIndex);
//delete pIndex;
}
}
fclose(file);
if (debug) printf("Debug: writing progress to %s\n", sProgressPathName.c_str());
FILE* file = fopen(sProgressPathName.c_str(), "a");
if (file!=NULL)
{
string buffer = sPathName + "\n";
fputs (buffer.c_str(), file);
fclose (file);
}
}
else
printf("can't open file\n");
}
void CCrackEngine::Run(vector<string> vPathName, CHashSet& hs, int i_maxThreads, bool resume, bool bDebug)
{
#ifndef _WIN32
tty_init();
#endif
resumeSession = resume;
debug = bDebug;
maxThreads = i_maxThreads;
// Reset statistics
ResetStatistics();
// Sort vPathName (CChainWalkSet need it)
int i, j;
for (i = 0; i < vPathName.size() - 1; i++)
for (j = 0; j < vPathName.size() - i - 1; j++)
{
if (vPathName[j] > vPathName[j + 1])
{
string sTemp;
sTemp = vPathName[j];
vPathName[j] = vPathName[j + 1];
vPathName[j + 1] = sTemp;
}
}
// Run
for (i = 0; i < vPathName.size() && hs.AnyhashLeft(); i++)
{
SearchRainbowTable(vPathName[i], hs);
printf("\n");
}
// delete precalc files
if (!keepPrecalcFiles)
m_cws.removePrecalcFiles();
#ifndef _WIN32
tty_done();
#endif
}
void CCrackEngine::setOutputFile(string sPathName)
{
writeOutput = true;
outputFile = sPathName;
}
void CCrackEngine::setSession(string sSession, string sProgress, string sPrecalc, bool keepPrecalc)
{
sSessionPathName = sSession;
sProgressPathName = sProgress;
sPrecalcPathName = sPrecalc;
keepPrecalcFiles = keepPrecalc;
}
float CCrackEngine::GetStatTotalDiskAccessTime()
{
return m_fTotalDiskAccessTime;
}
/*float CCrackEngine::GetWastedTime()
{
return m_fIndexTime;
}*/
float CCrackEngine::GetStatTotalCryptanalysisTime()
{
return m_fTotalCryptanalysisTime;
}
int CCrackEngine::GetStatTotalChainWalkStep()
{
return m_nTotalChainWalkStep;
}
int CCrackEngine::GetStatTotalFalseAlarm()
{
return m_nTotalFalseAlarm;
}
int CCrackEngine::GetStatTotalChainWalkStepDueToFalseAlarm()
{
return m_nTotalChainWalkStepDueToFalseAlarm;
}
| [
"neinbrucke@d3517bff-0f9d-46f7-b303-814026e826cd"
]
| [
[
[
1,
1336
]
]
]
|
96b591f782e14d3e03bc5c95dbdcb535ee1e2e6b | 96cee9d7834fc2350ef987d0f0db62c94645577d | /graph-theory/general_graph_match.cpp | ded82991c92357ca5eafda28314e1ade589e198c | []
| no_license | fswangke/ACM-ICPC-Code-Template | 25b9344a9685705cbc69503abf0da2c893c3e47a | 81645cc85df1769e0d4ef46d176902dd75131975 | refs/heads/master | 2021-01-24T16:02:34.693024 | 2011-10-29T04:16:57 | 2011-10-29T04:16:57 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 4,285 | cpp | /*
ๅธฆ่ฑๆ ๅผ่ฑ็ฎๆณ
1ใ่ดชๅฟๅๅงๅ
2ใๆพๅฏๅขๅนฟ่ทฏ. ไบค้ๆ . ไธคไธชๅค็นๆ่พน๏ผๅฝขๆ่ฑใ
3ใ็ผฉๅ๏ผ่พนไธค็ซฏ็นๅจๅBไธ็๏ผๆถ็ผฉๆใไป
ไธไธช็ซฏ็นๅฑไบB็ๅๆไปฅVB ไธบไธ็ซฏ็่พนใ
*/
#include <stdio.h>
#include <string.h>
#define MAXV 1008
#define MAXE 200008
#define SBN (sizeof(bool) * (n + 1))
#define SIN (sizeof(int) * (n + 1))
struct Edge {
int v, next;
Edge(){}
Edge(int _v, int _next):
v(_v), next(_next){}
};
struct Graph {
int n, match[MAXV], que[MAXV], pre[MAXV], base[MAXV];
bool flag[MAXV], inBlossom[MAXV], inPath[MAXV];
Edge edge[MAXE];
int head[MAXV], size;
inline void initg(int _n) {
size = 0;
n = _n;
memset(head, -1, SIN);
}
inline void addEdge(int u, int v) {
if (u == v) return;
edge[size] = Edge(v, head[u]);
head[u] = size++;
edge[size] = Edge(u, head[v]);
head[v] = size++;
}
int MaxMatch() {
memset(match, -1, SIN);
int i, j, ans = 0;
for (i = 1; i <= n; ++i) {
if (match[i] != -1) continue;
for (j = head[i]; j != -1 && match[i] == -1; j = edge[j].next)
if (match[edge[j].v] == -1) {
match[edge[j].v] = i;
match[i] = edge[j].v;
ans++;
}
}
for (i = 1; i <= n; ++i)
if (match[i] == -1)
ans += bfs(i);
return ans;
}
int bfs(int p) { //ๅฏปๆพๅฏๅขๅนฟ่ทฏ
int i, j, u, v, b, front, rear;
memset(pre, -1, SIN);
memset(flag, 0, SBN);
for (i = 1; i <= n; ++i)
base[i] = i;
front = rear = 0;
que[rear++] = p;
flag[p] = 1;
while (front != rear) {
u = que[front++];
for (i = head[u]; i != -1; i = edge[i].next) {
v = edge[i].v;
if (base[u] != base[v] && v != match[u]) {
if (v == p || (match[v] != -1 && pre[match[v]] != -1)) {
b = contract(u, v);
for (j = 1; j <= n; ++j) {
if (inBlossom[base[j]]) {
base[j] = b;
if (flag[j] == 0) {
flag[j] = 1;
que[rear++] = j;
}
}
}
}
else if (pre[v] == -1) {
pre[v] = u;
if (match[v] == -1) {
argument(v);
return 1;
}
else {
que[rear++] = match[v];
flag[match[v]] = 1;
}
}
}
}
}
return 0;
}
void argument(int u) { //ๅขๅนฟ
int v, k;
while (u != -1) {
v = pre[u];
k = match[v];
match[u] = v;
match[v] = u;
u = k;
}
}
void changeBlossom(int b, int u) { //ๅชไบ็นๅฑไบๅฝๅๅ
int v;
while (base[u] != b) {
v = match[u];
inBlossom[base[v]] = inBlossom[base[u]] = true;
u = pre[v];
if (base[u] != b)
pre[u] = v;
}
}
int contract(int u, int v) { //็ผฉๅ
memset(inBlossom, 0, SBN);
int b = findBase(base[u], base[v]);
changeBlossom(b, u);
changeBlossom(b, v);
if (base[u] != b)
pre[u] = v;
if (base[v] != b)
pre[v] = u;
return b;
}
int findBase(int u, int v) { //ๅฑไบๅชไธชๅ
memset(inPath, 0, SBN);
while (true) {
inPath[u] = true;
if (match[u] == -1)
break;
u = base[pre[match[u]]];
}
while(!inPath[v])
v = base[pre[match[v]]];
return v;
}
}GP; | [
"[email protected]"
]
| [
[
[
1,
142
]
]
]
|
3dd8ff4a6c69491e078abc5215f8e153d677748d | 028d79ad6dd6bb4114891b8f4840ef9f0e9d4a32 | /src/drivers/skyfox.cpp | c19e343c1c0f3f6131957c434f13d994215b9de8 | []
| no_license | neonichu/iMame4All-for-iPad | 72f56710d2ed7458594838a5152e50c72c2fb67f | 4eb3d4ed2e5ccb5c606fcbcefcb7c5a662ace611 | refs/heads/master | 2020-04-21T07:26:37.595653 | 2011-11-26T12:21:56 | 2011-11-26T12:21:56 | 2,855,022 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,619 | cpp | #include "../vidhrdw/skyfox.cpp"
/***************************************************************************
-= Sky Fox / Exerizer =-
driver by Luca Elia ([email protected])
CPU : Z80A x 2
Sound: YM2203C x 2
Other: 2 HM6116LP-3 (one on each board)
1 KM6264L-15 (on bottom board)
To Do: The background rendering is entirely guesswork
***************************************************************************/
#include "driver.h"
#include "vidhrdw/generic.h"
/* Variables defined in vidhrdw: */
extern int skyfox_bg_pos, skyfox_bg_ctrl;
/* Functions defined in vidhrdw: */
READ_HANDLER ( skyfox_vregs_r );
WRITE_HANDLER( skyfox_vregs_w );
void skyfox_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
void skyfox_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
/***************************************************************************
Main CPU
***************************************************************************/
/***************************************************************************
Sky Fox
***************************************************************************/
static struct MemoryReadAddress skyfox_readmem[] =
{
{ 0x0000, 0xbfff, MRA_ROM }, // ROM
{ 0xc000, 0xdfff, MRA_RAM }, // RAM
{ 0xe000, 0xe000, input_port_0_r }, // Input Ports
{ 0xe001, 0xe001, input_port_1_r }, //
{ 0xe002, 0xe002, input_port_2_r }, //
{ 0xf001, 0xf001, input_port_3_r }, //
// { 0xff00, 0xff07, skyfox_vregs_r }, // fake to read the vregs
{ -1 }
};
static struct MemoryWriteAddress skyfox_writemem[] =
{
{ 0x0000, 0xbfff, MWA_ROM }, // ROM
{ 0xc000, 0xcfff, MWA_RAM }, // RAM
{ 0xd000, 0xd3ff, MWA_RAM, &spriteram, &spriteram_size }, // Sprites
{ 0xd400, 0xdfff, MWA_RAM }, // RAM?
{ 0xe008, 0xe00f, skyfox_vregs_w }, // Video Regs
{ -1 }
};
static struct IOReadPort skyfox_readport[] =
{
{ -1 }
};
static struct IOWritePort skyfox_writeport[] =
{
{ -1 }
};
/***************************************************************************
Sound CPU
***************************************************************************/
/***************************************************************************
Sky Fox
***************************************************************************/
static struct MemoryReadAddress skyfox_sound_readmem[] =
{
{ 0x0000, 0x7fff, MRA_ROM }, // ROM
{ 0x8000, 0x87ff, MRA_RAM }, // RAM
{ 0xa001, 0xa001, YM2203_read_port_0_r }, // YM2203 #1
// { 0xc001, 0xc001, YM2203_read_port_1_r }, // YM2203 #2
{ 0xb000, 0xb000, soundlatch_r }, // From Main CPU
{ -1 }
};
static struct MemoryWriteAddress skyfox_sound_writemem[] =
{
{ 0x0000, 0x7fff, MWA_ROM }, // ROM
{ 0x8000, 0x87ff, MWA_RAM }, // RAM
// { 0x9000, 0x9001, MWA_NOP }, // ??
{ 0xa000, 0xa000, YM2203_control_port_0_w }, // YM2203 #1
{ 0xa001, 0xa001, YM2203_write_port_0_w }, //
// { 0xb000, 0xb001, MWA_NOP }, // ??
{ 0xc000, 0xc000, YM2203_control_port_1_w }, // YM2203 #2
{ 0xc001, 0xc001, YM2203_write_port_1_w }, //
{ -1 }
};
static struct IOReadPort skyfox_sound_readport[] =
{
{ -1 }
};
static struct IOWritePort skyfox_sound_writeport[] =
{
{ -1 }
};
/***************************************************************************
Input Ports
***************************************************************************/
INPUT_PORTS_START( skyfox )
PORT_START // IN0 - Player 1
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
PORT_START // IN1 - DSW
PORT_DIPNAME( 0x01, 0x01, "Unknown 1-0" ) // rest unused?
PORT_DIPSETTING( 0x01, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x02, 0x02, "Unknown 1-1" )
PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x04, 0x04, "Unknown 1-2" )
PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x18, 0x18, DEF_STR( Bonus_Life ) )
PORT_DIPSETTING( 0x00, "20K" )
PORT_DIPSETTING( 0x08, "30K" )
PORT_DIPSETTING( 0x10, "40K" )
PORT_DIPSETTING( 0x18, "50K" )
PORT_DIPNAME( 0x20, 0x20, "Unknown 1-5*" ) // used
PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x40, 0x40, DEF_STR( Flip_Screen ) )
PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x80, 0x00, DEF_STR( Cabinet ) )
PORT_DIPSETTING( 0x00, DEF_STR( Upright ) )
PORT_DIPSETTING( 0x80, DEF_STR( Cocktail ) )
PORT_START // IN2 - Coins + DSW + Vblank
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_VBLANK )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) )
PORT_DIPSETTING( 0x00, "1 Coin/1 Credit 2C/1C" ) // coin A & B
PORT_DIPSETTING( 0x04, "1 Coin/2 Credits 3C/1C" )
PORT_DIPSETTING( 0x08, "1 Coin/3 Credits 4C/1C" )
PORT_DIPSETTING( 0x0c, "1 Coin/4 Credits 5C/1C" )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START // IN3 - DSW
PORT_DIPNAME( 0x07, 0x00, DEF_STR( Lives ) )
PORT_DIPSETTING( 0x00, "1" )
PORT_DIPSETTING( 0x01, "2" )
PORT_DIPSETTING( 0x02, "3" )
PORT_DIPSETTING( 0x03, "4" )
PORT_DIPSETTING( 0x04, "5" )
// PORT_DIPSETTING( 0x05, "5" )
// PORT_DIPSETTING( 0x06, "5" )
PORT_BITX( 0x07, 0x07, IPT_DIPSWITCH_SETTING | IPF_CHEAT, "Infinite", IP_KEY_NONE, IP_JOY_NONE )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START // IN4 - Fake input port, polled every VBLANK to generate an NMI upon coin insertion
PORT_BIT_IMPULSE( 0x01, IP_ACTIVE_LOW, IPT_COIN1, 1 )
PORT_BIT_IMPULSE( 0x02, IP_ACTIVE_LOW, IPT_COIN2, 1 )
INPUT_PORTS_END
/***************************************************************************
Graphics Layouts
***************************************************************************/
/* 8x8x8 tiles (note that the tiles in the ROMs are 32x32x8, but
we cut them in 8x8x8 ones in the init function, in order to
support 8x8, 16x16 and 32x32 sprites. */
static struct GfxLayout layout_8x8x8 =
{
8,8,
RGN_FRAC(1,1),
8,
{0,1,2,3,4,5,6,7},
{0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8},
{0*64,1*64,2*64,3*64,4*64,5*64,6*64,7*64},
8*8*8
};
/***************************************************************************
Sky Fox
***************************************************************************/
static struct GfxDecodeInfo skyfox_gfxdecodeinfo[] =
{
{ REGION_GFX1, 0, &layout_8x8x8, 0, 1 }, // [0] Sprites
{ -1 }
};
/***************************************************************************
Machine Drivers
***************************************************************************/
/***************************************************************************
Sky Fox
***************************************************************************/
/* Check for coin insertion once a frame (polling a fake input port).
Generate an NMI in case. Scroll the background too. */
static int skyfox_interrupt(void)
{
/* Scroll the bg */
skyfox_bg_pos += (skyfox_bg_ctrl >> 1) & 0x7; // maybe..
/* Check coin 1 & 2 */
if ((readinputport(4) & 3) == 3) return ignore_interrupt();
else return nmi_interrupt();
}
static struct YM2203interface skyfox_ym2203_interface =
{
2,
1748000, /* ? same as sound cpu ? */
{ YM2203_VOL(80,80), YM2203_VOL(80,80) },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 }
};
static struct MachineDriver machine_driver_skyfox =
{
{
{
CPU_Z80,
4000000,
skyfox_readmem,skyfox_writemem, skyfox_readport,skyfox_writeport,
skyfox_interrupt, 1 /* NMI caused by coin insertion */
},
{
CPU_Z80 | CPU_AUDIO_CPU,
1748000,
skyfox_sound_readmem,skyfox_sound_writemem, skyfox_sound_readport,skyfox_sound_writeport,
ignore_interrupt, 1 /* No interrupts */
}
},
60,DEFAULT_REAL_60HZ_VBLANK_DURATION, // we're using IPT_VBLANK
1,
0,
/* video hardware */
512, 256, { 0+0x60, 320-1+0x60, 0+16, 256-1-16 }, // from $30*2 to $CC*2+8
skyfox_gfxdecodeinfo,
256+256, 256, /* 256 static colors (+256 for the background??) */
skyfox_vh_convert_color_prom,
VIDEO_TYPE_RASTER,
0,
0, /* No need for a vh_start function for now */
0,
skyfox_vh_screenrefresh,
/* sound hardware */
0,0,0,0,
{
{
SOUND_YM2203,
&skyfox_ym2203_interface
}
}
};
/***************************************************************************
ROMs Loading
***************************************************************************/
/***************************************************************************
Sky Fox
c042 : Lives
c044-5 : Score (BCD)
c048-9 : Power (BCD)
***************************************************************************/
/***************************************************************************
Exerizer [Bootleg]
malcor
Location Type File ID Checksum
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TB 5E 27C256 1-J F302 [ background ]
TB 5N 27C256 1-I F5E3 [ sound ]
LB 27C256 1-A A53E [ program 1 ]
LB 27C256 1-B 382C [ program 2 ]
LB 27C512 1-C CDAC [ GFX ]
LB 27C512 1-D 9C7A [ GFX ]
LB 27C512 1-E D808 [ GFX ]
LB 27C512 1-F F87E [ GFX ]
LB 27C512 1-G 9709 [ GFX ]
LB 27C512 1-H DFDA [ GFX ]
TB 82S129 1.BPR 0972 [ video blue ]
TB 82S129 2.BPR 0972 [ video red ]
TB 82S129 3.BPR 0972 [ video green ]
Lower board ROM locations:
---=======------=======----
| CN2 CN1 |
| 1-A |
| |
| 1-B |
| |
| |
| 1 1 1 1 1 1|
| H G F E D C|
---------------------------
Notes - This archive is of a bootleg copy,
- Japanese program revision
- Although the colour PROMs have the same checksums,
they are not the same.
Main processor - Z80 4MHz
Sound processor - Z80 1.748MHz
- YM2203C x2
***************************************************************************/
ROM_START( skyfox )
ROM_REGION( 0x10000, REGION_CPU1 ) /* Main Z80 Code */
ROM_LOAD( "skyfox1.bin", 0x00000, 0x8000, 0xb4d4bb6f )
ROM_LOAD( "skyfox2.bin", 0x08000, 0x8000, 0xe15e0263 ) // identical halves
ROM_REGION( 0x10000, REGION_CPU2 ) /* Sound Z80 Code */
ROM_LOAD( "skyfox9.bin", 0x00000, 0x8000, 0x0b283bf5 )
ROM_REGION( 0x60000, REGION_GFX1 | REGIONFLAG_DISPOSE ) /* Sprites */
ROM_LOAD( "skyfox3.bin", 0x00000, 0x10000, 0x3a17a929 )
ROM_LOAD( "skyfox4.bin", 0x10000, 0x10000, 0x358053bb )
ROM_LOAD( "skyfox5.bin", 0x20000, 0x10000, 0xc1215a6e )
ROM_LOAD( "skyfox6.bin", 0x30000, 0x10000, 0xcc37e15d )
ROM_LOAD( "skyfox7.bin", 0x40000, 0x10000, 0xfa2ab5b4 )
ROM_LOAD( "skyfox8.bin", 0x50000, 0x10000, 0x0e3edc49 )
ROM_REGION( 0x08000, REGION_GFX2 ) /* Background - do not dispose */
ROM_LOAD( "skyfox10.bin", 0x0000, 0x8000, 0x19f58f9c )
ROM_REGION( 0x300, REGION_PROMS ) /* Color Proms */
ROM_LOAD( "sfoxrprm.bin", 0x000, 0x100, 0x79913c7f ) // R
ROM_LOAD( "sfoxgprm.bin", 0x100, 0x100, 0xfb73d434 ) // G
ROM_LOAD( "sfoxbprm.bin", 0x200, 0x100, 0x60d2ab41 ) // B
ROM_END
ROM_START( exerizrb )
ROM_REGION( 0x10000, REGION_CPU1 ) /* Main Z80 Code */
ROM_LOAD( "1-a", 0x00000, 0x8000, 0x5df72a5d )
ROM_LOAD( "skyfox2.bin", 0x08000, 0x8000, 0xe15e0263 ) // 1-b
ROM_REGION( 0x10000, REGION_CPU2 ) /* Sound Z80 Code */
ROM_LOAD( "skyfox9.bin", 0x00000, 0x8000, 0x0b283bf5 ) // 1-i
ROM_REGION( 0x60000, REGION_GFX1 | REGIONFLAG_DISPOSE ) /* Sprites */
ROM_LOAD( "1-c", 0x00000, 0x10000, 0x450e9381 )
ROM_LOAD( "skyfox4.bin", 0x10000, 0x10000, 0x358053bb ) // 1-d
ROM_LOAD( "1-e", 0x20000, 0x10000, 0x50a38c60 )
ROM_LOAD( "skyfox6.bin", 0x30000, 0x10000, 0xcc37e15d ) // 1-f
ROM_LOAD( "1-g", 0x40000, 0x10000, 0xc9bbfe5c )
ROM_LOAD( "skyfox8.bin", 0x50000, 0x10000, 0x0e3edc49 ) // 1-h
ROM_REGION( 0x08000, REGION_GFX2 ) /* Background - do not dispose */
ROM_LOAD( "skyfox10.bin", 0x0000, 0x8000, 0x19f58f9c ) // 1-j
ROM_REGION( 0x300, REGION_PROMS ) /* Color Proms */
ROM_LOAD( "sfoxrprm.bin", 0x000, 0x100, 0x79913c7f ) // 2-bpr
ROM_LOAD( "sfoxgprm.bin", 0x100, 0x100, 0xfb73d434 ) // 3-bpr
ROM_LOAD( "sfoxbprm.bin", 0x200, 0x100, 0x60d2ab41 ) // 1-bpr
ROM_END
/* Untangle the graphics: cut each 32x32x8 tile in 16 8x8x8 tiles */
void init_skyfox(void)
{
unsigned char *RAM = memory_region(REGION_GFX1);
unsigned char *end = RAM + memory_region_length(REGION_GFX1);
unsigned char buf[32*32];
while (RAM < end)
{
int i;
for (i=0;i<(32*32);i++)
buf[i] = RAM[(i%8) + ((i/8)%8)*32 + ((i/64)%4)*8 + (i/256)*256];
memcpy(RAM,buf,32*32);
RAM += 32*32;
}
}
GAME( 1987, skyfox, 0, skyfox, skyfox, skyfox, ROT90_16BIT, "Jaleco (Nichibutsu USA License)", "Sky Fox" )
GAME( 1987, exerizrb, skyfox, skyfox, skyfox, skyfox, ROT90_16BIT, "Jaleco", "Exerizer (Japan) (bootleg)" )
| [
"[email protected]"
]
| [
[
[
1,
489
]
]
]
|
3e9017deb139601975e0bc47a5dfe78c6e57b4a2 | b8fbe9079ce8996e739b476d226e73d4ec8e255c | /src/engine/rb_ui/jpopupmenu.h | 8e0f4767a8c39da3aaf0ed9026ad0127a91d5574 | []
| no_license | dtbinh/rush | 4294f84de1b6e6cc286aaa1dd48cf12b12a467d0 | ad75072777438c564ccaa29af43e2a9fd2c51266 | refs/heads/master | 2021-01-15T17:14:48.417847 | 2011-06-16T17:41:20 | 2011-06-16T17:41:20 | 41,476,633 | 1 | 0 | null | 2015-08-27T09:03:44 | 2015-08-27T09:03:44 | null | UTF-8 | C++ | false | false | 757 | h | //****************************************************************************/
// File: JPopupMenu.h
// Date: 22.09.2005
// Author: Ruslan Shestopalyuk
//****************************************************************************/
#ifndef __JPOPUPMENU_H__
#define __JPOPUPMENU_H__
//****************************************************************************/
// Class: JPopupMenu
// Desc:
//****************************************************************************/
class JPopupMenu : public JListBox
{
public:
JPopupMenu ();
virtual void Render ();
expose( JPopupMenu )
{
parent(JListBox);
}
}; // class JPopupMenu
#endif // __JPOPUPMENU_H__
| [
"[email protected]"
]
| [
[
[
1,
27
]
]
]
|
1e9d4795254b1e4f9403a89fe0cbb3e48603d76c | 941e1c9c87576247aac5c28db16e2d73a2bec0af | /gmsrole.cpp | 5815649458886a5618293297525144170d492a6e | []
| no_license | luochong/vc-gms-1 | 49a5ccc2edd3da74da2a7d9271352db8213324cb | 607b087e37cc0946b4562b681bb65875863bc084 | refs/heads/master | 2016-09-06T09:32:16.340313 | 2009-06-14T07:35:19 | 2009-06-14T07:35:19 | 32,432,320 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,133 | cpp | // GMSRole.cpp: implementation of the CGMSRole class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "mygms.h"
#include "GMSRole.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CGMSRole::CGMSRole()
{
for(int i = 0; i < N; i++)
{
ClrAction(i);
}
m_admin_code = "";
m_admin_name = "";
m_admin_role = 0;
}
CGMSRole::~CGMSRole()
{
}
/**
็ฎก็ๅ็ปๅฝ
**/
bool CGMSRole::Login(CString Admin_name,CString Admin_password){
_variant_t strQuery;
strQuery = "SELECT * FROM admin WHERE Admin_name='"+Admin_name+ "' AND Admin_passwd='" + Admin_password+ "'";
theApp.ADOExecute(theApp.m_pRs, strQuery);
int iCount = theApp.m_pRs->GetRecordCount();
_variant_t Holder;
if ( 0==iCount )
{
return false;
}
else
{
Holder = theApp.m_pRs->GetCollect("Admin_code");
this->m_admin_code = (char*)(_bstr_t)Holder;
Holder = theApp.m_pRs->GetCollect("Admin_name");
this->m_admin_name = (char*)(_bstr_t)Holder;
Holder = theApp.m_pRs->GetCollect("Admin_role");
this->m_admin_role = Holder.intVal;
SetRoleAction();
return true;
}
}
/**
็ฎก็ๅ็ปๅฝ
**/
void CGMSRole::SetRoleAction(){
switch(m_admin_role){
case SUPER_ADMIN:
SetAction(OUT_ACTION) ;
SetAction(IN_ACTION) ;
SetAction(GOODS_ACTION) ;
SetAction(CATE_ACTION) ;
SetAction(ADMIN_ACTION);
break;
case IN_ADMIN:
SetAction(IN_ACTION);
SetAction(CATE_ACTION);
break;
case OUT_ADMIN:
SetAction(OUT_ACTION);
SetAction(CATE_ACTION);
break;
}
}
CGMSRole* CGMSRole::_instance = 0;
CGMSRole* CGMSRole::Instance(){
if(!_instance)
{
_instance = new CGMSRole();
}
return _instance;
} | [
"luochong1987@29d93fdc-527c-11de-bf49-a932634fd5a9"
]
| [
[
[
1,
110
]
]
]
|
17c9331915c41359d2bc0827aea2c49ade56ebe1 | 8bbbcc2bd210d5608613c5c591a4c0025ac1f06b | /nes/mapper/114.cpp | ed740d6ca6bb7cb71f7d7ff457574b2bb28d2e0f | []
| no_license | PSP-Archive/NesterJ-takka | 140786083b1676aaf91d608882e5f3aaa4d2c53d | 41c90388a777c63c731beb185e924820ffd05f93 | refs/heads/master | 2023-04-16T11:36:56.127438 | 2008-12-07T01:39:17 | 2008-12-07T01:39:17 | 357,617,280 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,551 | cpp | #ifdef _NES_MAPPER_CPP_
/////////////////////////////////////////////////////////////////////
// Mapper 114
void NES_mapper114_Init()
{
g_NESmapper.Reset = NES_mapper114_Reset;
g_NESmapper.MemoryWrite = NES_mapper114_MemoryWrite;
}
void NES_mapper114_Reset()
{
// set CPU bank pointers
g_NESmapper.set_CPU_banks4(0, 1, g_NESmapper.num_8k_ROM_banks-2, g_NESmapper.num_8k_ROM_banks-1);
g_NESmapper.Mapper114.regs[0]=0;
// set PPU bank pointers
if(g_NESmapper.num_1k_VROM_banks)
{
g_NESmapper.set_PPU_banks8(0,1,2,3,4,5,6,7);
}
}
void NES_mapper114_MemoryWrite(uint32 addr, uint8 data)
{
// char f=0;
switch(addr&0xf000){
case 0xA000:
g_NESmapper.set_CPU_bank4(data);
break;
case 0xC000:
g_NESmapper.set_CPU_bank5(data);
break;
/* case 0x8000:
set_CPU_bank4(data&0x0f);
break;
case 0x8000:
set_CPU_bank4(data&0x0f);
break;*/
// case 0xC004:
// set_PPU_bank1(data);
// break;
}
LOG("W " << HEX(addr,4) << " " << HEX(data,2) << " " << HEX(g_NESmapper.Mapper114.regs[0],2) << endl);
}
#if 0
void NES_mapper114_HSync(uint32 scanline)
{
if(g_NESmapper.Mapper114.irq_enabled)
{
if(scanline<241){
g_NESmapper.Mapper114.irq_counter--;
if(g_NESmapper.Mapper114.irq_counter<=0){
NES6502_DoIRQ();
g_NESmapper.Mapper114.irq_enabled = 0;
g_NESmapper.Mapper114.irq_counter = g_NESmapper.Mapper114.irq_latch;
}
}
}
}
#endif
/////////////////////////////////////////////////////////////////////
#endif
| [
"takka@e750ed6d-7236-0410-a570-cc313d6b6496"
]
| [
[
[
1,
67
]
]
]
|
b5f727aa24580b44422b8e224e21fcbc50fe2a75 | fac8de123987842827a68da1b580f1361926ab67 | /inc/physics/Animation/Animation/Rig/hkaBone.h | d7796de031445a28252d37d0f2be73fa9cd30fce | []
| no_license | blockspacer/transporter-game | 23496e1651b3c19f6727712a5652f8e49c45c076 | 083ae2ee48fcab2c7d8a68670a71be4d09954428 | refs/heads/master | 2021-05-31T04:06:07.101459 | 2009-02-19T20:59:59 | 2009-02-19T20:59:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,777 | h | /*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent.This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2008 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
#ifndef HKANIMATION_RIG_HKBONE_HKCLASS_H
#define HKANIMATION_RIG_HKBONE_HKCLASS_H
/// hkaBone meta information
extern const class hkClass hkaBoneClass;
/// The bone structure as seen by the toolchain.
class hkaBone
{
public:
HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_ANIM_RIG, hkaBone );
HK_DECLARE_REFLECTION();
//
// Members
//
public:
/// The name of the bone from the toolchain
char * m_name;
/// Whether or not this bone can move relative to its parent
hkBool m_lockTranslation;
};
#endif // HKANIMATION_RIG_HKBONE_HKCLASS_H
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20080529)
*
* Confidential Information of Havok. (C) Copyright 1999-2008
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at
* www.havok.com/tryhavok
*
*/
| [
"uraymeiviar@bb790a93-564d-0410-8b31-212e73dc95e4"
]
| [
[
[
1,
51
]
]
]
|
e4fc5e978caccad884784cb5021322ba1fb2462f | 521721c2e095daf757ad62a267b1c0f724561935 | /bsMesh.h | 054bdc12177b1c66c59266699fc6e51c38cb9ff7 | []
| no_license | MichaelSPG/boms | 251922d78f2db85ece495e067bd56a1e9fae14b1 | 23a13010e0aaa79fea3b7cf1b23e2faab02fa5d4 | refs/heads/master | 2021-01-10T16:23:51.722062 | 2011-12-08T00:04:33 | 2011-12-08T00:04:33 | 48,052,727 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,616 | h | #pragma once
#include <vector>
#include <numeric>
#include <Windows.h>
#include <d3d11.h>
#include "bsCollision.h"
class bsDx11Renderer;
class bsEntity;
/* Class containing a single mesh.
Contains vertex and index buffers, and can render itself.
*/
__declspec(align(16)) class bsMesh
{
public:
inline void* operator new(size_t)
{
return _aligned_malloc(sizeof(bsMesh), 16);
}
inline void operator delete(void* p)
{
_aligned_free(p);
}
//For container purposes only, do not use this constructor.
inline bsMesh(unsigned int id)
: mID(id)
, mLoadingFinished(false)
{}
/* Creates a mesh given a unique ID, vertex and index buffer(s), index count for each
index/vertex buffer pair, and an AABB whose extents covers every single vertex
in the vertex buffer.
*/
bsMesh(unsigned int id, std::vector<ID3D11Buffer*>&& vertexBuffers,
std::vector<ID3D11Buffer*>&& indexBuffers,
std::vector<unsigned int>&& indexCounts, std::vector<unsigned int>&& vertexCounts,
const bsCollision::Sphere& boundingSphere);
~bsMesh();
bsMesh& operator=(bsMesh&& other);
/* Renders the mesh using instancing.
*/
void drawInstanced(ID3D11DeviceContext& deviceContext, ID3D11Buffer* instanceBuffer,
unsigned int instanceCount) const;
/* Returns true if this mesh has finished loading and is ready to be rendered.
*/
inline bool hasFinishedLoading() const
{
return mLoadingFinished;
}
void attachedToEntity(bsEntity& entity);
/* Returns the total amount of triangles in this mesh.
*/
inline unsigned int getTriangleCount() const
{
return (unsigned int)std::accumulate(std::begin(mVertexCounts),
std::end(mVertexCounts), 0) / 3;
}
inline const std::vector<ID3D11Buffer*>& getVertexBuffers() const
{
return mVertexBuffers;
}
inline const std::vector<ID3D11Buffer*>& getIndexBuffers() const
{
return mIndexBuffers;
}
inline const std::vector<unsigned int>& getIndexCounts() const
{
return mIndexCounts;
}
inline const bsCollision::Sphere& getBoundingSphere() const
{
return mBoundingSphere;
}
private:
//Not copyable
bsMesh(const bsMesh&);
void operator=(const bsMesh&);
bsCollision::Sphere mBoundingSphere;
std::vector<ID3D11Buffer*> mVertexBuffers;
std::vector<ID3D11Buffer*> mIndexBuffers;
std::vector<unsigned int> mIndexCounts;
std::vector<unsigned int> mVertexCounts;
unsigned int mID;
//0 if loading is not finished, positive value otherwise.
volatile unsigned int mLoadingFinished;
std::vector<bsEntity*> mEntities;
};
| [
"[email protected]"
]
| [
[
[
1,
112
]
]
]
|
6ca6cd6cd73ab7d65cad72807ddcc31c710b276c | cd07acbe92f87b59260478f62a6f8d7d1e218ba9 | /src/StdAfx.cpp | 17ab79b33715e819dd56791ca9757f64891841a3 | []
| no_license | niepp/sperm-x | 3a071783e573d0c4bae67c2a7f0fe9959516060d | e8f578c640347ca186248527acf82262adb5d327 | refs/heads/master | 2021-01-10T06:27:15.004646 | 2011-09-24T03:33:21 | 2011-09-24T03:33:21 | 46,690,957 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 293 | cpp | // stdafx.cpp : source file that includes just the standard includes
// Sperm.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#ifdef _ATL_STATIC_REGISTRY
#include <statreg.h>
#endif
#include <atlimpl.cpp>
| [
"harithchen@e030fd90-5f31-5877-223c-63bd88aa7192"
]
| [
[
[
1,
13
]
]
]
|
f9011127be34ebe73331f7b39865ffab77ff8b13 | 9d3fb15c6c417ce0f2354a11cdb094bdcf2e8a46 | /nxtOSEK/etrobo2009sample_cpp/NXTway_GS.cpp | 0315887491ce997ffffd928844af3939a50906d2 | []
| no_license | ngoclt-28/robo2011sample | af19f552c13ddaf7ffd5b90d9464f3db271fe86f | be4199623256646673eacea8eda9044927952a6d | refs/heads/master | 2021-01-17T14:26:03.163227 | 2011-08-06T07:47:39 | 2011-08-06T07:47:39 | null | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,417 | cpp | //
// NXTway_GS.cpp
//
#include "NXTway_GS.h"
NXTway_GS::NXTway_GS(const Nxt& nxt, const GyroSensor& gyro, Motor& motorL, Motor& motorR)
:
mrNxt(nxt),
mrGyro(gyro),
mrMotorL(motorL),
mrMotorR(motorR)
{
this->reset();
}
//=============================================================================
// ๅถๅพกๅๆๅ
void NXTway_GS::reset(S16 offset)
{
// ใขใผใฟใชใปใใ
mrMotorL.reset();
mrMotorR.reset();
// ๅ็ซๆฏๅญๅถๅพกใฎๅๆๅ
balance_init();
this->setGyroOffset(offset);
}
//=============================================================================
// ใธใฃใคใญใปใณใตใชใใปใใๅคใฎ่จญๅฎ
void NXTway_GS::setGyroOffset(S16 offset)
{
mGyroOffset = offset;
}
//=============================================================================
// ใใฉใคใใผๅฝไปคใซใใ2่ผชๅ็ซๆฏๅญ่ตฐ่กไฝใฎๅถๅพก
void NXTway_GS::drive(Driver* driver)
{
S8 pwmL, pwmR;
VectorT<S8> command = driver->getCommand();
balance_control(
(F32)command.mX, // ๅๅพ้ฒๅฝไปค
(F32)command.mY, // ๆๅๅฝไปค
(F32)mrGyro.get(),
(F32)mGyroOffset,
(F32)mrMotorL.getCount(),
(F32)mrMotorR.getCount(),
(F32)mrNxt.getBattMv(),
&pwmL,
&pwmR);
mrMotorL.setPWM(pwmL);
mrMotorR.setPWM(pwmR);
}
| [
"[email protected]"
]
| [
[
[
1,
59
]
]
]
|
9aa7a63f0e552c0e0f5cb95e7fd2f2cfdbf96248 | b584a7655fb6af59d1f31cb27e34140f95df8fd4 | / cs112-final-w07/src/cube.cpp | 8eeb013f04dd94ee46b5b93c43b0d8f26298985a | []
| no_license | jamoozy/cs112-final-w07 | 4e77749a346d0a172df8197a198785736b3a3a4d | 15d3686c1902cf5504247382dc4f5d33d3fceecd | refs/heads/master | 2016-09-06T01:02:52.609264 | 2007-03-20T08:16:21 | 2007-03-20T08:16:21 | 41,124,707 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,379 | cpp | #include "cube.h"
#include "inputModule.h"
extern int wire;
#define BACK 0
#define FRONT 1
#define LEFT 2
#define RIGHT 3
#define BOTTOM 4
#define TOP 5
#define X_COOR 0
#define Y_COOR 1
#define Z_COOR 2
static double cube_offset[3] = {1,1,1};
static float cubeColors[6][4] =
{
{0.8, 0.8, 0.8, 1.0},
{0.8, 0.0, 0.0, 1.0},
{0.0, 0.8, 0.0, 1.0},
{0.0, 0.0, 0.8, 1.0},
{0.0, 0.8, 0.8, 1.0},
{0.8, 0.0, 0.8, 1.0}
};
static float cubeColors1[6][4] =
{
{0.6, 0, 0.6, 1.0},
{0.7, 0.8, 0.7, 1.0},
{0.3, 0.3, 0, 1.0},
{0.0, 0.0, 0.0, 1.0},
{0.4, 0.4, 0.4, 1.0},
{0.3, 0.5, 0, 1.0},
};
static float revolverColors[6][4] =
{
{0.18, 0.18, 0.18, 1.0},
{0.18, 0.0, 0.0, 1.0},
{0.0, 0.18, 0.0, 1.0},
{0.0, 0.0, 0.18, 1.0},
{0.0, 0.18, 0.18, 1.0},
{0.18, 0.0, 0.18, 1.0},
};
static float revolverVertexes[6][4][3] =
{
{
{1, -0.1, -0.1},
{1, -0.1, 0.1},
{1, 0.1, 0.1},
{1, 0.1, -0.1}},
{
{1.2, 0.1, 0.1},
{1.2, -0.1, 0.1},
{1.2, -0.1, -0.1},
{1.2, 0.1, -0.1}},
{
{1, -0.1, -0.1},
{1.2, -0.1, -0.1},
{1.2, -0.1, 0.1},
{1, -0.1, 0.1}},
{
{1.2, 0.1, 0.1},
{1.2, 0.1, -0.1},
{1, 0.1, -0.1},
{1, 0.1, 0.1}},
{
{1, -0.1, -0.1},
{1, 0.1, -0.1},
{1.2, 0.1, -0.1},
{1.2, -0.1, -0.1}},
{
{1.2, 0.1, 0.1},
{1, 0.1, 0.1},
{1, -0.1, 0.1},
{1.2, -0.1, 0.1}}
};
static float roomVertexes[6][4][3] =
{
{
{-2, -2, -2},
{-2, -2, 2},
{-2, 2, 2},
{-2, 2, -2}},
{
{2, 2, 2},
{2, -2, 2},
{2, -2, -2},
{2, 2, -2}},
{
{-2, -2, -2},
{2, -2, -2},
{2, -2, 2},
{-2, -2, 2}},
{
{2, 2, 2},
{2, 2, -2},
{-2, 2, -2},
{-2, 2, 2}},
{
{-2, -2, -2},
{-2, 2, -2},
{2, 2, -2},
{2, -2, -2}},
{
{2, 2, 2},
{-2, 2, 2},
{-2, -2, 2},
{2, -2, 2}}
};
static float cubeVertexes[6][4][3] =
{
{
{-0.3, -0.3, -0.3},
{-0.3, -0.3, 0.3},
{-0.3, 0.3, 0.3},
{-0.3, 0.3, -0.3}},
{
{0.3, 0.3, 0.3},
{0.3, -0.3, 0.3},
{0.3, -0.3, -0.3},
{0.3, 0.3, -0.3}},
{
{-0.3, -0.3, -0.3},
{0.3, -0.3, -0.3},
{0.3, -0.3, 0.3},
{-0.3, -0.3, 0.3}},
{
{0.3, 0.3, 0.3},
{0.3, 0.3, -0.3},
{-0.3, 0.3, -0.3},
{-0.3, 0.3, 0.3}},
{
{-0.3, -0.3, -0.3},
{-0.3, 0.3, -0.3},
{0.3, 0.3, -0.3},
{0.3, -0.3, -0.3}},
{
{0.3, 0.3, 0.3},
{-0.3, 0.3, 0.3},
{-0.3, -0.3, 0.3},
{0.3, -0.3, 0.3}}
};
static float cubeVertexes1[6][4][3] =
{
{
{-1.8, -1.8, -1.8},
{-1.8, -1.8, -1.3},
{-1.8, -1.3, -1.3},
{-1.8, -1.3, -1.8}},
{
{-1.3, -1.3, -1.3},
{-1.3, -1.8, -1.3},
{-1.3, -1.8, -1.8},
{-1.3, -1.3, -1.8}},
{
{-1.8, -1.8, -1.8},
{-1.3, -1.8, -1.8},
{-1.3, -1.8, -1.3},
{-1.8, -1.8, -1.3}},
{
{-1.3, -1.3, -1.3},
{-1.3, -1.3, -1.8},
{-1.8, -1.3, -1.8},
{-1.8, -1.3, -1.3}},
{
{-1.8, -1.8, -1.8},
{-1.8, -1.3, -1.8},
{-1.3, -1.3, -1.8},
{-1.3, -1.8, -1.8}},
{
{-1.3, -1.3, -1.3},
{-1.8, -1.3, -1.3},
{-1.8, -1.8, -1.3},
{-1.3, -1.8, -1.3}}
};
typedef float Vector3f[3];
Vector3f cubeRandomvector,cubeRandomvector1, revolverRandomvector;
double rangerand(double min, double max, long steps)
{
return min + ((rand() % steps) * (max - min)) / steps;
}
void moveSpinnerRevolver()
{
static bool isFirstTime = true;
if (isFirstTime)
{
//initialize: separate the cubes (they initially are located at the orginal
//of the 3D world, so first need to move them apart)
for (int i=0; i<5; i++)
{
drawCube();
drawRevolver();
}
isFirstTime = false;
}
// CheckAllCollisions(cubeVertexes,
// cubeVertexes1,
// revolverVertexes,
// roomVertexes);
drawRevolver();
// CheckAllCollisions(cubeVertexes,
// cubeVertexes1,
// revolverVertexes,
// roomVertexes);
drawCube();
CheckAllCollisions(cubeVertexes,
cubeVertexes1,
revolverVertexes,
roomVertexes);
drawCube1();
drawRoom();
glutPostRedisplay();
}
void drawRoom()
{
// set antialiasingand wire-frame rendering mode
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glEnable(GL_POLYGON_SMOOTH);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(2.5);
glColor3f(0.0, 0.0, 0.0);
// draw each cube face as an individual polygon
for (int i = 0; i < 6; i++) {
glBegin(GL_POLYGON);
glVertex3fv(&roomVertexes[i][0][0]);
glVertex3fv(&roomVertexes[i][1][0]);
glVertex3fv(&roomVertexes[i][2][0]);
glVertex3fv(&roomVertexes[i][3][0]);
glEnd();
}
}
void moveCube(double x, double y, double z)
{
for (int i = 0; i < 6; i++)
{
cubeVertexes[i][0][0] += x;
cubeVertexes[i][1][0] += x;
cubeVertexes[i][2][0] += x;
cubeVertexes[i][3][0] += x;
cubeVertexes[i][0][1] += y;
cubeVertexes[i][1][1] += y;
cubeVertexes[i][2][1] += y;
cubeVertexes[i][3][1] += y;
cubeVertexes[i][0][2] += z;
cubeVertexes[i][1][2] += z;
cubeVertexes[i][2][2] += z;
cubeVertexes[i][3][2] += z;
}
}
void drawCube()
{
//-------------------------------------
//make the First Cube move randomly
//-------------------------------------
// static bool firstTime = true;
// if (firstTime)
// {
// cubeRandomvector[0] = -0.01;
// cubeRandomvector[1] = 0.02;
// cubeRandomvector[2] = 0.03;
//
// /*cubeRandomvector[0] = rangerand(-0.2, 0.2, 10);
// cubeRandomvector[1] = rangerand(-0.2, 0.2, 10);
// cubeRandomvector[2] = rangerand(-0.2, 0.2, 10);*/
//
// firstTime = false;
// }
// for (int i = 0; i < 6; i++)
// {
// for (int j=0; j<3; j++)
// {
// cubeVertexes[i][0][j] += cubeRandomvector[j];
// cubeVertexes[i][1][j] += cubeRandomvector[j];
// cubeVertexes[i][2][j] += cubeRandomvector[j];
// cubeVertexes[i][3][j] += cubeRandomvector[j];
// }
// }
if (!wire) {
glDisable(GL_BLEND);
glDisable(GL_POLYGON_SMOOTH);
// set polygon fill mode
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
// draw each cube face as an individual polygon
{
for (int i = 0; i < 6; i++) {
glBegin(GL_POLYGON);
glColor3fv(&cubeColors[i][0]);
glVertex3fv(&cubeVertexes[i][0][0]);
glVertex3fv(&cubeVertexes[i][1][0]);
glVertex3fv(&cubeVertexes[i][2][0]);
glVertex3fv(&cubeVertexes[i][3][0]);
glEnd();
}
}
} else {
// set antialiasingand wire-frame rendering mode
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glEnable(GL_POLYGON_SMOOTH);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(2.5);
glColor3f(0.0, 0.0, 0.0);
// draw each cube face as an individual polygon
{
for (int i = 0; i < 6; i++) {
glBegin(GL_POLYGON);
glVertex3fv(&cubeVertexes[i][0][0]);
glVertex3fv(&cubeVertexes[i][1][0]);
glVertex3fv(&cubeVertexes[i][2][0]);
glVertex3fv(&cubeVertexes[i][3][0]);
glEnd();
}
}
}
}
void drawCube1()
{
//-------------------------------------
//make the First Cube move randomly
//-------------------------------------
static bool firstTime = true;
if (firstTime)
{
cubeRandomvector1[0] = 0.02;
cubeRandomvector1[1] = 0.01;
cubeRandomvector1[2] = -0.08;
firstTime = false;
}
for (int i = 0; i < 6; i++)
{
for (int j=0; j<3; j++)
{
cubeVertexes1[i][0][j] += cubeRandomvector1[j];
cubeVertexes1[i][1][j] += cubeRandomvector1[j];
cubeVertexes1[i][2][j] += cubeRandomvector1[j];
cubeVertexes1[i][3][j] += cubeRandomvector1[j];
}
}
if (!wire) {
glDisable(GL_BLEND);
glDisable(GL_POLYGON_SMOOTH);
// set polygon fill mode
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
// draw each cube face as an individual polygon
{
for (int i = 0; i < 6; i++) {
glBegin(GL_POLYGON);
glColor3fv(&cubeColors1[i][0]);
glVertex3fv(&cubeVertexes1[i][0][0]);
glVertex3fv(&cubeVertexes1[i][1][0]);
glVertex3fv(&cubeVertexes1[i][2][0]);
glVertex3fv(&cubeVertexes1[i][3][0]);
glEnd();
}
}
} else {
// set antialiasingand wire-frame rendering mode
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glEnable(GL_POLYGON_SMOOTH);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(2.5);
glColor3f(0.0, 0.0, 0.0);
// draw each cube face as an individual polygon
{
for (int i = 0; i < 6; i++) {
glBegin(GL_POLYGON);
glVertex3fv(&cubeVertexes1[i][0][0]);
glVertex3fv(&cubeVertexes1[i][1][0]);
glVertex3fv(&cubeVertexes1[i][2][0]);
glVertex3fv(&cubeVertexes1[i][3][0]);
glEnd();
}
}
}
}
void drawRevolver()
{
//-------------------------------------
//make the Small Cube move randomly
//-------------------------------------
static bool firstTime = true;
if (firstTime)
{
revolverRandomvector[0] = 0.01;
revolverRandomvector[1] = -0.02;
revolverRandomvector[2] = -0.01;
firstTime = false;
}
for (int i = 0; i < 6; i++)
{
for (int j=0; j<3; j++)
{
revolverVertexes[i][0][j] += revolverRandomvector[j];
revolverVertexes[i][1][j] += revolverRandomvector[j];
revolverVertexes[i][2][j] += revolverRandomvector[j];
revolverVertexes[i][3][j] += revolverRandomvector[j];
}
}
if (!wire) {
glDisable(GL_BLEND);
glDisable(GL_POLYGON_SMOOTH);
// set polygon fill mode
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
// draw each cube face as an individual polygon
{
for (int i = 0; i < 6; i++) {
glBegin(GL_POLYGON);
glColor3fv(&revolverColors[i][0]);
glVertex3fv(&revolverVertexes[i][0][0]);
glVertex3fv(&revolverVertexes[i][1][0]);
glVertex3fv(&revolverVertexes[i][2][0]);
glVertex3fv(&revolverVertexes[i][3][0]);
glEnd();
}
}
} else {
// set antialiasingand wire-frame rendering mode
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glEnable(GL_POLYGON_SMOOTH);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(2.5);
glColor3f(0.0, 0.0, 0.0);
// draw each cube face as an individual polygon
{
for (int i = 0; i < 6; i++) {
glBegin(GL_POLYGON);
glVertex3fv(&revolverVertexes[i][0][0]);
glVertex3fv(&revolverVertexes[i][1][0]);
glVertex3fv(&revolverVertexes[i][2][0]);
glVertex3fv(&revolverVertexes[i][3][0]);
glEnd();
}
}
}
}
//-------------------------------------------------------------
//change the move vector of a cube each time collision occurs
//-------------------------------------------------------------
void InvertMoveVector(Vector3f& vector, int hitCount, Vector3i faceHit)
{
for (int i=0;i<hitCount; i++)
{
int face = faceHit[i];
if (face == FRONT)
{
vector[X_COOR] = -(vector[X_COOR]);
}
else if (face == BACK)
{
vector[X_COOR] = -(vector[X_COOR]);
}
else if (face == LEFT)
{
vector[Y_COOR] = -(vector[Y_COOR]);
}
else if (face == RIGHT)
{
vector[Y_COOR] = -(vector[Y_COOR]);
}
else if (face == BOTTOM)
{
vector[Z_COOR] = -(vector[Z_COOR]);
}
else if (face == TOP)
{
vector[Z_COOR] = -(vector[Z_COOR]);
}
}
}
//-------------------------------------------------------------
//Check collision among all objects in our 3D world
//-------------------------------------------------------------
bool CheckAllCollisions(GLfloat TMPcubeVertexes[6][4][3],
GLfloat TMPcubeVertexes1[6][4][3],
GLfloat TMPrevolverVertexes[6][4][3],
GLfloat TMProomVertexes[6][4][3])
{
Vector3i faceHit;
bool collided = false;
//collision between Cube & Room
int hitCount = Collide(TMPcubeVertexes, TMProomVertexes, true, faceHit);
if (hitCount > 0)
{
collided = true;
InvertMoveVector(cubeRandomvector, hitCount, faceHit);
}
//collision between Cube1 & Room
hitCount = Collide(TMPcubeVertexes1, TMProomVertexes, true, faceHit);
if (hitCount > 0)
{
collided = true;
InvertMoveVector(cubeRandomvector1, hitCount, faceHit);
}
//collision between Small & Room
hitCount = Collide(TMPrevolverVertexes, TMProomVertexes, true, faceHit);
if (hitCount > 0)
{
collided = true;
InvertMoveVector(revolverRandomvector, hitCount, faceHit );
}
//collision between Cube & Small
hitCount = Collide(TMPrevolverVertexes, TMPcubeVertexes, false, faceHit);
if (hitCount > 0)
{
collided = true;
for (int c=0; c<3; c++)
{
cubeRandomvector[c] = -cubeRandomvector[c];
revolverRandomvector[c] = -revolverRandomvector[c];
}
}
//collision between Cube1 & Small
hitCount = Collide(TMPrevolverVertexes, TMPcubeVertexes1, false, faceHit);
if (hitCount > 0)
{
collided = true;
for (int c=0; c<3; c++)
{
cubeRandomvector1[c] = -cubeRandomvector1[c];
revolverRandomvector[c] = -revolverRandomvector[c];
}
}
//collision between Cube & Cube1
hitCount = Collide(TMPcubeVertexes1, TMPcubeVertexes, false, faceHit);
if (hitCount > 0)
{
collided = true;
for (int c=0; c<3; c++)
{
cubeRandomvector[c] = -cubeRandomvector[c];
cubeRandomvector1[c] = -cubeRandomvector1[c];
}
}
return collided;
}
//-------------------------------------------------------------
//Check collision between 2 cubes
//-------------------------------------------------------------
int Collide(GLfloat cube1[6][4][3], GLfloat cube2[6][4][3], bool mustBeInTheBox,
Vector3i& faceHit)
{
int hitCount = 0;
for (int face=BACK; face<=FRONT; face++)
{
//just need to check 8 vertices in BACK and FRONT faces
if ((face==BACK) || (face==FRONT))
{
for (int vertex=0; vertex<4; vertex++)
{
if (mustBeInTheBox)
{
//hitCount=0: inside the box
hitCount = IsVertexInBox(cube1[face][vertex], cube2, faceHit, mustBeInTheBox);
if (hitCount == 0)
{
if (!mustBeInTheBox)
return hitCount;
}
else
{
if (mustBeInTheBox)
return hitCount;
}
}
else
{
Vector3f ver;
ver[0] = cube1[face][vertex][0];
ver[1] = cube1[face][vertex][1];
ver[2] = cube1[face][vertex][2];
if (( ver[0] > cube2[BACK][0][X_COOR])
&& (ver[0] < cube2[FRONT][0][X_COOR])
&& (ver[1] > cube2[BACK][0][Y_COOR])
&& (ver[1] < cube2[FRONT][0][Y_COOR])
&& (ver[2] > cube2[BACK][0][Z_COOR])
&& (ver[2] < cube2[FRONT][0][Z_COOR]))
{
faceHit[hitCount++] = face;
return 1;
}
}
}
}
}
return 0;
}
//-------------------------------------------------------------
//
//-------------------------------------------------------------
//NOTE: check whether a point is within a bounding box
//ADVANTAGE: can be pipelined to boost performance
int IsVertexInBox(Vector3f vertex, GLfloat cube[6][4][3],
Vector3i& faceHit, bool mustBeInside)
{
// float x=vertex[0],y=vertex[1],z=vertex[2];
int hitCount=0;
//go through six faces of the cube
for (int face=BACK; face<=TOP; face++)
{
switch (face)
{
case BACK:
//behind the BACK FACE
if ( ((vertex[X_COOR] <= cube[face][0][X_COOR]) && mustBeInside)
|| ((vertex[X_COOR] > cube[face][0][X_COOR]) && !mustBeInside) )
faceHit[hitCount++] = face;
break;
case FRONT:
//infront of the FRONT FACE
if ( ((vertex[X_COOR] >= cube[face][0][X_COOR]) && mustBeInside)
|| (( vertex[X_COOR] < cube[face][0][X_COOR]) && !mustBeInside) )
faceHit[hitCount++] = face;
break;
case LEFT:
//on the left side of the LEFT FACE
if ( ((vertex[Y_COOR] <= cube[face][0][Y_COOR]) && mustBeInside)
|| (( vertex[Y_COOR] > cube[face][0][Y_COOR]) && !mustBeInside) )
faceHit[hitCount++] = face;
break;
case RIGHT:
//on the right side of the RIGHT FACE
if ( ((vertex[Y_COOR] >= cube[face][0][Y_COOR]) && mustBeInside)
|| ((vertex[Y_COOR] < cube[face][0][Y_COOR]) && !mustBeInside) )
faceHit[hitCount++] = face;
break;
case BOTTOM:
//under the BOTTOM FACE
if ( ((vertex[Z_COOR] <= cube[face][0][Z_COOR]) && mustBeInside)
|| ((vertex[Z_COOR] > cube[face][0][Z_COOR]) && !mustBeInside) )
faceHit[hitCount++] = face;
break;
case TOP:
//above the TOP FACE
if ( ((vertex[Z_COOR] >= cube[face][0][Z_COOR]) && mustBeInside)
|| ((vertex[Z_COOR] < cube[face][0][Z_COOR]) && !mustBeInside) )
faceHit[hitCount++] = face;
break;
}
}
return hitCount;
}
| [
"jamoozy@de016830-462b-0410-93e0-879ebbfe8d4a"
]
| [
[
[
1,
768
]
]
]
|
00f8feb5f1e1cd1ac2d8f3121cb488a8e258b36e | 96e96a73920734376fd5c90eb8979509a2da25c0 | /C3DE/PerVertexLightingWallNoFog.cpp | de695d65024168a241f1817b3c504cf4956b96ef | []
| no_license | lianlab/c3de | 9be416cfbf44f106e2393f60a32c1bcd22aa852d | a2a6625549552806562901a9fdc083c2cacc19de | refs/heads/master | 2020-04-29T18:07:16.973449 | 2009-11-15T10:49:36 | 2009-11-15T10:49:36 | 32,124,547 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,623 | cpp | #include "PerVertexLightingWallNoFog.h"
#include "DebugMemory.h"
PerVertexLightingWallNoFog::PerVertexLightingWallNoFog(ID3DXEffect *effect):
FX(effect)
{
m_shaderObjectAmbientMaterial = m_effect->GetParameterByName(0, "gAmbientMtrl");
m_shaderObjectDiffuseMaterial = m_effect->GetParameterByName(0, "gDiffuseMtrl");
m_shaderObjectSpecularMaterial = m_effect->GetParameterByName(0, "gSpecularMtrl");
m_shaderSpecularLightPower = m_effect->GetParameterByName(0, "gSpecularPower");
m_shaderAlpha = m_effect->GetParameterByName(0, "gAlpha");
m_hTex = m_effect->GetParameterByName(0, "gTex");
}
PerVertexLightingWallNoFog::~PerVertexLightingWallNoFog()
{
}
void PerVertexLightingWallNoFog::ResetHandlers()
{
D3DXMATRIX T;
D3DXMatrixIdentity(&T);
SetTransformMatrix(T);
}
void PerVertexLightingWallNoFog::SetObjectMaterials(D3DXCOLOR ambientMaterial, D3DXCOLOR diffuseMaterial,
D3DXCOLOR specularMaterial, float specularPower)
{
HR(m_effect->SetValue(m_shaderObjectAmbientMaterial, &ambientMaterial,sizeof(D3DXCOLOR)));
HR(m_effect->SetValue(m_shaderObjectDiffuseMaterial, &diffuseMaterial, sizeof(D3DXCOLOR)));
HR(m_effect->SetValue(m_shaderObjectSpecularMaterial, &specularMaterial, sizeof(D3DXCOLOR)));
HR(m_effect->SetFloat(m_shaderSpecularLightPower, specularPower));
}
void PerVertexLightingWallNoFog::SetObjectTexture(IDirect3DTexture9 *texture)
{
if(texture)
{
HR(m_effect->SetTexture(m_hTex, texture));
}
}
void PerVertexLightingWallNoFog::SetAlpha(float alpha)
{
HR(m_effect->SetFloat(m_shaderAlpha, alpha));
} | [
"caiocsabino@7e2be596-0d54-0410-9f9d-cf4183935158"
]
| [
[
[
1,
58
]
]
]
|
e295302e32fa3af831be8efdfa9a583f24656108 | 21da454a8f032d6ad63ca9460656c1e04440310e | /src/wcpp/net/wsiInetAddress.h | bb11a352b633710b6d8c3e2801afc2fcefe469be | []
| no_license | merezhang/wcpp | d9879ffb103513a6b58560102ec565b9dc5855dd | e22eb48ea2dd9eda5cd437960dd95074774b70b0 | refs/heads/master | 2021-01-10T06:29:42.908096 | 2009-08-31T09:20:31 | 2009-08-31T09:20:31 | 46,339,619 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,352 | h | #pragma once
#include <wcpp/lang/wsiObject.h>
#include <wcpp/io/wsiSerializable.h>
#include <wcpp/lang/wsiArray.h>
class wsiNetworkInterface;
#define WS_IID_OF_wsiInetAddress \
{ 0x19f2e923, 0x92aa, 0x49d2, { 0x89, 0x42, 0xbf, 0x2a, 0x3d, 0x80, 0x29, 0x4a } }
// {19F2E923-92AA-49d2-8942-BF2A3D80294A}
class wsiInetAddress : /* public wsiObject ,*/ public wsiSerializable
{
public:
static const ws_iid sIID;
public:
WS_METHOD( ws_boolean , Equals )(wsiObject * obj) = 0;
WS_METHOD( ws_result , GetAddress )(wsiByteArray ** ret) = 0;
WS_METHOD( ws_result , GetCanonicalHostName )(wsiString ** ret) = 0;
WS_METHOD( ws_result , GetHostAddress )(wsiString ** ret) = 0;
WS_METHOD( ws_result , GetHostName )(wsiString ** ret) = 0;
WS_METHOD( ws_int , HashCode )(void) = 0;
WS_METHOD( ws_boolean , IsAnyLocalAddress )(void) = 0;
WS_METHOD( ws_boolean , IsLinkLocalAddress )(void) = 0;
WS_METHOD( ws_boolean , IsLoopbackAddress )(void) = 0;
WS_METHOD( ws_boolean , IsMCGlobal )(void) = 0;
WS_METHOD( ws_boolean , IsMCLinkLocal )(void) = 0;
WS_METHOD( ws_boolean , IsMCNodeLocal )(void) = 0;
WS_METHOD( ws_boolean , IsMCOrgLocal )(void) = 0;
WS_METHOD( ws_boolean , IsMCSiteLocal )(void) = 0;
WS_METHOD( ws_boolean , IsMulticastAddress )(void) = 0;
WS_METHOD( ws_boolean , IsReachable )(ws_int timeout) = 0;
WS_METHOD( ws_boolean , IsReachable )(wsiNetworkInterface * netif, ws_int ttl, ws_int timeout) = 0;
WS_METHOD( ws_boolean , IsSiteLocalAddress )(void) = 0;
WS_METHOD( ws_result , ToString )(wsiString ** ret) = 0;
};
/* methods of NetworkInterface
WS_METHOD( ws_boolean , Equals )(wsiObject * obj) = 0;
WS_METHOD( ws_result , GetDisplayName )(wsiString ** ret) = 0;
WS_METHOD( ws_result , GetHardwareAddress )(wsiByteArray ** ret) = 0;
WS_METHOD( ws_result , GetInetAddresses )(wsiEnumeration<wsiInetAddress> ** ret) = 0;
WS_METHOD( ws_result , GetInterfaceAddresses )(wsiList<wsiInterfaceAddress> ** ret) = 0;
WS_METHOD( ws_int , GetMTU )(void) = 0;
WS_METHOD( ws_result , GetName )(wsiString ** ret) = 0;
WS_METHOD( ws_result , GetParent )(wsiNetworkInterface ** ret) = 0;
WS_METHOD( ws_result , GetSubInterfaces )(wsiEnumeration<wsiNetworkInterface> ** ret) = 0;
WS_METHOD( ws_int , HashCode )(void) = 0;
WS_METHOD( ws_boolean , IsLoopback )(void) = 0;
WS_METHOD( ws_boolean , IsPointToPoint )(void) = 0;
WS_METHOD( ws_boolean , IsUp )(void) = 0;
WS_METHOD( ws_boolean , IsVirtual )(void) = 0;
WS_METHOD( ws_boolean , SupportsMulticast )(void) = 0;
WS_METHOD( ws_result , ToString )(wsiString ** ret) = 0;
static ws_result GetByInetAddress (wsiNetworkInterface ** ret , wsiInetAddress * addr);
static ws_result GetByName (wsiNetworkInterface ** ret , wsiString * name);
static ws_result GetNetworkInterfaces (wsiEnumeration<wsiNetworkInterface> ** ret);
*/
| [
"xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8"
]
| [
[
[
1,
73
]
]
]
|
b25d827f2d9ed874695e77eaef6d238b3f8d1fcc | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/Dependencies/Xerces/include/xercesc/util/Platforms/OpenServer/OpenServerDefs.hpp | 3313791fe471852b16418b1d10b4bcf3fa096d8b | []
| no_license | svn2github/ngene | b2cddacf7ec035aa681d5b8989feab3383dac012 | 61850134a354816161859fe86c2907c8e73dc113 | refs/heads/master | 2023-09-03T12:34:18.944872 | 2011-07-27T19:26:04 | 2011-07-27T19:26:04 | 78,163,390 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 983 | hpp | /*
* Copyright 1999-2001,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: OpenServerDefs.hpp 191054 2005-06-17 02:56:35Z jberry $
*/
// ---------------------------------------------------------------------------
// OpenServer runs in little endian mode
// ---------------------------------------------------------------------------
#define ENDIANMODE_LITTLE
typedef void* FileHandle;
| [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
]
| [
[
[
1,
27
]
]
]
|
3cafe6d41a1b4a860ed27f8f6f8e4431c85f5944 | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/nGENE Proj/UtilitiesTypes.h | bd80e994cda9dd6023204ad052d6706d74ccc62a | []
| no_license | svn2github/ngene | b2cddacf7ec035aa681d5b8989feab3383dac012 | 61850134a354816161859fe86c2907c8e73dc113 | refs/heads/master | 2023-09-03T12:34:18.944872 | 2011-07-27T19:26:04 | 2011-07-27T19:26:04 | 78,163,390 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,456 | h | /*
---------------------------------------------------------------------------
This source file is part of nGENE Tech.
Copyright (c) 2006- Wojciech Toman
This program is free software.
File: UtilitiesTypes.h
Version: 0.01
Info: This file contains various types definitions which
are used by the engine.
---------------------------------------------------------------------------
*/
#pragma once
#ifndef __INC_UTILITIESTYPES_H_
#define __INC_UTILITIESTYPES_H_
#include "Prerequisities.h"
namespace nGENE
{
/// Simple rectangle described with its corners
template <typename T=Real>
struct SRect
{
T left;
T top;
T right;
T bottom;
SRect(T _left, T _top, T _right, T _bottom);
SRect();
};
typedef SRect <Real> RECT_FLOAT;
template <typename T>
SRect <T>::SRect(T _left, T _top, T _right, T _bottom):
left(_left),
top(_top),
right(_right),
bottom(_bottom)
{
Assert(left <= right, "Invalid boundaries!");
Assert(top <= bottom, "Invalid boundaries!");
}
//----------------------------------------------------------------------
template <typename T>
SRect <T>::SRect():
left(static_cast<T>(0)),
top(static_cast<T>(0)),
right(static_cast<T>(0)),
bottom(static_cast<T>(0))
{
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
}
#endif | [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
]
| [
[
[
1,
68
]
]
]
|
eabb654673d0a15440e278d1f4946ccbf3afa912 | d37848c528fe70a9ed6ede4737b93196c855d04e | /ParallelMergeSort/Assert.cpp | 0d4a221e4e4c21b65b871d5ec8329b7fe4d425fb | []
| no_license | chuanran/parallel-merge-sort | 74991cae0ad398f7d7d021a4bd62b5c16b2bb52e | 9c88ef5507aa800fc31d52b1bcd09058f742488c | refs/heads/master | 2021-01-10T13:38:33.531256 | 2011-03-21T13:57:03 | 2011-03-21T13:57:03 | 48,393,723 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 624 | cpp | #include "Assert.h"
#include <iostream>
#include <conio.h>
#include "cuda_runtime_api.h"
using std::cout;
using std::endl;
bool Assert::IsSorted(int A[], int N)
{
for (int i = 0; i < N - 1; i++)
{
if (A[i] > A[i+1]) return false;
}
return true;
}
bool Assert::CudaActionSuccessful( cudaError_t e , const char* file, int line, void(*Action)(void))
{
if (e != cudaSuccess)
{
cout << "CUDA returned error: '" << cudaGetErrorString(e) << "'" << endl;
cout << "Error in " << file << ":" << line << endl;
getch();
if (Action != NULL) Action();
return false;
}
else return true;
}
| [
"shay.markanty@018be4eb-6b87-c2f0-6375-72b8ba19d606"
]
| [
[
[
1,
28
]
]
]
|
77bf7ffbfffa74383aba9bd846bd35cbf2acb806 | b2d46af9c6152323ce240374afc998c1574db71f | /cursovideojuegos/theflostiproject/3rdParty/boost/libs/test/example/test_case_template_example.cpp | 1acdb4fdc260cd89ec3645a93f441b33e834f669 | [
"LicenseRef-scancode-unknown-license-reference",
"BSL-1.0"
]
| permissive | bugbit/cipsaoscar | 601b4da0f0a647e71717ed35ee5c2f2d63c8a0f4 | 52aa8b4b67d48f59e46cb43527480f8b3552e96d | refs/heads/master | 2021-01-10T21:31:18.653163 | 2011-09-28T16:39:12 | 2011-09-28T16:39:12 | 33,032,640 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 947 | cpp | // (C) Copyright Gennadiy Rozental 2001-2004.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/test for the library home page.
// Boost.Test
#include <boost/test/test_tools.hpp>
#include <boost/test/test_case_template.hpp>
using boost::unit_test::test_suite;
// Boost.MPL
#include <boost/mpl/range_c.hpp>
template<typename Number>
void free_test_function( Number* = 0 ) {
BOOST_CHECK_EQUAL( 2, (int const)Number::value );
}
BOOST_META_FUNC_TEST_CASE( free_test_function );
test_suite*
init_unit_test_suite( int, char* [] ) {
test_suite* test= BOOST_TEST_SUITE( "Test case template example" );
typedef boost::mpl::range_c<int,0,10> numbers;
test->add( BOOST_FUNC_TEMPLATE_TEST_CASE( free_test_function, numbers ) );
return test;
}
// EOF
| [
"ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a"
]
| [
[
[
1,
34
]
]
]
|
7e2498d4b46d4012b4357359ce3d5d856cc4a817 | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/tags/v0-1/engine/ui/include/Console.h | e98d9be08d37793aca477b0d2a71ad63b1e5d855 | [
"ClArtistic",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
]
| permissive | jacmoe/dsa-hl-svn | 55b05b6f28b0b8b216eac7b0f9eedf650d116f85 | 97798e1f54df9d5785fb206c7165cd011c611560 | refs/heads/master | 2021-04-22T12:07:43.389214 | 2009-11-27T22:01:03 | 2009-11-27T22:01:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,757 | h | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2005 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#ifndef __Console_H__
#define __Console_H__
#include "UiPrerequisites.h"
#include <vector>
#include <string>
#include "CeGuiWindow.h"
#include <OgreSingleton.h>
namespace rl {
class Interpreter;
/** This is a Console System
*/
class _RlUiExport Console
: public Ogre::Singleton<Console>, public CeGuiWindow
{
public:
Console();
static Console& getSingleton();
static Console* getSingletonPtr();
void setInterpreter(Interpreter* interpreter);
Interpreter* getInterpreter();
void write(const CeGuiString& output);
protected:
bool beforeShow();
private:
CEGUI::Editbox* mCommandLine;
CEGUI::Listbox* mDisplay;
Interpreter* mInterpreter;
bool mPrompt;
bool handleKeyDown(const CEGUI::EventArgs& e);
bool handleClose();
void appendTextRow(const CeGuiString& text, const CEGUI::colour color);
std::vector<CeGuiString> mHistory;
unsigned int mHistoryMarker;
void cycleHistory(int skip);
};
}
#endif
| [
"blakharaz@4c79e8ff-cfd4-0310-af45-a38c79f83013"
]
| [
[
[
1,
69
]
]
]
|
ef9a8135b6f3306d0f1fbd10ce7a4f784e94046c | f90b1358325d5a4cfbc25fa6cccea56cbc40410c | /src/PRatio/DriverProteomeInfo.cpp | 656f5ffb2ca1bd9f870039198544fe4e964f0c4b | []
| no_license | ipodyaco/prorata | bd52105499c3fad25781d91952def89a9079b864 | 1f17015d304f204bd5f72b92d711a02490527fe6 | refs/heads/master | 2021-01-10T09:48:25.454887 | 2010-05-11T19:19:40 | 2010-05-11T19:19:40 | 48,766,766 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 741 | cpp |
#include <iostream>
#include "proRataParameters.h"
#include "proteomeInfo.h"
#include <time.h>
using namespace std;
int main( int argc, char * argv[] )
{
// creat a ProRataParameters object
ProRataParameters params;
if( !params.setArguments( argc, argv ) )
{
cout << "ERROR: problem in reading the options and configurations!" << endl;
return 0;
}
ProteomeInfo mainProteomeInfo;
if( !mainProteomeInfo.processPeptidesXIC() )
cout << "cannot process peptide XIC " << endl;
if( !mainProteomeInfo.processProteins() )
cout << "cannot process protein " << endl;
mainProteomeInfo.writeFileQPR();
mainProteomeInfo.writeFileTAB();
cout << "Quantification completed!" << endl;
return 0;
}
| [
"chongle.pan@c58cc1ec-c975-bb1e-ac29-6983d7497d3a"
]
| [
[
[
1,
33
]
]
]
|
ac1af893d7f0be082fd6cc1f1143a44d2f61e408 | 0e5189734ee0503f01402d40ad2041fee5bedca2 | /ArduPiratesNG/libraries/FastSerial/vprintf.cpp | 53e013e71c28aaee47b96b8143c26e1ce33c9122 | []
| no_license | fvaldesc/ardupirates | ce280e4df0c927f9e1deef58e3df2a61c8d24ce7 | 9874fa229fbc9fbab7e942f3292a00c7c6f04e8d | refs/heads/master | 2020-05-07T01:12:33.596633 | 2011-12-14T21:15:13 | 2011-12-14T21:15:13 | 32,614,056 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 23,000 | cpp | // -*- Mode: C++; c-basic-offset: 8; indent-tabs-mode: nil -*-
/*
Adapted from the avr-libc vfprintf:
Copyright (c) 2002, Alexander Popov ([email protected])
Copyright (c) 2002,2004,2005 Joerg Wunsch
Copyright (c) 2005, Helmut Wallner
Copyright (c) 2007, Dmitry Xmelkov
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of the copyright holders nor the names of
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/* From: Id: printf_p_new.c,v 1.1.1.9 2002/10/15 20:10:28 joerg_wunsch Exp */
/* $Id: vfprintf.c,v 1.18.2.1 2009/04/01 23:12:06 arcanum Exp $ */
#include "BetterStream.h"
#include <avr/pgmspace.h>
#include <stdarg.h>
#include <string.h>
extern "C" {
#include "ftoa_engine.h"
#include "ntz.h"
#include "xtoa_fast.h"
}
// workaround for GCC bug c++/34734
#undef PROGMEM
#define PROGMEM __attribute__(( section(".progmem.data") ))
#undef PSTR
#define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); &__c[0];}))
#define GETBYTE(flag, mask, pnt) ({ \
unsigned char __c; \
asm ( \
"sbrc %2,%3 \n\t" \
"lpm %0,Z+ \n\t" \
"sbrs %2,%3 \n\t" \
"ld %0,Z+ " \
: "=r" (__c), \
"+z" (pnt) \
: "r" (flag), \
"I" (ntz(mask)) \
); \
__c; \
})
/*
#define GETBYTE(flag, mask, pnt) ({ \
unsigned char __c; \
__c = ((flag) & (mask)) \
? pgm_read_byte(pnt) : *pnt; \
pnt++; \
__c; \
})
*/
#define FL_ZFILL 0x01
#define FL_PLUS 0x02
#define FL_SPACE 0x04
#define FL_LPAD 0x08
#define FL_ALT 0x10
#define FL_WIDTH 0x20
#define FL_PREC 0x40
#define FL_LONG 0x80
#define FL_PGMSTRING FL_LONG
#define FL_NEGATIVE FL_LONG
#define FL_ALTUPP FL_PLUS
#define FL_ALTHEX FL_SPACE
#define FL_FLTUPP FL_ALT
#define FL_FLTEXP FL_PREC
#define FL_FLTFIX FL_LONG
void
BetterStream::_vprintf (unsigned char in_progmem, const char *fmt, va_list ap)
{
unsigned char c; /* holds a char from the format string */
unsigned char flags;
unsigned char width;
unsigned char prec;
unsigned char buf[11]; /* size for -1 in octal, without '\0' */
for (;;) {
/*
* Process non-format characters
*/
for (;;) {
c = GETBYTE (in_progmem, 1, fmt);
if (!c) return;
if (c == '%') {
c = GETBYTE (in_progmem, 1, fmt);
if (c != '%') break;
}
/* emit cr before lf to make most terminals happy */
if (c == '\n')
write('\r');
write(c);
}
flags = 0;
width = 0;
prec = 0;
/*
* Process format adjustment characters, precision, width.
*/
do {
if (flags < FL_WIDTH) {
switch (c) {
case '0':
flags |= FL_ZFILL;
continue;
case '+':
flags |= FL_PLUS;
/* FALLTHROUGH */
case ' ':
flags |= FL_SPACE;
continue;
case '-':
flags |= FL_LPAD;
continue;
case '#':
flags |= FL_ALT;
continue;
}
}
if (flags < FL_LONG) {
if (c >= '0' && c <= '9') {
c -= '0';
if (flags & FL_PREC) {
prec = 10*prec + c;
continue;
}
width = 10*width + c;
flags |= FL_WIDTH;
continue;
}
if (c == '.') {
if (flags & FL_PREC)
return;
flags |= FL_PREC;
continue;
}
if (c == 'l') {
flags |= FL_LONG;
continue;
}
if (c == 'h')
continue;
}
break;
} while ( (c = GETBYTE (in_progmem, 1, fmt)) != 0);
/*
* Handle floating-point formats E, F, G, e, f, g.
*/
if (c >= 'E' && c <= 'G') {
flags |= FL_FLTUPP;
c += 'e' - 'E';
goto flt_oper;
} else if (c >= 'e' && c <= 'g') {
int exp; /* exponent of master decimal digit */
int n;
unsigned char vtype; /* result of float value parse */
unsigned char sign; /* sign character (or 0) */
unsigned char ndigs;
flags &= ~FL_FLTUPP;
flt_oper:
if (!(flags & FL_PREC))
prec = 6;
flags &= ~(FL_FLTEXP | FL_FLTFIX);
if (c == 'e')
flags |= FL_FLTEXP;
else if (c == 'f')
flags |= FL_FLTFIX;
else if (prec > 0)
prec -= 1;
if (flags & FL_FLTFIX) {
vtype = 7; /* 'prec' arg for 'ftoa_engine' */
ndigs = prec < 60 ? prec + 1 : 60;
} else {
if (prec > 7) prec = 7;
vtype = prec;
ndigs = 0;
}
exp = __ftoa_engine (va_arg(ap,double), (char *)buf, vtype, ndigs);
vtype = buf[0];
sign = 0;
if ((vtype & FTOA_MINUS) && !(vtype & FTOA_NAN))
sign = '-';
else if (flags & FL_PLUS)
sign = '+';
else if (flags & FL_SPACE)
sign = ' ';
if (vtype & (FTOA_NAN | FTOA_INF)) {
const char *p;
ndigs = sign ? 4 : 3;
if (width > ndigs) {
width -= ndigs;
if (!(flags & FL_LPAD)) {
do {
write(' ');
} while (--width);
}
} else {
width = 0;
}
if (sign)
write(sign);
p = PSTR("inf");
if (vtype & FTOA_NAN)
p = PSTR("nan");
while ( (ndigs = pgm_read_byte(p)) != 0) {
if (flags & FL_FLTUPP)
ndigs += 'I' - 'i';
write(ndigs);
p++;
}
goto tail;
}
/* Output format adjustment, number of decimal digits in buf[] */
if (flags & FL_FLTFIX) {
ndigs += exp;
if ((vtype & FTOA_CARRY) && buf[1] == '1')
ndigs -= 1;
if ((signed char)ndigs < 1)
ndigs = 1;
else if (ndigs > 8)
ndigs = 8;
} else if (!(flags & FL_FLTEXP)) { /* 'g(G)' format */
if (exp <= prec && exp >= -4)
flags |= FL_FLTFIX;
while (prec && buf[1+prec] == '0')
prec--;
if (flags & FL_FLTFIX) {
ndigs = prec + 1; /* number of digits in buf */
prec = prec > exp
? prec - exp : 0; /* fractional part length */
}
}
/* Conversion result length, width := free space length */
if (flags & FL_FLTFIX)
n = (exp>0 ? exp+1 : 1);
else
n = 5; /* 1e+00 */
if (sign) n += 1;
if (prec) n += prec + 1;
width = width > n ? width - n : 0;
/* Output before first digit */
if (!(flags & (FL_LPAD | FL_ZFILL))) {
while (width) {
write(' ');
width--;
}
}
if (sign) write(sign);
if (!(flags & FL_LPAD)) {
while (width) {
write('0');
width--;
}
}
if (flags & FL_FLTFIX) { /* 'f' format */
n = exp > 0 ? exp : 0; /* exponent of left digit */
do {
if (n == -1)
write('.');
flags = (n <= exp && n > exp - ndigs)
? buf[exp - n + 1] : '0';
if (--n < -prec)
break;
write(flags);
} while (1);
if (n == exp
&& (buf[1] > '5'
|| (buf[1] == '5' && !(vtype & FTOA_CARRY))) )
{
flags = '1';
}
write(flags);
} else { /* 'e(E)' format */
/* mantissa */
if (buf[1] != '1')
vtype &= ~FTOA_CARRY;
write(buf[1]);
if (prec) {
write('.');
sign = 2;
do {
write(buf[sign++]);
} while (--prec);
}
/* exponent */
write(flags & FL_FLTUPP ? 'E' : 'e');
ndigs = '+';
if (exp < 0 || (exp == 0 && (vtype & FTOA_CARRY) != 0)) {
exp = -exp;
ndigs = '-';
}
write(ndigs);
for (ndigs = '0'; exp >= 10; exp -= 10)
ndigs += 1;
write(ndigs);
write('0' + exp);
}
goto tail;
}
/*
* Handle string formats c, s, S.
*/
{
const char * pnt;
size_t size;
switch (c) {
case 'c':
buf[0] = va_arg (ap, int);
pnt = (char *)buf;
size = 1;
goto no_pgmstring;
case 's':
pnt = va_arg (ap, char *);
size = strnlen (pnt, (flags & FL_PREC) ? prec : ~0);
no_pgmstring:
flags &= ~FL_PGMSTRING;
goto str_lpad;
case 'S':
pgmstring:
pnt = va_arg (ap, char *);
size = strnlen_P (pnt, (flags & FL_PREC) ? prec : ~0);
flags |= FL_PGMSTRING;
str_lpad:
if (!(flags & FL_LPAD)) {
while (size < width) {
write(' ');
width--;
}
}
while (size) {
write(GETBYTE (flags, FL_PGMSTRING, pnt));
if (width) width -= 1;
size -= 1;
}
goto tail;
}
}
/*
* Handle integer formats variations for d/i, u, o, p, x, X.
*/
if (c == 'd' || c == 'i') {
long x = (flags & FL_LONG) ? va_arg(ap,long) : va_arg(ap,int);
flags &= ~(FL_NEGATIVE | FL_ALT);
if (x < 0) {
x = -x;
flags |= FL_NEGATIVE;
}
c = __ultoa_invert (x, (char *)buf, 10) - (char *)buf;
} else {
int base;
if (c == 'u') {
flags &= ~FL_ALT;
base = 10;
goto ultoa;
}
flags &= ~(FL_PLUS | FL_SPACE);
switch (c) {
case 'o':
base = 8;
goto ultoa;
case 'p':
flags |= FL_ALT;
/* no break */
case 'x':
if (flags & FL_ALT)
flags |= FL_ALTHEX;
base = 16;
goto ultoa;
case 'X':
if (flags & FL_ALT)
flags |= (FL_ALTHEX | FL_ALTUPP);
base = 16 | XTOA_UPPER;
ultoa:
c = __ultoa_invert ((flags & FL_LONG)
? va_arg(ap, unsigned long)
: va_arg(ap, unsigned int),
(char *)buf, base) - (char *)buf;
flags &= ~FL_NEGATIVE;
break;
default:
return;
}
}
/*
* Format integers.
*/
{
unsigned char len;
len = c;
if (flags & FL_PREC) {
flags &= ~FL_ZFILL;
if (len < prec) {
len = prec;
if ((flags & FL_ALT) && !(flags & FL_ALTHEX))
flags &= ~FL_ALT;
}
}
if (flags & FL_ALT) {
if (buf[c-1] == '0') {
flags &= ~(FL_ALT | FL_ALTHEX | FL_ALTUPP);
} else {
len += 1;
if (flags & FL_ALTHEX)
len += 1;
}
} else if (flags & (FL_NEGATIVE | FL_PLUS | FL_SPACE)) {
len += 1;
}
if (!(flags & FL_LPAD)) {
if (flags & FL_ZFILL) {
prec = c;
if (len < width) {
prec += width - len;
len = width;
}
}
while (len < width) {
write(' ');
len++;
}
}
width = (len < width) ? width - len : 0;
if (flags & FL_ALT) {
write('0');
if (flags & FL_ALTHEX)
write(flags & FL_ALTUPP ? 'X' : 'x');
} else if (flags & (FL_NEGATIVE | FL_PLUS | FL_SPACE)) {
unsigned char z = ' ';
if (flags & FL_PLUS) z = '+';
if (flags & FL_NEGATIVE) z = '-';
write(z);
}
while (prec > c) {
write('0');
prec--;
}
do {
write(buf[--c]);
} while (c);
}
tail:
/* Tail is possible. */
while (width) {
write(' ');
width--;
}
} /* for (;;) */
}
| [
"lohnieh@51ca9009-c073-42c2-b418-8acb3dbd9f11"
]
| [
[
[
1,
521
]
]
]
|
9e609c9416da38009aa7a8e4e57ada23fe6422f9 | 1feabd4308571795d0628355d9385ddb84f4334c | /devices/wiga/soft/gardening/rolade_properties.hpp | 499345d4be87c67a0a2ffa1882d9c48002a2aee3 | []
| no_license | michalharakal/cheesboard.timer-modul | b7312156dafcaed35f12712899cbffc034ce65b7 | e83c2206f08929a5320952ac63d5d20dc0c148dd | refs/heads/master | 2021-01-01T19:06:32.758332 | 2011-12-29T22:04:23 | 2011-12-29T22:04:23 | 38,479,692 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 491 | hpp | /*
rolade.h
*/
#ifndef ROLADEDATA_HPP
#define ROLADEDATA_HPP
#include <stdio.h>
#include <inttypes.h>
extern "C" {
#include "rolade_properties.h"
};
class RoladeProperties:private RoladePropertiesData
{
public:
RoladeProperties();
~RoladeProperties();
void SetAutomaticInterval(uint8_t h_start, uint8_t m_start, uint8_t h_end, uint8_t m_end);
void Serialize(void *dest, size_t *size);
uint8_t getRawDataSize(void);
private:
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
29
]
]
]
|
f06e3aa386181bfd5773dda97acc5e3c0efb4d7c | 27167a5a0340fdc9544752bd724db27d3699a9a2 | /SDITabbedSample/FoldersDockingWindow.h | dca03b7d9b79434e05ce48672d0a0e548d3961ca | []
| no_license | eaglexmw-gmail/wtl-dockwins | 2b464be3958e1683cd668a10abafb528f43ac695 | ae307a1978b73bfd2823945068224bb6c01ae350 | refs/heads/master | 2020-06-30T21:03:26.075864 | 2011-10-23T12:50:14 | 2011-10-23T12:50:14 | 200,951,487 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,615 | h | // FoldersDockingWindow.h: interface for the CFoldersDockingWindow class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_FOLDERSDOCKINGWINDOW_H__46F73EC2_257A_4C57_A311_B5ECB00535DF__INCLUDED_)
#define AFX_FOLDERSDOCKINGWINDOW_H__46F73EC2_257A_4C57_A311_B5ECB00535DF__INCLUDED_
#include <sstream>
#include <dockwins/ExtDockingWindow.h>
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CFoldersDockingWindow :
public dockwins::CTitleDockingWindowImpl< CFoldersDockingWindow,CWindow,dockwins::COutlookLikeExTitleDockingWindowTraits>
{
typedef CFoldersDockingWindow thisClass;
typedef dockwins::CTitleDockingWindowImpl< CFoldersDockingWindow,CWindow,dockwins::COutlookLikeExTitleDockingWindowTraits> baseClass;
protected:
void FillTree(CTreeViewCtrl& tree)
{
for( int i =0; i < 10; i++)
{
std::basic_stringstream<TCHAR> text;
text<<_T("item ")<<i;
HTREEITEM hItem=tree.InsertItem(text.str().c_str(),0,1,TVI_ROOT,TVI_LAST);
for( int j = 0; j < 5; j++)
{
std::basic_stringstream<TCHAR> text;
text<<_T("sub item ")<<j;
tree.InsertItem(text.str().c_str(),0,1,hItem,TVI_LAST);
}
}
}
public:
void OnDocked(dockwins::HDOCKBAR hBar,bool bHorizontal)
{
DWORD dwStyle = GetWindowLong(GWL_STYLE)&(~WS_SIZEBOX);
SetWindowLong( GWL_STYLE, dwStyle);
baseClass::OnDocked(hBar,bHorizontal);
}
void OnUndocked(dockwins::HDOCKBAR hBar)
{
DWORD dwStyle = GetWindowLong(GWL_STYLE) | WS_SIZEBOX;
SetWindowLong( GWL_STYLE , dwStyle);
baseClass::OnUndocked(hBar);
}
DECLARE_WND_CLASS_EX(_T("CFoldersDockingWindow"), 0, COLOR_WINDOW)
BEGIN_MSG_MAP(thisClass)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_SIZE, OnSize)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
CHAIN_MSG_MAP(baseClass)
END_MSG_MAP()
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
m_images.Create(16, 16, TRUE, 3, 0);
ATLASSERT(m_images.m_hImageList);
CBitmap bmp;
bmp.LoadBitmap(IDB_DUMMYBMP);
m_images.Add( bmp, RGB(255,255,255));
m_tree.Create(m_hWnd,NULL,NULL,
TVS_SHOWSELALWAYS | TVS_HASBUTTONS |
TVS_LINESATROOT | TVS_HASLINES |
TVS_EDITLABELS|TVS_SHOWSELALWAYS|
TVS_DISABLEDRAGDROP|
WS_CHILD | WS_VISIBLE, WS_EX_CLIENTEDGE);
m_tree.SetImageList(m_images, TVSIL_NORMAL);
FillTree(m_tree);
return 0;
}
LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
{
if(wParam != SIZE_MINIMIZED )
{
RECT rc;
GetClientRect(&rc);
::SetWindowPos(m_tree.m_hWnd, NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top ,SWP_NOZORDER | SWP_NOACTIVATE);
}
bHandled = FALSE;
return 1;
}
LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
bHandled = FALSE;
m_images.Destroy();
return 0;
}
protected:
CTreeViewCtrl m_tree;
CImageList m_images;
};
#endif // !defined(AFX_FOLDERSDOCKINGWINDOW_H__46F73EC2_257A_4C57_A311_B5ECB00535DF__INCLUDED_)
| [
"[email protected]"
]
| [
[
[
1,
105
]
]
]
|
874ebb7e53802a95987fd271f8279128dc95e1ce | 68127d36b179fd5548a1e593e2c20791db6b48e3 | /programacaoC/A1611-01.CPP | 26363aa12aca5d5b90c2b966f375ac726bd0f1cf | []
| no_license | renatomb/engComp | fa50b962dbdf4f9387fd02a28b3dc130b683ed02 | b533c876b50427d44cfdb92c507a6e74b1b7fa79 | refs/heads/master | 2020-04-11T06:22:05.209022 | 2006-04-26T13:40:08 | 2018-12-13T04:25:08 | 161,578,821 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 316 | cpp | #include <stdio.h>
#include <iostream.h>
int tamanho(char s[]);
void main(){
char s[]="Universidade Potiguar";
char *ps=&s[21];
while (--ps>=s) putchar(*ps);
putchar('\n');
cout << "O tamanho da string e = " << tamanho(s);
}
int tamanho(char s[]){
int n;
for (n=0; *s; s++) n++;
return n;
} | [
"[email protected]"
]
| [
[
[
1,
17
]
]
]
|
b3a34f6af8ff5ed6feed68af9051330600ffd966 | ed9ecdcba4932c1adacac9218c83e19f71695658 | /PhysicsDemo2/PhysicsDemo2/stack.cpp | f4707fd835119b6fa4ee6a55f197c5880cac10cc | []
| no_license | karansapra/futurattack | 59cc71d2cc6564a066a8e2f18e2edfc140f7c4ab | 81e46a33ec58b258161f0dd71757a499263aaa62 | refs/heads/master | 2021-01-10T08:47:01.902600 | 2010-09-20T20:25:04 | 2010-09-20T20:25:04 | 45,804,375 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 832 | cpp | #include "stack.h"
StackAllocator::StackAllocator()
{
used_size = 0;
for (U32 i=0;i<STACK_SIZE;i++)
stack[i]=0x00;
}
U8 * StackAllocator::Allocate(U32 size)
{
static StackBlockHeader sbh;
_ASSERT(!(STACK_SIZE-used_size<size+SBH_SIZE));
_ASSERT(size!=0);
//Last block ptr retained
sbh.last_zone_ptr = &stack[used_size];
used_size += size;
mem_write(&stack[used_size],(U8*)&sbh,SBH_SIZE);
used_size += SBH_SIZE;
return sbh.last_zone_ptr;
}
void StackAllocator::FreeLast()
{
static StackBlockHeader sbh;
_ASSERT(used_size!=0);
mem_write((U8*)&sbh,&stack[used_size-SBH_SIZE],SBH_SIZE);
used_size = sbh.last_zone_ptr-stack;
}
void StackAllocator::mem_write(U8 *dest, U8* src, U32 size)
{
static U32 i;
_ASSERT(size!=0);
for (i=0;i<size;i++)
dest[i] = src[i];
} | [
"clems71@52ecbd26-af3e-11de-a2ab-0da4ed5138bb"
]
| [
[
[
1,
43
]
]
]
|
b499fe3e43b8fec9d4d680adf890d00a944a742b | 9d1cb48ec6f6c1f0e342f0f8f819cbda74ceba6e | /src/SCBARG.CPP | 46b2d07a83a482070ab1948874d87c15e079b77b | []
| no_license | correosdelbosque/veryie | e7a5ad44c68dc0b81d4afcff3be76eb8f83320ff | 6ea5a68d0a6eb6c3901b70c2dc806d1e2e2858f1 | refs/heads/master | 2021-01-10T13:17:59.755108 | 2010-06-16T04:23:26 | 2010-06-16T04:23:26 | 53,365,953 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,211 | cpp | /////////////////////////////////////////////////////////////////////////
//
// CSizingControlBarG Version 2.42
//
// Created: Jan 24, 1998 Last Modified: Feb 10, 2000
//
// See the official site at www.datamekanix.com for documentation and
// the latest news.
//
/////////////////////////////////////////////////////////////////////////
// Copyright (C) 1998-2000 by Cristi Posea. All rights reserved.
//
// This code is free for personal and commercial use, providing this
// notice remains intact in the source files and all eventual changes are
// clearly marked with comments.
//
// You must obtain the author's consent before you can include this code
// in a software library.
//
// No warrantee of any kind, express or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc. to
// [email protected] or post them at the message board at the site.
/////////////////////////////////////////////////////////////////////////
// sizecbar.cpp : implementation file
//
#include "stdafx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//#pragma optimize( "s", on )
/////////////////////////////////////////////////////////////////////////
// CSizingControlBarG
IMPLEMENT_DYNAMIC(CSizingControlBarG, baseCSizingControlBarG);
CSizingControlBarG::CSizingControlBarG()
{
m_cyGripper = 11;//15
}
CSizingControlBarG::~CSizingControlBarG()
{
}
BEGIN_MESSAGE_MAP(CSizingControlBarG, baseCSizingControlBarG)
//{{AFX_MSG_MAP(CSizingControlBarG)
ON_WM_NCLBUTTONUP()
ON_WM_NCHITTEST()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_SETTEXT, OnSetText)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////
// CSizingControlBarG message handlers
/////////////////////////////////////////////////////////////////////////
// Mouse Handling
//
void CSizingControlBarG::OnNcLButtonUp(UINT nHitTest, CPoint point)
{
try{
if (nHitTest == HTCLOSE)
m_pDockSite->ShowControlBar(this, FALSE, FALSE); // hide
baseCSizingControlBarG::OnNcLButtonUp(nHitTest, point);
}catch(...){}
}
void CSizingControlBarG::NcCalcClient(LPRECT pRc, UINT nDockBarID)
{
// subtract edges
baseCSizingControlBarG::NcCalcClient(pRc, nDockBarID);
if (!HasGripper())
return;
CRect rc(pRc);
BOOL bHorz = (nDockBarID == AFX_IDW_DOCKBAR_TOP) ||
(nDockBarID == AFX_IDW_DOCKBAR_BOTTOM);
if (bHorz)
rc.DeflateRect(m_cyGripper, 0, 0, 0);
else
rc.DeflateRect(0, m_cyGripper, 0, 0);
// set position for the "x" (hide bar) button
CPoint ptOrgBtn;
if (bHorz)
ptOrgBtn = CPoint(rc.left - 8, rc.top + 5);
else
ptOrgBtn = CPoint(rc.right - 7, rc.top - 8);
m_biHide.Move(ptOrgBtn - CRect(pRc).TopLeft());
*pRc = rc;
}
void CSizingControlBarG::NcPaintGripper(CDC* pDC, CRect rcClient)
{
}
UINT CSizingControlBarG::OnNcHitTest(CPoint point)
{
CRect rcBar;
GetWindowRect(rcBar);
UINT nRet = baseCSizingControlBarG::OnNcHitTest(point);
if (nRet != HTCLIENT)
return nRet;
CRect rc = m_biHide.GetRect();
rc.OffsetRect(rcBar.TopLeft());
if (rc.PtInRect(point))
return HTCLOSE;
return HTCLIENT;
}
/////////////////////////////////////////////////////////////////////////
// CSizingControlBarG implementation helpers
void CSizingControlBarG::OnUpdateCmdUI(CFrameWnd* pTarget,
BOOL bDisableIfNoHndler)
{
UNUSED_ALWAYS(bDisableIfNoHndler);
UNUSED_ALWAYS(pTarget);
if (!HasGripper())
return;
BOOL bNeedPaint = FALSE;
CPoint pt;
::GetCursorPos(&pt);
BOOL bHit = (OnNcHitTest(pt) == HTCLOSE);
BOOL bLButtonDown = (::GetKeyState(VK_LBUTTON) < 0);
BOOL bWasPushed = m_biHide.bPushed;
m_biHide.bPushed = bHit && bLButtonDown;
BOOL bWasRaised = m_biHide.bRaised;
m_biHide.bRaised = bHit && !bLButtonDown;
bNeedPaint |= (m_biHide.bPushed ^ bWasPushed) ||
(m_biHide.bRaised ^ bWasRaised);
if (bNeedPaint)
SendMessage(WM_NCPAINT);
}
/////////////////////////////////////////////////////////////////////////
// CSCBButton
CSCBButton::CSCBButton()
{
bRaised = FALSE;
bPushed = FALSE;
}
void CSCBButton::Paint(CDC* pDC)
{
CRect rc = GetRect();
if (bPushed)
{
pDC->Draw3dRect(rc, ::GetSysColor(COLOR_BTNTEXT),
::GetSysColor(COLOR_BTNHIGHLIGHT));
CRect rect = rc;
rect.top++;
rect.left++;
rect.right--;
rect.bottom--;
pDC->Draw3dRect(rect, ::GetSysColor(COLOR_BTNSHADOW),
::GetSysColor(COLOR_BTNFACE));
}
else
{
pDC->Draw3dRect(rc, ::GetSysColor(COLOR_BTNHIGHLIGHT),
::GetSysColor(COLOR_BTNTEXT));
CRect rect = rc;
rect.top++;
rect.left++;
rect.right--;
rect.bottom--;
pDC->Draw3dRect(rect, ::GetSysColor(COLOR_BTNFACE),
::GetSysColor(COLOR_BTNSHADOW));
}
COLORREF clrOldTextColor = pDC->GetTextColor();
pDC->SetTextColor(::GetSysColor(COLOR_BTNTEXT));
int nPrevBkMode = pDC->SetBkMode(TRANSPARENT);
CFont font;
int ppi = pDC->GetDeviceCaps(LOGPIXELSX);
int pointsize = MulDiv(60, 96, ppi); // 6 points at 96 ppi
font.CreatePointFont(pointsize, _T("Marlett"));
CFont* oldfont = pDC->SelectObject(&font);
pDC->TextOut(ptOrg.x + 3, ptOrg.y+2 , CString(_T("r"))); // x-like
pDC->SelectObject(oldfont);
pDC->SetBkMode(nPrevBkMode);
pDC->SetTextColor(clrOldTextColor);
}
BOOL CSizingControlBarG::HasGripper() const
{
#if defined(_SCB_MINIFRAME_CAPTION) || !defined(_SCB_REPLACE_MINIFRAME)
// if the miniframe has a caption, don't display the gripper
if (IsFloating())
return FALSE;
#endif //_SCB_MINIFRAME_CAPTION
return TRUE;
}
//#pragma optimize( "s", off )
| [
"songbohr@af2e6244-03f2-11de-b556-9305e745af9e"
]
| [
[
[
1,
224
]
]
]
|
e8348b7a03284ad6100d1effea2fb3810756c3e2 | b6bad03a59ec436b60c30fc793bdcf687a21cf31 | /som2416/wince5/ubcsp.cpp | b95c0bb9bcc573bca750116986e4e846c2fcfd2d | []
| no_license | blackfa1con/openembed | 9697f99b12df16b1c5135e962890e8a3935be877 | 3029d7d8c181449723bb16d0a73ee87f63860864 | refs/heads/master | 2021-01-10T14:14:39.694809 | 2010-12-16T03:20:27 | 2010-12-16T03:20:27 | 52,422,065 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 37,111 | cpp | /*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
/** **/
/** ubcsp,c **/
/** **/
/** MicroBCSP - a very low cost implementation of the BCSP protocol **/
/** **/
/*****************************************************************************/
#include "ubcsp.h"
//#if SHOW_PACKET_ERRORS || SHOW_LE_STATES
#include <stdio.h>
#include <windows.h>
//#endif
#ifdef UBCSP_CRC
#undef UBCSP_CRC
#define UBCSP_CRC 1
#endif
extern int icount;
static uint16 ubcsp_calc_crc (uint8 ch, uint16 crc);
static uint16 ubcsp_crc_reverse (uint16);
/*****************************************************************************/
/** **/
/** Constant Data - ROM **/
/** **/
/*****************************************************************************/
/* This is the storage for the link establishment messages */
static const uint8 ubcsp_le_buffer[4][4] =
{
0xDA, 0xDC, 0xED, 0xED,
0xAC, 0xAF, 0xEF, 0xEE,
0xAD, 0xEF, 0xAC, 0xED,
0xDE, 0xAD, 0xD0, 0xD0
};
/* These are the link establishment headers */
/* The two version are for the CRC and non-CRC varients */
#if UBCSP_CRC
static const uint8 ubcsp_send_le_header[4] =
{
0x40, 0x41, 0x00, 0x7E
};
#else
static const uint8 ubcsp_send_le_header[4] =
{
0x00, 0x41, 0x00, 0xBE
};
#endif
/*****************************************************************************/
/** **/
/** Static Data - RAM **/
/** **/
/*****************************************************************************/
/* This is the storage for all state data for ubcsp */
struct ubcsp_configuration ubcsp_config;
/* This is the ACK packet header - this will be overwritten when
we create an ack packet */
static uint8 ubcsp_send_ack_header[4] =
{
0x00, 0x00, 0x00, 0x00
};
/* This is the deslip lookup table */
static const ubcsp_deslip[2] =
{
SLIP_FRAME, SLIP_ESCAPE,
};
/* This is a state machine table for link establishment */
static uint8 next_le_packet[16] =
{
ubcsp_le_sync, // uninit
ubcsp_le_conf, // init
ubcsp_le_none, // active
ubcsp_le_none,
ubcsp_le_sync_resp, // sync_resp
ubcsp_le_sync_resp,
ubcsp_le_none,
ubcsp_le_none,
ubcsp_le_none, // conf_resp
ubcsp_le_conf_resp,
ubcsp_le_conf_resp,
ubcsp_le_none,
};
/* This is the storage required for building send and crc data */
static uint8 ubcsp_send_header[4];
static uint8 ubcsp_send_crc[2];
/* This is where the receive header is stored before the payload arrives */
static uint8 ubcsp_receive_header[4];
/*****************************************************************************/
/** **/
/** Code - ROM or RAM **/
/** **/
/*****************************************************************************/
/*****************************************************************************/
/** **/
/** ubcsp_initialize **/
/** **/
/** This initializes the state of the ubcsp engine to a known values **/
/** **/
/*****************************************************************************/
void ubcsp_initialize (void)
{
ubcsp_config.ack_number = 0;
ubcsp_config.sequence_number = 0;
ubcsp_config.send_ptr = 0;
ubcsp_config.send_size = 0;
ubcsp_config.receive_index = -4;
ubcsp_config.delay = 0;
#if SHOW_LE_STATES
DebugMessage(1,(_T("Hello Link Uninitialized\r\n")));
#endif
ubcsp_config.link_establishment_state = ubcsp_le_uninitialized;
ubcsp_config.link_establishment_packet = ubcsp_le_sync;
}
/*****************************************************************************/
/** **/
/** ubcsp_send_packet **/
/** **/
/** This sends a packet structure for sending to the ubcsp engine **/
/** This can only be called when the activity indication from ubcsp_poll **/
/** indicates that a packet can be sent with UBCSP_PACKET_SENT **/
/** **/
/*****************************************************************************/
void ubcsp_send_packet (struct ubcsp_packet *send_packet)
{
/* Initialize the send data to the packet we want to send */
ubcsp_config.send_packet = send_packet;
/* we cannot send the packet at the moment
when we can at the moment, just set things to 0 */
ubcsp_config.send_size = 0;
ubcsp_config.send_ptr = 0;
}
/*****************************************************************************/
/** **/
/** ubcsp_receive_packet **/
/** **/
/** This sends a packet structure for receiving to the ubcsp engine **/
/** This can only be called when the activity indication from ubcsp_poll **/
/** indicates that a packet can be sent with UBCSP_PACKET_RECEIVED **/
/** **/
/*****************************************************************************/
void ubcsp_receive_packet (struct ubcsp_packet *receive_packet)
{
/* Initialize the receive data to the packet we want to receive */
ubcsp_config.receive_packet = receive_packet;
/* setup to receive the header first */
ubcsp_config.receive_index = -4;
}
/*****************************************************************************/
/** **/
/** ubcsp_calc_crc **/
/** **/
/** Takes the next 8 bit value ch, and updates the crc with this value **/
/** **/
/*****************************************************************************/
#ifdef UBCSP_CRC
static uint16 ubcsp_calc_crc (uint8 ch, uint16 crc)
{
/* Calculate the CRC using the above 16 entry lookup table */
static const uint16 crc_table[] =
{
0x0000, 0x1081, 0x2102, 0x3183,
0x4204, 0x5285, 0x6306, 0x7387,
0x8408, 0x9489, 0xa50a, 0xb58b,
0xc60c, 0xd68d, 0xe70e, 0xf78f
};
/* Do this four bits at a time - more code, less space */
crc = (crc >> 4) ^ crc_table[(crc ^ ch) & 0x000f];
crc = (crc >> 4) ^ crc_table[(crc ^ (ch >> 4)) & 0x000f];
return crc;
}
/*****************************************************************************/
/** **/
/** ubcsp_crc_reverse **/
/** **/
/** Reserves the bits in crc and returns the new value **/
/** **/
/*****************************************************************************/
static uint16 ubcsp_crc_reverse (uint16 crc)
{
int32
b,
rev;
/* Reserse the bits to compute the actual CRC value */
for (b = 0, rev=0; b < 16; b++)
{
rev = rev << 1;
rev |= (crc & 1);
crc = crc >> 1;
}
return rev;
}
#endif
/*****************************************************************************/
/** **/
/** ubcsp_put_slip_uart **/
/** **/
/** Outputs a single octet to the uart **/
/** If the octet needs to be escaped, then output the escape value **/
/** and then store the second octet to be output later **/
/** **/
/*****************************************************************************/
static void ubcsp_put_slip_uart (uint8 ch)
{
/* output a single UART octet */
/* If it needs to be escaped, then output the escape octet
and set the send_slip_escape so that the next time we
output the second octet for the escape correctly.
This is done right at the top of ubcsp_poll */
if (ch == SLIP_FRAME)
{
put_uart (SLIP_ESCAPE);
ubcsp_config.send_slip_escape = SLIP_ESCAPE_FRAME;
}
else if (ch == SLIP_ESCAPE)
{
put_uart (SLIP_ESCAPE);
ubcsp_config.send_slip_escape = SLIP_ESCAPE_ESCAPE;
}
else
{
/* Not escaped, so just output octet */
put_uart (ch);
}
}
/*****************************************************************************/
/** **/
/** ubcsp_which_le_payload **/
/** **/
/** Check the payload of this packet, and determine which of the four **/
/** link establishment packets this was. **/
/** Can return 5 if it is not a valid link establishment packet **/
/** **/
/*****************************************************************************/
static uint32 ubcsp_which_le_payload (const uint8 *payload)
{
static int32
octet,
loop;
/* Search through the various link establishment payloads to find
which one we have received */
for (loop = 0; loop < 4; loop ++)
{
for (octet = 0; octet < 4; octet ++)
{
if (payload[octet] != ubcsp_le_buffer[loop][octet])
{
/* Bad match, just to loop again */
goto bad_match_loop;
}
}
/* All the octets matched, return the value */
return loop;
/* Jumps out of octet loop if we got a bad match */
bad_match_loop:
{}
}
/* Non of the link establishment payloads matched - return invalid value */
return 5;
}
/*****************************************************************************/
/** **/
/** ubcsp_recevied_packet **/
/** **/
/** This function is called when we have a SLIP END octet and a full **/
/** packet header and possibly data in the receive packet **/
/** **/
/*****************************************************************************/
static uint8 ubcsp_recevied_packet (void)
{
static uint8
receive_crc,
receive_seq,
receive_ack,
activity;
#if UBCSP_CRC
static int32
loop;
static uint16
crc;
#endif
static uint16
length;
/* Keep track of what activity this received packet will cause */
activity = 0;
/*** Do all error checks that we can ***/
/* First check the header checksum */
if (((ubcsp_receive_header[0] + ubcsp_receive_header[1] + ubcsp_receive_header[2] + ubcsp_receive_header[3]) & 0xff) != 0xff)
{
/* Header Checksum Error */
#if SHOW_PACKET_ERRORS
DebugMessage(1,(_T("######################## Header Checksum Error %02X %02X %02X %02X \r\n"),
ubcsp_receive_header[0],
ubcsp_receive_header[1],
ubcsp_receive_header[2],
ubcsp_receive_header[3]));
#endif
/* If we have a header checksum error, send an ack in return
this gets a packet to be resent as quickly as possible */
ubcsp_config.send_ack = 1;
return activity;
}
/* Decode the received packets header */
ubcsp_config.receive_packet->reliable = (ubcsp_receive_header[0] & 0x80) >> 7;
receive_crc = (ubcsp_receive_header[0] & 0x40) >> 6;
receive_ack = (ubcsp_receive_header[0] & 0x38) >> 3;
receive_seq = (ubcsp_receive_header[0] & 0x07);
ubcsp_config.receive_packet->channel = (ubcsp_receive_header[1] & 0x0f);
length =
((ubcsp_receive_header[1] & 0xf0) >> 4) |
(ubcsp_receive_header[2] << 4);
#if SHOW_PACKET_ERRORS
if (ubcsp_config.receive_packet->reliable)
{
DebugMessage(1,(_T(": %10d Recv SEQ %d ACK %d\r\n"),GetTickCount () % 100000,receive_seq,receive_ack));
}
else if (ubcsp_config.receive_packet->channel != 1)
{
DebugMessage(1,(_T(": %10d ACK %d\r\n"),GetTickCount () % 100000,receive_ack));
}
#endif
/* Check for length errors */
#if UBCSP_CRC
if (receive_crc)
{
/* If this packet had a CRC, then the length of the payload
should be 2 less than the received size of the payload */
if (length + 2 != ubcsp_config.receive_index)
{
/* Slip Length Error */
#if SHOW_PACKET_ERRORS
DebugMessage(1,(_T("++######################## Slip Length Error (With CRC) %d,%d \r\n"),length, ubcsp_config.receive_index - 2));
#endif
/* If we have a payload length error, send an ack in return
this gets a packet to be resent as quickly as possible */
ubcsp_config.send_ack = 1;
return activity;
}
/* We have a CRC at the end of this packet */
ubcsp_config.receive_index -= 2;
/* Calculate the packet CRC */
crc = 0xffff;
/* CRC the packet header */
for (loop = 0; loop < 4; loop ++)
{
crc = ubcsp_calc_crc (ubcsp_receive_header[loop], crc);
}
/* CRC the packet payload - without the CRC bytes */
for (loop = 0; loop < ubcsp_config.receive_index; loop ++)
{
crc = ubcsp_calc_crc (ubcsp_config.receive_packet->payload[loop], crc);
}
/* Reverse the CRC */
crc = ubcsp_crc_reverse (crc);
/* Check the CRC is correct */
if
(
(((crc & 0xff00) >> 8) != ubcsp_config.receive_packet->payload[ubcsp_config.receive_index]) ||
((crc & 0xff) != ubcsp_config.receive_packet->payload[ubcsp_config.receive_index + 1])
)
{
#if SHOW_PACKET_ERRORS
DebugMessage(1,(_T("++######################## CRC Error\r\n")));
#endif
/* If we have a packet crc error, send an ack in return
this gets a packet to be resent as quickly as possible */
ubcsp_config.send_ack = 1;
return activity;
}
}
else
{
#endif
/* No CRC present, so just check the length of payload with that received */
if (length != ubcsp_config.receive_index)
{
/* Slip Length Error */
#if SHOW_PACKET_ERRORS
DebugMessage(1,(_T("++######################## Slip Length Error (No CRC) %d,%d\r\n"), length, ubcsp_config.receive_index));
#endif
/* If we have a payload length error, send an ack in return
this gets a packet to be resent as quickly as possible */
ubcsp_config.send_ack = 1;
return activity;
}
#if UBCSP_CRC
}
#endif
/*** We have a fully formed packet having passed all data integrity checks ***/
/* Check if we have an ACK for the last packet we sent */
if (receive_ack != ubcsp_config.sequence_number)
{
/* Since we only have a window size of 1, if the ACK is not equal to SEQ
then the packet was sent */
if
(
(ubcsp_config.send_packet) &&
(ubcsp_config.send_packet->reliable)
)
{
/* We had sent a reliable packet, so clear this packet
Then increament the sequence number for the next packet */
ubcsp_config.send_packet = 0;
ubcsp_config.sequence_number ++;
ubcsp_config.delay = 0;
/* Notify the caller that we have SENT a packet */
activity |= UBCSP_PACKET_SENT;
}
}
/*** Now we can concentrate of the packet we have received ***/
/* Check for Link Establishment packets */
if (ubcsp_config.receive_packet->channel == 1)
{
/* Link Establishment */
ubcsp_config.delay = 0;
/* Find which link establishment packet this payload means
This could return 5, meaning none */
switch (ubcsp_which_le_payload (ubcsp_config.receive_packet->payload))
{
case 0:
{
/* SYNC Recv'd */
#if SHOW_LE_STATES
DebugMessage(1,(_T("Recv SYNC \r\n")));
#endif
/* If we receive a SYNC, then we respond to it with a SYNC RESP
but only if we are not active.
If we are active, then we have a PEER RESET */
if (ubcsp_config.link_establishment_state < ubcsp_le_active)
{
ubcsp_config.link_establishment_resp = 1;
}
else
{
/* Peer reset !!!! */
#if SHOW_LE_STATES
DebugMessage(1,(_T("PEER RESET \r\n")));
RETAILMSG(1,(_T("PEER RESET \r\n")));
#endif
/* Reinitialize the link */
ubcsp_initialize ();
/* Tell the host what has happened */
return UBCSP_PEER_RESET;
}
break;
}
case 1:
{
/* SYNC RESP Recv'd */
#if SHOW_LE_STATES
DebugMessage(1,(_T("Recv SYNC RESP \r\n")));
#endif
/* If we receive a SYNC RESP, push us into the initialized state */
if (ubcsp_config.link_establishment_state < ubcsp_le_initialized)
{
#if SHOW_LE_STATES
DebugMessage(1,(_T("Link Initialized \r\n")));
#endif
ubcsp_config.link_establishment_state = ubcsp_le_initialized;
}
break;
}
case 2:
{
/* CONF Recv'd */
#if SHOW_LE_STATES
DebugMessage(1,(_T("Recv CONF\r\n")));
#endif
/* If we receive a CONF, and we are initialized or active
then respond with a CONF RESP */
if (ubcsp_config.link_establishment_state >= ubcsp_le_initialized)
{
ubcsp_config.link_establishment_resp = 2;
}
break;
}
case 3:
{
/* CONF RESP Recv'd */
#if SHOW_LE_STATES
DebugMessage(1,(_T("Recv CONF RESP\r\n")));
#endif
/* If we received a CONF RESP, then push us into the active state */
if (ubcsp_config.link_establishment_state < ubcsp_le_active)
{
#if SHOW_LE_STATES
DebugMessage(1,(_T("Link Active\r\n")));
#endif
ubcsp_config.link_establishment_state = ubcsp_le_active;
ubcsp_config.send_size = 0;
return activity | UBCSP_PACKET_SENT;
}
break;
}
}
/* We have finished processing Link Establishment packets */
}
else if (ubcsp_config.receive_index)
{
/* We have some payload data we need to process
but only if we are active - otherwise, we just ignore it */
if (ubcsp_config.link_establishment_state == ubcsp_le_active)
{
if (ubcsp_config.receive_packet->reliable)
{
/* If the packet we've just received was reliable
then send an ACK */
ubcsp_config.send_ack = 1;
/* We the sequence number we received is the same as
the last ACK we sent, then we have received a packet in sequence */
if (receive_seq == ubcsp_config.ack_number)
{
/* Increase the ACK number - which will be sent in the next ACK
or normal packet we send */
ubcsp_config.ack_number ++;
/* Set the values in the receive_packet structure, so the caller
knows how much data we have */
ubcsp_config.receive_packet->length = length;
ubcsp_config.receive_packet = 0;
/* Tell the caller that we have received a packet, and that it
will be ACK'ed */
activity |= UBCSP_PACKET_RECEIVED | UBCSP_PACKET_ACK;
}
}
else
{
/* Set the values in the receive_packet structure, so the caller
knows how much data we have */
ubcsp_config.receive_packet->length = length;
ubcsp_config.receive_packet = 0;
/* Tell the caller that we have received a packet */
activity |= UBCSP_PACKET_RECEIVED;
}
}
}
/* Just return any activity that occured */
return activity;
}
/*****************************************************************************/
/** **/
/** ubcsp_setup_packet **/
/** **/
/** This function is called to setup a packet to be sent **/
/** This allows just a header, or a header and payload to be sent **/
/** It also allows the header checksum to be precalcuated **/
/** or calculated here **/
/** part1 is always 4 bytes **/
/** **/
/*****************************************************************************/
static void ubcsp_setup_packet (uint8 *part1, uint8 calc, uint8 *part2, uint16 len2)
{
/* If we need to calculate the checksum, do that now */
if (calc)
{
part1[3] =
~(part1[0] + part1[1] + part1[2]);
}
/* Setup the header send pointer and size so we can clock this out */
ubcsp_config.send_ptr = part1;
ubcsp_config.send_size = 4;
/* Setup the payload send pointer and size */
ubcsp_config.next_send_ptr = part2;
ubcsp_config.next_send_size = len2;
#if UBCSP_CRC
/* Initialize the crc as required */
ubcsp_config.send_crc = -1;
ubcsp_config.need_send_crc = 1;
#endif
}
/*****************************************************************************/
/** **/
/** ubcsp_sent_packet **/
/** **/
/** Called when we have finished sending a packet **/
/** If this packet was unreliable, then notify caller, and clear the data **/
/** **/
/*****************************************************************************/
static uint8 ubcsp_sent_packet (void)
{
if (ubcsp_config.send_packet)
{
if (!ubcsp_config.send_packet->reliable)
{
/* We had a packet sent that was unreliable */
/* Forget about this packet */
ubcsp_config.send_packet = 0;
/* Notify caller that they can send another one */
return UBCSP_PACKET_SENT;
}
}
/* We didn't have a packet, or it was reliable
Must wait for ACK before allowing another packet to be sent */
return 0;
}
/*****************************************************************************/
/** **/
/** ubcsp_poll **/
/** **/
/** This is the main function for ubcsp **/
/** It performs a number of tasks **/
/** **/
/** 1) Send another octet to the UART - escaping as required **/
/** 2) Setup the payload to be sent after the header has been sent **/
/** 3) Send the CRC for the packet if required **/
/** **/
/** 4) Calculate the next Link Establishment State **/
/** 5) Send a Link Establishment packet **/
/** 6) Send a normal packet if available **/
/** 7) Send an ACK packet if required **/
/** **/
/** 8) Receive octets from UART and deslip them as required **/
/** 9) Place received octets into receive header or receive payload buffer **/
/** 10) Process received packet when SLIP_END is received **/
/** **/
/** 11) Keep track of ability of caller to delay recalling **/
/** **/
/*****************************************************************************/
uint8 ubcsp_poll (uint8 *activity)
{
uint8 delay = UBCSP_POLL_TIME_IMMEDIATE;
uint8 value;
// DebugMessage(1,(_T("++ubcsp_poll++:: Enter.\r\n")));
/* Assume no activity to start with */
*activity = 0;
/* If we don't have to delay, then send something if we can */
/* if(icount >= 9)
{
DebugMessage(1,(_T("enter into ubcsp_poll after icount >= 9 \r\n")));
DebugMessage(1,(_T("delay = %d\r\n"),ubcsp_config.delay));
DebugMessage(1,(_T("send_size = %d\r\n"),ubcsp_config.send_size));
}*/
if (!ubcsp_config.delay)
{
/* Do we have something we are sending to send */
if (ubcsp_config.send_size)
{
/* We have something to send so send it */
if (ubcsp_config.send_slip_escape)
{
/* Last time we send a SLIP_ESCAPE octet
this time send the second escape code */
// DebugMessage(1,(_T("++ubcsp_put_slip_uart++:ubcsp_config.send_slip_escape =0x%x: .\r\n"),ubcsp_config.send_slip_escape));
put_uart (ubcsp_config.send_slip_escape);
ubcsp_config.send_slip_escape = 0;
}
else
{
#if UBCSP_CRC
/* get the value to send, and calculate CRC as we go */
value = *ubcsp_config.send_ptr ++;
ubcsp_config.send_crc = ubcsp_calc_crc (value, ubcsp_config.send_crc);
/* Output the octet */
// DebugMessage(1,(_T("++ubcsp_put_slip_uart++:value =0x%x: .\r\n"),value));
ubcsp_put_slip_uart (value);
#else
/* Just output the octet*/
ubcsp_put_slip_uart (*ubcsp_config.send_ptr ++);
#endif
}
/* If we did output a SLIP_ESCAPE, then don't process the end of a block */
if ((!ubcsp_config.send_slip_escape) && ((ubcsp_config.send_size = ubcsp_config.send_size - 1) == 0))
{
/*** We are at the end of a block - either header or payload ***/
/* setup the next block */
ubcsp_config.send_ptr = ubcsp_config.next_send_ptr;
ubcsp_config.send_size = ubcsp_config.next_send_size;
ubcsp_config.next_send_ptr = 0;
ubcsp_config.next_send_size = 0;
#if UBCSP_CRC
/* If we have no successor block
then we might need to send the CRC */
if (!ubcsp_config.send_ptr)
{
if (ubcsp_config.need_send_crc)
{
/* reverse the CRC from what we computed along the way */
ubcsp_config.need_send_crc = 0;
ubcsp_config.send_crc = ubcsp_crc_reverse (ubcsp_config.send_crc);
/* Save in the send_crc buffer */
ubcsp_send_crc[0] = (uint8) (ubcsp_config.send_crc >> 8);
ubcsp_send_crc[1] = (uint8) ubcsp_config.send_crc;
/* Setup to send this buffer */
ubcsp_config.send_ptr = ubcsp_send_crc;
ubcsp_config.send_size = 2;
}
else
{
/* We don't need to send the crc
either we just have, or this packet doesn't include it */
/* Output the end of FRAME marker */
// DebugMessage(1,(_T("++ubcsp_put_slip_uart++:put_uart1111 SLIP_FRAME: .\r\n")));
put_uart (SLIP_FRAME);
/* Check if this is an unreliable packet */
*activity |= ubcsp_sent_packet ();
/* We've sent the packet, so don't need to have be called quickly soon */
delay = UBCSP_POLL_TIME_DELAY;
}
}
#else
/* If we have no successor block
then we might need to send the CRC */
if (!ubcsp_config.send_ptr)
{
/* Output the end of FRAME marker */
put_uart (SLIP_FRAME);
/* Check if this is an unreliable packet */
*activity |= ubcsp_sent_packet ();
/* We've sent the packet, so don't need to have be called quickly soon */
delay = UBCSP_POLL_TIME_DELAY;
}
#endif
}
}
else if (ubcsp_config.link_establishment_packet == ubcsp_le_none)
{
/* We didn't have something to send
AND we have no Link Establishment packet to send */
if (ubcsp_config.link_establishment_resp & 2)
{
/* Send the start of FRAME packet */
// DebugMessage(1,(_T("++ubcsp_put_slip_uart++:2222Sent SLIP_FRAME: .\r\n")));
put_uart (SLIP_FRAME);
/* We did require a RESP packet - so setup the send */
ubcsp_setup_packet ((uint8*) ubcsp_send_le_header, 0, (uint8*) ubcsp_le_buffer[ubcsp_le_conf_resp], 4);
/* We have now "sent" this packet */
ubcsp_config.link_establishment_resp = 0;
}
else if (ubcsp_config.send_packet)
{
/* There is a packet ready to be sent */
/* Send the start of FRAME packet */
// DebugMessage(1,(_T("++ubcsp_put_slip_uart++:3333Sent SLIP_FRAME: .\r\n")));
put_uart (SLIP_FRAME);
/* Encode up the packet header using ACK and SEQ numbers */
ubcsp_send_header[0] =
(ubcsp_config.send_packet->reliable << 7) |
#if UBCSP_CRC
0x40 | /* Always use CRC's */
#endif
(ubcsp_config.ack_number << 3) |
(ubcsp_config.sequence_number);
/* Encode up the packet header's channel and length */
ubcsp_send_header[1] =
(ubcsp_config.send_packet->channel & 0x0f) |
((ubcsp_config.send_packet->length << 4) & 0xf0);
ubcsp_send_header[2] =
(ubcsp_config.send_packet->length >> 4) & 0xff;
/* Let the ubcsp_setup_packet function calculate the header checksum */
if(5 == ubcsp_config.ack_number)
DebugMessage(1,(_T("\r\npackyload length = %d\r\n"),ubcsp_config.send_packet->length));
ubcsp_setup_packet ((uint8*) ubcsp_send_header, 1, ubcsp_config.send_packet->payload, ubcsp_config.send_packet->length);
/* Don't need to send an ACK - we just place on in this packet */
ubcsp_config.send_ack = 0;
#if SHOW_PACKET_ERRORS
DebugMessage(1,(_T("++%10d Send Seq %d Ack %d\r\n"), GetTickCount () % 100000,ubcsp_config.sequence_number, ubcsp_config.ack_number));
#endif
}
else if (ubcsp_config.send_ack)
{
/* Send the start of FRAME packet */
put_uart (SLIP_FRAME);
#if SHOW_PACKET_ERRORS
DebugMessage(1,(_T("++: %10d Send ACK %d\r\n"), GetTickCount () % 100000,ubcsp_config.ack_number));
#endif
/* The ack packet is already computed apart from the first octet */
ubcsp_send_ack_header[0] =
#if UBCSP_CRC
0x40 |
#endif
(ubcsp_config.ack_number << 3);
/* Let the ubcsp_setup_packet function calculate the header checksum */
ubcsp_setup_packet (ubcsp_send_ack_header, 1, 0, 0);
/* We've now sent the ack */
ubcsp_config.send_ack = 0;
}
else
{
/* We didn't have a Link Establishment response packet,
a normal packet or an ACK packet to send */
if(icount >= 9)
DebugMessage(1,(_T("delay = UBCSP_POLL_TIME_DELAY.\r\n")));
delay = UBCSP_POLL_TIME_DELAY;
}
}
else
{
#if SHOW_PACKET_ERRORS
DebugMessage(1,(_T("%10d Send LE %d\n\r\n"), GetTickCount () % 100000, ubcsp_config.link_establishment_packet));
#endif
/* Send A Link Establishment Message */
// DebugMessage(1,(_T("++ubcsp_put_slip_uart++4444Sent SLIP_FRAME: .\r\n")));
put_uart (SLIP_FRAME);
/* Send the Link Establishment header followed by the
Link Establishment packet */
ubcsp_setup_packet ((uint8*) ubcsp_send_le_header, 0, (uint8*) ubcsp_le_buffer[ubcsp_config.link_establishment_packet], 4);
/* start sending immediately */
ubcsp_config.delay = 0;
/* workout what the next link establishment packet should be */
ubcsp_config.link_establishment_packet = next_le_packet[ubcsp_config.link_establishment_state + ubcsp_config.link_establishment_resp * 4];
/* We have now delt with any response packet that we needed */
ubcsp_config.link_establishment_resp = 0;
return 0;
}
}
// DebugMessage(1,(_T("++We now need to receive any octets from the UART.\r\n")));
/* We now need to receive any octets from the UART */
// if(icount >= 9)
// DebugMessage(1,(_T("\r\nbefore get_uart icount >= 9 = %d\r\n"), icount));
while ((ubcsp_config.receive_packet) && (get_uart (&value)))
{
/* If the last octet was SLIP_ESCAPE, then special processing is required */
//if(icount >= 9)
// DebugMessage(1,(_T("\r\nafter get_uar icount >= 8 = %d \r\n"), icount));
if (ubcsp_config.receive_slip_escape)
{
/* WARNING - out of range values are not detected !!!
This will probably be caught with the checksum or CRC check */
value = ubcsp_deslip[value - SLIP_ESCAPE_FRAME];
ubcsp_config.receive_slip_escape = 0;
}
else
{
/* Check for the SLIP_FRAME octet - must be start or end of packet */
if (value == SLIP_FRAME)
{
/* If we had a full header then we have a packet */
if (ubcsp_config.receive_index >= 0)
{
/* process the received packet */
*activity |= ubcsp_recevied_packet ();
if (*activity & UBCSP_PACKET_ACK)
{
/* We need to ACK this packet, then don't delay its sending */
ubcsp_config.delay = 0;
}
}
/* Setup to receive the next packet */
ubcsp_config.receive_index = -4;
/* Ok, next octet */
goto finished_receive;
}
else if (value == SLIP_ESCAPE)
{
/* If we receive a SLIP_ESCAPE,
then remember to process the next special octet */
ubcsp_config.receive_slip_escape = 1;
goto finished_receive;
}
}
if (ubcsp_config.receive_index < 0)
{
/* We are still receiving the header */
ubcsp_receive_header[ubcsp_config.receive_index + 4] = value;
ubcsp_config.receive_index ++;
}
else if (ubcsp_config.receive_index < ubcsp_config.receive_packet->length)
{
/* We are receiving the payload */
/* We might stop comming here if we are receiving a
packet which is longer than the receive_packet->length
given by the host */
ubcsp_config.receive_packet->payload[ubcsp_config.receive_index] = value;
ubcsp_config.receive_index ++;
}
finished_receive:
{
}
}
if (ubcsp_config.delay > 0)
{
/* We were delayed so delay some more
this could be cancelled if we received something */
ubcsp_config.delay --;
}
else
{
/* We had no delay, so use the delay we just decided to us */
ubcsp_config.delay = delay;
}
/* Report the current delay to the user */
return ubcsp_config.delay;
}
/*****************************************************************************/
/** **/
/** ubcsp_end_of_functions **/
/** **/
/*****************************************************************************/
/* This function is only included to allow for the size
of the code to be determined */
void ubcsp_end_of_functions (void)
{
}
| [
"[email protected]"
]
| [
[
[
1,
1183
]
]
]
|
15697d30ea860c830f59dece32683f6ebbc23eec | 8ffc2ad8cf32ffd9ba2974ee9bb4ae36de90a860 | /SIFT_DEMO/src/kdtree.cpp | 7f03865863f8720a7adc0913c6fc014e0eff0085 | []
| no_license | mhlee1215/sift-custom | ca40895d3b3ba6e3e2c6b45947e21a4e07a5270e | ec3910e172eae4bafa6e21952e058f6875362569 | refs/heads/master | 2016-09-06T10:54:10.910652 | 2010-06-10T08:52:48 | 2010-06-10T08:52:48 | 33,061,761 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,758 | cpp | /*
Functions and structures for maintaining a k-d tree database of image
features.
For more information, refer to:
Beis, J. S. and Lowe, D. G. Shape indexing using approximate
nearest-neighbor search in high-dimensional spaces. In <EM>Conference
on Computer Vision and Pattern Recognition (CVPR)</EM> (2003),
pp. 1000--1006.
Copyright (C) 2006 Rob Hess <[email protected]>
@version 1.1.1-20070913
*/
#include "kdtree.h"
#include "minpq.h"
#include "imgfeatures.h"
#include "utils.h"
#include <cxcore.h>
#include <stdio.h>
struct bbf_data
{
double d;
void* old_data;
};
/************************* Local Function Prototypes *************************/
kd_node* kd_node_init( feature*, int );
void expand_kd_node_subtree( kd_node* );
void assign_part_key( kd_node* );
double median_select( double*, int );
double rank_select( double*, int, int );
void insertion_sort( double*, int );
int partition_array( double*, int, double );
void partition_features( kd_node* );
kd_node* explore_to_leaf( kd_node*, feature*, min_pq* );
int insert_into_nbr_array( feature*, feature**, int, int );
int within_rect( CvPoint2D64f, CvRect );
/******************** Functions prototyped in keyptdb.h **********************/
/*
A function to build a k-d tree database from keypoints in an array.
@param features an array of features
@param n the number of features in features
@return Returns the root of a kd tree built from features or NULL on error.
*/
struct kd_node* kdtree_build( struct feature* features, int n )
{
struct kd_node* kd_root;
if( ! features || n <= 0 )
{
fprintf( stderr, "Warning: kdtree_build(): no features, %s, line %d\n",
__FILE__, __LINE__ );
return NULL;
}
kd_root = kd_node_init( features, n );
expand_kd_node_subtree( kd_root );
return kd_root;
}
/*
Finds an image feature's approximate k nearest neighbors in a kd tree using
Best Bin First search.
@param kd_root root of an image feature kd tree
@param feat image feature for whose neighbors to search
@param k number of neighbors to find
@param nbrs pointer to an array in which to store pointers to neighbors
in order of increasing descriptor distance
@param max_nn_chks search is cut off after examining this many tree entries
@return Returns the number of neighbors found and stored in nbrs, or
-1 on error.
*/
int kdtree_bbf_knn( kd_node* kd_root, feature* feat, int k, feature*** nbrs, int max_nn_chks )
{
kd_node* expl;
min_pq* min_pq;
feature* tree_feat, ** _nbrs;
bbf_data* bbf_data_;
int i, t = 0, n = 0;
if( ! nbrs || ! feat || ! kd_root )
{
fprintf( stderr, "Warning: NULL pointer error, %s, line %d\n",
__FILE__, __LINE__ );
return -1;
}
_nbrs = (feature **)calloc( k, sizeof(feature* ) );
min_pq = minpq_init();
minpq_insert( min_pq, kd_root, 0 );
while( min_pq->n > 0 && t < max_nn_chks )
{
expl = (struct kd_node*)minpq_extract_min( min_pq );
if( ! expl )
{
fprintf( stderr, "Warning: PQ unexpectedly empty, %s line %d\n",
__FILE__, __LINE__ );
goto fail;
}
expl = explore_to_leaf( expl, feat, min_pq );
if( ! expl )
{
fprintf( stderr, "Warning: PQ unexpectedly empty, %s line %d\n",
__FILE__, __LINE__ );
goto fail;
}
for( i = 0; i < expl->n; i++ )
{
tree_feat = &expl->features[i];
bbf_data_ = (bbf_data *)malloc( sizeof( bbf_data ) );
if( ! bbf_data_ )
{
fprintf( stderr, "Warning: unable to allocate memory,"
" %s line %d\n", __FILE__, __LINE__ );
goto fail;
}
bbf_data_->old_data = tree_feat->feature_data;
bbf_data_->d = descr_dist_sq(feat, tree_feat);
tree_feat->feature_data = bbf_data_;
n += insert_into_nbr_array( tree_feat, _nbrs, n, k );
}
t++;
}
minpq_release( &min_pq );
for( i = 0; i < n; i++ )
{
bbf_data_ = (bbf_data *)(_nbrs[i]->feature_data);
_nbrs[i]->feature_data = bbf_data_->old_data;
free( bbf_data_ );
}
*nbrs = _nbrs;
return n;
fail:
minpq_release( &min_pq );
for( i = 0; i < n; i++ )
{
bbf_data_ = (bbf_data *)(_nbrs[i]->feature_data);
_nbrs[i]->feature_data = bbf_data_->old_data;
free( bbf_data_ );
}
free( _nbrs );
*nbrs = NULL;
return -1;
}
/*
Finds an image feature's approximate k nearest neighbors within a specified
spatial region in a kd tree using Best Bin First search.
@param kd_root root of an image feature kd tree
@param feat image feature for whose neighbors to search
@param k number of neighbors to find
@param nbrs pointer to an array in which to store pointers to neighbors
in order of increasing descriptor distance
@param max_nn_chks search is cut off after examining this many tree entries
@param rect rectangular region in which to search for neighbors
@param model if true, spatial search is based on kdtree features' model
locations; otherwise it is based on their image locations
@return Returns the number of neighbors found and stored in \a nbrs
(in case \a k neighbors could not be found before examining
\a max_nn_checks keypoint entries).
*/
int kdtree_bbf_spatial_knn( struct kd_node* kd_root, struct feature* feat,
int k, struct feature*** nbrs, int max_nn_chks,
CvRect rect, int model )
{
struct feature** all_nbrs, ** sp_nbrs;
CvPoint2D64f pt;
int i, n, t = 0;
n = kdtree_bbf_knn( kd_root, feat, max_nn_chks, &all_nbrs, max_nn_chks );
sp_nbrs = (feature **)calloc( k, sizeof( struct feature* ) );
for( i = 0; i < n; i++ )
{
if( model )
pt = all_nbrs[i]->mdl_pt;
else
pt = all_nbrs[i]->img_pt;
if( within_rect( pt, rect ) )
{
sp_nbrs[t++] = all_nbrs[i];
if( t == k )
goto end;
}
}
end:
free( all_nbrs );
*nbrs = sp_nbrs;
return t;
}
/*
De-allocates memory held by a kd tree
@param kd_root pointer to the root of a kd tree
*/
void kdtree_release( kd_node* kd_root )
{
if( ! kd_root )
return;
kdtree_release( kd_root->kd_left );
kdtree_release( kd_root->kd_right );
free( kd_root );
}
/************************ Functions prototyped here **************************/
/*
Initializes a kd tree node with a set of features. The node is not
expanded, and no ordering is imposed on the features.
@param features an array of image features
@param n number of features
@return Returns an unexpanded kd-tree node.
*/
kd_node* kd_node_init( feature* features, int n )
{
kd_node* kd_node_;
kd_node_ = (kd_node *)malloc( sizeof( kd_node ) );
memset( kd_node_, 0, sizeof( kd_node ) );
kd_node_->ki = -1;
kd_node_->features = features;
kd_node_->n = n;
return kd_node_;
}
/*
Recursively expands a specified kd tree node into a tree whose leaves
contain one entry each.
@param kd_node an unexpanded node in a kd tree
*/
void expand_kd_node_subtree( struct kd_node* kd_node_ )
{
/* base case: leaf node */
if( kd_node_->n == 1 || kd_node_->n == 0 )
{
kd_node_->leaf = 1;
return;
}
assign_part_key( kd_node_ );
partition_features( kd_node_ );
if( kd_node_->kd_left )
expand_kd_node_subtree( kd_node_->kd_left );
if( kd_node_->kd_right )
expand_kd_node_subtree( kd_node_->kd_right );
}
/*
Determines the descriptor index at which and the value with which to
partition a kd tree node's features.
@param kd_node a kd tree node
*/
void assign_part_key( kd_node* kd_node_ )
{
struct feature* features;
double kv, x, mean, var, var_max = 0;
double* tmp;
int d, n, i, j, ki = 0;
features = kd_node_->features;
n = kd_node_->n;
d = features[0].d;
/* partition key index is that along which descriptors have most variance */
for( j = 0; j < d; j++ )
{
mean = var = 0;
for( i = 0; i < n; i++ )
mean += features[i].descr[j];
mean /= n;
for( i = 0; i < n; i++ )
{
x = features[i].descr[j] - mean;
var += x * x;
}
var /= n;
if( var > var_max )
{
ki = j;
var_max = var;
}
}
/* partition key value is median of descriptor values at ki */
tmp = (double *)calloc( n, sizeof( double ) );
for( i = 0; i < n; i++ )
tmp[i] = features[i].descr[ki];
kv = median_select( tmp, n );
free( tmp );
kd_node_->ki = ki;
kd_node_->kv = kv;
}
/*
Finds the median value of an array. The array's elements are re-ordered
by this function.
@param array an array; the order of its elelemts is reordered
@param n number of elements in array
@return Returns the median value of array.
*/
double median_select( double* array, int n )
{
return rank_select( array, n, (n - 1) / 2 );
}
/*
Finds the element of a specified rank in an array using the linear time
median-of-medians algorithm by Blum, Floyd, Pratt, Rivest, and Tarjan.
The elements of the array are re-ordered by this function.
@param array an array; the order of its elelemts is reordered
@param n number of elements in array
@param r the zero-based rank of the element to be selected
@return Returns the element from array with zero-based rank r.
*/
double rank_select( double* array, int n, int r )
{
double* tmp, med;
int gr_5, gr_tot, rem_elts, i, j;
/* base case */
if( n == 1 )
return array[0];
/* divide array into groups of 5 and sort them */
gr_5 = n / 5;
gr_tot = cvCeil( n / 5.0 );
rem_elts = n % 5;
tmp = array;
for( i = 0; i < gr_5; i++ )
{
insertion_sort( tmp, 5 );
tmp += 5;
}
insertion_sort( tmp, rem_elts );
/* recursively find the median of the medians of the groups of 5 */
tmp = (double *)calloc( gr_tot, sizeof( double ) );
for( i = 0, j = 2; i < gr_5; i++, j += 5 )
tmp[i] = array[j];
if( rem_elts )
tmp[i++] = array[n - 1 - rem_elts/2];
med = rank_select( tmp, i, ( i - 1 ) / 2 );
free( tmp );
/* partition around median of medians and recursively select if necessary */
j = partition_array( array, n, med );
if( r == j )
return med;
else if( r < j )
return rank_select( array, j, r );
else
{
array += j+1;
return rank_select( array, ( n - j - 1 ), ( r - j - 1 ) );
}
}
/*
Sorts an array in place into increasing order using insertion sort.
@param array an array
@param n number of elements
*/
void insertion_sort( double* array, int n )
{
double k;
int i, j;
for( i = 1; i < n; i++ )
{
k = array[i];
j = i-1;
while( j >= 0 && array[j] > k )
{
array[j+1] = array[j];
j -= 1;
}
array[j+1] = k;
}
}
/*
Partitions an array around a specified value.
@param array an array
@param n number of elements
@param pivot value around which to partition
@return Returns index of the pivot after partitioning
*/
int partition_array( double* array, int n, double pivot )
{
double tmp;
int p, i, j;
i = -1;
for( j = 0; j < n; j++ )
if( array[j] <= pivot )
{
tmp = array[++i];
array[i] = array[j];
array[j] = tmp;
if( array[i] == pivot )
p = i;
}
array[p] = array[i];
array[i] = pivot;
return i;
}
/*
Partitions the features at a specified kd tree node to create its two
children.
@param kd_node a kd tree node whose partition key is set
*/
void partition_features( kd_node* kd_node_ )
{
struct feature* features, tmp;
double kv;
int n, ki, p, i, j = -1;
features = kd_node_->features;
n = kd_node_->n;
ki = kd_node_->ki;
kv = kd_node_->kv;
for( i = 0; i < n; i++ )
if( features[i].descr[ki] <= kv )
{
tmp = features[++j];
features[j] = features[i];
features[i] = tmp;
if( features[j].descr[ki] == kv )
p = j;
}
tmp = features[p];
features[p] = features[j];
features[j] = tmp;
/* if all records fall on same side of partition, make node a leaf */
if( j == n - 1 )
{
kd_node_->leaf = 1;
return;
}
kd_node_->kd_left = kd_node_init( features, j + 1 );
kd_node_->kd_right = kd_node_init( features + ( j + 1 ), ( n - j - 1 ) );
}
/*
Explores a kd tree from a given node to a leaf. Branching decisions are
made at each node based on the descriptor of a given feature. Each node
examined but not explored is put into a priority queue to be explored
later, keyed based on the distance from its partition key value to the
given feature's desctiptor.
@param kd_node root of the subtree to be explored
@param feat feature upon which branching decisions are based
@param min_pq a minimizing priority queue into which tree nodes are placed
as described above
@return Returns a pointer to the leaf node at which exploration ends or
NULL on error.
*/
kd_node* explore_to_leaf( kd_node* kd_node_, feature* feat, min_pq* min_pq )
{
kd_node* unexpl, * expl = kd_node_;
double kv;
int ki;
while( expl && ! expl->leaf )
{
ki = expl->ki;
kv = expl->kv;
if( ki >= feat->d )
{
fprintf( stderr, "Warning: comparing imcompatible descriptors, %s" \
" line %d\n", __FILE__, __LINE__ );
return NULL;
}
if( feat->descr[ki] <= kv )
{
unexpl = expl->kd_right;
expl = expl->kd_left;
}
else
{
unexpl = expl->kd_left;
expl = expl->kd_right;
}
if( minpq_insert( min_pq, unexpl, ABS( kv - feat->descr[ki] ) ) )
{
fprintf( stderr, "Warning: unable to insert into PQ, %s, line %d\n",
__FILE__, __LINE__ );
return NULL;
}
}
return expl;
}
/*
Inserts a feature into the nearest-neighbor array so that the array remains
in order of increasing descriptor distance from the search feature.
@param feat feature to be inderted into the array; it's feature_data field
should be a pointer to a bbf_data with d equal to the squared descriptor
distance between feat and the search feature
@param nbrs array of nearest neighbors neighbors
@param n number of elements already in nbrs and
@param k maximum number of elements in nbrs
@return If feat was successfully inserted into nbrs, returns 1; otherwise
returns 0.
*/
int insert_into_nbr_array( struct feature* feat, struct feature** nbrs,
int n, int k )
{
struct bbf_data* fdata, * ndata;
double dn, df;
int i, ret = 0;
if( n == 0 )
{
nbrs[0] = feat;
return 1;
}
/* check at end of array */
fdata = (struct bbf_data*)feat->feature_data;
df = fdata->d;
ndata = (struct bbf_data*)nbrs[n-1]->feature_data;
dn = ndata->d;
if( df >= dn )
{
if( n == k )
{
feat->feature_data = fdata->old_data;
free( fdata );
return 0;
}
nbrs[n] = feat;
return 1;
}
/* find the right place in the array */
if( n < k )
{
nbrs[n] = nbrs[n-1];
ret = 1;
}
else
{
nbrs[n-1]->feature_data = ndata->old_data;
free( ndata );
}
i = n-2;
while( i >= 0 )
{
ndata = (bbf_data *)nbrs[i]->feature_data;
dn = ndata->d;
if( dn <= df )
break;
nbrs[i+1] = nbrs[i];
i--;
}
i++;
nbrs[i] = feat;
return ret;
}
/*
Determines whether a given point lies within a specified rectangular region
@param pt point
@param rect rectangular region
@return Returns 1 if pt is inside rect or 0 otherwise
*/
int within_rect( CvPoint2D64f pt, CvRect rect )
{
if( pt.x < rect.x || pt.y < rect.y )
return 0;
if( pt.x > rect.x + rect.width || pt.y > rect.y + rect.height )
return 0;
return 1;
}
| [
"mhlee1215@6231343e-7b99-2e4e-8751-d345bb62f328"
]
| [
[
[
1,
655
]
]
]
|
0597e7c443ae026f7cc1587b2ea1d9c3417a3396 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/parameter/keyword.hpp | 425194f14cc9088eeb3c1d7125976d41f0660cb2 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,263 | hpp | // Copyright Daniel Wallin, David Abrahams 2005. Use, modification and
// distribution is subject to the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef KEYWORD_050328_HPP
#define KEYWORD_050328_HPP
#include <boost/parameter/aux_/unwrap_cv_reference.hpp>
#include <boost/parameter/aux_/tag.hpp>
#include <boost/parameter/aux_/default.hpp>
namespace boost { namespace parameter {
// Instances of unique specializations of keyword<...> serve to
// associate arguments with parameter names. For example:
//
// struct rate_; // parameter names
// struct skew_;
// namespace
// {
// keyword<rate_> rate; // keywords
// keyword<skew_> skew;
// }
//
// ...
//
// f(rate = 1, skew = 2.4);
//
template <class Tag>
struct keyword
{
template <class T>
typename aux::tag<Tag, T>::type const
operator=(T& x) const
{
typedef typename aux::tag<Tag, T>::type result;
return result(x);
}
template <class Default>
aux::default_<Tag, Default>
operator|(Default& default_) const
{
return aux::default_<Tag, Default>(default_);
}
template <class Default>
aux::lazy_default<Tag, Default>
operator||(Default& default_) const
{
return aux::lazy_default<Tag, Default>(default_);
}
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) // avoid partial ordering bugs
template <class T>
typename aux::tag<Tag, T const>::type const
operator=(T const& x) const
{
typedef typename aux::tag<Tag, T const>::type result;
return result(x);
}
#endif
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) // avoid partial ordering bugs
template <class Default>
aux::default_<Tag, const Default>
operator|(const Default& default_) const
#if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
volatile
#endif
{
return aux::default_<Tag, const Default>(default_);
}
template <class Default>
aux::lazy_default<Tag, Default>
operator||(Default const& default_) const
#if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
volatile
#endif
{
return aux::lazy_default<Tag, Default>(default_);
}
#endif
public: // Insurance against ODR violations
// People will need to define these keywords in header files. To
// prevent ODR violations, it's important that the keyword used in
// every instantiation of a function template is the same object.
// We provide a reference to a common instance of each keyword
// object and prevent construction by users.
static keyword<Tag>& get()
{
static keyword<Tag> result;
return result;
}
};
// Reduces boilerplate required to declare and initialize keywords
// without violating ODR. Declares a keyword tag type with the given
// name in namespace tag_namespace, and declares and initializes a
// reference in an anonymous namespace to a singleton instance of that
// type.
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
# define BOOST_PARAMETER_KEYWORD(tag_namespace,name) \
namespace tag_namespace \
{ \
struct name \
{ \
static char const* keyword_name() \
{ \
return #name; \
} \
}; \
} \
static ::boost::parameter::keyword<tag_namespace::name>& name \
= ::boost::parameter::keyword<tag_namespace::name>::get();
#else
#define BOOST_PARAMETER_KEYWORD(tag_namespace,name) \
namespace tag_namespace \
{ \
struct name \
{ \
static char const* keyword_name() \
{ \
return #name; \
} \
}; \
} \
namespace \
{ \
::boost::parameter::keyword<tag_namespace::name>& name \
= ::boost::parameter::keyword<tag_namespace::name>::get(); \
}
#endif
}} // namespace boost::parameter
#endif // KEYWORD_050328_HPP
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
148
]
]
]
|
c9249d08eaf913ae01bc126048ab893e359d8b69 | 7d6597b8619a63f65b8a6cfcae721da7592b92aa | /spiral-core/include/spiral/internet/boostreactor/Client.h | df96e461bf3cd22e380c6fd0d9287789e2650c6b | [
"MIT"
]
| permissive | RangelReale/spiral-io | 51eb976a1def7959d364a57921cab527d30ea428 | cf8dbdfcfbef5dc8092fd7ea0ce8d052edf2f35d | refs/heads/master | 2023-07-06T22:39:19.708949 | 2009-12-10T21:00:22 | 2009-12-10T21:00:22 | 37,156,634 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,382 | h | #ifndef _SPIRAL_INTERNET_BOOSTREACTOR_CLIENT_H__
#define _SPIRAL_INTERNET_BOOSTREACTOR_CLIENT_H__
#include <string>
#include <boost/asio.hpp>
#include "spiral/Exception.h"
#include "spiral/internet/boostreactor/Connection.h"
#include "spiral/internet/boostreactor/Connector.h"
#include "spiral/internet/boostreactor/BoostReactor.h"
#include "spiral/internet/address/IPv4Address.h"
namespace spiral {
namespace internet {
namespace boostreactor {
using namespace std;
namespace ba=boost::asio;
namespace bs=boost::system;
using ba::ip::tcp;
class Client : public Connection
{
public:
Client(const string &host, int32_t port, /*bindAddress,*/ Connector *connector, BoostReactor *reactor);
void stopConnecting();
virtual void connectionLost(const Exception &reason);
// ITransport
virtual IAddress getPeer();
virtual IAddress getHost();
virtual void failIfNotConnected(const Exception &err);
protected:
void handle_resolve(const bs::error_code& err,
tcp::resolver::iterator endpoint_iterator);
void handle_connect(const bs::error_code& err,
tcp::resolver::iterator endpoint_iterator);
void connect();
private:
Connector *connector_;
address::IPv4Address address_;
BoostReactor *reactor_;
tcp::resolver resolver_;
};
}}} // spiral::internet::boostreactor
#endif // _SPIRAL_INTERNET_BOOSTREACTOR_CLIENT_H__
| [
"hitnrun@6cb40615-3296-4dc8-bcc4-269c24c2e8c1"
]
| [
[
[
1,
51
]
]
]
|
d8e3e2347c951d34f2a79c605cacc41c620c7d33 | 8dc7ed5499d1f1a7573fb1242b672eefe50178cd | /src/mod/game/server/hl2/hl2_client.cpp | afe17cfc71591cc209dec51034f38893354b238f | []
| no_license | rlmarsh85/bloodlines-resurgence | 8e5b1a1e6e5b9f22128485433fe06a0b78d2d98c | 33409c76cb4939b169bb9e7086457769624b897c | refs/heads/master | 2021-01-15T20:33:37.304393 | 2010-12-17T17:33:11 | 2010-12-17T17:33:11 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 4,795 | cpp | //========= Copyright ยฉ 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
/*
===== tf_client.cpp ========================================================
HL2 client/server game specific stuff
*/
#include "cbase.h"
#include "hl2_player.h"
#include "hl2_gamerules.h"
#include "gamerules.h"
#include "teamplay_gamerules.h"
#include "EntityList.h"
#include "physics.h"
#include "game.h"
#include "player_resource.h"
#include "engine/IEngineSound.h"
#include "vamp_player.h"
#include "tier0/vprof.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
void Host_Say( edict_t *pEdict, bool teamonly );
extern CBaseEntity* FindPickerEntityClass( CBasePlayer *pPlayer, char *classname );
extern bool g_fGameOver;
/*
===========
ClientPutInServer
called each time a player is spawned into the game
============
*/
void ClientPutInServer( edict_t *pEdict, const char *playername )
{
// Allocate a CBasePlayer for pev, and call spawn
//CHL2_Player *pPlayer = CHL2_Player::CreatePlayer( "player", pEdict );
CVamp_Player *pPlayer = CVamp_Player::CreatePlayer( "player", pEdict );
pPlayer->SetPlayerName( playername );
}
void ClientActive( edict_t *pEdict, bool bLoadGame )
{
// CHL2_Player *pPlayer = dynamic_cast< CHL2_Player* >( CBaseEntity::Instance( pEdict ) );
CVamp_Player *pPlayer = dynamic_cast< CVamp_Player* >( CBaseEntity::Instance( pEdict ) );
Assert( pPlayer );
if ( !pPlayer )
{
return;
}
pPlayer->InitialSpawn();
if ( !bLoadGame )
{
pPlayer->Spawn();
}
}
/*
===============
const char *GetGameDescription()
Returns the descriptive name of this .dll. E.g., Half-Life, or Team Fortress 2
===============
*/
const char *GetGameDescription()
{
if ( g_pGameRules ) // this function may be called before the world has spawned, and the game rules initialized
return g_pGameRules->GetGameDescription();
else
return "Half-Life 2";
}
//-----------------------------------------------------------------------------
// Purpose: Given a player and optional name returns the entity of that
// classname that the player is nearest facing
//
// Input :
// Output :
//-----------------------------------------------------------------------------
CBaseEntity* FindEntity( edict_t *pEdict, char *classname)
{
// If no name was given set bits based on the picked
if (FStrEq(classname,""))
{
return (FindPickerEntityClass( static_cast<CBasePlayer*>(GetContainingEntity(pEdict)), classname ));
}
return NULL;
}
//-----------------------------------------------------------------------------
// Purpose: Precache game-specific models & sounds
//-----------------------------------------------------------------------------
void ClientGamePrecache( void )
{
CBaseEntity::PrecacheModel("models/player.mdl");
CBaseEntity::PrecacheModel( "models/gibs/agibs.mdl" );
CBaseEntity::PrecacheModel ("models/weapons/v_hands.mdl");
CBaseEntity::PrecacheScriptSound( "HUDQuickInfo.LowAmmo" );
CBaseEntity::PrecacheScriptSound( "HUDQuickInfo.LowHealth" );
CBaseEntity::PrecacheScriptSound( "FX_AntlionImpact.ShellImpact" );
CBaseEntity::PrecacheScriptSound( "Missile.ShotDown" );
CBaseEntity::PrecacheScriptSound( "Bullets.DefaultNearmiss" );
CBaseEntity::PrecacheScriptSound( "Bullets.GunshipNearmiss" );
CBaseEntity::PrecacheScriptSound( "Bullets.StriderNearmiss" );
CBaseEntity::PrecacheScriptSound( "Geiger.BeepHigh" );
CBaseEntity::PrecacheScriptSound( "Geiger.BeepLow" );
}
// called by ClientKill and DeadThink
void respawn( CBaseEntity *pEdict, bool fCopyCorpse )
{
if (gpGlobals->coop || gpGlobals->deathmatch)
{
if ( fCopyCorpse )
{
// make a copy of the dead body for appearances sake
((CHL2_Player *)pEdict)->CreateCorpse();
}
// respawn player
pEdict->Spawn();
}
else
{ // restart the entire server
engine->ServerCommand("reload\n");
}
}
void GameStartFrame( void )
{
VPROF("GameStartFrame()");
if ( g_fGameOver )
return;
gpGlobals->teamplay = (teamplay.GetInt() != 0);
}
#ifdef HL2_EPISODIC
extern ConVar gamerules_survival;
#endif
//=========================================================
// instantiate the proper game rules object
//=========================================================
void InstallGameRules()
{
#ifdef HL2_EPISODIC
if ( gamerules_survival.GetBool() )
{
// Survival mode
CreateGameRulesObject( "CHalfLife2Survival" );
}
else
#endif
{
// generic half-life
CreateGameRulesObject( "CHalfLife2" );
}
}
| [
"[email protected]",
"Kareem@.(none)"
]
| [
[
[
1,
25
],
[
27,
47
],
[
50,
55
],
[
58,
180
]
],
[
[
26,
26
],
[
48,
49
],
[
56,
57
]
]
]
|
4374665f2ce446533e59d17a4a81e60d4bcbf20e | a01b67b20207e2d31404262146763d3839ee833d | /trunk/Projet/trunk/Scripting/viewerscript.h | e2e71c33a7a26e57a6aafd2a274e2f225710dc9a | []
| no_license | BackupTheBerlios/qtfin-svn | 49b59747b6753c72a035bf1e2e95601f91f5992c | ee18d9eb4f80a57a9121ba32dade96971196a3a2 | refs/heads/master | 2016-09-05T09:42:14.189410 | 2010-09-21T17:34:43 | 2010-09-21T17:34:43 | 40,801,620 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 3,080 | h | #ifndef VIEWERSCRIPT_H
#define VIEWERSCRIPT_H
#include "comsolscript.h"
#include "scriptmanager.h"
namespace Scripting {
/**
* Class representing the viewer COMSOL script.
* The one that generate a picture of the 3D geometry.
*/
class ViewerScript : public ComsolScript
{
public:
/**
* Default constructor.
* @param output_path
* The output_path of the generated image with a 'png' extension.
*/
ViewerScript(QString output_path = ScriptManager::getScriptDirectory("temp.png"));
/** Implementation */
virtual void write(QTextStream& script, Data::ProjectFile& data) const;
// GET
QString getOutputPath() { return output_path; }
// SET
void setOutputPath(QString value) { output_path = value; }
private:
/**
* Write the settings of the script.
*/
void writeMonofinSettings(QTextStream& script, Data::ProjectFile& data) const;
/**
* Writes the entry point called of the script.
*/
void writeMain(QTextStream& script, Data::ProjectFile& data) const;
/* Settings */
/** The generated image path. */
QString output_path;
};
}
#endif
// % Dรฉclaration du dossier contenant les scripts utilisรฉs.
// path('C:\Monofin\Projet\trunk\debug\scripts', path);
//
// % Initialisation d'une variable.
// clear monofin;
//
// % Longueur de l'axe central de la palme en mรจtre.
// monofin.length = 25e-2;
//
// % Courbes de Bรฉzier cubiques (P0, P1, P1, P2).
// % x : [P0.x P1.x P2.x], vecteur des X des points P0, P1 et P2.
// % y : [P0.y P1.y P2.y], vecteur des Y des points P0, P1 et P2.
// %
// % Remarque
// % L'unitรฉ dans laquelle sont exprimรฉes les coordonnรฉes est irrรฉvรฉlante.
// % Elle proviennent de l'interface graphique MonoFin et seront ramenรฉes ร des mรจtres
// % en respectant la longeur spรฉcifiรฉe dans monofin.length.
// monofin.segments = [ ...
// struct('x', [-10 -2 -1], 'y', [0 -65 -98]), ...
// struct('x', [-1 130 404], 'y', [-98 -248 -280]), ...
// struct('x', [404 332 400], 'y', [-280 -145 0])];
//
// % Strates constituant la palme. La premiรจre (resp. derniรจre) strate correspond au dessous (resp. dessus) de la palme.
// % thickness : รฉpaisseur de la strate exprimรฉe en mรจtre
// % length : longueur de la strate en % de monofin.length
// % E : module de Young en Pa
// % nu : coefficient de Poisson
// % rho : densitรฉ en kg/m^3
// monofin.layers = [ ...
// struct('thickness', 1e-2, 'length', 1, 'E', 200000000000, 'nu', 0.33, 'rho', 5000), ...
// struct('thickness', .5e-2, 'length', .9, 'E', 200000000000, 'nu', 0.33, 'rho', 7850), ...
// struct('thickness', 1e-2, 'length', .8, 'E', 200000000000, 'nu', 0.33, 'rho', 7850)];
//
// % Paramรจtres de la palme.
// % output_path : chemin de l'image (au format png) ร gรฉnรฉrer
// monofin.settings = struct( ...
// 'output_path', 'C:\Monofin\Projet\trunk\debug\scripts\toto');
//
// % Appel du point d'entrรฉe du script.
// viewer_main(monofin);
| [
"cyoann@314bda93-af5c-0410-b653-d297496769b1"
]
| [
[
[
1,
95
]
]
]
|
5f4b30d24fc8aa34801ffaf53b5b457dd5982149 | f2cc5cef5b0375083b98a13cd28edcee19e55e70 | /src/WidgetNavigator/WNavigator.h | 722a3bf1f0689d97882c4a24adf0513927ef5e70 | []
| no_license | romanio/mpsqt | 6153b598d6c17e0127a2e8130036bf7bb9e7aa26 | 7dbeb33cf92f7db46763ec94fc008f6e7635dac1 | refs/heads/master | 2021-01-20T10:11:07.723341 | 2010-07-14T20:36:21 | 2010-07-14T20:36:21 | 32,221,641 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 964 | h | #ifndef WNAVIGATOR_H
#define WNAVIGATOR_H
#include <QDockWidget>
#include <QVBoxLayout>
#include <QLabel>
#include <QComboBox>
#include <QCheckBox>
#include <QTableView>
#include <QLineEdit>
#include <QAbstractTableModel>
#include "..\SharedData/SharedData.h"
#include "..\SharedSelector\SharedSelector.h"
#include "NavModelWellList.h"
#include "NavModelProxyWellList.h"
class WNavigator : public QDockWidget
{
Q_OBJECT
public:
WNavigator(QWidget *parent = 0);
~WNavigator();
void update();
private:
QWidget* widgetContents;
QVBoxLayout* verticalLayout;
QLabel* labelWellFilter;
QComboBox* comboGroups;
QCheckBox* checkAllWells;
QTableView* tableWellList;
QLineEdit* lineFilter;
SharedData* m_data;
SharedSelector* m_select;
NavModelWellList* modelWellList;
NavModelProxyWellList* proxyWellList;
private slots:
void selectGroup(int gID);
void selectWell();
};
#endif // WNAVIGATOR_H
| [
"rkositsyn@95aae30a-fe7a-11de-b8ab-b3eb4b1fa784"
]
| [
[
[
1,
44
]
]
]
|
7749adf75717d28992f236bae3d80c6c34881449 | ee8761abf9db9f797753326be3640ddd1f57206c | /gKit/Widgets/nvglutils/nvShaderUtils.h | cb2c9d957618b68bcfb6dfa5eecc1ff280f8c526 | []
| no_license | Mefteg/3-sub-ways | fba4d0330943f7d9d2501d01e221c7d46cac7883 | 49218cf4ef7413036bdcdee16d5cd52f4896d4a2 | refs/heads/master | 2020-05-18T12:52:50.357430 | 2011-10-29T15:15:58 | 2011-10-29T15:15:58 | 32,360,588 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,571 | h | //
// Utility functions for compiling shaders and programs
//
// Author: Evan Hart
// Copyright (c) NVIDIA Corporation. All rights reserved.
////////////////////////////////////////////////////////////////////////////////
#ifndef NV_SHADER_UTILS_H
#define NV_SHADER_UTILS_H
#include <stdio.h>
#include <string.h>
#include <GL/glew.h>
namespace nv {
//
//
////////////////////////////////////////////////////////////
inline GLuint CompileGLSLShader( GLenum target, const char* shader) {
GLuint object;
object = glCreateShader( target);
if (!object)
return object;
glShaderSource( object, 1, &shader, NULL);
glCompileShader(object);
// check if shader compiled
GLint compiled = 0;
glGetShaderiv(object, GL_COMPILE_STATUS, &compiled);
if (!compiled) {
#ifdef NV_REPORT_COMPILE_ERRORS
char temp[256] = "";
glGetShaderInfoLog( object, 256, NULL, temp);
fprintf( stderr, "Compile failed:\n%s\n", temp);
#endif
glDeleteShader( object);
return 0;
}
return object;
}
//
//
////////////////////////////////////////////////////////////
inline GLuint CompileGLSLShaderFromFile( GLenum target, const char* filename) {
FILE *shaderFile;
char *text;
long size;
//must read files as binary to prevent problems from newline translation
shaderFile = fopen( filename, "rb");
if ( shaderFile == NULL)
return 0;
fseek( shaderFile, 0, SEEK_END);
size = ftell(shaderFile);
fseek( shaderFile, 0, SEEK_SET);
text = new char[size+1];
fread( text, size, 1, shaderFile);
fclose( shaderFile);
text[size] = '\0';
GLuint object = CompileGLSLShader( target, text);
delete []text;
return object;
}
// Create a program composed of vertex and fragment shaders.
inline GLuint LinkGLSLProgram( GLuint vertexShader, GLuint fragmentShader) {
GLuint program = glCreateProgram();
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);
glLinkProgram(program);
#ifdef NV_REPORT_COMPILE_ERRORS
// Get error log.
GLint charsWritten, infoLogLength;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
char * infoLog = new char[infoLogLength];
glGetProgramInfoLog(program, infoLogLength, &charsWritten, infoLog);
fputs(infoLog, stdout);
delete [] infoLog;
#endif
// Test linker result.
GLint linkSucceed = GL_FALSE;
glGetProgramiv(program, GL_LINK_STATUS, &linkSucceed);
if (linkSucceed == GL_FALSE) {
glDeleteProgram(program);
return 0;
}
return program;
}
// Create a program composed of vertex, geometry and fragment shaders.
inline GLuint LinkGLSLProgram( GLuint vertexShader, GLuint geometryShader, GLint inputType, GLint vertexOut, GLint outputType, GLuint fragmentShader) {
GLuint program = glCreateProgram();
glAttachShader(program, vertexShader);
glAttachShader(program, geometryShader);
glProgramParameteriEXT(program, GL_GEOMETRY_INPUT_TYPE_EXT, inputType);
glProgramParameteriEXT(program, GL_GEOMETRY_VERTICES_OUT_EXT, vertexOut);
glProgramParameteriEXT(program, GL_GEOMETRY_OUTPUT_TYPE_EXT, outputType);
glAttachShader(program, fragmentShader);
glLinkProgram(program);
#ifdef NV_REPORT_COMPILE_ERRORS
// Get error log.
GLint charsWritten, infoLogLength;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
char * infoLog = new char[infoLogLength];
glGetProgramInfoLog(program, infoLogLength, &charsWritten, infoLog);
fputs(infoLog, stdout);
delete [] infoLog;
#endif
// Test linker result.
GLint linkSucceed = GL_FALSE;
glGetProgramiv(program, GL_LINK_STATUS, &linkSucceed);
if (linkSucceed == GL_FALSE) {
glDeleteProgram(program);
return 0;
}
return program;
}
//
//
////////////////////////////////////////////////////////////
inline GLuint CompileASMShader(GLenum program_type, const char *code) {
GLuint program_id;
glGenProgramsARB(1, &program_id);
glBindProgramARB(program_type, program_id);
glProgramStringARB(program_type, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei) strlen(code), (GLubyte *) code);
GLint error_pos;
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &error_pos);
if (error_pos != -1) {
#ifdef NV_REPORT_COMPILE_ERRORS
const GLubyte *error_string;
error_string = glGetString(GL_PROGRAM_ERROR_STRING_ARB);
fprintf(stderr, "Program error at position: %d\n%s\n", (int)error_pos, error_string);
#endif
return 0;
}
return program_id;
}
//
//
////////////////////////////////////////////////////////////
inline GLuint CompileASMShaderFromFile( GLenum target, const char* filename) {
FILE *shaderFile;
char *text;
long size;
//must read files as binary to prevent problems from newline translation
shaderFile = fopen( filename, "rb");
if ( shaderFile == NULL)
return 0;
fseek( shaderFile, 0, SEEK_END);
size = ftell(shaderFile);
fseek( shaderFile, 0, SEEK_SET);
text = new char[size+1];
fread( text, size, 1, shaderFile);
fclose( shaderFile);
text[size] = '\0';
GLuint program_id = CompileASMShader( target, text);
delete []text;
return program_id;
}
} // nv namespace
#endif // NV_SHADER_UTILS_H
| [
"[email protected]@ae0aad3f-0d2d-2c89-41f8-224e04efc9db"
]
| [
[
[
1,
212
]
]
]
|
3ae12c0effb29c0a623ea0f785e654827796f040 | 0f973718202109e95fc25240d1cec2d952225732 | /Source/Cannonball.cpp | 07ee3a13e9772136c88fabca789c30d94c7c8f33 | []
| no_license | RadicalZephyr/fast-ai | eeb9a7bb2357680f63f06c5d49361e274772b456 | 4f8b9847f6d59f0ec0fcbbdaef8b2c7291be338f | refs/heads/master | 2021-01-01T19:47:08.047409 | 2011-09-28T01:14:48 | 2011-09-28T01:14:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,183 | cpp | #include "Cannonball.h"
#include "Important/Common.h"
#include "Util/Debug.h"
#include "Util/Functions.h"
#include "UnitTrainingManager\Behaviours/NexusBehaviour.h"
#include "UnitTrainingManager\Behaviours/DefaultBehaviour.h"
#include "Cheese/StrategyManager.h"
#include "UnitTrainingManager/Behaviours/GatewayBehaviour.h"
#include "UnitTrainingManager/Behaviours/RoboticsBehaviour.h"
using namespace BWAPI;
void Cannonball::onStart()
{
// Enable some cheat flags
Broodwar->enableFlag(Flag::UserInput);
setDebugSpeed(true);
// Uncomment to enable complete map information
//Broodwar->enableFlag(Flag::CompleteMapInformation);
// Creation of the g_managerWatchMap. Nexii get a specialized behaviour, all other buildings get the default (PRODUCE SOMETHING!!)
g_managerWatchMap.insert(std::make_pair(BWAPI::UnitTypes::Protoss_Nexus,
static_cast<UnitTrainingManager_BaseBehaviourFactory *>(new BM_BehaviourFactory<NexusBehaviour>)));
// Gateways produce zealots, and then make a class to cause the zealots to wander the map
g_managerWatchMap.insert(std::make_pair(BWAPI::UnitTypes::Protoss_Gateway,
static_cast<UnitTrainingManager_BaseBehaviourFactory *>(new BM_BehaviourFactory<GatewayBehaviour>)));
// Default behaviours
g_managerWatchMap.insert(std::make_pair(BWAPI::UnitTypes::Protoss_Carrier,
static_cast<UnitTrainingManager_BaseBehaviourFactory *>(new BM_BehaviourFactory<DefaultBehaviour>)));
g_managerWatchMap.insert(std::make_pair(BWAPI::UnitTypes::Protoss_Reaver,
static_cast<UnitTrainingManager_BaseBehaviourFactory *>(new BM_BehaviourFactory<DefaultBehaviour>)));
//g_managerWatchMap.insert(std::make_pair(BWAPI::UnitTypes::Protoss_Stargate,
// static_cast<UnitTrainingManager_BaseBehaviourFactory *>(new BM_BehaviourFactory<DefaultBehaviour>)));
g_managerWatchMap.insert(std::make_pair(BWAPI::UnitTypes::Protoss_Robotics_Facility,
static_cast<UnitTrainingManager_BaseBehaviourFactory *>(new BM_BehaviourFactory<RoboticsBehaviour>)));
// Register to check the watch map every time we create a unit
Signal::onFriendlyUnitCreate().connect(boost::bind(&checkForBuildings, _1, g_managerWatchMap));
Signal::onStart() ();
//std::set<BWAPI::TilePosition> startLocs = Broodwar->getStartLocations();
//char buff[2048];
//int point = 0;
//point += sprintf(buff, "Num locations: %d\n", startLocs.size());
//for (std::set<BWAPI::TilePosition>::iterator itr = startLocs.begin();
// itr != startLocs.end(); ++itr) {
// point += sprintf(buff+point, "x: %d, y: %d\n", itr->x(), itr->y());
//}
//PersistentPrinter *printer = new PersistentPrinter;
//printer->printf("%s", buff);
}
void Cannonball::onSendText(std::string text)
{
// This is the place to capture user input to do stuff with
//Broodwar->printf("onSendText called: '%s'", text.c_str());
if (UnitTypes::getUnitType(text) != UnitTypes::None) {
UnitTypeSet const buildSet = buildsWhat(UnitTypes::getUnitType(text));
//Broodwar->printf("%s can build:\n", UnitTypes::getUnitType(text).getName().c_str());
for (UnitTypeSet::const_iterator itr = buildSet.begin(); itr != buildSet.end(); itr++) {
Broodwar->printf("%s", itr->getName().c_str());
}
}
Signal::onSendText() (text);
}
// The actually import callbacks to our AI
void Cannonball::onFrame()
{
/* Global Update TODO: Move somewhere more general */
g_frame = Broodwar->getFrameCount();
if (Broodwar->isReplay())
return;
//if(probes->inLocation()) {
// Broodwar->printf("Happened");
// probes->nextLocation();
//}
Signal::onFrame() ();
}
// Best place to do stuff with our units because going to be
// called more for our units than the enemies
void Cannonball::onUnitCreate(BWAPI::Unit* unit)
{
// The unit belongs to us
if (unit->getPlayer() == Broodwar->self()) {
//Broodwar->printf("Created a %s", unit->getType().getName().c_str());
Signal::onFriendlyUnitCreate() (unit);
} else {
Signal::onEnemyUnitCreate() (unit);
}
}
// Probably mostly for responding to enemy units
void Cannonball::onUnitDiscover(BWAPI::Unit* unit)
{
//if (!Broodwar->isReplay() && Broodwar->getFrameCount()>1)
// Broodwar->sendText("A %s [%x] has been discovered at (%d,%d)",unit->getType().getName().c_str(),unit,unit->getPosition().x(),unit->getPosition().y());
Signal::onUnitDiscover() (unit);
}
void Cannonball::onUnitShow(BWAPI::Unit* unit)
{
//if (!Broodwar->isReplay() && Broodwar->getFrameCount()>1)
// Broodwar->sendText("A %s [%x] has been spotted at (%d,%d)",unit->getType().getName().c_str(),unit,unit->getPosition().x(),unit->getPosition().y());
Signal::onUnitShow() (unit);
}
/// Relatively unused callbacks
void Cannonball::onEnd(bool isWinner)
{
Signal::onEnd() (isWinner);
}
void Cannonball::onReceiveText(BWAPI::Player* player, std::string text)
{
//Broodwar->printf("%s said '%s'", player->getName().c_str(), text.c_str());
Signal::onReceiveText() (player, text);
}
void Cannonball::onPlayerLeft(BWAPI::Player* player)
{
//Broodwar->sendText("%s left the game.",player->getName().c_str());
Signal::onPlayerLeft() (player);
}
void Cannonball::onNukeDetect(BWAPI::Position target)
{
//if (target!=Positions::Unknown)
// Broodwar->printf("Nuclear Launch Detected at (%d,%d)",target.x(),target.y());
//else
// Broodwar->printf("Nuclear Launch Detected");
Signal::onNukeDetect() (target);
}
void Cannonball::onUnitEvade(BWAPI::Unit* unit)
{
//if (!Broodwar->isReplay() && Broodwar->getFrameCount()>1)
// Broodwar->sendText("A %s [%x] was last accessible at (%d,%d)",unit->getType().getName().c_str(),unit,unit->getPosition().x(),unit->getPosition().y());
Signal::onUnitEvade() (unit);
}
void Cannonball::onUnitHide(BWAPI::Unit* unit)
{
//if (!Broodwar->isReplay() && Broodwar->getFrameCount()>1)
// Broodwar->sendText("A %s [%x] was last seen at (%d,%d)",unit->getType().getName().c_str(),unit,unit->getPosition().x(),unit->getPosition().y());
Signal::onUnitHide() (unit);
}
void Cannonball::onUnitDestroy(BWAPI::Unit* unit)
{
//if (!Broodwar->isReplay() && Broodwar->getFrameCount()>1)
// Broodwar->sendText("A %s [%x] has been destroyed at (%d,%d)",unit->getType().getName().c_str(),unit,unit->getPosition().x(),unit->getPosition().y());
if (unit->getPlayer() == Broodwar->self()) {
Signal::onFriendlyUnitDestroy() (unit);
} else if (unit->getPlayer()->getType() == PlayerTypes::Neutral) {
Signal::onNeutralUnitDestroy() (unit);
} else {
Signal::onEnemyUnitDestroy() (unit);
}
}
void Cannonball::onUnitMorph(BWAPI::Unit* unit)
{
if (!Broodwar->isReplay())
Broodwar->sendText("A %s [%x] has been morphed at (%d,%d)",unit->getType().getName().c_str(),unit,unit->getPosition().x(),unit->getPosition().y());
else
{
/*if we are in a replay, then we will print out the build order
(just of the buildings, not the units).*/
if (unit->getType().isBuilding() && unit->getPlayer()->isNeutral()==false)
{
int seconds=Broodwar->getFrameCount()/24;
int minutes=seconds/60;
seconds%=60;
Broodwar->sendText("%.2d:%.2d: %s morphs a %s",minutes,seconds,unit->getPlayer()->getName().c_str(),unit->getType().getName().c_str());
}
}
Signal::onUnitMorph() (unit);
}
void Cannonball::onUnitRenegade(BWAPI::Unit* unit)
{
//if (!Broodwar->isReplay())
// Broodwar->sendText("A %s [%x] is now owned by %s",unit->getType().getName().c_str(),unit,unit->getPlayer()->getName().c_str());
Signal::onUnitRenegade() (unit);
}
void Cannonball::onSaveGame(std::string gameName)
{
//Broodwar->printf("The game was saved to \"%s\".", gameName.c_str());
Signal::onSaveGame() (gameName);
}
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
9
],
[
11,
35
],
[
37,
217
]
],
[
[
10,
10
],
[
36,
36
]
]
]
|
72ee873bac0cb0c78bbfaed30b41b0baea0fca35 | 28ba648bc8e18d3ad3878885ad39a05ebfb9259c | /CGWorkOpenGL/OpenGLView.cpp | c490c6105aee13cc64e3b8fe55d5e50280e7b66a | []
| no_license | LinusTIAN/cg1-winter10 | 67da233f27dcf2fa693d830598473fde7d402ece | 0b929141c6eac3b96c038656e58620767ff52d9f | refs/heads/master | 2020-05-05T08:12:56.957326 | 2011-01-31T13:24:08 | 2011-01-31T13:24:08 | 36,010,723 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 54,603 | cpp | // OpenGLView.cpp : implementation of the COpenGLView class
//
#include "stdafx.h"
#include "OpenGL.h"
#include "OpenGLDoc.h"
#include "OpenGLView.h"
#include <fstream>
#include <iostream>
using std::cout;
using std::endl;
#include <math.h>
#include "shlobj.h"
#include "MaterialDlg.h"
#include "LightDialog.h"
#include "MouseSensitivityDialog.h"
#include "MaterialDlg.h"
#include "FogDialog.h"
#include "LoadTextureDlg.h"
#include "MyEdgeDetector.h"
#include "globals.h"
#include <climits>
#ifdef _DEBUG
//#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "PngWrapper.h"
#include "iritSkel.h"
#include "shadersSkel.h"
#define _USE_MATH_DEFINES
#include <cmath>
// For Status Bar access
#include "MainFrm.h"
// Use this macro to display text messages in the status bar.
#define STATUS_BAR_TEXT(str) (((CMainFrame*)GetParentFrame())->getStatusBar().SetWindowText(str))
/////////////////////////////////////////////////////////////////////////////
// COpenGLView
IMPLEMENT_DYNCREATE(COpenGLView, CView)
BEGIN_MESSAGE_MAP(COpenGLView, CView)
//{{AFX_MSG_MAP(COpenGLView)
ON_WM_ERASEBKGND()
ON_WM_CREATE()
ON_WM_DESTROY()
ON_WM_SIZE()
ON_COMMAND(ID_FILE_LOAD, OnFileLoad)
ON_COMMAND(ID_VIEW_ORTHOGRAPHIC, OnViewOrthographic)
ON_UPDATE_COMMAND_UI(ID_VIEW_ORTHOGRAPHIC, OnUpdateViewOrthographic)
ON_COMMAND(ID_VIEW_PERSPECTIVE, OnViewPerspective)
ON_UPDATE_COMMAND_UI(ID_VIEW_PERSPECTIVE, OnUpdateViewPerspective)
ON_COMMAND(ID_ACTION_ROTATE, OnActionRotate)
ON_UPDATE_COMMAND_UI(ID_ACTION_ROTATE, OnUpdateActionRotate)
ON_COMMAND(ID_ACTION_SCALE, OnActionScale)
ON_UPDATE_COMMAND_UI(ID_ACTION_SCALE, OnUpdateActionScale)
ON_COMMAND(ID_ACTION_TRANSLATE, OnActionTranslate)
ON_UPDATE_COMMAND_UI(ID_ACTION_TRANSLATE, OnUpdateActionTranslate)
ON_COMMAND(ID_AXIS_X, OnAxisX)
ON_UPDATE_COMMAND_UI(ID_AXIS_X, OnUpdateAxisX)
ON_COMMAND(ID_AXIS_Y, OnAxisY)
ON_UPDATE_COMMAND_UI(ID_AXIS_Y, OnUpdateAxisY)
ON_COMMAND(ID_AXIS_Z, OnAxisZ)
ON_UPDATE_COMMAND_UI(ID_AXIS_Z, OnUpdateAxisZ)
ON_COMMAND(ID_LIGHT_SHADING_FLAT, OnLightShadingFlat)
ON_UPDATE_COMMAND_UI(ID_LIGHT_SHADING_FLAT, OnUpdateLightShadingFlat)
ON_COMMAND(ID_LIGHT_SHADING_GOURAUD, OnLightShadingGouraud)
ON_UPDATE_COMMAND_UI(ID_LIGHT_SHADING_GOURAUD, OnUpdateLightShadingGouraud)
ON_COMMAND(ID_LIGHT_CONSTANTS, OnLightConstants)
//}}AFX_MSG_MAP
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_COMMAND(ID_ACTION_OBJECTSPACE, &COpenGLView::OnActionObjectspace)
ON_UPDATE_COMMAND_UI(ID_ACTION_OBJECTSPACE, &COpenGLView::OnUpdateActionObjectspace)
ON_COMMAND(ID_ACTION_VIEWSPACE, &COpenGLView::OnActionViewspace)
ON_UPDATE_COMMAND_UI(ID_ACTION_VIEWSPACE, &COpenGLView::OnUpdateActionViewspace)
ON_COMMAND(ID_OPTIONS_MOUSESENSITIVITY, &COpenGLView::OnOptionsMousesensitivity)
ON_COMMAND(ID_OPTIONS_CHANGEWIRECOLOR, &COpenGLView::OnOptionsChangewirecolor)
ON_COMMAND(ID_OPTIONS_CHANGEBACKGROUNDCOLOR, &COpenGLView::OnOptionsChangebackgroundcolor)
ON_COMMAND(ID_OPTIONS_DRAWBOUNDINGBOX, &COpenGLView::OnOptionsDrawboundingbox)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_DRAWBOUNDINGBOX, &COpenGLView::OnUpdateOptionsDrawboundingbox)
ON_COMMAND(ID_OPTIONS_SHOWVERTICESNORMALS, &COpenGLView::OnOptionsShowverticesnormals)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_SHOWVERTICESNORMALS, &COpenGLView::OnUpdateOptionsShowverticesnormals)
ON_COMMAND(ID_OPTIONS_SHOWFACESNORMALS, &COpenGLView::OnOptionsShowfacesnormals)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_SHOWFACESNORMALS, &COpenGLView::OnUpdateOptionsShowfacesnormals)
ON_COMMAND(ID_OPTIONS_PERSPECTIVECONTROL, &COpenGLView::OnOptionsPerspectivecontrol)
ON_WM_LBUTTONUP()
ON_COMMAND(ID_OPTIONS_TORCH, &COpenGLView::OnOptionsTorch)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_TORCH, &COpenGLView::OnUpdateOptionsTorch)
ON_WM_KEYDOWN()
ON_COMMAND(ID_AXIS_XY, &COpenGLView::OnAxisXy)
ON_UPDATE_COMMAND_UI(ID_AXIS_XY, &COpenGLView::OnUpdateAxisXy)
ON_COMMAND(ID_FILE_RESET, &COpenGLView::OnFileReset)
ON_COMMAND(ID_ACTION_UNIFORMSCALING, &COpenGLView::OnActionUniformscaling)
ON_UPDATE_COMMAND_UI(ID_ACTION_UNIFORMSCALING, &COpenGLView::OnUpdateActionUniformscaling)
ON_COMMAND(ID_SHADING_WIREFRAME, &COpenGLView::OnShadingWireframe)
ON_UPDATE_COMMAND_UI(ID_SHADING_WIREFRAME, &COpenGLView::OnUpdateShadingWireframe)
ON_COMMAND(ID_MATERIAL_LOADTEXTURE, &COpenGLView::OnMaterialLoadtexture)
ON_COMMAND(ID_OPTIONS_BACKFACESCULLING, &COpenGLView::OnOptionsBackfacesculling)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_BACKFACESCULLING, &COpenGLView::OnUpdateOptionsBackfacesculling)
ON_COMMAND(ID_LIGHT_FOG, &COpenGLView::OnLightFog)
ON_COMMAND(ID_MATERIAL_PROPERTIES, &COpenGLView::OnMaterialProperties)
ON_COMMAND(ID_ACTION_TEXTURETRANSFORMATIONS, &COpenGLView::OnActionTexturetransformations)
ON_UPDATE_COMMAND_UI(ID_ACTION_TEXTURETRANSFORMATIONS, &COpenGLView::OnUpdateActionTexturetransformations)
ON_COMMAND(ID_RESET_LIGHT, &COpenGLView::OnResetLight)
ON_COMMAND(ID_RESET_VIEW, &COpenGLView::OnResetView)
ON_COMMAND(ID_MATERIAL_TESSELATION, &COpenGLView::OnMaterialTesselation)
ON_UPDATE_COMMAND_UI(ID_MATERIAL_TESSELATION, &COpenGLView::OnUpdateMaterialTesselation)
ON_COMMAND(ID_MATERIAL_LOADMIPMAP, &COpenGLView::OnMaterialLoadmipmap)
ON_COMMAND(ID_ADVANCED_LOADBACKGROUNG, &COpenGLView::OnAdvancedLoadbackgroung)
ON_COMMAND(ID_ADVANCED_EXPORTIMAGE, &COpenGLView::OnAdvancedExportimage)
ON_COMMAND(ID_ADVANCED_ADVANCEDSHADING, &COpenGLView::OnAdvancedAdvancedshading)
ON_UPDATE_COMMAND_UI(ID_ADVANCED_ADVANCEDSHADING, &COpenGLView::OnUpdateAdvancedAdvancedshading)
ON_UPDATE_COMMAND_UI(ID_ADVANCED_CELSHADING, &COpenGLView::OnUpdateAdvancedCelshading)
ON_COMMAND(ID_ADVANCED_CELSHADING, &COpenGLView::OnAdvancedCelshading)
ON_UPDATE_COMMAND_UI(ID_ADVANCED_DRAWOUTLINES, &COpenGLView::OnUpdateAdvancedDrawoutlines)
ON_COMMAND(ID_ADVANCED_DRAWOUTLINES, &COpenGLView::OnAdvancedDrawoutlines)
END_MESSAGE_MAP()
// A patch to fix GLaux disappearance from VS2005 to VS2008
void auxSolidCone(GLdouble radius, GLdouble height) {
GLUquadric *quad = gluNewQuadric();
gluQuadricDrawStyle(quad, GLU_FILL);
gluCylinder(quad, radius, 0.0, height, 20, 20);
gluDeleteQuadric(quad);
}
/////////////////////////////////////////////////////////////////////////////
// COpenGLView construction/destruction
COpenGLView::COpenGLView()
: m_LastTransformPoint(0)
, m_lastCtrlPoint(0)
, m_mouseScreenZ(0)
{
m_backgroundObj = NULL;
w_bbox = NULL;
m_showTesselation = false;
m_useShaders = false;
m_celShading = false;
m_drawOutlines = false;
m_mouseSensitivity = 50;
m_showBoundingBox = false;
m_showVertexNormals = false;
m_showFaceNormals = false;
m_recompile = false;
m_showBackFaces = true;
m_backgroundColor[0] = m_backgroundColor[1] = m_backgroundColor[2] = 0;
// Set default values
m_nAxis = ID_AXIS_X;
m_nAction = ID_ACTION_ROTATE;
m_nView = ID_VIEW_ORTHOGRAPHIC;
m_nSpace = ID_ACTION_VIEWSPACE;
m_bIsPerspective = false;
m_nLightShading = ID_LIGHT_SHADING_GOURAUD;
//init the first light to be enabled
m_lights[LIGHT_ID_1].enabled=true;
lightReset();
}
COpenGLView::~COpenGLView()
{
if (glsl_OK)
delShaders();
}
/////////////////////////////////////////////////////////////////////////////
// COpenGLView diagnostics
#ifdef _DEBUG
void COpenGLView::AssertValid() const
{
CView::AssertValid();
}
void COpenGLView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
COpenGLDoc* COpenGLView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COpenGLDoc)));
return (COpenGLDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// COpenGLView Window Creation - Linkage of windows to OpenGL
BOOL COpenGLView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
// An OpenGL window must be created with the following
// flags and must NOT include CS_PARENTDC for the
// class style.
cs.style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
return CView::PreCreateWindow(cs);
}
int COpenGLView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
InitializeOpenGL();
return 0;
}
// This method initialized the OpenGL system.
BOOL COpenGLView::InitializeOpenGL()
{
m_pDC = new CClientDC(this);
if ( NULL == m_pDC ) { // failure to get DC
::AfxMessageBox("Couldn't get a valid DC.");
return FALSE;
}
if ( !SetupPixelFormat() ) {
::AfxMessageBox("SetupPixelFormat failed.\n");
return FALSE;
}
if ( 0 == (m_hRC = ::wglCreateContext( m_pDC->GetSafeHdc() ) ) ) {
::AfxMessageBox("wglCreateContext failed.");
return FALSE;
}
if ( FALSE == ::wglMakeCurrent( m_pDC->GetSafeHdc(), m_hRC ) ) {
::AfxMessageBox("wglMakeCurrent failed.");
return FALSE;
}
// specify black as clear color
::glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
// specify the back of the buffer as clear depth (0 closest, 1 farmost)
::glClearDepth( 1.0f );
// enable depth testing (Enable zbuffer - hidden surface removal)
::glEnable( GL_DEPTH_TEST );
// Set default black as background color.
::glClearColor(0.0, 0.0, 0.0, 1.0f);
// Set wireframe mode
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
// Enable auto-normalize of vertex normals
glEnable(GL_NORMALIZE);
// Enable alpha-blending
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// The code expects only the 2nd frame in the projection matrix to be used and the
// first one to always be the identity matrix, so make sure this is the case
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glMatrixMode(GL_MODELVIEW);
// The modelview matrix stack is arranged as follows:
// === Current+Applied Transformations ========
// ==== Applied Transformations ===============
// ============ Identity ======================
// ...
glPushMatrix();
glPushMatrix();
// detect if GLSL available - we can use shaders
CString gl_ver_str = glGetString(GL_VERSION);
float gl_ver = atof(gl_ver_str);
if (gl_ver >= 2.05)
glsl_OK = true;
else
glsl_OK = false;
if (glsl_OK)
initShaders();
return TRUE;
}
BOOL COpenGLView::SetupPixelFormat(PIXELFORMATDESCRIPTOR* pPFD)
{
// default pixel format for a single-buffered,
// OpenGL-supporting, hardware-accelerated,
// RGBA-mode format. Pass in a pointer to a different
// pixel format if you want something else
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),// size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
PFD_DOUBLEBUFFER, // double buffered
PFD_TYPE_RGBA, // RGBA type
24, // 24-bit color depth
0, 0, 0, 0, 0, 0, // color bits ignored
0, // no alpha buffer
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
24, // 24-bit z-buffer
8, // 8-bit stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};
int pixelformat;
PIXELFORMATDESCRIPTOR* pPFDtoUse;
// let the user override the default pixel format
pPFDtoUse = (0 == pPFD)? &pfd : pPFD;
if ( 0 == (pixelformat = ::ChoosePixelFormat( m_pDC->GetSafeHdc(), pPFDtoUse )) ) {
::AfxMessageBox("ChoosePixelFormat failed.");
return FALSE;
}
if ( FALSE == ::SetPixelFormat(m_pDC->GetSafeHdc(), pixelformat, pPFDtoUse ) ) {
::AfxMessageBox("SetPixelFormat failed.");
return FALSE;
}
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// COpenGLView message handlers
void COpenGLView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
if ( 0 >= cx || 0 >= cy ) {
return;
}
// save the width and height of the current window
m_WindowWidth = cx;
m_WindowHeight = cy;
// compute the aspect ratio
// this will keep all dimension scales equal
m_AspectRatio = (GLdouble)m_WindowWidth/(GLdouble)m_WindowHeight;
// Now, set up the viewing area-select the full client area
::glViewport(0, 0, m_WindowWidth, m_WindowHeight);
if ( GL_NO_ERROR != ::glGetError() ) {
::AfxMessageBox("Error while trying to set viewport.");
}
// select the viewing volume. You do it after you
// get the aspect ratio and set the viewport
if ( !SetupCamera() )
{
::AfxMessageBox("Error while trying to setup camera.");
return;
}
// now select the modelview matrix and clear it
// this is the mode we do most of our calculations in
// so we leave it as the default mode.
//::glMatrixMode(GL_MODELVIEW);
//::glLoadIdentity();
// TODO: DO WE WANT TO RESET THE TRANSFORMATIONS WHEN CHANGING VIEWING MODE?
}
BOOL COpenGLView::SetupViewingFrustum(void)
{
// select a default perspective viewing volumn
::gluPerspective( c_humanYFov, m_AspectRatio, this->m_zNear, this->m_zFar );
// NOTE: Other commands you could have here are
// glFrustum, which gives you much more control over
// the perspective view, or glOrtho which is used for
// parallel projections. No matter what you use, check
// the error status when you set the viewing frustum!
int e = ::glGetError();
if ( e != GL_NO_ERROR ) {
CString msg;
msg.Format("Error at %d while trying to set viewing frustum: %x", __LINE__, e);
::AfxMessageBox(msg);
return FALSE;
}
return TRUE;
}
// This viewing projection gives us a constant aspect ration. This is done by
// increasing the corresponding size of the ortho cube.
BOOL COpenGLView::SetupViewingOrthoConstAspect(void)
{
double windowSize = 4; // the size of the window in GL coord system.
if ( m_AspectRatio > 1 ) { // x is bigger than y.
// Maintain y size and increase x size (and z) accordingly
// by MULTIPLYING by the aspect ratio.
::glOrtho( -windowSize*m_AspectRatio/2.0, windowSize*m_AspectRatio/2.0,
-windowSize/2.0, windowSize/2.0, this->m_zNear, this->m_zFar);
} else {
// Maintain x size and increase y size (and z) accordingly,
// by DIVIDING the aspect Ration (because it's smaller than 1).
::glOrtho( -windowSize/2.0, windowSize/2.0,
-windowSize/m_AspectRatio/2.0, windowSize/m_AspectRatio/2.0,
this->m_zNear, this->m_zFar);
}
int e = ::glGetError();
if ( e != GL_NO_ERROR ) {
CString msg;
msg.Format("Error at %d while trying to set viewing frustum: %x", __LINE__, e);
::AfxMessageBox(msg);
return FALSE;
}
return TRUE;
}
BOOL COpenGLView::OnEraseBkgnd(CDC* pDC)
{
// Windows will clear the window with the background color every time your window
// is redrawn, and then OpenGL will clear the viewport with its own background color.
// return CView::OnEraseBkgnd(pDC);
return true;
}
/////////////////////////////////////////////////////////////////////////////
// COpenGLView drawing
/////////////////////////////////////////////////////////////////////////////
#define checkImageWidth 64
#define checkImageHeight 64
GLubyte checkImage[checkImageHeight][checkImageWidth][3];
void makeCheckImage(void)
{
int i, j, c;
for (i = 0; i < checkImageHeight; i++) {
for (j = 0; j < checkImageWidth; j++) {
c = ((((i&0x8)==0)^((j&0x8))==0))*255;
checkImage[i][j][0] = (GLubyte) c;
checkImage[i][j][1] = (GLubyte) c;
checkImage[i][j][2] = (GLubyte) c;
}
}
}
void COpenGLView::OnDraw(CDC* pDC)
{
COpenGLDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// Light
setupLightInScene();
m_fogFarams.setupFog();
m_materialManager.setupMaterialInScene();
// Shading
if (m_nLightShading == ID_LIGHT_SHADING_FLAT){
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
glShadeModel (GL_FLAT);
}
else if (m_nLightShading == ID_LIGHT_SHADING_GOURAUD){
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glShadeModel (GL_SMOOTH);
}
else if (m_nLightShading == ID_SHADING_WIREFRAME){
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
// Culling
if (m_showBackFaces){
glDisable(GL_CULL_FACE);
}
else{
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
}
glClearColor((GLclampf)m_backgroundColor[0], (GLclampf)m_backgroundColor[1], (GLclampf)m_backgroundColor[2], 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear screen and zbuffer
if (objectData == NULL)
{
// draw just the axis
glPushMatrix();
draw_axis();
glPopMatrix();
}
else
{
Render();
if (torchEnabled)
{
// draw a red point marking the center of the torch
glColor3d(1.0, 0.0, 0.0);
glBegin(GL_POINTS);
glVertex3d(cursor_x, cursor_y, cursor_z);
glEnd();
}
}
glFlush();
SwapBuffers(wglGetCurrentDC());
}
/////////////////////////////////////////////////////////////////////////////
// COpenGLView OpenGL Finishing and clearing...
void COpenGLView::OnDestroy()
{
CView::OnDestroy();
// this call makes the current RC not current
if ( FALSE == ::wglMakeCurrent( 0, 0 ) ) {
::AfxMessageBox("wglMakeCurrent failed.");
}
// delete the RC
if ( m_hRC && (FALSE == ::wglDeleteContext( m_hRC )) ) {
::AfxMessageBox("wglDeleteContext failed.");
}
// delete the DC
if ( m_pDC ) {
delete m_pDC;
}
}
/////////////////////////////////////////////////////////////////////////////
// User Defined Functions
void COpenGLView::draw_axis()
{
glLineWidth(2.0f);
glColor3f(1.0f, 1.0f, 1.0f);
glTranslatef(-0.5, -0.5, -0.5);
// Draw Axis x
glColor3f(1, 0, 0);
glBegin(GL_LINES);
glVertex3d(-0.1,0,0);
glVertex3d( 1,0,0);
glEnd();
glPushMatrix();
glTranslatef( 1.0f, 0.0f, 0.0f );
glRotatef( 90.0, 0.0f, 1.0f, 0.0f );
auxSolidCone(0.05,0.5);
glPopMatrix();
glColor3f(0, 1, 0);
glBegin(GL_LINES);
glVertex3d(0,-0.1,0);
glVertex3d(0, 1,0);
glEnd();
glPushMatrix();
glTranslatef( 0.0f, 1.0f, 0.0f );
glRotatef( -90.0, 1.0f, 0.0f, 0.0f );
auxSolidCone(0.05,0.5);
glPopMatrix();
glColor3f(0, 0, 1);
glBegin(GL_LINES);
glVertex3d(0,0,-0.1);
glVertex3d(0,0, 1);
glEnd();
glPushMatrix();
glTranslatef( 0.0f, 0.0f, 1.0f );
auxSolidCone(0.05,0.5);
glPopMatrix();
glLineWidth(1); // return defaul line width
glColor3f(1,1,1); // return default color
}
void DrawFloor() // Draws The Floor
{
//glBindTexture(GL_TEXTURE_2D, texture[0]); // Select Texture 1 (0)
glBegin(GL_QUADS); // Begin Drawing A Quad
glNormal3f(0.0, 1.0, 0.0); // Normal Pointing Up
//glTexCoord2f(0.0f, 1.0f); // Bottom Left Of Texture
glVertex3f(-3.0, 0.0, 3.0); // Bottom Left Corner Of Floor
//glNormal3f(0.0, 1.0, 0.0);
//glTexCoord2f(0.0f, 0.0f); // Top Left Of Texture
glVertex3f(-3.0, 0.0,-3.0); // Top Left Corner Of Floor
//glNormal3f(0.0, 1.0, 0.0);
//glTexCoord2f(1.0f, 0.0f); // Top Right Of Texture
glVertex3f( 3.0, 0.0,-3.0); // Top Right Corner Of Floor
//glNormal3f(0.0, 1.0, 0.0);
//glTexCoord2f(1.0f, 1.0f); // Bottom Right Of Texture
glVertex3f( 3.0, 0.0, 3.0); // Bottom Right Corner Of Floor
glEnd(); // Done Drawing The Quad
}
void COpenGLView::RenderScene() {
if (objectData != NULL)
{
if (m_recompile)
{
objectData->recompileAll();
m_recompile = false;
}
glCallList( objectData->GetDisplayList(MyCompositeObject::SELECT_OPAQUE) );
glDepthMask(GL_FALSE); // make z-buffer read-only for rendering transparent objects
glCallList( objectData->GetDisplayList(MyCompositeObject::SELECT_TRANSPARENT) );
glDepthMask(GL_TRUE); // restore write permissions for z-buffer
if (m_showVertexNormals || m_showFaceNormals) {
glDisable(GL_LIGHTING);
glColor3f(0, 1, 0);
glCallList( objectData->GetNormalsDisplayList(m_showFaceNormals, m_showVertexNormals) );
}
if (m_showBoundingBox){
glDisable(GL_LIGHTING);
glColor3f(1, 0, 0);
objectData->DrawBoundingBox();
}
if (m_backgroundObj != NULL){
GLfloat allBright[] = {1.0, 1.0, 1.0, 1.0};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, allBright);
glDisable(GL_LIGHT0);
int oldView = m_nView;
OnViewOrthographic();
glPushMatrix();
glLoadIdentity();
if (m_useShaders)
selectShader(SH_DRAW_BG, m_WindowWidth, m_WindowHeight);
m_backgroundObj->Draw();
if (m_useShaders)
selectShader(m_celShading ? SH_CEL_SHADER : SH_DEFAULT, m_WindowWidth, m_WindowHeight);
glPopMatrix();
if (m_nView != oldView)
OnViewPerspective();;
m_nView = oldView;
}
}
return;
}
void COpenGLView::OnFileLoad()
{
TCHAR szFilters[] = _T ("IRIT Data Files (*.itd)|*.itd|All Files (*.*)|*.*||");
CFileDialog dlg(TRUE, "itd", "*.itd", OFN_FILEMUSTEXIST | OFN_HIDEREADONLY ,szFilters);
if (dlg.DoModal () == IDOK) {
delete m_backgroundObj;
m_backgroundObj = NULL;
delete objectData;
objectData = new MyCompositeObject();
m_strItdFileName = dlg.GetPathName(); // Full path and filename
int sep = m_strItdFileName.ReverseFind('\\');
if (sep >= 0) {
// last path-separator found
CString filePath = m_strItdFileName.Left(sep);
MyTextureManager::m_textureDir = filePath;
}
PngWrapper p;
CGSkelProcessIritDataFiles(m_strItdFileName, 1); // Open the file and read it.
this->GetDocument()->SetTitle(m_strItdFileName); // display the loaded file name in the title bar
OnFileReset();
materialReset();
// mark for re-compilation
m_recompile = true;
setTesselation(false);
}
}
// VIEW HANDLERS ///////////////////////////////////////////
// Note: that all the following Message Handlers act in a similar way.
// Each control or command has two functions associated with it.
void COpenGLView::OnViewOrthographic()
{
m_nView = ID_VIEW_ORTHOGRAPHIC;
m_bIsPerspective = false;
if ( !SetupCamera() )
{
::AfxMessageBox("Error while trying to setup camera.");
}
Invalidate(); // redraw using the new view.
}
void COpenGLView::OnUpdateViewOrthographic(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_nView == ID_VIEW_ORTHOGRAPHIC);
}
void COpenGLView::OnViewPerspective()
{
m_nView = ID_VIEW_PERSPECTIVE;
m_bIsPerspective = true;
if ( !SetupCamera() )
{
::AfxMessageBox("Error while trying to setup camera.");
}
Invalidate();
}
void COpenGLView::OnUpdateViewPerspective(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_nView == ID_VIEW_PERSPECTIVE);
}
// ACTION HANDLERS ///////////////////////////////////////////
void COpenGLView::OnActionObjectspace()
{
m_nSpace = ID_ACTION_OBJECTSPACE;
}
void COpenGLView::OnUpdateActionObjectspace(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(m_nSpace == ID_ACTION_OBJECTSPACE);
}
void COpenGLView::OnActionViewspace()
{
m_nSpace = ID_ACTION_VIEWSPACE;
}
void COpenGLView::OnUpdateActionViewspace(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(m_nSpace == ID_ACTION_VIEWSPACE);
}
void COpenGLView::OnActionTexturetransformations()
{
m_nSpace = ID_ACTION_TEXTURETRANSFORMATIONS;
}
void COpenGLView::OnUpdateActionTexturetransformations(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(m_nSpace == ID_ACTION_TEXTURETRANSFORMATIONS);
}
void COpenGLView::OnActionRotate()
{
m_nAction = ID_ACTION_ROTATE;
}
void COpenGLView::OnUpdateActionRotate(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_nAction == ID_ACTION_ROTATE);
}
void COpenGLView::OnActionTranslate()
{
m_nAction = ID_ACTION_TRANSLATE;
}
void COpenGLView::OnUpdateActionTranslate(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_nAction == ID_ACTION_TRANSLATE);
}
void COpenGLView::OnActionScale()
{
m_nAction = ID_ACTION_SCALE;
}
void COpenGLView::OnUpdateActionScale(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_nAction == ID_ACTION_SCALE);
}
void COpenGLView::OnActionUniformscaling()
{
m_nAction = ID_ACTION_UNIFORMSCALING;
}
void COpenGLView::OnUpdateActionUniformscaling(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(m_nAction == ID_ACTION_UNIFORMSCALING);
}
// AXIS HANDLERS ///////////////////////////////////////////
// Gets calles when the X button is pressed or when the Axis->X menu is selected.
// The only thing we do here is set the ChildView member variable m_nAxis to the
// selected axis.
void COpenGLView::OnAxisX()
{
m_nAxis = ID_AXIS_X;
}
// Gets called when windows has to repaint either the X button or the Axis pop up menu.
// The control is responsible for its redrawing.
// It sets itself disabled when the action is a Scale action.
// It sets itself Checked if the current axis is the X axis.
void COpenGLView::OnUpdateAxisX(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_nAxis == ID_AXIS_X);
}
void COpenGLView::OnAxisY()
{
m_nAxis = ID_AXIS_Y;
}
void COpenGLView::OnUpdateAxisY(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_nAxis == ID_AXIS_Y);
}
void COpenGLView::OnAxisZ()
{
m_nAxis = ID_AXIS_Z;
}
void COpenGLView::OnUpdateAxisZ(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_nAxis == ID_AXIS_Z);
}
void COpenGLView::OnAxisXy()
{
m_nAxis = ID_AXIS_XY;
}
void COpenGLView::OnUpdateAxisXy(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(m_nAxis == ID_AXIS_XY);
}
// OPTIONS HANDLERS ///////////////////////////////////////////
// LIGHT SHADING HANDLERS ///////////////////////////////////////////
void COpenGLView::OnLightShadingFlat()
{
m_nLightShading = ID_LIGHT_SHADING_FLAT;
Invalidate();
}
void COpenGLView::OnUpdateLightShadingFlat(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_nLightShading == ID_LIGHT_SHADING_FLAT);
}
void COpenGLView::OnLightShadingGouraud()
{
m_nLightShading = ID_LIGHT_SHADING_GOURAUD;
Invalidate();
}
void COpenGLView::OnUpdateLightShadingGouraud(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_nLightShading == ID_LIGHT_SHADING_GOURAUD);
}
void COpenGLView::OnShadingWireframe()
{
m_nLightShading = ID_SHADING_WIREFRAME;
Invalidate();
}
void COpenGLView::OnUpdateShadingWireframe(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(m_nLightShading == ID_SHADING_WIREFRAME);
}
void COpenGLView::OnOptionsBackfacesculling()
{
m_showBackFaces = !m_showBackFaces;
Invalidate();
}
void COpenGLView::OnUpdateOptionsBackfacesculling(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck( !m_showBackFaces);
}
void COpenGLView::OnMaterialTesselation()
{
m_showTesselation = !m_showTesselation;
setTesselation(m_showTesselation);
m_recompile = true;
Invalidate();
}
void COpenGLView::OnUpdateMaterialTesselation(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(m_showTesselation);
}
// LIGHT SETUP HANDLER ///////////////////////////////////////////
void COpenGLView::OnLightConstants()
{
CLightDialog dlg;
for (int id=LIGHT_ID_1;id<MAX_LIGHT;id++)
{
dlg.SetDialogData((LightID)id,m_lights[id]);
}
dlg.SetDialogData(LIGHT_ID_AMBIENT,m_ambientLight);
if (dlg.DoModal() == IDOK)
{
for (int id=LIGHT_ID_1;id<MAX_LIGHT;id++)
{
m_lights[id] = dlg.GetDialogData((LightID)id);
}
m_ambientLight = dlg.GetDialogData(LIGHT_ID_AMBIENT);
}
Invalidate();
}
void COpenGLView::OnLButtonDown(UINT nFlags, CPoint point)
{
m_LastTransformPoint = point;
}
void COpenGLView::OnLButtonUp(UINT nFlags, CPoint point)
{
ApplyLatestTransform();
}
void COpenGLView::OnMouseMove(UINT nFlags, CPoint point)
{
bool mustRedraw = false;
if (torchEnabled && objectData != NULL)
{
// move torch
static const double scale_factor = 1;
SHORT s = GetKeyState(VK_CONTROL);
if ( GetKeyState(VK_CONTROL) & (1 << (sizeof(SHORT)*CHAR_BIT)) )
{
// check if CTRL is down to decide whether to move the torch on Z-axis or not
CPoint point;
GetCursorPos(&point); // GetCursorPos seems to return different coordinates than OnMouseMove,
// so we override the point parameter for this part of the code so we
// can compare the coordinates and get a correct result
m_mouseScreenZ =
(m_prevMouseScreenZ + (point.y - m_lastCtrlPoint.y)/(m_WindowHeight*scale_factor)) * (m_mouseSensitivity / 100.0);
}
double modelMatrix[16],
projMatrix[16];
int viewportMatrix[4];
glGetDoublev(GL_MODELVIEW_MATRIX, &modelMatrix[0]);
glGetDoublev(GL_PROJECTION_MATRIX, &projMatrix[0]);
glGetIntegerv(GL_VIEWPORT, &viewportMatrix[0]);
// keep in mind that object-space y-coordinates go from top-to-bottom and screen-space y-coordinates
// go in the reverse direction
gluUnProject( point.x, m_WindowHeight-point.y, m_mouseScreenZ,
modelMatrix, projMatrix, viewportMatrix,
&cursor_x, &cursor_y, &cursor_z );
mustRedraw = true;
}
if (nFlags & MK_LBUTTON)
{
int x_move_amt = (point.x - m_LastTransformPoint.x),
y_move_amt = (m_LastTransformPoint.y - point.y );
//x_move_amt *= m_mouseSensitivity / 100.0;
//y_move_amt *= m_mouseSensitivity / 100.0;
// undo the previously applied transformation - we'll reapply it now along with the
// transform caused by this latest mouse move
glPopMatrix();
glPushMatrix();
if (m_nSpace == ID_ACTION_TEXTURETRANSFORMATIONS)
{
glMatrixMode(GL_TEXTURE);
}
switch (m_nAction)
{
case ID_ACTION_ROTATE:
RotateModel(x_move_amt, y_move_amt);
break;
case ID_ACTION_TRANSLATE:
TranslateModel(x_move_amt, y_move_amt);
break;
case ID_ACTION_SCALE:
case ID_ACTION_UNIFORMSCALING:
ScaleModel(x_move_amt, y_move_amt);
break;
default:
AfxMessageBox("Action not implemented.");
break;
}
glMatrixMode(GL_MODELVIEW);
mustRedraw = true;
}
if (mustRedraw)
Invalidate();
}
void COpenGLView::TranslateModel(int x_amt, int y_amt)
{
double factor = 1.0 * (m_mouseSensitivity/100.0 * 2.0);
double x_translate, y_translate, z_translate;
MouseDelta2ObjectDelta(x_amt, y_amt, &x_translate, &y_translate, &z_translate);
x_translate = (m_nAxis == ID_AXIS_X || m_nAxis == ID_AXIS_XY) ? x_translate*factor : 0;
y_translate = (m_nAxis == ID_AXIS_Y || m_nAxis == ID_AXIS_XY) ? y_translate*factor : 0;
z_translate = (m_nAxis == ID_AXIS_Z) ? z_translate*factor : 0;
if (m_nSpace == ID_ACTION_OBJECTSPACE || m_nSpace == ID_ACTION_TEXTURETRANSFORMATIONS)
glTranslated(x_translate, y_translate, z_translate);
else
{
// view-space transformation
GLdouble currentMatrix[16];
glGetDoublev(GL_MODELVIEW_MATRIX, ¤tMatrix[0]);
glLoadIdentity();
glTranslated(x_translate, y_translate, z_translate);
glMultMatrixd(¤tMatrix[0]);
}
}
void COpenGLView::RotateModel(int x_amt, int y_amt)
{
double rotate_axis_x, rotate_axis_y, rotate_axis_z;
double rotate_amt;
double factor = 2.0 * (m_mouseSensitivity/100.0 * 2.0);
static const double xy_balance = 10.0;
switch (m_nAxis)
{
case ID_AXIS_X:
rotate_amt = (-y_amt*factor/m_WindowWidth) * 360;
rotate_axis_x = 1.0;
rotate_axis_y = rotate_axis_z = 0;
break;
case ID_AXIS_Y:
rotate_amt = (x_amt*factor/m_WindowHeight) * 360;
rotate_axis_y = 1.0;
rotate_axis_x = rotate_axis_z = 0;
break;
case ID_AXIS_Z:
rotate_amt = (x_amt*factor/m_WindowHeight) * 360;
rotate_axis_z = 1.0;
rotate_axis_x = rotate_axis_y = 0;
break;
case ID_AXIS_XY:
rotate_amt = (x_amt*factor/m_WindowWidth + y_amt*factor/m_WindowHeight) * 180;
rotate_axis_z = 0;
rotate_axis_x = -1.0;
rotate_axis_y = 1.0;
break;
}
if (m_nSpace == ID_ACTION_OBJECTSPACE || m_nSpace == ID_ACTION_TEXTURETRANSFORMATIONS)
glRotated(rotate_amt, rotate_axis_x, rotate_axis_y, rotate_axis_z);
else
{
// view-space transformation
GLdouble currentMatrix[16];
glGetDoublev(GL_MODELVIEW_MATRIX, ¤tMatrix[0]);
const double cp[4] = {0, 0, 0, 1.0};
double cp1[4] = {0};
// find the current projected axes origin
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
cp1[i] += cp[j] * currentMatrix[i + 4*j];
for (int i = 0; i < 4; i++) cp1[i] /= cp1[3];
glLoadIdentity();
glRotated(rotate_amt, rotate_axis_x, rotate_axis_y, rotate_axis_z);
glMultMatrixd(¤tMatrix[0]);
double cp2[4] = {0};
// find the new projected axes origin
glGetDoublev(GL_MODELVIEW_MATRIX, ¤tMatrix[0]);
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
cp2[i] += cp[j] * currentMatrix[i + 4*j];
for (int i = 0; i < 4; i++) cp2[i] /= cp2[3];
/* figure out how much the object has moved as the result of the rotation about
the axis, and move it the same amount in the other direction -- in viewspace
coordinates! this is so the object rotates in viewspace coordinates but remains
centered in the viewport */
glLoadIdentity();
glTranslated(cp1[0] - cp2[0], cp1[1] - cp2[1], cp1[2] - cp2[2]);
glMultMatrixd(¤tMatrix[0]);
}
}
void COpenGLView::ScaleModel(int x_amt, int y_amt)
{
double factor = 1.0 * (m_mouseSensitivity/100.0 * 2.0);
double x_scale = 1 + (x_amt*factor / m_WindowWidth),
y_scale = 1 + (y_amt*factor / m_WindowHeight),
z_scale = y_scale;
if (m_nAction == ID_ACTION_UNIFORMSCALING) {
x_scale = y_scale = z_scale = (x_scale + y_scale)/2;
} else {
x_scale = (m_nAxis == ID_AXIS_X || m_nAxis == ID_AXIS_XY) ? x_scale : 1.0;
y_scale = (m_nAxis == ID_AXIS_Y || m_nAxis == ID_AXIS_XY) ? y_scale : 1.0;
z_scale = (m_nAxis == ID_AXIS_Z) ? z_scale : 1.0;
}
if (m_nSpace == ID_ACTION_OBJECTSPACE || m_nSpace == ID_ACTION_TEXTURETRANSFORMATIONS)
glScaled(x_scale, y_scale, z_scale);
else
{
// view-space transformation
GLdouble currentMatrix[16];
glGetDoublev(GL_MODELVIEW_MATRIX, ¤tMatrix[0]);
glLoadIdentity();
glScaled(x_scale, y_scale, z_scale);
glMultMatrixd(¤tMatrix[0]);
}
}
bool COpenGLView::SetupCamera(bool resetTransforms)
{
// define near + far planes
this->m_zNear = 0.1,
this->m_zFar = 20.0;
if (objectData != NULL)
{
// near clipping plane is 10 times the size of the object
// this should give us plenty of room to back away until it clips
//this->m_zFar = objectData->bbox.zSize() * 10;
this->m_zFar = 100*(objectData->bbox.xSize() + objectData->bbox.ySize() + objectData->bbox.zSize());
}
bool ret;
/** We want to perform all camera manipulations the same for both viewing modes.
If we setup perspective projection here, the scaling calculation later on will
be incorrect. Therefore, we setup orthographic projection and later fix the
projection matrix if this is incorrect.
**/
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glPushMatrix(); // restore identity matrix
ret = SetupViewingOrthoConstAspect();
glMatrixMode(GL_MODELVIEW);
if (!ret)
return ret;
if (resetTransforms)
{
glPopMatrix();
glPopMatrix(); // reset to identity matrix
glPushMatrix();
glPushMatrix();
if (objectData != NULL)
{
// scale the model so it fits on about 3/4 of the screen in orthographic view
// we fix the distortion this creates in perspective view later with a translation
// down the Z axis
double modelMatrix[16],
projMatrix[16];
int viewportMatrix[4];
double w_xmin, w_xmax, w_ymin, w_ymax, w_zmin, w_zmax;
glGetDoublev(GL_MODELVIEW_MATRIX, &modelMatrix[0]);
glGetDoublev(GL_PROJECTION_MATRIX, &projMatrix[0]);
glGetIntegerv(GL_VIEWPORT, &viewportMatrix[0]);
gluProject( objectData->bbox.x_min, objectData->bbox.y_min, objectData->bbox.z_min,
modelMatrix, projMatrix, viewportMatrix, &w_xmin, &w_ymin, &w_zmin);
gluProject( objectData->bbox.x_max, objectData->bbox.y_max, objectData->bbox.z_max,
modelMatrix, projMatrix, viewportMatrix, &w_xmax, &w_ymax, &w_zmax);
delete (w_bbox);
w_bbox = new MyBoundingBox (w_xmin, w_xmax, w_ymin, w_ymax, w_zmin, w_zmax);
double x_scale = (m_WindowWidth * 3 / 4) / w_bbox->xSize(),
y_scale = (m_WindowHeight * 3 / 4) / w_bbox->ySize();
m_scale = min(x_scale, y_scale); // if we need to reduce the model then reduce by the maximum amount
// if enlarging enlarge by the minimum amount
glScaled(m_scale, m_scale, m_scale);
}
// calculate needed camera distance from object and move the camera
// the calculation is meant for perspective mode, but it should work just as well for orthographic
// mode, since all we need is to move the object far enough back so it doesn't clip with the near plane
double distance = 3.0; // default distance if no object is loaded (for the axes)
if (objectData != NULL)
{
// we take this opportunity to also center the model in the window
MyBoundingBox bbox = objectData->bbox;
glTranslated( -bbox.GetCenterX(), -bbox.GetCenterY(), 0 );
double radFovY_half = M_PI/360 * c_humanYFov;
double size_x = objectData->bbox.xSize(),
size_y = max( objectData->bbox.ySize(), size_x/m_AspectRatio );
distance = (0.5*size_y) / std::sin(radFovY_half);
distance += objectData->bbox.zSize(); // don't forget the object isn't flat...
}
// get the size of the object (either loaded model or default axes) in the z plane
double zSize = (objectData != NULL) ? objectData->bbox.zSize() : 2;
if (distance <= this->m_zNear + zSize)
// the object is clipping the near plane!
distance = this->m_zNear + zSize;
if (distance + zSize >= this->m_zFar)
// we're moving it past the far plane!
distance = this->m_zFar - zSize - 1;
// move the camera
glTranslated(0.0, 0.0, -distance);
ApplyLatestTransform(); // apply this _NOT JUST_ for current transformation but to the ones to follow as well
}
/** If we should be in projection mode fix it now! **/
if (m_bIsPerspective) {
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glPushMatrix(); // restore identity matrix
ret = SetupViewingFrustum();
glMatrixMode(GL_MODELVIEW);
}
if (!ret)
return ret;
if ( GL_NO_ERROR != ::glGetError() ) {
::AfxMessageBox("Error while trying to set camera position.");
return FALSE;
}
return TRUE;
}
void COpenGLView::OnOptionsMousesensitivity()
{
CMouseSensitivityDialog dlg(m_mouseSensitivity);
if (dlg.DoModal () == IDOK) {
m_mouseSensitivity = dlg.m_sensitivity;
}
}
void COpenGLView::OnOptionsChangewirecolor()
{
CColorDialog dlg;
if (dlg.DoModal () == IDOK) {
if(NULL != objectData){
COLORREF color = dlg.GetColor();
objectData->changeColor( GetRValue(color) / 255.0,
GetGValue(color) / 255.0,
GetBValue(color) / 255.0 );
// mark for re-compilation
m_recompile = true;
Invalidate();
}
}
}
void COpenGLView::OnOptionsChangebackgroundcolor()
{
CColorDialog dlg;
if (dlg.DoModal () == IDOK) {
COLORREF color = dlg.GetColor();
m_backgroundColor[0] = GetRValue(color) / 255.0;
m_backgroundColor[1] = GetGValue(color) / 255.0;
m_backgroundColor[2] = GetBValue(color) / 255.0;
Invalidate();
}
}
void COpenGLView::OnOptionsDrawboundingbox()
{
m_showBoundingBox = !m_showBoundingBox;
Invalidate();
}
void COpenGLView::OnUpdateOptionsDrawboundingbox(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(m_showBoundingBox);
}
void COpenGLView::OnOptionsShowverticesnormals()
{
m_showVertexNormals = !m_showVertexNormals;
Invalidate();
}
void COpenGLView::OnUpdateOptionsShowverticesnormals(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(m_showVertexNormals);
}
void COpenGLView::OnOptionsShowfacesnormals()
{
m_showFaceNormals = !m_showFaceNormals;
Invalidate();
}
void COpenGLView::OnUpdateOptionsShowfacesnormals(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(m_showFaceNormals);
}
void COpenGLView::OnOptionsPerspectivecontrol()
{
AfxMessageBox("This option not implemented");
}
void COpenGLView::ApplyLatestTransform(void)
{
GLdouble m[16];
glGetDoublev(GL_MODELVIEW_MATRIX, &m[0]);
glPopMatrix();
glLoadMatrixd(&m[0]);
glPushMatrix();
}
void COpenGLView::OnOptionsTorch()
{
static bool familiar = false;
if (!familiar)
{
CString msg = "This appears to be your first time using the\n"
"torch feature. Move the mouse around the\n"
"object to illuminate different parts of it.\n"
"Hold the Ctrl key and drag the the mouse\n"
"up and down to move the torch on the Z\n"
"axis.";
AfxMessageBox(msg, MB_OK|MB_ICONINFORMATION);
familiar = true;
}
torchEnabled = !torchEnabled;
Invalidate();
}
void COpenGLView::OnUpdateOptionsTorch(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(torchEnabled);
}
void COpenGLView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar == VK_CONTROL)
{
m_prevMouseScreenZ = m_mouseScreenZ; // save it, since it's going to be getting changed now...
GetCursorPos(&m_lastCtrlPoint);
}
}
void COpenGLView::OnFileReset()
{
if (objectData != NULL){
m_backgroundColor[0] = m_backgroundColor[1] = m_backgroundColor[2] = 0;
glMatrixMode(GL_TEXTURE);
glPopMatrix();
glPushMatrix();
// reset the ModelView matrix
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPopMatrix();
glPushMatrix();
glPushMatrix();
SetupCamera(true); // setup projection and camera position for the newly loaded model
double objSize = max( objectData->bbox.xSize(), objectData->bbox.ySize() );
objSize = max( objSize, objectData->bbox.zSize() );
torch_range = objSize / 4;
// set the "mouse z-coordinate" for the torch to coincide with the center of the object's
// bounding-box, so we start off with it in the general area of the object...
double modelMatrix[16],
projMatrix[16];
int viewportMatrix[4];
glGetDoublev(GL_MODELVIEW_MATRIX, &modelMatrix[0]);
glGetDoublev(GL_PROJECTION_MATRIX, &projMatrix[0]);
glGetIntegerv(GL_VIEWPORT, &viewportMatrix[0]);
double tmp;
gluProject( objectData->bbox.GetCenterX(), objectData->bbox.GetCenterY(), objectData->bbox.GetCenterZ(),
modelMatrix, projMatrix, viewportMatrix,
&tmp, &tmp, &m_mouseScreenZ );
}
Invalidate(); // force a WM_PAINT for drawing.
}
void COpenGLView::lightReset(){
setupLightInScene();
for (int id=LIGHT_ID_1;id<MAX_LIGHT;id++)
{
m_lights[id].reset();
}
m_lights[0].enabled = true;
m_ambientLight.colorR = m_ambientLight.colorG = m_ambientLight.colorB = 0;
}
void COpenGLView::setupLightInScene(){
//Enable view lights
GLdouble currentMatrix[16];
glGetDoublev(GL_MODELVIEW_MATRIX, ¤tMatrix[0]);
glLoadIdentity();
m_lightManager.setupGeneralLight( (!torchEnabled) &&
(objectData != NULL) &&
(m_nLightShading != ID_SHADING_WIREFRAME),
m_ambientLight );
for (int i=0;i<MAX_LIGHT; i++ ){
if (m_lights[i].space == LIGHT_SPACE_VIEW)
m_lightManager.showLight(m_lights[i], i);
}
glMultMatrixd(¤tMatrix[0]);
//Enable local lights
for (int i=0;i<MAX_LIGHT; i++ ){
if (m_lights[i].space == LIGHT_SPACE_LOCAL)
m_lightManager.showLight(m_lights[i], i);
}
}
void COpenGLView::OnMaterialLoadtexture()
{
TCHAR szFilters[] = _T ("Png Files (*.png)|*.png|All Files (*.*)|*.*||");
CFileDialog dlg(TRUE, "png", "*.png", OFN_FILEMUSTEXIST | OFN_HIDEREADONLY ,szFilters);
if (dlg.DoModal () == IDOK) {
std::string file(dlg.GetPathName());
glMatrixMode(GL_TEXTURE);
glPopMatrix();
glPushMatrix();
m_textureManager.addPTexture(file.c_str(), true);
m_textureManager.set();
for (int i=0; i<objectData->m_nextObj; i++){
objectData->m_objects[i]->enableTexture(false);
}
m_recompile = true;
Invalidate();
}
}
void COpenGLView::OnLightFog()
{
CFogDialog dlg(m_fogFarams);
if (dlg.DoModal () == IDOK) {
m_fogFarams = dlg.getFogParams();
Invalidate();
}
}
void COpenGLView::OnMaterialProperties()
{
CMaterialDlg dlg(m_materialManager);
if (dlg.DoModal () == IDOK) {
m_materialManager = dlg.getMaterialManager();
m_textureManager.setupTextureParams(m_materialManager);
m_textureManager.set();
for (int i = 0; i < objectData->m_nextObj; i++){
objectData->m_objects[i]->m_textureManager.setupTextureParams(m_materialManager);
}
m_recompile = true;
Invalidate();
}
}
void COpenGLView::OnResetLight()
{
lightReset();
Invalidate();
}
void COpenGLView::OnResetView()
{
OnFileReset();
}
void COpenGLView::materialReset(){
m_materialManager.reset();
m_textureManager.setupTextureParams(m_materialManager);
}
void COpenGLView::setTesselation(bool bTesselation){
m_showTesselation = bTesselation;
GLUtesselator* tobj = (GLUtesselator*)m_tesselationManager.setTesselation(bTesselation);
if (objectData != NULL){
for (int i = 0; i < objectData->m_nextObj; i++) {
objectData->m_objects[i]->setTesselator(tobj);
}
}
}
void COpenGLView::OnMaterialLoadmipmap()
{
string *objectNames;
int len;
if (objectData) {
len = objectData->m_nextObj;
objectNames = new string[len];
for (int i = 0; i < len; i++)
objectNames[i] = objectData->m_objects[i]->m_name;
} else {
len = 0;
objectNames = NULL;
}
LoadTextureDlg dlg(objectNames, len);
if (dlg.DoModal() == IDOK) {
if (!objectData) return; // just in case...
int obj = dlg.m_objSelected;
string file = dlg.m_filePath;
objectData->m_objects[obj]->m_textureManager.addPTexture(file.c_str(), true, true);
m_recompile = true;
}
}
/** This helper function calculates how much an object should be transformed
(translated, scaled) in object coordinates to match a given movement in
screen coordinates. For consistency we calculate the projections using the
following mouse location values:
Before: screen.center.x, screen.center.y, object.center.z
After: screen.center.x + dx, screen.center.y + dy, object.center.z
**/
void COpenGLView::MouseDelta2ObjectDelta(int dx, int dy, double* obj_dx, double* obj_dy, double* obj_dz)
{
double modelMatrix[16],
projMatrix[16];
int viewportMatrix[4];
glGetDoublev(GL_MODELVIEW_MATRIX, &modelMatrix[0]);
glGetDoublev(GL_PROJECTION_MATRIX, &projMatrix[0]);
glGetIntegerv(GL_VIEWPORT, &viewportMatrix[0]);
double winx_before = m_WindowWidth/2,
winy_before = m_WindowHeight/2,
winz_before = 0,
t;
double center[4] = { (objectData) ? objectData->bbox.GetCenterX() : 0,
(objectData) ? objectData->bbox.GetCenterY() : 0,
(objectData) ? objectData->bbox.GetCenterZ() : 0,
1.0 };
// we need to apply the modelview and projection matrices to the center-point!
ApplyMatrix(center, modelMatrix, true);
// first convert object-z center to screen z-center
gluProject( center[0], center[1], center[2],
modelMatrix, projMatrix, viewportMatrix,
&t, &t, &winz_before);
double objx_before, objy_before, objz_before;
// calculate "BEFORE" coordinates
if (! gluUnProject( winx_before, winy_before, winz_before,
modelMatrix, projMatrix, viewportMatrix,
&objx_before, &objy_before, &objz_before ) )
AfxMessageBox("Failed projecting BEFORE coordinates");
double objx_after, objy_after, objz_after;
// calculate "AFTER" coordinates
if (! gluUnProject( winx_before + dx, winy_before + dy, winz_before,
modelMatrix, projMatrix, viewportMatrix,
&objx_after, &objy_after, &objz_after ) )
AfxMessageBox("Failed projecting AFTER coordinates");
static const double factor = 0.3; // heuristic
*obj_dx = (objx_after - objx_before) * factor;
*obj_dy = (objy_after - objy_before) * factor;
*obj_dz = *obj_dy;
}
/** Apply transformation matrix m to point vector v=(x,y,z,w). After the transformation v
contains vM
**/
void COpenGLView::ApplyMatrix(double v[4], double m[16], bool normalize)
{
double v_[4] = {0};
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
v_[i] += m[4*i + j] * v[j];
if (normalize) {
for (int i = 0; i < 4; i++)
v_[i] /= v_[3];
}
// copy result
for (int i = 0; i < 4; i++)
v[i] = v_[i];
}
void COpenGLView::OnAdvancedLoadbackgroung()
{
if (objectData==NULL)
return;
TCHAR szFilters[] = _T ("Png Files (*.png)|*.png|All Files (*.*)|*.*||");
CFileDialog dlg(TRUE, "png", "*.png", OFN_FILEMUSTEXIST | OFN_HIDEREADONLY ,szFilters);
if (dlg.DoModal () == IDOK) {
if (m_backgroundObj!=NULL)
delete m_backgroundObj;
std::string sFileName(dlg.GetPathName());
m_backgroundObj = new My3dObject("Background");
for (int j=0; j<3; j++)
m_backgroundObj->m_color[j] = 1.0;
m_backgroundObj->addPTexture(sFileName.c_str(),true);
int xSize = 1*(objectData->bbox.x_max - objectData->bbox.x_min);
int ySize = 1.6*(objectData->bbox.y_max - objectData->bbox.y_min);
int windowSize = 4;
int left = -windowSize*m_AspectRatio/2.0;
int right = windowSize*m_AspectRatio/2.0;
int buttom = -windowSize/2.0;
int up = windowSize/2.0;
int z = -99*(objectData->bbox.xSize() + objectData->bbox.ySize() + objectData->bbox.zSize());
int x3=right;
int y3=up;
int z3=z;
int x4=left;
int y4=up;
int z4=z;
int x1=left;
int y1=buttom;
int z1=z;
int x2=right;
int y2=buttom;
int z2=z;
MyPolygon *poly = new MyPolygon(4);
MyVertex v1(x1,y1,z1);
v1.setNormal(0,0,1);
v1.setUV(0,0);
MyVertex v2(x2,y2,z2);
v2.setNormal(0,0,1);
v2.setUV(1,0);
MyVertex v3(x3,y3,z3);
v3.setNormal(0,0,1);
v3.setUV(1,1);
MyVertex v4(x4,y4,z4);
v4.setNormal(0,0,1);
v4.setUV(0,1);
poly->AddVertex(v1);
poly->AddVertex(v2);
poly->AddVertex(v3);
poly->AddVertex(v4);
m_backgroundObj->AddPolyRef(poly);
//m_recompile = true;
Invalidate();
}
}
bool COpenGLView::GetFolder(string& folderpath){
bool retVal = false;
BROWSEINFO bi;
memset(&bi, 0, sizeof(bi));
bi.ulFlags = BIF_USENEWUI;
bi.hwndOwner = NULL;
bi.lpszTitle = NULL;
::OleInitialize(NULL);
LPITEMIDLIST pIDL = ::SHBrowseForFolder(&bi);
if(pIDL != NULL)
{
char buffer[_MAX_PATH] = {'\0'};
if(::SHGetPathFromIDList(pIDL, buffer) != 0)
{
folderpath = buffer;
retVal = true;
}
CoTaskMemFree(pIDL);
}
::OleUninitialize();
return retVal;
}
void COpenGLView::OnAdvancedExportimage()
{
string folderpath;
if (!GetFolder(folderpath))
return;
int* viewport = new int[4];
glGetIntegerv( GL_VIEWPORT, viewport);
char* image =(char*) malloc(3 * viewport[2] * viewport[3]);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, viewport[2], viewport[3], GL_RGB, GL_UNSIGNED_BYTE, image);
int imageWidth = viewport[2];
int imageHeight = viewport[3];
string fileName(folderpath+"\\background.png");
PngWrapper wrapper;
wrapper.SetFileName(fileName.c_str());
wrapper.SetHeight(imageHeight);
wrapper.SetWidth(imageWidth);
wrapper.InitWritePng();
for (int i = 0; i < imageWidth; i++) {
for (int j = 0; j < imageHeight; j++) {
byte r = image[j*imageWidth*3 + i*3 +0];
byte g = image[j*imageWidth*3 + i*3 +1];
byte b = image[j*imageWidth*3 + i*3 +2];
wrapper.SetValue(i,imageHeight-j,SET_RGB(r,g,b));
}
}
wrapper.WritePng();
}
void COpenGLView::OnAdvancedAdvancedshading()
{
if (!m_useShaders) {
// turning on shaders
if (!glsl_OK) {
AfxMessageBox("Your version of OpenGL does not support shaders", MB_ICONEXCLAMATION);
return;
}
setShaders();
m_useShaders = true;
Invalidate();
} else {
unsetShaders();
m_useShaders = false;
Invalidate();
}
}
void COpenGLView::OnUpdateAdvancedAdvancedshading(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(m_useShaders);
}
void COpenGLView::OnUpdateAdvancedCelshading(CCmdUI *pCmdUI)
{
m_celShading = m_useShaders && m_celShading; // in case shaders were turned off, we wish to turn this off also
pCmdUI->Enable(m_useShaders);
pCmdUI->SetCheck(m_celShading);
}
void COpenGLView::OnAdvancedCelshading()
{
m_celShading = !m_celShading;
selectShader(m_celShading ? SH_CEL_SHADER : SH_DEFAULT, m_WindowWidth, m_WindowHeight);
Invalidate();
}
void COpenGLView::OnUpdateAdvancedDrawoutlines(CCmdUI *pCmdUI)
{
m_drawOutlines = m_useShaders && m_drawOutlines; // in case shaders were turned off, we wish to turn this off also
pCmdUI->Enable(m_useShaders);
pCmdUI->SetCheck(m_drawOutlines);
}
void COpenGLView::OnAdvancedDrawoutlines()
{
m_drawOutlines = !m_drawOutlines;
Invalidate();
}
void COpenGLView::Render()
{
if (!m_useShaders) {
RenderScene();
return;
}
MyEdgeDetector e(m_WindowWidth, m_WindowHeight);
My3dObject *saveBG = m_backgroundObj;
m_backgroundObj = NULL;
if (m_drawOutlines) {
// clear background to white for maximum contrast with the way the normals are rendered to color
glClearColor((GLclampf)1.0, (GLclampf)1.0, (GLclampf)1.0, (GLclampf)1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
selectShader(SH_EDGE_SHADER_PASS1, m_WindowWidth, m_WindowHeight);
glPushMatrix();
RenderScene();
glPopMatrix();
e.detectEdges();
glClearColor((GLclampf)m_backgroundColor[0], (GLclampf)m_backgroundColor[1], (GLclampf)m_backgroundColor[2], 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
selectShader(m_celShading ? SH_CEL_SHADER : SH_DEFAULT, m_WindowWidth, m_WindowHeight); // setup appropriate shader
glPushMatrix();
m_backgroundObj = saveBG;
RenderScene();
glPopMatrix();
if (m_drawOutlines) {
// render edges in black
glEnable(GL_STENCIL_TEST);
e.stencilEdges();
glClear(GL_DEPTH_BUFFER_BIT); // otherwise nothing would get drawn
selectShader(SH_EDGE_SHADER_PASS2, m_WindowWidth, m_WindowHeight);
glStencilFunc (GL_EQUAL, 0x1, 0x1); // cut out everything BUT the outlines
glPushMatrix();
RenderScene();
glPopMatrix();
glDisable(GL_STENCIL_TEST);
}
}
| [
"hanashubin@2ff579a8-b8b1-c11a-477f-bc6c74f83876",
"slavak@2ff579a8-b8b1-c11a-477f-bc6c74f83876"
]
| [
[
[
1,
1
],
[
15,
16
],
[
22,
23
],
[
113,
122
],
[
124,
125
],
[
151,
153
],
[
162,
162
],
[
172,
172
],
[
177,
178
],
[
275,
276
],
[
283,
284
],
[
437,
437
],
[
477,
494
],
[
501,
504
],
[
506,
506
],
[
519,
528
],
[
551,
551
],
[
634,
656
],
[
658,
658
],
[
683,
684
],
[
689,
691
],
[
693,
693
],
[
697,
697
],
[
703,
706
],
[
720,
721
],
[
744,
744
],
[
816,
825
],
[
963,
972
],
[
974,
985
],
[
1071,
1074
],
[
1092,
1092
],
[
1109,
1109
],
[
1155,
1155
],
[
1211,
1211
],
[
1249,
1249
],
[
1283,
1288
],
[
1291,
1291
],
[
1371,
1371
],
[
1430,
1430
],
[
1475,
1479
],
[
1514,
1514
],
[
1518,
1518
],
[
1526,
1534
],
[
1538,
1540
],
[
1542,
1546
],
[
1548,
1548
],
[
1550,
1550
],
[
1561,
1567
],
[
1576,
1595
],
[
1598,
1632
],
[
1740,
1804
],
[
1806,
1866
]
],
[
[
2,
14
],
[
17,
21
],
[
24,
112
],
[
123,
123
],
[
126,
150
],
[
154,
161
],
[
163,
171
],
[
173,
176
],
[
179,
274
],
[
277,
282
],
[
285,
436
],
[
438,
476
],
[
495,
500
],
[
505,
505
],
[
507,
518
],
[
529,
550
],
[
552,
633
],
[
657,
657
],
[
659,
682
],
[
685,
688
],
[
692,
692
],
[
694,
696
],
[
698,
702
],
[
707,
719
],
[
722,
743
],
[
745,
815
],
[
826,
962
],
[
973,
973
],
[
986,
1070
],
[
1075,
1091
],
[
1093,
1108
],
[
1110,
1154
],
[
1156,
1210
],
[
1212,
1248
],
[
1250,
1282
],
[
1289,
1290
],
[
1292,
1370
],
[
1372,
1429
],
[
1431,
1474
],
[
1480,
1513
],
[
1515,
1517
],
[
1519,
1525
],
[
1535,
1537
],
[
1541,
1541
],
[
1547,
1547
],
[
1549,
1549
],
[
1551,
1560
],
[
1568,
1575
],
[
1596,
1597
],
[
1633,
1739
],
[
1805,
1805
],
[
1867,
1971
]
]
]
|
8266d0c9eb8c60c42b969da1de3a31b73fa9b067 | 3532ae25961855b20635decd1481ed7def20c728 | /app/Idiot/idiotwindow.h | 37791d13df1255906559194a4842117c696e5f28 | []
| no_license | mcharmas/Bazinga | 121645a0c7bc8bd6a91322c2a7ecc56a5d3f71b7 | 1d35317422c913f28710b3182ee0e03822284ba3 | refs/heads/master | 2020-05-18T05:48:32.213937 | 2010-03-22T17:13:09 | 2010-03-22T17:13:09 | 577,323 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,134 | h | #ifndef IDIOTWINDOW_H
#define IDIOTWINDOW_H
#include <QMainWindow>
#include <QSettings>
#include <QTimerEvent>
#include <bconnection.h>
namespace Ui {
class IdiotWindow;
}
/*! \brief Klasa wyลwietlajฤ
ca okno programu
Skลada siฤ tylko z dwรณch pรณl:
\li po lewej kolorowa reprezentacja otrzymanych obiektow ImageWidget
\li po prawej panel do nawiฤ
zania poลฤ
czenia BConnectionWidget
*/
class IdiotWindow : public QMainWindow {
Q_OBJECT
public:
/*! \brief Konstruktor
Wลฤ
cza timer co 10 ms.
\sa timerEvent(QTimerEvent*)
*/
IdiotWindow(QWidget *parent = 0);
/*! \brief Destruktor
Rozลฤ
cza z serwerem.
*/
~IdiotWindow();
protected:
/*! \brief Zwiฤ
zane z Qt, nie dotyczy programu */
void changeEvent(QEvent *e);
/*! \brief Sprawdza, czy przyszลy dane
Jeลli przyszลy nowe dane, tworzy z datagramu liste obiektow
i przekazuje je do ImageWidget::setBObs(quint32, BObList*) */
void timerEvent(QTimerEvent *ev);
private:
Ui::IdiotWindow *ui;
BConnection connection;
QSettings settings;
};
#endif // IDIOTWINDOW_H
| [
"santamon@ffdda973-792b-4bce-9e62-2343ac01ffa1"
]
| [
[
[
1,
52
]
]
]
|
cc601135489dfd95164322dd066862f34f810227 | 823afcea9ac0705f6262ccffdff65d687822fe93 | /RayTracing/Src/Plane.h | 40c05c0d737ff83bd97f6f73f5ede7677a3837e1 | []
| no_license | shourav9884/raytracing99999 | 02b405759edf7eb5021496f87af8fa8157e972be | 19c5e3a236dc1356f6b4ec38efcc05827acb9e04 | refs/heads/master | 2016-09-10T03:30:54.820034 | 2006-10-15T21:49:19 | 2006-10-15T21:49:19 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 983 | h | #pragma once
#include "Object3D.h"
#include "Vector3D.h"
#include "Ray.h"
class Plane : public Object3D
{
private:
Vector3D vector;
// O ponto (View e World position) รฉ herdado da Object3D que herda do SceneObject
private:
Vector3D getNormalVector( const Vector3D& aPoint, Vector2D aTextureUVCoordinates );
Vector2D getTextureUVCoordinates( const Vector3D& aIntersectionPoint);
public:
Plane( );
Plane( const Vector3D &aVector, const Vector3D &aPoint );
~Plane( );
double checkIntersection( const Ray& aRay );
// ร paralelo quando os vetores sao ortogonais
inline bool isParallel(const Vector3D &aVector)
{
double value = aVector.dotProduct(this->vector);
if( value > 0.00000000001 || value < -0.00000000001 )
return false;
else
return true;
}
inline const Vector3D &getVector( ) const
{
return this->vector;
}
inline void setVector( const Vector3D &aVector )
{
this->vector = aVector;
}
};
| [
"saulopessoa@34b68867-b01b-0410-ab61-0f167d00cb52"
]
| [
[
[
1,
45
]
]
]
|
8329c0b2671d7f3450bffa45c3f485bc2fdc362d | e2e49023f5a82922cb9b134e93ae926ed69675a1 | /tools/aoslcpp/include/aosl/resource_type_specific.inl | 5e31e68fd0f934d5491eac0ea1c5bdb0e2906105 | []
| no_license | invy/mjklaim-freewindows | c93c867e93f0e2fe1d33f207306c0b9538ac61d6 | 30de8e3dfcde4e81a57e9059dfaf54c98cc1135b | refs/heads/master | 2021-01-10T10:21:51.579762 | 2011-12-12T18:56:43 | 2011-12-12T18:56:43 | 54,794,395 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 662 | inl | // Copyright (C) 2005-2010 Code Synthesis Tools CC
//
// This program was generated by CodeSynthesis XSD, an XML Schema
// to C++ data binding compiler, in the Proprietary License mode.
// You should have received a proprietary license from Code Synthesis
// Tools CC prior to generating this code. See the license text for
// conditions.
//
#ifndef AOSLCPP_AOSL__RESOURCE_TYPE_SPECIFIC_INL
#define AOSLCPP_AOSL__RESOURCE_TYPE_SPECIFIC_INL
// Begin prologue.
//
//
// End prologue.
namespace aosl
{
// Resource_type_specific
//
}
// Begin epilogue.
//
//
// End epilogue.
#endif // AOSLCPP_AOSL__RESOURCE_TYPE_SPECIFIC_INL
| [
"klaim@localhost"
]
| [
[
[
1,
29
]
]
]
|
643f757d93c2a09e3bc6b135a9318a9857db3bdb | e3a6af78f5d4ff6a4e86056890df259cbe099d1c | /Source/Main.cpp | ea737a4b0df5990c0ac2dbf55465507db1af760b | []
| no_license | pingdynasty/BlipSim | 953383159ddf2f04614466830fc798edd64e7687 | bd49b7329125dc21a75761d516281f3e4b7667c2 | refs/heads/master | 2021-01-15T19:40:16.001588 | 2011-08-08T15:17:59 | 2011-08-08T15:17:59 | 2,162,192 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,990 | cpp | /*
==============================================================================
This file was auto-generated by the Jucer!
It contains the basic startup code for a Juce application.
==============================================================================
*/
#include "../JuceLibraryCode/JuceHeader.h"
#include "MainWindow.h"
#include "BlipSim.h"
//==============================================================================
class BlipSimApplication : public JUCEApplication
{
public:
//==============================================================================
BlipSimApplication()
{
}
~BlipSimApplication()
{
}
//==============================================================================
void initialise (const String& commandLine)
{
// Do your application's initialisation code here..
std::cout << "Main" << std::endl;
blipsim = new BlipSim();
blipsim->initialise();
mainWindow = new MainAppWindow();
}
void shutdown()
{
// Do your application's shutdown code here..
blipsim->shutdown();
deleteAndZero(blipsim);
mainWindow = 0;
}
//==============================================================================
void systemRequestedQuit()
{
quit();
}
//==============================================================================
const String getApplicationName()
{
return "BlipSim";
}
const String getApplicationVersion()
{
return ProjectInfo::versionString;
}
bool moreThanOneInstanceAllowed()
{
return true;
}
void anotherInstanceStarted (const String& commandLine)
{
}
private:
ScopedPointer <MainAppWindow> mainWindow;
BlipSim* blipsim;
};
//==============================================================================
// This macro generates the main() routine that starts the app.
START_JUCE_APPLICATION(BlipSimApplication)
| [
"[email protected]"
]
| [
[
[
1,
80
]
]
]
|
aa8659febd8111b11e84f41a767e5a880339735c | 1493997bb11718d3c18c6632b6dd010535f742f5 | /battleship/win32/view.h | 36ca8348d1767521cf6d81de8cb064345fc5dfc6 | []
| no_license | kovrov/scrap | cd0cf2c98a62d5af6e4206a2cab7bb8e4560b168 | b0f38d95dd4acd89c832188265dece4d91383bbb | refs/heads/master | 2021-01-20T12:21:34.742007 | 2010-01-12T19:53:23 | 2010-01-12T19:53:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 837 | h | #pragma once
#include "../game/board.h"
HWND CreateMapWidget(HWND hWndParent);
void SetMapWidgetData(HWND hwnd, const std::vector<board::Ship>* ships, const std::vector<board::Shot>* shots);
void SetMapWidgetThemeColor(HWND hwnd, int color_index, DWORD value);
// notifications
#define BSN_SQUARESELECTED WM_USER+1
struct BSNSquareInfo
{
NMHDR hdr;
board::Pos pos;
};
/* sample usage:
case WM_NOTIFY:
if (reinterpret_cast<NMHDR*>(lParam)->code == BSN_SQUARESELECTED)
{
BSNSquareInfo* si = reinterpret_cast<BSNSquareInfo*>(lParam);
}
break;
*/
// messages
#define BSM_SETDATA WM_USER+1
// color indexes
enum { SEA_BACKGROUND_COLOR,
SEA_FOREROUND_COLOR,
SHIP_FOREGROUND_COLOR,
SHIP_BACKGROUND_COLOR,
HIT_FOREGROUND_COLOR,
HIT_BACKGROUND_COLOR,
COLORS_LENGHT};
| [
"[email protected]"
]
| [
[
[
1,
41
]
]
]
|
1147493f9a630f3ce823c146448e24a4adfac5e3 | a51ac532423cf58c35682415c81aee8e8ae706ce | /GUI/MainWindow.cpp | 794c05f92a26b8ac29df2baa79534f464852e06e | []
| no_license | anderslindmark/PickNPlace | b9a89fb2a6df839b2b010b35a0c873af436a1ab9 | 00ca4f6ce2ecfeddfea7db5cb7ae8e9d0023a5e1 | refs/heads/master | 2020-12-24T16:59:20.515351 | 2008-05-25T01:32:31 | 2008-05-25T01:32:31 | 34,914,321 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 27,977 | cpp |
#include "MainWindow.h" // GUI.
#include <QString> // Qt.
#include <QMessageBox>
PicknPlaceGui::MainWindow *mainwindow;
///
/// \brief Callback wrapper function for Machine events.
/// calls the corresponding member method on the mainwindow object.
///
void on_machine_event(MachineEvent *e)
{
int type = (MachineEventType)e->GetEventType();
QString message = QString(e->GetEventMsg().c_str());
QMetaObject::invokeMethod(mainwindow, "MachineEventOccured", Qt::QueuedConnection,
Q_ARG(int, type), Q_ARG(QString, message));
delete e;
}
namespace PicknPlaceGui
{
///
/// \brief Constructor.
///
MainWindow::MainWindow()
{
mainwindow = this;
// Runs the generated code that setups the initial UI.
this->m_ui.setupUi(this);
this->CloseInformationBar();
this->ConnectSlots();
this->InitCameraManager();
this->CreateToolbarActionGroups();
this->SetGuiSubMode(Move);
this->InitMachineController();
this->m_pProgressDialog = NULL;
this->m_currentCommandIndex = 0;
this->m_runningCommandList = false;
this->m_ui.m_pModeToolBar->setVisible(false); // This is just unecessary, but I'll leave it in the ui-file :S
this->UpdateCameraWidgetMachineCoordinates();
MachineState ms = this->m_pMC->GetCurrentState();
MachineStateStruct mss = ms.GetState();
this->m_ui.m_pBrightnessVerticalSlider->setValue(mss.lampCameraBrightness);
}
///
/// \brief Destructor.
///
MainWindow::~MainWindow()
{
if (this->m_pMC)
{
// Make sure the machine controller has done its business.
this->m_pMC->Wait();
delete this->m_pMC;
}
}
///
/// \brief Initializes the Machine Controller and runs the machines init sequence.
///
void MainWindow::InitMachineController()
{
// TODO: Add a checkbox "don't show this warning again" and save the state in the config file.
int ret = QMessageBox::warning(this, tr("Pick and Place"),
tr("The Pick and Place machine is about to run its initialization sequence"
"\nplease make sure nothing is in its way."),
QMessageBox::Ok | QMessageBox::Cancel,
QMessageBox::Ok);
if (ret == QMessageBox::Cancel)
{
// TODO: Abort and shutdown. Or maybe disable all controls and show a "init button" only in the gui.
return;
}
// Create the machine controller and associate a callback function with it.
this->m_pMC = new MachineController("com1"); // TODO: Let the user choose com port.
this->m_pMC->AddEventHandler(&on_machine_event);
// Init the machine controller.
if (!this->m_pMC->InitializeMachine())
{
// TODO: Fail and exit if the machine controler cannot be initialized?
}
this->m_pMC->Wait();
}
///
/// \brief Initializes the Camera Manager.
///
void MainWindow::InitCameraManager()
{
camera::CameraManager *cameraManager = camera::CameraManager::getInstance();
// Add the dummy driver to the camera manager. This driver is used for testing
// the camera API on a computer without any frame grabber card
/*camera::DummyDriver *dummyDriver = new camera::DummyDriver();
dummyDriver->setImageSize(768, 576);
cameraManager->addDriver(dummyDriver);
*/
// Add the Euresys driver to the camera manager.
camera::EuresysDriver *euresysDriver = new camera::EuresysDriver();
cameraManager->addDriver(euresysDriver);
// TODO: Get the driverIdentifier and cameraIdentifier from the settings
std::string driverIdentifier = cameraManager->getDriver(0)->getIdentifier();
std::string cameraIdentifier = cameraManager->getDriver(0)->getCameraIdentifier(2);
// Set which camera the widget shoud use and start the acquiring
this->m_ui.m_pMainCameraWidget->setCamera(driverIdentifier, cameraIdentifier);
// TODO: Get the correction parameters from the settings
int distortedRectangle[8][2] = {
{31, 60},
{350, 30},
{732, 17},
{30, 288},
{741, 288},
{37, 513},
{355, 542},
{731, 550}
};
// Set the parameters for the barrel correction filter
this->m_ui.m_pMainCameraWidget->setImageCorrectionParameters(distortedRectangle);
// TODO: Get the coordinate conversion parameters from the settings
// Set the coordinate conversion parameters
this->m_ui.m_pMainCameraWidget->setCoordinateMapping(-47500, 0, 47500, 0, 32500, 0, -32500, 0);
this->m_ui.m_pMainCameraWidget->start();
this->m_ui.m_pMainCameraWidget->setMachineCommandList(&this->m_commands);
}
///
/// \brief Creates the action groups for the toolbars (so that only one item is selected at once).
///
void MainWindow::CreateToolbarActionGroups()
{
// Create an action group so that only one mode can be active at any given time.
this->m_pModesActionGroup = new QActionGroup(this);
this->m_pModesActionGroup->addAction(this->m_ui.m_pPickNPlaceToolAction);
this->m_pModesActionGroup->addAction(this->m_ui.m_pDispenceToolAction);
this->m_pInteractionActionGroup = new QActionGroup(this);
this->m_pInteractionActionGroup->addAction(this->m_ui.m_pMoveToolAction);
this->m_pInteractionActionGroup->addAction(this->m_ui.m_pDispenseDotToolAction);
this->m_pInteractionActionGroup->addAction(this->m_ui.m_pDispensePolygonToolAction);
this->m_pInteractionActionGroup->addAction(this->m_ui.m_pPickToolAction);
this->m_pInteractionActionGroup->addAction(this->m_ui.m_pPlaceToolAction);
}
///
/// \brief Toggles between the tools that are shown in the Tools toolbar depending on what gui mode the window is in.
///
void MainWindow::ToggleInteractionTools()
{
bool pnp = (this->m_guimode == PickNPlaceMode);
this->m_ui.m_pPickToolAction->setVisible(pnp);
this->m_ui.m_pPlaceToolAction->setVisible(pnp);
this->m_ui.m_pDispensePolygonToolAction->setVisible(!pnp);
this->m_ui.m_pDispenseDotToolAction->setVisible(!pnp);
}
///
/// \brief Changes the GUI sub mode.
/// \param mode The new GUI sub mode to change to.
///
void MainWindow::SetGuiSubMode(MainWindow::GuiSubMode mode)
{
this->m_subguimode = mode;
this->UpdateGuiBasedOnGuiSubMode();
}
///
/// \brief Changes the GUI to be consistent with the current GUI Sub mode.
///
void MainWindow::UpdateGuiBasedOnGuiSubMode()
{
QStackedWidget *msw = this->m_ui.m_pModeStackedWidget;
CameraWidget *cw = this->m_ui.m_pMainCameraWidget;
switch (this->m_subguimode)
{
default:
case Move:
{
msw->setCurrentWidget(this->m_ui.m_pEmptyModePage);
cw->setMode(CameraWidget::InteractionMode::Move);
break;
}
case Pick:
{
msw->setCurrentWidget(this->m_ui.m_pPickPlaceModePage);
cw->setMode(CameraWidget::InteractionMode::Pick);
break;
}
case Place:
{
msw->setCurrentWidget(this->m_ui.m_pPickPlaceModePage);
cw->setMode(CameraWidget::InteractionMode::Place);
break;
}
case DispenseDot:
{
msw->setCurrentWidget(this->m_ui.m_pDispenseDotModePage);
cw->setMode(CameraWidget::InteractionMode::DispenseDot);
break;
}
case DispensePolygon:
{
msw->setCurrentWidget(this->m_ui.m_pDispensePolyModePage);
cw->setMode(CameraWidget::InteractionMode::DispensePolygon);
break;
}
}
}
///
/// \brief Shows a information message in the information bar at the top of the window.
/// \param message The message that should be shown.
/// \param icon The icon to use when displaying the message, warning/information and so on. Check the QMessageBox::Icon enum for all icon types.
///
void MainWindow::ShowInformation(QString message, QMessageBox::Icon icon)
{
this->m_ui.m_pInformationFrame->setVisible(true);
QPalette pal = QApplication::palette();
// Get the icon pixmap.
QIcon tmpIcon;
switch (icon)
{
case QMessageBox::Icon::Information:
tmpIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation);
pal.setColor(QPalette::Window, QColor::fromRgb(0, 230, 255));
break;
case QMessageBox::Icon::Warning:
tmpIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning);
pal.setColor(QPalette::ColorRole::Window, QColor::fromRgb(255, 255, 127));
break;
case QMessageBox::Icon::Critical:
tmpIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical);
pal.setColor(QPalette::ColorRole::Window, QColor::fromRgb(255, 190, 0));
break;
case QMessageBox::Icon::Question:
tmpIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion);
pal.setColor(QPalette::ColorRole::Window, QColor::fromRgb(0, 230, 255));
default:
break;
}
// TODO: Fix setting palette for the information bar depending on message type, it's not working :(
this->m_ui.m_pInformationIconLabel->setPalette(pal);
if (!tmpIcon.isNull())
{
this->m_ui.m_pInformationIconLabel->setPixmap(tmpIcon.pixmap(16, 16));
}
else
{
this->m_ui.m_pInformationIconLabel->setPixmap(NULL);
}
// Set the information message.
this->m_ui.m_pInformationLabel->setText(message);
}
///
/// \brief Connects all slots for the GUI.
///
void MainWindow::ConnectSlots()
{
//
// Mode toolbar.
//
QMainWindow::connect(this->m_ui.m_pPickNPlaceToolAction, SIGNAL(triggered()), this, SLOT(PickNPlaceActionTriggered()));
QMainWindow::connect(this->m_ui.m_pDispenceToolAction, SIGNAL(triggered()), this, SLOT(DispenceActionTriggered()));
//
// Tools toolbar.
//
QMainWindow::connect(this->m_ui.m_pZoomToolAction, SIGNAL(triggered()), this, SLOT(ZoomActionTriggered()));
// Interaction tools.
QMainWindow::connect(this->m_ui.m_pMoveToolAction, SIGNAL(triggered()), this, SLOT(MoveToolTriggered()));
QMainWindow::connect(this->m_ui.m_pDispenseDotToolAction, SIGNAL(triggered()), this, SLOT(DispenseDotToolTriggered()));
QMainWindow::connect(this->m_ui.m_pDispensePolygonToolAction, SIGNAL(triggered()), this, SLOT(DispensePolygonToolTriggered()));
QMainWindow::connect(this->m_ui.m_pPickToolAction, SIGNAL(triggered()), this, SLOT(PickToolTriggered()));
QMainWindow::connect(this->m_ui.m_pPlaceToolAction, SIGNAL(triggered()), this, SLOT(PlaceToolTriggered()));
//
// Information bar.
//
QMainWindow::connect(this->m_ui.m_pCloseInformationButton, SIGNAL(pressed()), this, SLOT(CloseInformationBar()));
//
// Other controls.
//
QMainWindow::connect(this->m_ui.m_pBrightnessVerticalSlider, SIGNAL(valueChanged(int)), this, SLOT(BrightnessSliderChanged(int)));
QMainWindow::connect(this->m_ui.m_pBrightnessVerticalSlider, SIGNAL(sliderReleased()), this, SLOT(BrightnessSliderSliderReleased()));
QMainWindow::connect(this->m_ui.m_pLockZPushButton, SIGNAL(toggled(bool)), this, SLOT(ZLockButtonToggled(bool)));
QMainWindow::connect(this->m_ui.m_pXSpinBox, SIGNAL(valueChanged(int)), this, SLOT(XValueChanged(int)));
QMainWindow::connect(this->m_ui.m_pYSpinBox, SIGNAL(valueChanged(int)), this, SLOT(YValueChanged(int)));
QMainWindow::connect(this->m_ui.m_pZSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ZValueChanged(int)));
QMainWindow::connect(this->m_ui.m_pCommandsListWidget, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this, SLOT(CommandListItemChanged(QListWidgetItem *, QListWidgetItem *)));
QMainWindow::connect(this->m_ui.m_pClearPickPlacePointsButton, SIGNAL(pressed()), this, SLOT(ClearPickPlaceButtonPressed()));
QMainWindow::connect(this->m_ui.m_pClearPolygonButton, SIGNAL(pressed()), this, SLOT(ClearPolygonButtonPressed()));
QMainWindow::connect(this->m_ui.m_pRemoveDotButton, SIGNAL(pressed()), this, SLOT(RemoveDotButtonPressed()));
QMainWindow::connect(this->m_ui.m_pDispenseDotSpinBox, SIGNAL(valueChanged(int)), this, SLOT(DispenseDotSpinBoxValueChanged(int)));
QMainWindow::connect(this->m_ui.m_pEnqueueCommandButton, SIGNAL(pressed()), this, SLOT(EnqueueCommandButtonPressed()));
QMainWindow::connect(this->m_ui.m_pRunCommandsButton, SIGNAL(pressed()), this, SLOT(RunCommandsButtonPressed()));
QMainWindow::connect(this->m_ui.m_pRemoveCommandButton, SIGNAL(pressed()), this, SLOT(RemoveCommandButtonPressed()));
QMainWindow::connect(this->m_ui.m_pMainCameraWidget, SIGNAL(newMachineCoordinates(int, int)),
this, SLOT(CameraWidgetNewMachineCoordinates(int, int)));
QMainWindow::connect(this->m_ui.m_pMainCameraWidget, SIGNAL(commandReady(CameraWidget::InteractionMode, PicknPlaceGui::DispencePolygonCommand)),
this, SLOT(CameraWidgetCommandReady(CameraWidget::InteractionMode, PicknPlaceGui::DispencePolygonCommand)));
QMainWindow::connect(this->m_ui.m_pMainCameraWidget, SIGNAL(commandReady(CameraWidget::InteractionMode, QPoint *, QPoint *)),
this, SLOT(CameraWidgetCommandReady(CameraWidget::InteractionMode, QPoint *, QPoint *)));
QMainWindow::connect(this->m_ui.m_pMainCameraWidget, SIGNAL(commandReady(CameraWidget::InteractionMode, QPoint)),
this, SLOT(CameraWidgetCommandReady(CameraWidget::InteractionMode, QPoint)));
QMainWindow::connect(this->m_ui.m_pMainCameraWidget, SIGNAL(commandInvalid()), this, SLOT(CameraWidgetCommandInvalid()));
QMainWindow::connect(this->m_ui.m_pCommandsListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(CommandSelectionChanged()));
QMainWindow::connect(this->m_ui.m_pRemoveLastPointButton, SIGNAL(pressed()), this, SLOT(RemoveLastPointButtonPressed()));
}
void MainWindow::closeEvent(QCloseEvent *event)
{
// TODO: Check if the user really wants to quit before closing.
/*
if ()
{
event->accept();
}
else
{
event->ignore();
}
*/
}
///
/// \brief Slot for when a machine event has occured.
///
void MainWindow::MachineEventOccured(int type, QString message)
{
this->UpdateCameraWidgetMachineCoordinates();
if (type == EVENT_MACHINE_INITIALIZED)
{
//mainwindow->statusBar()->showMessage("Machine initialized successfully");
}
else if (type == EVENT_CMD_DONE)
{
// Check if there's any more commands to run in the command list.
if (this->m_runningCommandList)
{
this->RunCommands();
}
}
else if (type == EVENT_CMD_FAILED)
{
this->ShowInformation(message, QMessageBox::Icon::Critical);
}
else if (type == EVENT_CMD_ILLEGAL)
{
this->ShowInformation(message, QMessageBox::Icon::Critical);
}
else if (type == EVENT_CMD_OUT_OF_BOUNDS)
{
this->ShowInformation(message, QMessageBox::Icon::Warning);
}
}
///
/// \brief Runs the list of commands.
///
void MainWindow::RunCommands()
{
this->setEnabled(false);
this->m_runningCommandList = true;
this->m_ui.m_pMainCameraWidget->setDrawCommands(false);
if (!this->m_pProgressDialog)
{
this->m_pProgressDialog = new QProgressDialog(this);
this->m_pProgressDialog->setCancelButtonText(tr("Stop"));
this->m_pProgressDialog->setMaximum(this->m_commands.size());
QMainWindow::connect(this->m_pProgressDialog, SIGNAL(canceled()), this, SLOT(CommandsCanceled()));
}
else
{
this->m_pProgressDialog->setValue(this->m_currentCommandIndex + 1);
}
// Run the next command.
while (this->m_currentCommandIndex < this->m_commands.size())
{
PicknPlaceGui::GuiMachineCommand *c = this->m_commands.at(this->m_currentCommandIndex);
this->m_pMC->RunCommand(c->GetMachineCommand());
// Show progress.
this->m_pProgressDialog->setLabelText(QString(tr("Running command: %1 (%2 of %3)"))
.arg(c->toString()).arg(this->m_currentCommandIndex + 1).arg(this->m_commands.size()));
this->m_pProgressDialog->show();
this->m_currentCommandIndex++;
return;
//this->m_pMC->Wait();
}
CommandsCanceled();
this->m_ui.m_pMainCameraWidget->setDrawCommands(this->m_ui.m_pShowPolygonToolAction->isChecked());
this->UpdateCameraWidgetMachineCoordinates();
}
///
/// ======================================== SLOTS ==================================================
///
///
/// \brief Slot for when the "Stop" button is clicked on the command progress bar.
///
void MainWindow::CommandsCanceled()
{
if (this->m_pProgressDialog)
{
delete this->m_pProgressDialog;
}
this->m_currentCommandIndex = 0;
this->m_runningCommandList = false;
this->setEnabled(true);
}
///
/// \brief Slot for when the "Pick and Place" toolbar button (QAction) has been triggered, this should change the GUI mode.
///
void MainWindow::PickNPlaceActionTriggered()
{
if (this->m_ui.m_pPickNPlaceToolAction->isChecked())
{
// Change to Pick and place mode.
this->m_guimode = PickNPlaceMode;
this->ToggleInteractionTools();
}
}
///
/// \brief Slot for when the "Dispense" toolbar button (QAction) has been triggered, this should change the GUI mode.
///
void MainWindow::DispenceActionTriggered()
{
if (this->m_ui.m_pDispenceToolAction->isChecked())
{
// Change to Dispence mode.
this->m_guimode = DispenceMode;
this->ToggleInteractionTools();
}
}
///
/// \brief Slot for when the "Zoom" action is triggered.
///
void MainWindow::ZoomActionTriggered()
{
if (this->m_ui.m_pZoomToolAction->isChecked())
{
// TODO: Turn on the zoom camera on the camera widget.
}
else
{
}
}
///
/// \brief Slot for when the brightness slider changes.
///
void MainWindow::BrightnessSliderChanged(int value)
{
// Set the brightness for the machine.
//MachineLightBrightnessCommand brightness = MachineLightBrightnessCommand(Lamp::LAMP_CAMERA, value);
//this->m_pMC->RunCommand(brightness);
}
///
/// \brief Slot for when the brightness slider is released.
///
void MainWindow::BrightnessSliderSliderReleased()
{
// Set the brightness for the machine.
MachineLightBrightnessCommand brightness = MachineLightBrightnessCommand(Lamp::LAMP_CAMERA, this->m_ui.m_pBrightnessVerticalSlider->value());
this->m_pMC->RunCommand(brightness);
this->m_pMC->Wait();
}
///
/// \brief Updates the machine coordinates for the camera widget.
///
void MainWindow::UpdateCameraWidgetMachineCoordinates()
{
int x = this->m_pMC->GetCurrentState().GetState().x;
int y = this->m_pMC->GetCurrentState().GetState().y;
int z = this->m_pMC->GetCurrentState().GetState().z;
this->m_ui.m_pMainCameraWidget->setMachineCoordinates(x, y, z);
this->m_ui.m_pXSpinBox->setValue(x);
this->m_ui.m_pYSpinBox->setValue(y);
this->m_ui.m_pZSpinBox->setValue(z);
}
///
/// \brief The Z lock button was toggled.
///
void MainWindow::ZLockButtonToggled(bool toggled)
{
// Toggle the Z spinbox and slider (If the button is pressed they should be locked).
this->m_ui.m_pZSpinBox->setEnabled(!toggled);
this->m_ui.m_pZVerticalSlider->setEnabled(!toggled);
this->UpdateCameraWidgetMachineCoordinates();
}
///
/// \brief The Z value changed in the GUI.
///
void MainWindow::ZValueChanged(int value)
{
// Change the Z-Level for the machine head.
MachineMoveAbsoluteCommand move = MachineMoveAbsoluteCommand(AXIS_Z, value);
this->m_pMC->RunCommand(move);
this->m_pMC->Wait();
this->UpdateCameraWidgetMachineCoordinates();
}
///
/// \brief The Y value changed in the GUI.
///
void MainWindow::YValueChanged(int value)
{
// Change the Y-value for the machine head.
MachineMoveAbsoluteCommand move = MachineMoveAbsoluteCommand(AXIS_Y, value);
this->m_pMC->RunCommand(move);
this->m_pMC->Wait();
this->UpdateCameraWidgetMachineCoordinates();
}
///
/// \brief The X value changed in the GUI.
///
void MainWindow::XValueChanged(int value)
{
// Change the X-value for the machine head.
MachineMoveAbsoluteCommand move = MachineMoveAbsoluteCommand(AXIS_X, value);
this->m_pMC->RunCommand(move);
this->m_pMC->Wait();
this->UpdateCameraWidgetMachineCoordinates();
}
///
/// \brief Slot for when a new item in the command list is selected.
///
void MainWindow::CommandListItemChanged(QListWidgetItem *current, QListWidgetItem *previous)
{
this->m_ui.m_pRemoveCommandButton->setEnabled(current != NULL);
}
///
/// \brief Slot for when the close button on the information bar is pressed. Closes the information bar.
///
void MainWindow::CloseInformationBar()
{
this->m_ui.m_pInformationFrame->setVisible(false);
}
///
/// \brief Slot for when the move tool button is triggered.
///
void MainWindow::MoveToolTriggered()
{
SetGuiSubMode(GuiSubMode::Move);
}
///
/// \brief Slot for when the pick tool button is triggered.
///
void MainWindow::PickToolTriggered()
{
SetGuiSubMode(GuiSubMode::Pick);
}
///
/// \brief Slot for when the Place tool button is triggered.
///
void MainWindow::PlaceToolTriggered()
{
SetGuiSubMode(GuiSubMode::Place);
}
///
/// \brief Slot for when the Dispense Dot tool button is triggered.
///
void MainWindow::DispenseDotToolTriggered()
{
SetGuiSubMode(GuiSubMode::DispenseDot);
}
///
/// \brief Slot for when the Dispense Polygon tool button is triggered.
///
void MainWindow::DispensePolygonToolTriggered()
{
SetGuiSubMode(GuiSubMode::DispensePolygon);
}
///
/// \brief Slot for when the clear pick and place points button has been clicked.
///
void MainWindow::ClearPickPlaceButtonPressed()
{
if (this->m_subguimode == Pick)
{
this->m_ui.m_pMainCameraWidget->resetMode(CameraWidget::InteractionMode::Pick);
}
if (this->m_subguimode == Place)
{
this->m_ui.m_pMainCameraWidget->resetMode(CameraWidget::InteractionMode::Place);
}
}
///
/// \brief Slot for when the clear polygon button has been clicked.
///
void MainWindow::ClearPolygonButtonPressed()
{
this->m_ui.m_pMainCameraWidget->resetMode(CameraWidget::InteractionMode::DispensePolygon);
}
///
/// \brief Slot for when the remove dot button has been clicked.
///
void MainWindow::RemoveDotButtonPressed()
{
this->m_ui.m_pMainCameraWidget->resetMode(CameraWidget::InteractionMode::DispenseDot);
}
///
/// \brief Slot for when the dispense dot spin box changes value.
///
void MainWindow::DispenseDotSpinBoxValueChanged(int value)
{
this->m_ui.m_pMainCameraWidget->setDispenseDotRadius(value);
}
///
/// \brief Slot for when the enqueue command button has been clicked.
///
void MainWindow::EnqueueCommandButtonPressed()
{
CameraWidget *cw = this->m_ui.m_pMainCameraWidget;
CameraWidget::InteractionMode cmode = cw->getMode();
if (cmode == CameraWidget::InteractionMode::DispensePolygon)
{
DispencePolygonCommand *dpc = new DispencePolygonCommand(*cw->getDispensePolygon());
DispenceStateStruct dss = dpc->GetSettings();
dss.offsetX = 100000;
dpc->SetSettings(dss);
if (dpc)
{
this->m_commands.append(dpc);
}
}
else if (cmode == CameraWidget::InteractionMode::DispenseDot)
{
QPoint p = cw->getDotDispensePoint();
DispenceStateStruct dss = DispenceStateStruct();
DispenceDotCommand *ddp = new DispenceDotCommand(p.x(), p.y(), dss);
if (ddp)
{
this->m_commands.append(ddp);
}
}
else if ((cmode == CameraWidget::InteractionMode::Pick) || (cmode == CameraWidget::InteractionMode::Place))
{
QPoint *pickSrc = cw->getPickPoints();
QPoint *placeSrc = cw->getPlacePoints();
Coordinate2D pickPoints[3];
Coordinate2D placePoints[3];
for (int i = 0; i < 3; i++)
{
pickPoints[i].x = pickSrc[i].x();
pickPoints[i].y = pickSrc[i].y();
placePoints[i].x = placeSrc[i].x();
placePoints[i].y = placeSrc[i].y();
}
PickStateStruct pss = PickStateStruct();
PickAndPlaceCommand *ppc = new PickAndPlaceCommand(pickPoints[0], pickPoints[1], pickPoints[2],
placePoints[0], placePoints[1], placePoints[2], pss);
if (ppc)
{
this->m_commands.append(ppc);
}
cw->resetMode(CameraWidget::InteractionMode::Pick);
cw->resetMode(CameraWidget::InteractionMode::Place);
}
// Don't let the user mistakingly enqueue the same command twice by removing the command from the camera widget.
cw->resetCurrentMode();
this->RefreshCommandList();
}
///
/// \brief Refreshes the contents of the command list.
///
void MainWindow::RefreshCommandList()
{
QListWidget *clw = this->m_ui.m_pCommandsListWidget;
this->m_ui.m_pCommandsListWidget->clear();
for (int i = 0; i < this->m_commands.size(); i++)
{
QString str = QString("%1 - %2").arg(i + 1).arg(this->m_commands.at(i)->toString());
clw->addItem(str);
}
this->m_ui.m_pRunCommandsButton->setEnabled(this->m_commands.size() > 0);
}
///
/// \brief Slot for when the run commands button has been clicked.
///
void MainWindow::RunCommandsButtonPressed()
{
this->RunCommands();
}
///
/// \brief Slot for when the remove command button has been clicked.
///
void MainWindow::RemoveCommandButtonPressed()
{
QListWidget *clw = this->m_ui.m_pCommandsListWidget;
QModelIndex index = clw->currentIndex();
int i = index.row();
this->m_commands.removeAt(i);
this->RefreshCommandList();
}
///
/// \brief Slot for when the camera widget wants the machine to move.
///
void MainWindow::CameraWidgetNewMachineCoordinates(int newMachineX, int newMachineY)
{
// Move the machine!
int z = this->m_pMC->GetCurrentState().GetState().z;
MachineMoveAllCommand move = MachineMoveAllCommand(newMachineX, newMachineY, z);
this->m_pMC->RunCommand(move);
}
///
/// \brief Slot for when the camera widget has enough information to create a new command.
///
void MainWindow::CameraWidgetCommandReady(CameraWidget::InteractionMode mode, PicknPlaceGui::DispencePolygonCommand *polygon)
{
this->m_ui.m_pEnqueueCommandButton->setEnabled(true);
}
///
/// \brief Slot for when the camera widget has enough information to create a new command.
///
void MainWindow::CameraWidgetCommandReady(CameraWidget::InteractionMode mode, QPoint *pickPoints, QPoint *placePoints)
{
this->m_ui.m_pEnqueueCommandButton->setEnabled(true);
}
///
/// \brief Slot for when the camera widget has enough information to create a new command.
///
void MainWindow::CameraWidgetCommandReady(CameraWidget::InteractionMode mode, QPoint dot)
{
this->m_ui.m_pRemoveDotButton->setEnabled(true);
this->m_ui.m_pEnqueueCommandButton->setEnabled(true);
}
///
/// \brief Slot for when the camera widget doesn't have enough information to create a new command anymore.
///
void MainWindow::CameraWidgetCommandInvalid()
{
this->m_ui.m_pRemoveDotButton->setEnabled(false);
this->m_ui.m_pEnqueueCommandButton->setEnabled(false);
}
///
/// \brief Slot for when the selected command in the command list widget has changed.
///
void MainWindow::CommandSelectionChanged()
{
QListWidget *clw = this->m_ui.m_pCommandsListWidget;
this->m_ui.m_pRemoveCommandButton->setEnabled(clw->selectedItems().count() > 0);
// Set the highlight index for the camera widget.
QModelIndex index = clw->currentIndex();
int i = index.row();
this->m_ui.m_pMainCameraWidget->setHighlightedCommandIndex(i);
}
///
/// \brief Slot for when the remove last point button has been clicked.
///
void MainWindow::RemoveLastPointButtonPressed()
{
CameraWidget *cw = this->m_ui.m_pMainCameraWidget;
DispencePolygonCommand *dpc = cw->getDispensePolygon();
if (dpc && (dpc->Size() > 0))
{
dpc->DelPoint(dpc->Size() - 1);
// Make sure we remove the polygon if there are no points left.
if (dpc->Size() == 0)
{
cw->resetCurrentMode();
}
// TODO: Delete the command also
cw->update();
}
}
}
| [
"js@f672c3ff-8b41-4f22-a4ab-2adcb4f732c7",
"kers@f672c3ff-8b41-4f22-a4ab-2adcb4f732c7"
]
| [
[
[
1,
104
],
[
107,
110
],
[
112,
112
],
[
114,
115
],
[
119,
119
],
[
121,
121
],
[
139,
865
]
],
[
[
105,
106
],
[
111,
111
],
[
113,
113
],
[
116,
118
],
[
120,
120
],
[
122,
138
]
]
]
|
6740592e7aa4b334e1c14c8791bb635f7451be43 | 95a3e8914ddc6be5098ff5bc380305f3c5bcecb2 | /src/FusionForever_lib/HomingProjectile.cpp | dec4d39fe29827abc7db433d36651ff028f041af | []
| no_license | danishcake/FusionForever | 8fc3b1a33ac47177666e6ada9d9d19df9fc13784 | 186d1426fe6b3732a49dfc8b60eb946d62aa0e3b | refs/heads/master | 2016-09-05T16:16:02.040635 | 2010-04-24T11:05:10 | 2010-04-24T11:05:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,277 | cpp | #include "StdAfx.h"
#include "HomingProjectile.h"
#include "Section.h"
#include "TurningRoutines.h"
HomingProjectile::HomingProjectile(BaseEntity* _target)
: Projectile()
{
target_ = _target;
turn_rate_ = 10;
wave_sum_ = Random::RandomFactor() * 2 * M_PI;
wave_magnitude_ = 0.5f;
if(target_!=NULL)
target_->AddSubscriber(this);
}
HomingProjectile::~HomingProjectile(void)
{
if(target_ != NULL)
target_->RemoveSubscriber(this);
}
void HomingProjectile::Tick(float _timespan, std::vector<Decoration_ptr>& _spawn_dec, Matrix4f _transform)
{
wave_sum_ += _timespan * 8.0f;
float turn_rate = 0;
if(target_ != NULL)
{//Turn to face target
Vector3f target_position = target_->GetGlobalPosition() - this->position_;
TurnData turn_data = GetTurnDirection(this->angle_, target_position);
turn_rate = turn_data.turn_factor;
}
turn_rate += wave_magnitude_ * sinf(wave_sum_);
angle_ += turn_rate * _timespan * turn_rate_; //TODO check!
velocity_ = Vector3f(scalar_speed_ * sin(angle_ * M_PI / 180.0f), scalar_speed_ * cos(angle_ * M_PI / 180.0f),0);
Projectile::Tick(_timespan, _spawn_dec, _transform);
}
void HomingProjectile::EndSubscription(Subscriber* _source)
{
if(target_ == _source)
target_ = NULL;
}
| [
"Edward Woolhouse@e6f1df29-e57c-d74d-9e6e-27e3b006b1a7",
"[email protected]",
"EdwardDesktop@e6f1df29-e57c-d74d-9e6e-27e3b006b1a7"
]
| [
[
[
1,
11
],
[
13,
28
],
[
30,
33
],
[
35,
35
],
[
37,
45
]
],
[
[
12,
12
],
[
34,
34
]
],
[
[
29,
29
],
[
36,
36
]
]
]
|
ae834af0e59eb608231b297c5d46df5c839ef925 | ea12fed4c32e9c7992956419eb3e2bace91f063a | /zombie/code/conjurer/conjurer/src/conjurer/nlevelmapviewport_cmds.cc | 1b1ccbdade6429fee4918b2ea7e73147f2c0599e | []
| no_license | ugozapad/TheZombieEngine | 832492930df28c28cd349673f79f3609b1fe7190 | 8e8c3e6225c2ed93e07287356def9fbdeacf3d6a | refs/heads/master | 2020-04-30T11:35:36.258363 | 2011-02-24T14:18:43 | 2011-02-24T14:18:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,082 | cc | #include "precompiled/pchconjurerapp.h"
//------------------------------------------------------------------------------
// nlevelmapviewport_cmds.cc
// (C) 2005 Conjurer Services, S.A.
//------------------------------------------------------------------------------
#include "conjurer/nlevelmapviewport.h"
//------------------------------------------------------------------------------
/**
@scriptclass
nlevelmapviewport
@cppclass
nLevelMapViewport
@superclass
nappviewport
@classinfo
A custom viewport for class preview for Conjurer.
*/
NSCRIPT_INITCMDS_BEGIN(nLevelMapViewport)
NSCRIPT_ADDCMD('SBGC', void, SetBgColor, 1, (const vector4&), 0, ());
NSCRIPT_ADDCMD('GBGC', const vector4&, GetBgColor, 0, (), 0, ());
NSCRIPT_INITCMDS_END()
//------------------------------------------------------------------------------
/**
*/
bool
nLevelMapViewport::SaveCmds(nPersistServer* ps)
{
if (nAppViewport::SaveCmds(ps))
{
//nCmd* cmd;
return true;
}
return false;
}
| [
"magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91"
]
| [
[
[
1,
40
]
]
]
|
38f4da823530cf09dd8c41647b22dd87e7ba9d83 | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /Game/ClientShellDLL/ClientShellShared/FireFX.h | 99f15da372aacacf6a56ccdb335b9a77914f3264 | []
| no_license | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,132 | h | // ----------------------------------------------------------------------- //
//
// MODULE : FireFX.cpp
//
// PURPOSE : FireFX special FX - Definitions
//
// CREATED : 5/06/99
//
// (c) 1999 Monolith Productions, Inc. All Rights Reserved
//
// ----------------------------------------------------------------------- //
#ifndef __FIRE_FX_H__
#define __FIRE_FX_H__
#include "SpecialFX.h"
#include "SmokeFX.h"
#include "LightFX.h"
struct FIRECREATESTRUCT : public SFXCREATESTRUCT
{
FIRECREATESTRUCT();
LTVector vPos;
LTVector vLightColor;
LTVector vLightOffset;
LTFLOAT fLightRadius;
LTFLOAT fLightPhase;
LTFLOAT fLightFreq;
LTFLOAT fSoundRadius;
LTFLOAT fRadius;
LTBOOL bCreateSmoke;
LTBOOL bCreateLight;
LTBOOL bCreateSparks;
LTBOOL bCreateSound;
LTBOOL bBlackSmoke;
LTBOOL bSmokeOnly;
};
inline FIRECREATESTRUCT::FIRECREATESTRUCT()
{
vPos.Init();
vLightColor.Init();
vLightOffset.Init();
fLightRadius = 0.0f;
fLightPhase = 0.0f;
fLightFreq = 0.0f;
fSoundRadius = 0.0f;
fRadius = 0.0f;
bCreateSmoke = LTFALSE;
bCreateLight = LTFALSE;
bCreateSparks = LTFALSE;
bCreateSound = LTFALSE;
bBlackSmoke = LTFALSE;
bSmokeOnly = LTFALSE;
}
class CFireFX : public CSpecialFX
{
public :
CFireFX() : CSpecialFX()
{
m_hSound = LTNULL;
m_fSizeAdjust = 1.0f;
}
~CFireFX()
{
if (m_hSound)
{
g_pLTClient->SoundMgr()->KillSound(m_hSound);
}
}
virtual LTBOOL CreateObject(ILTClient* pClientDE);
virtual LTBOOL Init(HLOCALOBJ hServObj, ILTMessage_Read *pMsg);
virtual LTBOOL Init(SFXCREATESTRUCT* psfxCreateStruct);
virtual LTBOOL Update();
virtual uint32 GetSFXID() { return SFX_FIRE_ID; }
private :
FIRECREATESTRUCT m_cs;
HLTSOUND m_hSound;
LTFLOAT m_fSizeAdjust;
CSmokeFX m_Smoke1;
CSmokeFX m_Fire1;
CSmokeFX m_Fire2;
CLightFX m_Light;
};
#endif // __FIRE_FX_H__ | [
"[email protected]"
]
| [
[
[
1,
95
]
]
]
|
84dd7959a55d744d5ff11b8e8066ff46d348b0be | fcdddf0f27e52ece3f594c14fd47d1123f4ac863 | /terralib/src/terralib/drivers/qt/TeQtGLWidget.h | ef950e694862741e0ce2d5afc67f425260afd560 | []
| no_license | radtek/terra-printer | 32a2568b1e92cb5a0495c651d7048db6b2bbc8e5 | 959241e52562128d196ccb806b51fda17d7342ae | refs/heads/master | 2020-06-11T01:49:15.043478 | 2011-12-12T13:31:19 | 2011-12-12T13:31:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,562 | h | /************************************************************************************
TerraLib - a library for developing GIS applications.
Copyright ๏ฟฝ 2001-2007 INPE and Tecgraf/PUC-Rio.
This code is part of the TerraLib library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
You should have received a copy of the GNU Lesser General Public
License along with this library.
The authors reassure the license terms regarding the warranties.
They specifically disclaim any warranties, including, but not limited to,
the implied warranties of merchantability and fitness for a particular purpose.
The library provided hereunder is on an "as is" basis, and the authors have no
obligation to provide maintenance, support, updates, enhancements, or modifications.
In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
indirect, special, incidental, or consequential damages arising out of the use
of this library and its documentation.
*************************************************************************************/
#ifndef __TERRALIB_INTERNAL_QTGLBOX_H
#define __TERRALIB_INTERNAL_QTGLBOX_H
#include <qgl.h>
#include <qpixmap.h>
#include <TeDataTypes.h>
#include <vector>
#include <TeAppUtilsDefines.h>
using namespace std;
class TeTheme;
class TeDatabase;
class TeQtGrid;
class TLAPPUTILS_DLL TeQtGLWidget : public QGLWidget
{
Q_OBJECT
public:
TeQtGLWidget( QWidget* parent, const char* name, TeQtGrid* grid, string xField, string yField, string zField, QPaintDevice* xy, QPaintDevice* xz, QPaintDevice* yz, int selectedObjects = TeAll, string func = "NONE");
~TeQtGLWidget();
void drawAxis(bool b) {drawAxis_ = b; updateGL();}
GLfloat xRot_, yRot_, zRot_;
GLfloat xTranslation_, yTranslation_, zTranslation_;
GLfloat viewAngle_;
GLfloat xOff_, yOff_, zOff_;
GLfloat xSize_, ySize_, zSize_;
string xField_, yField_, zField_;
bool frontLighting_;
bool addSelection_;
TeTheme* theme_;
TeDatabase* db_;
public slots:
// the values of degrees, offset, size, translation and angle are between 0 - 99.
// therefore it shoud be conveted to adequate value
void setXRotation( int degrees );
void setYRotation( int degrees );
void setZRotation( int degrees );
void setXOffset( int offset );
void setYOffset( int offset );
void setZOffset( int offset );
void setXSize( int size );
void setYSize( int size );
void setZSize( int size );
void xOffsetReleased();
void yOffsetReleased();
void zOffsetReleased();
void xSizeReleased();
void ySizeReleased();
void zSizeReleased();
void setViewAngle( int angle );
void setLightingMode( int m );
void paint2D();
void paint3D();
void getCubeCoordinate(double& x1, double& y1, double& z1, double& x2, double& y2, double& z2);
void drawSelecteds();
void changeFunction(string function);
void changeInputObjects(int v);
void changeQuality(int v);
void updateSelection();
void deleteGLObject();
void initGLObject();
protected:
void initializeGL();
void paintGL();
void resizeGL( int w, int h );
void mousePressEvent(QMouseEvent*);
void mouseMoveEvent(QMouseEvent*);
void mouseReleaseEvent(QMouseEvent*);
void keyPressEvent(QKeyEvent*);
void keyReleaseEvent(QKeyEvent*);
void draw2DPixmaps();
void makeObject();
void getValues();
void selectFromHexaedro();
signals:
void setXOffsetSignal(int);
void setYOffsetSignal(int);
void setZOffsetSignal(int);
void setXSizeSignal(int);
void setYSizeSignal(int);
void setZSizeSignal(int);
void setXRotationSignal(int);
void setYRotationSignal(int);
void setZRotationSignal(int);
void setZoomSignal(int);
private:
int selIni_;
int quality_;
GLuint cone_;
vector<GLuint> ballVec_;
vector<string> idVec_;
map<string, GLuint> ballMap_;
GLfloat scale_;
GLfloat min_, max_;
QPoint mousePosition_;
vector<double> xVec_, yVec_, zVec_;
bool drawAxis_;
bool drawSelecteds_;
QPaintDevice *xyDevice_, *zxDevice_, *yzDevice_;
QPixmap xyPixmap_, zxPixmap_, yzPixmap_;
QColor defaultColor_;
QColor pointingColor_;
string function_;
int selectedObjects_;
TeQtGrid* grid_;
int keyPress_;
};
#endif // __TERRALIB_INTERNAL_QTGLBOX_H
| [
"[email protected]@58180da6-ba8b-8960-36a5-00cc02a3ddec"
]
| [
[
[
1,
154
]
]
]
|
2df53c894eac7b9f806d048ea1b0c2f211761f97 | 8bbbcc2bd210d5608613c5c591a4c0025ac1f06b | /nes/mapper/151.cpp | 207209afc29a89e317f0bd815f8e0ac33b74c54a | []
| no_license | PSP-Archive/NesterJ-takka | 140786083b1676aaf91d608882e5f3aaa4d2c53d | 41c90388a777c63c731beb185e924820ffd05f93 | refs/heads/master | 2023-04-16T11:36:56.127438 | 2008-12-07T01:39:17 | 2008-12-07T01:39:17 | 357,617,280 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,271 | cpp | #ifdef _NES_MAPPER_CPP_
/////////////////////////////////////////////////////////////////////
// Mapper 151
void NES_mapper151_Init()
{
g_NESmapper.Reset = NES_mapper151_Reset;
g_NESmapper.MemoryWrite = NES_mapper151_MemoryWrite;
}
void NES_mapper151_Reset()
{
// set CPU bank pointers
g_NESmapper.set_CPU_banks4(0,1,g_NESmapper.num_8k_ROM_banks-2,g_NESmapper.num_8k_ROM_banks-1);
// set VROM banks
g_NESmapper.set_PPU_banks8(0,1,2,3,4,5,6,7);
}
void NES_mapper151_MemoryWrite(uint32 addr, uint8 data)
{
switch(addr & 0xF000)
{
case 0x8000:
{
g_NESmapper.set_CPU_bank4(data);
}
break;
case 0xA000:
{
g_NESmapper.set_CPU_bank5(data);
}
break;
case 0xC000:
{
g_NESmapper.set_CPU_bank6(data);
}
break;
case 0xE000:
{
g_NESmapper.set_PPU_bank0(data*4+0);
g_NESmapper.set_PPU_bank1(data*4+1);
g_NESmapper.set_PPU_bank2(data*4+2);
g_NESmapper.set_PPU_bank3(data*4+3);
}
break;
case 0xF000:
{
g_NESmapper.set_PPU_bank4(data*4+0);
g_NESmapper.set_PPU_bank5(data*4+1);
g_NESmapper.set_PPU_bank6(data*4+2);
g_NESmapper.set_PPU_bank7(data*4+3);
}
break;
}
}
/////////////////////////////////////////////////////////////////////
#endif
| [
"takka@e750ed6d-7236-0410-a570-cc313d6b6496"
]
| [
[
[
1,
62
]
]
]
|
de2a28a7aa8460e5127341f4255249e221fbea42 | c3ae23286c2e8268355241f8f06cd1309922a8d6 | /rateracerlib/mathlib/Vec2.h | 4ad5486f928a7da4836d33fd410dcf6b8e068a3e | []
| no_license | BackupTheBerlios/rateracer-svn | 2f43f020ecdd8a3528880d474bec1c0464879597 | 838ad3f326962028ce8d493d2c06f6af6ea4664c | refs/heads/master | 2020-06-04T03:31:51.633612 | 2005-05-30T06:38:01 | 2005-05-30T06:38:01 | 40,800,078 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,284 | h | #pragma once
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include "MathUtils.h"
class Vec2
{
protected:
float v_[2];
public:
Vec2();
Vec2(const Vec2&);
Vec2(float, float);
// array access
float& operator [](int);
const float& operator [](int) const;
// assignment
Vec2& assign(float, float);
void setZero();
void copyFrom(float [2]);
void copyTo(float [2]) const;
// operations
Vec2& normalize();
Vec2& normalizeSafely();
Vec2& clampVec(float, float);
// math operators
Vec2& operator =(const Vec2&);
Vec2& operator +=(const Vec2&);
Vec2& operator -=(const Vec2&);
Vec2& operator *=(float);
Vec2& operator /=(float);
Vec2 operator +(const Vec2&) const;
Vec2 operator -(const Vec2&) const;
Vec2 operator -() const;
Vec2 operator *(float) const;
Vec2 operator /(float) const;
friend Vec2 operator *(float, const Vec2&);
bool operator ==(const Vec2&) const;
bool operator !=(const Vec2&) const;
friend float dot(const Vec2&, const Vec2&);
float length() const;
float lengthSquared() const;
float lengthManhattan() const;
friend float distance(const Vec2&, const Vec2&);
friend float distanceSquared(const Vec2&, const Vec2&);
// Angle between vectors u and v (radians)
friend float angle( Vec2 &u, Vec2 &v );
// angle in unit circle relative to x-axis
friend float angleUnitCircle( Vec2 &u );
// Project vector u onto vector v
friend Vec2 proj_u_on_v(Vec2 &u, Vec2 &v);
// Linear interpolation between two vectors
friend Vec2 lerp(float, const Vec2&, const Vec2&);
int minComponent() const;
int maxComponent() const;
// Unary, perpendicular dot product defined in Graphics Gems IV...
Vec2 perpDot() const;
void print() const; // Debug print to console
};
// CONSTRUCTORS
MATH_INLINE Vec2::Vec2()
{
v_[0] = v_[1] = 0;
}
MATH_INLINE Vec2::Vec2(const Vec2& v)
{
v_[0] = v.v_[0]; v_[1] = v.v_[1];
}
MATH_INLINE Vec2::Vec2(float x, float y)
{
v_[0] = x; v_[1] = y;
}
// ARRAY ACCESS
MATH_INLINE float& Vec2::operator [](int i)
{
assert(i == 0 || i == 1);
return v_[i];
}
MATH_INLINE const float& Vec2::operator [](int i) const
{
assert(i == 0 || i == 1);
return v_[i];
}
// ASSIGNMENT
MATH_INLINE Vec2& Vec2::assign(float x, float y)
{
v_[0] = x; v_[1] = y;
return *this;
}
MATH_INLINE Vec2& Vec2::operator =(const Vec2& v)
{
v_[0] = v.v_[0]; v_[1] = v.v_[1];
return *this;
}
MATH_INLINE void Vec2::setZero()
{
v_[0] = v_[1] = 0.0f;
}
// MATH OPERATORS
MATH_INLINE Vec2& Vec2::operator +=(const Vec2& v)
{
v_[0] += v.v_[0]; v_[1] += v.v_[1];
return *this;
}
MATH_INLINE Vec2& Vec2::operator -=(const Vec2& v)
{
v_[0] -= v.v_[0]; v_[1] -= v.v_[1];
return *this;
}
MATH_INLINE Vec2& Vec2::operator *=(float c)
{
v_[0] *= c; v_[1] *= c;
return *this;
}
MATH_INLINE Vec2& Vec2::operator /=(float c)
{
assert(!isZero(c));
float ic = 1.0f / c;
v_[0] *= ic; v_[1] *= ic;
return *this;
}
MATH_INLINE Vec2 Vec2::operator +(const Vec2& v) const
{
return Vec2(v_[0] + v.v_[0], v_[1] + v.v_[1]);
}
MATH_INLINE Vec2 Vec2::operator -(const Vec2& v) const
{
return Vec2(v_[0] - v.v_[0], v_[1] - v.v_[1]);
}
MATH_INLINE Vec2 Vec2::operator -() const
{
return Vec2(-v_[0], -v_[1]);
}
MATH_INLINE Vec2 Vec2::operator *(float c) const
{
return Vec2(v_[0] * c, v_[1] * c);
}
MATH_INLINE Vec2 Vec2::operator /(float c) const
{
assert(!isZero(c));
float ic = 1.0f / c;
return Vec2(v_[0] * ic, v_[1] * ic);
}
MATH_INLINE Vec2 operator *(float c, const Vec2& v)
{
return Vec2(c * v.v_[0], c * v.v_[1]);
}
MATH_INLINE bool Vec2::operator ==(const Vec2& v) const
{
return (fuzzyEQ(v_[0], v.v_[0]) && fuzzyEQ(v_[1], v.v_[1]));
}
MATH_INLINE bool Vec2::operator !=(const Vec2& v) const
{
return !(fuzzyEQ(v_[0], v.v_[0]) && fuzzyEQ(v_[1], v.v_[1]));
}
// OPERATIONS
MATH_INLINE Vec2& Vec2::clampVec(float lo, float hi)
{
clamp(v_[0], lo, hi); clamp(v_[1], lo, hi);
return *this;
}
MATH_INLINE float Vec2::length() const
{
return sqrtf(square(v_[0]) + square(v_[1]));
}
MATH_INLINE float Vec2::lengthSquared() const
{
return square(v_[0]) + square(v_[1]);
}
MATH_INLINE float Vec2::lengthManhattan() const
{
return fabsf(v_[0]) + fabsf(v_[1]);
}
MATH_INLINE Vec2& Vec2::normalize()
{
float len = length();
assert(!isZero(len));
*this *= 1.0f / len;
return *this;
}
MATH_INLINE Vec2& Vec2::normalizeSafely()
{
float len = length();
if (!isZero(len)) {
*this *= 1.0f / len;
}
return *this;
}
MATH_INLINE void Vec2::copyFrom(float f[2])
{
v_[0] = f[0]; v_[1] = f[1];
}
MATH_INLINE void Vec2::copyTo(float f[2]) const
{
f[0] = v_[0]; f[1] = v_[1];
}
MATH_INLINE int Vec2::minComponent() const
{
return (v_[0] < v_[1]) ? 0 : 1;
}
MATH_INLINE int Vec2::maxComponent() const
{
return (v_[0] > v_[1]) ? 0 : 1;
}
MATH_INLINE float distance(const Vec2& v1, const Vec2& v2)
{
return sqrtf(square(v1.v_[0] - v2.v_[0]) + square(v1.v_[1] - v2.v_[1]));
}
MATH_INLINE float distanceSquared(const Vec2& v1, const Vec2& v2)
{
return square(v1.v_[0] - v2.v_[0]) + square(v1.v_[1] - v2.v_[1]);
}
MATH_INLINE float dot(const Vec2& v1, const Vec2& v2)
{
return v1.v_[0] * v2.v_[0] + v1.v_[1] * v2.v_[1];
}
MATH_INLINE Vec2 lerp(float f, const Vec2& v1, const Vec2& v2)
{
return v1 + f * (v2 - v1);
}
MATH_INLINE float angle(Vec2 &u, Vec2 &v)
{
float divider = u.length() * v.length();
assert(!isZero(divider));
float dotUV = dot(u, v) / divider;
// rounding can give incorrect result, thus we need to clamp
clamp(dotUV, -1, 1);
return acosf(dotUV);
}
MATH_INLINE float angleUnitCircle(Vec2 &v)
{
Vec2 tmp = v;
tmp.normalize();
if ( tmp[1] > 0 )
return acosf(tmp[0]);
else
return -acosf(tmp[0]);
}
MATH_INLINE Vec2 proj_u_on_v(Vec2 &u, Vec2 &v)
{
return dot(u,v) / v.lengthSquared() * v;
}
MATH_INLINE Vec2 Vec2::perpDot() const
{
return Vec2(-v_[1], v_[0]);
}
MATH_INLINE void Vec2::print() const
{
printf("<%f %f>\n", v_[0], v_[1] );
}
| [
"gweronimo@afd64b18-8dda-0310-837d-b02fe5df315d"
]
| [
[
[
1,
319
]
]
]
|
0cc4a8722a335177a051374faa220674fc851a52 | 222bc22cb0330b694d2c3b0f4b866d726fd29c72 | /src/brookbox/wm2/WmlBezierCylinder2.h | f7df1a449befb4019ff0332e62a17c407f33d279 | [
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | darwin/inferno | 02acd3d05ca4c092aa4006b028a843ac04b551b1 | e87017763abae0cfe09d47987f5f6ac37c4f073d | refs/heads/master | 2021-03-12T22:15:47.889580 | 2009-04-17T13:29:39 | 2009-04-17T13:29:39 | 178,477 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,258 | h | // Magic Software, Inc.
// http://www.magic-software.com
// http://www.wild-magic.com
// Copyright (c) 2003. All Rights Reserved
//
// The Wild Magic Library (WML) source code is supplied under the terms of
// the license agreement http://www.magic-software.com/License/WildMagic.pdf
// and may not be copied or disclosed except in accordance with the terms of
// that agreement.
#ifndef WMLBEZIERCYLINDER2_H
#define WMLBEZIERCYLINDER2_H
#include "WmlBezierCylinder.h"
#include "WmlColorRGB.h"
#include "WmlVector2.h"
#include "WmlVector3.h"
namespace Wml
{
class WML_ITEM BezierCylinder2 : public BezierCylinder
{
WmlDeclareRTTI;
WmlDeclareStream;
public:
// Construction. BezierCylinder2 accepts responsibility for deleting
// the input array.
BezierCylinder2 (int* aiIndex);
// tessellation
virtual void Tessellate (int iLevel, const Vector3f* akCtrlPoint,
const ColorRGB* akCtrlColor, const Vector2f* akCtrlTexture,
TriMesh* pkMesh, int& riVertexStart, int& riTriangleStart);
protected:
BezierCylinder2 ();
// precomputation
class WML_ITEM IntervalParameters
{
public:
// s = curve direction, t = cylinder direction
int m_i00, m_i01, m_i10, m_i11;
Vector3f m_aakXss[2];
ColorRGB m_aakCss[2];
Vector2f m_aakTss[2];
};
void InitializePoints (const Vector3f* akCtrlPoint,
IntervalParameters& rkIP);
void InitializeColors (const ColorRGB* akCtrlColor,
IntervalParameters& rkIP);
void InitializeTextures (const Vector2f* akCtrlTexture,
IntervalParameters& rkIP);
// tessellate cylinder curves by recursive subdivision
void SubdivideCylinder (int iCLevel, Vector3f* akX, Vector3f* akXs,
Vector3f* akXt, ColorRGB* akColor, Vector2f* akTexture, int i0,
int i1, int iTwoPowL);
// tessellate boundary curves by recursive subdivision
void SubdivideBoundary (int iLevel, float fDSqr, Vector3f* akX,
Vector3f* akXs, Vector3f* akXt, ColorRGB* akColor,
Vector2f* akTexture, IntervalParameters& rkIP);
};
WmlSmartPointer(BezierCylinder2);
WmlRegisterStream(BezierCylinder2);
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
76
]
]
]
|
61f3b35c384b21094e8c63219da33a292a517c79 | ea4bdaf1f19d3a0890dd3ed7ef3219f58d1cd7b6 | /generateDot2ch.cpp | 1b648ebd4a43d8abafcd3739565cdb81990f2b65 | []
| no_license | hemogawa/IllustLogickGenerator | faffcb51f12105cbbc3a1e1b14a84ce5a99ef493 | b43fced6de292778bb2488b1c740252b744687ea | refs/heads/master | 2021-01-10T22:10:08.436332 | 2011-05-24T11:40:19 | 2011-05-24T11:40:19 | 1,793,060 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,461 | cpp | /**********************************************
ๅ้ธๅ
็ซฏ็งๅญฆๆ่กๅคงๅญฆ้ขๅคงๅญฆใ็ฅ่ญ็งๅญฆ็ ็ฉถ็ง
ๅๅฃซๅๆ่ชฒ็จใ1ๅนดใ่ๅท็็ๅญ
ใคใฉในใใใใใใ็ตตใ็ๆใใใใญใฐใฉใ ใงใ๏ผ
**********************************************/
#include<iostream>
#include<cv.h>
#include<stdio.h>
#include<cxcore.h>
#include<highgui.h>
#include<math.h>
#include<string.h>
#include<sstream>
using namespace std;
/*่ฒใๅๅพใใ้ขๆฐ*/
uchar GetColor(IplImage *srcImage, int x, int y){
return ((uchar*)(srcImage->imageData + srcImage->widthStep * y))[x];
}
/* ๅบๅ็ปๅใซ่ฒใใปใใใใ้ขๆฐ */
void setColor(IplImage *image, int x, int y, int num, int color){
for (int i=0; i<num; i++) {
for (int j=0; j<num; j++) {
if (x+j >= image->width || y+i >= image->height) {
break;
}
cvSetReal2D(image,y+i,x+j,color);
}
}
}
int main(int argc){
cout << "Content-type: text/html\n\n";
/*็ปๅ่ชญใฟ่พผใฟ*/
IplImage *srcImage = 0; //ๅ
ฅๅ็ปๅ
IplImage *rsImage = 0; //ใชใตใคใบๅพ็ปๅ
IplImage *dstImage = 0; //ๅบๅ็ปๅ
uchar c=0;
srcImage = cvLoadImage("images/getImage.png",CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_GRAYSCALE);
if(srcImage == 0)
return -1;
/*ๅ็ฎใงใใพใใๅบใใจใใใใใใใฎใงใชใตใคใบ๏ผ็ปๅใตใคใบใซใใฃใฆใชใตใคใบๅพใฎใตใคใบใๅคๆดใใใใๆนๅใใพใ*/
rsImage = cvCreateImage(cvSize(120,(srcImage->height*120)/srcImage->width),IPL_DEPTH_8U,1);
cvResize(srcImage,rsImage,CV_INTER_CUBIC);
dstImage = cvCreateImage(cvGetSize(rsImage),IPL_DEPTH_8U,1);
int size = 30; //ๅ็ฎๆฐ
int sizeNum = rsImage->height/size; //1ใในใใใใฎใใฏใปใซๆฐ
int x=0,y=0; //ๅบงๆจ
int xycolor[120][120]={0};
int color[2]={0}; //ๅๅบงๆจใฎ{0%,50%,100%}ๆฐ
while (y<rsImage->height) {
x=0; //ๆฌกใฎyๅบงๆจใซใใใใณใซๅ
้ ญใฎxๅบงๆจใซๆปใ
while (x <rsImage->width){
/*ๅ็ฎๅ
ใฎ่ฒใๅๅพ*/
c = GetColor(rsImage, x, y);
/*ๅคใซใใฃใฆ็ฝ้ปใซๆฏใๅใ*/
if (c<128){
color[0]++;
xycolor[x][y] = 0;
}
else{
color[1]++;
xycolor[x][y] = 255;
}
x++;
}
y++;
}
x=0;y=0;
int minor = 100,mager=100;
if(color[0] >color[1]*4){
minor = 255,mager = 0;
}else if (color[1] > color[0]*4) {
minor = 0,mager = 255;
}
if (minor != 100) {
while (y<rsImage->height) {
x=0; //ๆฌกใฎyๅบงๆจใซใใใใณใซๅ
้ ญใฎxๅบงๆจใซๆปใ
while (x <rsImage->width){
c = mager;
for (int i=0; i<sizeNum; i++) {
for (int j=0; j<sizeNum; j++) {
if (xycolor[x+j][y+i] == minor) {
c = minor;
break;
}
}
}
//ใปใใใใๅคใใใน็ฎๅ
ใฎๅบงๆจใซ้ฉ็จ
setColor(dstImage,x,y,sizeNum,c);
//ใใน็ฎใฎๅบงๆจๅ็งปๅ
x+=sizeNum;
}
y+=sizeNum;
}
}
if(minor ==100){
while (y<rsImage->height) {
x=0; //ๆฌกใฎyๅบงๆจใซใใใใณใซๅ
้ ญใฎxๅบงๆจใซๆปใ
while (x <rsImage->width){
int cnt[2] = {0};
for (int i=0; i<sizeNum; i++) {
for (int j=0; j<sizeNum; j++) {
if (xycolor[x+j][y+i] == 0) {
cnt[0]++;
}
else if (xycolor[x+j][y+i] == 255) {
cnt[1]++;
}
}
}
if (cnt[0] > cnt[1]) {
c=0;
}else {
c=255;
}
//ใปใใใใๅคใใใน็ฎๅ
ใฎๅบงๆจใซ้ฉ็จ
setColor(dstImage,x,y,sizeNum,c);
//ใใน็ฎใฎๅบงๆจๅ็งปๅ
x+=sizeNum;
}
y+=sizeNum;
}
}
cvSaveImage("images/dstImage2ch.png",dstImage);
printf("<div><img src=\"images/dstImage2ch.png\"></div>");
printf("<div>ใใฎ็ตตใใใคใฉในใใญใธใใฏใไฝๆใใพใใ๏ผไฟฎๆญฃใใๅ ดๅใฏ็ปๅใใใฆใณใญใผใใ๏ผไฟฎๆญฃใใใใกใคใซใใขใใใญใผใใใฆใใ ใใ๏ผ</div>");
printf("่ๆฏ่ฒ๏ผ<form action='./generateIL2ch.cgi' medthod='get'><select name='color' size='2'><option value='white' selected>็ฝ</option><option value='black'>้ป</option></select>");
printf("<input type='submit' value='ไฝๆใใ'></form>ใ<a href=\"./revise.php\">ไฝๆใใชใ</a><br>");
printf("ไฟฎๆญฃ็ปๅใขใใใญใผใ:");
printf("<form method=\"post\" action=\"./revisedUp.php\" enctype=\"multipart/form-data\"><input type=\"file\" name=\"revised\"><input type=\"submit\" value=\"ใขใใใญใผใ\"></form>");
return 0;
}
| [
"[email protected]"
]
| [
[
[
1,
142
]
]
]
|
b939d58e9f99494d3175eb4cbe15d8f26d457428 | 1e001ac9ca3a928a844b095e832779505c73ede7 | /trunk/PureCpp/BulletDebugDrawer.h | 786a36f7481e60cc87813314c6f307240a927708 | [
"MIT"
]
| permissive | svn2github/bullet-physics-editor | 4407762824e7c08569c14c4e469798090fe1e226 | c7a56264f5d0d967bad19454f33b4b0974f68cde | refs/heads/master | 2020-06-01T11:35:31.169730 | 2011-10-21T01:24:37 | 2011-10-21T01:24:37 | 30,486,131 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,603 | h | /*
* BulletDebugDrawer.h
* OpenGLEditor
*
* Created by Filip Kunc on 3/3/10.
* For license see LICENSE.TXT
*
*/
#pragma once
#ifdef WIN32
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#else
#include <OpenGL/gl.h>
#endif
#include <vector>
#include <string>
using namespace std;
#include "Enums.h"
#include "btBulletFile.h"
#include "Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.h"
#include "BulletDynamics/Dynamics/btDynamicsWorld.h"
#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
#include "BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h"
#include "BulletCollision/BroadphaseCollision/btDbvtBroadphase.h"
#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
#include "LinearMath/btIDebugDraw.h"
#include "LinearMath/btDefaultMotionState.h"
#include "GL_ShapeDrawerClone.h"
#include "LinearMath/btSerializer.h"
using namespace bParse;
class BulletDebugDrawer : public btIDebugDraw
{
private:
DebugDrawModes debugDrawMode;
public:
BulletDebugDrawer();
virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color);
virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color);
virtual void reportErrorWarning(const char* warningString);
virtual void draw3dText(const btVector3& location,const char* textString);
virtual void setDebugMode(int debugMode);
virtual int getDebugMode() const;
};
| [
"kunc.filip@2cb85d38-18f5-11df-8672-ad638f41b1de"
]
| [
[
[
1,
57
]
]
]
|
0089984f159dc745ae31410e2f5c0685850909fb | 4758b780dad736c20ec46e3e901ecdf5a0921c04 | /vm/int/SourceCode/cO_win32_display.h | 5f739874d8012dc83dbcf266fee10f44505b6449 | []
| no_license | arbv/kronos | 8f165515e77851d98b0e60b04d4b64d5bc40f3ea | 4974f865161b78161011cb92223bef45930261d9 | refs/heads/master | 2023-08-19T18:56:36.980449 | 2008-08-23T19:44:08 | 2008-08-23T19:44:08 | 97,011,574 | 1 | 1 | null | 2017-07-12T13:31:54 | 2017-07-12T13:31:54 | null | UTF-8 | C++ | false | false | 847 | h | #pragma once
class cO_win32_display
{
public:
virtual void write(char *ptr, int bytes);
virtual void writeChar(char ch);
cO_win32_display();
virtual ~cO_win32_display();
private:
HANDLE stdOut;
bool bInEsc;
COORD cord;
short H;
short W;
char szEsc[256];
int nEscCount;
WORD fColor; // = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
WORD bColor; // = BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE;
WORD wForeground; // = fColor;
WORD wBackground; // = bColor;
int Number(char *p);
void EraseLine();
void Erase();
void EraseChars(int n);
void InsertChars(int n);
void DeleteChars(int n);
void InsertLines(int n);
void DeleteLines(int n);
void ScrollScreen(int dx, int dy, SMALL_RECT *p);
};
| [
"leo.kuznetsov@4e16752f-1752-0410-94d0-8bc3fbd73b2e"
]
| [
[
[
1,
37
]
]
]
|
3c0cf02dc01404745f9a455c5f0b15037002b17f | ea12fed4c32e9c7992956419eb3e2bace91f063a | /zombie/code/zombie/nnetworkenet/src/nnetworkmanager/nnetworkmanagermulti_actions.cc | 81d841059b1c4aa55e12f005790af246b933ce28 | []
| no_license | ugozapad/TheZombieEngine | 832492930df28c28cd349673f79f3609b1fe7190 | 8e8c3e6225c2ed93e07287356def9fbdeacf3d6a | refs/heads/master | 2020-04-30T11:35:36.258363 | 2011-02-24T14:18:43 | 2011-02-24T14:18:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,342 | cc | //------------------------------------------------------------------------------
// nnetworkmanagermulti_actions.cc
// (C) 2005 Conjurer Services, S.A.
//------------------------------------------------------------------------------
#include "precompiled/pchnnetworkenet.h"
#include "nnetworkmanager/nnetworkmanagermulti.h"
#include "nnetworkmanager/nclientproxy.h"
#include "nnetworkenet/nnetclientenet.h"
#include "nnetworkenet/nnetserverenet.h"
#include "ngpactionmanager/ngpactionmanager.h"
#include "entity/nentityobjectserver.h"
#include "kernel/nlogclass.h"
//------------------------------------------------------------------------------
/**
@param action basic action name
@param numarg number of input arguments of the basic action
@param arglist input arguments
@param foreground if the action is foreground action or background action
@param queue if action need to be enqueue
*/
void
nNetworkManagerMulti::SendBasicAction(
const char * action, int numarg, nArg * arglist, bool foreground, bool queue )
{
n_assert2( numarg <= nNetworkManagerMulti::MAX_NUM_PARAMS, "Too much params in a Basic Action" );
bool needToSend = false;
bool clientOnly = nGPActionManager::Instance()->CheckExecuteFlags( action , nGPActionManager::ISONLY_CLIENT );
bool serverOnly = nGPActionManager::Instance()->CheckExecuteFlags( action , nGPActionManager::ISONLY_SERVER );
bool inClients = nGPActionManager::Instance()->CheckExecuteFlags( action , nGPActionManager::IS_IN_CLIENTS );
bool isAhead = nGPActionManager::Instance()->CheckExecuteFlags( action , nGPActionManager::IS_AHEAD );
bool initOK = true;
// execute if neccesary
if( isAhead || ( ( this->refNetServer.isvalid() || clientOnly ) && ! inClients ) )
{
if( queue )
{
nGPActionManager::Instance()->QueueAction( action, numarg, arglist, foreground );
}
else
{
initOK = nGPActionManager::Instance()->SetAction( action, numarg, arglist, foreground );
}
}
// check if need to send basic action
if( this->refNetServer.isvalid() )
{
// check if only need to execute in server
needToSend = initOK && ! serverOnly;
// check if only need to execute in client
needToSend = needToSend && ! clientOnly;
}
else if( this->refNetClient.isvalid() )
{
needToSend = ! clientOnly;
}
// send if it is neccesary
if( needToSend )
{
// find args for "init" function of basic action
nCmd * cmd = this->GetBasicActionInit( action );
n_assert( cmd );
if( cmd )
{
NLOG( network, ( NLOGACTIONS | 2, "Server: Send basic action \"%s\"", action ) );
// set buffer to send
nNetUtils::MessageType sendType = nNetUtils::Ordered;
char * actionBuffer = this->actionOrderedBuffer;
int * actionIndex = &this->actionOrderedIndex;
if( nGPActionManager::Instance()->CheckExecuteFlags( action , nGPActionManager::IS_UNRELIABLE ) )
{
sendType = nNetUtils::Unreliable;
actionBuffer = this->actionUnreliableBuffer;
actionIndex = &this->actionUnreliableIndex;
}
// init pointers to buffers
char * base = actionBuffer + *actionIndex;
char * pointer = base;
// create flags
unsigned char flags = 0;
flags |= foreground ? BAF_FOREGROUND : 0;
flags |= queue ? BAF_QUEUE : 0;
// pack number of args in flag parameter
flags |= unsigned char( numarg & BAF_NUMARGS );
// get first parameter, the entity
cmd->Rewind();
nArg * arg = cmd->In();
nEntityObject* entity = (nEntityObject*) arglist[ 0 ].GetO();
// pack in a buffer the action
pointer += nNetUtils::PackUniqueTo( pointer, action );
pointer += nNetUtils::PackTo( pointer, entity->GetId() );
pointer += nNetUtils::PackTo( pointer, flags );
for( int i = 1; i < numarg ; ++i )
{
arg = cmd->In();
pointer += nNetUtils::PackTo( pointer, arglist[ i ], arg );
}
cmd->GetProto()->RelCmd( cmd );
cmd = 0;
// send with the adecuate network layer
unsigned int bufferSize = unsigned int( pointer - base );
*actionIndex += bufferSize;
if( *actionIndex > MTU_SIZE )
{
this->SendActionBuffer( actionBuffer, *actionIndex, sendType );
}
// save statistics
if( bufferSize > this->longestAction )
{
this->longestAction = bufferSize;
}
}
}
}
//------------------------------------------------------------------------------
/**
@remarks let the basic action arguments in the argsArray object variable
@param message buffer with the basic action
@param entity [OUT] entity that execute the basic action
@param action [OUT] basic action name
@param numargs [OUT] number of input arguments of the basic action
@param foreground [OUT] if the action is foreground action or background action
@returns size of the basic action in the buffer
*/
size_t
nNetworkManagerMulti::UnpackAction( const char * message, nEntityObject * &entity, const char * &action,
int & numargs, bool &foreground, bool &queue )
{
// init pointer to data
const char * pointer = message;
// get basic action name
pointer += nNetUtils::UnpackUniqueFrom( pointer, action );
// find args for "init" function of basic action
nCmd * cmd = this->GetBasicActionInit( action );
n_assert( cmd );
if( cmd )
{
// get entity
unsigned int id;
pointer += nNetUtils::UnpackFrom( pointer, id );
entity = nEntityObjectServer::Instance()->GetEntityObject( id );
if( ! entity )
{
NLOG( network, ( NLOGACTIONS | 1, "Client ERROR: No Entity %x for action \"\"", id, action ) );
}
// get first parameter, the entity
cmd->Rewind();
nArg * arg = cmd->In();
// get foreground param
char byte;
pointer += nNetUtils::UnpackFrom( pointer, byte );
foreground = (byte & BAF_FOREGROUND) != 0;
// get queue param
queue = (byte & BAF_QUEUE) != 0;
// get basic action params
numargs = ( byte & BAF_NUMARGS );
n_assert2( numargs <= nNetworkManagerMulti::MAX_NUM_PARAMS, "Too much params in a Basic Action" );
this->argsArray[ 0 ].Delete();
this->argsArray[ 0 ].SetO( entity );
for( int i = 1 ; i < numargs ; ++i )
{
this->argsArray[ i ].Delete();
arg = cmd->In();
pointer += nNetUtils::UnpackFrom( pointer, this->argsArray[ i ], arg );
}
cmd->GetProto()->RelCmd( cmd );
}
return (pointer - message);
}
//------------------------------------------------------------------------------
/**
@param action name of the basic action
@returns the command for the init
*/
nCmd*
nNetworkManagerMulti::GetBasicActionInit( const char * action )const
{
nClass * actionClass = nKernelServer::Instance()->FindClass( action );
n_assert( actionClass );
if( actionClass )
{
nCmdProto * initCmd = actionClass->FindCmdByName( "init" );
n_assert( initCmd );
if( initCmd )
{
return initCmd->NewCmd();
}
}
return 0;
}
//------------------------------------------------------------------------------
/**
@param message basic action payload
@param size basic action payload size
*/
void
nNetworkManagerMulti::ActionsFromServer( const char * message, const int size )
{
// basic action params
const char * action;
bool foreground;
bool queue;
int numargs = 0;
nEntityObject * entity;
const char * pointer = message;
while( ( pointer - message ) < size )
{
action = 0;
entity = 0;
pointer += this->UnpackAction( pointer, entity, action, numargs, foreground, queue );
if( entity && action )
{
NLOG( network, ( NLOGACTIONS | 2, "Client: Basic Action \"%s\" from server", action ) );
// execute the action
if( queue )
{
nGPActionManager::Instance()->QueueAction( action, numargs, this->argsArray, foreground );
}
else
{
nGPActionManager::Instance()->SetAction( action, numargs, this->argsArray, foreground );
}
}
else
{
NLOG( network, ( NLOGACTIONS | 1, "Client ERROR: Bad actions block" ) );
break;
}
}
}
//------------------------------------------------------------------------------
/**
@param messagebasic action payload
@param size basic action payload size
@param client that send the basic action
*/
void
nNetworkManagerMulti::ActionsFromClient( const char * message, const int size )
{
// basic action params
const char * action;
bool foreground;
bool queue;
int numargs = 0;
nEntityObject * entity;
const char * last = 0;
const char * pointer = message;
while( ( pointer - message ) < size )
{
action = 0;
entity = 0;
last = pointer;
pointer += this->UnpackAction( pointer, entity, action, numargs, foreground, queue );
if( entity && action )
{
NLOG( network, ( NLOGACTIONS | 2, "Server: Basic action %x:\"%s\" ",
entity->GetId(), action ) );
bool canSendAction = true;
// execute the action if needed
if( ! nGPActionManager::Instance()->CheckExecuteFlags( action , nGPActionManager::IS_IN_CLIENTS ) )
{
if( queue )
{
nGPActionManager::Instance()->QueueAction( action, numargs, this->argsArray, foreground );
}
else
{
canSendAction = nGPActionManager::Instance()->SetAction( action, numargs, this->argsArray, foreground );
}
}
// check that only execute on server
canSendAction = canSendAction &&
! nGPActionManager::Instance()->CheckExecuteFlags( action , nGPActionManager::ISONLY_SERVER );
if( canSendAction )
{
NLOG( network, ( NLOGACTIONS | 2, "Send basic action \"%s\"", action ) );
// set buffer to send
nNetUtils::MessageType sendType = nNetUtils::Ordered;
char * actionBuffer = this->actionOrderedBuffer;
int * actionIndex = &this->actionOrderedIndex;
if( nGPActionManager::Instance()->CheckExecuteFlags( action , nGPActionManager::IS_UNRELIABLE ) )
{
sendType = nNetUtils::Unreliable;
actionBuffer = this->actionUnreliableBuffer;
actionIndex = &this->actionUnreliableIndex;
}
// put in the buffer for send
unsigned int bufferSize = unsigned int( pointer - last );
memcpy( actionBuffer + *actionIndex, last, bufferSize );
*actionIndex += bufferSize;
if( *actionIndex > MTU_SIZE )
{
this->SendActionBuffer( actionBuffer, *actionIndex, sendType );
}
// save statistics
if( bufferSize > this->longestAction )
{
this->longestAction = bufferSize;
}
}
}
else
{
NLOG( network, ( NLOGACTIONS | 1, "Server ERROR: Bad actions block" ) );
break;
}
}
}
//------------------------------------------------------------------------------
/**
*/
void
nNetworkManagerMulti::SendActionBuffer( const char * buffer, int & size, const nNetUtils::MessageType type )
{
NLOG( network, ( NLOGACTIONS | 2, "Send action buffer ( %d ) of %d bytes", int( type ), size ) );
if( this->refNetServer.isvalid() )
{
this->refNetServer->SendMessageAll( buffer, size, type );
}
else if( this->refNetClient.isvalid() )
{
this->refNetClient->SendMessage( buffer, size, type );
}
// save statistics
this->actionsSended.lastBytes += size;
++this->actionsSended.lastNum;
// restore buffer initial state
size = int( nNetUtils::PackTo( buffer, char( nNetworkManager::MESSAGE_ACTION ) ) );
}
//------------------------------------------------------------------------------
| [
"magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91"
]
| [
[
[
1,
389
]
]
]
|
496ffd3149783f8ef7d57aa5ef8568365c55da47 | b7c505dcef43c0675fd89d428e45f3c2850b124f | /Src/SimulatorQt/Util/qt/Win32/include/QtGui/qfileiconprovider.h | 73806676f13db7d5def2ab97a512b5d296c4caa2 | [
"BSD-2-Clause"
]
| permissive | pranet/bhuman2009fork | 14e473bd6e5d30af9f1745311d689723bfc5cfdb | 82c1bd4485ae24043aa720a3aa7cb3e605b1a329 | refs/heads/master | 2021-01-15T17:55:37.058289 | 2010-02-28T13:52:56 | 2010-02-28T13:52:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,830 | h | /****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information ([email protected])
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at [email protected].
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QFILEICONPROVIDER_H
#define QFILEICONPROVIDER_H
#include <QtGui/qicon.h>
#include <QtCore/qfileinfo.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
#ifndef QT_NO_FILEICONPROVIDER
class QFileIconProviderPrivate;
class Q_GUI_EXPORT QFileIconProvider
{
public:
QFileIconProvider();
virtual ~QFileIconProvider();
enum IconType { Computer, Desktop, Trashcan, Network, Drive, Folder, File };
virtual QIcon icon(IconType type) const;
virtual QIcon icon(const QFileInfo &info) const;
virtual QString type(const QFileInfo &info) const;
private:
Q_DECLARE_PRIVATE(QFileIconProvider)
QFileIconProviderPrivate *d_ptr;
Q_DISABLE_COPY(QFileIconProvider)
};
#endif // QT_NO_FILEICONPROVIDER
QT_END_NAMESPACE
QT_END_HEADER
#endif // QFILEICONPROVIDER_H
| [
"alon@rogue.(none)"
]
| [
[
[
1,
81
]
]
]
|
6f45a2f8b891248eb4875f2432dbf51d8923ab19 | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /Common/Scd/FlwLib/FLWSOLVE.H | 7c55ed81e780b6110619a8510ba9daf3bd0230e3 | []
| no_license | abcweizhuo/Test3 | 0f3379e528a543c0d43aad09489b2444a2e0f86d | 128a4edcf9a93d36a45e5585b70dee75e4502db4 | refs/heads/master | 2021-01-17T01:59:39.357645 | 2008-08-20T00:00:29 | 2008-08-20T00:00:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 32,147 | h | //================== SysCAD - Copyright Kenwalt (Pty) Ltd ===================
// $Nokeywords: $
//===========================================================================
// SysCAD Copyright Kenwalt (Pty) Ltd 1992
#ifndef __FLWSOLVE_H
#define __FLWSOLVE_H
#ifndef _AFXTEMPL_H__
#include <afxtempl.h> // "xafxtempl.h"
#endif
#ifndef __SC_DEFS_H
#include "sc_defs.h"
#endif
#ifndef __STDIO_H
#include <stdio.h>
#endif
#ifndef __FLWNETS_H
#include "FlwNets.h"
#endif
#ifndef __ODESOLVE_H
#include "odesolve.h"
#endif
#ifndef __EXECUTIV_H
#include "executiv.h"
#endif
#ifndef __SFE_BASE_H
#include "sfe_base.h"
#endif
#ifndef __SIGFLW_H
#include <sigflw.h>
#endif
#ifndef __EQNSOLVE_H
#include "eqnsolve.h"
#endif
#ifndef __TKNPARSE_H
#include "tknparse.h"
#endif
#ifndef __FLWSLVOB_H
#include "flwslvob.h"
#endif
#ifndef __ODESOLVE_H
#include "odesolve.h"
#endif
#ifdef __FLWSOLVE_CPP
#define DllImportExport DllExport
#elif !defined(FLWLIB)
#define DllImportExport DllImport
#else
#define DllImportExport
#endif
// ==========================================================================
// Command Identifiers
#define MAXTRACES 512
// ==========================================================================
//
//
//
// ==========================================================================
DEFINE_TAGOBJ(CFlwSolver)
DEFINE_TAGOBJ(FlwSlvPB)
DEFINE_TAGOBJ(FlwSlvDyn)
// ==========================================================================
//
//
//
// ==========================================================================
typedef CLockedListIter<CFlwNodeList, FlwNode*&> CLkFlwNodeIter;
typedef CLockedListIter<CNodeEvalIndexList, CNodeEvalIndex&> CLkNodeEvalIter;
class CFlwNodeListArray : public CArray <CFlwNodeList, CFlwNodeList&> { };
class CFlwNodeListODE
{
public:
CFlwNodeListODE(CFlwNodeList & List, CODEDataBlock & ODB) :
m_List(List),
m_ODB (ODB)
{
};
CFlwNodeList & m_List;
CODEDataBlock & m_ODB;
};
const byte FTS_DynMode = 0x01;
const byte FTS_ThrdSeq = 0x02;
const byte FTS_Order = 0x04;
const byte TOSL_Proc = 0x01;
const byte TOSL_Ctrl = 0x02;
const byte TOSL_Comb = 0x04;
const byte TOSL_All = 0x07;
class CSFGIOStack : public CArray<CSFGNodeInfo*, CSFGNodeInfo*> {};
_FWDDEF(FlwSlvBlk)
class FlwSlvBlk
{
public:
virtual void BuildDataDefn(DataDefnBlk & DDB);
virtual flag DataXchg(DataChangeBlk & DCB);
flag CreateSolutionBlks(int NRqdThreads);
int ClearSolutionBlks(flag ClearAll);
virtual flag PreStartCheckAll();
virtual flag InitialiseSolutionAll();
virtual flag TerminateSolutionAll();
virtual void StartSolutionAll();
virtual void ConfigureJoinsAll();
flag BuildMacroMdls();
void DeleteMacroMdls();
flag BuildSignalFlowGraph(flag DoingDynMode, byte Which);
void SetUpTearLinks(CSFGNodeInfoList & TearNodeList);
void SetUpTearCLinks(CSFGNodeInfoList & TearNodeList);
void AddToEvalOrder(pFlwNode p, pFlwNode pSrc, sint ReqdDirn, int NdStackIndex);
virtual bool BuildCtrlNdListReqd();
virtual void BuildCtrlNdList();
flag FindTOSequenceStart(byte Which);
void BuildTOSequence(byte Which);
void SummariseTOSequence(byte Which);
flag SolveTOSequenceThrd(int What, byte Which, LPVOID OtherData=NULL);
void FindTOSequence(byte Flags, byte Which);
void DumpEvalOrder(byte Which);
void InitTearConvergence(EqnSlvCtrlBlk & EqnCB);
flag TestTearConvergence(long ConvergeLoopCnt, EqnSlvCtrlBlk & EqnCB, Strng_List &BadTearTags, Strng_List & BadTearInfo);
void TransferAllTears(EqnSlvCtrlBlk & EqnCB);
void InitialiseAllTears(EqnSlvCtrlBlk & EqnCB);
void RestartAllTears(EqnSlvCtrlBlk & EqnCB);
double TestBalance(const EqnSlvCtrlBlk & TCtrl, CNodeEvalIndexList &Nds, Strng_List * pTBReport=NULL);
void ShowFlows(CNodeEvalIndexList &Nds, LPCTSTR Where);
void FITConfigureJoins(CFlwNodeList & List);//CLkFlwNodeIter & Iter);
void EvalAllElectrics(bool ConvergeIt);
void EvalAllPowerRequired();
void InitClosure();
void TestClosure(CNodeEvalIndexList &TOSequence);
void MarkClosureDataAvail(CNodeEvalIndexList &List);
void MarkClosureDataInvalid(CFlwNodeList &List);
void FixAllNdsLists();
public:
CFlwSolver &FlwSlvNd;
flag m_SolutionBlksOk;
CFlwNodeList m_AllNds;
CFlwNodeList m_ExcNds;
CFlwNodeList m_ProcessNds;
CFlwNodeList m_PwrCtrlNds;
CFlwNodeList m_StandAloneNds;
CFlwNodeListArray m_ProcessNdsLA;
CFlwNodeListArray m_AllNdsLA;
flag m_fProcTOSeqValid;
flag m_fCtrlTOSeqValid;
CNodeEvalIndexList * m_pProcTOSequence;
CNodeEvalIndexList * m_pProcTOSequencePrv;
CNodeEvalIndexList * m_pCtrlTOSequence;
CNodeEvalIndexList * m_pCtrlTOSequencePrv;
CNodeEvalIndexList * m_pCombTOSequence;
CNodeEvalIndexList * m_pCombTOSequencePrv;
CFlangeList m_Flanges, m_TearFlanges;
CTerminalList m_Terminals, m_TearTerminals;
CXRefPtrList m_TearXRefs;
void ClearTOSequence(byte Which, bool DoPrevious=false);
void SwapAndClearTOSequence(byte Which);
CNodeEvalIndexList & getProcTOSequence() { return *m_pProcTOSequence; };
CNodeEvalIndexList & getProcTOSequencePrv() { return *m_pProcTOSequencePrv; };
CNodeEvalIndexList & getProcTOSequenceDsp() { return *(m_pProcTOSequence->GetCount()>0 ? m_pProcTOSequence:m_pProcTOSequencePrv); };
CNodeEvalIndexList & getCtrlTOSequence() { return *m_pCtrlTOSequence; };
CNodeEvalIndexList & getCtrlTOSequencePrv() { return *m_pCtrlTOSequencePrv; };
CNodeEvalIndexList & getCtrlTOSequenceDsp() { return *(m_pCtrlTOSequence->GetCount()>0 ? m_pCtrlTOSequence:m_pCtrlTOSequencePrv); };
CNodeEvalIndexList & getCombTOSequence() { return *m_pCombTOSequence; };
CNodeEvalIndexList & getCombTOSequencePrv() { return *m_pCombTOSequencePrv; };
CNodeEvalIndexList & getCombTOSequenceDsp() { return *(m_pCombTOSequence->GetCount()>0 ? m_pCombTOSequence:m_pCombTOSequencePrv); };
_declspec(property(get=getProcTOSequence)) CNodeEvalIndexList & ProcTOSequence;
_declspec(property(get=getProcTOSequencePrv)) CNodeEvalIndexList & ProcTOSequencePrv;
_declspec(property(get=getProcTOSequenceDsp)) CNodeEvalIndexList & ProcTOSequenceDsp;
_declspec(property(get=getCtrlTOSequence)) CNodeEvalIndexList & CtrlTOSequence;
_declspec(property(get=getCtrlTOSequencePrv)) CNodeEvalIndexList & CtrlTOSequencePrv;
_declspec(property(get=getCtrlTOSequenceDsp)) CNodeEvalIndexList & CtrlTOSequenceDsp;
_declspec(property(get=getCombTOSequence)) CNodeEvalIndexList & CombTOSequence;
_declspec(property(get=getCombTOSequencePrv)) CNodeEvalIndexList & CombTOSequencePrv;
_declspec(property(get=getCombTOSequenceDsp)) CNodeEvalIndexList & CombTOSequenceDsp;
MacroMdlList MacroMdls;
CSignalFlowGraph m_ProcSigFlwGrf;
CSignalFlowGraph m_CtrlSigFlwGrf;
CNodeEvalIndexList m_TOList[4], m_TOListWork[4];
CNodeEvalIndexList & m_ProcTOList1, & m_ProcTOList2;
CNodeEvalIndexList & m_CtrlTOList1, & m_CtrlTOList2;
CNodeElectricsArray m_TSCA;
CLkNodeEvalIter m_TOListIter[4];
FlwSlvBlk(CFlwSolver * pFlwSlvNd);
virtual ~FlwSlvBlk();
Strng_List TBReport;
long m_ClosureIters;
CSFGIOStack m_SFGInsStack;
CSFGIOStack m_SFGOutsStack;
};
// ==========================================================================
//
//
//
// ==========================================================================
const int NDS_LapTime = 0;
const int NDS_LapTimeFrac = 1;
const int NDS_LapCount = 2;
const int NDS_TotalTime = 3;
const int NDS_TotalTimeFrac = 4;
const int NDS_TotalCounts = 5;
class FlwSlvPB : public FlwSlvBlk, public CTNode
{
public:
FlwSlvPB(pTagObjClass pClass_, pchar TagIn, pTaggedObject pAttach, TagObjAttachment eAttach);
FlwSlvPB(CFlwSolver * pFlwSlvNd);
virtual ~FlwSlvPB();
virtual void BuildDataDefn(DataDefnBlk & DDB);
virtual void BuildDataDefnOld(DataDefnBlk & DDB);
virtual flag DataXchg(DataChangeBlk & DCB);
virtual flag ValidateData(ValidateDataBlk & VDB);
virtual pchar TagOfParent() { return PlantModelTag; };
flag CreateSolutionBlks(int NRqdThreads);//flag fProBal_);
int ClearSolutionBlks(flag ClearAll);
void RemoveBadConnectNds();
void DoSolnInit(bool DoReInit);
int InitSolution(const EqnSlvCtrlBlk & EQCtrl, CFlwNodeList &AllNdsIn);
int StepSolution(const EqnSlvCtrlBlk & EQCtrl);
int TermSolution(const EqnSlvCtrlBlk & EQCtrl);
int GetSolutionError(const EqnSlvCtrlBlk & EQCtrl, Strng & RptLine);
//void TestClosure(CFlwNodeList &TOSequence);
void FITPBEvalMakeUpAvail(CLkNodeEvalIter & Iter);
void FITPBEvalMakeUpReqd(CLkNodeEvalIter & Iter);
void FITPBEvalPressures(CLkNodeEvalIter & Iter);
void FITPBEvalProducts(CLkNodeEvalIter & Iter);
void FITPBEvalDiscrete(CFlwNodeList & List);//CLkFlwNodeIter & Iter);
void FITPBEvalCtrlActions(CFlwNodeList & List);//CLkFlwNodeIter & Iter);
void FITPBEvalCtrlStrategy(CFlwNodeList & List);//CLkFlwNodeIter & Iter);
void EvalAllDiscrete();
void EvalAllBalance();
void EvalAllCtrlInitialise(eScdCtrlTasks Tasks);
void EvalAllCtrlStrategy(eScdCtrlTasks Tasks);
void EvalAllCtrlActions(eScdCtrlTasks Tasks);
void EvalAllCtrlTerminate(eScdCtrlTasks Tasks);
//bool EvalAllElectrics(long What);
// virtual void EvalAllPowerAvailable();
// virtual void EvalAllPowerRequired();
#if DOPBSMOOTHING
SparseSolver * pSSMS;
int m_nMtxOrder;
void SolvePBSmoothingInitial(const EqnSlvCtrlBlk & EQCtrl);
void SolvePBSmoothingEstimate(const EqnSlvCtrlBlk & EQCtrl);
void SolvePBSmoothingEvaluate(const EqnSlvCtrlBlk & EQCtrl);
#endif
void DumpNdStats(int What, double TotTime);
flag fLogClearWasOn;
CTimeStateBlock IntCB;
CFlwNodeList LnkNds;
};
// ==========================================================================
//
//
//
// ==========================================================================
// Control Evaluation
const byte ECA_Start=0;
const byte ECA_End=1;
_FWDDEF(FlwSlvBlk)
class FlwSlvDyn : public FlwSlvBlk , public ODESolverBase, public CTNode
{
public:
FlwSlvDyn(pTagObjClass pClass_, pchar TagIn, pTaggedObject pAttach, TagObjAttachment eAttach);
FlwSlvDyn(CFlwSolver * pFlwSlvNd);
virtual ~FlwSlvDyn();
void Construct();
virtual void BuildDataDefn(DataDefnBlk & DDB);
virtual void BuildDataDefnOld(DataDefnBlk & DDB);
virtual flag DataXchg(DataChangeBlk & DCB);
virtual flag ValidateData(ValidateDataBlk & VDB);
virtual pchar TagOfParent() { return PlantModelTag; };
flag CreateSolutionBlks(int NRqdThreads);//flag fProBal_);
int Dynamic_Setup(double Time_Stop_, double Time_Target_, double Time_Step_, flag ToSteadyState_, flag SolveOn);
int ClearSolutionBlks(flag ClearAll);
virtual double StartTime(void) {return ODE().GetTimeStepStart();};
virtual double Time(void) {return IntCB.GetTime();};
virtual double dTime(void) {return IntCB.GetTimeInc();};
virtual void EvalAllStates();
// ODEBase Overides
virtual void ODEStartStep();
virtual void ODEOperate(CODEDataBlock & ODB);
virtual void ODEDerivs();
virtual void EvalAllDiscrete();
virtual void EvalAllBalance();
virtual void EvalAllCtrlInitialise(eScdCtrlTasks Tasks);
virtual void EvalAllCtrlActions(eScdCtrlTasks Tasks);
virtual void EvalAllCtrlStrategy(eScdCtrlTasks Tasks);
void EvalAllCtrlTerminate(eScdCtrlTasks Tasks);
virtual void EvalAllStatistics(eScdCtrlTasks Tasks);
//bool EvalAllElectrics(long What);
//virtual void EvalAllPowerAvailable();
//virtual void EvalAllPowerRequired();
flag QueryTime(CXM_TimeControl &CB, CTimeValue &TimeRqd, CTimeValue &dTimeRqd);
flag Start(CXM_TimeControl &CB, CFlwNodeList &AllNdsIn);
flag ReStart();
flag Execute(CXM_TimeControl &CB, CEOExecReturn &EORet);
void CheckStopConditions(CXM_TimeControl &CB);
flag CheckStopRequired(CXM_TimeControl &CB, bool Starting, bool ShowMsgs);
flag Stop(CXM_TimeControl &CB);
void DumpRunStats(flag Total);
void DumpNdStats(int What);
// void FITConfigureJoins(CLkFlwNodeIter & Iter);
void FITPowers(CLkFlwNodeIter & Iter);
void FITStates(CFlwNodeList & List);
void FITStartStep(CFlwNodeList & List);
void FITFlowInfo(CFlwNodeList & List);
void FITEvalProductsSurge(CLkNodeEvalIter & Iter);
void FITEvalProducts(CLkNodeEvalIter & Iter);
void FITEvalDerivs(CLkNodeEvalIter & Iter);
void FITEvalIntegral(CLkNodeEvalIter & Iter);
void FITODEOperate(CFlwNodeList & List, CODEDataBlock & ODE);
void FITDiscrete(CFlwNodeList & List);
void FITEvalCtrlActions(CFlwNodeList & List);
void FITEvalCtrlStrategy(CLkFlwNodeIter & Iter);//CFlwNodeList & List);
void FITEvalStatistics(CFlwNodeList & List);
void FITEvalAudit(CLkNodeEvalIter & Iter);
CFullNetBlk FlwNets;
word NNetNds;
word NNets;
//double StopTime;
//bool m_StopRequired;
eScdSSTests m_SSTest;
long m_SSStopCount;
long m_SSMaxIters;
long m_SSIters;
long m_SSSteady;
double m_SSMaxChange;
Strng m_SSMaxTag;
CToleranceBlock m_SSPressTol;
CToleranceBlock m_SSQmTol;
CTimeStateBlock IntCB;
CODESolver m_ODE;
byte m_EvalCtrlAt;
dword dwIterNo;
Strng m_sDispHistTagListPath;
};
// ==========================================================================
//
//
//
// ==========================================================================
struct FSubsDataItem
{
XIOAction Action;
pTagAccessBlk pTAB;
pFlwNode pNd;
long lMdlIndex;
};// FSubsDataItem;
//============================================================================
DEFINE_TAGOBJ(CADObject);
class DllImportExport CADObject : public TaggedObject
{
DEFINE_MEMSTATS(CADObject)
public:
CSArray m_SelectedTags;
CFlwSolver *pFS, *pSrcFS;
public:
CADObject(pTagObjClass pClass_, pchar TagIn, pTaggedObject pAttach, TagObjAttachment eAttach);
virtual ~CADObject();
virtual void BuildDataDefn(DataDefnBlk & DDB) {};
virtual int SetSelectedTags(Strng_List &SelectedTags);
virtual int GetTagTree(CFlwTree & Tree);
virtual int GetStatus(Strng & Status);
virtual flag ValidModel() { return true; };
};
typedef CSCDList <pCADObject, pCADObject> CADObjectList;
typedef CSCDPtrListIter<CADObjectList, pCADObject> CADObjectIter;
typedef CSCDPtrListIterWithPos<CADObjectList, pCADObject> CADObjectIterPos;
//===========================================================================
#define ADObjectGrp "ADObject"
#define IMPLEMENT_ADOBJECT(ClassName, Name, Version, DrwGroup, TagInitialID, Cat, ShortDesc, Desc) \
IMPLEMENT_TAGOBJ(ClassName, ADObjectGrp, Name, Version, DrwGroup, TagInitialID, Cat, ShortDesc, Desc);
// ==========================================================================
class CADGroup
{
public:
TagObjClass *pClass;
Strng Class;
Strng Name;
CArray <CADObject*, CADObject*> Obj;
};
// ==========================================================================
//
//
//
// ==========================================================================
class DllImportExport CFlwSolver : public FlwNode, public CTagRefStatusFnHook, public CGlblXRefMngr
{
public:
CFlwSolver(pTagObjClass pClass_, pchar TagIn, pTaggedObject pAttach, TagObjAttachment eAttach);
virtual ~CFlwSolver();
static bool ParseSpecieDef1(int nToks, CSVColArray & C, CDBInitRec &CDBI, int CfgFilePrjFileVerNo, int InsertIndex=100000);
static bool ParseSpecieDef2(int nToks, CSVColArray & C, CDBInitRec &CDBI, int CfgFilePrjFileVerNo);
static bool LoadSpecieData(LPCTSTR CfgFile, LPCTSTR PrjSDBName, bool WithMsgs);
flag Init(flag *pStatusLoadReqd, flag * pAssocGrfsLoadReqd);
flag Term();
virtual TaggedObject * FindObjTag(pchar pSrchTag, flag SrchAll, int &ObjTagLen, int MinTagLen);
virtual FlwNode * FindNodeTag(pchar pTag);
virtual FlwNode * FindNodeGuid(pchar pGuid);
virtual void BuildDataDefn(DataDefnBlk & DDB);
virtual void BuildDataDefnOld(DataDefnBlk & DDB);
virtual flag DataXchg(DataChangeBlk & DCB);
virtual flag ValidateData(ValidateDataBlk & VDB);
virtual void SetState(eScdMdlStateActs RqdState);
virtual int FilesUsed(CFilesUsedArray & Files);
virtual void Set_All_Zs();
virtual void Set_All_Sizes();
CTimeStateBlock &IntCB() { return XDoingPB() ? PB.IntCB : Dyn.IntCB; };
void DoGlobalLinks();
void TryDoGlobalLinks() { DoGlobalLinks(); };
void UnDoGlobalLinks(bool FullDisconnect=true);
long MarkFlwNodesPressNetwork(FlwNode * pNd);
long MarkFlwNodesFlowNetwork(FlwNode * pNd);
int FE_DoInsert(char *ClassIn, char *SubClassIn, char *PrimaryCfgIn, char *NTag, char *SrcTag, char *DstTag, FlwNode **pNd=NULL, LPSTR pGuidStr=NULL);
int FE_DoInsertRoot(char * RootName);
int FE_DoDelete(char * Tag);
flag FE_GetNodeGuid(pchar Tag, Strng & Guid);
int FE_ChangeNodeGuid(pchar Tag, pchar Guid);
flag FE_FindNodeInfoFromGuid(pchar Guid, Strng &Tag, flag & IsLink);
int FE_DoConnect(char * SrcTag, char *DstTag);
int FE_DoDisConnect(char * SrcTag, char *DstTag);
int FE_SetCommon(char * Tag, char * EqpDesc, char * EqpMemo, char * EqpIdStr, char * EqpLocation, char * PlantArea, char * EqpGUID);
int FE_GetCommon(char * Tag, Strng & EqpDesc, Strng & EqpMemo, Strng & EqpIdStr, Strng & EqpLocation, Strng & PlantArea, Strng & EqpGUID);
// int FE_DoSolveNet();
int FE_TagOperation(FE_TagOps Act, Strng_List & TagList);
int FE_SetHoldGlobalLinks(bool On);
byte FE_FlwMomentumOn();
void FE_SetFlwMomentumOn(byte On);
byte FE_ODE_Method() { return ODE().Method(); };
byte FE_ODE_StepSizeControl() { return ODE().StepSizeControl(); };
void FE_ODE_SetMethod(byte Method_) { ODE().SetMethod(Method_); };
void FE_ODE_SetStepSizeControl(byte StepSizeControl_) { ODE().SetStepSizeControl(StepSizeControl_); };
double FE_ODE_GetMagEPSAbs() { return ODE().GetMagEPSAbs(); };
double FE_ODE_GetMagEPSRel() { return ODE().GetMagEPSRel(); };
void FE_ODE_SetMagEPSAbs(double Eps) { ODE().SetMagEPSAbs(Eps); };
void FE_ODE_SetMagEPSRel(double Eps) { ODE().SetMagEPSRel(Eps); };
double FE_ODE_GetTimeInc() { return ODE().GetTimeInc(); };
void FE_ODE_SetTimeInc(CTimeValue T) { ODE().SetTimeInc(T); };
double FE_ODE_GetTimeIncMxRqd() { return ODE().GetTimeIncMxRqd(); };
void FE_ODE_SetTimeIncMxRqd(CTimeValue T) { ODE().SetTimeIncMxRqd(T); };
double FE_ODE_GetTimeIncMnRqd() { return ODE().GetTimeIncMnRqd(); };
void FE_ODE_SetTimeIncMnRqd(CTimeValue T) { ODE().SetTimeIncMnRqd(T); };
double FE_Net_GetLnkEPSAbs() { return Dyn.FlwNets.m_LnkEPS.GetAbs();};
double FE_Net_GetLnkEPSRel() { return Dyn.FlwNets.m_LnkEPS.GetRel();};
void FE_Net_SetLnkEPSAbs(double Eps) { Dyn.FlwNets.m_LnkEPS.SetAbs(Eps);};
void FE_Net_SetLnkEPSRel(double Eps) { Dyn.FlwNets.m_LnkEPS.SetRel(Eps);};
double FE_Net_GetNetDeRate() { return Dyn.FlwNets.m_NetDeRating;};
void FE_Net_SetNetDeRate(double Mult) { Dyn.FlwNets.m_NetDeRating=Mult;};
LPCTSTR FE_Net_GetSpillArea() { return gs_DIOAreaTagDefault();};
void FE_Net_SetSpillArea(LPCTSTR Spill) { gs_DIOAreaTagDefault=Spill;};
void DoTraceChanges(dword Flags);
//flag RequestNodeDefinitions(LPSTR Group, CFlwNodeDefinitionList & Defns);
flag RequestModelIOInfoByIndex(pchar pTag, int iIndex, CRequestModelIOInfoRec & Info);
flag RequestModelIOInfoById(pchar pTag, int iId, CRequestModelIOInfoRec & Info);
flag RequestModelIOConn(pchar pTag, int iNo, RequestModelIOConnRec & Info);
flag DumpModelInfo(LPCSTR Path);
int RequestModelStatus(dword Options, CModelStatusArray &Status, flag & TagsChanged);
flag RequestModelAssocGrfs(CMdlAssocGrfArray & Grfs);
flag RequestModelAssocGrfsMasks(bool SetClass, bool SetNode,LPCSTR NdTag, CModelAssocGrfMasks & Msks);
int RequestTagRefInfo(LPCTSTR Tag, CXRefInfoArray &Refs);
flag RequestModelClassId(pchar pTag, Strng & ClassId);
flag RequestModelConnInfo(pchar pTag, RequestConnModelInfoRec & Info);
//int RequestXRefInfoChg();
flag FE_TestModelTagUnique(pchar pTag);
int FE_GetRctInfo(CRctBlkInformation & RctInfo);
int FE_SetRctInfo(LPCTSTR NodeTag);
int FE_GetNodeWiring(CNodeWiring &NodeWiring);
int FE_GetLinkWiring(CLinkWiring &LinkWiring);
int FE_SetLinkWiring(CLinkWiring &LinkWiring);
long FE_GetTopologyCount();
long FE_GetNodes(DWORD What, CFlwNodeArray & Nodes);
FlwNode *FE_FindNode(LPCTSTR Tag, LPCTSTR Guid);
//void FE_ElecComponentsChanged();
void FE_UnDoGlobalLinks();
long FE_SpModelFixupStrategy();
void FE_SetSpModelFixupStrategy(long Strategy);
void EO_SetModelState(eScdMdlStateActs RqdState, Strng_List &RqdTags);
flag EO_GetModelAction(LPCTSTR Tag, CMdlActionArray & Acts);
flag EO_SetModelAction(LPCTSTR Tag, CMdlAction & Act);
flag EO_GetModelGraphic(LPCTSTR Tag, CMdlGraphicArray & Grf);
flag EO_OperateModelGraphic(LPCTSTR Tag, CMdlGraphicWnd & Wnd, CMdlGraphic & Grf);
// Executiv Overrides
void EO_OnAppActivate(BOOL bActive);
flag EO_RequestTagInfo(RequestTagInfoRec& Rqst, ReplyTagInfoRec& Info);
int EO_QueryChangeTag(pchar pOldTag, pchar pNewTag);
int EO_ChangeTag(pchar pOldTag, pchar pNewTag);
int EO_ChangeTagDone(pchar pOldTag, pchar pNewTag);
int EO_QueryDeleteTags(Strng_List & Tags);
int EO_DeleteTags(Strng_List & Tags);
int EO_DeleteTagsDone(Strng_List & Tags);
int EO_CanClose(Strng_List & Problems);
int EO_SCInsertNodeG(CSvcExecCtrl & Ctrl, CSvcHeaderBlk & Header, CSvcNdGBlk & NdGBlk, CSvcTagBlk & TagBlk);
int EO_SCDeleteNodeG(CSvcExecCtrl & Ctrl, CSvcHeaderBlk & Header);
int EO_SCModifyNodeG(CSvcExecCtrl & Ctrl, CSvcHeaderBlk & Header, CSvcNdGBlk & NdGBlk, CSvcTagBlk & TagBlk);
int EO_SCInsertNodeM(CSvcExecCtrl & Ctrl, CSvcHeaderBlk & Header);
int EO_SCDeleteNodeM(CSvcExecCtrl & Ctrl, CSvcHeaderBlk & Header);
int EO_SCModifyNodeM(CSvcExecCtrl & Ctrl, CSvcHeaderBlk & Header);
int EO_SCInsertLinkG(CSvcExecCtrl & Ctrl, CSvcHeaderBlk & Header, CSvcLnkGBlk & LnkGBlk, CPointFList & ControlPoints, CSvcTagBlk & TagBlk);
int EO_SCDeleteLinkG(CSvcExecCtrl & Ctrl, CSvcHeaderBlk & Header);
int EO_SCModifyLinkG(CSvcExecCtrl & Ctrl, CSvcHeaderBlk & Header, CSvcGuidPair & Guids, CPointFList & ControlPoints, CSvcTagBlk & TagBlk);
int EO_SCInsertLinkM(CSvcExecCtrl & Ctrl, CSvcHeaderBlk & Header, CSvcLnkMBlk & LnkMBlk);
int EO_SCDeleteLinkM(CSvcExecCtrl & Ctrl, CSvcHeaderBlk & Header);
int EO_SCModifyLinkM(CSvcExecCtrl & Ctrl, CSvcHeaderBlk & Header, CSvcLnkMBlk & LnkMBlk);
int EO_GetSolutionError(EqnSlvCtrlBlk & EQCtrl, Strng & RptLine);
void EO_SetSolveMode();
flag EO_Starting(flag fBeginStarting);
flag EO_SetTime(CTimeValue TimeRqd, bool Rewind);
flag EO_QueryTime(CXM_TimeControl &CB, CTimeValue &TimeRqd, CTimeValue &dTimeRqd);
flag EO_GotoRunStart(CXM_TimeControl &CB);
flag EO_GotoRunEnd(CXM_TimeControl &CB, bool TimeChanged);
flag EO_PreStart(CXM_TimeControl &CB);
flag EO_Start(CXM_TimeControl &CB);
void EO_QuerySubsReqd(CXMsgLst &XM);
void EO_QuerySubsAvail(CXMsgLst &XM, CXMsgLst &XMRet);
flag EO_ReadSubsData(CXMsgLst &XM);
flag EO_WriteSubsData(CXMsgLst &XM, flag FirstBlock, flag LastBlock);
DWORD EO_ReadTaggedItem(CXM_ObjectTag & ObjTag, CXM_ObjectData &ObjData, CXM_Route &Route);
int EO_WriteTaggedItem(CXM_ObjectData &ObjData, CXM_Route &Route);
flag EO_Execute(CXM_TimeControl &CB, CEOExecReturn &EORet);
flag EO_StepDone(CXM_TimeControl &CB, flag StepExecuted);
flag EO_QueryStop(CXM_TimeControl &CB, bool Starting);
flag EO_Stop(CXM_TimeControl &CB);
flag EO_Stopping(flag BeginStopping);
flag EO_BeginPause(CXM_TimeControl &CB);
flag EO_EndPause(CXM_TimeControl &CB);
flag EO_BeginSave(FilingControlBlock &FCB);
flag EO_SaveDefinedData(FilingControlBlock &FCB, Strng &Tag, CXMsgLst &XM);
flag EO_SaveOtherData(FilingControlBlock &FCB);
flag EO_SaveConn(FilingControlBlock &FCB, CXMsgLst &XM);
flag EO_EndSave(FilingControlBlock &FCB);
flag EO_BeginLoad(FilingControlBlock &FCB);
flag EO_LoadDefinedData(FilingControlBlock &FCB, CXMsgLst &XM);
flag EO_LoadOtherData(FilingControlBlock &FCB);
flag EO_LoadConn(FilingControlBlock &FCB, CXMsgLst &XM);
flag EO_ConnectsDone(FilingControlBlock &FCB);
flag EO_DataLoaded(FilingControlBlock &FCB);
flag EO_EndLoad(FilingControlBlock &FCB);
CArray <FSubsDataItem, FSubsDataItem& > XData;
int LastNotPacked; // Used for testing in EO_ReadSubsData
void XDataClear();
byte m_iSaveWhat;
pFlwNode m_pSaveNode;
POSITION m_pSaveTear;
POSITION m_pSaveConn;
int m_iSaveIONo;
Strng m_sLabel;
// Multi Processor Stuff
long nProcessors;
long NProcessors() { return nProcessors; };
long nRqdThreads;
long NRqdThreads();
// Analysis Design
flag fADInited;
long m_ADIndexGrp;
long m_ADIndexObj;
CArray <CADGroup, CADGroup&> ADGrps;
void ADInit();
int DuplicateNetwork(CSArray & SelectedTags, FlwNode * pRoot);
int AnalyseNetwork(CFlwTree & Tree);
int FE_AD_GetID (int Index, Strng & Class, Strng & Name);
int FE_AD_Select (int Index, char * Tag);
int FE_AD_SetSelectedTags(Strng_List &SelectedTags);
int FE_AD_GetTagTree (CFlwTree & Tree);
int FE_AD_GetStatus (Strng & Status);
int FE_AD_Go ();
int FE_IOPnt_Add (LPCTSTR Tag, bool Input, LPCTSTR Desc, byte Type, LPCTSTR ValueStr, LPCTSTR ValueCnvs);
int FE_IOPnt_Remove (LPCTSTR Tag);
int FE_GetEvalOrder(bool GetCtrl, bool GetFullDescI, bool GetFullDescO, eTraceValue TraceWhat, CEvalOrderArray &Info);
int FE_GetEvalStats(CEvalStatsArray &Info);
int FE_GetNodeList(CNodeList&List);
int FE_GetNodeConfiguration(BOOL AllParms, BOOL AllState, LPCTSTR NdTag, CNodeConfigList&List);
int FE_GetNodeBalanceInfo(CNodeBalanceInfo & Balance, CNodeAuditInfo & Audit);
DEFINE_CI(CFlwSolver, FlwNode, 16);
// CTagRefStatusFnHook override
CTagRefStatus GetTagRefStatus(LPCTSTR Tag);
public:
SDBObject SDBObj;
#if WithTearObject
TearObject TearObj;
#endif
#if WITHCTRLOBJ
CtrlObject CtrlObj;
#endif
#if WITHCHANGEOBJ
ChgObject ChgObj;
#endif
TolObject TolObj;
#if WITHORDEROBJ
OrderObject OrderObj;
#endif
PwrObject PwrObj;
#if WITHIOOBJ
IOObject IOObj;
#endif
FlwNode * m_pRoot;
FlwNode * m_pPlantArea;
flag FlushDbg;
int iLclResultsValid;
FlwSlvPB PB;
FlwSlvDyn Dyn;
FILE *Rpt;
flag fStopOnError;
flag fGlblLinksDone;
flag fKeepGlblLinks;
flag m_fHoldDoGlobalLinks;
flag m_bMustCreateObjsFromFile;
flag m_bThreadStats;
int m_RQ_Files_Cnt;
double NetMaxResRatio;
double m_RandomSeed;
long m_lUnDoGlobalLinksCount;
flag * m_pStatusLoadReqd;
flag * m_pAssocGrfsLoadReqd;
CToleranceBlock m_MCloseTol;
CToleranceBlock m_HCloseTol;
CToleranceBlock m_HCloseTol2;
int m_AuditCount;
//CMap <LPSTR, LPSTR, FlwNode*, FlwNode*> m_NdGuidMap;
protected:
CString SecsBuff;
Strng m_PrjCnvsDBName;
Strng m_PrjSDBName;
Strng m_SpecieDataINIFile;
CArray<FlwNode*> m_TempNdPtrs;
};
//===========================================================================
//
//
//
//===========================================================================
#undef DllImportExport
#endif
| [
"[email protected]",
"[email protected]",
"[email protected]"
]
| [
[
[
1,
96
],
[
99,
99
],
[
101,
138
],
[
140,
145
],
[
147,
174
],
[
183,
186
],
[
199,
199
],
[
208,
225
],
[
231,
262
],
[
265,
282
],
[
287,
313
],
[
315,
350
],
[
356,
359
],
[
362,
363
],
[
368,
373
],
[
377,
380
],
[
387,
387
],
[
389,
391
],
[
394,
394
],
[
407,
411
],
[
414,
460
],
[
463,
491
],
[
493,
496
],
[
500,
504
],
[
506,
511
],
[
515,
518
],
[
520,
521
],
[
525,
526
],
[
529,
536
],
[
540,
540
],
[
551,
557
],
[
560,
560
],
[
562,
562
],
[
564,
564
],
[
567,
567
],
[
575,
577
],
[
580,
591
],
[
593,
598
],
[
604,
605
],
[
615,
615
],
[
631,
631
],
[
633,
633
],
[
640,
645
],
[
650,
650
],
[
653,
662
],
[
665,
670
],
[
677,
715
],
[
717,
719
],
[
721,
721
],
[
723,
762
],
[
766,
769
],
[
776,
779
],
[
782,
795
]
],
[
[
97,
98
],
[
100,
100
],
[
139,
139
],
[
146,
146
],
[
175,
182
],
[
187,
198
],
[
200,
207
],
[
226,
230
],
[
263,
264
],
[
283,
286
],
[
314,
314
],
[
351,
355
],
[
360,
361
],
[
364,
367
],
[
374,
376
],
[
381,
386
],
[
388,
388
],
[
392,
393
],
[
395,
406
],
[
461,
462
],
[
492,
492
],
[
497,
499
],
[
512,
514
],
[
519,
519
],
[
522,
524
],
[
527,
528
],
[
537,
539
],
[
541,
550
],
[
558,
559
],
[
561,
561
],
[
563,
563
],
[
565,
566
],
[
568,
574
],
[
578,
579
],
[
592,
592
],
[
599,
603
],
[
606,
614
],
[
616,
630
],
[
632,
632
],
[
634,
639
],
[
646,
649
],
[
651,
652
],
[
663,
664
],
[
671,
676
],
[
716,
716
],
[
720,
720
],
[
722,
722
],
[
763,
765
],
[
770,
775
],
[
780,
781
]
],
[
[
412,
413
],
[
505,
505
]
]
]
|
5f073edf7a23db31347cc213ec66c201f956ea7a | 2f43a19a5c96acfe8d6aed786dd57e092ac1f35f | /Classes/Side Libraries/xnamath/i_xnamathmatrix.inl | e2f755818cb3ab7694e792b31858ac8cfebda88a | []
| no_license | NERDSstack/Trap | c89b123d765e696f36c9029816177fa746784fdf | 78db7626ada289f4a4a6a7a3532e209608025c7f | refs/heads/master | 2020-08-28T04:57:22.655861 | 2010-12-20T17:33:37 | 2010-12-20T17:33:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 104,372 | inl | /*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
xnamathmatrix.inl
Abstract:
XNA math library for Windows and Xbox 360: Matrix functions
--*/
#if defined(_MSC_VER) && (_MSC_VER > 1000)
#pragma once
#endif
#ifndef __XNAMATHMATRIX_INL__
#define __XNAMATHMATRIX_INL__
/****************************************************************************
*
* Matrix
*
****************************************************************************/
//------------------------------------------------------------------------------
// Comparison operations
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Return TRUE if any entry in the matrix is NaN
XMFINLINE BOOL XMMatrixIsNaN
(
CXMMATRIX M
)
{
#if defined(_XM_NO_INTRINSICS_)
UINT i, uTest;
const UINT *pWork;
i = 16;
pWork = (const UINT *)(&M.m[0][0]);
do {
// Fetch value into integer unit
uTest = pWork[0];
// Remove sign
uTest &= 0x7FFFFFFFU;
// NaN is 0x7F800001 through 0x7FFFFFFF inclusive
uTest -= 0x7F800001U;
if (uTest<0x007FFFFFU) {
break; // NaN found
}
++pWork; // Next entry
} while (--i);
return (i!=0); // i == 0 if nothing matched
#elif defined(_XM_SSE_INTRINSICS_)
// Load in registers
XMVECTOR vX = M.r[0];
XMVECTOR vY = M.r[1];
XMVECTOR vZ = M.r[2];
XMVECTOR vW = M.r[3];
// Test themselves to check for NaN
vX = _mm_cmpneq_ps(vX,vX);
vY = _mm_cmpneq_ps(vY,vY);
vZ = _mm_cmpneq_ps(vZ,vZ);
vW = _mm_cmpneq_ps(vW,vW);
// Or all the results
vX = _mm_or_ps(vX,vZ);
vY = _mm_or_ps(vY,vW);
vX = _mm_or_ps(vX,vY);
// If any tested true, return true
return (_mm_movemask_ps(vX)!=0);
#else
#endif
}
//------------------------------------------------------------------------------
// Return TRUE if any entry in the matrix is +/-INF
XMFINLINE BOOL XMMatrixIsInfinite
(
CXMMATRIX M
)
{
#if defined(_XM_NO_INTRINSICS_)
UINT i, uTest;
const UINT *pWork;
i = 16;
pWork = (const UINT *)(&M.m[0][0]);
do {
// Fetch value into integer unit
uTest = pWork[0];
// Remove sign
uTest &= 0x7FFFFFFFU;
// INF is 0x7F800000
if (uTest==0x7F800000U) {
break; // INF found
}
++pWork; // Next entry
} while (--i);
return (i!=0); // i == 0 if nothing matched
#elif defined(_XM_SSE_INTRINSICS_)
// Mask off the sign bits
XMVECTOR vTemp1 = _mm_and_ps(M.r[0],g_XMAbsMask);
XMVECTOR vTemp2 = _mm_and_ps(M.r[1],g_XMAbsMask);
XMVECTOR vTemp3 = _mm_and_ps(M.r[2],g_XMAbsMask);
XMVECTOR vTemp4 = _mm_and_ps(M.r[3],g_XMAbsMask);
// Compare to infinity
vTemp1 = _mm_cmpeq_ps(vTemp1,g_XMInfinity);
vTemp2 = _mm_cmpeq_ps(vTemp2,g_XMInfinity);
vTemp3 = _mm_cmpeq_ps(vTemp3,g_XMInfinity);
vTemp4 = _mm_cmpeq_ps(vTemp4,g_XMInfinity);
// Or the answers together
vTemp1 = _mm_or_ps(vTemp1,vTemp2);
vTemp3 = _mm_or_ps(vTemp3,vTemp4);
vTemp1 = _mm_or_ps(vTemp1,vTemp3);
// If any are infinity, the signs are true.
return (_mm_movemask_ps(vTemp1)!=0);
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
// Return TRUE if the XMMatrix is equal to identity
XMFINLINE BOOL XMMatrixIsIdentity
(
CXMMATRIX M
)
{
#if defined(_XM_NO_INTRINSICS_)
unsigned int uOne, uZero;
const unsigned int *pWork;
// Use the integer pipeline to reduce branching to a minimum
pWork = (const unsigned int*)(&M.m[0][0]);
// Convert 1.0f to zero and or them together
uOne = pWork[0]^0x3F800000U;
// Or all the 0.0f entries together
uZero = pWork[1];
uZero |= pWork[2];
uZero |= pWork[3];
// 2nd row
uZero |= pWork[4];
uOne |= pWork[5]^0x3F800000U;
uZero |= pWork[6];
uZero |= pWork[7];
// 3rd row
uZero |= pWork[8];
uZero |= pWork[9];
uOne |= pWork[10]^0x3F800000U;
uZero |= pWork[11];
// 4th row
uZero |= pWork[12];
uZero |= pWork[13];
uZero |= pWork[14];
uOne |= pWork[15]^0x3F800000U;
// If all zero entries are zero, the uZero==0
uZero &= 0x7FFFFFFF; // Allow -0.0f
// If all 1.0f entries are 1.0f, then uOne==0
uOne |= uZero;
return (uOne==0);
#elif defined(_XM_SSE_INTRINSICS_)
XMVECTOR vTemp1 = _mm_cmpeq_ps(M.r[0],g_XMIdentityR0);
XMVECTOR vTemp2 = _mm_cmpeq_ps(M.r[1],g_XMIdentityR1);
XMVECTOR vTemp3 = _mm_cmpeq_ps(M.r[2],g_XMIdentityR2);
XMVECTOR vTemp4 = _mm_cmpeq_ps(M.r[3],g_XMIdentityR3);
vTemp1 = _mm_and_ps(vTemp1,vTemp2);
vTemp3 = _mm_and_ps(vTemp3,vTemp4);
vTemp1 = _mm_and_ps(vTemp1,vTemp3);
return (_mm_movemask_ps(vTemp1)==0x0f);
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
// Computation operations
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Perform a 4x4 matrix multiply by a 4x4 matrix
XMFINLINE XMMATRIX XMMatrixMultiply
(
CXMMATRIX M1,
CXMMATRIX M2
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX mResult;
// Cache the invariants in registers
float x = M1.m[0][0];
float y = M1.m[0][1];
float z = M1.m[0][2];
float w = M1.m[0][3];
// Perform the operation on the first row
mResult.m[0][0] = (M2.m[0][0]*x)+(M2.m[1][0]*y)+(M2.m[2][0]*z)+(M2.m[3][0]*w);
mResult.m[0][1] = (M2.m[0][1]*x)+(M2.m[1][1]*y)+(M2.m[2][1]*z)+(M2.m[3][1]*w);
mResult.m[0][2] = (M2.m[0][2]*x)+(M2.m[1][2]*y)+(M2.m[2][2]*z)+(M2.m[3][2]*w);
mResult.m[0][3] = (M2.m[0][3]*x)+(M2.m[1][3]*y)+(M2.m[2][3]*z)+(M2.m[3][3]*w);
// Repeat for all the other rows
x = M1.m[1][0];
y = M1.m[1][1];
z = M1.m[1][2];
w = M1.m[1][3];
mResult.m[1][0] = (M2.m[0][0]*x)+(M2.m[1][0]*y)+(M2.m[2][0]*z)+(M2.m[3][0]*w);
mResult.m[1][1] = (M2.m[0][1]*x)+(M2.m[1][1]*y)+(M2.m[2][1]*z)+(M2.m[3][1]*w);
mResult.m[1][2] = (M2.m[0][2]*x)+(M2.m[1][2]*y)+(M2.m[2][2]*z)+(M2.m[3][2]*w);
mResult.m[1][3] = (M2.m[0][3]*x)+(M2.m[1][3]*y)+(M2.m[2][3]*z)+(M2.m[3][3]*w);
x = M1.m[2][0];
y = M1.m[2][1];
z = M1.m[2][2];
w = M1.m[2][3];
mResult.m[2][0] = (M2.m[0][0]*x)+(M2.m[1][0]*y)+(M2.m[2][0]*z)+(M2.m[3][0]*w);
mResult.m[2][1] = (M2.m[0][1]*x)+(M2.m[1][1]*y)+(M2.m[2][1]*z)+(M2.m[3][1]*w);
mResult.m[2][2] = (M2.m[0][2]*x)+(M2.m[1][2]*y)+(M2.m[2][2]*z)+(M2.m[3][2]*w);
mResult.m[2][3] = (M2.m[0][3]*x)+(M2.m[1][3]*y)+(M2.m[2][3]*z)+(M2.m[3][3]*w);
x = M1.m[3][0];
y = M1.m[3][1];
z = M1.m[3][2];
w = M1.m[3][3];
mResult.m[3][0] = (M2.m[0][0]*x)+(M2.m[1][0]*y)+(M2.m[2][0]*z)+(M2.m[3][0]*w);
mResult.m[3][1] = (M2.m[0][1]*x)+(M2.m[1][1]*y)+(M2.m[2][1]*z)+(M2.m[3][1]*w);
mResult.m[3][2] = (M2.m[0][2]*x)+(M2.m[1][2]*y)+(M2.m[2][2]*z)+(M2.m[3][2]*w);
mResult.m[3][3] = (M2.m[0][3]*x)+(M2.m[1][3]*y)+(M2.m[2][3]*z)+(M2.m[3][3]*w);
return mResult;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX mResult;
// Use vW to hold the original row
XMVECTOR vW = M1.r[0];
// Splat the component X,Y,Z then W
XMVECTOR vX = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(0,0,0,0));
XMVECTOR vY = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(1,1,1,1));
XMVECTOR vZ = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(2,2,2,2));
vW = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(3,3,3,3));
// Perform the opertion on the first row
vX = _mm_mul_ps(vX,M2.r[0]);
vY = _mm_mul_ps(vY,M2.r[1]);
vZ = _mm_mul_ps(vZ,M2.r[2]);
vW = _mm_mul_ps(vW,M2.r[3]);
// Perform a binary add to reduce cumulative errors
vX = _mm_add_ps(vX,vZ);
vY = _mm_add_ps(vY,vW);
vX = _mm_add_ps(vX,vY);
mResult.r[0] = vX;
// Repeat for the other 3 rows
vW = M1.r[1];
vX = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(0,0,0,0));
vY = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(1,1,1,1));
vZ = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(2,2,2,2));
vW = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(3,3,3,3));
vX = _mm_mul_ps(vX,M2.r[0]);
vY = _mm_mul_ps(vY,M2.r[1]);
vZ = _mm_mul_ps(vZ,M2.r[2]);
vW = _mm_mul_ps(vW,M2.r[3]);
vX = _mm_add_ps(vX,vZ);
vY = _mm_add_ps(vY,vW);
vX = _mm_add_ps(vX,vY);
mResult.r[1] = vX;
vW = M1.r[2];
vX = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(0,0,0,0));
vY = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(1,1,1,1));
vZ = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(2,2,2,2));
vW = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(3,3,3,3));
vX = _mm_mul_ps(vX,M2.r[0]);
vY = _mm_mul_ps(vY,M2.r[1]);
vZ = _mm_mul_ps(vZ,M2.r[2]);
vW = _mm_mul_ps(vW,M2.r[3]);
vX = _mm_add_ps(vX,vZ);
vY = _mm_add_ps(vY,vW);
vX = _mm_add_ps(vX,vY);
mResult.r[2] = vX;
vW = M1.r[3];
vX = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(0,0,0,0));
vY = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(1,1,1,1));
vZ = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(2,2,2,2));
vW = _mm_shuffle_ps(vW,vW,_MM_SHUFFLE(3,3,3,3));
vX = _mm_mul_ps(vX,M2.r[0]);
vY = _mm_mul_ps(vY,M2.r[1]);
vZ = _mm_mul_ps(vZ,M2.r[2]);
vW = _mm_mul_ps(vW,M2.r[3]);
vX = _mm_add_ps(vX,vZ);
vY = _mm_add_ps(vY,vW);
vX = _mm_add_ps(vX,vY);
mResult.r[3] = vX;
return mResult;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixMultiplyTranspose
(
CXMMATRIX M1,
CXMMATRIX M2
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX mResult;
// Cache the invariants in registers
float x = M2.m[0][0];
float y = M2.m[1][0];
float z = M2.m[2][0];
float w = M2.m[3][0];
// Perform the operation on the first row
mResult.m[0][0] = (M1.m[0][0]*x)+(M1.m[0][1]*y)+(M1.m[0][2]*z)+(M1.m[0][3]*w);
mResult.m[0][1] = (M1.m[1][0]*x)+(M1.m[1][1]*y)+(M1.m[1][2]*z)+(M1.m[1][3]*w);
mResult.m[0][2] = (M1.m[2][0]*x)+(M1.m[2][1]*y)+(M1.m[2][2]*z)+(M1.m[2][3]*w);
mResult.m[0][3] = (M1.m[3][0]*x)+(M1.m[3][1]*y)+(M1.m[3][2]*z)+(M1.m[3][3]*w);
// Repeat for all the other rows
x = M2.m[0][1];
y = M2.m[1][1];
z = M2.m[2][1];
w = M2.m[3][1];
mResult.m[1][0] = (M1.m[0][0]*x)+(M1.m[0][1]*y)+(M1.m[0][2]*z)+(M1.m[0][3]*w);
mResult.m[1][1] = (M1.m[1][0]*x)+(M1.m[1][1]*y)+(M1.m[1][2]*z)+(M1.m[1][3]*w);
mResult.m[1][2] = (M1.m[2][0]*x)+(M1.m[2][1]*y)+(M1.m[2][2]*z)+(M1.m[2][3]*w);
mResult.m[1][3] = (M1.m[3][0]*x)+(M1.m[3][1]*y)+(M1.m[3][2]*z)+(M1.m[3][3]*w);
x = M2.m[0][2];
y = M2.m[1][2];
z = M2.m[2][2];
w = M2.m[3][2];
mResult.m[2][0] = (M1.m[0][0]*x)+(M1.m[0][1]*y)+(M1.m[0][2]*z)+(M1.m[0][3]*w);
mResult.m[2][1] = (M1.m[1][0]*x)+(M1.m[1][1]*y)+(M1.m[1][2]*z)+(M1.m[1][3]*w);
mResult.m[2][2] = (M1.m[2][0]*x)+(M1.m[2][1]*y)+(M1.m[2][2]*z)+(M1.m[2][3]*w);
mResult.m[2][3] = (M1.m[3][0]*x)+(M1.m[3][1]*y)+(M1.m[3][2]*z)+(M1.m[3][3]*w);
x = M2.m[0][3];
y = M2.m[1][3];
z = M2.m[2][3];
w = M2.m[3][3];
mResult.m[3][0] = (M1.m[0][0]*x)+(M1.m[0][1]*y)+(M1.m[0][2]*z)+(M1.m[0][3]*w);
mResult.m[3][1] = (M1.m[1][0]*x)+(M1.m[1][1]*y)+(M1.m[1][2]*z)+(M1.m[1][3]*w);
mResult.m[3][2] = (M1.m[2][0]*x)+(M1.m[2][1]*y)+(M1.m[2][2]*z)+(M1.m[2][3]*w);
mResult.m[3][3] = (M1.m[3][0]*x)+(M1.m[3][1]*y)+(M1.m[3][2]*z)+(M1.m[3][3]*w);
return mResult;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX Product;
XMMATRIX Result;
Product = XMMatrixMultiply(M1, M2);
Result = XMMatrixTranspose(Product);
return Result;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixTranspose
(
CXMMATRIX M
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX P;
XMMATRIX MT;
// Original matrix:
//
// m00m01m02m03
// m10m11m12m13
// m20m21m22m23
// m30m31m32m33
P.r[0] = XMVectorMergeXY(M.r[0], M.r[2]); // m00m20m01m21
P.r[1] = XMVectorMergeXY(M.r[1], M.r[3]); // m10m30m11m31
P.r[2] = XMVectorMergeZW(M.r[0], M.r[2]); // m02m22m03m23
P.r[3] = XMVectorMergeZW(M.r[1], M.r[3]); // m12m32m13m33
MT.r[0] = XMVectorMergeXY(P.r[0], P.r[1]); // m00m10m20m30
MT.r[1] = XMVectorMergeZW(P.r[0], P.r[1]); // m01m11m21m31
MT.r[2] = XMVectorMergeXY(P.r[2], P.r[3]); // m02m12m22m32
MT.r[3] = XMVectorMergeZW(P.r[2], P.r[3]); // m03m13m23m33
return MT;
#elif defined(_XM_SSE_INTRINSICS_)
// x.x,x.y,y.x,y.y
XMVECTOR vTemp1 = _mm_shuffle_ps(M.r[0],M.r[1],_MM_SHUFFLE(1,0,1,0));
// x.z,x.w,y.z,y.w
XMVECTOR vTemp3 = _mm_shuffle_ps(M.r[0],M.r[1],_MM_SHUFFLE(3,2,3,2));
// z.x,z.y,w.x,w.y
XMVECTOR vTemp2 = _mm_shuffle_ps(M.r[2],M.r[3],_MM_SHUFFLE(1,0,1,0));
// z.z,z.w,w.z,w.w
XMVECTOR vTemp4 = _mm_shuffle_ps(M.r[2],M.r[3],_MM_SHUFFLE(3,2,3,2));
XMMATRIX mResult;
// x.x,y.x,z.x,w.x
mResult.r[0] = _mm_shuffle_ps(vTemp1, vTemp2,_MM_SHUFFLE(2,0,2,0));
// x.y,y.y,z.y,w.y
mResult.r[1] = _mm_shuffle_ps(vTemp1, vTemp2,_MM_SHUFFLE(3,1,3,1));
// x.z,y.z,z.z,w.z
mResult.r[2] = _mm_shuffle_ps(vTemp3, vTemp4,_MM_SHUFFLE(2,0,2,0));
// x.w,y.w,z.w,w.w
mResult.r[3] = _mm_shuffle_ps(vTemp3, vTemp4,_MM_SHUFFLE(3,1,3,1));
return mResult;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
// Return the inverse and the determinant of a 4x4 matrix
XMINLINE XMMATRIX XMMatrixInverse
(
XMVECTOR* pDeterminant,
CXMMATRIX M
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX R;
XMMATRIX MT;
XMVECTOR D0, D1, D2;
XMVECTOR C0, C1, C2, C3, C4, C5, C6, C7;
XMVECTOR V0[4], V1[4];
XMVECTOR Determinant;
XMVECTOR Reciprocal;
XMMATRIX Result;
static CONST XMVECTORU32 SwizzleXXYY = {XM_PERMUTE_0X, XM_PERMUTE_0X, XM_PERMUTE_0Y, XM_PERMUTE_0Y};
static CONST XMVECTORU32 SwizzleZWZW = {XM_PERMUTE_0Z, XM_PERMUTE_0W, XM_PERMUTE_0Z, XM_PERMUTE_0W};
static CONST XMVECTORU32 SwizzleYZXY = {XM_PERMUTE_0Y, XM_PERMUTE_0Z, XM_PERMUTE_0X, XM_PERMUTE_0Y};
static CONST XMVECTORU32 SwizzleZWYZ = {XM_PERMUTE_0Z, XM_PERMUTE_0W, XM_PERMUTE_0Y, XM_PERMUTE_0Z};
static CONST XMVECTORU32 SwizzleWXWX = {XM_PERMUTE_0W, XM_PERMUTE_0X, XM_PERMUTE_0W, XM_PERMUTE_0X};
static CONST XMVECTORU32 SwizzleZXYX = {XM_PERMUTE_0Z, XM_PERMUTE_0X, XM_PERMUTE_0Y, XM_PERMUTE_0X};
static CONST XMVECTORU32 SwizzleYWXZ = {XM_PERMUTE_0Y, XM_PERMUTE_0W, XM_PERMUTE_0X, XM_PERMUTE_0Z};
static CONST XMVECTORU32 SwizzleWZWY = {XM_PERMUTE_0W, XM_PERMUTE_0Z, XM_PERMUTE_0W, XM_PERMUTE_0Y};
static CONST XMVECTORU32 Permute0X0Z1X1Z = {XM_PERMUTE_0X, XM_PERMUTE_0Z, XM_PERMUTE_1X, XM_PERMUTE_1Z};
static CONST XMVECTORU32 Permute0Y0W1Y1W = {XM_PERMUTE_0Y, XM_PERMUTE_0W, XM_PERMUTE_1Y, XM_PERMUTE_1W};
static CONST XMVECTORU32 Permute1Y0Y0W0X = {XM_PERMUTE_1Y, XM_PERMUTE_0Y, XM_PERMUTE_0W, XM_PERMUTE_0X};
static CONST XMVECTORU32 Permute0W0X0Y1X = {XM_PERMUTE_0W, XM_PERMUTE_0X, XM_PERMUTE_0Y, XM_PERMUTE_1X};
static CONST XMVECTORU32 Permute0Z1Y1X0Z = {XM_PERMUTE_0Z, XM_PERMUTE_1Y, XM_PERMUTE_1X, XM_PERMUTE_0Z};
static CONST XMVECTORU32 Permute0W1Y0Y0Z = {XM_PERMUTE_0W, XM_PERMUTE_1Y, XM_PERMUTE_0Y, XM_PERMUTE_0Z};
static CONST XMVECTORU32 Permute0Z0Y1X0X = {XM_PERMUTE_0Z, XM_PERMUTE_0Y, XM_PERMUTE_1X, XM_PERMUTE_0X};
static CONST XMVECTORU32 Permute1Y0X0W1X = {XM_PERMUTE_1Y, XM_PERMUTE_0X, XM_PERMUTE_0W, XM_PERMUTE_1X};
static CONST XMVECTORU32 Permute1W0Y0W0X = {XM_PERMUTE_1W, XM_PERMUTE_0Y, XM_PERMUTE_0W, XM_PERMUTE_0X};
static CONST XMVECTORU32 Permute0W0X0Y1Z = {XM_PERMUTE_0W, XM_PERMUTE_0X, XM_PERMUTE_0Y, XM_PERMUTE_1Z};
static CONST XMVECTORU32 Permute0Z1W1Z0Z = {XM_PERMUTE_0Z, XM_PERMUTE_1W, XM_PERMUTE_1Z, XM_PERMUTE_0Z};
static CONST XMVECTORU32 Permute0W1W0Y0Z = {XM_PERMUTE_0W, XM_PERMUTE_1W, XM_PERMUTE_0Y, XM_PERMUTE_0Z};
static CONST XMVECTORU32 Permute0Z0Y1Z0X = {XM_PERMUTE_0Z, XM_PERMUTE_0Y, XM_PERMUTE_1Z, XM_PERMUTE_0X};
static CONST XMVECTORU32 Permute1W0X0W1Z = {XM_PERMUTE_1W, XM_PERMUTE_0X, XM_PERMUTE_0W, XM_PERMUTE_1Z};
XMASSERT(pDeterminant);
MT = XMMatrixTranspose(M);
V0[0] = XMVectorPermute(MT.r[2], MT.r[2], SwizzleXXYY.v);
V1[0] = XMVectorPermute(MT.r[3], MT.r[3], SwizzleZWZW.v);
V0[1] = XMVectorPermute(MT.r[0], MT.r[0], SwizzleXXYY.v);
V1[1] = XMVectorPermute(MT.r[1], MT.r[1], SwizzleZWZW.v);
V0[2] = XMVectorPermute(MT.r[2], MT.r[0], Permute0X0Z1X1Z.v);
V1[2] = XMVectorPermute(MT.r[3], MT.r[1], Permute0Y0W1Y1W.v);
D0 = XMVectorMultiply(V0[0], V1[0]);
D1 = XMVectorMultiply(V0[1], V1[1]);
D2 = XMVectorMultiply(V0[2], V1[2]);
V0[0] = XMVectorPermute(MT.r[2], MT.r[2], SwizzleZWZW.v);
V1[0] = XMVectorPermute(MT.r[3], MT.r[3], SwizzleXXYY.v);
V0[1] = XMVectorPermute(MT.r[0], MT.r[0], SwizzleZWZW.v);
V1[1] = XMVectorPermute(MT.r[1], MT.r[1], SwizzleXXYY.v);
V0[2] = XMVectorPermute(MT.r[2], MT.r[0], Permute0Y0W1Y1W.v);
V1[2] = XMVectorPermute(MT.r[3], MT.r[1], Permute0X0Z1X1Z.v);
D0 = XMVectorNegativeMultiplySubtract(V0[0], V1[0], D0);
D1 = XMVectorNegativeMultiplySubtract(V0[1], V1[1], D1);
D2 = XMVectorNegativeMultiplySubtract(V0[2], V1[2], D2);
V0[0] = XMVectorPermute(MT.r[1], MT.r[1], SwizzleYZXY.v);
V1[0] = XMVectorPermute(D0, D2, Permute1Y0Y0W0X.v);
V0[1] = XMVectorPermute(MT.r[0], MT.r[0], SwizzleZXYX.v);
V1[1] = XMVectorPermute(D0, D2, Permute0W1Y0Y0Z.v);
V0[2] = XMVectorPermute(MT.r[3], MT.r[3], SwizzleYZXY.v);
V1[2] = XMVectorPermute(D1, D2, Permute1W0Y0W0X.v);
V0[3] = XMVectorPermute(MT.r[2], MT.r[2], SwizzleZXYX.v);
V1[3] = XMVectorPermute(D1, D2, Permute0W1W0Y0Z.v);
C0 = XMVectorMultiply(V0[0], V1[0]);
C2 = XMVectorMultiply(V0[1], V1[1]);
C4 = XMVectorMultiply(V0[2], V1[2]);
C6 = XMVectorMultiply(V0[3], V1[3]);
V0[0] = XMVectorPermute(MT.r[1], MT.r[1], SwizzleZWYZ.v);
V1[0] = XMVectorPermute(D0, D2, Permute0W0X0Y1X.v);
V0[1] = XMVectorPermute(MT.r[0], MT.r[0], SwizzleWZWY.v);
V1[1] = XMVectorPermute(D0, D2, Permute0Z0Y1X0X.v);
V0[2] = XMVectorPermute(MT.r[3], MT.r[3], SwizzleZWYZ.v);
V1[2] = XMVectorPermute(D1, D2, Permute0W0X0Y1Z.v);
V0[3] = XMVectorPermute(MT.r[2], MT.r[2], SwizzleWZWY.v);
V1[3] = XMVectorPermute(D1, D2, Permute0Z0Y1Z0X.v);
C0 = XMVectorNegativeMultiplySubtract(V0[0], V1[0], C0);
C2 = XMVectorNegativeMultiplySubtract(V0[1], V1[1], C2);
C4 = XMVectorNegativeMultiplySubtract(V0[2], V1[2], C4);
C6 = XMVectorNegativeMultiplySubtract(V0[3], V1[3], C6);
V0[0] = XMVectorPermute(MT.r[1], MT.r[1], SwizzleWXWX.v);
V1[0] = XMVectorPermute(D0, D2, Permute0Z1Y1X0Z.v);
V0[1] = XMVectorPermute(MT.r[0], MT.r[0], SwizzleYWXZ.v);
V1[1] = XMVectorPermute(D0, D2, Permute1Y0X0W1X.v);
V0[2] = XMVectorPermute(MT.r[3], MT.r[3], SwizzleWXWX.v);
V1[2] = XMVectorPermute(D1, D2, Permute0Z1W1Z0Z.v);
V0[3] = XMVectorPermute(MT.r[2], MT.r[2], SwizzleYWXZ.v);
V1[3] = XMVectorPermute(D1, D2, Permute1W0X0W1Z.v);
C1 = XMVectorNegativeMultiplySubtract(V0[0], V1[0], C0);
C0 = XMVectorMultiplyAdd(V0[0], V1[0], C0);
C3 = XMVectorMultiplyAdd(V0[1], V1[1], C2);
C2 = XMVectorNegativeMultiplySubtract(V0[1], V1[1], C2);
C5 = XMVectorNegativeMultiplySubtract(V0[2], V1[2], C4);
C4 = XMVectorMultiplyAdd(V0[2], V1[2], C4);
C7 = XMVectorMultiplyAdd(V0[3], V1[3], C6);
C6 = XMVectorNegativeMultiplySubtract(V0[3], V1[3], C6);
R.r[0] = XMVectorSelect(C0, C1, g_XMSelect0101.v);
R.r[1] = XMVectorSelect(C2, C3, g_XMSelect0101.v);
R.r[2] = XMVectorSelect(C4, C5, g_XMSelect0101.v);
R.r[3] = XMVectorSelect(C6, C7, g_XMSelect0101.v);
Determinant = XMVector4Dot(R.r[0], MT.r[0]);
*pDeterminant = Determinant;
Reciprocal = XMVectorReciprocal(Determinant);
Result.r[0] = XMVectorMultiply(R.r[0], Reciprocal);
Result.r[1] = XMVectorMultiply(R.r[1], Reciprocal);
Result.r[2] = XMVectorMultiply(R.r[2], Reciprocal);
Result.r[3] = XMVectorMultiply(R.r[3], Reciprocal);
return Result;
#elif defined(_XM_SSE_INTRINSICS_)
XMASSERT(pDeterminant);
XMMATRIX MT = XMMatrixTranspose(M);
XMVECTOR V00 = _mm_shuffle_ps(MT.r[2], MT.r[2],_MM_SHUFFLE(1,1,0,0));
XMVECTOR V10 = _mm_shuffle_ps(MT.r[3], MT.r[3],_MM_SHUFFLE(3,2,3,2));
XMVECTOR V01 = _mm_shuffle_ps(MT.r[0], MT.r[0],_MM_SHUFFLE(1,1,0,0));
XMVECTOR V11 = _mm_shuffle_ps(MT.r[1], MT.r[1],_MM_SHUFFLE(3,2,3,2));
XMVECTOR V02 = _mm_shuffle_ps(MT.r[2], MT.r[0],_MM_SHUFFLE(2,0,2,0));
XMVECTOR V12 = _mm_shuffle_ps(MT.r[3], MT.r[1],_MM_SHUFFLE(3,1,3,1));
XMVECTOR D0 = _mm_mul_ps(V00,V10);
XMVECTOR D1 = _mm_mul_ps(V01,V11);
XMVECTOR D2 = _mm_mul_ps(V02,V12);
V00 = _mm_shuffle_ps(MT.r[2],MT.r[2],_MM_SHUFFLE(3,2,3,2));
V10 = _mm_shuffle_ps(MT.r[3],MT.r[3],_MM_SHUFFLE(1,1,0,0));
V01 = _mm_shuffle_ps(MT.r[0],MT.r[0],_MM_SHUFFLE(3,2,3,2));
V11 = _mm_shuffle_ps(MT.r[1],MT.r[1],_MM_SHUFFLE(1,1,0,0));
V02 = _mm_shuffle_ps(MT.r[2],MT.r[0],_MM_SHUFFLE(3,1,3,1));
V12 = _mm_shuffle_ps(MT.r[3],MT.r[1],_MM_SHUFFLE(2,0,2,0));
V00 = _mm_mul_ps(V00,V10);
V01 = _mm_mul_ps(V01,V11);
V02 = _mm_mul_ps(V02,V12);
D0 = _mm_sub_ps(D0,V00);
D1 = _mm_sub_ps(D1,V01);
D2 = _mm_sub_ps(D2,V02);
// V11 = D0Y,D0W,D2Y,D2Y
V11 = _mm_shuffle_ps(D0,D2,_MM_SHUFFLE(1,1,3,1));
V00 = _mm_shuffle_ps(MT.r[1], MT.r[1],_MM_SHUFFLE(1,0,2,1));
V10 = _mm_shuffle_ps(V11,D0,_MM_SHUFFLE(0,3,0,2));
V01 = _mm_shuffle_ps(MT.r[0], MT.r[0],_MM_SHUFFLE(0,1,0,2));
V11 = _mm_shuffle_ps(V11,D0,_MM_SHUFFLE(2,1,2,1));
// V13 = D1Y,D1W,D2W,D2W
XMVECTOR V13 = _mm_shuffle_ps(D1,D2,_MM_SHUFFLE(3,3,3,1));
V02 = _mm_shuffle_ps(MT.r[3], MT.r[3],_MM_SHUFFLE(1,0,2,1));
V12 = _mm_shuffle_ps(V13,D1,_MM_SHUFFLE(0,3,0,2));
XMVECTOR V03 = _mm_shuffle_ps(MT.r[2], MT.r[2],_MM_SHUFFLE(0,1,0,2));
V13 = _mm_shuffle_ps(V13,D1,_MM_SHUFFLE(2,1,2,1));
XMVECTOR C0 = _mm_mul_ps(V00,V10);
XMVECTOR C2 = _mm_mul_ps(V01,V11);
XMVECTOR C4 = _mm_mul_ps(V02,V12);
XMVECTOR C6 = _mm_mul_ps(V03,V13);
// V11 = D0X,D0Y,D2X,D2X
V11 = _mm_shuffle_ps(D0,D2,_MM_SHUFFLE(0,0,1,0));
V00 = _mm_shuffle_ps(MT.r[1], MT.r[1],_MM_SHUFFLE(2,1,3,2));
V10 = _mm_shuffle_ps(D0,V11,_MM_SHUFFLE(2,1,0,3));
V01 = _mm_shuffle_ps(MT.r[0], MT.r[0],_MM_SHUFFLE(1,3,2,3));
V11 = _mm_shuffle_ps(D0,V11,_MM_SHUFFLE(0,2,1,2));
// V13 = D1X,D1Y,D2Z,D2Z
V13 = _mm_shuffle_ps(D1,D2,_MM_SHUFFLE(2,2,1,0));
V02 = _mm_shuffle_ps(MT.r[3], MT.r[3],_MM_SHUFFLE(2,1,3,2));
V12 = _mm_shuffle_ps(D1,V13,_MM_SHUFFLE(2,1,0,3));
V03 = _mm_shuffle_ps(MT.r[2], MT.r[2],_MM_SHUFFLE(1,3,2,3));
V13 = _mm_shuffle_ps(D1,V13,_MM_SHUFFLE(0,2,1,2));
V00 = _mm_mul_ps(V00,V10);
V01 = _mm_mul_ps(V01,V11);
V02 = _mm_mul_ps(V02,V12);
V03 = _mm_mul_ps(V03,V13);
C0 = _mm_sub_ps(C0,V00);
C2 = _mm_sub_ps(C2,V01);
C4 = _mm_sub_ps(C4,V02);
C6 = _mm_sub_ps(C6,V03);
V00 = _mm_shuffle_ps(MT.r[1],MT.r[1],_MM_SHUFFLE(0,3,0,3));
// V10 = D0Z,D0Z,D2X,D2Y
V10 = _mm_shuffle_ps(D0,D2,_MM_SHUFFLE(1,0,2,2));
V10 = _mm_shuffle_ps(V10,V10,_MM_SHUFFLE(0,2,3,0));
V01 = _mm_shuffle_ps(MT.r[0],MT.r[0],_MM_SHUFFLE(2,0,3,1));
// V11 = D0X,D0W,D2X,D2Y
V11 = _mm_shuffle_ps(D0,D2,_MM_SHUFFLE(1,0,3,0));
V11 = _mm_shuffle_ps(V11,V11,_MM_SHUFFLE(2,1,0,3));
V02 = _mm_shuffle_ps(MT.r[3],MT.r[3],_MM_SHUFFLE(0,3,0,3));
// V12 = D1Z,D1Z,D2Z,D2W
V12 = _mm_shuffle_ps(D1,D2,_MM_SHUFFLE(3,2,2,2));
V12 = _mm_shuffle_ps(V12,V12,_MM_SHUFFLE(0,2,3,0));
V03 = _mm_shuffle_ps(MT.r[2],MT.r[2],_MM_SHUFFLE(2,0,3,1));
// V13 = D1X,D1W,D2Z,D2W
V13 = _mm_shuffle_ps(D1,D2,_MM_SHUFFLE(3,2,3,0));
V13 = _mm_shuffle_ps(V13,V13,_MM_SHUFFLE(2,1,0,3));
V00 = _mm_mul_ps(V00,V10);
V01 = _mm_mul_ps(V01,V11);
V02 = _mm_mul_ps(V02,V12);
V03 = _mm_mul_ps(V03,V13);
XMVECTOR C1 = _mm_sub_ps(C0,V00);
C0 = _mm_add_ps(C0,V00);
XMVECTOR C3 = _mm_add_ps(C2,V01);
C2 = _mm_sub_ps(C2,V01);
XMVECTOR C5 = _mm_sub_ps(C4,V02);
C4 = _mm_add_ps(C4,V02);
XMVECTOR C7 = _mm_add_ps(C6,V03);
C6 = _mm_sub_ps(C6,V03);
C0 = _mm_shuffle_ps(C0,C1,_MM_SHUFFLE(3,1,2,0));
C2 = _mm_shuffle_ps(C2,C3,_MM_SHUFFLE(3,1,2,0));
C4 = _mm_shuffle_ps(C4,C5,_MM_SHUFFLE(3,1,2,0));
C6 = _mm_shuffle_ps(C6,C7,_MM_SHUFFLE(3,1,2,0));
C0 = _mm_shuffle_ps(C0,C0,_MM_SHUFFLE(3,1,2,0));
C2 = _mm_shuffle_ps(C2,C2,_MM_SHUFFLE(3,1,2,0));
C4 = _mm_shuffle_ps(C4,C4,_MM_SHUFFLE(3,1,2,0));
C6 = _mm_shuffle_ps(C6,C6,_MM_SHUFFLE(3,1,2,0));
// Get the determinate
XMVECTOR vTemp = XMVector4Dot(C0,MT.r[0]);
*pDeterminant = vTemp;
vTemp = _mm_div_ps(g_XMOne,vTemp);
XMMATRIX mResult;
mResult.r[0] = _mm_mul_ps(C0,vTemp);
mResult.r[1] = _mm_mul_ps(C2,vTemp);
mResult.r[2] = _mm_mul_ps(C4,vTemp);
mResult.r[3] = _mm_mul_ps(C6,vTemp);
return mResult;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMINLINE XMVECTOR XMMatrixDeterminant
(
CXMMATRIX M
)
{
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR V0, V1, V2, V3, V4, V5;
XMVECTOR P0, P1, P2, R, S;
XMVECTOR Result;
static CONST XMVECTORU32 SwizzleYXXX = {XM_PERMUTE_0Y, XM_PERMUTE_0X, XM_PERMUTE_0X, XM_PERMUTE_0X};
static CONST XMVECTORU32 SwizzleZZYY = {XM_PERMUTE_0Z, XM_PERMUTE_0Z, XM_PERMUTE_0Y, XM_PERMUTE_0Y};
static CONST XMVECTORU32 SwizzleWWWZ = {XM_PERMUTE_0W, XM_PERMUTE_0W, XM_PERMUTE_0W, XM_PERMUTE_0Z};
static CONST XMVECTOR Sign = {1.0f, -1.0f, 1.0f, -1.0f};
V0 = XMVectorPermute(M.r[2], M.r[2], SwizzleYXXX.v);
V1 = XMVectorPermute(M.r[3], M.r[3], SwizzleZZYY.v);
V2 = XMVectorPermute(M.r[2], M.r[2], SwizzleYXXX.v);
V3 = XMVectorPermute(M.r[3], M.r[3], SwizzleWWWZ.v);
V4 = XMVectorPermute(M.r[2], M.r[2], SwizzleZZYY.v);
V5 = XMVectorPermute(M.r[3], M.r[3], SwizzleWWWZ.v);
P0 = XMVectorMultiply(V0, V1);
P1 = XMVectorMultiply(V2, V3);
P2 = XMVectorMultiply(V4, V5);
V0 = XMVectorPermute(M.r[2], M.r[2], SwizzleZZYY.v);
V1 = XMVectorPermute(M.r[3], M.r[3], SwizzleYXXX.v);
V2 = XMVectorPermute(M.r[2], M.r[2], SwizzleWWWZ.v);
V3 = XMVectorPermute(M.r[3], M.r[3], SwizzleYXXX.v);
V4 = XMVectorPermute(M.r[2], M.r[2], SwizzleWWWZ.v);
V5 = XMVectorPermute(M.r[3], M.r[3], SwizzleZZYY.v);
P0 = XMVectorNegativeMultiplySubtract(V0, V1, P0);
P1 = XMVectorNegativeMultiplySubtract(V2, V3, P1);
P2 = XMVectorNegativeMultiplySubtract(V4, V5, P2);
V0 = XMVectorPermute(M.r[1], M.r[1], SwizzleWWWZ.v);
V1 = XMVectorPermute(M.r[1], M.r[1], SwizzleZZYY.v);
V2 = XMVectorPermute(M.r[1], M.r[1], SwizzleYXXX.v);
S = XMVectorMultiply(M.r[0], Sign);
R = XMVectorMultiply(V0, P0);
R = XMVectorNegativeMultiplySubtract(V1, P1, R);
R = XMVectorMultiplyAdd(V2, P2, R);
Result = XMVector4Dot(S, R);
return Result;
#elif defined(_XM_SSE_INTRINSICS_)
XMVECTOR V0, V1, V2, V3, V4, V5;
XMVECTOR P0, P1, P2, R, S;
XMVECTOR Result;
static CONST XMVECTORU32 SwizzleYXXX = {XM_PERMUTE_0Y, XM_PERMUTE_0X, XM_PERMUTE_0X, XM_PERMUTE_0X};
static CONST XMVECTORU32 SwizzleZZYY = {XM_PERMUTE_0Z, XM_PERMUTE_0Z, XM_PERMUTE_0Y, XM_PERMUTE_0Y};
static CONST XMVECTORU32 SwizzleWWWZ = {XM_PERMUTE_0W, XM_PERMUTE_0W, XM_PERMUTE_0W, XM_PERMUTE_0Z};
static CONST XMVECTORF32 Sign = {1.0f, -1.0f, 1.0f, -1.0f};
V0 = XMVectorPermute(M.r[2], M.r[2], SwizzleYXXX);
V1 = XMVectorPermute(M.r[3], M.r[3], SwizzleZZYY);
V2 = XMVectorPermute(M.r[2], M.r[2], SwizzleYXXX);
V3 = XMVectorPermute(M.r[3], M.r[3], SwizzleWWWZ);
V4 = XMVectorPermute(M.r[2], M.r[2], SwizzleZZYY);
V5 = XMVectorPermute(M.r[3], M.r[3], SwizzleWWWZ);
P0 = _mm_mul_ps(V0, V1);
P1 = _mm_mul_ps(V2, V3);
P2 = _mm_mul_ps(V4, V5);
V0 = XMVectorPermute(M.r[2], M.r[2], SwizzleZZYY);
V1 = XMVectorPermute(M.r[3], M.r[3], SwizzleYXXX);
V2 = XMVectorPermute(M.r[2], M.r[2], SwizzleWWWZ);
V3 = XMVectorPermute(M.r[3], M.r[3], SwizzleYXXX);
V4 = XMVectorPermute(M.r[2], M.r[2], SwizzleWWWZ);
V5 = XMVectorPermute(M.r[3], M.r[3], SwizzleZZYY);
P0 = XMVectorNegativeMultiplySubtract(V0, V1, P0);
P1 = XMVectorNegativeMultiplySubtract(V2, V3, P1);
P2 = XMVectorNegativeMultiplySubtract(V4, V5, P2);
V0 = XMVectorPermute(M.r[1], M.r[1], SwizzleWWWZ);
V1 = XMVectorPermute(M.r[1], M.r[1], SwizzleZZYY);
V2 = XMVectorPermute(M.r[1], M.r[1], SwizzleYXXX);
S = _mm_mul_ps(M.r[0], Sign);
R = _mm_mul_ps(V0, P0);
R = XMVectorNegativeMultiplySubtract(V1, P1, R);
R = XMVectorMultiplyAdd(V2, P2, R);
Result = XMVector4Dot(S, R);
return Result;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
#define XMRANKDECOMPOSE(a, b, c, x, y, z) \
if((x) < (y)) \
{ \
if((y) < (z)) \
{ \
(a) = 2; \
(b) = 1; \
(c) = 0; \
} \
else \
{ \
(a) = 1; \
\
if((x) < (z)) \
{ \
(b) = 2; \
(c) = 0; \
} \
else \
{ \
(b) = 0; \
(c) = 2; \
} \
} \
} \
else \
{ \
if((x) < (z)) \
{ \
(a) = 2; \
(b) = 0; \
(c) = 1; \
} \
else \
{ \
(a) = 0; \
\
if((y) < (z)) \
{ \
(b) = 2; \
(c) = 1; \
} \
else \
{ \
(b) = 1; \
(c) = 2; \
} \
} \
}
#define XM_DECOMP_EPSILON 0.0001f
XMINLINE BOOL XMMatrixDecompose( XMVECTOR *outScale, XMVECTOR *outRotQuat, XMVECTOR *outTrans, CXMMATRIX M )
{
FLOAT fDet;
FLOAT *pfScales;
XMVECTOR *ppvBasis[3];
XMMATRIX matTemp;
UINT a, b, c;
static const XMVECTOR *pvCanonicalBasis[3] = {
&g_XMIdentityR0.v,
&g_XMIdentityR1.v,
&g_XMIdentityR2.v
};
// Get the translation
outTrans[0] = M.r[3];
ppvBasis[0] = &matTemp.r[0];
ppvBasis[1] = &matTemp.r[1];
ppvBasis[2] = &matTemp.r[2];
matTemp.r[0] = M.r[0];
matTemp.r[1] = M.r[1];
matTemp.r[2] = M.r[2];
matTemp.r[3] = g_XMIdentityR3.v;
pfScales = (FLOAT *)outScale;
XMVectorGetXPtr(&pfScales[0],XMVector3Length(ppvBasis[0][0]));
XMVectorGetXPtr(&pfScales[1],XMVector3Length(ppvBasis[1][0]));
XMVectorGetXPtr(&pfScales[2],XMVector3Length(ppvBasis[2][0]));
XMRANKDECOMPOSE(a, b, c, pfScales[0], pfScales[1], pfScales[2])
if(pfScales[a] < XM_DECOMP_EPSILON)
{
ppvBasis[a][0] = pvCanonicalBasis[a][0];
}
ppvBasis[a][0] = XMVector3Normalize(ppvBasis[a][0]);
if(pfScales[b] < XM_DECOMP_EPSILON)
{
UINT aa, bb, cc;
FLOAT fAbsX, fAbsY, fAbsZ;
fAbsX = fabsf(XMVectorGetX(ppvBasis[a][0]));
fAbsY = fabsf(XMVectorGetY(ppvBasis[a][0]));
fAbsZ = fabsf(XMVectorGetZ(ppvBasis[a][0]));
XMRANKDECOMPOSE(aa, bb, cc, fAbsX, fAbsY, fAbsZ)
ppvBasis[b][0] = XMVector3Cross(ppvBasis[a][0],pvCanonicalBasis[cc][0]);
}
ppvBasis[b][0] = XMVector3Normalize(ppvBasis[b][0]);
if(pfScales[c] < XM_DECOMP_EPSILON)
{
ppvBasis[c][0] = XMVector3Cross(ppvBasis[a][0],ppvBasis[b][0]);
}
ppvBasis[c][0] = XMVector3Normalize(ppvBasis[c][0]);
fDet = XMVectorGetX(XMMatrixDeterminant(matTemp));
// use Kramer's rule to check for handedness of coordinate system
if(fDet < 0.0f)
{
// switch coordinate system by negating the scale and inverting the basis vector on the x-axis
pfScales[a] = -pfScales[a];
ppvBasis[a][0] = XMVectorNegate(ppvBasis[a][0]);
fDet = -fDet;
}
fDet -= 1.0f;
fDet *= fDet;
if(XM_DECOMP_EPSILON < fDet)
{
// Non-SRT matrix encountered
return FALSE;
}
// generate the quaternion from the matrix
outRotQuat[0] = XMQuaternionRotationMatrix(matTemp);
return TRUE;
}
//------------------------------------------------------------------------------
// Transformation operations
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixIdentity()
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
M.r[0] = g_XMIdentityR0.v;
M.r[1] = g_XMIdentityR1.v;
M.r[2] = g_XMIdentityR2.v;
M.r[3] = g_XMIdentityR3.v;
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX M;
M.r[0] = g_XMIdentityR0;
M.r[1] = g_XMIdentityR1;
M.r[2] = g_XMIdentityR2;
M.r[3] = g_XMIdentityR3;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixSet
(
FLOAT m00, FLOAT m01, FLOAT m02, FLOAT m03,
FLOAT m10, FLOAT m11, FLOAT m12, FLOAT m13,
FLOAT m20, FLOAT m21, FLOAT m22, FLOAT m23,
FLOAT m30, FLOAT m31, FLOAT m32, FLOAT m33
)
{
XMMATRIX M;
M.r[0] = XMVectorSet(m00, m01, m02, m03);
M.r[1] = XMVectorSet(m10, m11, m12, m13);
M.r[2] = XMVectorSet(m20, m21, m22, m23);
M.r[3] = XMVectorSet(m30, m31, m32, m33);
return M;
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixTranslation
(
FLOAT OffsetX,
FLOAT OffsetY,
FLOAT OffsetZ
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
M.m[0][0] = 1.0f;
M.m[0][1] = 0.0f;
M.m[0][2] = 0.0f;
M.m[0][3] = 0.0f;
M.m[1][0] = 0.0f;
M.m[1][1] = 1.0f;
M.m[1][2] = 0.0f;
M.m[1][3] = 0.0f;
M.m[2][0] = 0.0f;
M.m[2][1] = 0.0f;
M.m[2][2] = 1.0f;
M.m[2][3] = 0.0f;
M.m[3][0] = OffsetX;
M.m[3][1] = OffsetY;
M.m[3][2] = OffsetZ;
M.m[3][3] = 1.0f;
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX M;
M.r[0] = g_XMIdentityR0;
M.r[1] = g_XMIdentityR1;
M.r[2] = g_XMIdentityR2;
M.r[3] = _mm_set_ps(1.0f,OffsetZ,OffsetY,OffsetX);
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixTranslationFromVector
(
FXMVECTOR Offset
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
M.m[0][0] = 1.0f;
M.m[0][1] = 0.0f;
M.m[0][2] = 0.0f;
M.m[0][3] = 0.0f;
M.m[1][0] = 0.0f;
M.m[1][1] = 1.0f;
M.m[1][2] = 0.0f;
M.m[1][3] = 0.0f;
M.m[2][0] = 0.0f;
M.m[2][1] = 0.0f;
M.m[2][2] = 1.0f;
M.m[2][3] = 0.0f;
M.m[3][0] = Offset.vector4_f32[0];
M.m[3][1] = Offset.vector4_f32[1];
M.m[3][2] = Offset.vector4_f32[2];
M.m[3][3] = 1.0f;
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMVECTOR vTemp = _mm_and_ps(Offset,g_XMMask3);
vTemp = _mm_or_ps(vTemp,g_XMIdentityR3);
XMMATRIX M;
M.r[0] = g_XMIdentityR0;
M.r[1] = g_XMIdentityR1;
M.r[2] = g_XMIdentityR2;
M.r[3] = vTemp;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixScaling
(
FLOAT ScaleX,
FLOAT ScaleY,
FLOAT ScaleZ
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
M.r[0] = XMVectorSet(ScaleX, 0.0f, 0.0f, 0.0f);
M.r[1] = XMVectorSet(0.0f, ScaleY, 0.0f, 0.0f);
M.r[2] = XMVectorSet(0.0f, 0.0f, ScaleZ, 0.0f);
M.r[3] = g_XMIdentityR3.v;
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX M;
M.r[0] = _mm_set_ps( 0, 0, 0, ScaleX );
M.r[1] = _mm_set_ps( 0, 0, ScaleY, 0 );
M.r[2] = _mm_set_ps( 0, ScaleZ, 0, 0 );
M.r[3] = g_XMIdentityR3;
return M;
#elif defined(XM_NO_MISALIGNED_VECTOR_ACCESS)
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixScalingFromVector
(
FXMVECTOR Scale
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
M.m[0][0] = Scale.vector4_f32[0];
M.m[0][1] = 0.0f;
M.m[0][2] = 0.0f;
M.m[0][3] = 0.0f;
M.m[1][0] = 0.0f;
M.m[1][1] = Scale.vector4_f32[1];
M.m[1][2] = 0.0f;
M.m[1][3] = 0.0f;
M.m[2][0] = 0.0f;
M.m[2][1] = 0.0f;
M.m[2][2] = Scale.vector4_f32[2];
M.m[2][3] = 0.0f;
M.m[3][0] = 0.0f;
M.m[3][1] = 0.0f;
M.m[3][2] = 0.0f;
M.m[3][3] = 1.0f;
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX M;
M.r[0] = _mm_and_ps(Scale,g_XMMaskX);
M.r[1] = _mm_and_ps(Scale,g_XMMaskY);
M.r[2] = _mm_and_ps(Scale,g_XMMaskZ);
M.r[3] = g_XMIdentityR3;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMINLINE XMMATRIX XMMatrixRotationX
(
FLOAT Angle
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
FLOAT fSinAngle = sinf(Angle);
FLOAT fCosAngle = cosf(Angle);
M.m[0][0] = 1.0f;
M.m[0][1] = 0.0f;
M.m[0][2] = 0.0f;
M.m[0][3] = 0.0f;
M.m[1][0] = 0.0f;
M.m[1][1] = fCosAngle;
M.m[1][2] = fSinAngle;
M.m[1][3] = 0.0f;
M.m[2][0] = 0.0f;
M.m[2][1] = -fSinAngle;
M.m[2][2] = fCosAngle;
M.m[2][3] = 0.0f;
M.m[3][0] = 0.0f;
M.m[3][1] = 0.0f;
M.m[3][2] = 0.0f;
M.m[3][3] = 1.0f;
return M;
#elif defined(_XM_SSE_INTRINSICS_)
FLOAT SinAngle = sinf(Angle);
FLOAT CosAngle = cosf(Angle);
XMVECTOR vSin = _mm_set_ss(SinAngle);
XMVECTOR vCos = _mm_set_ss(CosAngle);
// x = 0,y = cos,z = sin, w = 0
vCos = _mm_shuffle_ps(vCos,vSin,_MM_SHUFFLE(3,0,0,3));
XMMATRIX M;
M.r[0] = g_XMIdentityR0;
M.r[1] = vCos;
// x = 0,y = sin,z = cos, w = 0
vCos = _mm_shuffle_ps(vCos,vCos,_MM_SHUFFLE(3,1,2,0));
// x = 0,y = -sin,z = cos, w = 0
vCos = _mm_mul_ps(vCos,g_XMNegateY);
M.r[2] = vCos;
M.r[3] = g_XMIdentityR3;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMINLINE XMMATRIX XMMatrixRotationY
(
FLOAT Angle
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
FLOAT fSinAngle = sinf(Angle);
FLOAT fCosAngle = cosf(Angle);
M.m[0][0] = fCosAngle;
M.m[0][1] = 0.0f;
M.m[0][2] = -fSinAngle;
M.m[0][3] = 0.0f;
M.m[1][0] = 0.0f;
M.m[1][1] = 1.0f;
M.m[1][2] = 0.0f;
M.m[1][3] = 0.0f;
M.m[2][0] = fSinAngle;
M.m[2][1] = 0.0f;
M.m[2][2] = fCosAngle;
M.m[2][3] = 0.0f;
M.m[3][0] = 0.0f;
M.m[3][1] = 0.0f;
M.m[3][2] = 0.0f;
M.m[3][3] = 1.0f;
return M;
#elif defined(_XM_SSE_INTRINSICS_)
FLOAT SinAngle = sinf(Angle);
FLOAT CosAngle = cosf(Angle);
XMVECTOR vSin = _mm_set_ss(SinAngle);
XMVECTOR vCos = _mm_set_ss(CosAngle);
// x = sin,y = 0,z = cos, w = 0
vSin = _mm_shuffle_ps(vSin,vCos,_MM_SHUFFLE(3,0,3,0));
XMMATRIX M;
M.r[2] = vSin;
M.r[1] = g_XMIdentityR1;
// x = cos,y = 0,z = sin, w = 0
vSin = _mm_shuffle_ps(vSin,vSin,_MM_SHUFFLE(3,0,1,2));
// x = cos,y = 0,z = -sin, w = 0
vSin = _mm_mul_ps(vSin,g_XMNegateZ);
M.r[0] = vSin;
M.r[3] = g_XMIdentityR3;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMINLINE XMMATRIX XMMatrixRotationZ
(
FLOAT Angle
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
FLOAT fSinAngle = sinf(Angle);
FLOAT fCosAngle = cosf(Angle);
M.m[0][0] = fCosAngle;
M.m[0][1] = fSinAngle;
M.m[0][2] = 0.0f;
M.m[0][3] = 0.0f;
M.m[1][0] = -fSinAngle;
M.m[1][1] = fCosAngle;
M.m[1][2] = 0.0f;
M.m[1][3] = 0.0f;
M.m[2][0] = 0.0f;
M.m[2][1] = 0.0f;
M.m[2][2] = 1.0f;
M.m[2][3] = 0.0f;
M.m[3][0] = 0.0f;
M.m[3][1] = 0.0f;
M.m[3][2] = 0.0f;
M.m[3][3] = 1.0f;
return M;
#elif defined(_XM_SSE_INTRINSICS_)
FLOAT SinAngle = sinf(Angle);
FLOAT CosAngle = cosf(Angle);
XMVECTOR vSin = _mm_set_ss(SinAngle);
XMVECTOR vCos = _mm_set_ss(CosAngle);
// x = cos,y = sin,z = 0, w = 0
vCos = _mm_unpacklo_ps(vCos,vSin);
XMMATRIX M;
M.r[0] = vCos;
// x = sin,y = cos,z = 0, w = 0
vCos = _mm_shuffle_ps(vCos,vCos,_MM_SHUFFLE(3,2,0,1));
// x = cos,y = -sin,z = 0, w = 0
vCos = _mm_mul_ps(vCos,g_XMNegateX);
M.r[1] = vCos;
M.r[2] = g_XMIdentityR2;
M.r[3] = g_XMIdentityR3;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMINLINE XMMATRIX XMMatrixRotationRollPitchYaw
(
FLOAT Pitch,
FLOAT Yaw,
FLOAT Roll
)
{
XMVECTOR Angles;
XMMATRIX M;
Angles = XMVectorSet(Pitch, Yaw, Roll, 0.0f);
M = XMMatrixRotationRollPitchYawFromVector(Angles);
return M;
}
//------------------------------------------------------------------------------
XMINLINE XMMATRIX XMMatrixRotationRollPitchYawFromVector
(
FXMVECTOR Angles // <Pitch, Yaw, Roll, undefined>
)
{
XMVECTOR Q;
XMMATRIX M;
Q = XMQuaternionRotationRollPitchYawFromVector(Angles);
M = XMMatrixRotationQuaternion(Q);
return M;
}
//------------------------------------------------------------------------------
XMINLINE XMMATRIX XMMatrixRotationNormal
(
FXMVECTOR NormalAxis,
FLOAT Angle
)
{
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR A;
XMVECTOR N0, N1;
XMVECTOR V0, V1, V2;
XMVECTOR R0, R1, R2;
XMVECTOR C0, C1, C2;
XMMATRIX M;
static CONST XMVECTORU32 SwizzleYZXW = {XM_PERMUTE_0Y, XM_PERMUTE_0Z, XM_PERMUTE_0X, XM_PERMUTE_0W};
static CONST XMVECTORU32 SwizzleZXYW = {XM_PERMUTE_0Z, XM_PERMUTE_0X, XM_PERMUTE_0Y, XM_PERMUTE_0W};
static CONST XMVECTORU32 Permute0Z1Y1Z0X = {XM_PERMUTE_0Z, XM_PERMUTE_1Y, XM_PERMUTE_1Z, XM_PERMUTE_0X};
static CONST XMVECTORU32 Permute0Y1X0Y1X = {XM_PERMUTE_0Y, XM_PERMUTE_1X, XM_PERMUTE_0Y, XM_PERMUTE_1X};
static CONST XMVECTORU32 Permute0X1X1Y0W = {XM_PERMUTE_0X, XM_PERMUTE_1X, XM_PERMUTE_1Y, XM_PERMUTE_0W};
static CONST XMVECTORU32 Permute1Z0Y1W0W = {XM_PERMUTE_1Z, XM_PERMUTE_0Y, XM_PERMUTE_1W, XM_PERMUTE_0W};
static CONST XMVECTORU32 Permute1X1Y0Z0W = {XM_PERMUTE_1X, XM_PERMUTE_1Y, XM_PERMUTE_0Z, XM_PERMUTE_0W};
FLOAT fSinAngle = sinf(Angle);
FLOAT fCosAngle = cosf(Angle);
A = XMVectorSet(fSinAngle, fCosAngle, 1.0f - fCosAngle, 0.0f);
C2 = XMVectorSplatZ(A);
C1 = XMVectorSplatY(A);
C0 = XMVectorSplatX(A);
N0 = XMVectorPermute(NormalAxis, NormalAxis, SwizzleYZXW.v);
N1 = XMVectorPermute(NormalAxis, NormalAxis, SwizzleZXYW.v);
V0 = XMVectorMultiply(C2, N0);
V0 = XMVectorMultiply(V0, N1);
R0 = XMVectorMultiply(C2, NormalAxis);
R0 = XMVectorMultiplyAdd(R0, NormalAxis, C1);
R1 = XMVectorMultiplyAdd(C0, NormalAxis, V0);
R2 = XMVectorNegativeMultiplySubtract(C0, NormalAxis, V0);
V0 = XMVectorSelect(A, R0, g_XMSelect1110.v);
V1 = XMVectorPermute(R1, R2, Permute0Z1Y1Z0X.v);
V2 = XMVectorPermute(R1, R2, Permute0Y1X0Y1X.v);
M.r[0] = XMVectorPermute(V0, V1, Permute0X1X1Y0W.v);
M.r[1] = XMVectorPermute(V0, V1, Permute1Z0Y1W0W.v);
M.r[2] = XMVectorPermute(V0, V2, Permute1X1Y0Z0W.v);
M.r[3] = g_XMIdentityR3.v;
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMVECTOR N0, N1;
XMVECTOR V0, V1, V2;
XMVECTOR R0, R1, R2;
XMVECTOR C0, C1, C2;
XMMATRIX M;
FLOAT fSinAngle = sinf(Angle);
FLOAT fCosAngle = cosf(Angle);
C2 = _mm_set_ps1(1.0f - fCosAngle);
C1 = _mm_set_ps1(fCosAngle);
C0 = _mm_set_ps1(fSinAngle);
N0 = _mm_shuffle_ps(NormalAxis,NormalAxis,_MM_SHUFFLE(3,0,2,1));
// N0 = XMVectorPermute(NormalAxis, NormalAxis, SwizzleYZXW);
N1 = _mm_shuffle_ps(NormalAxis,NormalAxis,_MM_SHUFFLE(3,1,0,2));
// N1 = XMVectorPermute(NormalAxis, NormalAxis, SwizzleZXYW);
V0 = _mm_mul_ps(C2, N0);
V0 = _mm_mul_ps(V0, N1);
R0 = _mm_mul_ps(C2, NormalAxis);
R0 = _mm_mul_ps(R0, NormalAxis);
R0 = _mm_add_ps(R0, C1);
R1 = _mm_mul_ps(C0, NormalAxis);
R1 = _mm_add_ps(R1, V0);
R2 = _mm_mul_ps(C0, NormalAxis);
R2 = _mm_sub_ps(V0,R2);
V0 = _mm_and_ps(R0,g_XMMask3);
// V0 = XMVectorSelect(A, R0, g_XMSelect1110);
V1 = _mm_shuffle_ps(R1,R2,_MM_SHUFFLE(2,1,2,0));
V1 = _mm_shuffle_ps(V1,V1,_MM_SHUFFLE(0,3,2,1));
// V1 = XMVectorPermute(R1, R2, Permute0Z1Y1Z0X);
V2 = _mm_shuffle_ps(R1,R2,_MM_SHUFFLE(0,0,1,1));
V2 = _mm_shuffle_ps(V2,V2,_MM_SHUFFLE(2,0,2,0));
// V2 = XMVectorPermute(R1, R2, Permute0Y1X0Y1X);
R2 = _mm_shuffle_ps(V0,V1,_MM_SHUFFLE(1,0,3,0));
R2 = _mm_shuffle_ps(R2,R2,_MM_SHUFFLE(1,3,2,0));
M.r[0] = R2;
// M.r[0] = XMVectorPermute(V0, V1, Permute0X1X1Y0W);
R2 = _mm_shuffle_ps(V0,V1,_MM_SHUFFLE(3,2,3,1));
R2 = _mm_shuffle_ps(R2,R2,_MM_SHUFFLE(1,3,0,2));
M.r[1] = R2;
// M.r[1] = XMVectorPermute(V0, V1, Permute1Z0Y1W0W);
V2 = _mm_shuffle_ps(V2,V0,_MM_SHUFFLE(3,2,1,0));
// R2 = _mm_shuffle_ps(R2,R2,_MM_SHUFFLE(3,2,1,0));
M.r[2] = V2;
// M.r[2] = XMVectorPermute(V0, V2, Permute1X1Y0Z0W);
M.r[3] = g_XMIdentityR3;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMINLINE XMMATRIX XMMatrixRotationAxis
(
FXMVECTOR Axis,
FLOAT Angle
)
{
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR Normal;
XMMATRIX M;
XMASSERT(!XMVector3Equal(Axis, XMVectorZero()));
XMASSERT(!XMVector3IsInfinite(Axis));
Normal = XMVector3Normalize(Axis);
M = XMMatrixRotationNormal(Normal, Angle);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMASSERT(!XMVector3Equal(Axis, XMVectorZero()));
XMASSERT(!XMVector3IsInfinite(Axis));
XMVECTOR Normal = XMVector3Normalize(Axis);
XMMATRIX M = XMMatrixRotationNormal(Normal, Angle);
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixRotationQuaternion
(
FXMVECTOR Quaternion
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
XMVECTOR Q0, Q1;
XMVECTOR V0, V1, V2;
XMVECTOR R0, R1, R2;
static CONST XMVECTOR Constant1110 = {1.0f, 1.0f, 1.0f, 0.0f};
static CONST XMVECTORU32 SwizzleXXYW = {XM_PERMUTE_0X, XM_PERMUTE_0X, XM_PERMUTE_0Y, XM_PERMUTE_0W};
static CONST XMVECTORU32 SwizzleZYZW = {XM_PERMUTE_0Z, XM_PERMUTE_0Y, XM_PERMUTE_0Z, XM_PERMUTE_0W};
static CONST XMVECTORU32 SwizzleYZXW = {XM_PERMUTE_0Y, XM_PERMUTE_0Z, XM_PERMUTE_0X, XM_PERMUTE_0W};
static CONST XMVECTORU32 Permute0Y0X0X1W = {XM_PERMUTE_0Y, XM_PERMUTE_0X, XM_PERMUTE_0X, XM_PERMUTE_1W};
static CONST XMVECTORU32 Permute0Z0Z0Y1W = {XM_PERMUTE_0Z, XM_PERMUTE_0Z, XM_PERMUTE_0Y, XM_PERMUTE_1W};
static CONST XMVECTORU32 Permute0Y1X1Y0Z = {XM_PERMUTE_0Y, XM_PERMUTE_1X, XM_PERMUTE_1Y, XM_PERMUTE_0Z};
static CONST XMVECTORU32 Permute0X1Z0X1Z = {XM_PERMUTE_0X, XM_PERMUTE_1Z, XM_PERMUTE_0X, XM_PERMUTE_1Z};
static CONST XMVECTORU32 Permute0X1X1Y0W = {XM_PERMUTE_0X, XM_PERMUTE_1X, XM_PERMUTE_1Y, XM_PERMUTE_0W};
static CONST XMVECTORU32 Permute1Z0Y1W0W = {XM_PERMUTE_1Z, XM_PERMUTE_0Y, XM_PERMUTE_1W, XM_PERMUTE_0W};
static CONST XMVECTORU32 Permute1X1Y0Z0W = {XM_PERMUTE_1X, XM_PERMUTE_1Y, XM_PERMUTE_0Z, XM_PERMUTE_0W};
Q0 = XMVectorAdd(Quaternion, Quaternion);
Q1 = XMVectorMultiply(Quaternion, Q0);
V0 = XMVectorPermute(Q1, Constant1110, Permute0Y0X0X1W.v);
V1 = XMVectorPermute(Q1, Constant1110, Permute0Z0Z0Y1W.v);
R0 = XMVectorSubtract(Constant1110, V0);
R0 = XMVectorSubtract(R0, V1);
V0 = XMVectorPermute(Quaternion, Quaternion, SwizzleXXYW.v);
V1 = XMVectorPermute(Q0, Q0, SwizzleZYZW.v);
V0 = XMVectorMultiply(V0, V1);
V1 = XMVectorSplatW(Quaternion);
V2 = XMVectorPermute(Q0, Q0, SwizzleYZXW.v);
V1 = XMVectorMultiply(V1, V2);
R1 = XMVectorAdd(V0, V1);
R2 = XMVectorSubtract(V0, V1);
V0 = XMVectorPermute(R1, R2, Permute0Y1X1Y0Z.v);
V1 = XMVectorPermute(R1, R2, Permute0X1Z0X1Z.v);
M.r[0] = XMVectorPermute(R0, V0, Permute0X1X1Y0W.v);
M.r[1] = XMVectorPermute(R0, V0, Permute1Z0Y1W0W.v);
M.r[2] = XMVectorPermute(R0, V1, Permute1X1Y0Z0W.v);
M.r[3] = g_XMIdentityR3.v;
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX M;
XMVECTOR Q0, Q1;
XMVECTOR V0, V1, V2;
XMVECTOR R0, R1, R2;
static CONST XMVECTORF32 Constant1110 = {1.0f, 1.0f, 1.0f, 0.0f};
Q0 = _mm_add_ps(Quaternion,Quaternion);
Q1 = _mm_mul_ps(Quaternion,Q0);
V0 = _mm_shuffle_ps(Q1,Q1,_MM_SHUFFLE(3,0,0,1));
V0 = _mm_and_ps(V0,g_XMMask3);
// V0 = XMVectorPermute(Q1, Constant1110,Permute0Y0X0X1W);
V1 = _mm_shuffle_ps(Q1,Q1,_MM_SHUFFLE(3,1,2,2));
V1 = _mm_and_ps(V1,g_XMMask3);
// V1 = XMVectorPermute(Q1, Constant1110,Permute0Z0Z0Y1W);
R0 = _mm_sub_ps(Constant1110,V0);
R0 = _mm_sub_ps(R0, V1);
V0 = _mm_shuffle_ps(Quaternion,Quaternion,_MM_SHUFFLE(3,1,0,0));
// V0 = XMVectorPermute(Quaternion, Quaternion,SwizzleXXYW);
V1 = _mm_shuffle_ps(Q0,Q0,_MM_SHUFFLE(3,2,1,2));
// V1 = XMVectorPermute(Q0, Q0,SwizzleZYZW);
V0 = _mm_mul_ps(V0, V1);
V1 = _mm_shuffle_ps(Quaternion,Quaternion,_MM_SHUFFLE(3,3,3,3));
// V1 = XMVectorSplatW(Quaternion);
V2 = _mm_shuffle_ps(Q0,Q0,_MM_SHUFFLE(3,0,2,1));
// V2 = XMVectorPermute(Q0, Q0,SwizzleYZXW);
V1 = _mm_mul_ps(V1, V2);
R1 = _mm_add_ps(V0, V1);
R2 = _mm_sub_ps(V0, V1);
V0 = _mm_shuffle_ps(R1,R2,_MM_SHUFFLE(1,0,2,1));
V0 = _mm_shuffle_ps(V0,V0,_MM_SHUFFLE(1,3,2,0));
// V0 = XMVectorPermute(R1, R2,Permute0Y1X1Y0Z);
V1 = _mm_shuffle_ps(R1,R2,_MM_SHUFFLE(2,2,0,0));
V1 = _mm_shuffle_ps(V1,V1,_MM_SHUFFLE(2,0,2,0));
// V1 = XMVectorPermute(R1, R2,Permute0X1Z0X1Z);
Q1 = _mm_shuffle_ps(R0,V0,_MM_SHUFFLE(1,0,3,0));
Q1 = _mm_shuffle_ps(Q1,Q1,_MM_SHUFFLE(1,3,2,0));
M.r[0] = Q1;
// M.r[0] = XMVectorPermute(R0, V0,Permute0X1X1Y0W);
Q1 = _mm_shuffle_ps(R0,V0,_MM_SHUFFLE(3,2,3,1));
Q1 = _mm_shuffle_ps(Q1,Q1,_MM_SHUFFLE(1,3,0,2));
M.r[1] = Q1;
// M.r[1] = XMVectorPermute(R0, V0,Permute1Z0Y1W0W);
Q1 = _mm_shuffle_ps(V1,R0,_MM_SHUFFLE(3,2,1,0));
M.r[2] = Q1;
// M.r[2] = XMVectorPermute(R0, V1,Permute1X1Y0Z0W);
M.r[3] = g_XMIdentityR3;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMINLINE XMMATRIX XMMatrixTransformation2D
(
FXMVECTOR ScalingOrigin,
FLOAT ScalingOrientation,
FXMVECTOR Scaling,
FXMVECTOR RotationOrigin,
FLOAT Rotation,
CXMVECTOR Translation
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
XMVECTOR VScaling;
XMVECTOR NegScalingOrigin;
XMVECTOR VScalingOrigin;
XMMATRIX MScalingOriginI;
XMMATRIX MScalingOrientation;
XMMATRIX MScalingOrientationT;
XMMATRIX MScaling;
XMVECTOR VRotationOrigin;
XMMATRIX MRotation;
XMVECTOR VTranslation;
// M = Inverse(MScalingOrigin) * Transpose(MScalingOrientation) * MScaling * MScalingOrientation *
// MScalingOrigin * Inverse(MRotationOrigin) * MRotation * MRotationOrigin * MTranslation;
VScalingOrigin = XMVectorSelect(g_XMSelect1100.v, ScalingOrigin, g_XMSelect1100.v);
NegScalingOrigin = XMVectorNegate(VScalingOrigin);
MScalingOriginI = XMMatrixTranslationFromVector(NegScalingOrigin);
MScalingOrientation = XMMatrixRotationZ(ScalingOrientation);
MScalingOrientationT = XMMatrixTranspose(MScalingOrientation);
VScaling = XMVectorSelect(g_XMOne.v, Scaling, g_XMSelect1100.v);
MScaling = XMMatrixScalingFromVector(VScaling);
VRotationOrigin = XMVectorSelect(g_XMSelect1100.v, RotationOrigin, g_XMSelect1100.v);
MRotation = XMMatrixRotationZ(Rotation);
VTranslation = XMVectorSelect(g_XMSelect1100.v, Translation,g_XMSelect1100.v);
M = XMMatrixMultiply(MScalingOriginI, MScalingOrientationT);
M = XMMatrixMultiply(M, MScaling);
M = XMMatrixMultiply(M, MScalingOrientation);
M.r[3] = XMVectorAdd(M.r[3], VScalingOrigin);
M.r[3] = XMVectorSubtract(M.r[3], VRotationOrigin);
M = XMMatrixMultiply(M, MRotation);
M.r[3] = XMVectorAdd(M.r[3], VRotationOrigin);
M.r[3] = XMVectorAdd(M.r[3], VTranslation);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX M;
XMVECTOR VScaling;
XMVECTOR NegScalingOrigin;
XMVECTOR VScalingOrigin;
XMMATRIX MScalingOriginI;
XMMATRIX MScalingOrientation;
XMMATRIX MScalingOrientationT;
XMMATRIX MScaling;
XMVECTOR VRotationOrigin;
XMMATRIX MRotation;
XMVECTOR VTranslation;
// M = Inverse(MScalingOrigin) * Transpose(MScalingOrientation) * MScaling * MScalingOrientation *
// MScalingOrigin * Inverse(MRotationOrigin) * MRotation * MRotationOrigin * MTranslation;
static const XMVECTORU32 Mask2 = {0xFFFFFFFF,0xFFFFFFFF,0,0};
static const XMVECTORF32 ZWOne = {0,0,1.0f,1.0f};
VScalingOrigin = _mm_and_ps(ScalingOrigin, Mask2);
NegScalingOrigin = XMVectorNegate(VScalingOrigin);
MScalingOriginI = XMMatrixTranslationFromVector(NegScalingOrigin);
MScalingOrientation = XMMatrixRotationZ(ScalingOrientation);
MScalingOrientationT = XMMatrixTranspose(MScalingOrientation);
VScaling = _mm_and_ps(Scaling, Mask2);
VScaling = _mm_or_ps(VScaling,ZWOne);
MScaling = XMMatrixScalingFromVector(VScaling);
VRotationOrigin = _mm_and_ps(RotationOrigin, Mask2);
MRotation = XMMatrixRotationZ(Rotation);
VTranslation = _mm_and_ps(Translation, Mask2);
M = XMMatrixMultiply(MScalingOriginI, MScalingOrientationT);
M = XMMatrixMultiply(M, MScaling);
M = XMMatrixMultiply(M, MScalingOrientation);
M.r[3] = XMVectorAdd(M.r[3], VScalingOrigin);
M.r[3] = XMVectorSubtract(M.r[3], VRotationOrigin);
M = XMMatrixMultiply(M, MRotation);
M.r[3] = XMVectorAdd(M.r[3], VRotationOrigin);
M.r[3] = XMVectorAdd(M.r[3], VTranslation);
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMINLINE XMMATRIX XMMatrixTransformation
(
FXMVECTOR ScalingOrigin,
FXMVECTOR ScalingOrientationQuaternion,
FXMVECTOR Scaling,
CXMVECTOR RotationOrigin,
CXMVECTOR RotationQuaternion,
CXMVECTOR Translation
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
XMVECTOR NegScalingOrigin;
XMVECTOR VScalingOrigin;
XMMATRIX MScalingOriginI;
XMMATRIX MScalingOrientation;
XMMATRIX MScalingOrientationT;
XMMATRIX MScaling;
XMVECTOR VRotationOrigin;
XMMATRIX MRotation;
XMVECTOR VTranslation;
// M = Inverse(MScalingOrigin) * Transpose(MScalingOrientation) * MScaling * MScalingOrientation *
// MScalingOrigin * Inverse(MRotationOrigin) * MRotation * MRotationOrigin * MTranslation;
VScalingOrigin = XMVectorSelect(g_XMSelect1110.v, ScalingOrigin, g_XMSelect1110.v);
NegScalingOrigin = XMVectorNegate(ScalingOrigin);
MScalingOriginI = XMMatrixTranslationFromVector(NegScalingOrigin);
MScalingOrientation = XMMatrixRotationQuaternion(ScalingOrientationQuaternion);
MScalingOrientationT = XMMatrixTranspose(MScalingOrientation);
MScaling = XMMatrixScalingFromVector(Scaling);
VRotationOrigin = XMVectorSelect(g_XMSelect1110.v, RotationOrigin, g_XMSelect1110.v);
MRotation = XMMatrixRotationQuaternion(RotationQuaternion);
VTranslation = XMVectorSelect(g_XMSelect1110.v, Translation, g_XMSelect1110.v);
M = XMMatrixMultiply(MScalingOriginI, MScalingOrientationT);
M = XMMatrixMultiply(M, MScaling);
M = XMMatrixMultiply(M, MScalingOrientation);
M.r[3] = XMVectorAdd(M.r[3], VScalingOrigin);
M.r[3] = XMVectorSubtract(M.r[3], VRotationOrigin);
M = XMMatrixMultiply(M, MRotation);
M.r[3] = XMVectorAdd(M.r[3], VRotationOrigin);
M.r[3] = XMVectorAdd(M.r[3], VTranslation);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX M;
XMVECTOR NegScalingOrigin;
XMVECTOR VScalingOrigin;
XMMATRIX MScalingOriginI;
XMMATRIX MScalingOrientation;
XMMATRIX MScalingOrientationT;
XMMATRIX MScaling;
XMVECTOR VRotationOrigin;
XMMATRIX MRotation;
XMVECTOR VTranslation;
// M = Inverse(MScalingOrigin) * Transpose(MScalingOrientation) * MScaling * MScalingOrientation *
// MScalingOrigin * Inverse(MRotationOrigin) * MRotation * MRotationOrigin * MTranslation;
VScalingOrigin = _mm_and_ps(ScalingOrigin,g_XMMask3);
NegScalingOrigin = XMVectorNegate(ScalingOrigin);
MScalingOriginI = XMMatrixTranslationFromVector(NegScalingOrigin);
MScalingOrientation = XMMatrixRotationQuaternion(ScalingOrientationQuaternion);
MScalingOrientationT = XMMatrixTranspose(MScalingOrientation);
MScaling = XMMatrixScalingFromVector(Scaling);
VRotationOrigin = _mm_and_ps(RotationOrigin,g_XMMask3);
MRotation = XMMatrixRotationQuaternion(RotationQuaternion);
VTranslation = _mm_and_ps(Translation,g_XMMask3);
M = XMMatrixMultiply(MScalingOriginI, MScalingOrientationT);
M = XMMatrixMultiply(M, MScaling);
M = XMMatrixMultiply(M, MScalingOrientation);
M.r[3] = XMVectorAdd(M.r[3], VScalingOrigin);
M.r[3] = XMVectorSubtract(M.r[3], VRotationOrigin);
M = XMMatrixMultiply(M, MRotation);
M.r[3] = XMVectorAdd(M.r[3], VRotationOrigin);
M.r[3] = XMVectorAdd(M.r[3], VTranslation);
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMINLINE XMMATRIX XMMatrixAffineTransformation2D
(
FXMVECTOR Scaling,
FXMVECTOR RotationOrigin,
FLOAT Rotation,
FXMVECTOR Translation
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
XMVECTOR VScaling;
XMMATRIX MScaling;
XMVECTOR VRotationOrigin;
XMMATRIX MRotation;
XMVECTOR VTranslation;
// M = MScaling * Inverse(MRotationOrigin) * MRotation * MRotationOrigin * MTranslation;
VScaling = XMVectorSelect(g_XMOne.v, Scaling, g_XMSelect1100.v);
MScaling = XMMatrixScalingFromVector(VScaling);
VRotationOrigin = XMVectorSelect(g_XMSelect1100.v, RotationOrigin, g_XMSelect1100.v);
MRotation = XMMatrixRotationZ(Rotation);
VTranslation = XMVectorSelect(g_XMSelect1100.v, Translation,g_XMSelect1100.v);
M = MScaling;
M.r[3] = XMVectorSubtract(M.r[3], VRotationOrigin);
M = XMMatrixMultiply(M, MRotation);
M.r[3] = XMVectorAdd(M.r[3], VRotationOrigin);
M.r[3] = XMVectorAdd(M.r[3], VTranslation);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX M;
XMVECTOR VScaling;
XMMATRIX MScaling;
XMVECTOR VRotationOrigin;
XMMATRIX MRotation;
XMVECTOR VTranslation;
static const XMVECTORU32 Mask2 = {0xFFFFFFFFU,0xFFFFFFFFU,0,0};
static const XMVECTORF32 ZW1 = {0,0,1.0f,1.0f};
// M = MScaling * Inverse(MRotationOrigin) * MRotation * MRotationOrigin * MTranslation;
VScaling = _mm_and_ps(Scaling, Mask2);
VScaling = _mm_or_ps(VScaling, ZW1);
MScaling = XMMatrixScalingFromVector(VScaling);
VRotationOrigin = _mm_and_ps(RotationOrigin, Mask2);
MRotation = XMMatrixRotationZ(Rotation);
VTranslation = _mm_and_ps(Translation, Mask2);
M = MScaling;
M.r[3] = _mm_sub_ps(M.r[3], VRotationOrigin);
M = XMMatrixMultiply(M, MRotation);
M.r[3] = _mm_add_ps(M.r[3], VRotationOrigin);
M.r[3] = _mm_add_ps(M.r[3], VTranslation);
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMINLINE XMMATRIX XMMatrixAffineTransformation
(
FXMVECTOR Scaling,
FXMVECTOR RotationOrigin,
FXMVECTOR RotationQuaternion,
CXMVECTOR Translation
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
XMMATRIX MScaling;
XMVECTOR VRotationOrigin;
XMMATRIX MRotation;
XMVECTOR VTranslation;
// M = MScaling * Inverse(MRotationOrigin) * MRotation * MRotationOrigin * MTranslation;
MScaling = XMMatrixScalingFromVector(Scaling);
VRotationOrigin = XMVectorSelect(g_XMSelect1110.v, RotationOrigin,g_XMSelect1110.v);
MRotation = XMMatrixRotationQuaternion(RotationQuaternion);
VTranslation = XMVectorSelect(g_XMSelect1110.v, Translation,g_XMSelect1110.v);
M = MScaling;
M.r[3] = XMVectorSubtract(M.r[3], VRotationOrigin);
M = XMMatrixMultiply(M, MRotation);
M.r[3] = XMVectorAdd(M.r[3], VRotationOrigin);
M.r[3] = XMVectorAdd(M.r[3], VTranslation);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX M;
XMMATRIX MScaling;
XMVECTOR VRotationOrigin;
XMMATRIX MRotation;
XMVECTOR VTranslation;
// M = MScaling * Inverse(MRotationOrigin) * MRotation * MRotationOrigin * MTranslation;
MScaling = XMMatrixScalingFromVector(Scaling);
VRotationOrigin = _mm_and_ps(RotationOrigin,g_XMMask3);
MRotation = XMMatrixRotationQuaternion(RotationQuaternion);
VTranslation = _mm_and_ps(Translation,g_XMMask3);
M = MScaling;
M.r[3] = _mm_sub_ps(M.r[3], VRotationOrigin);
M = XMMatrixMultiply(M, MRotation);
M.r[3] = _mm_add_ps(M.r[3], VRotationOrigin);
M.r[3] = _mm_add_ps(M.r[3], VTranslation);
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixReflect
(
FXMVECTOR ReflectionPlane
)
{
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR P;
XMVECTOR S;
XMVECTOR A, B, C, D;
XMMATRIX M;
static CONST XMVECTOR NegativeTwo = {-2.0f, -2.0f, -2.0f, 0.0f};
XMASSERT(!XMVector3Equal(ReflectionPlane, XMVectorZero()));
XMASSERT(!XMPlaneIsInfinite(ReflectionPlane));
P = XMPlaneNormalize(ReflectionPlane);
S = XMVectorMultiply(P, NegativeTwo);
A = XMVectorSplatX(P);
B = XMVectorSplatY(P);
C = XMVectorSplatZ(P);
D = XMVectorSplatW(P);
M.r[0] = XMVectorMultiplyAdd(A, S, g_XMIdentityR0.v);
M.r[1] = XMVectorMultiplyAdd(B, S, g_XMIdentityR1.v);
M.r[2] = XMVectorMultiplyAdd(C, S, g_XMIdentityR2.v);
M.r[3] = XMVectorMultiplyAdd(D, S, g_XMIdentityR3.v);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX M;
static CONST XMVECTORF32 NegativeTwo = {-2.0f, -2.0f, -2.0f, 0.0f};
XMASSERT(!XMVector3Equal(ReflectionPlane, XMVectorZero()));
XMASSERT(!XMPlaneIsInfinite(ReflectionPlane));
XMVECTOR P = XMPlaneNormalize(ReflectionPlane);
XMVECTOR S = _mm_mul_ps(P,NegativeTwo);
XMVECTOR X = _mm_shuffle_ps(P,P,_MM_SHUFFLE(0,0,0,0));
XMVECTOR Y = _mm_shuffle_ps(P,P,_MM_SHUFFLE(1,1,1,1));
XMVECTOR Z = _mm_shuffle_ps(P,P,_MM_SHUFFLE(2,2,2,2));
P = _mm_shuffle_ps(P,P,_MM_SHUFFLE(3,3,3,3));
X = _mm_mul_ps(X,S);
Y = _mm_mul_ps(Y,S);
Z = _mm_mul_ps(Z,S);
P = _mm_mul_ps(P,S);
X = _mm_add_ps(X,g_XMIdentityR0);
Y = _mm_add_ps(Y,g_XMIdentityR1);
Z = _mm_add_ps(Z,g_XMIdentityR2);
P = _mm_add_ps(P,g_XMIdentityR3);
M.r[0] = X;
M.r[1] = Y;
M.r[2] = Z;
M.r[3] = P;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixShadow
(
FXMVECTOR ShadowPlane,
FXMVECTOR LightPosition
)
{
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR P;
XMVECTOR Dot;
XMVECTOR A, B, C, D;
XMMATRIX M;
static CONST XMVECTORU32 Select0001 = {XM_SELECT_0, XM_SELECT_0, XM_SELECT_0, XM_SELECT_1};
XMASSERT(!XMVector3Equal(ShadowPlane, XMVectorZero()));
XMASSERT(!XMPlaneIsInfinite(ShadowPlane));
P = XMPlaneNormalize(ShadowPlane);
Dot = XMPlaneDot(P, LightPosition);
P = XMVectorNegate(P);
D = XMVectorSplatW(P);
C = XMVectorSplatZ(P);
B = XMVectorSplatY(P);
A = XMVectorSplatX(P);
Dot = XMVectorSelect(Select0001.v, Dot, Select0001.v);
M.r[3] = XMVectorMultiplyAdd(D, LightPosition, Dot);
Dot = XMVectorRotateLeft(Dot, 1);
M.r[2] = XMVectorMultiplyAdd(C, LightPosition, Dot);
Dot = XMVectorRotateLeft(Dot, 1);
M.r[1] = XMVectorMultiplyAdd(B, LightPosition, Dot);
Dot = XMVectorRotateLeft(Dot, 1);
M.r[0] = XMVectorMultiplyAdd(A, LightPosition, Dot);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX M;
XMASSERT(!XMVector3Equal(ShadowPlane, XMVectorZero()));
XMASSERT(!XMPlaneIsInfinite(ShadowPlane));
XMVECTOR P = XMPlaneNormalize(ShadowPlane);
XMVECTOR Dot = XMPlaneDot(P,LightPosition);
// Negate
P = _mm_mul_ps(P,g_XMNegativeOne);
XMVECTOR X = _mm_shuffle_ps(P,P,_MM_SHUFFLE(0,0,0,0));
XMVECTOR Y = _mm_shuffle_ps(P,P,_MM_SHUFFLE(1,1,1,1));
XMVECTOR Z = _mm_shuffle_ps(P,P,_MM_SHUFFLE(2,2,2,2));
P = _mm_shuffle_ps(P,P,_MM_SHUFFLE(3,3,3,3));
Dot = _mm_and_ps(Dot,g_XMMaskW);
X = _mm_mul_ps(X,LightPosition);
Y = _mm_mul_ps(Y,LightPosition);
Z = _mm_mul_ps(Z,LightPosition);
P = _mm_mul_ps(P,LightPosition);
P = _mm_add_ps(P,Dot);
Dot = _mm_shuffle_ps(Dot,Dot,_MM_SHUFFLE(0,3,2,1));
Z = _mm_add_ps(Z,Dot);
Dot = _mm_shuffle_ps(Dot,Dot,_MM_SHUFFLE(0,3,2,1));
Y = _mm_add_ps(Y,Dot);
Dot = _mm_shuffle_ps(Dot,Dot,_MM_SHUFFLE(0,3,2,1));
X = _mm_add_ps(X,Dot);
// Store the resulting matrix
M.r[0] = X;
M.r[1] = Y;
M.r[2] = Z;
M.r[3] = P;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
// View and projection initialization operations
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixLookAtLH
(
FXMVECTOR EyePosition,
FXMVECTOR FocusPosition,
FXMVECTOR UpDirection
)
{
XMVECTOR EyeDirection;
XMMATRIX M;
EyeDirection = XMVectorSubtract(FocusPosition, EyePosition);
M = XMMatrixLookToLH(EyePosition, EyeDirection, UpDirection);
return M;
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixLookAtRH
(
FXMVECTOR EyePosition,
FXMVECTOR FocusPosition,
FXMVECTOR UpDirection
)
{
XMVECTOR NegEyeDirection;
XMMATRIX M;
NegEyeDirection = XMVectorSubtract(EyePosition, FocusPosition);
M = XMMatrixLookToLH(EyePosition, NegEyeDirection, UpDirection);
return M;
}
//------------------------------------------------------------------------------
XMINLINE XMMATRIX XMMatrixLookToLH
(
FXMVECTOR EyePosition,
FXMVECTOR EyeDirection,
FXMVECTOR UpDirection
)
{
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR NegEyePosition;
XMVECTOR D0, D1, D2;
XMVECTOR R0, R1, R2;
XMMATRIX M;
XMASSERT(!XMVector3Equal(EyeDirection, XMVectorZero()));
XMASSERT(!XMVector3IsInfinite(EyeDirection));
XMASSERT(!XMVector3Equal(UpDirection, XMVectorZero()));
XMASSERT(!XMVector3IsInfinite(UpDirection));
R2 = XMVector3Normalize(EyeDirection);
R0 = XMVector3Cross(UpDirection, R2);
R0 = XMVector3Normalize(R0);
R1 = XMVector3Cross(R2, R0);
NegEyePosition = XMVectorNegate(EyePosition);
D0 = XMVector3Dot(R0, NegEyePosition);
D1 = XMVector3Dot(R1, NegEyePosition);
D2 = XMVector3Dot(R2, NegEyePosition);
M.r[0] = XMVectorSelect(D0, R0, g_XMSelect1110.v);
M.r[1] = XMVectorSelect(D1, R1, g_XMSelect1110.v);
M.r[2] = XMVectorSelect(D2, R2, g_XMSelect1110.v);
M.r[3] = g_XMIdentityR3.v;
M = XMMatrixTranspose(M);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX M;
XMASSERT(!XMVector3Equal(EyeDirection, XMVectorZero()));
XMASSERT(!XMVector3IsInfinite(EyeDirection));
XMASSERT(!XMVector3Equal(UpDirection, XMVectorZero()));
XMASSERT(!XMVector3IsInfinite(UpDirection));
XMVECTOR R2 = XMVector3Normalize(EyeDirection);
XMVECTOR R0 = XMVector3Cross(UpDirection, R2);
R0 = XMVector3Normalize(R0);
XMVECTOR R1 = XMVector3Cross(R2,R0);
XMVECTOR NegEyePosition = _mm_mul_ps(EyePosition,g_XMNegativeOne);
XMVECTOR D0 = XMVector3Dot(R0,NegEyePosition);
XMVECTOR D1 = XMVector3Dot(R1,NegEyePosition);
XMVECTOR D2 = XMVector3Dot(R2,NegEyePosition);
R0 = _mm_and_ps(R0,g_XMMask3);
R1 = _mm_and_ps(R1,g_XMMask3);
R2 = _mm_and_ps(R2,g_XMMask3);
D0 = _mm_and_ps(D0,g_XMMaskW);
D1 = _mm_and_ps(D1,g_XMMaskW);
D2 = _mm_and_ps(D2,g_XMMaskW);
D0 = _mm_or_ps(D0,R0);
D1 = _mm_or_ps(D1,R1);
D2 = _mm_or_ps(D2,R2);
M.r[0] = D0;
M.r[1] = D1;
M.r[2] = D2;
M.r[3] = g_XMIdentityR3;
M = XMMatrixTranspose(M);
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixLookToRH
(
FXMVECTOR EyePosition,
FXMVECTOR EyeDirection,
FXMVECTOR UpDirection
)
{
XMVECTOR NegEyeDirection;
XMMATRIX M;
NegEyeDirection = XMVectorNegate(EyeDirection);
M = XMMatrixLookToLH(EyePosition, NegEyeDirection, UpDirection);
return M;
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixPerspectiveLH
(
FLOAT ViewWidth,
FLOAT ViewHeight,
FLOAT NearZ,
FLOAT FarZ
)
{
#if defined(_XM_NO_INTRINSICS_)
FLOAT TwoNearZ, fRange;
XMMATRIX M;
XMASSERT(!XMScalarNearEqual(ViewWidth, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(ViewHeight, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
TwoNearZ = NearZ + NearZ;
fRange = FarZ / (FarZ - NearZ);
M.m[0][0] = TwoNearZ / ViewWidth;
M.m[0][1] = 0.0f;
M.m[0][2] = 0.0f;
M.m[0][3] = 0.0f;
M.m[1][0] = 0.0f;
M.m[1][1] = TwoNearZ / ViewHeight;
M.m[1][2] = 0.0f;
M.m[1][3] = 0.0f;
M.m[2][0] = 0.0f;
M.m[2][1] = 0.0f;
M.m[2][2] = fRange;
M.m[2][3] = 1.0f;
M.m[3][0] = 0.0f;
M.m[3][1] = 0.0f;
M.m[3][2] = -fRange * NearZ;
M.m[3][3] = 0.0f;
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMASSERT(!XMScalarNearEqual(ViewWidth, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(ViewHeight, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
XMMATRIX M;
FLOAT TwoNearZ = NearZ + NearZ;
FLOAT fRange = FarZ / (FarZ - NearZ);
// Note: This is recorded on the stack
XMFLOAT4A tmp(TwoNearZ / ViewWidth, TwoNearZ / ViewHeight, fRange, -fRange * NearZ);
// Copy from memory to SSE register
XMVECTOR vValues = XMLoadFloat4A(&tmp);
XMVECTOR vTemp = _mm_setzero_ps();
// Copy x only
vTemp = _mm_move_ss(vTemp,vValues);
// TwoNearZ / ViewWidth,0,0,0
M.r[0] = vTemp;
// 0,TwoNearZ / ViewHeight,0,0
vTemp = vValues;
vTemp = _mm_and_ps(vTemp,g_XMMaskY);
M.r[1] = vTemp;
// x=fRange,y=-fRange * NearZ,0,1.0f
vValues = _mm_shuffle_ps(vValues,g_XMIdentityR3,_MM_SHUFFLE(3,2,3,2));
// 0,0,fRange,1.0f
vTemp = _mm_setzero_ps();
vTemp = _mm_shuffle_ps(vTemp,vValues,_MM_SHUFFLE(3,0,0,0));
M.r[2] = vTemp;
// 0,0,-fRange * NearZ,0
vTemp = _mm_shuffle_ps(vTemp,vValues,_MM_SHUFFLE(2,1,0,0));
M.r[3] = vTemp;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixPerspectiveRH
(
FLOAT ViewWidth,
FLOAT ViewHeight,
FLOAT NearZ,
FLOAT FarZ
)
{
#if defined(_XM_NO_INTRINSICS_)
FLOAT TwoNearZ, fRange;
XMMATRIX M;
XMASSERT(!XMScalarNearEqual(ViewWidth, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(ViewHeight, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
TwoNearZ = NearZ + NearZ;
fRange = FarZ / (NearZ - FarZ);
M.m[0][0] = TwoNearZ / ViewWidth;
M.m[0][1] = 0.0f;
M.m[0][2] = 0.0f;
M.m[0][3] = 0.0f;
M.m[1][0] = 0.0f;
M.m[1][1] = TwoNearZ / ViewHeight;
M.m[1][2] = 0.0f;
M.m[1][3] = 0.0f;
M.m[2][0] = 0.0f;
M.m[2][1] = 0.0f;
M.m[2][2] = fRange;
M.m[2][3] = -1.0f;
M.m[3][0] = 0.0f;
M.m[3][1] = 0.0f;
M.m[3][2] = fRange * NearZ;
M.m[3][3] = 0.0f;
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMASSERT(!XMScalarNearEqual(ViewWidth, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(ViewHeight, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
XMMATRIX M;
FLOAT TwoNearZ = NearZ + NearZ;
FLOAT fRange = FarZ / (NearZ-FarZ);
// Note: This is recorded on the stack
XMFLOAT4A tmp(TwoNearZ / ViewWidth, TwoNearZ / ViewHeight, fRange, fRange * NearZ);
// Copy from memory to SSE register
XMVECTOR vValues = XMLoadFloat4A(&tmp);
XMVECTOR vTemp = _mm_setzero_ps();
// Copy x only
vTemp = _mm_move_ss(vTemp,vValues);
// TwoNearZ / ViewWidth,0,0,0
M.r[0] = vTemp;
// 0,TwoNearZ / ViewHeight,0,0
vTemp = vValues;
vTemp = _mm_and_ps(vTemp,g_XMMaskY);
M.r[1] = vTemp;
// x=fRange,y=-fRange * NearZ,0,-1.0f
vValues = _mm_shuffle_ps(vValues,g_XMNegIdentityR3,_MM_SHUFFLE(3,2,3,2));
// 0,0,fRange,-1.0f
vTemp = _mm_setzero_ps();
vTemp = _mm_shuffle_ps(vTemp,vValues,_MM_SHUFFLE(3,0,0,0));
M.r[2] = vTemp;
// 0,0,-fRange * NearZ,0
vTemp = _mm_shuffle_ps(vTemp,vValues,_MM_SHUFFLE(2,1,0,0));
M.r[3] = vTemp;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixPerspectiveFovLH
(
FLOAT FovAngleY,
FLOAT AspectRatio,
FLOAT NearZ,
FLOAT FarZ
)
{
#if defined(_XM_NO_INTRINSICS_)
FLOAT SinFov;
FLOAT CosFov;
FLOAT Height;
FLOAT Width;
XMMATRIX M;
XMASSERT(!XMScalarNearEqual(FovAngleY, 0.0f, 0.00001f * 2.0f));
XMASSERT(!XMScalarNearEqual(AspectRatio, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
XMScalarSinCos(&SinFov, &CosFov, 0.5f * FovAngleY);
Height = CosFov / SinFov;
Width = Height / AspectRatio;
M.r[0] = XMVectorSet(Width, 0.0f, 0.0f, 0.0f);
M.r[1] = XMVectorSet(0.0f, Height, 0.0f, 0.0f);
M.r[2] = XMVectorSet(0.0f, 0.0f, FarZ / (FarZ - NearZ), 1.0f);
M.r[3] = XMVectorSet(0.0f, 0.0f, -M.r[2].vector4_f32[2] * NearZ, 0.0f);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMASSERT(!XMScalarNearEqual(FovAngleY, 0.0f, 0.00001f * 2.0f));
XMASSERT(!XMScalarNearEqual(AspectRatio, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
XMMATRIX M;
FLOAT SinFov;
FLOAT CosFov;
XMScalarSinCos(&SinFov, &CosFov, 0.5f * FovAngleY);
FLOAT fRange = FarZ / (FarZ-NearZ);
// Note: This is recorded on the stack
FLOAT Height = CosFov / SinFov;
XMFLOAT4A tmp(Height / AspectRatio, Height, fRange, -fRange * NearZ);
// Copy from memory to SSE register
XMVECTOR vValues = XMLoadFloat4A(&tmp);
XMVECTOR vTemp = _mm_setzero_ps();
// Copy x only
vTemp = _mm_move_ss(vTemp,vValues);
// CosFov / SinFov,0,0,0
M.r[0] = vTemp;
// 0,Height / AspectRatio,0,0
vTemp = vValues;
vTemp = _mm_and_ps(vTemp,g_XMMaskY);
M.r[1] = vTemp;
// x=fRange,y=-fRange * NearZ,0,1.0f
vTemp = _mm_setzero_ps();
vValues = _mm_shuffle_ps(vValues,g_XMIdentityR3,_MM_SHUFFLE(3,2,3,2));
// 0,0,fRange,1.0f
vTemp = _mm_shuffle_ps(vTemp,vValues,_MM_SHUFFLE(3,0,0,0));
M.r[2] = vTemp;
// 0,0,-fRange * NearZ,0.0f
vTemp = _mm_shuffle_ps(vTemp,vValues,_MM_SHUFFLE(2,1,0,0));
M.r[3] = vTemp;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixPerspectiveFovRH
(
FLOAT FovAngleY,
FLOAT AspectRatio,
FLOAT NearZ,
FLOAT FarZ
)
{
#if defined(_XM_NO_INTRINSICS_)
FLOAT SinFov;
FLOAT CosFov;
FLOAT Height;
FLOAT Width;
XMMATRIX M;
XMASSERT(!XMScalarNearEqual(FovAngleY, 0.0f, 0.00001f * 2.0f));
XMASSERT(!XMScalarNearEqual(AspectRatio, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
XMScalarSinCos(&SinFov, &CosFov, 0.5f * FovAngleY);
Height = CosFov / SinFov;
Width = Height / AspectRatio;
M.r[0] = XMVectorSet(Width, 0.0f, 0.0f, 0.0f);
M.r[1] = XMVectorSet(0.0f, Height, 0.0f, 0.0f);
M.r[2] = XMVectorSet(0.0f, 0.0f, FarZ / (NearZ - FarZ), -1.0f);
M.r[3] = XMVectorSet(0.0f, 0.0f, M.r[2].vector4_f32[2] * NearZ, 0.0f);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMASSERT(!XMScalarNearEqual(FovAngleY, 0.0f, 0.00001f * 2.0f));
XMASSERT(!XMScalarNearEqual(AspectRatio, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
XMMATRIX M;
FLOAT SinFov;
FLOAT CosFov;
XMScalarSinCos(&SinFov, &CosFov, 0.5f * FovAngleY);
FLOAT fRange = FarZ / (NearZ-FarZ);
// Note: This is recorded on the stack
FLOAT Height = CosFov / SinFov;
XMFLOAT4A tmp(Height / AspectRatio, Height, fRange, fRange * NearZ);
// Copy from memory to SSE register
XMVECTOR vValues = XMLoadFloat4A(&tmp);
XMVECTOR vTemp = _mm_setzero_ps();
// Copy x only
vTemp = _mm_move_ss(vTemp,vValues);
// CosFov / SinFov,0,0,0
M.r[0] = vTemp;
// 0,Height / AspectRatio,0,0
vTemp = vValues;
vTemp = _mm_and_ps(vTemp,g_XMMaskY);
M.r[1] = vTemp;
// x=fRange,y=-fRange * NearZ,0,-1.0f
vTemp = _mm_setzero_ps();
vValues = _mm_shuffle_ps(vValues,g_XMNegIdentityR3,_MM_SHUFFLE(3,2,3,2));
// 0,0,fRange,-1.0f
vTemp = _mm_shuffle_ps(vTemp,vValues,_MM_SHUFFLE(3,0,0,0));
M.r[2] = vTemp;
// 0,0,fRange * NearZ,0.0f
vTemp = _mm_shuffle_ps(vTemp,vValues,_MM_SHUFFLE(2,1,0,0));
M.r[3] = vTemp;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixPerspectiveOffCenterLH
(
FLOAT ViewLeft,
FLOAT ViewRight,
FLOAT ViewBottom,
FLOAT ViewTop,
FLOAT NearZ,
FLOAT FarZ
)
{
#if defined(_XM_NO_INTRINSICS_)
FLOAT TwoNearZ;
FLOAT ReciprocalWidth;
FLOAT ReciprocalHeight;
XMMATRIX M;
XMASSERT(!XMScalarNearEqual(ViewRight, ViewLeft, 0.00001f));
XMASSERT(!XMScalarNearEqual(ViewTop, ViewBottom, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
TwoNearZ = NearZ + NearZ;
ReciprocalWidth = 1.0f / (ViewRight - ViewLeft);
ReciprocalHeight = 1.0f / (ViewTop - ViewBottom);
M.r[0] = XMVectorSet(TwoNearZ * ReciprocalWidth, 0.0f, 0.0f, 0.0f);
M.r[1] = XMVectorSet(0.0f, TwoNearZ * ReciprocalHeight, 0.0f, 0.0f);
M.r[2] = XMVectorSet(-(ViewLeft + ViewRight) * ReciprocalWidth,
-(ViewTop + ViewBottom) * ReciprocalHeight,
FarZ / (FarZ - NearZ),
1.0f);
M.r[3] = XMVectorSet(0.0f, 0.0f, -M.r[2].vector4_f32[2] * NearZ, 0.0f);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMASSERT(!XMScalarNearEqual(ViewRight, ViewLeft, 0.00001f));
XMASSERT(!XMScalarNearEqual(ViewTop, ViewBottom, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
XMMATRIX M;
FLOAT TwoNearZ = NearZ+NearZ;
FLOAT ReciprocalWidth = 1.0f / (ViewRight - ViewLeft);
FLOAT ReciprocalHeight = 1.0f / (ViewTop - ViewBottom);
FLOAT fRange = FarZ / (FarZ-NearZ);
// Note: This is recorded on the stack
XMFLOAT4A tmp(TwoNearZ*ReciprocalWidth, TwoNearZ*ReciprocalHeight, -fRange * NearZ, 0);
// Copy from memory to SSE register
XMVECTOR vValues = XMLoadFloat4A(&tmp);
XMVECTOR vTemp = _mm_setzero_ps();
// Copy x only
vTemp = _mm_move_ss(vTemp,vValues);
// TwoNearZ*ReciprocalWidth,0,0,0
M.r[0] = vTemp;
// 0,TwoNearZ*ReciprocalHeight,0,0
vTemp = vValues;
vTemp = _mm_and_ps(vTemp,g_XMMaskY);
M.r[1] = vTemp;
// 0,0,fRange,1.0f
M.m[2][0] = -(ViewLeft + ViewRight) * ReciprocalWidth;
M.m[2][1] = -(ViewTop + ViewBottom) * ReciprocalHeight;
M.m[2][2] = fRange;
M.m[2][3] = 1.0f;
// 0,0,-fRange * NearZ,0.0f
vValues = _mm_and_ps(vValues,g_XMMaskZ);
M.r[3] = vValues;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixPerspectiveOffCenterRH
(
FLOAT ViewLeft,
FLOAT ViewRight,
FLOAT ViewBottom,
FLOAT ViewTop,
FLOAT NearZ,
FLOAT FarZ
)
{
#if defined(_XM_NO_INTRINSICS_)
FLOAT TwoNearZ;
FLOAT ReciprocalWidth;
FLOAT ReciprocalHeight;
XMMATRIX M;
XMASSERT(!XMScalarNearEqual(ViewRight, ViewLeft, 0.00001f));
XMASSERT(!XMScalarNearEqual(ViewTop, ViewBottom, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
TwoNearZ = NearZ + NearZ;
ReciprocalWidth = 1.0f / (ViewRight - ViewLeft);
ReciprocalHeight = 1.0f / (ViewTop - ViewBottom);
M.r[0] = XMVectorSet(TwoNearZ * ReciprocalWidth, 0.0f, 0.0f, 0.0f);
M.r[1] = XMVectorSet(0.0f, TwoNearZ * ReciprocalHeight, 0.0f, 0.0f);
M.r[2] = XMVectorSet((ViewLeft + ViewRight) * ReciprocalWidth,
(ViewTop + ViewBottom) * ReciprocalHeight,
FarZ / (NearZ - FarZ),
-1.0f);
M.r[3] = XMVectorSet(0.0f, 0.0f, M.r[2].vector4_f32[2] * NearZ, 0.0f);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMASSERT(!XMScalarNearEqual(ViewRight, ViewLeft, 0.00001f));
XMASSERT(!XMScalarNearEqual(ViewTop, ViewBottom, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
XMMATRIX M;
FLOAT TwoNearZ = NearZ+NearZ;
FLOAT ReciprocalWidth = 1.0f / (ViewRight - ViewLeft);
FLOAT ReciprocalHeight = 1.0f / (ViewTop - ViewBottom);
FLOAT fRange = FarZ / (NearZ-FarZ);
// Note: This is recorded on the stack
XMFLOAT4A tmp(TwoNearZ*ReciprocalWidth, TwoNearZ*ReciprocalHeight, fRange * NearZ, 0);
// Copy from memory to SSE register
XMVECTOR vValues = XMLoadFloat4A(&tmp);
XMVECTOR vTemp = _mm_setzero_ps();
// Copy x only
vTemp = _mm_move_ss(vTemp,vValues);
// TwoNearZ*ReciprocalWidth,0,0,0
M.r[0] = vTemp;
// 0,TwoNearZ*ReciprocalHeight,0,0
vTemp = vValues;
vTemp = _mm_and_ps(vTemp,g_XMMaskY);
M.r[1] = vTemp;
// 0,0,fRange,1.0f
M.m[2][0] = (ViewLeft + ViewRight) * ReciprocalWidth;
M.m[2][1] = (ViewTop + ViewBottom) * ReciprocalHeight;
M.m[2][2] = fRange;
M.m[2][3] = -1.0f;
// 0,0,-fRange * NearZ,0.0f
vValues = _mm_and_ps(vValues,g_XMMaskZ);
M.r[3] = vValues;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixOrthographicLH
(
FLOAT ViewWidth,
FLOAT ViewHeight,
FLOAT NearZ,
FLOAT FarZ
)
{
#if defined(_XM_NO_INTRINSICS_)
FLOAT fRange;
XMMATRIX M;
XMASSERT(!XMScalarNearEqual(ViewWidth, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(ViewHeight, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
fRange = 1.0f / (FarZ-NearZ);
M.r[0] = XMVectorSet(2.0f / ViewWidth, 0.0f, 0.0f, 0.0f);
M.r[1] = XMVectorSet(0.0f, 2.0f / ViewHeight, 0.0f, 0.0f);
M.r[2] = XMVectorSet(0.0f, 0.0f, fRange, 0.0f);
M.r[3] = XMVectorSet(0.0f, 0.0f, -fRange * NearZ, 1.0f);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMASSERT(!XMScalarNearEqual(ViewWidth, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(ViewHeight, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
XMMATRIX M;
FLOAT fRange = 1.0f / (FarZ-NearZ);
// Note: This is recorded on the stack
XMFLOAT4A tmp(2.0f / ViewWidth, 2.0f / ViewHeight, fRange, -fRange * NearZ);
// Copy from memory to SSE register
XMVECTOR vValues = XMLoadFloat4A(&tmp);
XMVECTOR vTemp = _mm_setzero_ps();
// Copy x only
vTemp = _mm_move_ss(vTemp,vValues);
// 2.0f / ViewWidth,0,0,0
M.r[0] = vTemp;
// 0,2.0f / ViewHeight,0,0
vTemp = vValues;
vTemp = _mm_and_ps(vTemp,g_XMMaskY);
M.r[1] = vTemp;
// x=fRange,y=-fRange * NearZ,0,1.0f
vTemp = _mm_setzero_ps();
vValues = _mm_shuffle_ps(vValues,g_XMIdentityR3,_MM_SHUFFLE(3,2,3,2));
// 0,0,fRange,0.0f
vTemp = _mm_shuffle_ps(vTemp,vValues,_MM_SHUFFLE(2,0,0,0));
M.r[2] = vTemp;
// 0,0,-fRange * NearZ,1.0f
vTemp = _mm_shuffle_ps(vTemp,vValues,_MM_SHUFFLE(3,1,0,0));
M.r[3] = vTemp;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixOrthographicRH
(
FLOAT ViewWidth,
FLOAT ViewHeight,
FLOAT NearZ,
FLOAT FarZ
)
{
#if defined(_XM_NO_INTRINSICS_)
XMMATRIX M;
XMASSERT(!XMScalarNearEqual(ViewWidth, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(ViewHeight, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
M.r[0] = XMVectorSet(2.0f / ViewWidth, 0.0f, 0.0f, 0.0f);
M.r[1] = XMVectorSet(0.0f, 2.0f / ViewHeight, 0.0f, 0.0f);
M.r[2] = XMVectorSet(0.0f, 0.0f, 1.0f / (NearZ - FarZ), 0.0f);
M.r[3] = XMVectorSet(0.0f, 0.0f, M.r[2].vector4_f32[2] * NearZ, 1.0f);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMASSERT(!XMScalarNearEqual(ViewWidth, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(ViewHeight, 0.0f, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
XMMATRIX M;
FLOAT fRange = 1.0f / (NearZ-FarZ);
// Note: This is recorded on the stack
XMFLOAT4A tmp(2.0f / ViewWidth, 2.0f / ViewHeight, fRange, fRange * NearZ);
// Copy from memory to SSE register
XMVECTOR vValues = XMLoadFloat4A(&tmp);
XMVECTOR vTemp = _mm_setzero_ps();
// Copy x only
vTemp = _mm_move_ss(vTemp,vValues);
// 2.0f / ViewWidth,0,0,0
M.r[0] = vTemp;
// 0,2.0f / ViewHeight,0,0
vTemp = vValues;
vTemp = _mm_and_ps(vTemp,g_XMMaskY);
M.r[1] = vTemp;
// x=fRange,y=fRange * NearZ,0,1.0f
vTemp = _mm_setzero_ps();
vValues = _mm_shuffle_ps(vValues,g_XMIdentityR3,_MM_SHUFFLE(3,2,3,2));
// 0,0,fRange,0.0f
vTemp = _mm_shuffle_ps(vTemp,vValues,_MM_SHUFFLE(2,0,0,0));
M.r[2] = vTemp;
// 0,0,fRange * NearZ,1.0f
vTemp = _mm_shuffle_ps(vTemp,vValues,_MM_SHUFFLE(3,1,0,0));
M.r[3] = vTemp;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixOrthographicOffCenterLH
(
FLOAT ViewLeft,
FLOAT ViewRight,
FLOAT ViewBottom,
FLOAT ViewTop,
FLOAT NearZ,
FLOAT FarZ
)
{
#if defined(_XM_NO_INTRINSICS_)
FLOAT ReciprocalWidth;
FLOAT ReciprocalHeight;
XMMATRIX M;
XMASSERT(!XMScalarNearEqual(ViewRight, ViewLeft, 0.00001f));
XMASSERT(!XMScalarNearEqual(ViewTop, ViewBottom, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
ReciprocalWidth = 1.0f / (ViewRight - ViewLeft);
ReciprocalHeight = 1.0f / (ViewTop - ViewBottom);
M.r[0] = XMVectorSet(ReciprocalWidth + ReciprocalWidth, 0.0f, 0.0f, 0.0f);
M.r[1] = XMVectorSet(0.0f, ReciprocalHeight + ReciprocalHeight, 0.0f, 0.0f);
M.r[2] = XMVectorSet(0.0f, 0.0f, 1.0f / (FarZ - NearZ), 0.0f);
M.r[3] = XMVectorSet(-(ViewLeft + ViewRight) * ReciprocalWidth,
-(ViewTop + ViewBottom) * ReciprocalHeight,
-M.r[2].vector4_f32[2] * NearZ,
1.0f);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX M;
FLOAT fReciprocalWidth = 1.0f / (ViewRight - ViewLeft);
FLOAT fReciprocalHeight = 1.0f / (ViewTop - ViewBottom);
FLOAT fRange = 1.0f / (FarZ-NearZ);
// Note: This is recorded on the stack
XMFLOAT4A tmp(fReciprocalWidth, fReciprocalHeight, fRange, 1.0f);
XMFLOAT4A tmp2(-(ViewLeft + ViewRight), -(ViewTop + ViewBottom), -NearZ, 1.0f);
// Copy from memory to SSE register
XMVECTOR vValues = XMLoadFloat4A(&tmp);
XMVECTOR rMem2 = XMLoadFloat4A(&tmp2);
XMVECTOR vTemp = _mm_setzero_ps();
// Copy x only
vTemp = _mm_move_ss(vTemp,vValues);
// fReciprocalWidth*2,0,0,0
vTemp = _mm_add_ss(vTemp,vTemp);
M.r[0] = vTemp;
// 0,fReciprocalHeight*2,0,0
vTemp = vValues;
vTemp = _mm_and_ps(vTemp,g_XMMaskY);
vTemp = _mm_add_ps(vTemp,vTemp);
M.r[1] = vTemp;
// 0,0,fRange,0.0f
vTemp = vValues;
vTemp = _mm_and_ps(vTemp,g_XMMaskZ);
M.r[2] = vTemp;
// -(ViewLeft + ViewRight)*fReciprocalWidth,-(ViewTop + ViewBottom)*fReciprocalHeight,fRange*-NearZ,1.0f
vValues = _mm_mul_ps(vValues,rMem2);
M.r[3] = vValues;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
//------------------------------------------------------------------------------
XMFINLINE XMMATRIX XMMatrixOrthographicOffCenterRH
(
FLOAT ViewLeft,
FLOAT ViewRight,
FLOAT ViewBottom,
FLOAT ViewTop,
FLOAT NearZ,
FLOAT FarZ
)
{
#if defined(_XM_NO_INTRINSICS_)
FLOAT ReciprocalWidth;
FLOAT ReciprocalHeight;
XMMATRIX M;
XMASSERT(!XMScalarNearEqual(ViewRight, ViewLeft, 0.00001f));
XMASSERT(!XMScalarNearEqual(ViewTop, ViewBottom, 0.00001f));
XMASSERT(!XMScalarNearEqual(FarZ, NearZ, 0.00001f));
ReciprocalWidth = 1.0f / (ViewRight - ViewLeft);
ReciprocalHeight = 1.0f / (ViewTop - ViewBottom);
M.r[0] = XMVectorSet(ReciprocalWidth + ReciprocalWidth, 0.0f, 0.0f, 0.0f);
M.r[1] = XMVectorSet(0.0f, ReciprocalHeight + ReciprocalHeight, 0.0f, 0.0f);
M.r[2] = XMVectorSet(0.0f, 0.0f, 1.0f / (NearZ - FarZ), 0.0f);
M.r[3] = XMVectorSet(-(ViewLeft + ViewRight) * ReciprocalWidth,
-(ViewTop + ViewBottom) * ReciprocalHeight,
M.r[2].vector4_f32[2] * NearZ,
1.0f);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMMATRIX M;
FLOAT fReciprocalWidth = 1.0f / (ViewRight - ViewLeft);
FLOAT fReciprocalHeight = 1.0f / (ViewTop - ViewBottom);
FLOAT fRange = 1.0f / (NearZ-FarZ);
// Note: This is recorded on the stack
XMFLOAT4A tmp(fReciprocalWidth, fReciprocalHeight, fRange, 1.0f);
XMFLOAT4A tmp2(-(ViewLeft + ViewRight), -(ViewTop + ViewBottom), NearZ, 1.0f);
// Copy from memory to SSE register
XMVECTOR vValues = XMLoadFloat4A(&tmp);
XMVECTOR rMem2 = XMLoadFloat4A(&tmp2);
XMVECTOR vTemp = _mm_setzero_ps();
// Copy x only
vTemp = _mm_move_ss(vTemp,vValues);
// fReciprocalWidth*2,0,0,0
vTemp = _mm_add_ss(vTemp,vTemp);
M.r[0] = vTemp;
// 0,fReciprocalHeight*2,0,0
vTemp = vValues;
vTemp = _mm_and_ps(vTemp,g_XMMaskY);
vTemp = _mm_add_ps(vTemp,vTemp);
M.r[1] = vTemp;
// 0,0,fRange,0.0f
vTemp = vValues;
vTemp = _mm_and_ps(vTemp,g_XMMaskZ);
M.r[2] = vTemp;
// -(ViewLeft + ViewRight)*fReciprocalWidth,-(ViewTop + ViewBottom)*fReciprocalHeight,fRange*-NearZ,1.0f
vValues = _mm_mul_ps(vValues,rMem2);
M.r[3] = vValues;
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}
#ifdef __cplusplus
/****************************************************************************
*
* XMMATRIX operators and methods
*
****************************************************************************/
//------------------------------------------------------------------------------
XMFINLINE _XMMATRIX::_XMMATRIX
(
FXMVECTOR R0,
FXMVECTOR R1,
FXMVECTOR R2,
CXMVECTOR R3
)
{
r[0] = R0;
r[1] = R1;
r[2] = R2;
r[3] = R3;
}
//------------------------------------------------------------------------------
XMFINLINE _XMMATRIX::_XMMATRIX
(
FLOAT m00, FLOAT m01, FLOAT m02, FLOAT m03,
FLOAT m10, FLOAT m11, FLOAT m12, FLOAT m13,
FLOAT m20, FLOAT m21, FLOAT m22, FLOAT m23,
FLOAT m30, FLOAT m31, FLOAT m32, FLOAT m33
)
{
r[0] = XMVectorSet(m00, m01, m02, m03);
r[1] = XMVectorSet(m10, m11, m12, m13);
r[2] = XMVectorSet(m20, m21, m22, m23);
r[3] = XMVectorSet(m30, m31, m32, m33);
}
//------------------------------------------------------------------------------
XMFINLINE _XMMATRIX::_XMMATRIX
(
CONST FLOAT* pArray
)
{
r[0] = XMLoadFloat4((XMFLOAT4*)pArray);
r[1] = XMLoadFloat4((XMFLOAT4*)(pArray + 4));
r[2] = XMLoadFloat4((XMFLOAT4*)(pArray + 8));
r[3] = XMLoadFloat4((XMFLOAT4*)(pArray + 12));
}
//------------------------------------------------------------------------------
XMFINLINE _XMMATRIX& _XMMATRIX::operator=
(
CONST _XMMATRIX& M
)
{
r[0] = M.r[0];
r[1] = M.r[1];
r[2] = M.r[2];
r[3] = M.r[3];
return *this;
}
//------------------------------------------------------------------------------
#ifndef XM_NO_OPERATOR_OVERLOADS
#if !defined(_XBOX_VER) && defined(_XM_ISVS2005_) && defined(_XM_X64_)
#pragma warning(push)
#pragma warning(disable : 4328)
#endif
XMFINLINE _XMMATRIX& _XMMATRIX::operator*=
(
CONST _XMMATRIX& M
)
{
*this = XMMatrixMultiply(*this, M);
return *this;
}
//------------------------------------------------------------------------------
XMFINLINE _XMMATRIX _XMMATRIX::operator*
(
CONST _XMMATRIX& M
) CONST
{
return XMMatrixMultiply(*this, M);
}
#if !defined(_XBOX_VER) && defined(_XM_ISVS2005_) && defined(_XM_X64_)
#pragma warning(pop)
#endif
#endif // !XM_NO_OPERATOR_OVERLOADS
/****************************************************************************
*
* XMFLOAT3X3 operators
*
****************************************************************************/
//------------------------------------------------------------------------------
XMFINLINE _XMFLOAT3X3::_XMFLOAT3X3
(
FLOAT m00, FLOAT m01, FLOAT m02,
FLOAT m10, FLOAT m11, FLOAT m12,
FLOAT m20, FLOAT m21, FLOAT m22
)
{
m[0][0] = m00;
m[0][1] = m01;
m[0][2] = m02;
m[1][0] = m10;
m[1][1] = m11;
m[1][2] = m12;
m[2][0] = m20;
m[2][1] = m21;
m[2][2] = m22;
}
//------------------------------------------------------------------------------
XMFINLINE _XMFLOAT3X3::_XMFLOAT3X3
(
CONST FLOAT* pArray
)
{
UINT Row;
UINT Column;
for (Row = 0; Row < 3; Row++)
{
for (Column = 0; Column < 3; Column++)
{
m[Row][Column] = pArray[Row * 3 + Column];
}
}
}
//------------------------------------------------------------------------------
XMFINLINE _XMFLOAT3X3& _XMFLOAT3X3::operator=
(
CONST _XMFLOAT3X3& Float3x3
)
{
_11 = Float3x3._11;
_12 = Float3x3._12;
_13 = Float3x3._13;
_21 = Float3x3._21;
_22 = Float3x3._22;
_23 = Float3x3._23;
_31 = Float3x3._31;
_32 = Float3x3._32;
_33 = Float3x3._33;
return *this;
}
/****************************************************************************
*
* XMFLOAT4X3 operators
*
****************************************************************************/
//------------------------------------------------------------------------------
XMFINLINE _XMFLOAT4X3::_XMFLOAT4X3
(
FLOAT m00, FLOAT m01, FLOAT m02,
FLOAT m10, FLOAT m11, FLOAT m12,
FLOAT m20, FLOAT m21, FLOAT m22,
FLOAT m30, FLOAT m31, FLOAT m32
)
{
m[0][0] = m00;
m[0][1] = m01;
m[0][2] = m02;
m[1][0] = m10;
m[1][1] = m11;
m[1][2] = m12;
m[2][0] = m20;
m[2][1] = m21;
m[2][2] = m22;
m[3][0] = m30;
m[3][1] = m31;
m[3][2] = m32;
}
//------------------------------------------------------------------------------
XMFINLINE _XMFLOAT4X3::_XMFLOAT4X3
(
CONST FLOAT* pArray
)
{
UINT Row;
UINT Column;
for (Row = 0; Row < 4; Row++)
{
for (Column = 0; Column < 3; Column++)
{
m[Row][Column] = pArray[Row * 3 + Column];
}
}
}
//------------------------------------------------------------------------------
XMFINLINE _XMFLOAT4X3& _XMFLOAT4X3::operator=
(
CONST _XMFLOAT4X3& Float4x3
)
{
XMVECTOR V1 = XMLoadFloat4((XMFLOAT4*)&Float4x3._11);
XMVECTOR V2 = XMLoadFloat4((XMFLOAT4*)&Float4x3._22);
XMVECTOR V3 = XMLoadFloat4((XMFLOAT4*)&Float4x3._33);
XMStoreFloat4((XMFLOAT4*)&_11, V1);
XMStoreFloat4((XMFLOAT4*)&_22, V2);
XMStoreFloat4((XMFLOAT4*)&_33, V3);
return *this;
}
/****************************************************************************
*
* XMFLOAT4X4 operators
*
****************************************************************************/
//------------------------------------------------------------------------------
XMFINLINE _XMFLOAT4X4::_XMFLOAT4X4
(
FLOAT m00, FLOAT m01, FLOAT m02, FLOAT m03,
FLOAT m10, FLOAT m11, FLOAT m12, FLOAT m13,
FLOAT m20, FLOAT m21, FLOAT m22, FLOAT m23,
FLOAT m30, FLOAT m31, FLOAT m32, FLOAT m33
)
{
m[0][0] = m00;
m[0][1] = m01;
m[0][2] = m02;
m[0][3] = m03;
m[1][0] = m10;
m[1][1] = m11;
m[1][2] = m12;
m[1][3] = m13;
m[2][0] = m20;
m[2][1] = m21;
m[2][2] = m22;
m[2][3] = m23;
m[3][0] = m30;
m[3][1] = m31;
m[3][2] = m32;
m[3][3] = m33;
}
//------------------------------------------------------------------------------
XMFINLINE _XMFLOAT4X4::_XMFLOAT4X4
(
CONST FLOAT* pArray
)
{
UINT Row;
UINT Column;
for (Row = 0; Row < 4; Row++)
{
for (Column = 0; Column < 4; Column++)
{
m[Row][Column] = pArray[Row * 4 + Column];
}
}
}
//------------------------------------------------------------------------------
XMFINLINE _XMFLOAT4X4& _XMFLOAT4X4::operator=
(
CONST _XMFLOAT4X4& Float4x4
)
{
XMVECTOR V1 = XMLoadFloat4((XMFLOAT4*)&Float4x4._11);
XMVECTOR V2 = XMLoadFloat4((XMFLOAT4*)&Float4x4._21);
XMVECTOR V3 = XMLoadFloat4((XMFLOAT4*)&Float4x4._31);
XMVECTOR V4 = XMLoadFloat4((XMFLOAT4*)&Float4x4._41);
XMStoreFloat4((XMFLOAT4*)&_11, V1);
XMStoreFloat4((XMFLOAT4*)&_21, V2);
XMStoreFloat4((XMFLOAT4*)&_31, V3);
XMStoreFloat4((XMFLOAT4*)&_41, V4);
return *this;
}
#endif // __cplusplus
#endif // __XNAMATHMATRIX_INL__
| [
"[email protected]"
]
| [
[
[
1,
3158
]
]
]
|
33c0198754963401acb2fb4fc7eac68e2fe9ccc9 | 3856c39683bdecc34190b30c6ad7d93f50dce728 | /LastProject/Source/Cell.cpp | 611c43fd719c53885e4aa4c7ab44705d8d6ba40d | []
| no_license | yoonhada/nlinelast | 7ddcc28f0b60897271e4d869f92368b22a80dd48 | 5df3b6cec296ce09e35ff0ccd166a6937ddb2157 | refs/heads/master | 2021-01-20T09:07:11.577111 | 2011-12-21T22:12:36 | 2011-12-21T22:12:36 | 34,231,967 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 6,825 | cpp | /**
@file CCell.cpp
@date 2011/09/23
@author ๋ฐฑ๊ฒฝํ
@brief ํ๋ธ ๋ฉด ํด๋์ค
*/
#include "stdafx.h"
#include "Cell.h"
#ifdef _CELLCUBE
CCell::CCell()
{
Clear();
}
CCell::~CCell()
{
Release();
}
VOID CCell::Clear()
{
m_pD3dDevice = NULL ;
m_iStartVB = 0;
m_iStartIB = 0;
m_fCubeSize = 0.0f;
m_iFaceNum = 0;
m_iVisible = TRUE;
}
HRESULT CCell::Create( LPDIRECT3DDEVICE9 a_pD3dDevice,
LPDIRECT3DVERTEXBUFFER9 &a_pVB, LPDIRECT3DINDEXBUFFER9 &a_pIB,
INT a_iStartVB, INT a_iStartIB, FLOAT a_fCubeSize, INT a_iFaceNum )
{
m_pD3dDevice = a_pD3dDevice;
m_iStartVB = a_iStartVB;
m_iStartIB = a_iStartIB;
m_fCubeSize = a_fCubeSize;
m_iFaceNum = a_iFaceNum;
_InitVB( a_pVB );
_InitIB( a_pIB );
return S_OK;
}
HRESULT CCell::Release()
{
return S_OK;
}
HRESULT CCell::_InitVB( LPDIRECT3DVERTEXBUFFER9 &a_pVB )
{
// v0----- v1
// /| /|
// v3------v2|
// | | | |
// | |v4---|-|v5
// |/ |/
// v7------v6
FLOAT fSize = m_fCubeSize;
D3DXVECTOR3 v0 = D3DXVECTOR3( -fSize, fSize, fSize );
D3DXVECTOR3 v1 = D3DXVECTOR3( fSize, fSize, fSize );
D3DXVECTOR3 v2 = D3DXVECTOR3( fSize, fSize, -fSize );
D3DXVECTOR3 v3 = D3DXVECTOR3( -fSize, fSize, -fSize );
D3DXVECTOR3 v4 = D3DXVECTOR3( -fSize, -fSize, fSize );
D3DXVECTOR3 v5 = D3DXVECTOR3( fSize, -fSize, fSize );
D3DXVECTOR3 v6 = D3DXVECTOR3( fSize, -fSize, -fSize );
D3DXVECTOR3 v7 = D3DXVECTOR3( -fSize, -fSize, -fSize );
FLOAT fNom = 1.0f;
D3DXVECTOR3 nTop = D3DXVECTOR3( 0.0f, fNom, 0.0f );
D3DXVECTOR3 nBottom = D3DXVECTOR3( 0.0f, -fNom, 0.0f );
D3DXVECTOR3 nFront = D3DXVECTOR3( 0.0f, 0.0f, -fNom );
D3DXVECTOR3 nBack = D3DXVECTOR3( 0.0f, 0.0f, fNom );
D3DXVECTOR3 nLeft = D3DXVECTOR3( -fNom, 0.0f, 0.0f );
D3DXVECTOR3 nRight = D3DXVECTOR3( fNom, 0.0f, 0.0f );
D3DXVECTOR2 tTL = D3DXVECTOR2( 0.0f, 0.0f );
D3DXVECTOR2 tTR = D3DXVECTOR2( 1.0f, 0.0f );
D3DXVECTOR2 tBL = D3DXVECTOR2( 1.0f, 1.0f );
D3DXVECTOR2 tBR = D3DXVECTOR2( 0.0f, 1.0f );
CUBEVERTEX* pVertices = NULL;
INT test = CUBEVERTEX::VertexNum;
if( FAILED( a_pVB->Lock( m_iStartVB * sizeof( CUBEVERTEX ), CUBEVERTEX::VertexNum * sizeof( CUBEVERTEX ), (VOID**)&pVertices, 0 ) ) )
{
Release();
return E_FAIL;
}
CUBEVERTEX verticesLast[CUBEVERTEX::VertexNum];
if( m_iFaceNum == EnumCubeCellFace::TOP )
{
CUBEVERTEX vertices[CUBEVERTEX::VertexNum] = {
//Top------------------------------------------------------
// 0
{ v0,
//a_Color,
nTop,
tTL
},
// 1
{ v1,
// a_Color,
nTop,
tTR
},
// 2
{ v2,
//a_Color,
nTop,
tBL
},
// 3
{ v3,
//a_Color,
nTop,
tBR
}
};
memcpy( verticesLast, vertices, CUBEVERTEX::VertexNum * sizeof( CUBEVERTEX ) );
}
else if( m_iFaceNum == EnumCubeCellFace::BOTTOM )
{
CUBEVERTEX vertices[CUBEVERTEX::VertexNum] = {
//Bottom------------------------------------------------------
// 4
{ v7,
//a_Color,
nBottom,
tTL
},
// 5
{ v6,
//a_Color,
nBottom,
tTR
},
// 6
{ v5,
//a_Color,
nBottom,
tBL
},
// 7
{ v4,
//a_Color,
nBottom,
tBR
}
};
memcpy( verticesLast, vertices, CUBEVERTEX::VertexNum * sizeof( CUBEVERTEX ) );
}
else if( m_iFaceNum == EnumCubeCellFace::FRONT )
{
CUBEVERTEX vertices[CUBEVERTEX::VertexNum] = {
//Front------------------------------------------------------
// 8
{ v3,
//a_Color,
nFront,
tTL
},
// 9
{ v2,
//a_Color,
nFront,
tTR
},
// 10
{ v6,
//a_Color,
nFront,
tBL
},
// 11
{ v7,
//a_Color,
nFront,
tBR
}
};
memcpy( verticesLast, vertices, CUBEVERTEX::VertexNum * sizeof( CUBEVERTEX ) );
}
else if( m_iFaceNum == EnumCubeCellFace::BACK )
{
CUBEVERTEX vertices[CUBEVERTEX::VertexNum] = {
//Back------------------------------------------------------
// 12
{ v1,
//a_Color,
nBack,
tTR
},
// 13
{ v0,
//a_Color,
nBack,
tTL
},
// 14
{ v4,
//a_Color,
nBack,
tBR
},
// 15
{ v5,
//a_Color,
nBack,
tBL
}
};
memcpy( verticesLast, vertices, CUBEVERTEX::VertexNum * sizeof( CUBEVERTEX ) );
}
else if( m_iFaceNum == EnumCubeCellFace::LEFT )
{
CUBEVERTEX vertices[CUBEVERTEX::VertexNum] = {
//Left------------------------------------------------------
// 16
{ v0,
//a_Color,
nLeft,
tTL
},
// 17
{ v3,
//a_Color,
nLeft,
tTR
},
// 18
{ v7,
//a_Color,
nLeft,
tBL
},
// 19
{ v4,
//a_Color,
nLeft,
tBR
}
};
memcpy( verticesLast, vertices, CUBEVERTEX::VertexNum * sizeof( CUBEVERTEX ) );
}
else if( m_iFaceNum == EnumCubeCellFace::RIGHT )
{
CUBEVERTEX vertices[CUBEVERTEX::VertexNum] = {
//Right------------------------------------------------------
// 20
{ v2,
//a_Color,
nRight,
tTL
},
// 21
{ v1,
//a_Color,
nRight,
tTR
},
// 22
{ v5,
//a_Color,
nRight,
tBL
},
// 23
{ v6,
//a_Color,
nRight,
tBR
}
};
memcpy( verticesLast, vertices, CUBEVERTEX::VertexNum * sizeof( CUBEVERTEX ) );
}
memcpy( pVertices, verticesLast, CUBEVERTEX::VertexNum * sizeof( CUBEVERTEX ) );
a_pVB->Unlock();
return S_OK;
}
HRESULT CCell::_InitIB( LPDIRECT3DINDEXBUFFER9 &a_pIB )
{
// v0----- v1
// /| /|
// v3------v2|
// | | | |
// | |v4---|-|v5
// |/ |/
// v7------v6
CUBEINDEX* pIndices = NULL;
if( FAILED( a_pIB->Lock( m_iStartIB, 2 * sizeof( CUBEINDEX ), (VOID**)&pIndices, 0 ) ) )
{
Release();
return E_FAIL;
}
CUBEINDEX i[2] =
{
{ 0, 1, 3 }, { 1, 2, 3 }
};
memcpy( pIndices, i, 2 * sizeof( CUBEINDEX ) );
a_pIB->Unlock();
return S_OK;
}
VOID CCell::Render()
{
m_pD3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, m_iStartVB, 0, CUBEVERTEX::VertexNum, 0, 2 );
}
#endif | [
"[email protected]@d02aaf57-2019-c8cd-d06c-d029ef2af4e0"
]
| [
[
[
1,
353
]
]
]
|
3091f8bdf58ae55ce28954cafc33a8024a47ba78 | 0279b408607cffed7b4e6c480ebcb767ca1414de | /Verรถffentlichungen/0.1.1/Bestandteile/Lesegeraete/Lesegeraet/Lesegeraetinterface.h | 1c937e119a49d922635fc620e32bbe5ecf7352f9 | []
| no_license | BackupTheBerlios/qsmartcard-svn | 3fc6d6d5ef67be24fbd5f2ce9ddf9ea8f1460058 | ce55cb5790323b1a86782ec367409bef92b2a478 | refs/heads/master | 2020-12-25T19:15:19.683493 | 2007-04-21T15:50:58 | 2007-04-21T15:50:58 | 40,823,841 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,259 | h | /*
* Copyright (C) 2005-2006 Frank Bรผttner [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef QFRANKLESEGERAETINTERFACE_H
#define QFRANKLESEGERAETINTERFACE_H
class QStringList;
class QFrankLesegeraet;
class QFrankLesegeraetinterface
{
public:
virtual ~QFrankLesegeraetinterface() {}
virtual QStringList Geraete() const = 0;
virtual QFrankLesegeraet* erstellen(const QString &) =0;
};
Q_DECLARE_INTERFACE(QFrankLesegeraetinterface,"QFrank.SmartCard.Lesegeraete.Interface/0.1")
#endif
| [
"frank@44d785f6-2729-0410-8380-9ee487a164e4"
]
| [
[
[
1,
34
]
]
]
|
d77b601184bbe4303dec8b2d1190fc105fb7a080 | b14d5833a79518a40d302e5eb40ed5da193cf1b2 | /cpp/extern/xercesc++/2.6.0/src/xercesc/util/regx/XMLRangeFactory.hpp | 81fb455e68f7b8301915ae6da24110d02aa70066 | [
"Apache-2.0"
]
| permissive | andyburke/bitflood | dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf | fca6c0b635d07da4e6c7fbfa032921c827a981d6 | refs/heads/master | 2016-09-10T02:14:35.564530 | 2011-11-17T09:51:49 | 2011-11-17T09:51:49 | 2,794,411 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,289 | hpp | /*
* Copyright 2001-2002,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XMLRangeFactory.hpp,v 1.6 2004/09/08 13:56:47 peiyongz Exp $
*/
#if !defined(XMLRANGEFACTORY_HPP)
#define XMLRANGEFACTORY_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/regx/RangeFactory.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLUTIL_EXPORT XMLRangeFactory: public RangeFactory {
public:
// -----------------------------------------------------------------------
// Constructors and operators
// -----------------------------------------------------------------------
XMLRangeFactory();
~XMLRangeFactory();
// -----------------------------------------------------------------------
// Initialization methods
// -----------------------------------------------------------------------
void initializeKeywordMap();
protected:
// -----------------------------------------------------------------------
// Protected Helper methods
// -----------------------------------------------------------------------
void buildRanges();
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLRangeFactory(const XMLRangeFactory&);
XMLRangeFactory& operator=(const XMLRangeFactory&);
bool fRangesCreated;
bool fKeywordsInitialized;
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End file XMLRangeFactory.hpp
*/
| [
"[email protected]"
]
| [
[
[
1,
68
]
]
]
|
a956dd80a7cabd76474b94d0085e1b6a2682ac16 | 1d2705c9be9ee0f974c224eb794f2f8a9e9a3d50 | /tracking_machine.exe/main.cpp | 54c170cab3253003cc885dd764c752630c5b91bc | []
| no_license | llvllrbreeze/alcorapp | dfe2551f36d346d73d998f59d602c5de46ef60f7 | 3ad24edd52c19f0896228f55539aa8bbbb011aac | refs/heads/master | 2021-01-10T07:36:01.058011 | 2008-12-16T12:51:50 | 2008-12-16T12:51:50 | 47,865,136 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 182 | cpp | #define WIN32_LEAN_AND_MEAN
#include "alcor.apps\trm\tracking_machine.h"
using namespace all;
int main()
{
trm::tracking_machine machine;
getchar();
return 0;
} | [
"andrea.carbone@1ffd000b-a628-0410-9a29-793f135cad17"
]
| [
[
[
1,
12
]
]
]
|
98ba57d907ca32374b56631f8dfa2cb1199911f6 | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/tags/v0-1/engine/core/src/CameraObject.cpp | 4e528c20bd269b9134da1d8cdcc6b1804aee4e88 | [
"ClArtistic",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
]
| permissive | jacmoe/dsa-hl-svn | 55b05b6f28b0b8b216eac7b0f9eedf650d116f85 | 97798e1f54df9d5785fb206c7165cd011c611560 | refs/heads/master | 2021-04-22T12:07:43.389214 | 2009-11-27T22:01:03 | 2009-11-27T22:01:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,595 | cpp | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2005 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#include "CameraObject.h"
#include "Actor.h"
#include "CoreSubsystem.h"
#include "World.h"
#include "Exception.h"
using namespace Ogre;
namespace rl {
CameraObject::CameraObject(const String& name)
{
Camera* camera = CoreSubsystem::getSingleton().getWorld()->
getSceneManager()->createCamera(name);
camera->setNearClipDistance(10);
camera->setFarClipDistance(1000000);
mMovableObject = camera;
}
Camera* CameraObject::getCamera()
{
return static_cast<Camera*>(mMovableObject);
}
String CameraObject::getObjectType()
{
return "CameraObject";
}
Vector3 CameraObject::getSize()
{
return Vector3(getCamera()->getNearClipDistance() * 3.0f, 0, 0);
}
Entity* CameraObject::getEntity() const
{
Throw(rl::IllegalStateException, "CameraObject has no Entity");
return NULL;
}
}
| [
"blakharaz@4c79e8ff-cfd4-0310-af45-a38c79f83013"
]
| [
[
[
1,
57
]
]
]
|
ced7dd7aa17a3627c52395d156b679fe644b847c | 53dec6da17d4088313d7d14a98fb6a2aed18b5d3 | /carbon/1.0/dev/source/IDAppNative/source/win/ThreadPool.cpp | 7bf428a4eda44d52508ebb878ff013d253292742 | []
| no_license | saurabh1403/carbon-app-management | 5ece03894dae1461176757cd3ba73b977287435c | c0b6f4cd31ed0cbd4308b75c5d24cfd83e9dd182 | refs/heads/master | 2021-01-10T19:02:26.901965 | 2011-07-31T12:32:39 | 2011-07-31T12:32:39 | 35,387,088 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,344 | cpp |
#include "ThreadPool.h"
#include "Utilities.h"
#include "IDAppNative.h"
#include "IDAppGlobalContext.h"
ThreadPool::ThreadPool():shouldContinue(false),m_hThreads(NULL), nThreadsRunning(0)
{
}
ThreadPool::~ThreadPool()
{
//blocking here
closeAllThreads();
}
bool ThreadPool::initWithThreads()
{
CARBONLOG_CLASS_PTR logger(carbonLogger::getLoggerPtr());
unsigned int nCores = carbonUtilities::cuGetNumberOfProcessors();
shouldContinue = true;
CARBONLOG_INFO(logger, "[initWithThreads] : Number of threads to spawn are "<<nCores);
return initWithThreads(nCores);
}
bool ThreadPool::initWithThreads(unsigned int nthreads)
{
CARBONLOG_CLASS_PTR logger(carbonLogger::getLoggerPtr());
if(nthreads > 10)
{
CARBONLOG_ERROR(logger, "[initWithThreads] : Too many threads asked to start - " <<nthreads);
return false;
}
if(nthreads == 0)
{
CARBONLOG_WARN(logger, "[initWithThreads] : 0 threads asked to spawn");
return true;
}
//in case, previously threads are opened.
closeAllThreads();
m_hThreads = new HANDLE[nthreads];
for(unsigned int i =0; i< nthreads ;i++)
{
DWORD threadID = 0;
m_hThreads[i] = CreateThread(NULL, 0, &(ThreadPool::WorkerThread), this, 0, &threadID);
if(m_hThreads[i] != NULL)
nThreadsRunning++;
else
CARBONLOG_ERROR(logger, "[initWithThreads] : Threads "<<i<<" spawing failed");
}
CARBONLOG_INFO(logger, "[initWithThreads] : Threads spawned completed");
return (nThreadsRunning == 0)? false : true;
}
//a synchronous blocking call call
bool ThreadPool::closeAllThreads()
{
CARBONLOG_CLASS_PTR logger(carbonLogger::getLoggerPtr());
//wait for all threads closure
if(m_hThreads == NULL || nThreadsRunning == 0)
{
CARBONLOG_TRACE(logger, "[closeAllThreads] : There is no thread to close. ");
return true;
}
shouldContinue = false;
WaitForMultipleObjects(nThreadsRunning, m_hThreads, true, INFINITE);
CARBONLOG_INFO(logger, "[closeAllThreads] : Threads are now closed.");
delete [] m_hThreads;
m_hThreads = NULL;
return true;
}
bool ThreadPool::getJobMsg(std::string &jobMsg)
{
//it will only return the async job messages
BIPacket pkt;
if(IDAppGlobalContext::getInstance().getBIObject().readAsyncPkt(pkt) == kBridgeInterfaceErrorNoDataPresent)
return false;
else
{
jobMsg.assign(pkt.buffer);
return true;
}
return true;
}
bool ThreadPool::writeJobOutput(const std::string &outStr)
{
return (IDAppGlobalContext::getInstance().writePktToBi(outStr) == kBridgeInterfaceErrorNone);
}
DWORD WINAPI ThreadPool::WorkerThread(LPVOID lpParam)
{
CoInitialize(NULL);
ThreadPool *obj = (ThreadPool *)lpParam;
CARBONLOG_CLASS_PTR logger(carbonLogger::getLoggerPtr());
CARBONLOG_INFO(logger, "[WorkerThread] : starting worker thread now..");
while(obj->shouldContinue)
{
std::string jobMsg, jobOutput;
if(obj->getJobMsg(jobMsg))
{
CARBONLOG_DEBUG(logger, "[WorkerThread] : Processing job ..");
processJob(jobMsg,jobOutput);
if(!obj->writeJobOutput(jobOutput))
CARBONLOG_ERROR(logger, "[WorkerThread] : Failed to write packet to BI");
}
else
Sleep(10);
}
CARBONLOG_INFO(logger, "[WorkerThread] : exiting worker thread now..");
CoUninitialize();
return 0;
}
| [
"saurabhgupta1403@e16f9d33-a4db-0b4f-5d1a-325b24bf4611"
]
| [
[
[
1,
145
]
]
]
|
8fc25b4907d9e688b48d4a3a78da4193f93ea8a9 | e3e69b1533b942e6b834cc53a461e2bfce68244e | /Fl_Knob.h | f9187f4f7ed83feac7d4156220a5e39d433c9c84 | []
| no_license | berilevi/cidei | 89d396e67a934e2c5698bd6d3b8d177ea829d7b5 | 3c84935809f0a68783733db57c3de6fdad2ecedf | refs/heads/master | 2020-05-02T22:13:52.643632 | 2008-09-04T18:51:00 | 2008-09-04T18:51:00 | 33,262,364 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 837 | h | // generated by Fast Light User Interface Designer (fluid) version 1.0010
#ifndef Fl_Knob_H
#define Fl_Knob_H
#include <FL/Fl.H>
#include <Fl/Fl_Valuator.H>
class Fl_Knob : public Fl_Valuator {
public:
enum Fl_Knobtype {DOTLIN=0,DOTLOG_1,DOTLOG_2,DOTLOG_3,LINELIN,LINELOG_1,LINELOG_2,LINELOG_3};
private:
int _type;
float _percent;
int _scaleticks;
short a1,a2;
public:
Fl_Knob(int xx,int yy,int ww,int hh,const char *l=0);
~Fl_Knob();
private:
void draw();
int handle(int event);
public:
void type(int ty);
private:
void shadow(const int offs,const uchar r,uchar g,uchar b);
void draw_scale(const int ox,const int oy,const int side);
void draw_cursor(const int ox,const int oy,const int side);
public:
void cursor(const int pc);
void scaleticks(const int tck);
};
#endif
| [
"juanpab1980@b98271d3-b73c-0410-b3e6-1dfb2072a0f9"
]
| [
[
[
1,
32
]
]
]
|
2ce53ac4d41f9103415115108838afb9bd751dfd | 138a353006eb1376668037fcdfbafc05450aa413 | /source/ogre/OgreNewt/boost/mpl/comparison.hpp | 06c41931da0ea0d4a7bf96aae8ffc280225c9a31 | []
| no_license | sonicma7/choreopower | 107ed0a5f2eb5fa9e47378702469b77554e44746 | 1480a8f9512531665695b46dcfdde3f689888053 | refs/heads/master | 2020-05-16T20:53:11.590126 | 2009-11-18T03:10:12 | 2009-11-18T03:10:12 | 32,246,184 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 772 | hpp |
#ifndef BOOST_MPL_COMPARISON_HPP_INCLUDED
#define BOOST_MPL_COMPARISON_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2000-2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Source: /cvsroot/ogre/ogreaddons/ogrenewt/OgreNewt_Main/inc/boost/mpl/comparison.hpp,v $
// $Date: 2006/04/17 23:48:05 $
// $Revision: 1.1 $
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/not_equal_to.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/greater.hpp>
#include <boost/mpl/less_equal.hpp>
#include <boost/mpl/greater_equal.hpp>
#endif // BOOST_MPL_COMPARISON_HPP_INCLUDED
| [
"Sonicma7@0822fb10-d3c0-11de-a505-35228575a32e"
]
| [
[
[
1,
24
]
]
]
|
2e675dfb6504da0f761323f099a6d6f1476bbd8e | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /Game/ObjectDLL/ObjectShared/GearItems.h | 0acd96e64312741433a878a79ef0ed10abc2a90d | []
| no_license | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,902 | h | // ----------------------------------------------------------------------- //
//
// MODULE : GearItems.h
//
// PURPOSE : Gear items definition
//
// CREATED : 10/22/99
//
// (c) 1999-2002 Monolith Productions, Inc. All Rights Reserved
//
// ----------------------------------------------------------------------- //
#ifndef __GEAR_ITEMS_H__
#define __GEAR_ITEMS_H__
#include "PickupItem.h"
#include "WeaponMgr.h"
LINKTO_MODULE( GearItems );
class GearItem : public PickupItem
{
public :
GearItem();
protected :
uint32 EngineMessageFn(uint32 messageID, void *pData, LTFLOAT fData);
virtual void ObjectTouch(HOBJECT hObject, bool bForcePickup=false);
virtual void PickedUp(ILTMessage_Read *pMsg);
virtual void Respawn( );
uint8 m_nGearId;
private :
bool ReadProp(ObjectCreateStruct *pStruct);
bool PostPropRead(ObjectCreateStruct *pStruct);
void InitialUpdate(ILTServer *pServer);
void Save(ILTMessage_Write *pMsg, uint32 dwSaveFlags);
void Load(ILTMessage_Read *pMsg, uint32 dwLoadFlags);
};
#ifndef __PSX2
class CGearPlugin : public CWeaponMgrPlugin
{
public:
virtual LTRESULT PreHook_EditStringList(const char* szRezPath, const char* szPropName, char** aszStrings, uint32* pcStrings, const uint32 cMaxStrings, const uint32 cMaxStringLength);
virtual LTRESULT PreHook_PropChanged(
const char *szObjName,
const char *szPropName,
const int nPropType,
const GenericProp &gpPropValue,
ILTPreInterface *pInterface,
const char *szModifiers );
virtual LTRESULT PreHook_Dims(
const char* szRezPath,
const char* szPropValue,
char* szModelFilenameBuf,
int nModelFilenameBufLen,
LTVector & vDims);
protected:
CPickupItemPlugin m_PickupItemPlugin;
};
#endif
#endif // __GEAR_ITEMS_H__ | [
"[email protected]"
]
| [
[
[
1,
74
]
]
]
|
b8ebd0e7cfb0493d6e46c1faaaf853c665cfda40 | b922e4a186b33fb6efe7439ee2f676f1ae095b99 | /src/Lab2/lab2.cpp | 717c29f9f6b21c4aa45c0c9a1c13071920be01ee | []
| no_license | Daniel-Svensson/dist_sys | 61bb9e9c57233deafce41f79acd3f4fb3fa1e042 | 1b5effb7a6d9045b7cf82ddc813d33045f9f3f7f | refs/heads/master | 2021-05-26T19:58:20.444194 | 2010-02-18T16:06:23 | 2010-02-18T16:06:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,412 | cpp | #include <iostream>
#include "CardDatabase.h"
#include "CardWrite.h"
#include "Card.h"
using namespace std;
#include <iostream>
#include <string>
#include <asio.hpp>
int webb(int argc, char* argv[]) {
std::string host = argc > 1 ? argv[1] : "mir41.ida.liu.se";
asio::ip::tcp::iostream stream(host, "7000");
if (stream) {
// stream << "getCardsNumber\n" << flush;
// stream << "getCardsNumber\n" << flush;
stream << "getCardInfo 1\n" << flush;
// Sleep(100));
stream << "exit\n";
std::string line;
// Sleep(100);
while(std::getline(stream, line))
{
std::cout << line << std::endl;
if(line.find('\0') != string::npos)
cerr << "hitta null";
}
}
return 0;
}
int main(int argc, char* argv[])
{
// webb(argc,argv);
CardDatabase db;
auto_ptr<Card> rcv_card;
CardWrite cw;
int num = -1;
do
{
cout << "There are " << db.GetNumCards() << " numbers of cards" << endl;
cout << "Select a card: ";
cin >> num;
if( num == -1)
break;
auto_ptr<Card> card = db.GetCard(num);
rcv_card = card;
// CardWrite();
}while(false); //while(num != -1);
CardWrite(); //make a connection to Card Writer server
//Send the received card info from Card DB server to Card Writer Server
cw.SendCard(rcv_card);
return 0;
}
| [
"[email protected]",
"[email protected]",
"Daniel@ILLER.(none)"
]
| [
[
[
1,
3
],
[
5,
8
],
[
36,
36
],
[
39,
39
],
[
42,
52
],
[
61,
63
]
],
[
[
4,
4
],
[
20,
20
],
[
23,
23
],
[
37,
37
],
[
40,
41
],
[
53,
60
]
],
[
[
9,
19
],
[
21,
22
],
[
24,
35
],
[
38,
38
]
]
]
|
330ee5af562b8a02edfb18514a3ea0e9b81e5450 | b3b0c727bbafdb33619dedb0b61b6419692e03d3 | /Source/WinHTTPLW/gtest/testWinHTTPLW.cpp | d2928ebf584f67cf5b2a59f71faed140536d2a01 | []
| no_license | testzzzz/hwccnet | 5b8fb8be799a42ef84d261e74ee6f91ecba96b1d | 4dbb1d1a5d8b4143e8c7e2f1537908cb9bb98113 | refs/heads/master | 2021-01-10T02:59:32.527961 | 2009-11-04T03:39:39 | 2009-11-04T03:39:39 | 45,688,112 | 0 | 1 | null | null | null | null | MacCentralEurope | C++ | false | false | 1,434 | cpp | //////////////////////////////////////////////////////////
///
/// @file testWinHTTPLW.cpp
///
/// @brief ลลปโโGoogleTestโคโย โWinHTTPLWลล
///
/// @version 1.0
///
/// @author โลลคโฆ
///
/// @date 2009-09-27
///
//////////////////////////////////////////////////////////
#include "stdafx.h"
#include "testWinHTTPLW.h"
WinHTTPLW* TestWinHTTPLW::pLW = NULL;
TEST_F(TestWinHTTPLW, 52xianjian)
{
ASSERT_EQ(S_OK, WinHTTPLW::Initialize());
ASSERT_EQ(S_OK, TestWinHTTPLW::pLW->Connect(L"www.52xianjian.com"));
ASSERT_EQ(S_OK, TestWinHTTPLW::pLW->Request(L"GET", L"/ip.php"));
ASSERT_EQ(S_OK, TestWinHTTPLW::pLW->downloadFile(L"ip"));
}
TEST_F(TestWinHTTPLW, baidu)
{
ASSERT_EQ(S_OK, WinHTTPLW::Initialize());
ASSERT_EQ(S_OK, TestWinHTTPLW::pLW->Connect(L"www.baidu.com"));
ASSERT_EQ(S_OK, TestWinHTTPLW::pLW->Request());
ASSERT_EQ(S_OK, TestWinHTTPLW::pLW->downloadFile(L"baidu"));
}
TEST_F(TestWinHTTPLW, google)
{
ASSERT_EQ(S_OK, WinHTTPLW::Initialize());
ASSERT_EQ(S_OK, TestWinHTTPLW::pLW->Connect(L"www.google.com"));
ASSERT_EQ(S_OK, TestWinHTTPLW::pLW->Request());
ASSERT_EQ(S_OK, TestWinHTTPLW::pLW->downloadFile(L"google"));
}
int _tmain(int argc, _TCHAR* argv[])
{
testing::GTEST_FLAG(output) = "xml:TestResult.xml";
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
} | [
"[email protected]"
]
| [
[
[
1,
50
]
]
]
|
843cdf4527565c466a37c788947175ab79241c7d | c440e6c62e060ee70b82fc07dfb9a93e4cc13370 | /src/modules/audioportout.h | 2a816d3a398ca2d18d66d10dce259643ceb6750d | []
| no_license | BackupTheBerlios/pgrtsound-svn | 2a3f2ae2afa4482f9eba906f932c30853c6fe771 | d7cefe2129d20ec50a9e18943a850d0bb26852e1 | refs/heads/master | 2020-05-21T01:01:41.354611 | 2005-10-02T13:09:13 | 2005-10-02T13:09:13 | 40,748,578 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 344 | h | #ifndef AUDIOPORTOUT_H
#define AUDIOPORTOUT_H
#include "module.h"
/*
* Interfejs wyjscia systemu (algorytmu)
*/
class AudioPortOut : public Module {
public:
AudioPortOut();
~AudioPortOut();
REGISTER_MODULE( "AudioPortOut", AudioPortOut )
private:
Input inLeft;
Input inRight;
};
#endif // AUDIOPORTOUT_H
| [
"ad4m@fa088095-53e8-0310-8a07-f9518708c3e6"
]
| [
[
[
1,
20
]
]
]
|
a263f48d35174111899bac54625d3b3e40c969df | 16d8b25d0d1c0f957c92f8b0d967f71abff1896d | /OblivionOnline/ClientEntityUpdateManager.h | 7388f4a17fc71ca98770705874577c1d15e6ff08 | []
| no_license | wlasser/oonline | 51973b5ffec0b60407b63b010d0e4e1622cf69b6 | fd37ee6985f1de082cbc9f8625d1d9307e8801a6 | refs/heads/master | 2021-05-28T23:39:16.792763 | 2010-05-12T22:35:20 | 2010-05-12T22:35:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,776 | h | /*
Copyright(c) 2007-2010 Julian Bangert
This file is part of OblivionOnline.
OblivionOnline is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
OblivionOnline is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "EntityUpdateManager.h"
class ClientEntityUpdateManager : public EntityUpdateManager
{
public:
ClientEntityUpdateManager(EntityManager * mgr) : EntityUpdateManager(mgr)
{
}
OO_API virtual void OnAVModUpdate(Entity *ent,unsigned char AVCode,bool Inbound);
OO_API virtual void OnPositionUpdate(Entity *ent,bool Inbound );//Triggers Events and network code;
OO_API virtual void OnAVUpdate(Entity *ent,unsigned char AVCode,bool Inbound );
OO_API virtual void GlobalSend(Entity *ent,bool Inbound );
OO_API virtual void OnNameUpdate(Entity *ent,bool Inbound );
OO_API virtual void OnEquipUdate(Entity *ent,unsigned char slot,bool Inbound );
OO_API virtual void OnClassUpdate(Entity *ent,bool Inbound );
OO_API virtual void OnCellChange(Entity *ent,UINT32 oldCell, bool Inbound );
OO_API virtual void OnRaceUpdate(Entity *ent,bool Inbound );
OO_API virtual void OnAnimationUpdate(Entity *ent,bool Inbound );
OO_API virtual void Chat(Entity *ent,std::string Message,bool Inbound );
OO_API virtual void OnCustomUpdate(Entity *ent,UINT32 Index,bool Inbound);
virtual bool NewPlayerID(UINT32 ID);
virtual void NewClientStatus(bool IsMasterClient);
}; | [
"obliviononline@2644d07b-d655-0410-af38-4bee65694944"
]
| [
[
[
1,
41
]
]
]
|
c5b3b29a349a19aa73eb37ef04e5197043077b9d | d866ee0dee1e0db90bcfb6bb03b155411ace6db0 | /cob_common/generic_can/common/src/CanPeakSys.cpp | f21d7e4a3527fbaa2b0d6cf819c87ddc3364fb5e | []
| no_license | Kuhn1981/care-o-bot | a0a31e8bbe8823f4dcfdeef3830eba777cd9987f | 2797166dd4252040b0f9dfa1918483956be4c2b7 | refs/heads/master | 2020-12-24T10:58:10.792578 | 2010-03-24T14:49:07 | 2010-03-24T14:49:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,734 | cpp | /****************************************************************
*
* Copyright (c) 2010
*
* Fraunhofer Institute for Manufacturing Engineering
* and Automation (IPA)
*
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* Project name: care-o-bot
* ROS stack name: cob3_common
* ROS package name: generic_can
* Description:
*
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* Author: Christian Connette, email:[email protected]
* Supervised by: Christian Connette, email:[email protected]
*
* Date of creation: Feb 2009
* ToDo: Remove dependency to inifiles_old -> Inifile.h
*
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Fraunhofer Institute for Manufacturing
* Engineering and Automation (IPA) nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License LGPL as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License LGPL for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License LGPL along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*
****************************************************************/
#include <generic_can/CanPeakSys.h>
#include <stdlib.h>
#include <cerrno>
#include <cstring>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
//-----------------------------------------------
const int CanPeakSys::c_iInterrupt = 7;
const int CanPeakSys::c_iPort = 0x378;
//-----------------------------------------------
CanPeakSys::CanPeakSys(const char* cIniFile)
{
m_bInitialized = false;
// read IniFile
m_IniFile.SetFileName(cIniFile, "CanPeakSys.cpp");
init();
}
//-----------------------------------------------
CanPeakSys::~CanPeakSys()
{
if (m_bInitialized)
{
CAN_Close(m_handle);
}
}
//-----------------------------------------------
void CanPeakSys::init()
{
m_handle = LINUX_CAN_Open("/dev/pcan24", O_RDWR);
if (! m_handle)
{
// Fatal error
std::cout << "Cannot open CAN-dongle on parallel port: " << strerror(errno) << std::endl;
sleep(3);
exit(0);
}
int ret = CAN_ERR_OK;
int iBaudrateVal = 0;
m_IniFile.GetKeyInt( "CanCtrl", "BaudrateVal", &iBaudrateVal, true);
switch(iBaudrateVal)
{
case 0:
ret = CAN_Init(m_handle, CAN_BAUD_1M, CAN_INIT_TYPE_ST);
break;
case 2:
ret = CAN_Init(m_handle, CAN_BAUD_500K, CAN_INIT_TYPE_ST);
break;
case 4:
ret = CAN_Init(m_handle, CAN_BAUD_250K, CAN_INIT_TYPE_ST);
break;
case 6:
ret = CAN_Init(m_handle, CAN_BAUD_125K, CAN_INIT_TYPE_ST);
break;
case 9:
ret = CAN_Init(m_handle, CAN_BAUD_50K, CAN_INIT_TYPE_ST);
break;
case 11:
ret = CAN_Init(m_handle, CAN_BAUD_20K, CAN_INIT_TYPE_ST);
break;
case 13:
ret = CAN_Init(m_handle, CAN_BAUD_10K, CAN_INIT_TYPE_ST);
break;
}
if(ret)
{
std::cout << "CanPeakSys::CanPeakSys(), error in init" << std::endl;
}
else
{
std::cout << "CanPeakSys::CanpeakSys(), init ok" << std::endl;
m_bInitialized = true;
}
}
//-------------------------------------------
bool CanPeakSys::transmitMsg(CanMsg CMsg, bool bBlocking)
{
TPCANMsg TPCMsg;
bool bRet = true;
if (m_bInitialized == false) return false;
// copy CMsg to TPCmsg
TPCMsg.LEN = CMsg.m_iLen;
TPCMsg.ID = CMsg.m_iID;
TPCMsg.MSGTYPE = CMsg.m_iType;
for(int i=0; i<8; i++)
TPCMsg.DATA[i] = CMsg.getAt(i);
// write msg
int iRet;
iRet = CAN_Write(m_handle, &TPCMsg);
iRet = CAN_Status(m_handle);
if(iRet < 0)
{
std::cout << "CanPeakSys::transmitMsg, errorcode= " << nGetLastError() << std::endl;
bRet = false;
}
return bRet;
}
//-------------------------------------------
bool CanPeakSys::receiveMsg(CanMsg* pCMsg)
{
TPCANRdMsg TPCMsg;
TPCMsg.Msg.LEN = 8;
TPCMsg.Msg.MSGTYPE = 0;
TPCMsg.Msg.ID = 0;
int iRet = CAN_ERR_OK;
bool bRet = false;
if (m_bInitialized == false) return false;
iRet = LINUX_CAN_Read_Timeout(m_handle, &TPCMsg, 0);
if (iRet == CAN_ERR_OK)
{
pCMsg->m_iID = TPCMsg.Msg.ID;
pCMsg->set(TPCMsg.Msg.DATA[0], TPCMsg.Msg.DATA[1], TPCMsg.Msg.DATA[2], TPCMsg.Msg.DATA[3],
TPCMsg.Msg.DATA[4], TPCMsg.Msg.DATA[5], TPCMsg.Msg.DATA[6], TPCMsg.Msg.DATA[7]);
bRet = true;
}
else if (CAN_Status(m_handle) != CAN_ERR_QRCVEMPTY)
{
std::cout << "CanPeakSys::receiveMsg ERROR: iRet = " << iRet << std::endl;
pCMsg->set(0, 0, 0, 0, 0, 0, 0, 0);
}
else
{
// make sure there's never an undefined state (even when can drivers fail)
pCMsg->set(0, 0, 0, 0, 0, 0, 0, 0);
}
return bRet;
}
//-------------------------------------------
bool CanPeakSys::receiveMsgRetry(CanMsg* pCMsg, int iNrOfRetry)
{
int i, iRet;
TPCANRdMsg TPCMsg;
TPCMsg.Msg.LEN = 8;
TPCMsg.Msg.MSGTYPE = 0;
TPCMsg.Msg.ID = 0;
if (m_bInitialized == false) return false;
// wait until msg in buffer
bool bRet = true;
iRet = CAN_ERR_OK;
i=0;
do
{
iRet = LINUX_CAN_Read_Timeout(m_handle, &TPCMsg, 0);
if(iRet == CAN_ERR_OK)
break;
i++;
usleep(100000);
}
while(i < iNrOfRetry);
// eval return value
if(iRet != CAN_ERR_OK)
{
std::cout << "CanPeakSys::receiveMsgRetry: " << strerror(errno) << std::endl;
pCMsg->set(0, 0, 0, 0, 0, 0, 0, 0);
bRet = false;
}
else
{
pCMsg->m_iID = TPCMsg.Msg.ID;
pCMsg->set(TPCMsg.Msg.DATA[0], TPCMsg.Msg.DATA[1], TPCMsg.Msg.DATA[2], TPCMsg.Msg.DATA[3],
TPCMsg.Msg.DATA[4], TPCMsg.Msg.DATA[5], TPCMsg.Msg.DATA[6], TPCMsg.Msg.DATA[7]);
}
return bRet;
}
| [
"cpc@okeanos.(none)",
"[email protected]"
]
| [
[
[
1,
53
],
[
55,
253
]
],
[
[
54,
54
]
]
]
|
1de03cda78912f5e99c2ce1468d440601d94d005 | a2ba072a87ab830f5343022ed11b4ac365f58ef0 | / urt-bumpy-q3map2 --username [email protected]/libs/generic/callback.cpp | 11e3be8974b238114083fa3efbd2e47c6caa5186 | []
| no_license | Garey27/urt-bumpy-q3map2 | 7d0849fc8eb333d9007213b641138e8517aa092a | fcc567a04facada74f60306c01e68f410cb5a111 | refs/heads/master | 2021-01-10T17:24:51.991794 | 2010-06-22T13:19:24 | 2010-06-22T13:19:24 | 43,057,943 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,590 | cpp |
#include "callback.h"
#if defined(_DEBUG) || defined(DOXYGEN)
namespace ExampleMemberCaller
{
// MemberCaller example
class Integer
{
public:
int value;
void printValue() const
{
// print this->value here;
}
void setValue()
{
value = 3;
}
// a typedef to make things more readable
typedef MemberCaller<Integer, &Integer::setValue> SetValueCaller;
};
void example()
{
Integer foo = { 0 };
{
Callback bar = ConstMemberCaller<Integer, &Integer::printValue>(foo);
// invoke the callback
bar(); // foo.printValue()
}
{
// use the typedef to improve readability
Callback bar = Integer::SetValueCaller(foo);
// invoke the callback
bar(); // foo.setValue()
}
}
// end example
}
namespace ExampleReferenceCaller
{
// ReferenceCaller example
void Int_printValue(const int& value)
{
// print value here;
}
void Int_setValue(int& value)
{
value = 3;
}
// a typedef to make things more readable
typedef ReferenceCaller<int, Int_setValue> IntSetValueCaller;
void example()
{
int foo = 0;
{
Callback bar = ConstReferenceCaller<int, Int_printValue>(foo);
// invoke the callback
bar(); // Int_printValue(foo)
}
{
// use the typedef to improve readability
Callback bar = IntSetValueCaller(foo);
// invoke the callback
bar(); // Int_setValue(foo)
}
}
// end example
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
89
]
]
]
|
90964f821eeee0aae5499188781dc137c3c504f0 | f55665c5faa3d79d0d6fe91fcfeb8daa5adf84d0 | /Depend/MyGUI/MyGUIEngine/include/MyGUI_ToolTipManager.h | 6300244172c8934d35958c6ab0417647706b611d | []
| no_license | lxinhcn/starworld | 79ed06ca49d4064307ae73156574932d6185dbab | 86eb0fb8bd268994454b0cfe6419ffef3fc0fc80 | refs/heads/master | 2021-01-10T07:43:51.858394 | 2010-09-15T02:38:48 | 2010-09-15T02:38:48 | 47,859,019 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,881 | h | /*!
@file
@author Albert Semenov
@date 03/2010
*/
/*
This file is part of MyGUI.
MyGUI is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MyGUI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __MYGUI_TOOL_TIP_MANAGER_H__
#define __MYGUI_TOOL_TIP_MANAGER_H__
#include "MyGUI_Prerequest.h"
#include "MyGUI_IUnlinkWidget.h"
#include "MyGUI_Singleton.h"
namespace MyGUI
{
class MYGUI_EXPORT ToolTipManager :
public Singleton<ToolTipManager>,
public IUnlinkWidget
{
public:
ToolTipManager();
void initialise();
void shutdown();
void setDelayVisible(float _value);
float getDelayVisible() const
{
return mDelayVisible;
}
/*internal:*/
void _unlinkWidget(Widget* _widget);
private:
void notifyEventFrameStart(float _time);
void hideToolTip(Widget* _widget);
void showToolTip(Widget* _widget, size_t _index, const IntPoint& _point);
void moveToolTip(Widget* _widget, size_t _index, const IntPoint& _point);
bool isNeedToolTip(Widget* _widget);
size_t getToolTipIndex(Widget* _widget) const;
private:
float mDelayVisible;
Widget* mOldFocusWidget;
IntPoint mOldMousePoint;
bool mToolTipVisible;
float mCurrentTime;
size_t mOldIndex;
bool mNeedToolTip;
bool mIsInitialise;
};
}
#endif // __MYGUI_TOOL_TIP_MANAGER_H__
| [
"albertclass@a94d7126-06ea-11de-b17c-0f1ef23b492c"
]
| [
[
[
1,
75
]
]
]
|
76b9ee84648aa34cdf1b1a53396e9a8d2fbf801a | dadf8e6f3c1adef539a5ad409ce09726886182a7 | /airplay/h/toeBox2DSingleShape.h | f05f19137e44a4ebfef3969fd4cb5aaae9987706 | []
| no_license | sarthakpandit/toe | 63f59ea09f2c1454c1270d55b3b4534feedc7ae3 | 196aa1e71e9f22f2ecfded1c3da141e7a75b5c2b | refs/heads/master | 2021-01-10T04:04:45.575806 | 2011-06-09T12:56:05 | 2011-06-09T12:56:05 | 53,861,788 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,449 | h | #pragma once
#include <toeBox2DBody.h>
#include <Box2D\Box2D.h>
namespace TinyOpenEngine
{
class CtoeBox2DSingleShape : public CtoeBox2DBody
{
protected:
/// The friction coefficient, usually in the range [0,1].
float32 friction;
/// The restitution (elasticity) usually in the range [0,1].
float32 restitution;
/// The density, usually in kg/m^2.
float32 density;
/// A sensor shape collects contact information but never generates a collision
/// response.
bool isSensor;
/// The collision category bits. Normally you would just set one bit.
uint16 categoryBits;
/// The collision mask bits. This states the categories that this
/// shape would accept for collision.
uint16 maskBits;
/// Collision groups allow a certain group of objects to never collide (negative)
/// or always collide (positive). Zero means no collision group. Non-zero group
/// filtering always wins against the mask bits.
int16 groupIndex;
b2Fixture* fixture;
public:
//Constructor
CtoeBox2DSingleShape();
//Desctructor
virtual ~CtoeBox2DSingleShape();
virtual void CreateShape(b2Body* body);
//Reads/writes a binary file using @a IwSerialise interface.
virtual void Serialise ();
#ifdef IW_BUILD_RESOURCES
//Parses from text file: parses attribute/value pair.
virtual bool ParseAttribute(CIwTextParserITX* pParser, const char* pAttrName);
#endif
};
} | [
"[email protected]"
]
| [
[
[
1,
52
]
]
]
|
9d832a59d42dabbda91b0961e9793c9360bd9d3c | 81e051c660949ac0e89d1e9cf286e1ade3eed16a | /quake3ce/code/botlib/be_interface.cpp | 24d64fcce51a38d24f2deb14414af2800566499f | []
| no_license | crioux/q3ce | e89c3b60279ea187a2ebcf78dbe1e9f747a31d73 | 5e724f55940ac43cb25440a65f9e9e12220c9ada | refs/heads/master | 2020-06-04T10:29:48.281238 | 2008-11-16T15:00:38 | 2008-11-16T15:00:38 | 32,103,416 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 29,934 | cpp | /*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
/*****************************************************************************
* name: be_interface.c // bk010221 - FIXME - DEAD code elimination
*
* desc: bot library interface
*
* $Archive: /MissionPack/code/botlib/be_interface.c $
*
*****************************************************************************/
#include"botlib_pch.h"
//library globals in a structure
botlib_globals_t botlibglobals;
botlib_export_t be_botlib_export;
botlib_import_t botimport;
//
int bl_bot_developer;
//qtrue if the library is setup
int botlibsetup = qfalse;
//===========================================================================
//
// several functions used by the exported functions
//
//===========================================================================
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
int Sys_MilliSeconds(void)
{
#ifdef _WIN32
return GetTickCount();
#else
time_t tm;
time(&tm);
return (int)tm;
#endif
} //end of the function Sys_MilliSeconds
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
qboolean ValidClientNumber(int num, char *str)
{
if (num < 0 || num > botlibglobals.maxclients)
{
//weird: the disabled stuff results in a crash
botimport.Print(PRT_ERROR, "%s: invalid client number %d, [0, %d]\n",
str, num, botlibglobals.maxclients);
return qfalse;
} //end if
return qtrue;
} //end of the function BotValidateClientNumber
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
qboolean ValidEntityNumber(int num, const char *str)
{
if (num < 0 || num > botlibglobals.maxentities)
{
botimport.Print(PRT_ERROR, "%s: invalid entity number %d, [0, %d]\n",
str, num, botlibglobals.maxentities);
return qfalse;
} //end if
return qtrue;
} //end of the function BotValidateClientNumber
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
qboolean BotLibSetup(const char *str)
{
if (!botlibglobals.botlibsetup)
{
botimport.Print(PRT_ERROR, "%s: bot library used before being setup\n", str);
return qfalse;
} //end if
return qtrue;
} //end of the function BotLibSetup
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
int Export_BotLibSetup(void)
{
int errnum;
bl_bot_developer = FIXED_TO_INT(LibVarGetValue("bot_developer"));
memset( &botlibglobals, 0, sizeof(botlibglobals) ); // bk001207 - init
//initialize byte swapping (litte endian etc.)
// Swap_Init();
Log_Open("botlib.log");
//
botimport.Print(PRT_MESSAGE, "------- BotLib Initialization -------\n");
//
botlibglobals.maxclients = FIXED_TO_INT(LibVarValue("maxclients", "128"));
botlibglobals.maxentities = FIXED_TO_INT(LibVarValue("maxentities", "1024"));
errnum = AAS_Setup(); //be_aas_main.c
if (errnum != BLERR_NOERROR) return errnum;
errnum = EA_Setup(); //be_ea.c
if (errnum != BLERR_NOERROR) return errnum;
errnum = BotSetupWeaponAI(); //be_ai_weap.c
if (errnum != BLERR_NOERROR)return errnum;
errnum = BotSetupGoalAI(); //be_ai_goal.c
if (errnum != BLERR_NOERROR) return errnum;
errnum = BotSetupChatAI(); //be_ai_chat.c
if (errnum != BLERR_NOERROR) return errnum;
errnum = BotSetupMoveAI(); //be_ai_move.c
if (errnum != BLERR_NOERROR) return errnum;
botlibsetup = qtrue;
botlibglobals.botlibsetup = qtrue;
return BLERR_NOERROR;
} //end of the function Export_BotLibSetup
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
int Export_BotLibShutdown(void)
{
if (!BotLibSetup("BotLibShutdown")) return BLERR_LIBRARYNOTSETUP;
#ifndef DEMO
//DumpFileCRCs();
#endif //DEMO
//
BotShutdownChatAI(); //be_ai_chat.c
BotShutdownMoveAI(); //be_ai_move.c
BotShutdownGoalAI(); //be_ai_goal.c
BotShutdownWeaponAI(); //be_ai_weap.c
BotShutdownWeights(); //be_ai_weight.c
BotShutdownCharacters(); //be_ai_char.c
//shud down aas
AAS_Shutdown();
//shut down bot elemantary actions
EA_Shutdown();
//free all libvars
LibVarDeAllocAll();
//remove all global defines from the pre compiler
PC_RemoveAllGlobalDefines();
//dump all allocated memory
// DumpMemory();
#ifdef DEBUG
PrintMemoryLabels();
#endif
//shut down library log file
Log_Shutdown();
//
botlibsetup = qfalse;
botlibglobals.botlibsetup = qfalse;
// print any files still open
PC_CheckOpenSourceHandles();
//
return BLERR_NOERROR;
} //end of the function Export_BotLibShutdown
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
int Export_BotLibVarSet(const char *var_name, const char *value)
{
LibVarSet(var_name, value);
return BLERR_NOERROR;
} //end of the function Export_BotLibVarSet
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
int Export_BotLibVarGet(const char *var_name, char *value, int size)
{
const char *varvalue;
varvalue = LibVarGetString(var_name);
strncpy(value, varvalue, size-1);
value[size-1] = '\0';
return BLERR_NOERROR;
} //end of the function Export_BotLibVarGet
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
int Export_BotLibStartFrame(gfixed time)
{
if (!BotLibSetup("BotStartFrame")) return BLERR_LIBRARYNOTSETUP;
return AAS_StartFrame(time);
} //end of the function Export_BotLibStartFrame
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
int Export_BotLibLoadMap(const char *mapname)
{
#ifdef DEBUG
int starttime = Sys_MilliSeconds();
#endif
int errnum;
if (!BotLibSetup("BotLoadMap")) return BLERR_LIBRARYNOTSETUP;
//
botimport.Print(PRT_MESSAGE, "------------ Map Loading ------------\n");
//startup AAS for the current map, model and sound index
errnum = AAS_LoadMap(mapname);
if (errnum != BLERR_NOERROR) return errnum;
//initialize the items in the level
BotInitLevelItems(); //be_ai_goal.h
BotSetBrushModelTypes(); //be_ai_move.h
//
botimport.Print(PRT_MESSAGE, "-------------------------------------\n");
#ifdef DEBUG
botimport.Print(PRT_MESSAGE, "map loaded in %d msec\n", Sys_MilliSeconds() - starttime);
#endif
//
return BLERR_NOERROR;
} //end of the function Export_BotLibLoadMap
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
int Export_BotLibUpdateEntity(int ent, bot_entitystate_t *state)
{
if (!BotLibSetup("BotUpdateEntity")) return BLERR_LIBRARYNOTSETUP;
if (!ValidEntityNumber(ent, "BotUpdateEntity")) return BLERR_INVALIDENTITYNUMBER;
return AAS_UpdateEntity(ent, state);
} //end of the function Export_BotLibUpdateEntity
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
void AAS_TestMovementPrediction(int entnum, bvec3_t origin, avec3_t dir);
void ElevatorBottomCenter(aas_reachability_t *reach, bvec3_t bottomcenter);
int BotGetReachabilityToGoal(bvec3_t origin, int areanum,
int lastgoalareanum, int lastareanum,
int *avoidreach, gfixed *avoidreachtimes, int *avoidreachtries,
bot_goal_t *goal, int travelflags, int movetravelflags,
struct bot_avoidspot_s *avoidspots, int numavoidspots, int *flags);
int AAS_PointLight(bvec3_t origin, int *red, int *green, int *blue);
int AAS_TraceAreas(bvec3_t start, bvec3_t end, int *areas, bvec3_t *points, int maxareas);
int AAS_Reachability_WeaponJump(int area1num, int area2num);
int BotFuzzyPointReachabilityArea(bvec3_t origin);
bfixed BotGapDistance(bvec3_t origin, avec3_t hordir, int entnum);
void AAS_FloodAreas(bvec3_t origin);
int BotExportTest(int parm0, char *parm1, bvec3_t parm2, avec3_t parm3)
{
// return AAS_PointLight(parm2, NULL, NULL, NULL);
#ifdef DEBUG
static int area = -1;
static int line[2];
int newarea, i, highlightarea, flood;
// int reachnum;
bvec3_t eye, end, origin;
avec3_t forward, right;
// bvec3_t bottomcenter;
// aas_trace_t trace;
// aas_face_t *face;
// aas_entity_t *ent;
// bsp_trace_t bsptrace;
// aas_reachability_t reach;
// bot_goal_t goal;
// clock_t start_time, end_time;
bvec3_t mins = {-BFIXED(16,0), -BFIXED(16,0), -BFIXED(24,0)};
bvec3_t maxs = {BFIXED(16,0), BFIXED(16,0), BFIXED(32,0)};
// int areas[10], numareas;
//return 0;
if (!aasworld.loaded) return 0;
/*
if (parm0 & 1)
{
AAS_ClearShownPolygons();
AAS_FloodAreas(parm2);
} //end if
return 0;
*/
for (i = 0; i < 2; i++) if (!line[i]) line[i] = botimport.DebugLineCreate();
// AAS_ClearShownDebugLines();
//if (AAS_AgainstLadder(parm2)) botimport.Print(PRT_MESSAGE, "against ladder\n");
//BotOnGround(parm2, PRESENCE_NORMAL, 1, &newarea, &newarea);
//botimport.Print(PRT_MESSAGE, "%f %f %f\n", FIXED_TO_DOUBLE(parm2[0]), FIXED_TO_DOUBLE(parm2[1]), FIXED_TO_DOUBLE(parm2[2]));
//*
highlightarea = FIXED_TO_INT(LibVarGetValue("bot_highlightarea"));
if (highlightarea > 0)
{
newarea = highlightarea;
} //end if
else
{
VectorCopy(parm2, origin);
origin[2] += BFIXED(0,5);
//newarea = AAS_PointAreaNum(origin);
newarea = BotFuzzyPointReachabilityArea(origin);
} //end else
botimport.Print(PRT_MESSAGE, "\rtravel time to goal (%d) = %d ", botlibglobals.goalareanum,
AAS_AreaTravelTimeToGoalArea(newarea, origin, botlibglobals.goalareanum, TFL_DEFAULT));
//newarea = BotReachabilityArea(origin, qtrue);
if (newarea != area)
{
botimport.Print(PRT_MESSAGE, "origin = %f, %f, %f\n", FIXED_TO_DOUBLE(origin[0]), FIXED_TO_DOUBLE(origin[1]), FIXED_TO_DOUBLE(origin[2]));
area = newarea;
botimport.Print(PRT_MESSAGE, "new area %d, cluster %d, presence type %d\n",
area, AAS_AreaCluster(area), AAS_PointPresenceType(origin));
botimport.Print(PRT_MESSAGE, "area contents: ");
if (aasworld.areasettings[area].contents & AREACONTENTS_WATER)
{
botimport.Print(PRT_MESSAGE, "water &");
} //end if
if (aasworld.areasettings[area].contents & AREACONTENTS_LAVA)
{
botimport.Print(PRT_MESSAGE, "lava &");
} //end if
if (aasworld.areasettings[area].contents & AREACONTENTS_SLIME)
{
botimport.Print(PRT_MESSAGE, "slime &");
} //end if
if (aasworld.areasettings[area].contents & AREACONTENTS_JUMPPAD)
{
botimport.Print(PRT_MESSAGE, "jump pad &");
} //end if
if (aasworld.areasettings[area].contents & AREACONTENTS_CLUSTERPORTAL)
{
botimport.Print(PRT_MESSAGE, "cluster portal &");
} //end if
if (aasworld.areasettings[area].contents & AREACONTENTS_VIEWPORTAL)
{
botimport.Print(PRT_MESSAGE, "view portal &");
} //end if
if (aasworld.areasettings[area].contents & AREACONTENTS_DONOTENTER)
{
botimport.Print(PRT_MESSAGE, "do not enter &");
} //end if
if (aasworld.areasettings[area].contents & AREACONTENTS_MOVER)
{
botimport.Print(PRT_MESSAGE, "mover &");
} //end if
if (!aasworld.areasettings[area].contents)
{
botimport.Print(PRT_MESSAGE, "empty");
} //end if
botimport.Print(PRT_MESSAGE, "\n");
botimport.Print(PRT_MESSAGE, "travel time to goal (%d) = %d\n", botlibglobals.goalareanum,
AAS_AreaTravelTimeToGoalArea(newarea, origin, botlibglobals.goalareanum, TFL_DEFAULT|TFL_ROCKETJUMP));
/*
VectorCopy(origin, end);
end[2] += 5;
numareas = AAS_TraceAreas(origin, end, areas, NULL, 10);
AAS_TraceClientBBox(origin, end, PRESENCE_CROUCH, -1);
botimport.Print(PRT_MESSAGE, "num areas = %d, area = %d\n", numareas, areas[0]);
*/
/*
botlibglobals.goalareanum = newarea;
VectorCopy(parm2, botlibglobals.goalorigin);
botimport.Print(PRT_MESSAGE, "new goal %2.1f %2.1f %2.1f area %d\n",
origin[0], origin[1], origin[2], newarea);
*/
} //end if
//*
flood = FIXED_TO_INT(LibVarGetValue("bot_flood"));
if (parm0 & 1)
{
if (flood)
{
AAS_ClearShownPolygons();
AAS_ClearShownDebugLines();
AAS_FloodAreas(parm2);
}
else
{
botlibglobals.goalareanum = newarea;
VectorCopy(parm2, botlibglobals.goalorigin);
botimport.Print(PRT_MESSAGE, "new goal %2.1f %2.1f %2.1f area %d\n",
origin[0], origin[1], origin[2], newarea);
}
} //end if*/
if (flood)
return 0;
// if (parm0 & BUTTON_USE)
// {
// botlibglobals.runai = !botlibglobals.runai;
// if (botlibglobals.runai) botimport.Print(PRT_MESSAGE, "started AI\n");
// else botimport.Print(PRT_MESSAGE, "stopped AI\n");
//* /
/*
goal.areanum = botlibglobals.goalareanum;
reachnum = BotGetReachabilityToGoal(parm2, newarea, 1,
ms.avoidreach, ms.avoidreachtimes,
&goal, TFL_DEFAULT);
if (!reachnum)
{
botimport.Print(PRT_MESSAGE, "goal not reachable\n");
} //end if
else
{
AAS_ReachabilityFromNum(reachnum, &reach);
AAS_ClearShownDebugLines();
AAS_ShowArea(area, qtrue);
AAS_ShowArea(reach.areanum, qtrue);
AAS_DrawCross(reach.start, 6, LINECOLOR_BLUE);
AAS_DrawCross(reach.end, 6, LINECOLOR_RED);
//
if ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_ELEVATOR)
{
ElevatorBottomCenter(&reach, bottomcenter);
AAS_DrawCross(bottomcenter, 10, LINECOLOR_GREEN);
} //end if
} //end else*/
// botimport.Print(PRT_MESSAGE, "travel time to goal = %d\n",
// AAS_AreaTravelTimeToGoalArea(area, origin, botlibglobals.goalareanum, TFL_DEFAULT));
// botimport.Print(PRT_MESSAGE, "test rj from 703 to 716\n");
// AAS_Reachability_WeaponJump(703, 716);
// } //end if*/
/* face = AAS_AreaGroundFace(newarea, parm2);
if (face)
{
AAS_ShowFace(face - aasworld.faces);
} //end if*/
/*
AAS_ClearShownDebugLines();
AAS_ShowArea(newarea, parm0 & BUTTON_USE);
AAS_ShowReachableAreas(area);
*/
AAS_ClearShownPolygons();
AAS_ClearShownDebugLines();
AAS_ShowAreaPolygons(newarea, 1, parm0 & 4);
if (parm0 & 2) AAS_ShowReachableAreas(area);
else
{
static int lastgoalareanum, lastareanum;
static int avoidreach[MAX_AVOIDREACH];
static gfixed avoidreachtimes[MAX_AVOIDREACH];
static int avoidreachtries[MAX_AVOIDREACH];
int reachnum, resultFlags;
bot_goal_t goal;
aas_reachability_t reach;
/*
goal.areanum = botlibglobals.goalareanum;
VectorCopy(botlibglobals.goalorigin, goal.origin);
reachnum = BotGetReachabilityToGoal(origin, newarea,
lastgoalareanum, lastareanum,
avoidreach, avoidreachtimes, avoidreachtries,
&goal, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP,
NULL, 0, &resultFlags);
AAS_ReachabilityFromNum(reachnum, &reach);
AAS_ShowReachability(&reach);
*/
int curarea;
bvec3_t curorigin;
goal.areanum = botlibglobals.goalareanum;
VectorCopy(botlibglobals.goalorigin, goal.origin);
VectorCopy(origin, curorigin);
curarea = newarea;
for ( i = 0; i < 100; i++ ) {
if ( curarea == goal.areanum ) {
break;
}
reachnum = BotGetReachabilityToGoal(curorigin, curarea,
lastgoalareanum, lastareanum,
avoidreach, avoidreachtimes, avoidreachtries,
&goal, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP,
NULL, 0, &resultFlags);
AAS_ReachabilityFromNum(reachnum, &reach);
AAS_ShowReachability(&reach);
VectorCopy(reach.end, origin);
lastareanum = curarea;
curarea = reach.areanum;
}
} //end else
VectorClear(forward);
//BotGapDistance(origin, forward, 0);
/*
if (parm0 & BUTTON_USE)
{
botimport.Print(PRT_MESSAGE, "test rj from 703 to 716\n");
AAS_Reachability_WeaponJump(703, 716);
} //end if*/
AngleVectors(parm3, forward, right, NULL);
//get the eye 16 units to the right of the origin
FIXED_VEC3MA_R(parm2, BFIXED(8,0), right, eye);
//get the eye 24 units up
eye[2] += BFIXED(24,0);
//get the end point for the line to be traced
FIXED_VEC3MA_R(eye, BFIXED(800,0), forward, end);
// AAS_TestMovementPrediction(1, parm2, forward);
/*
//trace the line to find the hit point
trace = AAS_TraceClientBBox(eye, end, PRESENCE_NORMAL, 1);
if (!line[0]) line[0] = botimport.DebugLineCreate();
botimport.DebugLineShow(line[0], eye, trace.endpos, LINECOLOR_BLUE);
//
AAS_ClearShownDebugLines();
if (trace.ent)
{
ent = &aasworld.entities[trace.ent];
AAS_ShowBoundingBox(ent->origin, ent->mins, ent->maxs);
} //end if
*/
/*
start_time = clock();
for (i = 0; i < 2000; i++)
{
AAS_Trace2(eye, mins, maxs, end, 1, MASK_PLAYERSOLID);
// AAS_TraceClientBBox(eye, end, PRESENCE_NORMAL, 1);
} //end for
end_time = clock();
botimport.Print(PRT_MESSAGE, "me %lu clocks, %lu CLOCKS_PER_SEC\n", end_time - start_time, CLOCKS_PER_SEC);
start_time = clock();
for (i = 0; i < 2000; i++)
{
AAS_Trace(eye, mins, maxs, end, 1, MASK_PLAYERSOLID);
} //end for
end_time = clock();
botimport.Print(PRT_MESSAGE, "id %lu clocks, %lu CLOCKS_PER_SEC\n", end_time - start_time, CLOCKS_PER_SEC);
*/
// TTimo: nested comments are BAD for gcc -Werror, use #if 0 instead..
#if 0
AAS_ClearShownDebugLines();
//bsptrace = AAS_Trace(eye, NULL, NULL, end, 1, MASK_PLAYERSOLID);
bsptrace = AAS_Trace(eye, mins, maxs, end, 1, MASK_PLAYERSOLID);
if (!line[0]) line[0] = botimport.DebugLineCreate();
botimport.DebugLineShow(line[0], eye, bsptrace.endpos, LINECOLOR_YELLOW);
if (bsptrace.fraction < BFIXED_1)
{
face = AAS_TraceEndFace(&trace);
if (face)
{
AAS_ShowFace(face - aasworld.faces);
} //end if
AAS_DrawPlaneCross(bsptrace.endpos,
bsptrace.plane.normal,
bsptrace.plane.dist + bsptrace.exp_dist,
bsptrace.plane.type, LINECOLOR_GREEN);
if (trace.ent)
{
ent = &aasworld.entities[trace.ent];
AAS_ShowBoundingBox(ent->origin, ent->mins, ent->maxs);
} //end if
} //end if
//bsptrace = AAS_Trace2(eye, NULL, NULL, end, 1, MASK_PLAYERSOLID);
bsptrace = AAS_Trace2(eye, mins, maxs, end, 1, MASK_PLAYERSOLID);
botimport.DebugLineShow(line[1], eye, bsptrace.endpos, LINECOLOR_BLUE);
if (bsptrace.fraction < BFIXED_1)
{
AAS_DrawPlaneCross(bsptrace.endpos,
bsptrace.plane.normal,
bsptrace.plane.dist,// + bsptrace.exp_dist,
bsptrace.plane.type, LINECOLOR_RED);
if (bsptrace.ent)
{
ent = &aasworld.entities[bsptrace.ent];
AAS_ShowBoundingBox(ent->origin, ent->mins, ent->maxs);
} //end if
} //end if
#endif
#endif
return 0;
} //end of the function BotExportTest
/*
============
Init_AAS_Export
============
*/
static void Init_AAS_Export( aas_export_t *aas ) {
//--------------------------------------------
// be_aas_entity.c
//--------------------------------------------
aas->AAS_EntityInfo = AAS_EntityInfo;
//--------------------------------------------
// be_aas_main.c
//--------------------------------------------
aas->AAS_Initialized = AAS_Initialized;
aas->AAS_PresenceTypeBoundingBox = AAS_PresenceTypeBoundingBox;
aas->AAS_Time = AAS_Time;
//--------------------------------------------
// be_aas_sample.c
//--------------------------------------------
aas->AAS_PointAreaNum = AAS_PointAreaNum;
aas->AAS_PointReachabilityAreaIndex = AAS_PointReachabilityAreaIndex;
aas->AAS_TraceAreas = AAS_TraceAreas;
aas->AAS_BBoxAreas = AAS_BBoxAreas;
aas->AAS_AreaInfo = AAS_AreaInfo;
//--------------------------------------------
// be_aas_bspq3.c
//--------------------------------------------
aas->AAS_PointContents = AAS_PointContents;
aas->AAS_NextBSPEntity = AAS_NextBSPEntity;
aas->AAS_ValueForBSPEpairKey = AAS_ValueForBSPEpairKey;
aas->AAS_VectorForBSPEpairKey = AAS_VectorForBSPEpairKey;
aas->AAS_FloatForBSPEpairKey = AAS_FloatForBSPEpairKey;
aas->AAS_IntForBSPEpairKey = AAS_IntForBSPEpairKey;
//--------------------------------------------
// be_aas_reach.c
//--------------------------------------------
aas->AAS_AreaReachability = AAS_AreaReachability;
//--------------------------------------------
// be_aas_route.c
//--------------------------------------------
aas->AAS_AreaTravelTimeToGoalArea = AAS_AreaTravelTimeToGoalArea;
aas->AAS_EnableRoutingArea = AAS_EnableRoutingArea;
aas->AAS_PredictRoute = AAS_PredictRoute;
//--------------------------------------------
// be_aas_altroute.c
//--------------------------------------------
aas->AAS_AlternativeRouteGoals = AAS_AlternativeRouteGoals;
//--------------------------------------------
// be_aas_move.c
//--------------------------------------------
aas->AAS_Swimming = AAS_Swimming;
aas->AAS_PredictClientMovement = AAS_PredictClientMovement;
}
/*
============
Init_EA_Export
============
*/
static void Init_EA_Export( ea_export_t *ea ) {
//ClientCommand elementary actions
ea->EA_Command = EA_Command;
ea->EA_Say = EA_Say;
ea->EA_SayTeam = EA_SayTeam;
ea->EA_Action = EA_Action;
ea->EA_Gesture = EA_Gesture;
ea->EA_Talk = EA_Talk;
ea->EA_Attack = EA_Attack;
ea->EA_Use = EA_Use;
ea->EA_Respawn = EA_Respawn;
ea->EA_Crouch = EA_Crouch;
ea->EA_MoveUp = EA_MoveUp;
ea->EA_MoveDown = EA_MoveDown;
ea->EA_MoveForward = EA_MoveForward;
ea->EA_MoveBack = EA_MoveBack;
ea->EA_MoveLeft = EA_MoveLeft;
ea->EA_MoveRight = EA_MoveRight;
ea->EA_SelectWeapon = EA_SelectWeapon;
ea->EA_Jump = EA_Jump;
ea->EA_DelayedJump = EA_DelayedJump;
ea->EA_Move = EA_Move;
ea->EA_View = EA_View;
ea->EA_GetInput = EA_GetInput;
ea->EA_EndRegular = EA_EndRegular;
ea->EA_ResetInput = EA_ResetInput;
}
/*
============
Init_AI_Export
============
*/
static void Init_AI_Export( ai_export_t *ai ) {
//-----------------------------------
// be_ai_char.h
//-----------------------------------
ai->BotLoadCharacter = BotLoadCharacter;
ai->BotFreeCharacter = BotFreeCharacter;
ai->Characteristic_Float = Characteristic_Float;
ai->Characteristic_BFloat = Characteristic_BFloat;
ai->Characteristic_Integer = Characteristic_Integer;
ai->Characteristic_BInteger = Characteristic_BInteger;
ai->Characteristic_String = Characteristic_String;
//-----------------------------------
// be_ai_chat.h
//-----------------------------------
ai->BotAllocChatState = BotAllocChatState;
ai->BotFreeChatState = BotFreeChatState;
ai->BotQueueConsoleMessage = BotQueueConsoleMessage;
ai->BotRemoveConsoleMessage = BotRemoveConsoleMessage;
ai->BotNextConsoleMessage = BotNextConsoleMessage;
ai->BotNumConsoleMessages = BotNumConsoleMessages;
ai->BotInitialChat = BotInitialChat;
ai->BotNumInitialChats = BotNumInitialChats;
ai->BotReplyChat = BotReplyChat;
ai->BotChatLength = BotChatLength;
ai->BotEnterChat = BotEnterChat;
ai->BotGetChatMessage = BotGetChatMessage;
ai->StringContains = StringContains;
ai->BotFindMatch = BotFindMatch;
ai->BotMatchVariable = BotMatchVariable;
ai->UnifyWhiteSpaces = UnifyWhiteSpaces;
ai->BotReplaceSynonyms = BotReplaceSynonyms;
ai->BotLoadChatFile = BotLoadChatFile;
ai->BotSetChatGender = BotSetChatGender;
ai->BotSetChatName = BotSetChatName;
//-----------------------------------
// be_ai_goal.h
//-----------------------------------
ai->BotResetGoalState = BotResetGoalState;
ai->BotResetAvoidGoals = BotResetAvoidGoals;
ai->BotRemoveFromAvoidGoals = BotRemoveFromAvoidGoals;
ai->BotPushGoal = BotPushGoal;
ai->BotPopGoal = BotPopGoal;
ai->BotEmptyGoalStack = BotEmptyGoalStack;
ai->BotDumpAvoidGoals = BotDumpAvoidGoals;
ai->BotDumpGoalStack = BotDumpGoalStack;
ai->BotGoalName = BotGoalName;
ai->BotGetTopGoal = BotGetTopGoal;
ai->BotGetSecondGoal = BotGetSecondGoal;
ai->BotChooseLTGItem = BotChooseLTGItem;
ai->BotChooseNBGItem = BotChooseNBGItem;
ai->BotTouchingGoal = BotTouchingGoal;
ai->BotItemGoalInVisButNotVisible = BotItemGoalInVisButNotVisible;
ai->BotGetLevelItemGoal = BotGetLevelItemGoal;
ai->BotGetNextCampSpotGoal = BotGetNextCampSpotGoal;
ai->BotGetMapLocationGoal = BotGetMapLocationGoal;
ai->BotAvoidGoalTime = BotAvoidGoalTime;
ai->BotSetAvoidGoalTime = BotSetAvoidGoalTime;
ai->BotInitLevelItems = BotInitLevelItems;
ai->BotUpdateEntityItems = BotUpdateEntityItems;
ai->BotLoadItemWeights = BotLoadItemWeights;
ai->BotFreeItemWeights = BotFreeItemWeights;
ai->BotInterbreedGoalFuzzyLogic = BotInterbreedGoalFuzzyLogic;
ai->BotSaveGoalFuzzyLogic = BotSaveGoalFuzzyLogic;
ai->BotMutateGoalFuzzyLogic = BotMutateGoalFuzzyLogic;
ai->BotAllocGoalState = BotAllocGoalState;
ai->BotFreeGoalState = BotFreeGoalState;
//-----------------------------------
// be_ai_move.h
//-----------------------------------
ai->BotResetMoveState = BotResetMoveState;
ai->BotMoveToGoal = BotMoveToGoal;
ai->BotMoveInDirection = BotMoveInDirection;
ai->BotResetAvoidReach = BotResetAvoidReach;
ai->BotResetLastAvoidReach = BotResetLastAvoidReach;
ai->BotReachabilityArea = BotReachabilityArea;
ai->BotMovementViewTarget = BotMovementViewTarget;
ai->BotPredictVisiblePosition = BotPredictVisiblePosition;
ai->BotAllocMoveState = BotAllocMoveState;
ai->BotFreeMoveState = BotFreeMoveState;
ai->BotInitMoveState = BotInitMoveState;
ai->BotAddAvoidSpot = BotAddAvoidSpot;
//-----------------------------------
// be_ai_weap.h
//-----------------------------------
ai->BotChooseBestFightWeapon = BotChooseBestFightWeapon;
ai->BotGetWeaponInfo = BotGetWeaponInfo;
ai->BotLoadWeaponWeights = BotLoadWeaponWeights;
ai->BotAllocWeaponState = BotAllocWeaponState;
ai->BotFreeWeaponState = BotFreeWeaponState;
ai->BotResetWeaponState = BotResetWeaponState;
//-----------------------------------
// be_ai_gen.h
//-----------------------------------
ai->GeneticParentsAndChildSelection = GeneticParentsAndChildSelection;
}
/*
============
GetBotLibAPI
============
*/
botlib_export_t *GetBotLibAPI(int apiVersion, botlib_import_t *import) {
assert(import); // bk001129 - this wasn't set for baseq3/
botimport = *import;
assert(botimport.Print); // bk001129 - pars pro toto
Com_Memset( &be_botlib_export, 0, sizeof( be_botlib_export ) );
if ( apiVersion != BOTLIB_API_VERSION ) {
botimport.Print( PRT_ERROR, "Mismatched BOTLIB_API_VERSION: expected %i, got %i\n", BOTLIB_API_VERSION, apiVersion );
return NULL;
}
Init_AAS_Export(&be_botlib_export.aas);
Init_EA_Export(&be_botlib_export.ea);
Init_AI_Export(&be_botlib_export.ai);
be_botlib_export.BotLibSetup = Export_BotLibSetup;
be_botlib_export.BotLibShutdown = Export_BotLibShutdown;
be_botlib_export.BotLibVarSet = Export_BotLibVarSet;
be_botlib_export.BotLibVarGet = Export_BotLibVarGet;
be_botlib_export.PC_AddGlobalDefine = PC_AddGlobalDefine;
be_botlib_export.PC_LoadSourceHandle = PC_LoadSourceHandle;
be_botlib_export.PC_FreeSourceHandle = PC_FreeSourceHandle;
be_botlib_export.PC_ReadTokenHandle = PC_ReadTokenHandle;
be_botlib_export.PC_SourceFileAndLine = PC_SourceFileAndLine;
be_botlib_export.BotLibStartFrame = Export_BotLibStartFrame;
be_botlib_export.BotLibLoadMap = Export_BotLibLoadMap;
be_botlib_export.BotLibUpdateEntity = Export_BotLibUpdateEntity;
be_botlib_export.Test = BotExportTest;
return &be_botlib_export;
}
| [
"jack.palevich@684fc592-8442-0410-8ea1-df6b371289ac",
"crioux@684fc592-8442-0410-8ea1-df6b371289ac"
]
| [
[
[
1,
58
],
[
60,
60
],
[
66,
89
],
[
91,
105
],
[
107,
203
],
[
205,
214
],
[
216,
216
],
[
218,
868
]
],
[
[
59,
59
],
[
61,
65
],
[
90,
90
],
[
106,
106
],
[
204,
204
],
[
215,
215
],
[
217,
217
]
]
]
|
6d6ed0f08ddc874fa0565a31ef7abf942d2fda4e | 37f1b00f0aba269599453952c0394b105b797744 | /classes/ugrad/csce3110/assignments/03_binary_tree/Tree.h | 646f9206e7c05624bb0909467335ba478301508d | []
| no_license | palmerc/lab | 58e95801619a4d9c00a8e1caae8d872952d455b0 | d9c36b84dac060ce8c74251f6c42b121653dd837 | refs/heads/master | 2016-09-06T09:43:12.532000 | 2010-09-10T14:23:58 | 2010-09-10T14:23:58 | 16,708,989 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 8,825 | h | // Tree.h
// Template Tree class definition.
#ifndef TREE_H
#define TREE_H
#include <iostream>
using std::cout;
using std::endl;
#include <new>
#include "Treenode.h"
// Tree class-template definition
template< typename NODETYPE > class Tree
{
public:
Tree(); // constructor
void insertNode( const NODETYPE & );
void removeNode( const NODETYPE & );
void preOrderTraversal() const;
void inOrderTraversal() const;
void postOrderTraversal() const;
Tree< NODETYPE > ** findNode( const NODETYPE & );
private:
TreeNode< NODETYPE > *rootPtr;
// utility functions
void insertNodeHelper( TreeNode< NODETYPE > *, TreeNode< NODETYPE > **, const NODETYPE & );
void removeNodeHelper( TreeNode< NODETYPE > **, const NODETYPE & );
void preOrderHelper( TreeNode< NODETYPE > * ) const;
void inOrderHelper( TreeNode< NODETYPE > * ) const;
void postOrderHelper( TreeNode< NODETYPE > * ) const;
}; // end class Tree
// constructor
template< typename NODETYPE >
Tree< NODETYPE >::Tree()
{
rootPtr = 0; // indicate tree is initially empty
} // end Tree constructor
// insert node in Tree
template< typename NODETYPE >
void Tree< NODETYPE >::insertNode( const NODETYPE &value )
{
insertNodeHelper( 0, &rootPtr, value );
} // end function insertNode
// utility function called by insertNode; receives a pointer
// to a pointer so that the function can modify pointer's value
template< typename NODETYPE >
void Tree< NODETYPE >::insertNodeHelper(
TreeNode< NODETYPE > *parent, TreeNode< NODETYPE > **ptr, const NODETYPE &value )
{
cout << "Insert " << parent << " " << *ptr << " " << value << endl;
// subtree is empty; create new TreeNode containing value
if ( *ptr == 0 )
*ptr = new TreeNode< NODETYPE >( parent, value );
else // subtree is not empty
{
// data to insert is less than data in current node
if ( value < ( *ptr )->data )
insertNodeHelper( *ptr, &( ( *ptr )->leftPtr ), value );
else
{
// data to insert is greater than data in current node
if ( value > ( *ptr )->data )
insertNodeHelper( *ptr, &( ( *ptr )->rightPtr ), value );
else // duplicate data value ignored
cout << value << " dup" << endl;
} // end else
} // end else
} // end function insertNodeHelper
// remove node in Tree
template< typename NODETYPE >
void Tree< NODETYPE >::removeNode( const NODETYPE &value )
{
removeNodeHelper( &rootPtr, value );
} // end function removeNode
template< typename NODETYPE >
Tree< NODETYPE >** Tree< NODETYPE >::findNode( const NODETYPE &value )
{
TreeNode< NODETYPE > *ptr = *rootPtr;
while ( ( *ptr )->data != value )
{
if ( value < ( *ptr )->data )
*ptr = ( *ptr )->leftPtr;
else if ( value > ( *ptr )->data )
*ptr = ( *ptr )->rightPtr;
}
return *ptr;
}
// utility function called by removeNode; receives a pointer
// to a pointer so that the function can modify pointer's value
template< typename NODETYPE >
void Tree< NODETYPE >::removeNodeHelper(
TreeNode< NODETYPE > **ptr, const NODETYPE &value )
{
if ( value < ( *ptr )->data )
removeNodeHelper( &( ( *ptr )->leftPtr ), value );
else if ( value > ( *ptr )->data )
removeNodeHelper( &( ( *ptr )->rightPtr ), value );
else if ( ( *ptr )->leftPtr != 0 && ( *ptr )->rightPtr != 0 ) // Two children
{
if ( ( *ptr )->rightPtr->leftPtr != 0 ) // In order successor
{
cout << "This" << endl;
( *ptr )->rightPtr->leftPtr->parentPtr = ( *ptr )->parentPtr;
// Connect with my new parent
// If I am my parent's right child
if ( ( *ptr )->parentPtr->rightPtr == *ptr)
( *ptr )->parentPtr->rightPtr = ( *ptr )->rightPtr->leftPtr;
else // If I am my parent's left child
( *ptr )->parentPtr->leftPtr = ( *ptr )->rightPtr->leftPtr;
// Change the in order successors parent
//delete *ptr;
}
else
{
cout << "Promote the right one" << endl;
// Fix the parent ptr of my replacement
//cout << ( *ptr )->leftPtr->data << endl;
( *ptr )->rightPtr->leftPtr = ( *ptr )->leftPtr;
// Fix the parent ptr to me
if ( ( *ptr )->parentPtr != 0 ) // If you aren't root
{
( *ptr )->rightPtr->parentPtr = ( *ptr )->parentPtr;
if ( ( *ptr )->parentPtr->rightPtr == *ptr)
( *ptr )->parentPtr->rightPtr = ( *ptr )->rightPtr;
else // If I am my parent's left child
( *ptr )->parentPtr->leftPtr = ( *ptr )->rightPtr;
}
}
}
else if ( ( *ptr )->leftPtr != 0 ) // if it has only a left child
{
( *ptr )->leftPtr->parentPtr = ( *ptr )->parentPtr;
// I am connected to the right of the parent
if ( ( *ptr )->parentPtr->rightPtr == *ptr)
( *ptr )->parentPtr->rightPtr = ( *ptr )->leftPtr;
else // If I am my parent's left child
( *ptr )->parentPtr->leftPtr = ( *ptr )->leftPtr;
// Assign the left child my parent
//delete *ptr;
}
else if ( ( *ptr )->rightPtr != 0 ) // if it has only a right child
{
//cout << "Delete with Right child only " << ( *ptr )->parentPtr << endl;
( *ptr )->rightPtr->parentPtr = ( *ptr )->parentPtr;
//cout << "double checking " << ( *ptr )->rightPtr->parentPtr;
// I am connected to the right of the parent
//cout << ( *ptr )->parentPtr->rightPtr << "==" << *ptr << endl;
//cout << ( *ptr )->parentPtr->leftPtr << "==" << *ptr << endl;
if ( ( *ptr )->parentPtr->rightPtr == *ptr)
{
//cout << "tick1" << endl;
// Assign the right child to the parents right side
( *ptr )->parentPtr->rightPtr = ( *ptr )->rightPtr;
}
else // If I am my parent's left child
{
//cout << "tick2" << endl;
( *ptr )->parentPtr->leftPtr = ( *ptr )->rightPtr;
}
// Assign the right child my parent
//cout << "tick3" << endl;
//cout << "tick4" << endl;
//delete *ptr;
}
else // No children - Tested
{
//cout << "No Children" << endl;
//cout << ( *ptr )->parentPtr->rightPtr << "==" << *ptr << endl;
//cout << ( *ptr )->parentPtr->leftPtr << "==" << *ptr << endl;
// I am connected to the right of the parent
//cout << "This old value" << ( *ptr )->parentPtr->data << endl;
if ( ( *ptr )->parentPtr->rightPtr == *ptr)
( *ptr )->parentPtr->rightPtr = 0;
else // If I am my parent's left child
( *ptr )->parentPtr->leftPtr = 0;
delete *ptr;
}
} // end function removeNodeHelper
// begin preorder traversal of Tree
template< typename NODETYPE >
void Tree< NODETYPE >::preOrderTraversal() const
{
preOrderHelper( rootPtr );
} // end function preOrderTraversal
// utility function to perform preorder traversal of Tree
template< typename NODETYPE >
void Tree< NODETYPE >::preOrderHelper( TreeNode< NODETYPE > *ptr ) const
{
if ( ptr != 0 )
{
cout << ptr->data << ' '; // process node
preOrderHelper( ptr->leftPtr ); // traverse left subtree
preOrderHelper( ptr->rightPtr ); // traverse right subtree
} // end if
} // end function preOrderHelper
// begin inorder traversal of Tree
template< typename NODETYPE >
void Tree< NODETYPE >::inOrderTraversal() const
{
inOrderHelper( rootPtr );
} // end function inOrderTraversal
// utility function to perform inorder traversal of Tree
template< typename NODETYPE >
void Tree< NODETYPE >::inOrderHelper( TreeNode< NODETYPE > *ptr ) const
{
if ( ptr != 0 )
{
inOrderHelper( ptr->leftPtr ); // traverse left subtree
cout << ptr->data << ' '; // process node
inOrderHelper( ptr->rightPtr ); // traverse right subtree
} // end if
} // end function inOrderHelper
// begin postorder traversal of Tree
template< typename NODETYPE >
void Tree< NODETYPE >::postOrderTraversal() const
{
postOrderHelper( rootPtr );
} // end function postOrderTraversal
// utility function to perform postorder traversal of Tree
template< typename NODETYPE >
void Tree< NODETYPE >::postOrderHelper(
TreeNode< NODETYPE > *ptr ) const
{
if ( ptr != 0 )
{
postOrderHelper( ptr->leftPtr ); // traverse left subtree
postOrderHelper( ptr->rightPtr ); // traverse right subtree
cout << ptr->data << ' '; // process node
} // end if
} // end function postOrderHelper
#endif
| [
"palmerc@9c8e43f7-b2fe-0310-8927-e999a62a3b53"
]
| [
[
[
1,
250
]
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.