blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
5
146
content_id
stringlengths
40
40
detected_licenses
sequencelengths
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
sequencelengths
1
16
author_lines
sequencelengths
1
16
a81b84041ab23c3191c3b563e001c2848244df51
9b6eced5d80668bd4328a8f3d1f75c97f04f5e08
/bthci/hci2implementations/hctls/usb_original/hctl/src/hctlusboriginalserver.cpp
a29cc5cc2becd15b02f025a967d9eb4b2948e3eb
[]
no_license
SymbianSource/oss.FCL.sf.os.bt
3ca94a01740ac84a6a35718ad3063884ea885738
ba9e7d24a7fa29d6dd93808867c28bffa2206bae
refs/heads/master
2021-01-18T23:42:06.315016
2010-10-14T10:30:12
2010-10-14T10:30:12
72,765,157
1
0
null
null
null
null
UTF-8
C++
false
false
3,502
cpp
// Copyright (c) 2007-2010 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: // /** @file @internalComponent */ #include "hctlusboriginalserver.h" #include "hctlusboriginal.h" #include "hctlusboriginalutils.h" #include "hctlusboriginalpolicy.h" #include <bluetooth/logger.h> #ifdef __FLOG_ACTIVE _LIT8(KLogComponent, LOG_COMPONENT_HCTL_USB_ORIGINAL); #endif CHCTLUsbOriginalServer::CHCTLUsbOriginalServer(CHCTLUsbOriginal& aUsbOriginal) : CPolicyServer(CActive::EPriorityStandard, KHCTLUsbOriginalPolicy) , iUsbOriginal(aUsbOriginal) { LOG_FUNC } void CHCTLUsbOriginalServer::ConstructL() { LOG_FUNC StartL(KHCTLUsbOrginalSrvName); } CHCTLUsbOriginalServer* CHCTLUsbOriginalServer::NewL(CHCTLUsbOriginal& aUsbOriginal) { LOG_STATIC_FUNC CHCTLUsbOriginalServer* self = new(ELeave) CHCTLUsbOriginalServer(aUsbOriginal); CleanupStack::PushL(self); self->ConstructL(); CleanupStack::Pop(); return self; } CHCTLUsbOriginalServer::~CHCTLUsbOriginalServer() { LOG_FUNC } CSession2* CHCTLUsbOriginalServer::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const { LOG_FUNC LOG3(_L8("\taVersion = (%d,%d,%d)"), aVersion.iMajor, aVersion.iMinor, aVersion.iBuild); // Version number check... TVersion v(KHCTLUsbOriginalSrvMajorVersionNumber, KHCTLUsbOriginalSrvMinorVersionNumber, KHCTLUsbOriginalSrvBuildNumber); if(!User::QueryVersionSupported(v, aVersion)) { LEAVEIFERRORL(KErrNotSupported); } if(iSession) { LEAVEIFERRORL(KErrInUse); } iSession = new(ELeave) CHCTLUsbOriginalSession(iUsbOriginal); return iSession; } void CHCTLUsbOriginalServer::DropSession(CHCTLUsbOriginalSession* aSession) const { __ASSERT_DEBUG(iSession == aSession, PANIC(KUsbOriginalPanic, EBadSessionPointer)); iSession = NULL; } CHCTLUsbOriginalSession::CHCTLUsbOriginalSession(CHCTLUsbOriginal& aUsbOriginal) : iUsbOriginal(aUsbOriginal) { LOG_FUNC } CHCTLUsbOriginalSession::~CHCTLUsbOriginalSession() { LOG_FUNC static_cast<const CHCTLUsbOriginalServer*>(Server())->DropSession(this); } void CHCTLUsbOriginalSession::ServiceL(const RMessage2& aMessage) { LOG_FUNC LOG1(_L("\taMessage.Function() = %d"), aMessage.Function()); switch(aMessage.Function()) { case EFunctionAttached: { if(iDeviceAttached) { PANIC_MSG(aMessage, KHCTLUsbOriginalServerPanicCat, EDeviceAlreadyAttached); return; } TUint32 aclToken = static_cast<TUint32>(aMessage.Int0()); TUint32 scoToken = static_cast<TUint32>(aMessage.Int1()); iUsbOriginal.DeviceAttachedL(aclToken, scoToken); iDeviceAttached = ETrue; } break; case EFunctionDetached: { if(!iDeviceAttached) { PANIC_MSG(aMessage, KHCTLUsbOriginalServerPanicCat, EDeviceNotAttached); return; } iUsbOriginal.DeviceRemoved(); iDeviceAttached = EFalse; } break; default: PANIC_MSG(aMessage, KHCTLUsbOriginalServerPanicCat, EInvalidFunction); return; } aMessage.Complete(KErrNone); }
[ "none@none" ]
[ [ [ 1, 145 ] ] ]
f48df143319f58e24ea405e48ecb874938d406f2
028d79ad6dd6bb4114891b8f4840ef9f0e9d4a32
/src/drivers/pengo.cpp
9f691f052272d4370bbc0aebfa8681c879b5b6c0
[]
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
17,367
cpp
#include "../vidhrdw/pengo.cpp" /*************************************************************************** Pengo memory map (preliminary) driver by Nicola Salmoria 0000-7fff ROM 8000-83ff Video RAM 8400-87ff Color RAM 8800-8fff RAM memory mapped ports: read: 9000 DSW1 9040 DSW0 9080 IN1 90c0 IN0 write: 8ff2-8ffd 6 pairs of two bytes: the first byte contains the sprite image number (bits 2-7), Y flip (bit 0), X flip (bit 1); the second byte the color 9005 sound voice 1 waveform (nibble) 9011-9013 sound voice 1 frequency (nibble) 9015 sound voice 1 volume (nibble) 900a sound voice 2 waveform (nibble) 9016-9018 sound voice 2 frequency (nibble) 901a sound voice 2 volume (nibble) 900f sound voice 3 waveform (nibble) 901b-901d sound voice 3 frequency (nibble) 901f sound voice 3 volume (nibble) 9022-902d Sprite coordinates, x/y pairs for 6 sprites 9040 interrupt enable 9041 sound enable 9042 palette bank selector 9043 flip screen 9044-9045 coin counters 9046 color lookup table bank selector 9047 character/sprite bank selector 9070 watchdog reset Main clock: XTAL = 18.432 MHz Z80 Clock: XTAL/6 = 3.072 MHz Horizontal video frequency: HSYNC = XTAL/3/192/2 = 16 kHz Video frequency: VSYNC = HSYNC/132/2 = 60.606060 Hz VBlank duration: 1/VSYNC * (20/132) = 2500 us ***************************************************************************/ #include "driver.h" #include "vidhrdw/generic.h" void pengo_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom); WRITE_HANDLER( pengo_gfxbank_w ); int pengo_vh_start(void); WRITE_HANDLER( pengo_flipscreen_w ); void pengo_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh); extern unsigned char *pengo_soundregs; WRITE_HANDLER( pengo_sound_enable_w ); WRITE_HANDLER( pengo_sound_w ); /* in machine/segacrpt.c */ void pengo_decode(void); static struct MemoryReadAddress readmem[] = { { 0x0000, 0x7fff, MRA_ROM }, { 0x8000, 0x8fff, MRA_RAM }, /* video and color RAM, scratchpad RAM, sprite codes */ { 0x9000, 0x903f, input_port_3_r }, /* DSW1 */ { 0x9040, 0x907f, input_port_2_r }, /* DSW0 */ { 0x9080, 0x90bf, input_port_1_r }, /* IN1 */ { 0x90c0, 0x90ff, input_port_0_r }, /* IN0 */ { -1 } /* end of table */ }; static struct MemoryWriteAddress writemem[] = { { 0x0000, 0x7fff, MWA_ROM }, { 0x8000, 0x83ff, videoram_w, &videoram, &videoram_size }, { 0x8400, 0x87ff, colorram_w, &colorram }, { 0x8800, 0x8fef, MWA_RAMROM }, { 0x8ff0, 0x8fff, MWA_RAM, &spriteram, &spriteram_size}, { 0x9000, 0x901f, pengo_sound_w, &pengo_soundregs }, { 0x9020, 0x902f, MWA_RAM, &spriteram_2 }, { 0x9040, 0x9040, interrupt_enable_w }, { 0x9041, 0x9041, pengo_sound_enable_w }, { 0x9042, 0x9042, MWA_NOP }, { 0x9043, 0x9043, pengo_flipscreen_w }, { 0x9044, 0x9046, MWA_NOP }, { 0x9047, 0x9047, pengo_gfxbank_w }, { 0x9070, 0x9070, MWA_NOP }, { -1 } /* end of table */ }; INPUT_PORTS_START( pengo ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY ) /* the coin input must stay low for no less than 2 frames and no more */ /* than 9 frames to pass the self test check. */ /* Moreover, this way we avoid the game freezing until the user releases */ /* the "coin" key. */ PORT_BIT_IMPULSE( 0x10, IP_ACTIVE_LOW, IPT_COIN1, 2 ) PORT_BIT_IMPULSE( 0x20, IP_ACTIVE_LOW, IPT_COIN2, 2 ) /* Coin Aux doesn't need IMPULSE to pass the test, but it still needs it */ /* to avoid the freeze. */ PORT_BIT_IMPULSE( 0x40, IP_ACTIVE_LOW, IPT_COIN3, 2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL ) PORT_BITX(0x10, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL ) PORT_START /* DSW0 */ PORT_DIPNAME( 0x01, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x00, "30000" ) PORT_DIPSETTING( 0x01, "50000" ) PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x04, DEF_STR( Cocktail ) ) PORT_DIPNAME( 0x18, 0x10, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x18, "2" ) PORT_DIPSETTING( 0x10, "3" ) PORT_DIPSETTING( 0x08, "4" ) PORT_DIPSETTING( 0x00, "5" ) PORT_BITX( 0x20, 0x20, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Rack Test", KEYCODE_F1, IP_JOY_NONE ) PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0xc0, 0x80, DEF_STR( Difficulty ) ) PORT_DIPSETTING( 0xc0, "Easy" ) PORT_DIPSETTING( 0x80, "Medium" ) PORT_DIPSETTING( 0x40, "Hard" ) PORT_DIPSETTING( 0x00, "Hardest" ) PORT_START /* DSW1 */ PORT_DIPNAME( 0x0f, 0x0c, DEF_STR( Coin_A ) ) PORT_DIPSETTING( 0x00, DEF_STR( 4C_1C ) ) PORT_DIPSETTING( 0x08, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x04, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x09, "2 Coins/1 Credit 5/3" ) PORT_DIPSETTING( 0x05, "2 Coins/1 Credit 4/3" ) PORT_DIPSETTING( 0x0c, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x0d, "1 Coin/1 Credit 5/6" ) PORT_DIPSETTING( 0x03, "1 Coin/1 Credit 4/5" ) PORT_DIPSETTING( 0x0b, "1 Coin/1 Credit 2/3" ) PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x07, "1 Coin/2 Credits 5/11" ) PORT_DIPSETTING( 0x0f, "1 Coin/2 Credits 4/9" ) PORT_DIPSETTING( 0x0a, DEF_STR( 1C_3C ) ) PORT_DIPSETTING( 0x06, DEF_STR( 1C_4C ) ) PORT_DIPSETTING( 0x0e, DEF_STR( 1C_5C ) ) PORT_DIPSETTING( 0x01, DEF_STR( 1C_6C ) ) PORT_DIPNAME( 0xf0, 0xc0, DEF_STR( Coin_B ) ) PORT_DIPSETTING( 0x00, DEF_STR( 4C_1C ) ) PORT_DIPSETTING( 0x80, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x40, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x90, "2 Coins/1 Credit 5/3" ) PORT_DIPSETTING( 0x50, "2 Coins/1 Credit 4/3" ) PORT_DIPSETTING( 0xc0, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0xd0, "1 Coin/1 Credit 5/6" ) PORT_DIPSETTING( 0x30, "1 Coin/1 Credit 4/5" ) PORT_DIPSETTING( 0xb0, "1 Coin/1 Credit 2/3" ) PORT_DIPSETTING( 0x20, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x70, "1 Coin/2 Credits 5/11" ) PORT_DIPSETTING( 0xf0, "1 Coin/2 Credits 4/9" ) PORT_DIPSETTING( 0xa0, DEF_STR( 1C_3C ) ) PORT_DIPSETTING( 0x60, DEF_STR( 1C_4C ) ) PORT_DIPSETTING( 0xe0, DEF_STR( 1C_5C ) ) PORT_DIPSETTING( 0x10, DEF_STR( 1C_6C ) ) INPUT_PORTS_END static struct GfxLayout tilelayout = { 8,8, /* 8*8 characters */ 256, /* 256 characters */ 2, /* 2 bits per pixel */ { 0, 4 }, /* the two bitplanes for 4 pixels are packed into one byte */ { 8*8+0, 8*8+1, 8*8+2, 8*8+3, 0, 1, 2, 3 }, /* bits are packed in groups of four */ { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, 16*8 /* every char takes 16 bytes */ }; static struct GfxLayout spritelayout = { 16,16, /* 16*16 sprites */ 64, /* 64 sprites */ 2, /* 2 bits per pixel */ { 0, 4 }, /* the two bitplanes for 4 pixels are packed into one byte */ { 8*8, 8*8+1, 8*8+2, 8*8+3, 16*8+0, 16*8+1, 16*8+2, 16*8+3, 24*8+0, 24*8+1, 24*8+2, 24*8+3, 0, 1, 2, 3 }, { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8 }, 64*8 /* every sprite takes 64 bytes */ }; static struct GfxDecodeInfo gfxdecodeinfo[] = { { REGION_GFX1, 0x0000, &tilelayout, 0, 32 }, /* first bank */ { REGION_GFX1, 0x1000, &spritelayout, 0, 32 }, { REGION_GFX2, 0x0000, &tilelayout, 4*32, 32 }, /* second bank */ { REGION_GFX2, 0x1000, &spritelayout, 4*32, 32 }, { -1 } /* end of array */ }; static struct namco_interface namco_interface = { 3072000/32, /* sample rate */ 3, /* number of voices */ 100, /* playback volume */ REGION_SOUND1 /* memory region */ }; static struct MachineDriver machine_driver_pengo = { /* basic machine hardware */ { { CPU_Z80, /* 18432000/6, * 3.072 Mhz */ 3020000, /* The correct speed is 3.072 Mhz, but 3.020 gives a more */ /* accurate emulation speed (time for two attract mode */ /* cycles after power up, until the high score list appears */ /* for the second time: 3'39") */ readmem,writemem,0,0, interrupt,1 } }, 60, 2500, /* frames per second, vblank duration */ 1, /* single CPU, no need for interleaving */ 0, /* video hardware */ 36*8, 28*8, { 0*8, 36*8-1, 0*8, 28*8-1 }, gfxdecodeinfo, 32,4*64, pengo_vh_convert_color_prom, VIDEO_TYPE_RASTER | VIDEO_SUPPORTS_DIRTY, 0, pengo_vh_start, generic_vh_stop, pengo_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_NAMCO, &namco_interface } } }; /*************************************************************************** Game driver(s) ***************************************************************************/ ROM_START( pengo ) ROM_REGION( 2*0x10000, REGION_CPU1 ) /* 64k for code + 64k for decrypted opcodes */ ROM_LOAD( "ic8", 0x0000, 0x1000, 0xf37066a8 ) ROM_LOAD( "ic7", 0x1000, 0x1000, 0xbaf48143 ) ROM_LOAD( "ic15", 0x2000, 0x1000, 0xadf0eba0 ) ROM_LOAD( "ic14", 0x3000, 0x1000, 0xa086d60f ) ROM_LOAD( "ic21", 0x4000, 0x1000, 0xb72084ec ) ROM_LOAD( "ic20", 0x5000, 0x1000, 0x94194a89 ) ROM_LOAD( "ic32", 0x6000, 0x1000, 0xaf7b12c4 ) ROM_LOAD( "ic31", 0x7000, 0x1000, 0x933950fe ) ROM_REGION( 0x2000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "ic92", 0x0000, 0x2000, 0xd7eec6cd ) ROM_REGION( 0x2000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "ic105", 0x0000, 0x2000, 0x5bfd26e9 ) ROM_REGION( 0x0420, REGION_PROMS ) ROM_LOAD( "pr1633.078", 0x0000, 0x0020, 0x3a5844ec ) ROM_LOAD( "pr1634.088", 0x0020, 0x0400, 0x766b139b ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "pr1635.051", 0x0000, 0x0100, 0xc29dea27 ) ROM_LOAD( "pr1636.070", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( pengo2 ) ROM_REGION( 2*0x10000, REGION_CPU1 ) /* 64k for code + 64k for decrypted opcodes */ ROM_LOAD( "ic8.2", 0x0000, 0x1000, 0xe4924b7b ) ROM_LOAD( "ic7.2", 0x1000, 0x1000, 0x72e7775d ) ROM_LOAD( "ic15.2", 0x2000, 0x1000, 0x7410ef1e ) ROM_LOAD( "ic14.2", 0x3000, 0x1000, 0x55b3f379 ) ROM_LOAD( "ic21", 0x4000, 0x1000, 0xb72084ec ) ROM_LOAD( "ic20.2", 0x5000, 0x1000, 0x770570cf ) ROM_LOAD( "ic32", 0x6000, 0x1000, 0xaf7b12c4 ) ROM_LOAD( "ic31.2", 0x7000, 0x1000, 0x669555c1 ) ROM_REGION( 0x2000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "ic92", 0x0000, 0x2000, 0xd7eec6cd ) ROM_REGION( 0x2000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "ic105", 0x0000, 0x2000, 0x5bfd26e9 ) ROM_REGION( 0x0420, REGION_PROMS ) ROM_LOAD( "pr1633.078", 0x0000, 0x0020, 0x3a5844ec ) ROM_LOAD( "pr1634.088", 0x0020, 0x0400, 0x766b139b ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "pr1635.051", 0x0000, 0x0100, 0xc29dea27 ) ROM_LOAD( "pr1636.070", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( pengo2u ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "pengo.u8", 0x0000, 0x1000, 0x3dfeb20e ) ROM_LOAD( "pengo.u7", 0x1000, 0x1000, 0x1db341bd ) ROM_LOAD( "pengo.u15", 0x2000, 0x1000, 0x7c2842d5 ) ROM_LOAD( "pengo.u14", 0x3000, 0x1000, 0x6e3c1f2f ) ROM_LOAD( "pengo.u21", 0x4000, 0x1000, 0x95f354ff ) ROM_LOAD( "pengo.u20", 0x5000, 0x1000, 0x0fdb04b8 ) ROM_LOAD( "pengo.u32", 0x6000, 0x1000, 0xe5920728 ) ROM_LOAD( "pengo.u31", 0x7000, 0x1000, 0x13de47ed ) ROM_REGION( 0x2000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "ic92", 0x0000, 0x2000, 0xd7eec6cd ) ROM_REGION( 0x2000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "ic105", 0x0000, 0x2000, 0x5bfd26e9 ) ROM_REGION( 0x0420, REGION_PROMS ) ROM_LOAD( "pr1633.078", 0x0000, 0x0020, 0x3a5844ec ) ROM_LOAD( "pr1634.088", 0x0020, 0x0400, 0x766b139b ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "pr1635.051", 0x0000, 0x0100, 0xc29dea27 ) ROM_LOAD( "pr1636.070", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( penta ) ROM_REGION( 2*0x10000, REGION_CPU1 ) /* 64k for code + 64k for decrypted opcodes */ ROM_LOAD( "008_pn01.bin", 0x0000, 0x1000, 0x22f328df ) ROM_LOAD( "007_pn05.bin", 0x1000, 0x1000, 0x15bbc7d3 ) ROM_LOAD( "015_pn02.bin", 0x2000, 0x1000, 0xde82b74a ) ROM_LOAD( "014_pn06.bin", 0x3000, 0x1000, 0x160f3836 ) ROM_LOAD( "021_pn03.bin", 0x4000, 0x1000, 0x7824e3ef ) ROM_LOAD( "020_pn07.bin", 0x5000, 0x1000, 0x377b9663 ) ROM_LOAD( "032_pn04.bin", 0x6000, 0x1000, 0xbfde44c1 ) ROM_LOAD( "031_pn08.bin", 0x7000, 0x1000, 0x64e8c30d ) ROM_REGION( 0x2000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "092_pn09.bin", 0x0000, 0x2000, 0x6afeba9d ) ROM_REGION( 0x2000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "ic105", 0x0000, 0x2000, 0x5bfd26e9 ) ROM_REGION( 0x0420, REGION_PROMS ) ROM_LOAD( "pr1633.078", 0x0000, 0x0020, 0x3a5844ec ) ROM_LOAD( "pr1634.088", 0x0020, 0x0400, 0x766b139b ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "pr1635.051", 0x0000, 0x0100, 0xc29dea27 ) ROM_LOAD( "pr1636.070", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END static void init_pengo(void) { pengo_decode(); } static void init_penta(void) { /* the values vary, but the translation mask is always laid out like this: 0 1 2 3 4 5 6 7 8 9 a b c d e f 0 A A B B A A B B C C D D C C D D 1 A A B B A A B B C C D D C C D D 2 E E F F E E F F G G H H G G H H 3 E E F F E E F F G G H H G G H H 4 A A B B A A B B C C D D C C D D 5 A A B B A A B B C C D D C C D D 6 E E F F E E F F G G H H G G H H 7 E E F F E E F F G G H H G G H H 8 H H G G H H G G F F E E F F E E 9 H H G G H H G G F F E E F F E E a D D C C D D C C B B A A B B A A b D D C C D D C C B B A A B B A A c H H G G H H G G F F E E F F E E d H H G G H H G G F F E E F F E E e D D C C D D C C B B A A B B A A f D D C C D D C C B B A A B B A A (e.g. 0xc0 is XORed with H) therefore in the following tables we only keep track of A, B, C, D, E, F, G and H. */ static const unsigned char data_xortable[2][8] = { { 0xa0,0x82,0x28,0x0a,0x82,0xa0,0x0a,0x28 }, /* ...............0 */ { 0x88,0x0a,0x82,0x00,0x88,0x0a,0x82,0x00 } /* ...............1 */ }; static const unsigned char opcode_xortable[8][8] = { { 0x02,0x08,0x2a,0x20,0x20,0x2a,0x08,0x02 }, /* ...0...0...0.... */ { 0x88,0x88,0x00,0x00,0x88,0x88,0x00,0x00 }, /* ...0...0...1.... */ { 0x88,0x0a,0x82,0x00,0xa0,0x22,0xaa,0x28 }, /* ...0...1...0.... */ { 0x88,0x0a,0x82,0x00,0xa0,0x22,0xaa,0x28 }, /* ...0...1...1.... */ { 0x2a,0x08,0x2a,0x08,0x8a,0xa8,0x8a,0xa8 }, /* ...1...0...0.... */ { 0x2a,0x08,0x2a,0x08,0x8a,0xa8,0x8a,0xa8 }, /* ...1...0...1.... */ { 0x88,0x0a,0x82,0x00,0xa0,0x22,0xaa,0x28 }, /* ...1...1...0.... */ { 0x88,0x0a,0x82,0x00,0xa0,0x22,0xaa,0x28 } /* ...1...1...1.... */ }; int A; unsigned char *rom = memory_region(REGION_CPU1); int diff = memory_region_length(REGION_CPU1) / 2; memory_set_opcode_base(0,rom+diff); for (A = 0x0000;A < 0x8000;A++) { int i,j; unsigned char src; src = rom[A]; /* pick the translation table from bit 0 of the address */ i = A & 1; /* pick the offset in the table from bits 1, 3 and 5 of the source data */ j = ((src >> 1) & 1) + (((src >> 3) & 1) << 1) + (((src >> 5) & 1) << 2); /* the bottom half of the translation table is the mirror image of the top */ if (src & 0x80) j = 7 - j; /* decode the ROM data */ rom[A] = src ^ data_xortable[i][j]; /* now decode the opcodes */ /* pick the translation table from bits 4, 8 and 12 of the address */ i = ((A >> 4) & 1) + (((A >> 8) & 1) << 1) + (((A >> 12) & 1) << 2); rom[A + diff] = src ^ opcode_xortable[i][j]; } } GAME( 1982, pengo, 0, pengo, pengo, pengo, ROT90, "Sega", "Pengo (set 1)" ) GAME( 1982, pengo2, pengo, pengo, pengo, pengo, ROT90, "Sega", "Pengo (set 2)" ) GAME( 1982, pengo2u, pengo, pengo, pengo, 0, ROT90, "Sega", "Pengo (set 2 not encrypted)" ) GAME( 1982, penta, pengo, pengo, pengo, penta, ROT90, "bootleg", "Penta" )
[ [ [ 1, 480 ] ] ]
68c5e57466e8029eef595b0b5fb58ba133b7fb87
619941b532c6d2987c0f4e92b73549c6c945c7e5
/Source/Nuclex/GUI/DesktopWindow.cpp
248472c7ca69172910af1676a6e38d78739292bb
[]
no_license
dzw/stellarengine
2b70ddefc2827be4f44ec6082201c955788a8a16
2a0a7db2e43c7c3519e79afa56db247f9708bc26
refs/heads/master
2016-09-01T21:12:36.888921
2008-12-12T12:40:37
2008-12-12T12:40:37
36,939,169
0
0
null
null
null
null
UTF-8
C++
false
false
9,662
cpp
//  // // # # ### # # -= Nuclex Library =-  // // ## # # # ## ## DesktopWindow.cpp - GUI desktop window  // // ### # # ###  // // # ### # ### Manages the root window which contains all other windows  // // # ## # # ## ## and widget in the GUI  // // # # ### # # R1 (C)2002-2004 Markus Ewald -> License.txt  // //  // #include "Nuclex/GUI/DesktopWindow.h" #include "ScopeGuard/ScopeGuard.h" using namespace Nuclex; using namespace Nuclex::Input; using namespace Nuclex::GUI; // ############################################################################################# // // # Nuclex::GUI::DesktopWindow::DesktopWindow() Constructor # // // ############################################################################################# // /** Initializes a DesktopWindow */ DesktopWindow::DesktopWindow() : Window(Box2<float>(), "desktop"), m_nActiveWindowButton(0), m_bDragging(false) { Window::setMoveable(false); } // ############################################################################################# // // # Nuclex::GUI::DesktopWindow::addWindow() # // // ############################################################################################# // /** Add a new child window to the desktop @param sName Name under which to manage the child window @param spWindow The Window to be added */ void DesktopWindow::addWindow(const string &sName, const shared_ptr<Window> &spWindow) { WindowMap::iterator WindowIt = m_Windows.find(sName); if(WindowIt != m_Windows.end()) WindowIt->second = spWindow; else m_Windows.insert(WindowMap::value_type(sName, spWindow)); } // ############################################################################################# // // # Nuclex::GUI::DesktopWindow::removeWindow() # // // ############################################################################################# // /** Removes a Window that was previously added using addWindow() @param sName Name under which the window was added */ void DesktopWindow::removeWindow(const string &sName) { WindowMap::iterator WindowIt = m_Windows.find(sName); if(WindowIt != m_Windows.end()) m_Windows.erase(WindowIt); else throw InvalidArgumentException("Nuclex::GUI::DesktopWindow::removeWindow()", string("Item not found: '") + sName + "'"); } // ############################################################################################# // // # Nuclex::GUI::DesktopWindow::clearWindows() # // // ############################################################################################# // /** Removes all windows from the desktop */ void DesktopWindow::clearWindows() { m_Windows.clear(); } // ############################################################################################# // // # Nuclex::GUI::DesktopWindow::enumWindows() # // // ############################################################################################# // /** Creates a new enumerator to enumerate over all windows added to the desktop. @return A new enumerator over all windows of the desktop */ shared_ptr<DesktopWindow::WindowEnumerator> DesktopWindow::enumWindows() const { throw NotSupportedException("Nuclex::GUI::DesktopWindow::enumWindows()", "Not implemented yet"); } // ############################################################################################# // // # Nuclex::GUI::DesktopWindow::draw() # // // ############################################################################################# // /** Draws the window @param VD VertexDrawer to use for drawing @param T The GUI theme to be used */ void DesktopWindow::draw(Video::VertexDrawer &VD, Theme &T) { // Draw all widgets positioned directly on the desktop shared_ptr<Window::WidgetEnumerator> spWidgetEnum = enumWidgets(); while(spWidgetEnum->next()) spWidgetEnum->get()->draw(VD, T); // Draw all child windows of the desktop for(WindowMap::iterator WindowIt = m_Windows.begin(); WindowIt != m_Windows.end(); ++WindowIt) { WindowIt->second->draw(VD, T); } } // ############################################################################################# // // # Nuclex::GUI::DesktopWindow::processInput() # // // ############################################################################################# // /** Processes an input event sent to the desktop window @param InputEvent The input event to be processed @todo Fat ugly method. Somehow decompose into behavioral traits. */ bool DesktopWindow::processInput(const Event &InputEvent) { // If this is an event containing mouse coordinates if(hasMouseCoordinates(InputEvent)) { shared_ptr<Window> spWindowUnderMouse; WindowMap::iterator WindowEnd = m_Windows.end(); for(WindowMap::iterator WindowIt = m_Windows.begin(); WindowIt != WindowEnd; ++WindowIt) if(WindowIt->second->hitTest(Point2<float>(InputEvent.Location, StaticCastTag()))) spWindowUnderMouse = WindowIt->second; // If the mouse isn't dragging a widget, process the message normally if(!m_bDragging) { if(m_wpActiveWindow.expired()) { // When a mouse button is pressed, the widget under the mouse will be in // drag mode until the mouse button is released again if(InputEvent.eType == Event::T_MOUSEBUTTONDOWN) { if(spWindowUnderMouse) { m_nActiveWindowButton = InputEvent.nButton; m_wpActiveWindow = spWindowUnderMouse; // The left mouse button actives widgets if(InputEvent.nButton == 0) m_wpFocusWindow = spWindowUnderMouse; // Let the widget handle the mousebuttondown message return spWindowUnderMouse->processInput(InputEvent); } else { bool bWidgetUnderMouse = false; shared_ptr<Window::WidgetEnumerator> spWidgetEnum = enumWidgets(); while(spWidgetEnum->next()) if(spWidgetEnum->get()->hitTest(Point2<float>(InputEvent.Location, StaticCastTag()))) bWidgetUnderMouse = true; if(bWidgetUnderMouse) { m_wpFocusWindow = shared_ptr<Window>(); } else { m_nActiveWindowButton = InputEvent.nButton; m_bDragging = true; return true; } } // When the mouse is moved, the widget under the mouse is notified of it // Also, the widget the mouse was hovering about previously receives one final message } else if(InputEvent.eType == Event::T_MOUSEMOVE) { // If there is a current hover widget, send it the mouse move message if(!m_wpHoverWindow.expired()) { shared_ptr<Window>(m_wpHoverWindow)->processInput(InputEvent); // Assign the new hover widget, or possibly nothing if(spWindowUnderMouse && (spWindowUnderMouse != shared_ptr<Window>(m_wpHoverWindow))) spWindowUnderMouse->processInput(InputEvent); } else if(spWindowUnderMouse) { spWindowUnderMouse->processInput(InputEvent); } m_wpHoverWindow = spWindowUnderMouse; // Mouse was pressed on empty location, but released on a widget } else if(InputEvent.eType == Event::T_MOUSEBUTTONUP) { // Will be discarded, logically seen as drag operation on the window itself //return false; } // The mouse is dragging a window } else { // Send all mouse messages to the widget being dragged until released { ScopeGuard Reset_ActiveWindow = MakeObjGuard(m_wpActiveWindow, &weak_ptr<Window>::reset); if((InputEvent.eType != Event::T_MOUSEBUTTONUP) || (InputEvent.nButton != m_nActiveWindowButton)) Reset_ActiveWindow.Dismiss(); return shared_ptr<Window>(m_wpActiveWindow)->processInput(InputEvent); } } } else { if((InputEvent.eType == Event::T_MOUSEBUTTONUP) && (InputEvent.nButton == m_nActiveWindowButton)) { m_bDragging = false; return DesktopWindow::processInput( Event(Event::T_MOUSEMOVE, Event::V_NONE, InputEvent.Location) ); } else { return true; } } } else if(isKeyboardEvent(InputEvent)) { if(!m_wpFocusWindow.expired()) return shared_ptr<Window>(m_wpFocusWindow)->processInput(InputEvent); } return Window::processInput(InputEvent); }
[ [ [ 1, 211 ] ] ]
797a4081f2858bcb471a8bf350b97aeae6b570f3
3daaefb69e57941b3dee2a616f62121a3939455a
/mgllib/src/audio/MglOgg.cpp
e85252fb484e28dba9a3c92535e6239b0a83460b
[]
no_license
myun2ext/open-mgl-legacy
21ccadab8b1569af8fc7e58cf494aaaceee32f1e
8faf07bad37a742f7174b454700066d53a384eae
refs/heads/master
2016-09-06T11:41:14.108963
2009-12-28T12:06:58
2009-12-28T12:06:58
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
3,410
cpp
#include "stdafx.h" #include "MglOgg.h" #define VOX_DLL_NAME "Vox.dll" //#define VOX_DLL_NAME "Vox_d.dll" typedef Vox* __stdcall CreateVox(); #define USE_CHK() if(m_useFlg!=TRUE)return; // コンストラクタ CMglOgg::CMglOgg() { m_hDll = NULL; m_pDriver = NULL; m_loadFlg = FALSE; m_useFlg = TRUE; m_fNowVolume = VOX_DEFAULT_VOLUME; } // デストラクタ CMglOgg::~CMglOgg() { Release(); } // 初期化 void CMglOgg::Init( HWND hWnd ) { USE_CHK(); m_hDll = LoadLibrary( VOX_DLL_NAME ); if ( m_hDll == NULL ) MyuThrow( 0, "CMglOgg::Init() %s のロードに失敗しました。", VOX_DLL_NAME ); CreateVox *pCreateVox = (CreateVox *)GetProcAddress( m_hDll,"CreateVox" ); m_pDriver = pCreateVox(); } // 開放 void CMglOgg::Release() { if ( m_pDriver != NULL ) { //UnLoad(); m_pDriver->Delete(); // delete m_pDriver を行ってはいけない!! m_pDriver = NULL; } if ( m_hDll != NULL ) { FreeLibrary( m_hDll ); m_hDll = NULL; } } // 読み込み void CMglOgg::Load( const char* szOggFile ) { // チェック USE_CHK(); InitCheck(); // 読み込み if ( m_loadFlg ) UnLoad(); if ( m_pDriver->Load( (char*)szOggFile ) != true ) MyuThrow( 0, "CMglOgg::Load() %s の読み込みに失敗しました。", szOggFile ); m_loadFlg = TRUE; } // 開放 void CMglOgg::UnLoad() { // チェック USE_CHK(); InitCheck(); if ( m_loadFlg ){ m_pDriver->Release(); m_loadFlg = FALSE; } } // 再生 void CMglOgg::Play( int nLoopCnt ) { // チェック USE_CHK(); LoadCheck(); // ループ再生 if ( m_pDriver->SetLoop(nLoopCnt) != true ) MyuThrow( 0, "CMglOgg::SetLoop() ループ回数の設定に失敗しました。" ); // 再生 if ( m_pDriver->Play() != true ) MyuThrow( 0, "CMglOgg::Play() 再生に失敗しました。" ); } // ループ再生をストップ void CMglOgg::StopLoop() { // チェック USE_CHK(); LoadCheck(); // ループ再生 if ( m_pDriver->SetLoop(0) != true ) MyuThrow( 0, "CMglOgg::SetLoop() ループ回数の設定に失敗しました。" ); } // 停止 void CMglOgg::Stop() { // チェック USE_CHK(); LoadCheck(); Pause(); SeekToHead(); } // ポーズ void CMglOgg::Pause() { // チェック USE_CHK(); LoadCheck(); // ループ再生 if ( m_pDriver->Pause() != true ) MyuThrow( 0, "CMglOgg::Pause() ポーズに失敗しました。" ); } // ボリュームの設定 void CMglOgg::SetVolume( float fVolume ) { // チェック USE_CHK(); LoadCheck(); // ループ再生 if ( m_pDriver->SetVolume( fVolume ) != true ) MyuThrow( 0, "CMglOgg::SetVolume() ボリュームの設定に失敗しました。" ); m_fNowVolume = fVolume; } // フェード void CMglOgg::Fade( float fTargetVolume, int nFadeTime ) { // チェック USE_CHK(); LoadCheck(); // 再生 if ( m_pDriver->Fade( m_fNowVolume, fTargetVolume, nFadeTime ) != true ) MyuThrow( 0, "CMglOgg::Fade() フェード処理に失敗しました。" ); m_fNowVolume = fTargetVolume; } void CMglOgg::SeekTo( long nSeekTime, DWORD dwFlg ) { // チェック USE_CHK(); LoadCheck(); // 再生 if ( m_pDriver->Seek( nSeekTime ) != true ) MyuThrow( 0, "CMglOgg::SeekTo() シーク処理に失敗しました。" ); }
[ "myun2@6d62ff88-fa28-0410-b5a4-834eb811a934" ]
[ [ [ 1, 173 ] ] ]
2208545f6d102aed910e358cca22b05546e7e73d
b14d5833a79518a40d302e5eb40ed5da193cf1b2
/cpp/extern/crypto++/5.2.1/network.cpp
8e5a9b744e7e1eea816f8058115522acc69d3138
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-cryptopp" ]
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
8,318
cpp
// network.cpp - written and placed in the public domain by Wei Dai #include "pch.h" #include "network.h" #include "wait.h" #define CRYPTOPP_TRACE_NETWORK 0 NAMESPACE_BEGIN(CryptoPP) unsigned int NonblockingSource::PumpMessages2(unsigned int &messageCount, bool blocking) { if (messageCount == 0) return 0; unsigned long byteCount = ULONG_MAX; messageCount = 0; RETURN_IF_NONZERO(Pump2(byteCount, blocking)); if (!m_messageEndSent && SourceExhausted()) { RETURN_IF_NONZERO(AttachedTransformation()->Put2(NULL, 0, GetAutoSignalPropagation(), true)); m_messageEndSent = true; messageCount = 1; } return 0; } bool NonblockingSink::IsolatedFlush(bool hardFlush, bool blocking) { TimedFlush(blocking ? INFINITE_TIME : 0); return hardFlush && !!GetCurrentBufferSize(); } // ************************************************************* #ifdef HIGHRES_TIMER_AVAILABLE NetworkSource::NetworkSource(BufferedTransformation *attachment) : NonblockingSource(attachment), m_buf(1024*16) , m_waitingForResult(false), m_outputBlocked(false) , m_dataBegin(0), m_dataEnd(0) { } void NetworkSource::GetWaitObjects(WaitObjectContainer &container) { if (!m_outputBlocked) { if (m_dataBegin == m_dataEnd) AccessReceiver().GetWaitObjects(container); else container.SetNoWait(); } AttachedTransformation()->GetWaitObjects(container); } unsigned int NetworkSource::GeneralPump2(unsigned long &byteCount, bool blockingOutput, unsigned long maxTime, bool checkDelimiter, byte delimiter) { NetworkReceiver &receiver = AccessReceiver(); unsigned long maxSize = byteCount; byteCount = 0; bool forever = maxTime == INFINITE_TIME; Timer timer(Timer::MILLISECONDS, forever); BufferedTransformation *t = AttachedTransformation(); if (m_outputBlocked) goto DoOutput; while (true) { if (m_dataBegin == m_dataEnd) { if (receiver.EofReceived()) break; if (m_waitingForResult) { if (receiver.MustWaitForResult() && !receiver.Wait(SaturatingSubtract(maxTime, timer.ElapsedTime()))) break; unsigned int recvResult = receiver.GetReceiveResult(); #if CRYPTOPP_TRACE_NETWORK OutputDebugString((IntToString((unsigned int)this) + ": Received " + IntToString(recvResult) + " bytes\n").c_str()); #endif m_dataEnd += recvResult; m_waitingForResult = false; if (!receiver.MustWaitToReceive() && !receiver.EofReceived() && m_dataEnd != m_buf.size()) goto ReceiveNoWait; } else { m_dataEnd = m_dataBegin = 0; if (receiver.MustWaitToReceive()) { if (!receiver.Wait(SaturatingSubtract(maxTime, timer.ElapsedTime()))) break; receiver.Receive(m_buf+m_dataEnd, m_buf.size()-m_dataEnd); m_waitingForResult = true; } else { ReceiveNoWait: m_waitingForResult = true; // call Receive repeatedly as long as data is immediately available, // because some receivers tend to return data in small pieces #if CRYPTOPP_TRACE_NETWORK OutputDebugString((IntToString((unsigned int)this) + ": Receiving " + IntToString(m_buf.size()-m_dataEnd) + " bytes\n").c_str()); #endif while (receiver.Receive(m_buf+m_dataEnd, m_buf.size()-m_dataEnd)) { unsigned int recvResult = receiver.GetReceiveResult(); #if CRYPTOPP_TRACE_NETWORK OutputDebugString((IntToString((unsigned int)this) + ": Received " + IntToString(recvResult) + " bytes\n").c_str()); #endif m_dataEnd += recvResult; if (receiver.EofReceived() || m_dataEnd > m_buf.size() /2) { m_waitingForResult = false; break; } } } } } else { m_putSize = STDMIN((unsigned long)m_dataEnd-m_dataBegin, maxSize-byteCount); if (checkDelimiter) m_putSize = std::find(m_buf+m_dataBegin, m_buf+m_dataBegin+m_putSize, delimiter) - (m_buf+m_dataBegin); DoOutput: unsigned int result = t->PutModifiable2(m_buf+m_dataBegin, m_putSize, 0, forever || blockingOutput); if (result) { if (t->Wait(SaturatingSubtract(maxTime, timer.ElapsedTime()))) goto DoOutput; else { m_outputBlocked = true; return result; } } m_outputBlocked = false; byteCount += m_putSize; m_dataBegin += m_putSize; if (checkDelimiter && m_dataBegin < m_dataEnd && m_buf[m_dataBegin] == delimiter) break; if (byteCount == maxSize) break; // once time limit is reached, return even if there is more data waiting // but make 0 a special case so caller can request a large amount of data to be // pumped as long as it is immediately available if (maxTime > 0 && timer.ElapsedTime() > maxTime) break; } } return 0; } // ************************************************************* NetworkSink::NetworkSink(unsigned int maxBufferSize, unsigned int autoFlushBound) : m_maxBufferSize(maxBufferSize), m_autoFlushBound(autoFlushBound) , m_needSendResult(false), m_wasBlocked(false) , m_buffer(STDMIN(16U*1024U+256, maxBufferSize)), m_skipBytes(0) , m_speedTimer(Timer::MILLISECONDS), m_byteCountSinceLastTimerReset(0) , m_currentSpeed(0), m_maxObservedSpeed(0) { } float NetworkSink::ComputeCurrentSpeed() { if (m_speedTimer.ElapsedTime() > 1000) { m_currentSpeed = m_byteCountSinceLastTimerReset * 1000 / m_speedTimer.ElapsedTime(); m_maxObservedSpeed = STDMAX(m_currentSpeed, m_maxObservedSpeed * 0.98f); m_byteCountSinceLastTimerReset = 0; m_speedTimer.StartTimer(); // OutputDebugString(("max speed: " + IntToString((int)m_maxObservedSpeed) + " current speed: " + IntToString((int)m_currentSpeed) + "\n").c_str()); } return m_currentSpeed; } unsigned int NetworkSink::Put2(const byte *inString, unsigned int length, int messageEnd, bool blocking) { if (m_skipBytes) { assert(length >= m_skipBytes); inString += m_skipBytes; length -= m_skipBytes; } m_buffer.LazyPut(inString, length); if (!blocking || m_buffer.CurrentSize() > m_autoFlushBound) TimedFlush(0, 0); unsigned int targetSize = messageEnd ? 0 : m_maxBufferSize; if (blocking) TimedFlush(INFINITE_TIME, targetSize); if (m_buffer.CurrentSize() > targetSize) { assert(!blocking); unsigned int blockedBytes = STDMIN(m_buffer.CurrentSize() - targetSize, (unsigned long)length); m_buffer.UndoLazyPut(blockedBytes); m_buffer.FinalizeLazyPut(); m_wasBlocked = true; m_skipBytes += length - blockedBytes; return STDMAX(blockedBytes, 1U); } m_buffer.FinalizeLazyPut(); m_wasBlocked = false; m_skipBytes = 0; if (messageEnd) AccessSender().SendEof(); return 0; } unsigned int NetworkSink::TimedFlush(unsigned long maxTime, unsigned int targetSize) { NetworkSender &sender = AccessSender(); bool forever = maxTime == INFINITE_TIME; Timer timer(Timer::MILLISECONDS, forever); unsigned int totalFlushSize = 0; while (true) { if (m_buffer.CurrentSize() <= targetSize) break; if (m_needSendResult) { if (sender.MustWaitForResult() && !sender.Wait(SaturatingSubtract(maxTime, timer.ElapsedTime()))) break; unsigned int sendResult = sender.GetSendResult(); #if CRYPTOPP_TRACE_NETWORK OutputDebugString((IntToString((unsigned int)this) + ": Sent " + IntToString(sendResult) + " bytes\n").c_str()); #endif m_buffer.Skip(sendResult); totalFlushSize += sendResult; m_needSendResult = false; if (!m_buffer.AnyRetrievable()) break; } unsigned long timeOut = maxTime ? SaturatingSubtract(maxTime, timer.ElapsedTime()) : 0; if (sender.MustWaitToSend() && !sender.Wait(timeOut)) break; unsigned int contiguousSize = 0; const byte *block = m_buffer.Spy(contiguousSize); #if CRYPTOPP_TRACE_NETWORK OutputDebugString((IntToString((unsigned int)this) + ": Sending " + IntToString(contiguousSize) + " bytes\n").c_str()); #endif sender.Send(block, contiguousSize); m_needSendResult = true; if (maxTime > 0 && timeOut == 0) break; // once time limit is reached, return even if there is more data waiting } m_byteCountSinceLastTimerReset += totalFlushSize; ComputeCurrentSpeed(); return totalFlushSize; } #endif // #ifdef HIGHRES_TIMER_AVAILABLE NAMESPACE_END
[ [ [ 1, 282 ] ] ]
3f0a7578e3841ffe0ce74b1290622e6f50b12572
e7c45d18fa1e4285e5227e5984e07c47f8867d1d
/Common/ModelsC/RTTS/RtSpMdl.cpp
f07add119dd635306f421e34f58bc1394331217a
[]
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
4,190
cpp
//================== SysCAD - Copyright Kenwalt (Pty) Ltd =================== // $Nokeywords: $ //=========================================================================== #include "stdafx.h" #define __RTSPMDL_CPP #include "sp_db.h" #include "rtspmdl.h" #define SIZEDST1 #include "models.h" #include "op_db.h" // ========================================================================== #define dbgModels 01 #if dbgModels #include "dbgmngr.h" static CDbgMngr dbgSpecies ("BASIC", "Species"); #endif // ========================================================================== // // Rio Tinto Specie Model // // ========================================================================== // must be in Range 0x0001 to 0x8000 const dword SMVF_LiqConcOK = 0x00000001; const word xidComp0 = 30010; IMPLEMENT_SPMODEL(CRtSpMdl, "RioTinto", "", TOC_ALL|TOC_RTTS, "RioTinto", "Rio Tinto Size Specie Model"); IMPLEMENT_SPARES(CRtSpMdl, 100); CRtSpMdl::CRtSpMdl(pTagObjClass pClass_, pchar Tag_, pTaggedObject pAttach, TagObjAttachment eAttach): SpModel(pClass_, Tag_, pAttach, eAttach) { } // -------------------------------------------------------------------------- CRtSpMdl::~CRtSpMdl() { } // -------------------------------------------------------------------------- void CRtSpMdl::BuildDataDefn_Vars(DataDefnBlk & DDB) { SpModel::BuildDataDefn_Vars(DDB); //Strng Tg(DDB.BlockTag()); //Tg+=".."; //DDB.Page(Tg(), DDB_OptPage); if (ODB.AssayCompCount()>0) { DDB.BeginObject(this, "SD", "SizeData", NULL, DDB_OptPage); DDB.Text("Extra Size Data"); for (int i=0; i<ODB.AssayCompCount(); i++) DDB.Double((char*)ODB.AssayName(i), "", DC_Qm, "kg/s", xidComp0+i, this, isResult|noFile|noSnap|NAN_OK); DDB.EndObject(); } } // -------------------------------------------------------------------------- flag CRtSpMdl::DataXchg(DataChangeBlk & DCB) { if (SpModel::DataXchg(DCB)) return true; if (DCB.lHandle>=xidComp0 && DCB.lHandle<xidComp0+ODB.AssayCompCount()) { const int Index = DCB.lHandle-xidComp0; const int EnIndex = ODB.AssayEnIndex(Index); CSD_DistDefn &DD = *SD_Defn.GetDist(0); double d = 0.0; for (int s=0; s<DD.NPriIds(); s++) { int SpId = DD.PriSzId(s); ASSERT(SpId>=0); if (ODB[SpId].OK()) d += (VMass[SpId]*ODB[SpId].CompPercentage(EnIndex)/100.0); } DCB.D=d; return 1; } /*SpModel * pMdl = this;// Model(); SQSzDist1 * pSz = SQSzDist1::Ptr(pMdl, false); if (pSz==NULL || !pSz->DistributionsExist()) { DCB.D=dNAN; } else { double d = 0.0; int EnIndex = DCB.lHandle-xidComp0; CSD_Distribution &D=pSz->Dist(0); for (int s=0; s<D.NPriIds(); s++) { int SpId = D.PriSzId(s); ASSERT(SpId>=0); if (ODB[SpId].OK()) { double ddd=ODB[SpId].CompPercentage(EnIndex)/100.0; double dd=SpMass(SpId); d += (dd*ddd); } } DCB.D=d; return 1; } }*/ return 0; } //--------------------------------------------------------------------------- flag CRtSpMdl::ValidateData(ValidateDataBlk & VDB) { flag OK=SpModel::ValidateData(VDB); return OK; } //-------------------------------------------------------------------------- flag CRtSpMdl::CIStrng(int No, pchar & pS) { // NB check CBCount is large enough. switch (No-CBContext()) { case 1: pS="W\t1 ???"; return 1; case 2: pS="W\t2 ???"; return 1; case 3: pS="W\t3 ???"; return 1; case 4: pS="W\t4 ???"; return 1; case 5: pS="W\t5 ???"; return 1; case 6: pS="W\t6 ???"; return 1; default: return SpModel::CIStrng(No, pS); } } // ========================================================================== // // End // // ========================================================================== //
[ [ [ 1, 152 ] ] ]
7e73b415d458f0702ff86976f00035cb7e79b655
4d91ca4dcaaa9167928d70b278b82c90fef384fa
/CedeCryptViewer/CedeCrypt/CedeCrypt/ProtectedFoldersWindow.h
635e402b56222262085e23119e9fa818dd3187fb
[]
no_license
dannydraper/CedeCryptClassic
13ef0d5f03f9ff3a9a1fe4a8113e385270536a03
5f14e3c9d949493b2831710e0ce414a1df1148ec
refs/heads/master
2021-01-17T13:10:51.608070
2010-10-01T10:09:15
2010-10-01T10:09:15
63,413,327
0
0
null
null
null
null
UTF-8
C++
false
false
2,366
h
#pragma once #include <windows.h> #include <io.h> #include <stdio.h> #include <direct.h> #include <shlobj.h> #include <commctrl.h> #include "UIWindow.h" #include "Diagnostics.h" #include "UIHandler.h" #include "UIBanner.h" #include "MultiContent.h" #include "UIRect.h" #include "UIPicButton.h" class ProtectedFoldersWindow : public UIWindow { public: ProtectedFoldersWindow (); ~ProtectedFoldersWindow (); void SetDiagnostics (Diagnostics *pdiag); void Initialise (HWND hWnd, unsigned int uID); void OutputInt (LPCSTR lpszText, int iValue); void OutputText (LPCSTR lpszText); void OutputText (LPCSTR lpszName, LPCSTR lpszValue); void SaveList (); void LoadList (); bool PrepareListPath (); bool FileExists (char *FileName); void GetListFilePath (char *szDestpath); private: // Private Member Variables & objects bool BrowseForFolder (LPCTSTR szTitle, char *szOutPath); // The UI Handler required for multiple handling of custom controls. UIHandler m_uihandler; // ID ofthis window - required for window class registration purposes unsigned int m_ID; // Global Window Handle HWND m_hwnd; HWND m_parenthwnd; HWND m_lstfolders; HWND m_btnaddfolder; HWND m_btnremfolder; HWND m_lblheader; // The header bitmap image UIBanner m_header; // The MultiContent Control MultiContent m_mainconv; // The path to the file containing the // protected folder list char m_szListfile[SIZE_STRING]; // Flag indicating if we're using diagnostics bool m_bUseDiagnostics; Diagnostics *m_pdiag; // Registered class name // We need a different class name for every instance of // this window. This class name // Is created by the Initialise routine // with a uID value suffixed to the end char m_szClassname[SIZE_STRING]; // event notification from base class void OnDestroy (HWND hWnd); void OnCreate (HWND hWnd); void OnCommand (HWND hWnd, WPARAM wParam, LPARAM lParam); void OnUICommand (HWND hWnd, WPARAM wParam, LPARAM lParam); void OnUIScroll (HWND hWnd, WPARAM wParam, LPARAM lParam); void OnPaint (HWND hWnd); void OnTimer (WPARAM wParam); void OnMouseMove (HWND hWnd, int mouseXPos, int mouseYPos); void OnLButtonDown (HWND hWnd); void OnLButtonUp (HWND hWnd); };
[ "ddraper@f12373e4-23ff-6a4a-9817-e77f09f3faef" ]
[ [ [ 1, 84 ] ] ]
105730ffa02a3e5e64298ed70d203a5000efea1a
b822313f0e48cf146b4ebc6e4548b9ad9da9a78e
/KylinSdk/Core/Source/rMotionSimulator.h
8622396ff84d48ef67f36822ec84ef112e2123fc
[]
no_license
dzw/kylin001v
5cca7318301931bbb9ede9a06a24a6adfe5a8d48
6cec2ed2e44cea42957301ec5013d264be03ea3e
refs/heads/master
2021-01-10T12:27:26.074650
2011-05-30T07:11:36
2011-05-30T07:11:36
46,501,473
0
0
null
null
null
null
GB18030
C++
false
false
2,305
h
#pragma once namespace Kylin { namespace PhyX { ////////////////////////////////////////////////////////////////////////// // 运动虚拟体 class MotionDummy { public: MotionDummy(Node* pHost, KPoint3 kSpeed = KPoint3::ZERO, KFLOAT fGravity = _WGravity) : m_pHost(pHost) , m_kSpeed(kSpeed) , m_bIsInAir(false) , m_fGravity(fGravity) , m_kPreSpeed(KPoint3::ZERO) { } protected: //----------------------------------------------------- // 落地 KVOID Touchdown(); //----------------------------------------------------- // 休息状态 KVOID Repose(); //----------------------------------------------------- // 是否是静止的 KBOOL IsImmobile(); protected: //----------------------------------------------------- // Node* m_pHost; //----------------------------------------------------- // 该物体的线性速度 KPoint3 m_kSpeed; // 上一帧物体速度 KPoint3 m_kPreSpeed; // 重力 KFLOAT m_fGravity; //----------------------------------------------------- //此物体是否在空中 BOOL m_bIsInAir; friend class MotionSimulator; friend class Calculator; }; ////////////////////////////////////////////////////////////////////////// // 运动模拟器 class MotionSimulator { public: MotionSimulator(); virtual KVOID Tick(KFLOAT fElapsed); virtual KVOID Destroy(); //----------------------------------------------------- // 提交模拟对象及参数(水平速度,重力加速度) virtual KVOID Commit(Node* pNode, const KPoint3 fSpeed, KFLOAT fGravity = _WGravity); //----------------------------------------------------- // 剔除模拟对象 virtual KVOID Erase(Node* pNode); public: //----------------------------------------------------- // 设置重力加速度 KVOID SetGravity(KFLOAT fG); protected: class Calculator { public: Calculator(){} KVOID Handle(MotionDummy* pDummy, KFLOAT fElapsed); protected: friend class MotionSimulator; }; protected: typedef KMAP<Node*,MotionDummy*> DummyMap; DummyMap m_kDummyMap; Calculator* m_pCalculator; }; } }
[ "[email protected]", "apayaccount@5fe9e158-c84b-58b7-3744-914c3a81fc4f" ]
[ [ [ 1, 12 ], [ 14, 16 ], [ 18, 41 ], [ 44, 61 ], [ 64, 65 ], [ 67, 76 ], [ 78, 93 ] ], [ [ 13, 13 ], [ 17, 17 ], [ 42, 43 ], [ 62, 63 ], [ 66, 66 ], [ 77, 77 ] ] ]
df62801b341d14d274f32d463bd00e19a022dbe1
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/zombie/nnavmesh/src/nnavmeshparser/navtag.cc
b5f1fc1cd0fb84e863b3a0663ec089369c8c9f45
[]
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
2,026
cc
#include "precompiled/pchnnavmesh.h" //------------------------------------------------------------------------------ // navtag.cc // (C) 2005 Conjurer Services, S.A. //------------------------------------------------------------------------------ #include "nnavmeshparser/navtag.h" //------------------------------------------------------------------------------ /** Return the string representation of some tag */ const nString& NavTag::GetString(const NavTag& tag) { static nString strTags[NumTags]; // Init all strings to empty string in debug... #ifndef NDEBUG for ( int i = 0; i < NumTags; ++i ) { strTags[i] = ""; } #endif // Use only letters, numbers and underline. Case matters. // Don't change the representation (read the comment about changing NavTagId, // for string representations applies the same rule). strTags[Root] = "navigation"; strTags[FileFormatType] = "type"; strTags[Version] = "version"; strTags[Mesh] = "navigation_mesh"; strTags[MeshNodesNb] = "num_nodes"; strTags[MeshNode] = "mesh_node"; strTags[MeshNodeIndex] = "index"; strTags[MeshNodeLinks] = "links"; strTags[MeshNodeLinksNb] = "num_links"; strTags[MeshNodeLink] = "link"; strTags[Polygon] = "polygon"; strTags[PolygonVerticesNb] = "num_vertices"; strTags[PolygonVertex] = "vertex"; strTags[Graph] = "navigation_graph"; strTags[GraphNodesNb] = "num_nodes"; strTags[GraphNode] = "graph_node"; strTags[Obstacles] = "obstacles"; strTags[ObstaclesNb] = "num_obstacles"; // ...to check if for some tag is missing its string representation. #ifndef NDEBUG for ( int i = 0; i < NumTags; ++i ) { n_assert( strTags[i] != "" ); } #endif return strTags[tag.tagId]; } //------------------------------------------------------------------------------ // EOF //------------------------------------------------------------------------------
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 61 ] ] ]
87030795600ce1b0dd8686f2b77050626f54d12f
8a3fce9fb893696b8e408703b62fa452feec65c5
/业余时间学习笔记/MemPool/MemPool/MemFactory.cpp
039f7fed8e9e9ec89ad75ed71573b3c6a5d0e08b
[]
no_license
win18216001/tpgame
bb4e8b1a2f19b92ecce14a7477ce30a470faecda
d877dd51a924f1d628959c5ab638c34a671b39b2
refs/heads/master
2021-04-12T04:51:47.882699
2011-03-08T10:04:55
2011-03-08T10:04:55
42,728,291
0
2
null
null
null
null
WINDOWS-1252
C++
false
false
1,618
cpp
#include "stdafx.h" #include "MemFactory.h" const long blocksize = 5120; #define BINDTOFAC(Size,Alloc)\ m_factory->Add(Size,new Alloc(Size,AALLOCSIZE/Size) ) CMemFactory::CMemFactory() { /// ¾²Ì¬³õʼ»¯ m_alloc = &SmallObjAllocator::Allocate; m_destory = &SmallObjAllocator::Destory; m_factory = new Factory<long,SmallObjAllocator*,AllocMem,Destory>(m_alloc,m_destory); BINDTOFAC( 16 , SmallObjAllocator ); BINDTOFAC( 32 , SmallObjAllocator ); BINDTOFAC( 64 , SmallObjAllocator ); BINDTOFAC( 128 , SmallObjAllocator ); BINDTOFAC( 256 , SmallObjAllocator ); BINDTOFAC( 512 , SmallObjAllocator ); BINDTOFAC( 1024 , SmallObjAllocator ); BINDTOFAC( 2048 , SmallObjAllocator ); BINDTOFAC( 5120 , SmallObjAllocator ); } int CMemFactory::Index(unsigned long size) { unsigned long arr[ ] = { 32,64,128,256,512,1024,2048,5120 }; return arr[ FindIndx( arr , 0 , sizeof(arr)/sizeof(unsigned long) , size ) ]; } void* CMemFactory::Alloc(unsigned long size) { if( size <= blocksize ) { long idx = Index(size); return m_factory->Alloc(idx); } else { long range = size - 5120 ; size = ( range / 512 + (range %512 == 0 ? 0 : 1 ) ) * 512 + 5120; if( m_factory->CheckExist( size ) ) { return m_factory->Alloc( size ); } else { BINDTOFAC( size , SmallObjAllocator ); return m_factory->Alloc( size ); } } } void CMemFactory::Free(void* pAddr, unsigned long size) { if ( size == 0 ) { size = *(long*)( (char*)pAddr - 4 ); } m_factory->Release( size , pAddr ); }
[ [ [ 1, 69 ] ] ]
a26a30e85a783b74e849b9c036bda197ef3abf49
cfa6cdfaba310a2fd5f89326690b5c48c6872a2a
/Library/Include/ClientSock.h
d5ecf6ffc926fd45ebc0d3e3c2a21f3cf3a11863
[]
no_license
asdlei00/project-jb
1cc70130020a5904e0e6a46ace8944a431a358f6
0bfaa84ddab946c90245f539c1e7c2e75f65a5c0
refs/heads/master
2020-05-07T21:41:16.420207
2009-09-12T03:40:17
2009-09-12T03:40:17
40,292,178
0
0
null
null
null
null
UHC
C++
false
false
1,505
h
/* Author : Bill Kim ([email protected], [email protected], [email protected]) Release Date : 2009. 04. 08. File Name : Client Socket Version : 1.00.00 Test PC : CPU - Pentium(R) 4 3.4 Ghz, RAM - 2 GB Graphic - NVIDIA Geforce 7800 GT Test OS : Windows XP Home Professional + SP2 Test Application : Visual Studio 2003 + DirectX SDK 9.0c(Dec, 2006) Contents Client Socket Header 2009 ⓒ Copyright MIS Corporation. All Rights Reserved. */ #pragma once #include "afxsock.h" #define WM_CLIENT_RECEIVE 0x0002 #define WM_CLIENT_SEND 0x0003 #define WM_CLIENT_CONNECT 0x0004 #define WM_CLIENT_CLOSE 0x0005 #define WM_CLIENT_NETDOWN 0x0006 #define WM_CLIENT_SEND_ERROR 0x0007 class CClientSock : public CAsyncSocket { // Attributes public: int m_Tag; // 소켓 정보를 위한 태그 bool m_bConnect; // 접속 여부 확인 HWND m_hWnd; // Operations public: CClientSock(); CClientSock(HWND hWnd); virtual ~CClientSock(); // Overrides public: // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CClientSock) public: virtual void OnReceive(int nErrorCode); virtual void OnSend(int nErrorCode); virtual void OnConnect(int nErrorCode); virtual void OnClose(int nErrorCode); //}}AFX_VIRTUAL // Generated message map functions //{{AFX_MSG(CClientSock) // NOTE - the ClassWizard will add and remove member functions here. //}}AFX_MSG // Implementation protected: };
[ [ [ 1, 62 ] ] ]
46d748927f9db6cbdcb8882b0b7d3d13d7a2b5f5
6f8721dafe2b841f4eb27237deead56ba6e7a55b
/src/WorldOfAnguis/Graphics/DirectX/World/DXWorldView.h
a9f5fe827209c991ebc9922d346da9e876ee44af
[]
no_license
worldofanguis/WoA
dea2abf6db52017a181b12e9c0f9989af61cfa2a
161c7bb4edcee8f941f31b8248a41047d89e264b
refs/heads/master
2021-01-19T10:25:57.360015
2010-02-19T16:05:40
2010-02-19T16:05:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,001
h
/* * ___ ___ __ * \ \ / / / \ * \ \ / / / \ * \ \ /\ / /___ / /\ \ * \ \/ \/ /| | / ____ \ * \___/\___/ |___|/__/ \__\ * World Of Anguis * */ /* Class: DXWorldView * Description: The goal of this class is to draw the world, the surface on the screen * * Functions: Setup(...) * setup the class with the drawing devices * LoadWorldTexture(...) * load the texture of the world from a bmp file * Draw(...) * draw the section of the world on the screen buffer, we are looking at * UpdateSurface(...) * this function is responsible for reshaping the world texture after * an explosion or something that alter its shape. */ #pragma once #include "Common.h" #include "Singleton.h" class DXWorldView : public Singleton<DXWorldView> { public: DXWorldView(); ~DXWorldView(); int GetSurfaceWidth() {return SurfaceWidth;} // The size of the map // int GetSurfaceHeight() {return SurfaceHeight;} // The size of the map // void Setup(LPDIRECT3DDEVICE9 pDevice,LPD3DXSPRITE pSprite) {this->pDevice = pDevice; this->pSprite = pSprite;} /* Load the map texture from file */ bool LoadWorldTexture(char *File); /* Copy the pSurface (Terrain) to the BackBuffer */ void Draw(int Left,int Top,int Width,int Height); /* Updates the pSurface (Terrain), should be called after exlosions */ void UpdateSurface(char *Map,int MapWidth,int PixelPerHitMap,RECT* DirtyRegion); LPDIRECT3DTEXTURE9 GetDisplaySurface() {return pDisplaySurface;} private: int SurfaceWidth; int SurfaceHeight; int BytesPerPixel; LPDIRECT3DTEXTURE9 pDisplaySurface; // Active map texture // LPDIRECT3DTEXTURE9 pWorkSurface; // Working texture // LPDIRECT3DTEXTURE9 pOriginalSurface; // Original map texture // LPDIRECT3DDEVICE9 pDevice; LPD3DXSPRITE pSprite; }; #define sWorldView DXWorldView::Instance()
[ [ [ 1, 64 ] ] ]
5d33b437ae03a3c8dffd53fa2296eed34c5f7345
b86d7c8f28a0c243b4c578821e353d5efcaf81d2
/clearcasehelper/CustomListCtrl/DropScrollBar.h
461a1043c1c83489d67080e7de7870437592e1e5
[]
no_license
nk39/mototool
dd4998d38348e0e2d010098919f68cf2c982f26a
34a0698fd274ae8b159fc8032f3065877ba2114d
refs/heads/master
2021-01-10T19:26:23.675639
2008-01-04T04:47:54
2008-01-04T04:47:54
34,927,428
1
1
null
null
null
null
UTF-8
C++
false
false
2,323
h
///////////////////////////////////////////////////////////////////////////// // DropScrollBar.h : header file // // CAdvComboBox Control // Version: 2.1 // Date: September 2002 // Author: Mathias Tunared // Email: [email protected] // Copyright (c) 2002. All Rights Reserved. // // This code, in compiled form or as source code, may be redistributed // unmodified PROVIDING it is not sold for profit without the authors // written consent, and providing that this notice and the authors name // and all copyright notices remains intact. // // This file is provided "as is" with no expressed or implied warranty. // The author accepts no liability for any damage/loss of business that // this product may cause. // ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_DROPSCROLLBAR_H__8814CD20_3D94_4B9C_8A64_DF4E9F6DD4DC__INCLUDED_) #define AFX_DROPSCROLLBAR_H__8814CD20_3D94_4B9C_8A64_DF4E9F6DD4DC__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "DropWnd.h" class CDropListBox; ///////////////////////////////////////////////////////////////////////////// // CDropScrollBar window class CDropScrollBar : public CScrollBar { // Construction public: CDropScrollBar(); // Attributes public: // Operations public: void SetListBox( CDropListBox* pListBox ); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CDropScrollBar) //}}AFX_VIRTUAL // Implementation public: virtual ~CDropScrollBar(); // Generated message map functions protected: //{{AFX_MSG(CDropScrollBar) afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void VScroll(UINT nSBCode, UINT nPos); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); //}}AFX_MSG afx_msg LONG OnSetCapture( WPARAM wParam, LPARAM lParam ); afx_msg LONG OnReleaseCapture( WPARAM wParam, LPARAM lParam ); DECLARE_MESSAGE_MAP() private: CDropListBox* m_pListBox; }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_DROPSCROLLBAR_H__8814CD20_3D94_4B9C_8A64_DF4E9F6DD4DC__INCLUDED_)
[ "netnchen@631d5421-cb3f-0410-96e9-8590a48607ad" ]
[ [ [ 1, 78 ] ] ]
307f8db28b59acc1e4ea9c0b560f5232356cbb5f
fcf03ead74f6dc103ec3b07ffe3bce81c820660d
/Base/DLLs/PolymorphicDLL1/PolymorphicDLL1.h
00fa64ec9c018b926ae38598429bb11877b196cf
[]
no_license
huellif/symbian-example
72097c9aec6d45d555a79a30d576dddc04a65a16
56f6c5e67a3d37961408fc51188d46d49bddcfdc
refs/heads/master
2016-09-06T12:49:32.021854
2010-10-14T06:31:20
2010-10-14T06:31:20
38,062,421
2
0
null
null
null
null
UTF-8
C++
false
false
488
h
// PolymorphicDLL1.h // // Copyright (C) Symbian Software Ltd 2000-2005. All rights reserved. #ifndef __PolymorphicDLL1_H #define __PolymorphicDLL1_H // get definition of base class #include "UsingDLLs.h" class CFrenchMessenger : public CMessenger { public: // constructor support virtual void ConstructL(CConsoleBase* aConsole, const TDesC& aName); // destructor virtual ~CFrenchMessenger(); // useful functions virtual void ShowMessage(); }; #endif
[ "liuxk99@bdc341c6-17c0-11de-ac9f-1d9250355bca" ]
[ [ [ 1, 22 ] ] ]
3cc4abb3cce2e57b872a38428485c912d528d76e
d1bf1aaa9175579a13b3e19808f8d887a40e0253
/src/NetworkFactory.h
ab4eb9ea8ca569a4a50888fd980d2fa2f48a0ee8
[]
no_license
peterfine/Robust-Sensors
06aa38fcc7ac014befe0f77dacad1f8c5bb988f7
d7312bf2316520225b77ee06c820e177393abdbc
refs/heads/master
2020-04-09T17:43:58.820589
2011-11-03T00:35:48
2011-11-03T00:35:48
2,699,181
0
0
null
null
null
null
UTF-8
C++
false
false
702
h
/******************************************************************************* * NetworkFactory.h * * Peter Fine - Thesis - Network Factory * Created May '05 * ******************************************************************************/ #ifndef _NETWORKFACTORY_H_ #define _NETWORKFACTORY_H_ class NeuralNetwork; class CTRNNetwork; class Properties; class MTRand; /** * Creates a NeuralNetwork object given a properties object. */ class NetworkFactory { public: static NeuralNetwork* generateNetwork(Properties& theProperties, MTRand& theRand); static void addProperties(Properties& theProperties); }; #endif //_NETWORKFACTORY_H_
[ "Peter@Peter-Laptop.(none)" ]
[ [ [ 1, 29 ] ] ]
70759089e55f1549f67ff59427dea5d93f976398
164ff2d79079ec650b0a676a42db49327a0e5d3c
/Source/Simulation/helisimDevCPP/model.cpp
3dbacdbdf3bbf4fa18e302ed1092b1247d6e47d2
[]
no_license
glocklueng/helocamosun
87bd137eebd9030cce7abebddbfb360465a4e473
3fd02937f805b75de8eca277bffc60f19569ed9e
refs/heads/master
2016-09-06T17:27:40.689764
2007-11-19T09:10:10
2007-11-19T09:10:10
42,766,167
1
0
null
null
null
null
UTF-8
C++
false
false
21,713
cpp
/****************************************************************** * * This is the new X-Cell helicopter simulation model * * Author: Aaron Kahn * ******************************************************************/ #include "model.h" /**************** HELICOPTER STRUCTUERS ****************************/ struct heli_def xcell; double model_dt = 0.001; // sec /********************* INTERNAL FUNCTIONS *********************************/ /* this is for the rotor flapping * . . . . * Xdot = [a1 b1 d c] * X = [a1 b1 d c] * A1B1 = [A1 B1] * args = [u v p q db1dv da1du w_in w_off kc dir tau Kc Kd] */ void RotorFlapDynamics(double Xdot[2], double X[2], double *t, double A1B1[2], double args[13]); void RotorFlapDynamics(double Xdot[4], double X[4], double *t, double A1B1[2], double args[13]) { double u,v,p,q,db1dv,da1du,w_in,w_off,kc,dir,tau,Kc,Kd; double a_sum, b_sum; double a1dot, b1dot, a1, b1; double d_dot, c_dot, d, c; double A1, B1; u = args[0]; v = args[1]; p = args[2]; q = args[3]; db1dv = args[4]; da1du = args[5]; w_in = args[6]; w_off = args[7]; kc = args[8]; dir = args[9]; tau = args[10]; Kc = args[11]; Kd = args[12]; a1 = X[0]; b1 = X[1]; d = X[2]; c = X[3]; // flybar mixing // lateral mixing A1 = A1B1[0] + Kd*d; // longitudinal mixing B1 = A1B1[1] + Kc*c; a_sum = b1 - A1 + dir*kc*a1 - db1dv*v*0.3; b_sum = a1 + B1 - dir*kc*b1 - da1du*u*0.3; a1dot = -w_in*b_sum - w_off*a_sum - q; b1dot = -w_in*a_sum + w_off*b_sum - p; d_dot = -d/tau - p + 0.2731*A1B1[0]/tau; c_dot = -c/tau - q - 0.2587*A1B1[1]/tau; Xdot[0] = a1dot; Xdot[1] = b1dot; Xdot[2] = d_dot; Xdot[3] = c_dot; } /********************** FUNCTIONS *****************************************/ /* This will do a combined blade element momentum theory thrust, power, torque computation * on a rotor. The inputs to the function are all of the input elements of * blade_element_def. Only T, P, Q, and average v are outputs. * * Source: Keys, Pgs 96-98 * Proudy, Pg 96 */ void rotorCalc(struct blade_element_def *pBe) { double dR; // thickness of the blade element double r_R; // ratio of local radius to total radius double r; // local radius double theta_r; // local collective angle double theta0; // root collective angle double omega_r; // local velocity double alpha; // local angle of attack double v1[NUMSTATIONS]; // local induced velocity double dT[NUMSTATIONS]; // incriment of thrust double dD[NUMSTATIONS]; // incriment of profile drag double dQ[NUMSTATIONS]; // incriment of torque double dP[NUMSTATIONS]; // incriment of power double vv; // abcOmega/2 + 4piVperp int n; int i; vv = pBe->a*pBe->b*pBe->c*pBe->omega/2.0 + 4.0*C_PI*pBe->Vperp; dR = (pBe->R - pBe->R0)/100.0; theta0 = fabs(pBe->collective) - (0.75 - (pBe->R0/pBe->R))*pBe->twst; for(n=1; n<=NUMSTATIONS; ++n) { i = n-1; r_R = (pBe->R0 + (double)(n)*dR)/pBe->R; r = r_R*pBe->R; theta_r = theta0 + pBe->twst*r_R; omega_r = pBe->omega*r; alpha = theta_r - pBe->Vperp/omega_r; v1[i] = ( -vv + sqrt(fabs( SQR(vv) + 8.0*C_PI*pBe->b*SQR(pBe->omega)*pBe->a*pBe->c*r*alpha )))/(8.0*C_PI);// Proudy pg 96 dT[i] = 4.0*C_PI*pBe->rho*(pBe->Vperp + v1[i])*v1[i]*r*dR; // Keys eq 3.11 dD[i] = 0.5*pBe->Cd0*pBe->rho*SQR(omega_r)*pBe->c*dR; // Keys eq 3.5 dQ[i] = (dT[i]*(pBe->Vperp + v1[i])/omega_r + dD[i])*r; // Keys eq 3.9a dP[i] = dQ[i]*pBe->omega; // Keys eq 3.9b } pBe->T = 0.0; pBe->Q = 0.0; pBe->P = 0.0; pBe->avg_v1 = 0.0; for(n=0; n<NUMSTATIONS; ++n) { pBe->T += dT[n]; pBe->Q += dQ[n]; pBe->P += dP[n]; pBe->avg_v1 += v1[n]; } pBe->avg_v1 = pBe->avg_v1/(double)(NUMSTATIONS); if( pBe->collective < 0.0 ) { pBe->T *= -1.0; pBe->avg_v1 *= -1.0; } } /* This will perform the initialization of the entire model. It is also the function * to call to reset the model. For the case of resetting, more than the minimum calculations * are done, but this miminimizes the number of functions to deal with. */ void ModelInit(void) { struct sixdof_fe_init_inputs_def sixinit; double rho, temp, pres, sp_sound; /******************* LOAD THE RAW DATA FOR THE X-CELL HELICOPTER *********************/ // CG information xcell.cg.fs_cg = 0.0; // in xcell.cg.wl_cg = 10.91; // in xcell.cg.wt = 8.0; // lbs xcell.cg.ix = 0.2184; // slug-ft^2 xcell.cg.iy = 0.3214; // slug-ft^2 xcell.cg.iz = 0.4608; // slug-ft^2 xcell.cg.ixz = 0.0337; // slug-ft^2 xcell.cg.hp_loss = 0.1; // HP xcell.cg.m = xcell.cg.wt/32.2; // slugs xcell.cg.altitude = 0.0; // initial DA ft // Main Rotor Information xcell.m.fs = 0.0; // in xcell.m.wl = 0.0; // in xcell.m.is = 0.0; // longitudinal shaft tilt (rad) xcell.m.e = 0.0225; // ft xcell.m.i_b = 0.0847; // slug-ft^2 xcell.m.r = 1.1875; // ft xcell.m.ro = 0.6; // ft xcell.m.a = 6.0; // */rad xcell.m.cd0 = 0.01; // nondimentional xcell.m.b = 2; // # of blades xcell.m.c = 0.1875; // ft xcell.m.twst = 0.0; // rad xcell.m.k1 = 0; // delta-3 hinge xcell.m.dir = -1.0; // MR direction of rotation viewed from top (1 = ccw; -1 = cw) xcell.m.ib = 0.0; // laterial shaft tilt (rad) // Flybar Information (Tischler and Mettler, System Identification Modeling // Of a Model-Scale Helicopter ) xcell.fb.tau = 0.36; // sec xcell.fb.Kd = 0.3; xcell.fb.Kc = 0.3; // Fuselage Information xcell.f.fs = 3.0; // in xcell.f.wl = 12.0; // in xcell.f.xuu = -0.4240; // ft^2 xcell.f.yvv = -1.2518; // ft^2 xcell.f.zww = -0.8861; // ft^2 // Horizontal Fin Information xcell.h.fs = 0; // in xcell.h.wl = 0; // in xcell.h.zuu = 0; // ft^2 xcell.h.zuw = 0; // ft^2 xcell.h.zmax = 0; // ft^2 // Vertical Fin Information xcell.v.fs = -41.5; // in xcell.v.wl = 7.25; // in xcell.v.yuu = 0; // ft^2 xcell.v.yuv = -1.4339; // ft^2 xcell.v.ymax = -0.275; // ft^2 xcell.v.a = 5.5; // */rad // Tail Rotor Information xcell.t.fs = -41.5; // in xcell.t.wl = 7.25; // in xcell.t.r = 0.5417; // ft xcell.t.r0 = 0.083; // ft xcell.t.a = 3.0; // */rad xcell.t.b = 2; // # of TR blades xcell.t.c = 0.099; // ft xcell.t.twst = 0.0; // rad xcell.t.cd0 = 0.01; // nondimentional xcell.t.duct = 0.0; // duct augmetation (duct*thrust; power/duct) // Landing Gear Information // right-front gear xcell.grIn[0].cg2point[0] = (8.0 - xcell.cg.fs_cg)/12.0; xcell.grIn[0].cg2point[1] = 0.65; xcell.grIn[0].cg2point[2] = (20.0 - xcell.cg.wl_cg)/12.0; xcell.grIn[0].k = 120.0; xcell.grIn[0].b = sqrt(2.0*xcell.grIn[0].k); xcell.grIn[0].mu_x = 0.8; xcell.grIn[0].mu_y = 0.8; xcell.grIn[0].rotation = 0.0; // right-back gear xcell.grIn[1].cg2point[0] = (-6.0 - xcell.cg.fs_cg)/12.0; xcell.grIn[1].cg2point[1] = 0.65; xcell.grIn[1].cg2point[2] = (20.0 - xcell.cg.wl_cg)/12.0; xcell.grIn[1].k = 120.0; xcell.grIn[1].b = sqrt(2.0*xcell.grIn[0].k); xcell.grIn[1].mu_x = 0.8; xcell.grIn[1].mu_y = 0.8; xcell.grIn[1].rotation = 0.0; // left-front gear xcell.grIn[2].cg2point[0] = (8.0 - xcell.cg.fs_cg)/12.0; xcell.grIn[2].cg2point[1] = -0.65; xcell.grIn[2].cg2point[2] = (20.0 - xcell.cg.wl_cg)/12.0; xcell.grIn[2].k = 120.0; xcell.grIn[2].b = sqrt(2.0*xcell.grIn[0].k); xcell.grIn[2].mu_x = 0.8; xcell.grIn[2].mu_y = 0.8; xcell.grIn[2].rotation = 0.0; // left-back gear xcell.grIn[3].cg2point[0] = (-6.0 - xcell.cg.fs_cg)/12.0; xcell.grIn[3].cg2point[1] = -0.65; xcell.grIn[3].cg2point[2] = (20.0 - xcell.cg.wl_cg)/12.0; xcell.grIn[3].k = 120.0; xcell.grIn[3].b = sqrt(2.0*xcell.grIn[0].k); xcell.grIn[3].mu_x = 0.8; xcell.grIn[3].mu_y = 0.8; xcell.grIn[3].rotation = 0.0; // tail xcell.grIn[4].cg2point[0] = (-41.5 - xcell.cg.fs_cg)/12.0; xcell.grIn[4].cg2point[1] = 0.0; xcell.grIn[4].cg2point[2] = (15.0 - xcell.cg.wl_cg)/12.0; xcell.grIn[4].k = 140.0; xcell.grIn[4].b = sqrt(2.0*xcell.grIn[0].k); xcell.grIn[4].mu_x = 0.8; xcell.grIn[4].mu_y = 0.8; xcell.grIn[4].rotation = 0.0; xcell.num_gear = 5; // Servo Information (all servos are generic) // B1 (pitch) servo xcell.svIn[0].wn = 38.2261; xcell.svIn[0].zeta = 0.5118; xcell.svIn[0].slop = 0.0; // A1 (roll) servo xcell.svIn[1].wn = 38.2261; xcell.svIn[1].zeta = 0.5118; xcell.svIn[1].slop = 0.0; // MR Coll servo xcell.svIn[2].wn = 38.2261; xcell.svIn[2].zeta = 0.5118; xcell.svIn[2].slop = 0.0; // TR Coll servo xcell.svIn[3].wn = 38.2261; xcell.svIn[3].zeta = 0.5118; xcell.svIn[3].slop = 0.0; // Tail Gyro Gain xcell.c.gyro_gain = 0;//80.0; ///we dont have a tail rotor gyro /************** COMPUTE CG RELATIVE POSITIONS **********************************/ // Main Rotor xcell.m.h = (xcell.cg.wl_cg - xcell.m.wl)/12.0; // vertical distance to CG (ft) xcell.m.d = (xcell.cg.fs_cg - xcell.m.fs)/12.0; // horizontal distance to CG (ft) // Tail Rotor xcell.t.h = (xcell.cg.wl_cg - xcell.t.wl)/12.0; // vertical distance to CG (ft) xcell.t.d = (xcell.cg.fs_cg - xcell.t.fs)/12.0; // horizontal distance to CG (ft) // Fuselage xcell.f.h = (xcell.cg.wl_cg - xcell.f.wl)/12.0; // vertical distance to CG (ft) xcell.f.d = (xcell.cg.fs_cg - xcell.f.fs)/12.0; // horizontal distance to CG (ft) // Horizontal Fin xcell.h.h = (xcell.cg.wl_cg - xcell.h.wl)/12.0; // vertical distance to CG (ft) xcell.h.d = (xcell.cg.fs_cg - xcell.h.fs)/12.0; // horizontal distance to CG (ft) // Vertical Fin xcell.v.h = (xcell.cg.wl_cg - xcell.v.wl)/12.0; // vertical distance to CG (ft) xcell.v.d = (xcell.cg.fs_cg - xcell.v.fs)/12.0; // horizontal distance to CG (ft) /************** STATE VECTOR AND CONTROL INITIALIZATIONS ************************/ // 6-DOF Initializations sixinit.Ixx = xcell.cg.ix; sixinit.Iyy = xcell.cg.iy; sixinit.Izz = xcell.cg.iz; sixinit.Ixz = xcell.cg.ixz; sixinit.m = xcell.cg.m; Vinit(sixinit.NED, 3); sixinit.NED[2] = -2.0; Vinit(sixinit.THETA, 3); Vinit(sixinit.pqr, 3); Vinit(sixinit.uvw, 3); sixdof_fe_init(&sixinit, &xcell.sixdofIn, &xcell.sixdofX); // CG Initialization xcell.cg.altitude = 0.0; memcpy(xcell.cg.NED, xcell.sixdofX.NED, 3*sizeof(double)); memcpy(xcell.cg.uvw, xcell.sixdofX.Vb, 3*sizeof(double)); memcpy(xcell.cg.V, xcell.sixdofX.Ve, 3*sizeof(double)); memcpy(xcell.cg.THETA, xcell.sixdofX.THETA, 3*sizeof(double)); memcpy(xcell.cg.pqr, xcell.sixdofX.rate, 3*sizeof(double)); xcell.cg.time = 0.0; Vinit(xcell.cg.F, 3); Vinit(xcell.cg.M, 3); // Initial Control Inputs xcell.c.A1 = 0.0; // roll (rad + right wing down) xcell.c.B1 = 0.0; // pitch (rad + nose down) xcell.c.mr_col = 2.5*C_DEG2RAD; // mr col (rad) xcell.c.tr_col = 4.5*C_DEG2RAD; // tr col (rad) xcell.c.mr_rev = 3000.0; // mr RPM xcell.c.tr_rev = 4.6*xcell.c.mr_rev; // tr RPM xcell.c.gyro_gain = 0.08; // set/clear the holds xcell.sixdofIn.hold_p = 0; xcell.sixdofIn.hold_q = 0; xcell.sixdofIn.hold_r = 0; xcell.sixdofIn.hold_u = 0; xcell.sixdofIn.hold_v = 0; xcell.sixdofIn.hold_w = 0; // Servo Initialization // B1 (pitch) servo Vinit(xcell.svX[0].X, 2); xcell.svX[0].output = 0.0; xcell.svIn[0].command = xcell.c.B1; // A1 (roll) servo Vinit(xcell.svX[1].X, 2); xcell.svX[1].output = 0.0; xcell.svIn[1].command = xcell.c.A1; // MR collective servo Vinit(xcell.svX[2].X, 2); xcell.svX[2].output = 0.0; xcell.svIn[2].command = xcell.c.mr_col; // TR collective servo Vinit(xcell.svX[3].X, 2); xcell.svX[3].output = 0.0; xcell.svIn[3].command = xcell.c.tr_col; /**************** MAIN ROTOR DYNAMIC CONSTANT CALUCULATIONS **********************/ atmosphere((xcell.cg.altitude - xcell.cg.NED[2]), &rho, &pres, &temp, &sp_sound); xcell.m.omega = xcell.c.mr_rev*C_TWOPI/60.0; // rad/s xcell.m.v_tip = xcell.m.r*xcell.m.omega; // ft/s xcell.m.lock = (rho*xcell.m.a*xcell.m.c*pow(xcell.m.r, 4.0))/xcell.m.i_b; // mr lock number xcell.m.omega_f = (xcell.m.lock*xcell.m.omega/16.0)*(1.0 + (8.0/3.0)*(xcell.m.e/xcell.m.r)); // natural freq shift xcell.m.k2 = 0.75*(xcell.m.e/xcell.m.r)*(xcell.m.omega/xcell.m.omega_f); // cross-couple coef. xcell.m.kc = xcell.m.k1 + xcell.m.k2; // total cross-couple coef. xcell.m.tau = 16.0/(xcell.m.omega*xcell.m.lock); // time constant of rotor xcell.m.w_off = xcell.m.omega/(1.0 + SQR(xcell.m.omega/xcell.m.omega_f)); // off-axis flap xcell.m.w_in = xcell.m.omega/xcell.m.omega_f*xcell.m.w_off; // on-axis flap xcell.m.dl_db1 = 0.75*(xcell.m.b*xcell.m.c*SQR(xcell.m.r)*rho*\ SQR(xcell.m.v_tip)*xcell.m.a*xcell.m.e/(xcell.m.lock*xcell.m.r)); // moment coef xcell.m.dm_da1 = xcell.m.dl_db1; xcell.m.ct = xcell.cg.wt/(rho*C_PI*SQR(xcell.m.r)*SQR(xcell.m.v_tip)); // thrust coef xcell.m.sigma = xcell.m.b*xcell.m.c/(C_PI*xcell.m.r); // solidity xcell.m.db1dv = -(2.0/xcell.m.v_tip)*(8.0*xcell.m.ct/(xcell.m.a*xcell.m.sigma) + \ sqrt(xcell.m.ct/2.0)); // flap back coef xcell.m.da1du = -xcell.m.db1dv; // flab back coef xcell.m.vi = 15.0; xcell.m.a1 = 0.0; xcell.m.b1 = 0.0; xcell.m.a1dot = 0.0; xcell.m.b1dot = 0.0; xcell.m.thrust = 0.0; xcell.m.x = 0.0; xcell.m.y = 0.0; xcell.m.z = 0.0; xcell.m.l = 0.0; xcell.m.m = 0.0; xcell.m.n = 0.0; xcell.fb.c = 0.0; xcell.fb.c_dot = 0.0; xcell.fb.d = 0.0; xcell.fb.d_dot = 0.0; /****************** TAIL ROTOR CALCULATIONS ***************************************/ xcell.t.omega = xcell.c.tr_rev*C_TWOPI/60.0; xcell.t.fr = xcell.t.cd0*xcell.t.r*xcell.t.b*xcell.t.c; xcell.t.vi = 10.0; xcell.t.thrust = 0.0; xcell.t.x = 0.0; xcell.t.y = 0.0; xcell.t.z = 0.0; xcell.t.l = 0.0; xcell.t.m = 0.0; xcell.t.n = 0.0; } /* This will perform the time stepping of the servo model. * The values of U[7] are as follows... * U[0] = main rotor collective (rad) * U[1] = A1 swashplate tilt (+ right roll) (rad) * U[2] = B1 swashplate tilt (+ nose down) (rad) * U[3] = tail rotor collective (rad) * * The svIn[3] and svX[3] are as follows... * sv[0] = B1 (pitch servo) * sv[1] = A1 (roll servo) * sv[2] = main rotor collective * sv[3] = tail rotor collective */ void Actuator(struct heli_def *heli, double U[4]) { struct control_def *c = &heli->c; struct cg_def *cg = &heli->cg; struct servo_inputs_def *A1svIn = &heli->svIn[1]; struct servo_state_def *A1svX = &heli->svX[1]; struct servo_inputs_def *B1svIn = &heli->svIn[0]; struct servo_state_def *B1svX = &heli->svX[0]; struct servo_inputs_def *mrColsvIn = &heli->svIn[2]; struct servo_state_def *mrColsvX = &heli->svX[2]; struct servo_inputs_def *trColsvIn = &heli->svIn[3]; struct servo_state_def *trColsvX = &heli->svX[3]; mrColsvIn->command = LIMIT(U[0], 2.5*C_DEG2RAD, 18.0*C_DEG2RAD); A1svIn->command = LIMIT(U[1], -8.0*C_DEG2RAD, 8.0*C_DEG2RAD); B1svIn->command = LIMIT(U[2], -8.0*C_DEG2RAD, 8.0*C_DEG2RAD); trColsvIn->command = LIMIT(U[3], -20.0*C_DEG2RAD, 20.0*C_DEG2RAD); servo(A1svX, A1svIn, model_dt); servo(B1svX, B1svIn, model_dt); servo(mrColsvX, mrColsvIn, model_dt); servo(trColsvX, trColsvIn, model_dt); c->B1 = B1svX->output; c->A1 = A1svX->output; c->mr_col = mrColsvX->output; c->tr_col = trColsvX->output; } /* This will perform the landing gear calculations with the landing gear * model provided in the simulation library. */ void LandingGear(struct heli_def *heli) { struct cg_def *cg = &heli->cg; struct control_def *c = &heli->c; int i; for(i=0; i<heli->num_gear; ++i) { heli->grIn[i].altitude = cg->NED[2]; memcpy(heli->grIn[i].THETA, cg->THETA, 3*sizeof(double)); memcpy(heli->grIn[i].uvw, cg->uvw, 3*sizeof(double)); memcpy(heli->grIn[i].pqr, cg->pqr, 3*sizeof(double)); gear(&heli->grIn[i], &heli->grOut[i]); cg->F[0] += heli->grOut[i].F[0]; cg->F[1] += heli->grOut[i].F[1]; cg->F[2] += heli->grOut[i].F[2]; cg->M[0] += heli->grOut[i].M[0]; cg->M[1] += heli->grOut[i].M[1]; cg->M[2] += heli->grOut[i].M[2]; } } /* This will perform the forces and moments calculations on the aircraft * before the calculations of the 6-DOF. The landing gear calculations are done * after this function. The servo and wind models are run after this as well. */ void FandM(struct heli_def *heli) { struct mainrotor_def *m = &heli->m; struct flybar_def *fb = &heli->fb; struct tailrotor_def *t = &heli->t; struct verticalfin_def *v = &heli->v; struct horizontalfin_def *h = &heli->h; struct fuse_def *f = &heli->f; struct cg_def *cg = &heli->cg; struct blade_element_def *mb = &heli->MRBE; struct blade_element_def *tb = &heli->TRBE; struct control_def *c = &heli->c; double rho; // density of air (slug/ft^3) double pressure; // air pressure (lb/ft^2) double temperature; // air temperature (deg R) double sp_sound; // local speed of sound (ft/s) double densAlt; // current density altitude (ft MSL + up) double cBE[MAXSIZE][MAXSIZE]; // rotation matrix earth TP -> body double tempV[MAXSIZE]; // temp vector double Xdot[4], X[4], U[2], args[13]; // for RK4 routine (rotor dynamics) // compute the current atmospheric conditions densAlt = cg->altitude - cg->NED[2]; atmosphere(densAlt, &rho, &pressure, &temperature, &sp_sound); // compute the local gravitational force tempV[0] = 0.0; tempV[1] = 0.0; tempV[2] = 32.2*cg->m; eulerDC(cBE, cg->THETA[0], cg->THETA[1], cg->THETA[2]); MVmult(cBE, tempV, cg->F, 3, 3); // Main Rotor Calculations mb->a = m->a; mb->b = m->b; mb->c = m->c; mb->Cd0 = m->cd0; mb->collective = c->mr_col; mb->e = 0.7; // oswalds efficency factor mb->omega = c->mr_rev*C_TWOPI/60.0; mb->R = m->r; mb->R0 = m->ro; mb->rho = rho; mb->twst = m->twst; mb->Vperp = -(cg->uvw[2] + cg->uvw[0]*(m->is + m->a1) - cg->uvw[1]*(m->ib + m->b1)); rotorCalc(mb); m->thrust = mb->T; m->power = mb->P; m->torque = mb->Q; m->vi = mb->avg_v1; m->x = -m->thrust*(m->is + m->a1); m->y = m->thrust*(m->ib + m->b1); m->z = -m->thrust; m->l = m->y*m->h + m->dl_db1*m->b1; m->m = m->z*m->d - m->x*m->h + m->dm_da1*m->a1; m->n = m->torque*m->dir; // Tail Rotor Calculations tb->a = t->a; tb->b = t->b; tb->c = t->c; tb->Cd0 = t->cd0; tb->collective = c->tr_col; tb->e = 0.7; // oswalds efficency factor tb->omega = c->tr_rev*C_TWOPI/60.0; tb->R = t->r; tb->R0 = t->r0; tb->rho = rho; tb->twst = t->twst; tb->Vperp = (cg->uvw[1] - t->d*cg->pqr[2])*m->dir; rotorCalc(tb); t->thrust = tb->T + tb->T*t->duct; t->power = tb->P - tb->P*t->duct; t->x = 0.0; t->y = t->thrust*m->dir; t->z = 0.0; t->l = t->y*t->h; t->m = 0.0; t->n = -t->y*t->d; // Fuselage Calculations f->x = (rho/2.0)*cg->uvw[0]*fabs(cg->uvw[0])*f->xuu; f->y = (rho/2.0)*cg->uvw[1]*fabs(cg->uvw[1])*f->yvv; f->z = (rho/2.0)*f->zww*( cg->uvw[2]*fabs(cg->uvw[2]) - m->vi ); f->l = f->y*f->h; f->m = f->z*f->d - f->x*f->h; f->n = -f->y*f->d; // Vertical Fin Calculations v->x = 0.0; v->y = (rho/2.0)*cg->uvw[1]*fabs(cg->uvw[1])*v->yuv; v->z = 0.0; v->l = v->y*v->h; v->m = 0.0; v->n = -v->y*v->d; // Main Rotor TPP Dynamics X[0] = m->a1; X[1] = m->b1; X[2] = fb->d; X[3] = fb->c; U[0] = c->A1; U[1] = c->B1; args[0] = cg->uvw[0]; args[1] = cg->uvw[1]; args[2] = cg->pqr[0]; args[3] = cg->pqr[1]; args[4] = m->db1dv; args[5] = m->da1du; args[6] = m->w_in; args[7] = m->w_off; args[8] = m->kc; args[9] = m->dir; args[10] = fb->tau; args[11] = fb->Kc; args[12] = fb->Kd; RK4(X, Xdot, cg->time, U, args, 4, model_dt, &RotorFlapDynamics); m->a1 = X[0]; m->b1 = X[1]; fb->d = X[2]; fb->c = X[3]; m->a1dot = Xdot[0]; m->b1dot = Xdot[1]; fb->d_dot = Xdot[2]; fb->c_dot = Xdot[3]; // Sum Up Total Forces and Moments At CG cg->F[0] += m->x + t->x + f->x + v->x; cg->F[1] += m->y + t->y + f->y + v->y; cg->F[2] += m->z + t->z + f->z + v->z; cg->M[0] = m->l + t->l + f->l + v->l; cg->M[1] = m->m + t->m + f->m + v->m; cg->M[2] = m->n + t->n + f->n + v->n; } /* This will perform the entire calculations of everything that needs to happen to * make the math model of the vehicle work. This is the function to call to * propogate the helicopter model, 6-DOF, landing gear, servos, and wind. * * U[4] = [mr_coll rad + goes up * A1 rad + right wind down * B1 rad + nose down * tr_coll] rad + right turn */ void ModelGO(double U[4]) { FandM(&xcell); LandingGear(&xcell); Actuator(&xcell, U); memcpy(xcell.sixdofIn.F, xcell.cg.F, sizeof(double)*MAXSIZE); memcpy(xcell.sixdofIn.M, xcell.cg.M, sizeof(double)*MAXSIZE); sixdof_fe(&xcell.sixdofX, &xcell.sixdofIn, model_dt); memcpy(xcell.cg.NED, xcell.sixdofX.NED, sizeof(double)*MAXSIZE); memcpy(xcell.cg.uvw, xcell.sixdofX.Vb, sizeof(double)*MAXSIZE); memcpy(xcell.cg.V, xcell.sixdofX.Ve, sizeof(double)*MAXSIZE); memcpy(xcell.cg.THETA, xcell.sixdofX.THETA, sizeof(double)*MAXSIZE); memcpy(xcell.cg.pqr, xcell.sixdofX.rate, sizeof(double)*MAXSIZE); xcell.cg.time += model_dt; }
[ "scottm361@aa1bae0d-ba29-0410-9611-f7b7655375bb" ]
[ [ [ 1, 723 ] ] ]
26e75cf8962ef11b8cfd30c7ad68a2ccce714b6e
cbb40e1d71bc4585ad3a58d32024090901487b76
/trunk/tokamaksrc/TokaDemo/PingPangMD2XMesh.h
491a34986935bcd3979d73402b1259c814ecf880
[]
no_license
huangleon/tokamak
c0dee7b8182ced6b514b37cf9c526934839c6c2e
0218e4d17dcf93b7ab476e3e8bd4026f390f82ca
refs/heads/master
2021-01-10T10:11:42.617076
2011-08-22T02:32:16
2011-08-22T02:32:16
50,816,154
0
0
null
null
null
null
UTF-8
C++
false
false
4,649
h
#ifndef _ANIMATED_MESH_MD2X_H_ #define _ANIMATED_MESH_MD2X_H_ #include <irrlicht.h> using irr::c8; using irr::s32; using irr::u32; using irr::u16; using irr::f32; using irr::scene::IAnimatedMeshMD2; using irr::scene::IMesh; using irr::scene::IMeshBuffer; using irr::io::IReadFile; using irr::video::SMaterial; using irr::video::E_VERTEX_TYPE; using irr::video::EVT_STANDARD; using irr::core::aabbox3d; using irr::core::aabbox3df; using irr::core::array; using irr::video::E_MATERIAL_FLAG; using irr::scene::E_ANIMATED_MESH_TYPE; using irr::scene::EMD2_ANIMATION_TYPE; using irr::scene::EAMT_MD2; using irr::core::stringc; using irr::ELOG_LEVEL; using irr::ELL_INFORMATION; using irr::video::S3DVertex; class CPingPangMD2XMesh : public IAnimatedMeshMD2 , public IMesh , public IMeshBuffer { enum { MD2_MAGIC_NUMBER = 844121161 }; enum { MD2_VERSION = 8 }; enum { MD2_MAX_VERTS = 2048 }; enum { MD2_FRAME_SHIFT = 0 }; // 2? public: CPingPangMD2XMesh() : m_pTriangles( 0 ) , m_pTexCoords( 0 ) , m_nTriangleCount( 0 ) , m_nVertexCount( 0 ) { //m_Material.ZBuffer = 0; //m_Material.ZWriteEnable = false; //m_Material.BackfaceCulling = false; } virtual ~CPingPangMD2XMesh() { Clearup(); } virtual bool loadFile( IReadFile* file ); virtual s32 getFrameCount() { return m_arrFrames.size(); } virtual IMesh* getMesh( s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1 ); virtual u32 getMeshBufferCount() const { return 1; } virtual IMeshBuffer* getMeshBuffer( u32 nr ) const { return (IMeshBuffer*) this; } virtual IMeshBuffer* getMeshBuffer( const SMaterial &material ) const { if( m_Material == material ) return (IMeshBuffer*) this; else return 0; } virtual const SMaterial& getMaterial( ) const { return m_Material; } virtual SMaterial& getMaterial() { return m_Material; } virtual const void* getVertices() const { return m_arrVertices.const_pointer(); } virtual void* getVertices() { return m_arrVertices.pointer(); } virtual E_VERTEX_TYPE getVertexType() const { return EVT_STANDARD; } virtual u32 getVertexPitch() const { return sizeof( S3DVertex ); } virtual u32 getVertexCount() const { return m_arrVertices.size(); } virtual const u16* getIndices() const { return m_arrIndices.const_pointer(); } virtual u16* getIndices() { return m_arrIndices.pointer(); } virtual u32 getIndexCount() const { return m_arrIndices.size(); } virtual const aabbox3d<f32>& getBoundingBox() const { return m_BoundingBox; } virtual void setBoundingBox( const aabbox3df& box ) { m_BoundingBox = box; } virtual void setMaterialFlag( E_MATERIAL_FLAG flag, bool newvalue ) { m_Material.setFlag(flag, newvalue); } virtual E_ANIMATED_MESH_TYPE getMeshType() const { return EAMT_MD2; } virtual void getFrameLoop( EMD2_ANIMATION_TYPE, s32& outBegin, s32& outEnd, s32& outFps ) const; virtual bool getFrameLoop( const c8* name, s32& outBegin, s32& outEnd, s32& outFps ) const; virtual s32 getAnimationCount() const { return FrameData.size(); } virtual const c8* getAnimationName( s32 nr ) const; private: void updateInterpolationBuffer( s32 frame, s32 startFrame, s32 endFrame ); virtual void calculateBoundingBox(); array<aabbox3d<f32> > m_lstBox; SMaterial m_Material; aabbox3d<f32> m_BoundingBox; struct SFrameData { stringc name; s32 begin; s32 end; s32 fps; }; array< SFrameData > FrameData; void log( const c8* text, const c8* hint, ELOG_LEVEL ll = ELL_INFORMATION ); void* m_pTriangles; void* m_pTexCoords; u32 m_nTriangleCount; u32 m_nVertexCount; array<void *> m_arrFrames; array<u16> m_arrIndices; array<S3DVertex> m_arrVertices; void Clearup(); }; #endif //_ANIMATED_MESH_MD2X_H_
[ [ [ 1, 237 ] ] ]
d0ffdaa885c6ff3540198f40dd397013bd750690
f55665c5faa3d79d0d6fe91fcfeb8daa5adf84d0
/Depend/MyGUI/Common/PanelView/BasePanelView.h
6148df6f15b3d4381107c8aeb5cd55b3aaab5df4
[]
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
WINDOWS-1251
C++
false
false
6,108
h
/*! @file @author Albert Semenov @date 08/2008 @module */ #ifndef __BASE_PANEL_VIEW_H__ #define __BASE_PANEL_VIEW_H__ #include <MyGUI.h> #include "BaseLayout/BaseLayout.h" #include "PanelView/BasePanelViewItem.h" namespace wraps { template <typename TypeCell> class BasePanelView : public BaseLayout { public: typedef std::vector<BasePanelViewItem*> VectorCell; public: BasePanelView(const std::string& _layout, MyGUI::Widget* _parent) : BaseLayout(_layout, _parent), mNeedUpdate(false), mOldClientWidth(0), mFirstInitialise(false) { mScrollView = mMainWidget->castType<MyGUI::ScrollView>(); // пото?перенест??лейаут mScrollView->setCanvasAlign(MyGUI::Align::HCenter | MyGUI::Align::Top); mScrollView->setVisibleHScroll(false); mNeedUpdate = false; mOldClientWidth = mScrollView->getClientCoord().width; MyGUI::Gui::getInstance().eventFrameStart += MyGUI::newDelegate(this, &BasePanelView::frameEnteredCheck); } virtual ~BasePanelView() { MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate(this, &BasePanelView::frameEnteredCheck); removeAllItems(); } //! Get number of items size_t getItemCount() { return mItems.size(); } //! Insert an item into a list at a specified position void insertItem(size_t _index, BasePanelViewItem* _item) { MYGUI_ASSERT_RANGE_INSERT(_index, mItems.size(), "BasePanelView::insertItem"); if (_index == MyGUI::ITEM_NONE) _index = mItems.size(); MYGUI_ASSERT(findItem(_item) == MyGUI::ITEM_NONE, "panel allready exist"); // создае?лейаут базово?ячейк? BasePanelViewCell* cell = new TypeCell(mScrollView); cell->eventUpdatePanel = MyGUI::newDelegate(this, &BasePanelView::notifyUpdatePanel); // теперь основной лейаут ячейк? _item->_initialise(cell); mItems.insert(mItems.begin() + _index, _item); setNeedUpdate(); mFirstInitialise = true; } //! Add an item to the end of a list void addItem(BasePanelViewItem* _item) { insertItem(MyGUI::ITEM_NONE, _item); } //! Get item from specified position BasePanelViewItem* getItem(size_t _index) { MYGUI_ASSERT_RANGE(_index, mItems.size(), "BasePanelView::getItem"); return mItems[_index]; } //! Search item, returns the position of the first occurrence in list or ITEM_NONE if item not found size_t findItem(BasePanelViewItem* _item) { for (VectorCell::iterator iter = mItems.begin(); iter != mItems.end(); ++iter) { if ((*iter) == _item) return iter - mItems.begin(); } return MyGUI::ITEM_NONE; } //! Remove item at a specified position void removeItemAt(size_t _index) { MYGUI_ASSERT_RANGE(_index, mItems.size(), "BasePanelView::removeItemAt"); BasePanelViewCell* cell = mItems[_index]->getPanelCell(); mItems[_index]->_shutdown(); delete cell; mItems.erase(mItems.begin() + _index); setNeedUpdate(); } //! Remove item at a specified position void removeItem(BasePanelViewItem* _item) { size_t index = findItem(_item); MYGUI_ASSERT(index != MyGUI::ITEM_NONE, "item is not found"); removeItemAt(index); } //! Remove all items void removeAllItems() { for (VectorCell::iterator iter = mItems.begin(); iter != mItems.end(); ++iter) { BasePanelViewCell* cell = (*iter)->getPanelCell(); (*iter)->_shutdown(); delete cell; } mItems.clear(); setNeedUpdate(); } void updateView() { // вычисляем максимальную высоту всег?добр? int height = 0; for (VectorCell::iterator iter = mItems.begin(); iter != mItems.end(); ++iter) { MyGUI::Widget* widget = (*iter)->getPanelCell()->getMainWidget(); if (widget->getVisible()) { height += widget->getHeight(); } } // ставим высоту холста, ?спрашиваем получившую? ширину клиент? mScrollView->setCanvasSize(0, height); // ширина клиент?могл?поме?тся const MyGUI::IntSize& size = mScrollView->getClientCoord().size(); mScrollView->setCanvasSize(size.width, height); bool change = mFirstInitialise; if (mOldClientWidth != size.width) { mOldClientWidth = size.width; change = true; } // выравнивае?вс?панели int pos = 0; for (VectorCell::iterator iter = mItems.begin(); iter != mItems.end(); ++iter) { MyGUI::Widget* widget = (*iter)->getPanelCell()->getMainWidget(); if (widget->getVisible() || mFirstInitialise) { height = widget->getHeight(); widget->setCoord(MyGUI::IntCoord(0, pos, size.width, height)); // оповещае? чт?мы обновили ширину if (change) (*iter)->notifyChangeWidth(size.width); pos += height; } } mNeedUpdate = false; mFirstInitialise = false; MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate(this, &BasePanelView::frameEntered); } // изменились размер? // необходимо обновить вс?панели void setNeedUpdate() { if (!mNeedUpdate) { mNeedUpdate = true; MyGUI::Gui::getInstance().eventFrameStart += MyGUI::newDelegate(this, &BasePanelView::frameEntered); } } private: void notifyUpdatePanel(BasePanelViewCell* _panel) { setNeedUpdate(); } void frameEntered(float _time) { updateView(); } void frameEnteredCheck(float _time) { const MyGUI::IntSize& size = mMainWidget->getSize(); if (size != mOldSize) { mOldSize = size; setNeedUpdate(); } } protected: MyGUI::ScrollView* mScrollView; private: VectorCell mItems; bool mNeedUpdate; int mOldClientWidth; MyGUI::IntSize mOldSize; bool mFirstInitialise; }; } // namespace wraps #endif // __BASE_PANEL_VIEW_H__
[ "albertclass@a94d7126-06ea-11de-b17c-0f1ef23b492c" ]
[ [ [ 1, 229 ] ] ]
3eb82a881feca1fd61653dcc93958eeb21726459
740ed7e8d98fc0af56ee8e0832e3bd28f08cf362
/src/game/captain_badass/states/ThrowingAxeState.cpp
3409f8a309f26429a15ad00554966c022926684c
[]
no_license
fgervais/armconsoledemogame
420c53f926728b30fe1723733de2f32961a6a6d9
9158c0e684db16c4327b51aec45d1e4eed96b2d4
refs/heads/master
2021-01-10T11:27:43.912609
2010-07-29T18:53:06
2010-07-29T18:53:06
44,270,121
0
0
null
null
null
null
UTF-8
C++
false
false
472
cpp
/* * BusterState.cpp * * Created on: 2010-05-29 * Author: Basse */ #include "ThrowingAxeState.h" #include <iostream> using namespace std; ThrowingAxeState::ThrowingAxeState(uint32_t animationWidth, uint32_t animationHeight, Bitmap** animationFrames, uint32_t numberOfFrame, Bitmap** animationMasks) : State(animationWidth, animationHeight, animationFrames, numberOfFrame, animationMasks) { } ThrowingAxeState::~ThrowingAxeState() { }
[ "fournierseb2@051cbfc0-75b8-dce1-6088-688cefeb9347" ]
[ [ [ 1, 20 ] ] ]
243b4a44baf7faa033f0a88e8d120d789cc0a7fc
a36d7a42310a8351aa0d427fe38b4c6eece305ea
/core_billiard/my_render.h
9ceae22f606ce93981e98fa237231a3dd71b4d82
[]
no_license
newpolaris/mybilliard01
ca92888373c97606033c16c84a423de54146386a
dc3b21c63b5bfc762d6b1741b550021b347432e8
refs/heads/master
2020-04-21T06:08:04.412207
2009-09-21T15:18:27
2009-09-21T15:18:27
39,947,400
0
0
null
null
null
null
UTF-8
C++
false
false
4,834
h
#pragma once #include "stdafx.h" namespace my_render { using namespace std; using namespace std::tr1; class ApplicationWindow; class MouseEventListener; class KeyboardEventListener; class Render; class RenderEventListener; class RenderTarget; class RenderTargetCallBack; class RenderState; class RenderState_Wireframe; class RenderState_Cull; class RenderState_Alpha; class RenderState_ZBuffer; class Shader; class Texture; class EffectShader; class EffectShaderCallBack; class EffectShaderFeeder; class EffectShaderCameraFeeder; class EffectShaderShadowMapFeeder; class ShaderVariable; class EffectShaderAnnotation; class EffectShaderVariable; class EffectShaderVariableBlock; class EffectShaderVariableBlockCallBack; class RenderTargetChain; class VertexBuffer; class RenderBufferFactory; class Scene; class Base; class Node; class Camera; class CameraMatrix; class ColladaFactory; class NodeFactory; class GeometryFactory; class Instance; class InstanceResolver; class Geometry; class GeometryMesh; class GeometryMeshPrimitive; class Displayable; class CameraFactory; class CameraPerspective; class CameraOrthographic; MY_SMART_PTR( ApplicationWindow ); MY_SMART_PTR( MouseEventListener ); MY_SMART_PTR( KeyboardEventListener ); MY_SMART_PTR( Render ); MY_SMART_PTR( RenderState ); MY_SMART_PTR( RenderTarget ); MY_SMART_PTR( RenderTargetCallBack ); MY_SMART_PTR( RenderEventListener ); MY_SMART_PTR( VertexBuffer ); MY_SMART_PTR( Texture ); MY_SMART_PTR( Shader ); MY_SMART_PTR( ShaderVariable ); MY_SMART_PTR( EffectShaderAnnotation ); MY_SMART_PTR( EffectShaderVariable ); MY_SMART_PTR( EffectShaderVariableBlock ); MY_SMART_PTR( EffectShaderVariableBlockCallBack ); MY_SMART_PTR( EffectShaderCallBack ); MY_SMART_PTR( EffectShader ); MY_SMART_PTR( EffectShaderFeeder ); MY_SMART_PTR( EffectShaderCameraFeeder ); MY_SMART_PTR( EffectShaderShadowMapFeeder ); MY_SMART_PTR( RenderTargetChain ); MY_SMART_PTR( RenderBufferFactory ); MY_SMART_PTR( Scene ); MY_SMART_PTR( Base ); MY_SMART_PTR( Node ); MY_SMART_PTR( Camera ); MY_SMART_PTR( CameraMatrix ); MY_SMART_PTR( ColladaFactory ); MY_SMART_PTR( NodeFactory ); MY_SMART_PTR( Displayable ); MY_SMART_PTR( GeometryFactory ); MY_SMART_PTR( Instance ); MY_SMART_PTR( InstanceResolver ); MY_SMART_PTR( Geometry ); MY_SMART_PTR( GeometryMesh ); MY_SMART_PTR( GeometryMeshPrimitive ); MY_SMART_PTR( CameraFactory ); MY_SMART_PTR( CameraPerspective ); MY_SMART_PTR( CameraOrthographic ); } #include "WM4Math.h" #include "RowMajorMatrix44.h" #include "Displayable.h" #include "RenderTargetCallBack.h" #include "RenderTarget.h" #include "ApplicationWindow.h" #include "MouseEventListener.h" #include "KeyboardEventListener.h" #include "MouseEventListenerNull.hpp" #include "KeyboardEventListenerNull.hpp" #include "VertexBuffer.h" #include "RenderBufferFactory.h" #include "RenderBufferFactoryNull.hpp" #include "Texture.h" #include "Shader.h" #include "ShaderVariable.h" #include "ShaderVariableNull.hpp" #include "EffectShaderCallBack.h" #include "EffectShaderAnnotation.h" #include "EffectShaderVariable.h" #include "EffectShaderVariableBlock.h" #include "EffectShaderVariableBlockCallBack.h" #include "EffectShader.h" #include "EffectShaderFeeder.h" #include "EffectShaderFeederNull.hpp" #include "EffectShaderCameraFeeder.h" #include "EffectShaderShadowMapFeeder.h" #include "RenderTargetChain.h" #include "RenderState_Alpha.h" #include "RenderState_AlphaNull.hpp" #include "RenderState_ZBuffer.h" #include "RenderState_ZBufferNull.hpp" #include "RenderState_Wireframe.h" #include "RenderState_WireframeNull.hpp" #include "RenderState_Cull.h" #include "RenderState_CullNull.hpp" #include "RenderState.h" #include "RenderStateNull.hpp" #include "RenderEventListener.h" #include "RenderEventListenerNull.hpp" #include "Render.h" #include "RenderNull.hpp" #include "Scene.h" #include "Base.h" #include "BaseNull.hpp" #include "Node.h" #include "NodeNull.hpp" #include "Camera.h" #include "CameraMatrix.h" #include "ColladaFactory.h" #include "NodeFactory.h" #include "GeometryFactory.h" #include "Instance.h" #include "InstanceResolver.h" #include "Geometry.h" #include "GeometryMesh.h" #include "GeometryMeshPrimitive.h" #include "CameraCommon.h" #include "CameraFactory.h" #include "CameraPerspective.h" #include "CameraOrthographic.h"
[ "wrice127@af801a76-7f76-11de-8b9f-9be6f49bd635" ]
[ [ [ 1, 177 ] ] ]
c03da37f219768e0e83aab615eaea939df235ba0
f89e32cc183d64db5fc4eb17c47644a15c99e104
/pcsx2-rr/pcsx2/x86/microVU_Analyze.inl
81e2d07764ae556b6217a80cd5d81e655fcc15e0
[]
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
16,479
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 //------------------------------------------------------------------ // Micro VU - Pass 1 Functions //------------------------------------------------------------------ //------------------------------------------------------------------ // Helper Macros //------------------------------------------------------------------ #define aReg(x) mVUregs.VF[x] #define bReg(x, y) mVUregsTemp.VFreg[y] = x; mVUregsTemp.VF[y] #define aMax(x, y) ((x > y) ? x : y) #define aMin(x, y) ((x < y) ? x : y) // Read a VF reg #define analyzeReg1(xReg, vfRead) { \ if (xReg) { \ if (_X) { mVUstall = aMax(mVUstall, aReg(xReg).x); vfRead.reg = xReg; vfRead.x = 1; } \ if (_Y) { mVUstall = aMax(mVUstall, aReg(xReg).y); vfRead.reg = xReg; vfRead.y = 1; } \ if (_Z) { mVUstall = aMax(mVUstall, aReg(xReg).z); vfRead.reg = xReg; vfRead.z = 1; } \ if (_W) { mVUstall = aMax(mVUstall, aReg(xReg).w); vfRead.reg = xReg; vfRead.w = 1; } \ } \ } // Write to a VF reg #define analyzeReg2(xReg, vfWrite, isLowOp) { \ if (xReg) { \ if (_X) { bReg(xReg, isLowOp).x = 4; vfWrite.reg = xReg; vfWrite.x = 4; } \ if (_Y) { bReg(xReg, isLowOp).y = 4; vfWrite.reg = xReg; vfWrite.y = 4; } \ if (_Z) { bReg(xReg, isLowOp).z = 4; vfWrite.reg = xReg; vfWrite.z = 4; } \ if (_W) { bReg(xReg, isLowOp).w = 4; vfWrite.reg = xReg; vfWrite.w = 4; } \ } \ } // Read a VF reg (BC opcodes) #define analyzeReg3(xReg, vfRead) { \ if (xReg) { \ if (_bc_x) { mVUstall = aMax(mVUstall, aReg(xReg).x); vfRead.reg = xReg; vfRead.x = 1; } \ else if (_bc_y) { mVUstall = aMax(mVUstall, aReg(xReg).y); vfRead.reg = xReg; vfRead.y = 1; } \ else if (_bc_z) { mVUstall = aMax(mVUstall, aReg(xReg).z); vfRead.reg = xReg; vfRead.z = 1; } \ else { mVUstall = aMax(mVUstall, aReg(xReg).w); vfRead.reg = xReg; vfRead.w = 1; } \ } \ } // For Clip Opcode #define analyzeReg4(xReg, vfRead) { \ if (xReg) { \ mVUstall = aMax(mVUstall, aReg(xReg).w); \ vfRead.reg = xReg; vfRead.w = 1; \ } \ } // Read VF reg (FsF/FtF) #define analyzeReg5(xReg, fxf, vfRead) { \ if (xReg) { \ switch (fxf) { \ case 0: mVUstall = aMax(mVUstall, aReg(xReg).x); vfRead.reg = xReg; vfRead.x = 1; break; \ case 1: mVUstall = aMax(mVUstall, aReg(xReg).y); vfRead.reg = xReg; vfRead.y = 1; break; \ case 2: mVUstall = aMax(mVUstall, aReg(xReg).z); vfRead.reg = xReg; vfRead.z = 1; break; \ case 3: mVUstall = aMax(mVUstall, aReg(xReg).w); vfRead.reg = xReg; vfRead.w = 1; break; \ } \ } \ } // Flips xyzw stalls to yzwx (MR32 Opcode) #define analyzeReg6(xReg, vfRead) { \ if (xReg) { \ if (_X) { mVUstall = aMax(mVUstall, aReg(xReg).y); vfRead.reg = xReg; vfRead.y = 1; } \ if (_Y) { mVUstall = aMax(mVUstall, aReg(xReg).z); vfRead.reg = xReg; vfRead.z = 1; } \ if (_Z) { mVUstall = aMax(mVUstall, aReg(xReg).w); vfRead.reg = xReg; vfRead.w = 1; } \ if (_W) { mVUstall = aMax(mVUstall, aReg(xReg).x); vfRead.reg = xReg; vfRead.x = 1; } \ } \ } // Reading a VI reg #define analyzeVIreg1(xReg, viRead) { \ if (xReg) { \ mVUstall = aMax(mVUstall, mVUregs.VI[xReg]); \ viRead.reg = xReg; viRead.used = 1; \ } \ } // Writing to a VI reg #define analyzeVIreg2(xReg, viWrite, aCycles) { \ if (xReg) { \ mVUconstReg[xReg].isValid = 0; \ mVUregsTemp.VIreg = xReg; \ mVUregsTemp.VI = aCycles; \ viWrite.reg = xReg; \ viWrite.used = aCycles; \ } \ } #define analyzeQreg(x) { mVUregsTemp.q = x; mVUstall = aMax(mVUstall, mVUregs.q); } #define analyzePreg(x) { mVUregsTemp.p = x; mVUstall = aMax(mVUstall, ((mVUregs.p) ? (mVUregs.p - 1) : 0)); } #define analyzeRreg() { mVUregsTemp.r = 1; } #define analyzeXGkick1() { mVUstall = aMax(mVUstall, mVUregs.xgkick); } #define analyzeXGkick2(x) { mVUregsTemp.xgkick = x; } #define setConstReg(x, v) { if (x) { mVUconstReg[x].isValid = 1; mVUconstReg[x].regValue = v; } } //------------------------------------------------------------------ // FMAC1 - Normal FMAC Opcodes //------------------------------------------------------------------ __fi void mVUanalyzeFMAC1(mV, int Fd, int Fs, int Ft) { sFLAG.doFlag = 1; analyzeReg1(Fs, mVUup.VF_read[0]); analyzeReg1(Ft, mVUup.VF_read[1]); analyzeReg2(Fd, mVUup.VF_write, 0); } //------------------------------------------------------------------ // FMAC2 - ABS/FTOI/ITOF Opcodes //------------------------------------------------------------------ __fi void mVUanalyzeFMAC2(mV, int Fs, int Ft) { analyzeReg1(Fs, mVUup.VF_read[0]); analyzeReg2(Ft, mVUup.VF_write, 0); } //------------------------------------------------------------------ // FMAC3 - BC(xyzw) FMAC Opcodes //------------------------------------------------------------------ __fi void mVUanalyzeFMAC3(mV, int Fd, int Fs, int Ft) { sFLAG.doFlag = 1; analyzeReg1(Fs, mVUup.VF_read[0]); analyzeReg3(Ft, mVUup.VF_read[1]); analyzeReg2(Fd, mVUup.VF_write, 0); } //------------------------------------------------------------------ // FMAC4 - Clip FMAC Opcode //------------------------------------------------------------------ __fi void mVUanalyzeFMAC4(mV, int Fs, int Ft) { cFLAG.doFlag = 1; analyzeReg1(Fs, mVUup.VF_read[0]); analyzeReg4(Ft, mVUup.VF_read[1]); } //------------------------------------------------------------------ // IALU - IALU Opcodes //------------------------------------------------------------------ __fi void mVUanalyzeIALU1(mV, int Id, int Is, int It) { if (!Id) { mVUlow.isNOP = 1; } analyzeVIreg1(Is, mVUlow.VI_read[0]); analyzeVIreg1(It, mVUlow.VI_read[1]); analyzeVIreg2(Id, mVUlow.VI_write, 1); } __fi void mVUanalyzeIALU2(mV, int Is, int It) { if (!It) { mVUlow.isNOP = 1; } analyzeVIreg1(Is, mVUlow.VI_read[0]); analyzeVIreg2(It, mVUlow.VI_write, 1); } __fi void mVUanalyzeIADDI(mV, int Is, int It, s16 imm) { mVUanalyzeIALU2(mVU, Is, It); if (!Is) { setConstReg(It, imm); } } //------------------------------------------------------------------ // MR32 - MR32 Opcode //------------------------------------------------------------------ __fi void mVUanalyzeMR32(mV, int Fs, int Ft) { if (!Ft) { mVUlow.isNOP = 1; } analyzeReg6(Fs, mVUlow.VF_read[0]); analyzeReg2(Ft, mVUlow.VF_write, 1); } //------------------------------------------------------------------ // FDIV - DIV/SQRT/RSQRT Opcodes //------------------------------------------------------------------ __fi void mVUanalyzeFDIV(mV, int Fs, int Fsf, int Ft, int Ftf, u8 xCycles) { analyzeReg5(Fs, Fsf, mVUlow.VF_read[0]); analyzeReg5(Ft, Ftf, mVUlow.VF_read[1]); analyzeQreg(xCycles); } //------------------------------------------------------------------ // EFU - EFU Opcodes //------------------------------------------------------------------ __fi void mVUanalyzeEFU1(mV, int Fs, int Fsf, u8 xCycles) { analyzeReg5(Fs, Fsf, mVUlow.VF_read[0]); analyzePreg(xCycles); } __fi void mVUanalyzeEFU2(mV, int Fs, u8 xCycles) { analyzeReg1(Fs, mVUlow.VF_read[0]); analyzePreg(xCycles); } //------------------------------------------------------------------ // MFP - MFP Opcode //------------------------------------------------------------------ __fi void mVUanalyzeMFP(mV, int Ft) { if (!Ft) { mVUlow.isNOP = 1; } analyzeReg2(Ft, mVUlow.VF_write, 1); } //------------------------------------------------------------------ // MOVE - MOVE Opcode //------------------------------------------------------------------ __fi void mVUanalyzeMOVE(mV, int Fs, int Ft) { if (!Ft || (Ft == Fs)) { mVUlow.isNOP = 1; } analyzeReg1(Fs, mVUlow.VF_read[0]); analyzeReg2(Ft, mVUlow.VF_write, 1); } //------------------------------------------------------------------ // LQx - LQ/LQD/LQI Opcodes //------------------------------------------------------------------ __fi void mVUanalyzeLQ(mV, int Ft, int Is, bool writeIs) { analyzeVIreg1(Is, mVUlow.VI_read[0]); analyzeReg2 (Ft, mVUlow.VF_write, 1); if (!Ft) { if (writeIs && Is) { mVUlow.noWriteVF = 1; } else { mVUlow.isNOP = 1; } } if (writeIs) { analyzeVIreg2(Is, mVUlow.VI_write, 1); } } //------------------------------------------------------------------ // SQx - SQ/SQD/SQI Opcodes //------------------------------------------------------------------ __fi void mVUanalyzeSQ(mV, int Fs, int It, bool writeIt) { analyzeReg1 (Fs, mVUlow.VF_read[0]); analyzeVIreg1(It, mVUlow.VI_read[0]); if (writeIt) { analyzeVIreg2(It, mVUlow.VI_write, 1); } } //------------------------------------------------------------------ // R*** - R Reg Opcodes //------------------------------------------------------------------ __fi void mVUanalyzeR1(mV, int Fs, int Fsf) { analyzeReg5(Fs, Fsf, mVUlow.VF_read[0]); analyzeRreg(); } __fi void mVUanalyzeR2(mV, int Ft, bool canBeNOP) { if (!Ft) { if (canBeNOP) { mVUlow.isNOP = 1; } else { mVUlow.noWriteVF = 1; } } analyzeReg2(Ft, mVUlow.VF_write, 1); analyzeRreg(); } //------------------------------------------------------------------ // Sflag - Status Flag Opcodes //------------------------------------------------------------------ __ri void flagSet(mV, bool setMacFlag) { int curPC = iPC; for (int i = mVUcount, j = 0; i > 0; i--, j++) { j += mVUstall; incPC2(-2); if (sFLAG.doFlag && (j >= 3)) { if (setMacFlag) { mFLAG.doFlag = 1; } else { sFLAG.doNonSticky = 1; } break; } } iPC = curPC; } __ri void mVUanalyzeSflag(mV, int It) { mVUlow.readFlags = 1; analyzeVIreg2(It, mVUlow.VI_write, 1); if (!It) { mVUlow.isNOP = 1; } else { mVUsFlagHack = 0; // Don't Optimize Out Status Flags for this block mVUinfo.swapOps = 1; flagSet(mVU, 0); if (mVUcount < 4) { mVUpBlock->pState.needExactMatch |= 1; } } } __ri void mVUanalyzeFSSET(mV) { mVUlow.isFSSET = 1; mVUlow.readFlags = 1; } //------------------------------------------------------------------ // Mflag - Mac Flag Opcodes //------------------------------------------------------------------ __ri void mVUanalyzeMflag(mV, int Is, int It) { mVUlow.readFlags = 1; analyzeVIreg1(Is, mVUlow.VI_read[0]); analyzeVIreg2(It, mVUlow.VI_write, 1); if (!It) { mVUlow.isNOP = 1; } else { mVUinfo.swapOps = 1; flagSet(mVU, 1); if (mVUcount < 4) { mVUpBlock->pState.needExactMatch |= 2; } } } //------------------------------------------------------------------ // Cflag - Clip Flag Opcodes //------------------------------------------------------------------ __fi void mVUanalyzeCflag(mV, int It) { mVUinfo.swapOps = 1; mVUlow.readFlags = 1; if (mVUcount < 4) { mVUpBlock->pState.needExactMatch |= 4; } analyzeVIreg2(It, mVUlow.VI_write, 1); } //------------------------------------------------------------------ // XGkick //------------------------------------------------------------------ __fi void mVUanalyzeXGkick(mV, int Fs, int xCycles) { analyzeVIreg1(Fs, mVUlow.VI_read[0]); analyzeXGkick1(); analyzeXGkick2(xCycles); // Note: Technically XGKICK should stall on the next instruction, // this code stalls on the same instruction. The only case where this // will be a problem with, is if you have very-specifically placed // FMxxx or FSxxx opcodes checking flags near this instruction AND // the XGKICK instruction stalls. No-game should be effected by // this minor difference. } //------------------------------------------------------------------ // Branches - Branch Opcodes //------------------------------------------------------------------ static void analyzeBranchVI(mV, int xReg, bool &infoVar) { if (!xReg) return; int i, j = 0; int iEnd = 4; int bPC = iPC; incPC2(-2); for (i = 0; i < iEnd; i++) { if (i == mVUcount) { bool warn = 0; if (i == 1) warn = 1; if (mVUpBlock->pState.viBackUp == xReg) { if (i == 0) warn = 1; infoVar = 1; j = i; i++; } if (warn) DevCon.Warning("microVU%d: Warning Branch VI-Delay with small block (%d) [%04x]", getIndex, i, xPC); break; // if (warn), we don't have enough information to always guarantee the correct result. } if ((mVUlow.VI_write.reg == xReg) && mVUlow.VI_write.used) { if (mVUlow.readFlags) { if (i) DevCon.Warning("microVU%d: Warning Branch VI-Delay with Read Flags Set (%d) [%04x]", getIndex, i, xPC); break; // Not sure if on the above "if (i)" case, if we need to "continue" or if we should "break" } j = i; } elif (i == 0) break; incPC2(-2); } if (i) { if (!infoVar) { iPC = bPC; incPC2(-2*(j+1)); mVUlow.backupVI = 1; infoVar = 1; } iPC = bPC; Console.WriteLn(Color_Green, "microVU%d: Branch VI-Delay (%d) [%04x]", getIndex, j+1, xPC); } else iPC = bPC; } /* // Dead Code... the old version of analyzeBranchVI() __fi void analyzeBranchVI(mV, int xReg, bool &infoVar) { if (!xReg) return; int i; int iEnd = aMin(5, (mVUcount+1)); int bPC = iPC; incPC2(-2); for (i = 0; i < iEnd; i++) { if ((i == mVUcount) && (i < 5)) { if (mVUpBlock->pState.viBackUp == xReg) { infoVar = 1; i++; } break; } if ((mVUlow.VI_write.reg == xReg) && mVUlow.VI_write.used) { if (mVUlow.readFlags || i == 5) break; if (i == 0) { incPC2(-2); continue; } if (((mVUlow.VI_read[0].reg == xReg) && (mVUlow.VI_read[0].used)) || ((mVUlow.VI_read[1].reg == xReg) && (mVUlow.VI_read[1].used))) { incPC2(-2); continue; } } break; } if (i) { if (!infoVar) { incPC2(2); mVUlow.backupVI = 1; infoVar = 1; } iPC = bPC; Console.WriteLn( Color_Green, "microVU%d: Branch VI-Delay (%d) [%04x]", getIndex, i, xPC); } else iPC = bPC; } */ // Branch in Branch Delay-Slots __ri int mVUbranchCheck(mV) { if (!mVUcount) return 0; incPC(-2); if (mVUlow.branch) { mVUlow.badBranch = 1; incPC(2); mVUlow.evilBranch = 1; mVUregs.blockType = 2; mVUregs.needExactMatch |= 7; // This might not be necessary, but w/e... Console.Warning("microVU%d Warning: Branch in Branch delay slot! [%04x]", mVU->index, xPC); return 1; } incPC(2); return 0; } __fi void mVUanalyzeCondBranch1(mV, int Is) { analyzeVIreg1(Is, mVUlow.VI_read[0]); if (!mVUstall && !mVUbranchCheck(mVU)) { analyzeBranchVI(mVU, Is, mVUlow.memReadIs); } } __fi void mVUanalyzeCondBranch2(mV, int Is, int It) { analyzeVIreg1(Is, mVUlow.VI_read[0]); analyzeVIreg1(It, mVUlow.VI_read[1]); if (!mVUstall && !mVUbranchCheck(mVU)) { analyzeBranchVI(mVU, Is, mVUlow.memReadIs); analyzeBranchVI(mVU, It, mVUlow.memReadIt); } } __fi void mVUanalyzeNormBranch(mV, int It, bool isBAL) { mVUbranchCheck(mVU); if (isBAL) { analyzeVIreg2(It, mVUlow.VI_write, 1); setConstReg(It, bSaveAddr); } } __ri void mVUanalyzeJump(mV, int Is, int It, bool isJALR) { mVUbranchCheck(mVU); mVUlow.branch = (isJALR) ? 10 : 9; if (mVUconstReg[Is].isValid && doConstProp) { mVUlow.constJump.isValid = 1; mVUlow.constJump.regValue = mVUconstReg[Is].regValue; //DevCon.Status("microVU%d: Constant JR/JALR Address Optimization", mVU->index); } analyzeVIreg1(Is, mVUlow.VI_read[0]); if (isJALR) { analyzeVIreg2(It, mVUlow.VI_write, 1); setConstReg(It, bSaveAddr); } }
[ "koeiprogenitor@bfa1b011-20a7-a6e3-c617-88e5d26e11c5" ]
[ [ [ 1, 483 ] ] ]
85632f6c61b21271ad007b4db4a3aeeed567acf3
33cdd09e352529963fe8b28b04e0d2e33483777b
/trunk/ReportAsistent/AttributeLinkDialogBase.h
759fe3adef1a761ad19e92a2df6f8e4eca9ffc77
[]
no_license
BackupTheBerlios/reportasistent-svn
20e386c86b6990abafb679eeb9205f2aef1af1ac
209650c8cbb0c72a6e8489b0346327374356b57c
refs/heads/master
2020-06-04T16:28:21.972009
2010-05-18T12:06:48
2010-05-18T12:06:48
40,804,982
0
0
null
null
null
null
UTF-8
C++
false
false
2,115
h
// AttributeLinkDialogBase.h: interface for the CAttributeLinkDialogBase class. // ////////////////////////////////////////////////////////////////////// /* This file is part of LM Report Asistent. Authors: Jan Dedek, Jan Kodym, Martin Chrz, Iva Bartunkova LM Report Asistent 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. LM Report Asistent 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 LM Report Asistent; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #if !defined(AFX_ATTRIBUTELINKDIALOGBASE_H__715B070E_2493_4E4D_8E5F_AF11FB8EF94F__INCLUDED_) #define AFX_ATTRIBUTELINKDIALOGBASE_H__715B070E_2493_4E4D_8E5F_AF11FB8EF94F__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #define ATTRLIST_CL_NAME 0 #define ATTRLIST_CL_VALUE 1 /** * class CAttributeLinkDialogBase: Base class for dialogs of Attribute Link and Attribute Link Table static elements. * * @author */ class CAttributeLinkDialogBase { protected: MSXML2::IXMLDOMElementPtr & m_SelXMLElm; public: CAttributeLinkDialogBase(MSXML2::IXMLDOMElementPtr & edited_element); // standard constructor protected: void SaveTarget(CComboBox & target_combo); void OnRefresh(CListCtrl & AttributesList, LPCTSTR target_id); void FillAttributesList(CListCtrl & AttributesList, LPCTSTR target_id); void InitAttributesList(CListCtrl & AttributesList); void FillTargets(CComboBox & TargetCombo); void InitBaseDialog(CListCtrl & AttributesList, CComboBox & TargetCombo); }; #endif // !defined(AFX_ATTRIBUTELINKDIALOGBASE_H__715B070E_2493_4E4D_8E5F_AF11FB8EF94F__INCLUDED_)
[ "dedej1am@fded5620-0c03-0410-a24c-85322fa64ba0", "chrzm@fded5620-0c03-0410-a24c-85322fa64ba0", "ibart@fded5620-0c03-0410-a24c-85322fa64ba0" ]
[ [ [ 1, 3 ], [ 6, 6 ], [ 23, 33 ], [ 39, 41 ], [ 43, 56 ] ], [ [ 4, 5 ], [ 7, 22 ], [ 34, 34 ], [ 36, 38 ] ], [ [ 35, 35 ], [ 42, 42 ] ] ]
5258e3878fef56d075abe74d6f88630677f0cf0a
724cded0e31f5fd52296d516b4c3d496f930fd19
/inc/jrtp/rtpsession.h
a56bf92c0a5203f678e800ef575f97dedb2c9025
[]
no_license
yubik9/p2pcenter
0c85a38f2b3052adf90b113b2b8b5b312fefcb0a
fc4119f29625b1b1f4559ffbe81563e6fcd2b4ea
refs/heads/master
2021-08-27T15:40:05.663872
2009-02-19T00:13:33
2009-02-19T00:13:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,075
h
/* This file is a part of JRTPLIB Copyright (c) 1999-2006 Jori Liesenborgs Contact: [email protected] This library was developed at the "Expertisecentrum Digitale Media" (http://www.edm.uhasselt.be), a research center of the Hasselt University (http://www.uhasselt.be). The library is based upon work done for my thesis at the School for Knowledge Technology (Belgium/The Netherlands). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef RTPSESSION_H #define RTPSESSION_H #include "rtpconfig.h" #include "rtplibraryversion.h" #include "rtppacketbuilder.h" #include "rtpsessionsources.h" #include "rtptransmitter.h" #include "rtpcollisionlist.h" #include "rtcpscheduler.h" #include "rtcppacketbuilder.h" #include "rtptimeutilities.h" #include <list> #ifdef RTP_SUPPORT_THREAD #include "jmutex.h" #endif // RTP_SUPPORT_THREAD class RTPTransmitter; class RTPSessionParams; class RTPTransmissionParams; class RTPAddress; class RTPSourceData; class RTPPacket; class RTPPollThread; class RTPTransmissionInfo; class RTCPCompoundPacket; class RTCPPacket; class RTCPAPPPacket; class RTPSession { public: RTPSession(RTPTransmitter::TransmissionProtocol proto = RTPTransmitter::IPv4UDPProto); virtual ~RTPSession(); int Create(const RTPSessionParams &sessparams,const RTPTransmissionParams *transparams = 0); void Destroy(); void BYEDestroy(const RTPTime &maxwaittime,const void *reason,size_t reasonlength); bool IsActive(); uint32_t GetLocalSSRC(); int AddDestination(const RTPAddress &addr); int DeleteDestination(const RTPAddress &addr); void ClearDestinations(); bool SupportsMulticasting(); int JoinMulticastGroup(const RTPAddress &addr); int LeaveMulticastGroup(const RTPAddress &addr); void LeaveAllMulticastGroups(); int SendPacket(const void *data,size_t len); int SendPacket(const void *data,size_t len, uint8_t pt,bool mark,uint32_t timestampinc); int SendPacketEx(const void *data,size_t len, uint16_t hdrextID,const void *hdrextdata,size_t numhdrextwords); int SendPacketEx(const void *data,size_t len, uint8_t pt,bool mark,uint32_t timestampinc, uint16_t hdrextID,const void *hdrextdata,size_t numhdrextwords); int SetDefaultPayloadType(uint8_t pt); int SetDefaultMark(bool m); int SetDefaultTimestampIncrement(uint32_t timestampinc); int IncrementTimestamp(uint32_t inc); int IncrementTimestampDefault(); int SetPreTransmissionDelay(const RTPTime &delay); RTPTransmissionInfo *GetTransmissionInfo(); int Poll(); int WaitForIncomingData(const RTPTime &delay,bool *dataavailable = 0); int AbortWait(); RTPTime GetRTCPDelay(); // The following methods (GotoFirstSource till GetNextPacket) should // be called between calls to BeginDataAccess end EndDataAccess. This // makes sure that nasty things don't happen (e.g. when a background // thread is polling for data) int BeginDataAccess(); bool GotoFirstSource(); bool GotoNextSource(); bool GotoPreviousSource(); bool GotoFirstSourceWithData(); bool GotoNextSourceWithData(); bool GotoPreviousSourceWithData(); RTPSourceData *GetCurrentSourceInfo(); RTPSourceData *GetSourceInfo(uint32_t ssrc); RTPPacket *GetNextPacket(); int EndDataAccess(); int SetReceiveMode(RTPTransmitter::ReceiveMode m); int AddToIgnoreList(const RTPAddress &addr); int DeleteFromIgnoreList(const RTPAddress &addr); void ClearIgnoreList(); int AddToAcceptList(const RTPAddress &addr); int DeleteFromAcceptList(const RTPAddress &addr); void ClearAcceptList(); int SetMaximumPacketSize(size_t s); int SetSessionBandwidth(double bw); int SetTimestampUnit(double u); void SetNameInterval(int count); void SetEMailInterval(int count); void SetLocationInterval(int count); void SetPhoneInterval(int count); void SetToolInterval(int count); void SetNoteInterval(int count); int SetLocalName(const void *s,size_t len); int SetLocalEMail(const void *s,size_t len); int SetLocalLocation(const void *s,size_t len); int SetLocalPhone(const void *s,size_t len); int SetLocalTool(const void *s,size_t len); int SetLocalNote(const void *s,size_t len); #ifdef RTPDEBUG void DumpSources(); void DumpTransmitter(); #endif // RTPDEBUG protected: virtual RTPTransmitter *NewUserDefinedTransmitter() { return 0; } virtual void OnRTPPacket(RTPPacket *pack,const RTPTime &receivetime, const RTPAddress *senderaddress) { } virtual void OnRTCPCompoundPacket(RTCPCompoundPacket *pack,const RTPTime &receivetime, const RTPAddress *senderaddress) { } virtual void OnSSRCCollision(RTPSourceData *srcdat,const RTPAddress *senderaddress,bool isrtp) { } virtual void OnCNAMECollision(RTPSourceData *srcdat,const RTPAddress *senderaddress, const uint8_t *cname,size_t cnamelength) { } virtual void OnNewSource(RTPSourceData *srcdat) { } virtual void OnRemoveSource(RTPSourceData *srcdat) { } virtual void OnTimeout(RTPSourceData *srcdat) { } virtual void OnBYETimeout(RTPSourceData *srcdat) { } virtual void OnAPPPacket(RTCPAPPPacket *apppacket,const RTPTime &receivetime, const RTPAddress *senderaddress) { } virtual void OnUnknownPacketType(RTCPPacket *rtcppack,const RTPTime &receivetime, const RTPAddress *senderaddress) { } virtual void OnUnknownPacketFormat(RTCPPacket *rtcppack,const RTPTime &receivetime, const RTPAddress *senderaddress) { } virtual void OnNoteTimeout(RTPSourceData *srcdat) { } virtual void OnBYEPacket(RTPSourceData *srcdat) { } #ifdef RTP_SUPPORT_THREAD virtual void OnPollThreadError(int errcode) { } virtual void OnPollThreadStep() { } #endif // RTP_SUPPORT_THREAD private: int CreateCNAME(uint8_t *buffer,size_t *bufferlength,bool resolve); int ProcessPolledData(); int ProcessRTCPCompoundPacket(RTCPCompoundPacket &rtcpcomppack,RTPRawPacket *pack); RTPTransmitter *rtptrans; const RTPTransmitter::TransmissionProtocol protocol; bool created; bool usingpollthread; bool acceptownpackets; bool useSR_BYEifpossible; size_t maxpacksize; double sessionbandwidth; double controlfragment; double sendermultiplier; double byemultiplier; double membermultiplier; double collisionmultiplier; double notemultiplier; RTPSessionSources sources; RTPPacketBuilder packetbuilder; RTCPScheduler rtcpsched; RTCPPacketBuilder rtcpbuilder; RTPCollisionList collisionlist; std::list<RTCPCompoundPacket *> byepackets; #ifdef RTP_SUPPORT_THREAD RTPPollThread *pollthread; JMutex sourcesmutex,buildermutex,schedmutex; friend class RTPPollThread; #endif // RTP_SUPPORT_THREAD friend class RTPSessionSources; }; #endif // RTPSESSION_H
[ "fuwenke@b5bb1052-fe17-11dd-bc25-5f29055a2a2d" ]
[ [ [ 1, 216 ] ] ]
e4125eca04dfb39a778e1b05b2feb1f16682d960
18abe58b8685c7e45f73fa20cd5cbb52b2b7a698
/Applications/Legacy/gcolon/curvature.cc
5eeaa8505c9937172e9cf5d5f95fdafed45b0d04
[ "BSD-3-Clause" ]
permissive
clwyatt/CTC
011fd56eeb7a9744505324a8d78cfab93aad8867
284d52dc888bcd997214804715fe690149e33f85
refs/heads/master
2021-01-23T07:21:21.294533
2009-04-07T10:11:48
2009-04-07T10:11:48
8,322,828
1
0
null
null
null
null
UTF-8
C++
false
false
5,507
cc
// File: curvature.cc // Abstract: determine curvature of surface points on binary volume // // ref. Tracing Surfaces for Surfacing Traces // Sander & Zucker // // ref. Surface Parameterization and Curvature Measurement // of Arbitrary 3-D Objects: Five Pratical Methods // Stokely and Wu, PAMI vol. 14, 1992 // // Created: 02/24/98 by: Chris L. Wyatt // Modified: 07/28/98 for use in seed_locator.cc // // #include "curvature.h" surface_point * curvature(bframe3d * data, int * surface_length) { surface_point * surf_top; surface_point * current; surface_point * temp; int xdim, ydim, zdim; int i, j, k, x1, x2, y1, y2, z1, z2; double Ax, Ay, Az, dx, dy, dz; double sum11, sum12, sum13, sum22, sum23, sum33; double a, b, c; point ip, p; // p1, p2, p3; point neighbors[100]; int numn, sp; float **ATA, **ATAInv; *surface_length = 0; data->querydim(&xdim, &ydim, &zdim); surf_top = NULL; current = surf_top; //loop through adding to list of points //cheat a little and don't check edges for(i = 1; i < (xdim-1); i++) for(j = 1; j < (ydim-1); j++) for(k = 1; k < (zdim-1); k++) { if( is_on_surface(data, i, j, k) == 1 ) { temp = gradient(data, i, j, k); if(surf_top == NULL){ surf_top = temp; current = surf_top;} else{ current->next = temp; current = temp; } *surface_length += 1; } } fprintf(stderr, "%i surface points found.\n", *surface_length); current = surf_top; for(sp = 0; sp < *surface_length; sp++){ x2 = current->x; y2 = current->y; z2 = current->z; //fprintf(stderr, "Center point: (%i,%i,%i)\n", x2, y2, z2); Ax = gxangle(current); Ay = gyangle(current); Az = gzangle(current); //fprintf(stderr, "Rotation:\nRx=%f \nRy=%f \nRz=%f\n\n", Ax, Ay, Az); numn = 0; for(i=-2; i < 3; i++) for(j=-2; j < 3; j++) for(k=-2; k < 3; k++) { x1 = x2+i; y1 = y2+j; z1 = z2+k; if(is_on_surface(data, x1, y1, z1) == TRUE) { ip.x = (double)(x2) - (double)(x1); ip.y = (double)(y2) - (double)(y1); ip.z = (double)(z2) - (double)(z1); //p1 = Rz(ip, Az); //p2 = Ry(p1, Ay); //p3 = Rx(p2, Ax); p = Rx(Ry(Rz(ip, Az), Ay), Ax); neighbors[numn] = p; numn +=1; //fprintf(stderr, "Origional point %i: (%i,%i,%i)\n", numn, x1, y1, z1); //fprintf(stderr, "Rz: (%f,%f,%f)\n", p1.x, p1.y, p1.z); //fprintf(stderr, "Ry: (%f,%f,%f)\n", p2.x, p2.y, p2.z); //fprintf(stderr, "Rx: (%f,%f,%f)\n", p3.x, p3.y, p3.z); //fprintf(stderr, "New Point %i: (%f, %f, %f)\n", numn, p.x, p.y, p.z); } } numn -= 1; ATA = matrix(1, 3, 1, 3); ATAInv = matrix(1, 3, 1, 3); sum11 = 0; sum12 = 0; sum13 = 0; sum22 = 0; sum23 = 0; sum33 = 0; for (i=0; i<numn; i++){ dx = neighbors[i].x; dy = neighbors[i].y; sum11 += dx*dx*dx*dx; sum12 += dx*dx*2*dx*dy; sum13 += dx*dx*dy*dy; sum22 += 2*dx*dy*2*dx*dy; sum23 += 2*dx*dy*dy*dy; sum33 += dy*dy*dy*dy; } ATA[1][1] = sum11; ATA[1][2] = sum12; ATA[1][3] = sum13; ATA[2][1] = sum12; ATA[2][2] = sum22; ATA[2][3] = sum23; ATA[3][1] = sum13; ATA[3][2] = sum23; ATA[3][3] = sum33; invertMatrixSVD(ATA, ATAInv, 3); sum11 = sum12 = sum13 = 0; for (i=0; i<numn; i++){ dx = neighbors[i].x; dy = neighbors[i].y; dz = neighbors[i].z; sum11 += dx*dx*dz; sum12 += 2*dx*dy*dz; sum13 += dy*dy*dz; } a = ATAInv[1][1]*sum11 + ATAInv[1][2]*sum12 + ATAInv[1][3]*sum13; b = ATAInv[2][1]*sum11 + ATAInv[2][2]*sum12 + ATAInv[2][3]*sum13; c = ATAInv[3][1]*sum11 + ATAInv[3][2]*sum12 + ATAInv[3][3]*sum13; current->K = 4*(a*c - b*b); current->H = a + c; //fprintf(stderr, "K = %f, ", current->K); //fprintf(stderr, "H = %f\n", current->H); free_matrix(ATA, 1, 3, 1, 3); free_matrix(ATAInv, 1, 3, 1, 3); current = current->next; } return surf_top; } int is_on_surface(bframe3d * data, int x, int y, int z) { int flg = 0; if(data->getpixel(x, y, z) == TRUE){ if( (data->getpixel(x+1, y, z) != TRUE) || (data->getpixel(x-1, y, z) != TRUE) || (data->getpixel(x, y+1, z) != TRUE) || (data->getpixel(x, y-1, z) != TRUE) || (data->getpixel(x, y, z+1) != TRUE) || (data->getpixel(x, y, z-1) != TRUE) ) { flg = 1; } } return flg; } double gxangle(surface_point * p) { double Ax; Ax = atan2(p->gz, p->gy); return Ax; } double gyangle(surface_point * p) { double Ay; Ay = atan2(p->gx, p->gz); return Ay; } double gzangle(surface_point * p) { double Az; Az = atan2(p->gy, p->gx); return Az; } // void write_curvature(surface_point * surf, int surface_length, int volsize) // { // surface_point * current; // float *H, *K; // int i; // H = new float[volsize]; // k = new float[volsize]; // for(i=0; i < volsize; i++) // { // *(H + i) = 0; // *(K + i) = 0; // } // current = surf; // for(i=0; i < surface_length; i++) // { // } // }
[ [ [ 1, 231 ] ] ]
130bc565eb7e18936308c0c07177e79d10ad60bc
942b88e59417352fbbb1a37d266fdb3f0f839d27
/src/WIN32/windowui.cxx
2dfe5734c986141955e0ef3f4cf2f3b470bf1b4f
[ "BSD-2-Clause" ]
permissive
take-cheeze/ARGSS...
2c1595d924c24730cc714d017edb375cfdbae9ef
2f2830e8cc7e9c4a5f21f7649287cb6a4924573f
refs/heads/master
2016-09-05T15:27:26.319404
2010-12-13T09:07:24
2010-12-13T09:07:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
18,524
cxx
////////////////////////////////////////////////////////////////////////////////// /// ARGSS - Copyright (c) 2009 - 2010, Alejandro Marzini (vgvgf) /// 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. /// /// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''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 AUTHOR 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. ////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// /// Headers //////////////////////////////////////////////////////////// #include "windowui.hxx" #include "../output.hxx" #include "../window.hxx" //////////////////////////////////////////////////////////// /// Definitions //////////////////////////////////////////////////////////// #ifdef UNICODE #ifndef _T #define _T(x) L ## x #endif static std::basic_string< WCHAR > s2ws(const std::string& s) { int len; int slength = (int)s.length() + 1; len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0); WCHAR* buf = new WCHAR[len]; MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len); std::basic_string< WCHAR > r(buf); delete[] buf; return r; } #else #ifdef _T #undef _T #endif #define _T(x) x static std::string s2ws(const std::string& s) { return s; } #endif #ifndef WM_XBUTTONDOWN #define WM_XBUTTONDOWN 523 #endif #ifndef WM_XBUTTONUP #define WM_XBUTTONUP 524 #endif #ifndef XBUTTON1 #define XBUTTON1 1 #endif #ifndef XBUTTON2 #define XBUTTON2 2 #endif //////////////////////////////////////////////////////////// /// Event Process //////////////////////////////////////////////////////////// LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { WindowUi* window = (WindowUi*) GetWindowLongPtr(hWnd, GWLP_USERDATA); return (!window->ProccesEvents(hWnd, uMsg, wParam, lParam))? 0 : DefWindowProc(hWnd, uMsg, wParam, lParam); } //////////////////////////////////////////////////////////// /// Constructor //////////////////////////////////////////////////////////// WindowUi::WindowUi(long iwidth, long iheight, std::string title, bool center, bool fs_flag) { keys.resize(Input::Keys::KEYS_COUNT, false); mouse_focus = false; mouse_wheel = 0; mouse_x = 0; mouse_y = 0; width = iwidth; height = iheight; fullscreen = fs_flag; hinstance = ::GetModuleHandle(NULL); #ifdef UNICODE WNDCLASSEXW wc; #else WNDCLASSEXA wc; #endif wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.lpfnWndProc = (WNDPROC) WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hinstance; wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = _T("ARGSS Player"); wc.hIconSm = NULL; #ifdef UNICODE if (!RegisterClassExW(&wc)) { #else if (!RegisterClassExA(&wc)) { #endif Output::ErrorStr("Failed to register the window class."); } if (fullscreen) { DEVMODE dmScreenSettings; memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); dmScreenSettings.dmSize = sizeof(dmScreenSettings); dmScreenSettings.dmPelsWidth = width; dmScreenSettings.dmPelsHeight = height; dmScreenSettings.dmBitsPerPel = 32; dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { Output::WarningStr("Current fullscreen mode is not supported. Windowed mode will be used."); } } DWORD dwExStyle; DWORD dwStyle; if (fullscreen) { dwExStyle = WS_EX_APPWINDOW; dwStyle = WS_POPUP; ShowCursor(FALSE); } else { dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; dwStyle = WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME; } long posx = 0; long posy = 0; if (!fullscreen && center) { RECT scrrect; if (::SystemParametersInfo(SPI_GETWORKAREA, 0, &scrrect, SPIF_UPDATEINIFILE)) { int centerx = scrrect.right / 2; int centery = scrrect.bottom / 2; int edge = ::GetSystemMetrics(SM_CXEDGE); int capt = ::GetSystemMetrics(SM_CXFIXEDFRAME); posx = centerx - width / 2 - edge; posy = centery - height / 2 - capt; } } RECT windowRect = {posx, posy, posx + iwidth, posy + iheight}; ::AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle); hwnd = ::CreateWindowEx(dwExStyle, _T("ARGSS Player"), s2ws(title).c_str(), dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, NULL, NULL, hinstance, NULL); if (!hwnd) { Dispose(); Output::ErrorStr("Failed to create the window."); } PIXELFORMATDESCRIPTOR pfd; ZeroMemory(&pfd, sizeof(pfd)); pfd.nSize = sizeof(pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 32; pfd.cDepthBits = 16; pfd.iLayerType = PFD_MAIN_PLANE; if (!(hdc = ::GetDC(hwnd))){ Dispose(); Output::ErrorStr("Failed to create opengl device context."); } unsigned int PixelFormat; if (!(PixelFormat = ::ChoosePixelFormat(hdc, &pfd))) { Dispose(); Output::ErrorStr("Couldn't find a suitable pixel format."); } if (!::SetPixelFormat(hdc, PixelFormat, &pfd)) { Dispose(); Output::ErrorStr("Can't set the pixel format."); } if (!(hrc = wglCreateContext(hdc))) { Dispose(); Output::ErrorStr("Failed to create opengl rendering context."); } if (!wglMakeCurrent(hdc, hrc)) { Dispose(); Output::ErrorStr("Can't activate opengl rendering context."); } ::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)this); ::ShowWindow(hwnd, SW_SHOW); ::SetForegroundWindow(hwnd); ::SetFocus(hwnd); } //////////////////////////////////////////////////////////// /// Destructor //////////////////////////////////////////////////////////// WindowUi::~WindowUi() { } //////////////////////////////////////////////////////////// /// Swap Buffers //////////////////////////////////////////////////////////// void WindowUi::swapBuffers() { ::SwapBuffers(hdc); } //////////////////////////////////////////////////////////// /// Dispose //////////////////////////////////////////////////////////// void WindowUi::Dispose() { if (fullscreen) { ::ChangeDisplaySettings(NULL, 0); ::ShowCursor(true); } if (hrc) { wglMakeCurrent(NULL, NULL); wglDeleteContext(hrc); hrc = NULL; } if (hdc && !ReleaseDC(hwnd, hdc)) { hdc = NULL; } if (hwnd && !DestroyWindow(hwnd)) { hwnd = NULL; } if (!UnregisterClass(_T("ARGSS Player"), hinstance)) { hinstance = NULL; } } //////////////////////////////////////////////////////////// /// Resize //////////////////////////////////////////////////////////// void WindowUi::resize(long nwidth, long nheight) { if (width != nwidth && height != nheight) { width = nwidth; height = nheight; } } //////////////////////////////////////////////////////////// /// set title //////////////////////////////////////////////////////////// void WindowUi::setTitle(std::string title) { ::SetWindowText(hwnd, s2ws(title).c_str()); } //////////////////////////////////////////////////////////// /// Toggle fullscreen //////////////////////////////////////////////////////////// void WindowUi::toggleFullscreen() { if (fullscreen) { DEVMODE devmode; devmode.dmSize = sizeof(DEVMODE); devmode.dmPelsWidth = width; devmode.dmPelsHeight = height; devmode.dmBitsPerPel = 32; devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; if (::ChangeDisplaySettings(&devmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { Output::Warning("Failed to toggle fullscreen mode"); return; } ::SetWindowLong(hwnd, GWL_STYLE, WS_POPUP); ::SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW); ::SetWindowPos(hwnd, HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED); ::ShowWindow(hwnd, SW_SHOW); long Style = ::GetWindowLong(hwnd, GWL_STYLE); ::SetWindowLong(hwnd, GWL_STYLE, Style | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); fullscreen = true; } else { } } //////////////////////////////////////////////////////////// /// get Width //////////////////////////////////////////////////////////// long WindowUi::getWidth() { return width; } //////////////////////////////////////////////////////////// /// get Height //////////////////////////////////////////////////////////// long WindowUi::getHeight() { return height; } //////////////////////////////////////////////////////////// /// get Event //////////////////////////////////////////////////////////// bool WindowUi::popEvent(Event& evnt) { if (hwnd && events.empty()) { MSG Message; while (PeekMessage(&Message, hwnd, 0, 0, PM_REMOVE)) { TranslateMessage(&Message); DispatchMessage(&Message); } } if (!events.empty()) { evnt = events.front(); events.pop(); return true; } return false; } //////////////////////////////////////////////////////////// /// Process events //////////////////////////////////////////////////////////// int WindowUi::ProccesEvents(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { Event evnt; long param1; switch (uMsg) { case WM_ACTIVATE: if (HIWORD(wParam)) { evnt.type = Event::LostFocus; } else { evnt.type = Event::GainFocus; } events.push(evnt); return 0; case WM_SETFOCUS: evnt.type = Event::GainFocus; events.push(evnt); return 0; case WM_KILLFOCUS: evnt.type = Event::LostFocus; events.push(evnt); return 0; case WM_SYSCOMMAND: switch (wParam) { case SC_SCREENSAVE: case SC_MONITORPOWER: return 0; } break; case WM_CLOSE: evnt.type = Event::Quit; events.push(evnt); return 0; case WM_KEYDOWN: case WM_SYSKEYDOWN: evnt.type = Event::KeyDown; param1 = VK2IK(wParam); switch (param1) { case Input::Keys::LSHIFT: case Input::Keys::RSHIFT: evnt.param1 = Input::Keys::SHIFT; events.push(evnt); case Input::Keys::LCTRL: case Input::Keys::RCTRL: evnt.param1 = Input::Keys::CTRL; events.push(evnt); case Input::Keys::LALT: case Input::Keys::RALT: evnt.param1 = Input::Keys::ALT; events.push(evnt); } evnt.param1 = param1; events.push(evnt); keys[param1] = true; return 0; case WM_KEYUP: case WM_SYSKEYUP: evnt.type = Event::KeyUp; param1 = VK2IK(wParam); switch (param1) { case Input::Keys::LSHIFT: case Input::Keys::RSHIFT: evnt.param1 = Input::Keys::SHIFT; events.push(evnt); case Input::Keys::LCTRL: case Input::Keys::RCTRL: evnt.param1 = Input::Keys::CTRL; events.push(evnt); case Input::Keys::LALT: case Input::Keys::RALT: evnt.param1 = Input::Keys::ALT; events.push(evnt); } evnt.param1 = param1; events.push(evnt); keys[param1] = false; return 0; case WM_MOUSEWHEEL: mouse_wheel = GET_WHEEL_DELTA_WPARAM(wParam); return 0; case WM_LBUTTONDOWN: keys[Input::Keys::MOUSE_LEFT] = true; return 0; case WM_LBUTTONUP: keys[Input::Keys::MOUSE_LEFT] = false; return 0; case WM_RBUTTONDOWN: keys[Input::Keys::MOUSE_RIGHT] = true; return 0; case WM_RBUTTONUP: keys[Input::Keys::MOUSE_RIGHT] = false; return 0; case WM_MBUTTONDOWN: keys[Input::Keys::MOUSE_MIDDLE] = true; return 0; case WM_MBUTTONUP: keys[Input::Keys::MOUSE_MIDDLE] = false; return 0; case WM_XBUTTONDOWN: if (HIWORD(wParam) == XBUTTON1) { keys[Input::Keys::MOUSE_XBUTTON1] = true; } else { keys[Input::Keys::MOUSE_XBUTTON2] = true; } return 0; case WM_XBUTTONUP: if (HIWORD(wParam) == XBUTTON1) { keys[Input::Keys::MOUSE_XBUTTON1] = false; } else { keys[Input::Keys::MOUSE_XBUTTON2] = false; } return 0; case WM_MOUSEMOVE: mouse_focus = true; mouse_x = LOWORD(lParam); mouse_y = HIWORD(lParam); return 0; case WM_MOUSELEAVE: mouse_focus = false; return 0; } return 1; } //////////////////////////////////////////////////////////// /// Virtual Keys to InputKey //////////////////////////////////////////////////////////// Input::Keys::InputKey WindowUi::VK2IK(int vk) { switch(vk) { case VK_BACK : return Input::Keys::BACKSPACE; case VK_TAB : return Input::Keys::TAB; case VK_CLEAR : return Input::Keys::CLEAR; case VK_RETURN : return Input::Keys::RETURN; case VK_PAUSE : return Input::Keys::PAUSE; case VK_ESCAPE : return Input::Keys::ESCAPE; case VK_SPACE : return Input::Keys::SPACE; case VK_NEXT : return Input::Keys::PGUP; case VK_PRIOR : return Input::Keys::PGDN; case VK_END : return Input::Keys::ENDS; case VK_HOME : return Input::Keys::HOME; case VK_LEFT : return Input::Keys::LEFT; case VK_UP : return Input::Keys::UP; case VK_RIGHT : return Input::Keys::RIGHT; case VK_DOWN : return Input::Keys::DOWN; case VK_SNAPSHOT : return Input::Keys::SNAPSHOT; case VK_INSERT : return Input::Keys::INSERT; case VK_DELETE : return Input::Keys::DEL; case VK_SHIFT : return Input::Keys::SHIFT; case VK_LSHIFT : return Input::Keys::LSHIFT; case VK_RSHIFT : return Input::Keys::RSHIFT; case VK_CONTROL : return Input::Keys::CTRL; case VK_LCONTROL : return Input::Keys::LCTRL; case VK_RCONTROL : return Input::Keys::RCTRL; case VK_MENU : return Input::Keys::ALT; case VK_LMENU : return Input::Keys::LALT; case VK_RMENU : return Input::Keys::RALT; case '0' : return Input::Keys::N0; case '1' : return Input::Keys::N1; case '2' : return Input::Keys::N2; case '3' : return Input::Keys::N3; case '4' : return Input::Keys::N4; case '5' : return Input::Keys::N5; case '6' : return Input::Keys::N6; case '7' : return Input::Keys::N7; case '8' : return Input::Keys::N8; case '9' : return Input::Keys::N9; case 'A' : return Input::Keys::A; case 'B' : return Input::Keys::B; case 'C' : return Input::Keys::C; case 'D' : return Input::Keys::D; case 'E' : return Input::Keys::E; case 'F' : return Input::Keys::F; case 'G' : return Input::Keys::G; case 'H' : return Input::Keys::H; case 'I' : return Input::Keys::I; case 'J' : return Input::Keys::J; case 'K' : return Input::Keys::K; case 'L' : return Input::Keys::L; case 'M' : return Input::Keys::M; case 'N' : return Input::Keys::N; case 'O' : return Input::Keys::O; case 'P' : return Input::Keys::P; case 'Q' : return Input::Keys::Q; case 'R' : return Input::Keys::R; case 'S' : return Input::Keys::S; case 'T' : return Input::Keys::T; case 'U' : return Input::Keys::U; case 'V' : return Input::Keys::V; case 'W' : return Input::Keys::W; case 'X' : return Input::Keys::X; case 'Y' : return Input::Keys::Y; case 'Z' : return Input::Keys::Z; case VK_LWIN : return Input::Keys::LOS; case VK_RWIN : return Input::Keys::ROS; case VK_APPS : return Input::Keys::APPS; case VK_NUMPAD0 : return Input::Keys::KP0; case VK_NUMPAD1 : return Input::Keys::KP1; case VK_NUMPAD2 : return Input::Keys::KP2; case VK_NUMPAD3 : return Input::Keys::KP3; case VK_NUMPAD4 : return Input::Keys::KP4; case VK_NUMPAD5 : return Input::Keys::KP5; case VK_NUMPAD6 : return Input::Keys::KP6; case VK_NUMPAD7 : return Input::Keys::KP7; case VK_NUMPAD8 : return Input::Keys::KP8; case VK_NUMPAD9 : return Input::Keys::KP9; case VK_MULTIPLY : return Input::Keys::MULTIPLY; case VK_ADD : return Input::Keys::ADD; case VK_SEPARATOR : return Input::Keys::SEPARATOR; case VK_SUBTRACT : return Input::Keys::SUBTRACT; case VK_DECIMAL : return Input::Keys::DECIMAL; case VK_DIVIDE : return Input::Keys::DIVIDE; case VK_F1 : return Input::Keys::F1; case VK_F2 : return Input::Keys::F2; case VK_F3 : return Input::Keys::F3; case VK_F4 : return Input::Keys::F4; case VK_F5 : return Input::Keys::F5; case VK_F6 : return Input::Keys::F6; case VK_F7 : return Input::Keys::F7; case VK_F8 : return Input::Keys::F8; case VK_F9 : return Input::Keys::F9; case VK_F10 : return Input::Keys::F10; case VK_F11 : return Input::Keys::F11; case VK_F12 : return Input::Keys::F12; case VK_CAPITAL : return Input::Keys::CAPS_LOCK; case VK_NUMLOCK : return Input::Keys::NUM_LOCK; case VK_SCROLL : return Input::Keys::SCROLL_LOCK; } return Input::Keys::InputKey(0); } //////////////////////////////////////////////////////////// /// Properties //////////////////////////////////////////////////////////// bool WindowUi::isFullscreen() { return fullscreen; } std::vector<bool> WindowUi::getKeyStates() { return keys; } bool WindowUi::getMouseFocus() { return mouse_focus; } int WindowUi::getMouseWheel() { return mouse_wheel; } int WindowUi::getMousePosX() { return mouse_x; } int WindowUi::getMousePosY() { return mouse_y; }
[ [ [ 1, 614 ] ] ]
6ce14c4e6aff9c906dfafadd4069a4d88d8efc36
fcf03ead74f6dc103ec3b07ffe3bce81c820660d
/FileBrowse/uiq/FileBrowse/src/filebrowsedocument.cpp
538ac0bf1e7508c6c4575d9a7aa4ef4085f1946c
[]
no_license
huellif/symbian-example
72097c9aec6d45d555a79a30d576dddc04a65a16
56f6c5e67a3d37961408fc51188d46d49bddcfdc
refs/heads/master
2016-09-06T12:49:32.021854
2010-10-14T06:31:20
2010-10-14T06:31:20
38,062,421
2
0
null
null
null
null
UTF-8
C++
false
false
888
cpp
// FileBrowseDocument.cpp // // Copyright (c) 2006 Symbian Software Ltd. All rights reserved. // #include <QikApplication.h> #include "FileBrowseAppUi.h" #include "FileBrowseDocument.h" #include "RFsEngine.h" CFileBrowseDocument::CFileBrowseDocument (CQikApplication& aApp) : CQikDocument(aApp) {} CFileBrowseDocument* CFileBrowseDocument::NewL(CQikApplication& aApp) { CFileBrowseDocument* self = new (ELeave) CFileBrowseDocument(aApp); CleanupStack::PushL(self); self->ConstructL(); CleanupStack::Pop(self); return self; } void CFileBrowseDocument::ConstructL() { iEngine = CRFsEngine::NewL(); } CFileBrowseDocument::~CFileBrowseDocument() { delete iEngine; } CEikAppUi* CFileBrowseDocument::CreateAppUiL() { return new(ELeave) CFileBrowseAppUi; } CRFsEngine& CFileBrowseDocument::RFsEngine() { return *iEngine; }
[ "liuxk99@bdc341c6-17c0-11de-ac9f-1d9250355bca" ]
[ [ [ 1, 42 ] ] ]
9681730587866e5c25f2b80ec631f18209ffd18f
b4d726a0321649f907923cc57323942a1e45915b
/CODE/ImpED/BriefingEditorDlg.h
d301ae74ea307254a8c67c50cb4e37e8e58b0923
[]
no_license
chief1983/Imperial-Alliance
f1aa664d91f32c9e244867aaac43fffdf42199dc
6db0102a8897deac845a8bd2a7aa2e1b25086448
refs/heads/master
2016-09-06T02:40:39.069630
2010-10-06T22:06:24
2010-10-06T22:06:24
967,775
2
0
null
null
null
null
UTF-8
C++
false
false
6,739
h
/* * Copyright (C) Volition, Inc. 1999. All rights reserved. * * All source code herein is the property of Volition, Inc. You may not sell * or otherwise commercially exploit the source or things you created based on the * source. * */ /* * $Logfile: /Freespace2/code/FRED2/BriefingEditorDlg.h $ * $Revision: 1.2 $ * $Date: 2002/08/15 01:06:34 $ * $Author: penguin $ * * Briefing editor dialog box class. * * $Log: BriefingEditorDlg.h,v $ * Revision 1.2 2002/08/15 01:06:34 penguin * Include filename reorg (to coordinate w/ fs2_open) * * Revision 1.1.1.1 2002/07/15 03:10:52 inquisitor * Initial FRED2 Checking * * * 3 5/20/99 1:46p Andsager * Add briefing view copy and paste between stages * * 2 10/07/98 6:28p Dave * Initial checkin. Renamed all relevant stuff to be Fred2 instead of * Fred. Globalized mission and campaign file extensions. Removed Silent * Threat specific code. * * 1 10/07/98 3:01p Dave * * 1 10/07/98 3:00p Dave * * 24 4/20/98 4:40p Hoffoss * Added a button to 4 editors to play the chosen wave file. * * 23 4/07/98 4:51p Dave * (Hoffoss) Fixed a boat load of bugs caused by the new change to * multiple briefings. Allender's code changed to support this in the * briefing editor wasn't quite correct. * * 22 4/06/98 5:37p Hoffoss * Added sexp tree support to briefings in Fred. * * 21 2/18/98 6:45p Hoffoss * Added support for lines between icons in briefings for Fred. * * 20 2/09/98 9:25p Allender * team v team support. multiple pools and breifings * * 19 2/04/98 4:32p Allender * support for multiple briefings and debriefings. Changes to mission * type (now a bitfield). Bitfield defs for multiplayer modes * * 18 11/04/97 4:33p Hoffoss * Made saving keep the current briefing state intact. * * 17 10/19/97 11:32p Hoffoss * Added support for briefing cuts in Fred. * * 16 9/30/97 5:56p Hoffoss * Added music selection combo boxes to Fred. * * 15 8/19/97 10:15a Hoffoss * Made escape close briefing window through normal channels. * * 14 8/14/97 6:37p Hoffoss * Added briefing icon id support to Fred. * * 13 8/07/97 3:45p Hoffoss * Added in several requested features to the briefing editor. * * 12 8/06/97 12:25p Hoffoss * Fixed bugs: Briefing editor dialog wasn't getting reset when new * mission created, and hitting MFC assert when quitting while briefing * editor open. * * 11 7/03/97 9:42a Hoffoss * Added a ship type field in briefing editor. * * 10 6/26/97 6:04p Hoffoss * Briefing icons now are selected before normal objects. * * 9 6/26/97 5:18p Hoffoss * Major rework of briefing editor functionality. * * 8 6/25/97 4:13p Hoffoss * Added functionality to the make icon button. * * 7 6/25/97 10:37a Hoffoss * Added icon text field support to briefing editor. * * 6 6/24/97 3:03p Hoffoss * New stages now copy another stage if possible. * * 5 6/24/97 11:31a Hoffoss * Added code for handling icon editing. * * 4 6/24/97 10:16a Hoffoss * Changes to briefing editor code. * * 3 6/23/97 2:58p Hoffoss * Added more functionality to briefing editor. * * 2 6/18/97 2:39p Hoffoss * Improved on briefing editor. Still far from done, though. * * $NoKeywords: $ */ #ifndef __BRIEFINGEDITORDLG_H__ #define __BRIEFINGEDITORDLG_H__ #include "parse/sexp.h" #include "mission/missionbriefcommon.h" ///////////////////////////////////////////////////////////////////////////// // briefing_editor_dlg dialog class briefing_editor_dlg : public CDialog { // Construction public: void focus_sexp(int select_sexp_node); int calc_num_lines_for_icons(int num); void batch_render(); void save_editor_state(); void restore_editor_state(); void reset_icon_loop(int stage); int get_next_icon(int id); void OnOK(); void OnCancel(); int find_icon(int id, int stage); void propagate_icon(int num); void reset_editor(); int check_mouse_hit(int x, int y); void delete_icon(int num); void update_positions(); void icon_select(int num); void draw_icon(object *objp); void create(); void update_data(int update = 1); briefing_editor_dlg(CWnd* pParent = NULL); // standard constructor // Dialog Data //{{AFX_DATA(briefing_editor_dlg) enum { IDD = IDD_BRIEFING_EDITOR }; sexp_tree m_tree; CButton m_lines; BOOL m_hilight; int m_icon_image; CString m_icon_label; CString m_stage_title; CString m_text; CString m_tag; CString m_time; CString m_voice; CString m_icon_text; int m_icon_team; int m_icon_iff; int m_ship_type; BOOL m_change_local; int m_id; int m_briefing_music; BOOL m_cut_next; BOOL m_cut_prev; int m_current_briefing; //}}AFX_DATA CBitmap m_play_bm; // copy view variables int m_copy_view_set; vector m_copy_view_pos; matrix m_copy_view_orient; // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(briefing_editor_dlg) public: virtual BOOL DestroyWindow(); protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); //}}AFX_VIRTUAL // Implementation protected: brief_icon *iconp; briefing *save_briefing; int icon_loop, stage_loop; int m_cur_stage; int m_last_stage; int m_cur_icon; int m_last_icon; int stage_saved; int icon_saved; int modified; // int point_obj; int icon_obj[MAX_STAGE_ICONS]; int icon_marked[MAX_STAGE_ICONS]; int line_marked[MAX_BRIEF_STAGE_LINES]; void copy_stage(int from, int to); // Generated message map functions //{{AFX_MSG(briefing_editor_dlg) afx_msg void OnClose(); afx_msg void OnNext(); afx_msg void OnPrev(); afx_msg void OnBrowse(); afx_msg void OnAddStage(); afx_msg void OnDeleteStage(); afx_msg void OnInsertStage(); afx_msg void OnMakeIcon(); afx_msg void OnDeleteIcon(); afx_msg void OnGotoView(); afx_msg void OnSaveView(); afx_msg void OnSelchangeIconImage(); afx_msg void OnSelchangeTeam(); afx_msg void OnSelchangeIff(); afx_msg void OnPropagateIcons(); afx_msg void OnInitMenu(CMenu* pMenu); afx_msg void OnLines(); afx_msg void OnRclickTree(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnBeginlabeleditTree(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnEndlabeleditTree(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnPlay(); afx_msg void OnCopyView(); afx_msg void OnPasteView(); afx_msg void OnBriefTag(); //}}AFX_MSG DECLARE_MESSAGE_MAP() private: }; #endif
[ [ [ 1, 241 ] ] ]
a0a8cf7b8acf7646ea64e61f82d5a01ed4e11bc4
891e876aafde31b093ff8a67907c4b36a1e632b2
/common/LibHeaders/IND_Entity2d.h
0cc31651aeb7a379e8f6f34db0180d3f271fe69c
[]
no_license
aramande/Nirena
fc51d8768e9a9fb7e44dd6fadf726ed3fc1d51c8
1e7299ee4915ab073dc7c64569789a07769e71be
refs/heads/master
2021-01-18T20:17:52.943977
2010-12-04T00:05:10
2010-12-04T00:05:10
1,217,641
0
0
null
null
null
null
ISO-8859-2
C++
false
false
15,011
h
/***************************************************************************************** /* File: IND_Entity2d.h /* Desc: Entity 2d object /*****************************************************************************************/ /* IndieLib 2d library Copyright (C) 2005 Javier López López ([email protected]) 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. This library 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 this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _IND_ENTITY2D_ #define _IND_ENTITY2D_ // ----- Includes ----- #include "IND_SurfaceManager.h" // -------------------------------------------------------------------------------- // IND_Entity2d // -------------------------------------------------------------------------------- /*! \defgroup IND_Entity2d IND_Entity2d \ingroup EntityManagers 2d entity class managed by IND_Entity2dManager for drawing graphical objects into the screen and manipulating their attributes, click in ::IND_Entity2d to see all the methods of this class. */ /*@{*/ /*! \b IND_Entity2d is an 2d entity object of the class ::IND_Entity2dManager. This class, together with ::IND_Entity3d (object of ::IND_Entity3dManager), are the most important classes of IndieLib. An entity is an object that can have a graphical object associated to it. Using the methods of this class you will be able to change the attributes of the graphical object that it contains. For example, in a game, a bullet can be a ::IND_Entity2d that has a ::IND_Surface associated to it. You can have as many bullets (::IND_Entity2d objects) in the screen as you want, all of them sharing the same IND_Surface (the sprite). In system memory you will have only one 3d mesh loaded, the rest will be instances. The cool thing is that you can change the attributes of each of these different ::IND_Entity2d objects. For example, you can change the size, rotation, color or transparency of the bullets. So, having only one sprite, you can have lot of different bullets in the screen, with different sizes, colors, positions, etc. IND_Entity2d can have so many different graphical objects associated to it: - Surfaces (Sprites, scrolls, images, etc) - Animations - Fonts - Primitives (lines, rectangles, circles, polys, etc) */ class DLL_EXP IND_Entity2d { public: // ----- Init ----- IND_Entity2d (); ~IND_Entity2d (); // ----- Public sets ------ /** @name Graphical objects assignation to the 2d entity * */ //@{ void SetSurface (IND_Surface *pNewSurface); void SetAnimation (IND_Animation *pNewAnimation); void SetPrimitive2d (IND_Primitive2d pPri2d); void SetFont (IND_Font *pFont); //@} /** @name Showing * */ //@{ void SetShow (bool pShow); //@} /** @name Animations * */ //@{ void SetSequence (int pSequence); void SetNumReplays (int pNumReplays); //@} /** @name Primitives * */ //@{ void SetLine (int pX1, int pY1, int pX2, int pY2); void SetRectangle (int pX1, int pY1, int pX2, int pY2); void SetRadius (int pRadius); void SetNumSides (int pNumSides); void SetPolyAngle (float pPolyAngle); void SetPolyPoints (IND_Point *pPolyPoints); void SetNumLines (int pNumLines); //@} /** @name Fonts * */ //@{ void SetAlign (IND_Align pAlign); void SetCharSpacing (int pCharSpacing); void SetLineSpacing (int pLineSpacing); void SetText (char *pText); //@} /** @name Space transformations (Some of these methods doesn't affect the fonts or the primitives) * */ //@{ void SetPosition (float pX, float pY, int pZ); void SetAngleXYZ (float pAnX, float pAnY, float pAnZ); void SetScale (float pSx, float pSy); void SetMirrorX (bool pMx); void SetMirrorY (bool pMy); void SetFilter (IND_Filter pF); bool SetHotSpot (float pX, float pY); bool SetRegion (int pOffX, int pOffY, int pRegionWidth, int pRegionHeight); bool ToggleWrap (bool pWrap); void SetWrapDisplacement (float pUDisplace, float pVDisplace); //@} /** @name Color transformations, blending and back face culling (Some of these methods doesn't affect the fonts or the primitives) * */ //@{ void SetBackCull (bool pCull); void SetTint (byte pR, byte pG, byte pB); void SetTransparency (byte pA); void SetFade (byte pR, byte pG, byte pB, byte pA); void SetBlendSource (IND_BlendingType pSo); void SetBlendDest (IND_BlendingType pDs); //@} /** @name Collisions * */ //@{ bool SetBoundingAreas (char *pFile); bool SetBoundingTriangle (char *pId, int pAx, int pAy, int pBx, int pBy, int pCx, int pCy); bool SetBoundingCircle (char *pId, int pOffsetX, int pOffsetY, int pRadius); bool SetBoundingRectangle (char *pId, int pOffsetX, int pOffsetY, int pWidth, int pHeight); bool DeleteBoundingAreas (char *pId); void ShowCollisionAreas (bool pShowCollisionAreas); void ShowGridAreas (bool pShowGridAreas); //@} // ----- Public Gets ------ /** @name Gets * */ //@{ //! If the entity has a surface assigned, it returns a pointer to this surface. IND_Surface *GetSurface () { return mSu; } //! If the entity has a animation assigned, it returns a pointer to this animation. IND_Animation *GetAnimation () { return mAn; } //! Returns true if the entity is being showed, false if not bool IsShow () { return mShow; } //! Returns the sequence number that has been assigned to the animation. int GetSequence () { return mSequence; } //! Returns the number of repetitions the animation has to do. If this value is equal or less than zero, it indicates that the amination is looping. int GetNumReplays () { return mNumReplays; } //! Returns X position of the entity. float GetPosX () { return mX; } //! Returns Y position of the entity. float GetPosY () { return mY; } //! Returns Z position of the entity. int GetPosZ () { return mZ; } //! Returns the angle in the X axis of the entity. float GetAngleX () { return mAngleX; } //! Returns the angle in the Y axis of the entity. float GetAngleY () { return mAngleY; } //! Returns the angle in the Z axis of the entity. float GetAngleZ () { return mAngleZ; } //! Returns the X scale of the entity. float GetScaleX () { return mScaleX; } //! Returns the Y scale of the entity. float GetScaleY () { return mScaleY; } //! Indicate if the entity is making backface culling 0 = No, 1 = Yes. bool GetBackCull () { return mCull; } //!Indicate if the entity makes horizontal mirror. 0 = No, 1 = Yes. bool GetMirrorX () { return mMirrorX; } //! Indicate if the entity makes vertical mirror. 0 = No, 1 = Yes. bool GetMirrorY () { return mMirrorY; } //! Returns the type of filter ::IND_Filter which uses the graphical object assignated to the entity. IND_Filter GetFilter () { return mFilter; } //! Returns the type ::IND_Type which uses the graphical object assignated to the entity. IND_Type GetType () { return mType; } //! Returns the tinted level in the R (red) channel of the entity. byte GetTintR () { return mR; } //! Returns the tTinted level in the G (green) channel of the entity. byte GetTintG () { return mG; } //! Returns the tinted level in the B (blue) channel of the entity. byte GetTintB () { return mB; } //! Returns the transparency level of the entity byte GetTransparency () { return mA; } //! Returns the fade level in R (red) channel of the entity. byte GetFadeR () { return mFadeR; } //! Returns the fade level in G (green) channel of the entity. byte GetFadeG () { return mFadeG; } //! Returns the fade level in B (blue) channel of the entity. byte GetFadeB () { return mFadeB; } //! Returns the fade level of the entity. byte GetFadeA () { return mFadeA; } //! Returns the blending type ::IND_BlendingType for the source IND_BlendingType GetBlendSource () { return mSo; } //! Returns the blending type ::IND_BlendingType for the destination IND_BlendingType GetDestSource () { return mDs; } //! Returns the X HotSpot of the entity. float GetHotSpotX () { return mHotSpotX; } //! Returns the Y HotSpot of the entity. float GetHotSpotY () { return mHotSpotY; } //! Returns the X position of the upper left corner of the region assignated to the entity by IND_Entity2d::SetRegion() int GetRegionX () { return mOffX; } //! Returns the Y position of the upper left corner of the region assignated to the entity by IND_Entity2d::SetRegion() int GetRegionY () { return mOffY; } //! Returns the width of the region assignated to the entity by IND_Entity2d::SetRegion() int GetRegionWidth () { return mRegionWidth; } //! Returns the height of the region assignated to the entity by IND_Entity2d::SetRegion() int GetRegionHeight () { return mRegionHeight; } //! Returns the position 1 (true) if the image is being repeated in the X,Y axis bool IfWrap () { return mWrap; } //! Returns the position in x from the first point of a primitive line. int GetLineX1 () { return mX1;} //! Returns the position in y from the first point of a primitive line. int GetLineY1 () { return mY1; } //! Returns the position in x from the second point of a primitive line. int GetLineX2 () { return mX2; } //! Returns the position in y from the second point of a primitive line. int GetLineY2 () { return mY2; } //! Returns the radius of the primitives ::IND_REGULAR_POLY int GetRadius () { return mRadius; } //! Returns the numbers of sides of the primitive ::IND_REGULAR_POLY int GetNumSides () { return mNumSides; } //! Returns the primitive angle ::IND_REGULAR_POLY float GetPolyAngle () { return mPolyAngle; } //! Returns the points array which draw the primitive ::IND_POLY2D IND_Point *GetPolyPoints () { return mPolyPoints; } //! Returns the number of lines which draw the primitive ::IND_POLY2D int GetNumLines () { return mNumLines; } //! Returns the align ::IND_Align of the text IND_Align GetAlign () { return mAlign; } //! Returns the additional space between characters when using IND_Font int GetCharSpacing () { return mCharSpacing; } //! Returns the line spacing between lines when using IND_Font int GetLineSpacing () { return mLineSpacing; } //! Returns the text string of the entity char *GetText () { return mText; } //! Returs true if the collision areas are being shown bool IsShowCollisionAreas () { return mShowCollisionAreas; } //! Returs true if the grid areas are being shown bool IsShowGridAreas () { return mShowGridAreas; } //@} private: // ----- Private ------ // ----- Objects ----- CollisionParser *mCollisionParser; // ----- Entity attributes ----- IND_Surface *mSu; // Pointer to a surface IND_Animation *mAn; // Pointer to an animation IND_Primitive2d mPri2d; // Primitive type IND_Font *mFont; // Fonts // Show bool mShow; // Flag for showing / hiding the entity // Space transformation attributes bool mUpdateTransFlag; // Flag for knowing when to recalculate the transformation matrix of an entity float mX; // x Coordinate float mY; // y Coordinate int mZ; // Depth (indicates which object will be blitted upon which other) float mAngleX; // Angle in the x axis float mAngleY; // Angle in the y axis float mAngleZ; // Angle in the z axis float mScaleX; // Horizontal scaling float mScaleY; // Vertical scaling bool mCull; // Back Face Culling ON / OFF float mHotSpotX; // Hotspot x float mHotSpotY; // Hotspot y int mAxisCalX; // Horizontal hotspot precalculated int mAxisCalY; // Vertical hotspot precalculated bool mMirrorX; // Horizontal mirroring bool mMirrorY; // Vertical mirroring IND_Filter mFilter; // Filter type (0 = Nearest Point || 1 = Linear) IND_Matrix mMat; // World matrix // Color, transperency and fading attributes IND_Type mType; // IND_Type: IND_Opaque, IND_Alpha byte mR; // R component for tinting byte mG; // G component for tinting byte mB; // B component for tinting byte mA; // Transparency byte mFadeR; // R component for the fade to color byte mFadeG; // G component for the fade to color byte mFadeB; // B component for the fade to color byte mFadeA; // Amount of fade IND_BlendingType mSo; // Blending source IND_BlendingType mDs; // Blending destination // Region int mOffX; // x coordinate int mOffY; // y coordinate int mRegionWidth; // Witdh int mRegionHeight; // Height // Tiling bool mWrap; // Wrapping float mUDisplace; // U Coordinate displacement float mVDisplace; // V Coordinate displacement // Animation attributes int mSequence; // Index of the sequence int mNumReplays; // Num of replays of the sequence int mFirstTime; // Flag // 2d primitive attributes int mX1, mY1, mX2, mY2; // Line int mRadius; // Radius IND_Point *mPolyPoints; // Point list int mNumLines; // Number of sides of the polygon int mNumSides; // Number of sides of the regular polygon float mPolyAngle; // Regular polygon angle // Fonts attributes IND_Align mAlign; // Font align int mCharSpacing; // Additional space between letters int mLineSpacing; // Space between lines char *mText; // Text // Collision attributes bool mShowCollisionAreas; // Grid areas attributes bool mShowGridAreas; // Collision list for surfaces (the collision list for animations is in IND_AnimationManager.h) list <BOUNDING_COLLISION*> *mListBoundingCollision; // Vector of bounding areas for collision checking // ----- Private methods ----- void InitAttrib (); bool IsNullMatrix (); // ----- Friends ----- friend class IND_Entity2dManager; }; /*@}*/ #endif // _IND_ENTITY2D_
[ [ [ 1, 374 ] ] ]
de7da71add136710c1c052f36687eae7167310ce
fb6dd0d5bb8d707bff28fb9ec7359d04badb2113
/source/point/Pion.h
636ca9ed92a527a64b132d17f83c8c93a11a5069
[]
no_license
btuduri/labyrinth-nds
fc6a3bbe98ae1834819af0c51da4913352f4f0e2
7f401d3b6da71ddfb7d3758d0b7262b9e078e961
refs/heads/master
2020-12-24T14:36:45.270641
2008-12-31T12:49:43
2008-12-31T12:49:43
32,271,737
0
0
null
null
null
null
UTF-8
C++
false
false
143
h
namespace point { class Pion { public: Pion(void); ~Pion(void); void move(int x, int y); int getSize(); }; }
[ "pdesoyres@e041c052-d737-11dd-9aad-3f7dfcff7c77" ]
[ [ [ 1, 12 ] ] ]
5b5e81ede559e96c61e55bfb7234d72b687759d9
21da454a8f032d6ad63ca9460656c1e04440310e
/src/wcpp/lang/helper/wscObjectRootEx.h
d3504a2ae429874bfc188e6dcbf791ff3505f277
[]
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
2,153
h
#pragma once #include <wcpp/wspr/ws_type.h> #include "wsuThreadModel.h" #include "wscObjectRootBase.h" template<typename T_ThreadModel> class wscObjectRootEx : public wscObjectRootBase { public: typedef wscObjectRootBase t_super_class; typedef T_ThreadModel ThreadModel; /* typedef typename ThreadModel::AutoCriticalSection CritSec; typedef typename ThreadModel::AutoDeleteCriticalSection AutoDelCritSec; typedef typename wsuObjectLockT<ThreadModel> ObjectLock; */ protected: wscObjectRootEx(void) : m_nRef(0) { } // methods ws_int InternalAddRef() { return ThreadModel::Increment( m_nRef ); } ws_int InternalRelease() { ws_int ret = ThreadModel::Decrement( m_nRef ); if (ret==0) { delete ((wsiInterface*)this); } return ret; } void Lock(void) { InternalThrowUnsupported(); // m_lock.Lock(); } void Unlock(void) { InternalThrowUnsupported(); // m_lock.Unlock(); } protected: void FinalConstruct() { t_super_class::FinalConstruct(); } void FinalRelease() { t_super_class::FinalRelease(); } ws_int OuterAddRef(void) { return m_pOuter->AddRef(); } ws_result OuterQueryInterface(const ws_iid & iid , void** pp) { return m_pOuter->QueryInterface(iid,pp); } ws_int OuterRelease(void) { return m_pOuter->Release(); } public: /* static void InternalQueryInterface(void* pThis, const WS_INTMAP_ENTRY * pEntries, const ws_iid & iid, void** pp) { t_super_class::InternalQueryInterface( pThis , pEntries , iid , pp ); } */ static void ObjectMain(ws_boolean bStarting) { t_super_class::ObjectMain( bStarting ); } private: // data member union { ws_int m_nRef; wsiInterface * m_pOuter; }; // ObjectLock m_lock; };
[ "xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8" ]
[ [ [ 1, 108 ] ] ]
0f7a5792d5c8bd477b56b29613c34d8795dc8f7b
6630a81baef8700f48314901e2d39141334a10b7
/1.4/Testing/Cxx/swFrameworkDependent/FrameFactory/swMainFrame.h
4b8aabc6f9708fc5131730737b689c393c854064
[]
no_license
jralls/wxGuiTesting
a1c0bed0b0f5f541cc600a3821def561386e461e
6b6e59e42cfe5b1ac9bca02fbc996148053c5699
refs/heads/master
2021-01-10T19:50:36.388929
2009-03-24T20:22:11
2009-03-26T18:51:24
623,722
1
0
null
null
null
null
UTF-8
C++
false
false
773
h
/////////////////////////////////////////////////////////////////////////////// // Name: swFrameworkDependent/FrameFactory/swMainFrame.h // Author: Yann Rouillard, Viet Bui Xuan // Created: 2002 // Copyright: (c) 2002 Yann Rouillard, Viet Bui Xuan // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// #ifndef SWMAINFRAME_H #define SWMAINFRAME_H #ifdef __GNUG__ #pragma interface "swMainFrame.h" #endif #include "Common.h" #include "swWindow.h" namespace sw { class MainFrame: public Window { public: virtual ~MainFrame (); wxWindow *GetWindow () const; virtual wxFrame *GetFrame() const = 0; }; } // End namespace sw #endif // SWMAINFRAME_H
[ "john@64288482-8357-404e-ad65-de92a562ee98" ]
[ [ [ 1, 35 ] ] ]
5ba9fa2092454e552346573a7a48fefb1808a9d7
96e96a73920734376fd5c90eb8979509a2da25c0
/BulletPhysics/BulletDynamics/ConstraintSolver/btSliderConstraint.h
a980812ae7bf43c242eb7617b094da17420cec40
[]
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
10,187
h
/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* Added by Roman Ponomarev ([email protected]) April 04, 2008 TODO: - add clamping od accumulated impulse to improve stability - add conversion for ODE constraint solver */ #ifndef SLIDER_CONSTRAINT_H #define SLIDER_CONSTRAINT_H #include "LinearMath/btVector3.h" #include "btJacobianEntry.h" #include "btTypedConstraint.h" class btRigidBody; #define SLIDER_CONSTRAINT_DEF_SOFTNESS (btScalar(1.0)) #define SLIDER_CONSTRAINT_DEF_DAMPING (btScalar(1.0)) #define SLIDER_CONSTRAINT_DEF_RESTITUTION (btScalar(0.7)) class btSliderConstraint : public btTypedConstraint { protected: ///for backwards compatibility during the transition to 'getInfo/getInfo2' bool m_useSolveConstraintObsolete; btTransform m_frameInA; btTransform m_frameInB; // use frameA fo define limits, if true bool m_useLinearReferenceFrameA; // linear limits btScalar m_lowerLinLimit; btScalar m_upperLinLimit; // angular limits btScalar m_lowerAngLimit; btScalar m_upperAngLimit; // softness, restitution and damping for different cases // DirLin - moving inside linear limits // LimLin - hitting linear limit // DirAng - moving inside angular limits // LimAng - hitting angular limit // OrthoLin, OrthoAng - against constraint axis btScalar m_softnessDirLin; btScalar m_restitutionDirLin; btScalar m_dampingDirLin; btScalar m_softnessDirAng; btScalar m_restitutionDirAng; btScalar m_dampingDirAng; btScalar m_softnessLimLin; btScalar m_restitutionLimLin; btScalar m_dampingLimLin; btScalar m_softnessLimAng; btScalar m_restitutionLimAng; btScalar m_dampingLimAng; btScalar m_softnessOrthoLin; btScalar m_restitutionOrthoLin; btScalar m_dampingOrthoLin; btScalar m_softnessOrthoAng; btScalar m_restitutionOrthoAng; btScalar m_dampingOrthoAng; // for interlal use bool m_solveLinLim; bool m_solveAngLim; btJacobianEntry m_jacLin[3]; btScalar m_jacLinDiagABInv[3]; btJacobianEntry m_jacAng[3]; btScalar m_timeStep; btTransform m_calculatedTransformA; btTransform m_calculatedTransformB; btVector3 m_sliderAxis; btVector3 m_realPivotAInW; btVector3 m_realPivotBInW; btVector3 m_projPivotInW; btVector3 m_delta; btVector3 m_depth; btVector3 m_relPosA; btVector3 m_relPosB; btScalar m_linPos; btScalar m_angPos; btScalar m_angDepth; btScalar m_kAngle; bool m_poweredLinMotor; btScalar m_targetLinMotorVelocity; btScalar m_maxLinMotorForce; btScalar m_accumulatedLinMotorImpulse; bool m_poweredAngMotor; btScalar m_targetAngMotorVelocity; btScalar m_maxAngMotorForce; btScalar m_accumulatedAngMotorImpulse; //------------------------ void initParams(); public: // constructors btSliderConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA); btSliderConstraint(btRigidBody& rbB, const btTransform& frameInB, bool useLinearReferenceFrameB); btSliderConstraint(); // overrides virtual void buildJacobian(); virtual void getInfo1 (btConstraintInfo1* info); virtual void getInfo2 (btConstraintInfo2* info); virtual void solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep); // access const btRigidBody& getRigidBodyA() const { return m_rbA; } const btRigidBody& getRigidBodyB() const { return m_rbB; } const btTransform & getCalculatedTransformA() const { return m_calculatedTransformA; } const btTransform & getCalculatedTransformB() const { return m_calculatedTransformB; } const btTransform & getFrameOffsetA() const { return m_frameInA; } const btTransform & getFrameOffsetB() const { return m_frameInB; } btTransform & getFrameOffsetA() { return m_frameInA; } btTransform & getFrameOffsetB() { return m_frameInB; } btScalar getLowerLinLimit() { return m_lowerLinLimit; } void setLowerLinLimit(btScalar lowerLimit) { m_lowerLinLimit = lowerLimit; } btScalar getUpperLinLimit() { return m_upperLinLimit; } void setUpperLinLimit(btScalar upperLimit) { m_upperLinLimit = upperLimit; } btScalar getLowerAngLimit() { return m_lowerAngLimit; } void setLowerAngLimit(btScalar lowerLimit) { m_lowerAngLimit = btNormalizeAngle(lowerLimit); } btScalar getUpperAngLimit() { return m_upperAngLimit; } void setUpperAngLimit(btScalar upperLimit) { m_upperAngLimit = btNormalizeAngle(upperLimit); } bool getUseLinearReferenceFrameA() { return m_useLinearReferenceFrameA; } btScalar getSoftnessDirLin() { return m_softnessDirLin; } btScalar getRestitutionDirLin() { return m_restitutionDirLin; } btScalar getDampingDirLin() { return m_dampingDirLin ; } btScalar getSoftnessDirAng() { return m_softnessDirAng; } btScalar getRestitutionDirAng() { return m_restitutionDirAng; } btScalar getDampingDirAng() { return m_dampingDirAng; } btScalar getSoftnessLimLin() { return m_softnessLimLin; } btScalar getRestitutionLimLin() { return m_restitutionLimLin; } btScalar getDampingLimLin() { return m_dampingLimLin; } btScalar getSoftnessLimAng() { return m_softnessLimAng; } btScalar getRestitutionLimAng() { return m_restitutionLimAng; } btScalar getDampingLimAng() { return m_dampingLimAng; } btScalar getSoftnessOrthoLin() { return m_softnessOrthoLin; } btScalar getRestitutionOrthoLin() { return m_restitutionOrthoLin; } btScalar getDampingOrthoLin() { return m_dampingOrthoLin; } btScalar getSoftnessOrthoAng() { return m_softnessOrthoAng; } btScalar getRestitutionOrthoAng() { return m_restitutionOrthoAng; } btScalar getDampingOrthoAng() { return m_dampingOrthoAng; } void setSoftnessDirLin(btScalar softnessDirLin) { m_softnessDirLin = softnessDirLin; } void setRestitutionDirLin(btScalar restitutionDirLin) { m_restitutionDirLin = restitutionDirLin; } void setDampingDirLin(btScalar dampingDirLin) { m_dampingDirLin = dampingDirLin; } void setSoftnessDirAng(btScalar softnessDirAng) { m_softnessDirAng = softnessDirAng; } void setRestitutionDirAng(btScalar restitutionDirAng) { m_restitutionDirAng = restitutionDirAng; } void setDampingDirAng(btScalar dampingDirAng) { m_dampingDirAng = dampingDirAng; } void setSoftnessLimLin(btScalar softnessLimLin) { m_softnessLimLin = softnessLimLin; } void setRestitutionLimLin(btScalar restitutionLimLin) { m_restitutionLimLin = restitutionLimLin; } void setDampingLimLin(btScalar dampingLimLin) { m_dampingLimLin = dampingLimLin; } void setSoftnessLimAng(btScalar softnessLimAng) { m_softnessLimAng = softnessLimAng; } void setRestitutionLimAng(btScalar restitutionLimAng) { m_restitutionLimAng = restitutionLimAng; } void setDampingLimAng(btScalar dampingLimAng) { m_dampingLimAng = dampingLimAng; } void setSoftnessOrthoLin(btScalar softnessOrthoLin) { m_softnessOrthoLin = softnessOrthoLin; } void setRestitutionOrthoLin(btScalar restitutionOrthoLin) { m_restitutionOrthoLin = restitutionOrthoLin; } void setDampingOrthoLin(btScalar dampingOrthoLin) { m_dampingOrthoLin = dampingOrthoLin; } void setSoftnessOrthoAng(btScalar softnessOrthoAng) { m_softnessOrthoAng = softnessOrthoAng; } void setRestitutionOrthoAng(btScalar restitutionOrthoAng) { m_restitutionOrthoAng = restitutionOrthoAng; } void setDampingOrthoAng(btScalar dampingOrthoAng) { m_dampingOrthoAng = dampingOrthoAng; } void setPoweredLinMotor(bool onOff) { m_poweredLinMotor = onOff; } bool getPoweredLinMotor() { return m_poweredLinMotor; } void setTargetLinMotorVelocity(btScalar targetLinMotorVelocity) { m_targetLinMotorVelocity = targetLinMotorVelocity; } btScalar getTargetLinMotorVelocity() { return m_targetLinMotorVelocity; } void setMaxLinMotorForce(btScalar maxLinMotorForce) { m_maxLinMotorForce = maxLinMotorForce; } btScalar getMaxLinMotorForce() { return m_maxLinMotorForce; } void setPoweredAngMotor(bool onOff) { m_poweredAngMotor = onOff; } bool getPoweredAngMotor() { return m_poweredAngMotor; } void setTargetAngMotorVelocity(btScalar targetAngMotorVelocity) { m_targetAngMotorVelocity = targetAngMotorVelocity; } btScalar getTargetAngMotorVelocity() { return m_targetAngMotorVelocity; } void setMaxAngMotorForce(btScalar maxAngMotorForce) { m_maxAngMotorForce = maxAngMotorForce; } btScalar getMaxAngMotorForce() { return m_maxAngMotorForce; } btScalar getLinearPos() { return m_linPos; } // access for ODE solver bool getSolveLinLimit() { return m_solveLinLim; } btScalar getLinDepth() { return m_depth[0]; } bool getSolveAngLimit() { return m_solveAngLim; } btScalar getAngDepth() { return m_angDepth; } // internal void buildJacobianInt(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB); void solveConstraintInt(btRigidBody& rbA, btSolverBody& bodyA,btRigidBody& rbB, btSolverBody& bodyB); // shared code used by ODE solver void calculateTransforms(void); void testLinLimits(void); void testLinLimits2(btConstraintInfo2* info); void testAngLimits(void); // access for PE Solver btVector3 getAncorInA(void); btVector3 getAncorInB(void); }; #endif //SLIDER_CONSTRAINT_H
[ "caiocsabino@7e2be596-0d54-0410-9f9d-cf4183935158" ]
[ [ [ 1, 230 ] ] ]
d876c0913e5effa84cb6afba78c5d137a968a22c
885fc5f6e056abe95996b4fc6eebef06a94d50ce
/include/FFMpegDecoder.h
103c5534bd2d58f8151dad388f661526b94c8b8d
[]
no_license
jdzyzh/ffmpeg-wrapper
bdf0a6f15db2625b2707cbac57d5bfaca6396e3d
5185bb3695df9adda59f7f849095314f16b2bd48
refs/heads/master
2021-01-10T08:58:06.519741
2011-11-30T06:32:50
2011-11-30T06:32:50
54,611,386
1
0
null
null
null
null
UTF-8
C++
false
false
2,332
h
#ifndef FFMPEG_DECODER_H #define FFMPEG_DECODER_H #include "FFMpegWrapperAPI.h" extern "C" { #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> } #include "AVInfo.h" #include "SimpleBuffer.h" #include "FFMpegFifo.h" #include "FFMpegReSampler.h" #include "FPSCounter.h" class FFMPEGWRAPPER_API FFMpegDecoder { public: FFMpegDecoder(); ~FFMpegDecoder(); AVInfo* openFile(char* filename); AVInfo* openFileW(wchar_t* filename); AVPacket* readPacket(); AVFrame* decodeVideo(); AVFrame* decodeVideo(AVPacket *encodedPacket); SimpleBuf* decodeAudio(); int decodeAudio(AVPacket *pkt,unsigned char* outputBuf,int outputBufSize); double getVideoPtsSec(); double getAudioPtsSec(); PixelFormat getPixelFormat(); int seekToSec(double sec); AVFrame* getFrameAtSec(double sec); AVFrame* getNextVideoFrame(); FFMpegReSampler* createReSampler(int ch2,int rate2,SampleFormat fmt2); unsigned char* getReSampledAudioSamples(int audio_size); bool isOpened(); protected: static int my_get_buffer(struct AVCodecContext *c, AVFrame *pic); static void my_release_buffer(struct AVCodecContext *c, AVFrame *pic); void syncVideoPTS(); public: //protected: int videoBufSize; SimpleBuf audioBuf; //audio decode result unsigned char* resampleBuf; //resample result int videoStream,audioStream; AVFormatContext* pFormatCtx; AVCodecContext* pVideoCodecCtx; AVCodecContext* pAudioCodecCtx; AVCodec* pVideoCodec; AVCodec* pAudioCodec; AVFrame* pDecodedFrame; AVPacket encodedPacket; AVInfo mediaInfo; double videoPTS; double videoClock; FFMpegReSampler* resampler; FFMpegFifo* fifoResampleResult; unsigned char* resampleChunk; //this will be returned by getReSampledAudio() int audioBytesPerSec; double audioPtsSec; bool opened; FPSCounter fpsCounter; public: static const int ERR_OPENFILE = -1; static const int ERR_FIND_STREAM = -2; static const int ERR_NOAVSTREAM = -3; static const int ERR_FINDDECODER_V = -4; static const int ERR_OPENDECODER_V = -5; static const int ERR_FINDDECODER_A = -6; static const int ERR_OPENDECODER_A = -7; static const int ERR_NO_STREAM = -8; }; #endif //FFMPEG_DECODER_H
[ "ransomhmc@6544afd8-f103-2cf2-cfd9-24e348754d5f", "[email protected]" ]
[ [ [ 1, 15 ], [ 17, 17 ], [ 19, 77 ], [ 80, 91 ] ], [ [ 16, 16 ], [ 18, 18 ], [ 78, 79 ] ] ]
595b70fdf9e06bd31f07306636ab2bc8330af94f
de75637338706776f8770c9cd169761cec128579
/VHFOS/Simple Game Editor/StandardTools.h
4642f7b11f4dd9f0654551826baa6ca6dfe65e3b
[]
no_license
huytd/fosengine
e018957abb7b2ea2c4908167ec83cb459c3de716
1cebb1bec49720a8e9ecae1c3d0c92e8d16c27c5
refs/heads/master
2021-01-18T23:47:32.402023
2008-07-12T07:20:10
2008-07-12T07:20:10
38,933,821
0
0
null
null
null
null
UTF-8
C++
false
false
9,575
h
#ifndef _STANDARD_TOOLS_H_ #define _STANDARD_TOOLS_H_ #include "ITool.h" #include "ProjectLevel.h" using namespace irr; using namespace gui; using namespace scene; class MoveTool:public ITool { public: MoveTool() :ITool() { image="resources/ui/move.png"; toolTipText=L"Move a scene node"; } void onActivate() { registerMouse(); ldown=false; rdown=false; } void onDeactivate() { unregisterMouse(); } void onMouse(SMouseEvent& args) { switch(args.mouseEvent) { case EMIE_LMOUSE_PRESSED_DOWN: ldown=true; oldX=args.x; oldY=args.y; break; case EMIE_RMOUSE_PRESSED_DOWN: rdown=true; oldX=args.x; oldY=args.y; break; case EMIE_LMOUSE_LEFT_UP: ldown=false; break; case EMIE_RMOUSE_LEFT_UP: rdown=false; break; case EMIE_MOUSE_MOVED: core::vector3df moveVect; if(ldown) { moveVect=core::vector3df((f32)(args.x-oldX),0,(f32)(oldY-args.y)); } if(rdown) { moveVect=core::vector3df(0,(f32)(oldY-args.y),0); } moveVect=moveVect/800; core::matrix4 m; core::vector3df camRot=manager->getCore()->getGraphicDevice()->getSceneManager()->getActiveCamera()->getRotation(); camRot.X=0; m.setRotationDegrees(camRot); m.transformVect(moveVect); ProjectLevel* level=(ProjectLevel*)(manager->getCurrentLevel()); ISceneNode* node=level->getSelectedNode(); if(node&&(node!=manager->getCore()->getGraphicDevice()->getSceneManager()->getRootSceneNode())) { moveVect=moveVect*node->getAbsolutePosition().getDistanceFrom(manager->getCore()->getGraphicDevice()->getSceneManager()->getActiveCamera()->getPosition()); node->setPosition(node->getPosition()+moveVect); node->updateAbsolutePosition(); } oldX=args.x; oldY=args.y; break; } } protected: bool ldown; bool rdown; int oldX; int oldY; }; class SelectTool:public ITool { public: SelectTool() :ITool() { image="resources/ui/select.bmp"; toolTipText=L"Select a scene node"; } void onActivate() { registerMouse(); } void onDeactivate() { unregisterMouse(); } void onMouse(SMouseEvent& args) { if(args.mouseEvent==EMIE_LMOUSE_PRESSED_DOWN) { ProjectLevel* level=(ProjectLevel*)(manager->getCurrentLevel()); //IGUIElement* el=manager->getCore()->getGraphicDevice()->getGUIEnvironment()->getRootGUIElement()->getElementFromPoint(position2d<s32>(args.x,args.y)); //if(el) // return; if(manager->getCore()->getInputManager()->isKeyPressed(KEY_CONTROL))//hold control and click to select the root sceneNode { level->setSelectedNode(manager->getCore()->getGraphicDevice()->getSceneManager()->getRootSceneNode()); return; } ISceneNode* node=manager->getCore()->getGraphicDevice()->getSceneManager()->getSceneCollisionManager()->getSceneNodeFromScreenCoordinatesBB( core::position2d<s32>(args.x,args.y),0,true); if(node) { level->setSelectedNode(node); level->updateNodeList(); } } } }; class RotateTool:public ITool { public: RotateTool() :ITool() { image="resources/ui/rotate.png"; toolTipText=L"Rotate a scene node"; } void onActivate() { registerMouse(); ldown=false; rdown=false; } void onDeactivate() { unregisterMouse(); } void onMouse(SMouseEvent& args) { switch(args.mouseEvent) { case EMIE_LMOUSE_PRESSED_DOWN: ldown=true; oldX=args.x; oldY=args.y; break; case EMIE_RMOUSE_PRESSED_DOWN: rdown=true; oldX=args.x; oldY=args.y; break; case EMIE_LMOUSE_LEFT_UP: ldown=false; break; case EMIE_RMOUSE_LEFT_UP: rdown=false; break; case EMIE_MOUSE_MOVED: core::vector3df rotVect; if(ldown) { rotVect=core::vector3df(0,(f32)(args.x-oldX),(f32)(oldY-args.y)); } if(rdown) { rotVect=core::vector3df((f32)(oldY-args.y),0,0); } ProjectLevel* level=(ProjectLevel*)(manager->getCurrentLevel()); ISceneNode* node=level->getSelectedNode(); if(node&&(node!=manager->getCore()->getGraphicDevice()->getSceneManager()->getRootSceneNode())) { node->setRotation(node->getRotation()+rotVect); node->updateAbsolutePosition(); } oldX=args.x; oldY=args.y; break; } } protected: bool ldown; bool rdown; int oldX; int oldY; }; class ScaleTool:public ITool { public: ScaleTool() :ITool() { image="resources/ui/scale.png"; toolTipText=L"Scale a scene node"; } void onActivate() { registerMouse(); ldown=false; rdown=false; } void onDeactivate() { unregisterMouse(); } void onMouse(SMouseEvent& args) { switch(args.mouseEvent) { case EMIE_LMOUSE_PRESSED_DOWN: ldown=true; oldX=args.x; oldY=args.y; break; case EMIE_RMOUSE_PRESSED_DOWN: rdown=true; oldX=args.x; oldY=args.y; break; case EMIE_LMOUSE_LEFT_UP: ldown=false; break; case EMIE_RMOUSE_LEFT_UP: rdown=false; break; case EMIE_MOUSE_MOVED: core::vector3df scaleVect; if(ldown) { scaleVect=core::vector3df((f32)(args.x-oldX),0,(f32)(oldY-args.y)); } if(rdown) { scaleVect=core::vector3df(0,(f32)(oldY-args.y),0); } scaleVect=scaleVect/800; core::matrix4 m; core::vector3df camRot=manager->getCore()->getGraphicDevice()->getSceneManager()->getActiveCamera()->getRotation(); camRot.X=0; m.setRotationDegrees(camRot); m.transformVect(scaleVect); ProjectLevel* level=(ProjectLevel*)(manager->getCurrentLevel()); ISceneNode* node=level->getSelectedNode(); if(node&&(node!=manager->getCore()->getGraphicDevice()->getSceneManager()->getRootSceneNode())) { scaleVect=scaleVect*node->getAbsolutePosition().getDistanceFrom(manager->getCore()->getGraphicDevice()->getSceneManager()->getActiveCamera()->getPosition()); node->setScale(node->getScale()+scaleVect); node->updateAbsolutePosition(); } oldX=args.x; oldY=args.y; break; } } protected: bool ldown; bool rdown; int oldX; int oldY; }; class RunNodeScript:public ITool { public: RunNodeScript() :ITool() { toggle=false; image="resources/ui/script.bmp"; toolTipText=L"Run the script in a node"; } void onActivate() { ProjectLevel* level=(ProjectLevel*)(manager->getCurrentLevel()); ISceneNode* node=level->getSelectedNode(); const char* script=level->getData(node); if(script) manager->getCore()->getScriptVM()->ExecuteString(script); } }; class CloneTool:public ITool { public: CloneTool() { toggle=false; image="resources/ui/clone.png"; toolTipText=L"Clone the selected node"; } void onActivate() { ProjectLevel* level=(ProjectLevel*)(manager->getCurrentLevel()); ISceneNode* node=level->getSelectedNode(); if(node) { ISceneNode* newNode=node->clone(); if(newNode) { newNode->setDebugDataVisible(EDS_OFF); level->updateNodeList(); } if(newNode&&(level->getData(node))) level->setData(newNode,level->getData(node)); } } }; class LoadMeshTool:public ITool { public: LoadMeshTool() { toggle=false; image="resources/ui/clone.png"; toolTipText=L"Load a new mesh"; } void onActivate() { ProjectLevel* level=(ProjectLevel*)(manager->getCurrentLevel()); manager->getCore()->getFileSystem()->changeWorkingDirectoryTo(level->setting->meshPath.c_str()); level->getFile(L"Select a mesh to load",new sgfMethodDelegate<LoadMeshTool,const char*>(this,&LoadMeshTool::loadMesh)); //manager->getCore()->getFileSystem()->changeWorkingDirectoryTo(level->setting->workingDir.c_str()); } void loadMesh(const char*& file) { if(!file) return; ProjectLevel* level=(ProjectLevel*)(manager->getCurrentLevel()); stringc relativePath(file); int pos=relativePath.find(level->setting->meshPath.c_str()); int meshPathLen=level->setting->workingDir.size(); if(pos>=0) { relativePath=relativePath.subString(meshPathLen+1,relativePath.size()-meshPathLen-1); } relativePath.replace('\\','/'); ISceneManager* smgr=manager->getCore()->getGraphicDevice()->getSceneManager(); if(!smgr->getMeshCache()->isMeshLoaded(relativePath.c_str()))//if not loaded { if(smgr->getMesh(relativePath.c_str()))//if loading is successful { static wchar_t wideCharBuffer[400]; wideCharBuffer[0]='\0'; mbstowcs(wideCharBuffer,relativePath.c_str(),400); level->meshList->addItem(wideCharBuffer); } } } }; class CreateAnimatedMeshTool:public ITool { public: CreateAnimatedMeshTool() { toggle=false; image="resources/ui/clone.png"; toolTipText=L"Create an animated mesh"; } void onActivate() { ProjectLevel* level=(ProjectLevel*)(manager->getCurrentLevel()); if(level->meshList->getSelected()==-1) return; const wchar_t* mesh=level->meshList->getListItem(level->meshList->getSelected()); static char charBuffer[400]; charBuffer[0]='\0'; wcstombs(charBuffer,mesh,400); vector3df trans(0,0,100); vector3df pos=level->camera->getAbsolutePosition(); matrix4 m; m.setRotationDegrees(level->camera->getRotation()); m.transformVect(trans); pos+=trans;//put the mesh in front of camera ISceneManager* smgr=manager->getCore()->getGraphicDevice()->getSceneManager(); smgr->addAnimatedMeshSceneNode(smgr->getMesh(charBuffer),0,-1,pos); level->updateNodeList(); } }; #endif
[ "doqkhanh@52f955dd-904d-0410-b1ed-9fe3d3cbfe06" ]
[ [ [ 1, 402 ] ] ]
fe10a691b5d7eae3e026515f31a05e388cf0d4e6
6e4f9952ef7a3a47330a707aa993247afde65597
/PROJECTS_ROOT/SmartWires/SmartWndSizer/ResizeableDialog.cpp
794e09f849b9a1adab149fa14e7fb41f1cc60a01
[]
no_license
meiercn/wiredplane-wintools
b35422570e2c4b486c3aa6e73200ea7035e9b232
134db644e4271079d631776cffcedc51b5456442
refs/heads/master
2021-01-19T07:50:42.622687
2009-07-07T03:34:11
2009-07-07T03:34:11
34,017,037
2
1
null
null
null
null
UTF-8
C++
false
false
11,456
cpp
/****************************************************************************** $Author$ $Modtime$ $Revision$ Description: Implementation of class "CResizeableDialog" (resizeable dialog box with smart controls) $Log$ ******************************************************************************/ #include "stdafx.h" #include "ResizeableDialog.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif /*** Definition of class "CResizeableDialog" *********************************/ const UINT CResizeableDialog::ATTACH_TO_LEFT_EDGE = 0x01; const UINT CResizeableDialog::ATTACH_TO_RIGHT_EDGE = 0x02; const UINT CResizeableDialog::ATTACH_TO_VERTICAL_EDGES = CResizeableDialog::ATTACH_TO_LEFT_EDGE | CResizeableDialog::ATTACH_TO_RIGHT_EDGE; const UINT CResizeableDialog::ATTACH_TO_TOP_EDGE = 0x04; const UINT CResizeableDialog::ATTACH_TO_BOTTOM_EDGE = 0x08; const UINT CResizeableDialog::ATTACH_TO_HORIZONTAL_EDGES = CResizeableDialog::ATTACH_TO_TOP_EDGE | CResizeableDialog::ATTACH_TO_BOTTOM_EDGE; const UINT CResizeableDialog::ATTACH_TO_ALL_EDGES = CResizeableDialog::ATTACH_TO_VERTICAL_EDGES | CResizeableDialog::ATTACH_TO_HORIZONTAL_EDGES; const UINT CResizeableDialog::CENTER_HORIZONTAL = 0x10; const UINT CResizeableDialog::CENTER_VERTICAL = 0x20; const UINT CResizeableDialog::CENTER = CResizeableDialog::CENTER_HORIZONTAL | CResizeableDialog::CENTER_VERTICAL; const int CResizeableDialog::m_nMaxStandardWidth = 600; const int CResizeableDialog::m_nMaxStandardHeight = 400; /*** Constructor *************************************************************/ CResizeableDialog::CResizeableDialog(UINT nIDTemplate, CWnd* pParentWnd): CDialog(nIDTemplate, pParentWnd) { //{{AFX_DATA_INIT(CResizeableDialog) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT bMiniScroll=0; iGlobalOffsetX=0; iGlobalOffsetY=0; m_nScreenWidth = GetSystemMetrics(SM_CXSCREEN); m_nScreenHeight = GetSystemMetrics(SM_CYSCREEN); m_nMinWidth = -1; m_nMinHeight = -1; m_nMaxWidth = -1; m_nMaxHeight = -1; m_bNotYetMaximized = true; } /*** Destructor **************************************************************/ CResizeableDialog::~CResizeableDialog() { for (POSITION pos = m_mapCtrls.GetStartPosition(); pos;) { UINT nID; CtrlData* pCtrlData; m_mapCtrls.GetNextAssoc(pos, nID, pCtrlData); m_mapCtrls.RemoveKey (nID); delete pCtrlData; } } /*** Public member functions *************************************************/ /*** Register control to be resized or centered ******************************/ UINT CResizeableDialog::RegisterControl(UINT nID, UINT nSmartMode) { CtrlData* pCtrlData; if (m_mapCtrls.Lookup(nID, pCtrlData)) { ASSERT(false); return 0; } else { // check for inconsistent and unnecessary parameters if (nSmartMode & ATTACH_TO_VERTICAL_EDGES) { if (nSmartMode & CENTER_HORIZONTAL) { ASSERT(false); nSmartMode &= ~(ATTACH_TO_VERTICAL_EDGES | CENTER_HORIZONTAL); } if (!(nSmartMode & ATTACH_TO_RIGHT_EDGE)) nSmartMode &= ~ATTACH_TO_LEFT_EDGE; } if (nSmartMode & ATTACH_TO_HORIZONTAL_EDGES) { if (nSmartMode & CENTER_VERTICAL) { ASSERT(false); nSmartMode &= ~(ATTACH_TO_HORIZONTAL_EDGES | CENTER_VERTICAL); } if (!(nSmartMode & ATTACH_TO_BOTTOM_EDGE)) nSmartMode &= ~ATTACH_TO_TOP_EDGE; } if (nSmartMode) { pCtrlData = new CtrlData; pCtrlData->m_nSmartMode = nSmartMode; // calculate distances between control and the edges of the client area // of this dialog box CRect rectThis(m_rectOrig); ClientToScreen(rectThis); CRect rectCtrl; GetDlgItem(nID)->GetWindowRect(rectCtrl); pCtrlData->m_rectDistances.left = rectCtrl.left - rectThis.left; pCtrlData->m_rectDistances.right = rectThis.right - rectCtrl.right; pCtrlData->m_rectDistances.top = rectCtrl.top - rectThis.top; pCtrlData->m_rectDistances.bottom = rectThis.bottom - rectCtrl.bottom; m_mapCtrls[nID] = pCtrlData; } } return nSmartMode; } /*** Set maximum size to current size ****************************************/ void CResizeableDialog::ThisSizeIsMaxSize() { CRect rect; GetWindowRect(rect); m_nMaxWidth = rect.Width(); m_nMaxHeight = rect.Height(); } /*** Set minimum size to current size ****************************************/ void CResizeableDialog::ThisSizeIsMinSize() { CRect rect; GetWindowRect(rect); m_nMinWidth = rect.Width(); m_nMinHeight = rect.Height(); } /*** Protected member functions **********************************************/ /*** Data exchange: member variables <--> controls ***************************/ void CResizeableDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CResizeableDialog) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } /*** Windows needs to know the maximized size and position *******************/ void CResizeableDialog::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { if (m_nMaxWidth != -1 && m_nMaxHeight != -1) { if (m_bNotYetMaximized && !IsIconic() && !IsZoomed()) { // maximize the window centered to the previous restored position CRect rect; GetWindowRect(rect); // calculate position of maximized window rect.left -= (m_nMaxWidth - rect.Width()) / 2; rect.top -= (m_nMaxHeight - rect.Height()) / 2; // correct position of maximized window to avoid clipping if (rect.left + m_nMaxWidth > m_nScreenWidth) rect.left = m_nScreenWidth - m_nMaxWidth; if (rect.top + m_nMaxHeight > m_nScreenHeight) rect.top = m_nScreenHeight - m_nMaxHeight; if (rect.left < 0) rect.left = 0; if (rect.top < 0) rect.top = 0; lpMMI->ptMaxPosition = rect.TopLeft(); } lpMMI->ptMaxSize.x = m_nMaxWidth; lpMMI->ptMaxSize.y = m_nMaxHeight; lpMMI->ptMaxTrackSize.x = m_nMaxWidth; lpMMI->ptMaxTrackSize.y = m_nMaxHeight; } if (m_nMinWidth != -1 && m_nMinHeight != -1) { lpMMI->ptMinTrackSize.x = m_nMinWidth; lpMMI->ptMinTrackSize.y = m_nMinHeight; } CDialog::OnGetMinMaxInfo(lpMMI); } /*** Called before the first display of the dialog box ***********************/ BOOL CResizeableDialog::OnInitDialog() { CDialog::OnInitDialog(); // remember original (= minimum) size GetWindowRect(m_rectOrig); m_nMinWidth = m_rectOrig.Width(); m_nMinHeight = m_rectOrig.Height(); GetClientRect(m_rectOrig); // calculate standard size m_nStandardWidth = m_nScreenWidth / 2; m_nStandardHeight = m_nScreenHeight / 2; if (m_nStandardWidth < m_nMinWidth || m_nStandardHeight < m_nMinHeight) { m_nStandardWidth = m_nMinWidth; m_nStandardHeight = m_nMinHeight; } else { if (m_nStandardWidth > m_nMaxStandardWidth) m_nStandardWidth = m_nMaxStandardWidth; if (m_nStandardHeight > m_nMaxStandardHeight) m_nStandardHeight = m_nMaxStandardHeight; } m_nStandardXPos = (m_nScreenWidth - m_nStandardWidth) / 2; m_nStandardYPos = (m_nScreenHeight - m_nStandardHeight) / 2; return TRUE; } /*** The dialog box will be repainted ****************************************/ void CResizeableDialog::OnPaint() { CPaintDC dc(this); // device context for painting if (!IsZoomed()) { // draw size grip to signal that the dialog box can be resized GetClientRect(rLastGripRect); rLastGripRect.left = rLastGripRect.right - GetSystemMetrics(SM_CXHSCROLL); rLastGripRect.top = rLastGripRect.bottom - GetSystemMetrics(SM_CYVSCROLL); if(bMiniScroll){ rLastGripRect.left += bMiniScroll; rLastGripRect.left += bMiniScroll; } dc.DrawFrameControl(rLastGripRect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP); } } /*** The size of the dialog box has been changed *****************************/ void CResizeableDialog::ApplyLayout() { CRect rectThis; GetClientRect (rectThis); ClientToScreen(rectThis); for (POSITION pos = m_mapCtrls.GetStartPosition(); pos;) { UINT nID; CtrlData* pCtrlData; m_mapCtrls.GetNextAssoc(pos, nID, pCtrlData); CWnd* pCtrl = GetDlgItem(nID); if(pCtrl && pCtrl->IsWindowEnabled()){ CRect rectCtrl; pCtrl->GetWindowRect(rectCtrl); int nCtrlWidth = rectCtrl.Width(); int nCtrlHeight = rectCtrl.Height(); // update control coordinates if (pCtrlData->m_nSmartMode & ATTACH_TO_ALL_EDGES) { if (pCtrlData->m_nSmartMode & ATTACH_TO_LEFT_EDGE) { rectCtrl.left = rectThis.left + pCtrlData->m_rectDistances.left; if (!(pCtrlData->m_nSmartMode & ATTACH_TO_RIGHT_EDGE)) rectCtrl.right = rectCtrl.left + nCtrlWidth; } if (pCtrlData->m_nSmartMode & ATTACH_TO_RIGHT_EDGE) { rectCtrl.right = rectThis.right - pCtrlData->m_rectDistances.right; if (!(pCtrlData->m_nSmartMode & ATTACH_TO_LEFT_EDGE)) rectCtrl.left = rectCtrl.right - nCtrlWidth; } if (pCtrlData->m_nSmartMode & ATTACH_TO_TOP_EDGE) { rectCtrl.top = rectThis.top + pCtrlData->m_rectDistances.top; if (!(pCtrlData->m_nSmartMode & ATTACH_TO_BOTTOM_EDGE)) rectCtrl.bottom = rectCtrl.top + nCtrlHeight; } if (pCtrlData->m_nSmartMode & ATTACH_TO_BOTTOM_EDGE) { rectCtrl.bottom = rectThis.bottom - pCtrlData->m_rectDistances.bottom; if (!(pCtrlData->m_nSmartMode & ATTACH_TO_TOP_EDGE)) rectCtrl.top = rectCtrl.bottom - nCtrlHeight; } } if (pCtrlData->m_nSmartMode & CENTER) { if (pCtrlData->m_nSmartMode & CENTER_HORIZONTAL) { rectCtrl.left = rectThis.left + (rectThis.Width() - nCtrlWidth) / 2; rectCtrl.right = rectCtrl.left + nCtrlWidth; } if (pCtrlData->m_nSmartMode & CENTER_VERTICAL) { rectCtrl.top = rectThis.top + (rectThis.Height() - nCtrlHeight) / 2; rectCtrl.bottom = rectCtrl.top + nCtrlHeight; } } // convert control coordinates from screen coordinates to coordinates // relative to the client area of this dialog box rectCtrl.left -= rectThis.left; rectCtrl.right -= rectThis.left; rectCtrl.top -= rectThis.top; rectCtrl.bottom -= rectThis.top; rectCtrl.OffsetRect(iGlobalOffsetX,iGlobalOffsetY); // resize/move control pCtrl->MoveWindow(rectCtrl); } } Invalidate(); // redraw window to erase old size grip } void CResizeableDialog::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); if (nType == SIZE_MAXIMIZED || nType == SIZE_RESTORED) { ApplyLayout(); } } /*** The position of this window has been changed ****************************/ void CResizeableDialog::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) { CDialog::OnWindowPosChanged(lpwndpos); if (IsZoomed()) // remember that window has been maximized m_bNotYetMaximized = false; } /*** Table of message handlers ***********************************************/ BEGIN_MESSAGE_MAP(CResizeableDialog, CDialog) //{{AFX_MSG_MAP(CResizeableDialog) ON_WM_PAINT() ON_WM_SIZE() ON_WM_GETMINMAXINFO() ON_WM_WINDOWPOSCHANGED() //}}AFX_MSG_MAP END_MESSAGE_MAP()
[ "wplabs@3fb49600-69e0-11de-a8c1-9da277d31688" ]
[ [ [ 1, 372 ] ] ]
79cc2bfde09b4210e1d40feb495767d976dcbad8
f13f46fbe8535a7573d0f399449c230a35cd2014
/JelloMan/BaseGrid.cpp
411beabe707f4607bfd3f573417d1278d20c7ee6
[]
no_license
fangsunjian/jello-man
354f1c86edc2af55045d8d2bcb58d9cf9b26c68a
148170a4834a77a9e1549ad3bb746cb03470df8f
refs/heads/master
2020-12-24T16:42:11.511756
2011-06-14T10:16:51
2011-06-14T10:16:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
895
cpp
#include "BaseGrid.h" #include "ContentManager.h" // CONSTRUCTOR - DESTRUCTOR BaseGrid::BaseGrid() : m_pEffect(0), m_mtxWorld(Matrix::Identity), m_pBaseGrid(0), m_pBaseGridCenter(0) { } BaseGrid::~BaseGrid() { } // GENERAL void BaseGrid::Init() { m_pEffect = Content->LoadEffect<PosColEffect>(_T("../Content/Effects/poscol.fx")); m_pBaseGrid = Content->LoadSpline(_T("../Content/Models/basegrid.obj")); m_pBaseGridCenter = Content->LoadSpline(_T("../Content/Models/basegrid_center.obj")); } void BaseGrid::Draw(const RenderContext* pRenderContext) { m_pEffect->SetWorldViewProjection(m_mtxWorld * pRenderContext->GetCamera()->GetViewProjection()); m_pEffect->SetColor(Color(0.f,.1f,.2f,1.f)); m_pBaseGrid->Draw(m_pEffect); m_pEffect->SetColor(Color(0.f,.25f,.5f,1.f)); m_pBaseGridCenter->Draw(m_pEffect); }
[ "[email protected]", "bastian.damman@0fb7bab5-1bf9-c5f3-09d9-7611b49293d6" ]
[ [ [ 1, 20 ], [ 22, 36 ] ], [ [ 21, 21 ] ] ]
40bf2950092964695c6bcea6989de21b52841458
2dbbca065b62a24f47aeb7ec5cd7a4fd82083dd4
/OUAN/OUAN/Src/Graphics/Volume/VolumeRenderable.cpp
5a9c78a92662506a2ace3ee8a7f9e1fcab70a1fe
[]
no_license
juanjmostazo/once-upon-a-night
9651dc4dcebef80f0475e2e61865193ad61edaaa
f8d5d3a62952c45093a94c8b073cbb70f8146a53
refs/heads/master
2020-05-28T05:45:17.386664
2010-10-06T12:49:50
2010-10-06T12:49:50
38,101,059
1
1
null
null
null
null
UTF-8
C++
false
false
6,874
cpp
#include "OUAN_Precompiled.h" /* ----------------------------------------------------------------------------- This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org/ Copyright (c) 2000-2006 Torus Knot Software Ltd Also see acknowledgements in Readme.html You may use this sample code for anything you like, it is not covered by the LGPL like the rest of the engine. ----------------------------------------------------------------------------- */ #include "VolumeRenderable.h" using namespace Ogre; VolumeRenderable::VolumeRenderable(size_t nSlices, float size, const String &texture): mSlices(nSlices), mSize(size), mTexture(texture) { mRadius = sqrtf(size*size+size*size+size*size)/2.0f; mBox = Ogre::AxisAlignedBox(-size, -size, -size, size, size, size); // No shadows setCastShadows(false); initialise(); } VolumeRenderable::~VolumeRenderable() { // Remove private material MaterialManager::getSingleton().remove(mTexture); // need to release IndexData and vertexData created for renderable delete mRenderOp.indexData; delete mRenderOp.vertexData; } void VolumeRenderable::_notifyCurrentCamera( Camera* cam ) { MovableObject::_notifyCurrentCamera(cam); // Fake orientation toward camera Vector3 zVec = getParentNode()->_getDerivedPosition() - cam->getDerivedPosition(); zVec.normalise(); Vector3 fixedAxis = cam->getDerivedOrientation() * Vector3::UNIT_Y ; Vector3 xVec = fixedAxis.crossProduct( zVec ); xVec.normalise(); Vector3 yVec = zVec.crossProduct( xVec ); yVec.normalise(); Quaternion oriQuat; oriQuat.FromAxes( xVec, yVec, zVec ); oriQuat.ToRotationMatrix(mFakeOrientation); Matrix3 tempMat; Quaternion q = getParentNode()->_getDerivedOrientation().UnitInverse() * oriQuat ; q.ToRotationMatrix(tempMat); Matrix4 rotMat = Matrix4::IDENTITY; rotMat = tempMat; rotMat.setTrans(Vector3(0.5f, 0.5f, 0.5f)); mUnit->setTextureTransform(rotMat); } void VolumeRenderable::getWorldTransforms( Matrix4* xform ) const { Matrix4 destMatrix(Matrix4::IDENTITY); // this initialisation is needed const Vector3 &position = getParentNode()->_getDerivedPosition(); const Vector3 &scale = getParentNode()->_getDerivedScale(); Matrix3 scale3x3(Matrix3::ZERO); scale3x3[0][0] = scale.x; scale3x3[1][1] = scale.y; scale3x3[2][2] = scale.z; destMatrix = mFakeOrientation * scale3x3; destMatrix.setTrans(position); *xform = destMatrix; } void VolumeRenderable::initialise() { // Create geometry size_t nvertices = mSlices*4; // n+1 planes size_t elemsize = 3*3; size_t dsize = elemsize*nvertices; size_t x; Ogre::IndexData *idata = new Ogre::IndexData(); Ogre::VertexData *vdata = new Ogre::VertexData(); // Create structures float *vertices = new float[dsize]; float coords[4][2] = { {0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 0.0f}, {1.0f, 1.0f} }; for(x=0; x<mSlices; x++) { for(size_t y=0; y<4; y++) { float xcoord = coords[y][0]-0.5; float ycoord = coords[y][1]-0.5; float zcoord = -((float)x/(float)(mSlices-1) - 0.5f); // 1.0f .. a/(a+1) // coordinate vertices[x*4*elemsize+y*elemsize+0] = xcoord*(mSize/2.0f); vertices[x*4*elemsize+y*elemsize+1] = ycoord*(mSize/2.0f); vertices[x*4*elemsize+y*elemsize+2] = zcoord*(mSize/2.0f); // normal vertices[x*4*elemsize+y*elemsize+3] = 0.0f; vertices[x*4*elemsize+y*elemsize+4] = 0.0f; vertices[x*4*elemsize+y*elemsize+5] = 1.0f; // tex vertices[x*4*elemsize+y*elemsize+6] = xcoord*sqrtf(3.0f); vertices[x*4*elemsize+y*elemsize+7] = ycoord*sqrtf(3.0f); vertices[x*4*elemsize+y*elemsize+8] = zcoord*sqrtf(3.0f); } } unsigned short *faces = new unsigned short[mSlices*6]; for(x=0; x<mSlices; x++) { faces[x*6+0] = x*4+0; faces[x*6+1] = x*4+1; faces[x*6+2] = x*4+2; faces[x*6+3] = x*4+1; faces[x*6+4] = x*4+2; faces[x*6+5] = x*4+3; } // Setup buffers vdata->vertexStart = 0; vdata->vertexCount = nvertices; VertexDeclaration* decl = vdata->vertexDeclaration; VertexBufferBinding* bind = vdata->vertexBufferBinding; size_t offset = 0; decl->addElement(0, offset, VET_FLOAT3, VES_POSITION); offset += VertexElement::getTypeSize(VET_FLOAT3); decl->addElement(0, offset, VET_FLOAT3, VES_NORMAL); offset += VertexElement::getTypeSize(VET_FLOAT3); decl->addElement(0, offset, VET_FLOAT3, VES_TEXTURE_COORDINATES); offset += VertexElement::getTypeSize(VET_FLOAT3); HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton().createVertexBuffer( offset, nvertices, HardwareBuffer::HBU_STATIC_WRITE_ONLY); bind->setBinding(0, vbuf); vbuf->writeData(0, vbuf->getSizeInBytes(), vertices, true); HardwareIndexBufferSharedPtr ibuf = HardwareBufferManager::getSingleton(). createIndexBuffer( HardwareIndexBuffer::IT_16BIT, mSlices*6, HardwareBuffer::HBU_STATIC_WRITE_ONLY); idata->indexBuffer = ibuf; idata->indexCount = mSlices*6; idata->indexStart = 0; ibuf->writeData(0, ibuf->getSizeInBytes(), faces, true); // Delete temporary buffers delete [] vertices; delete [] faces; // Now make the render operation mRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST; mRenderOp.indexData = idata; mRenderOp.vertexData = vdata; mRenderOp.useIndexes = true; // Create a brand new private material MaterialPtr material = MaterialManager::getSingleton().create(mTexture, "VolumeRenderable", false, 0); // Manual, loader // Remove pre-created technique from defaults material->removeAllTechniques(); // Create a techinique and a pass and a texture unit Technique * technique = material->createTechnique(); Pass * pass = technique->createPass(); TextureUnitState * textureUnit = pass->createTextureUnitState(); // Set pass parameters pass->setSceneBlending(SBT_TRANSPARENT_ALPHA); pass->setDepthWriteEnabled(false); pass->setCullingMode(CULL_NONE); pass->setLightingEnabled(false); // Set texture unit parameters textureUnit->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); textureUnit->setTextureName(mTexture, TEX_TYPE_3D); textureUnit->setTextureFiltering(TFO_TRILINEAR); mUnit = textureUnit; m_pMaterial = material; } Ogre::Real VolumeRenderable::getBoundingRadius() const { return mRadius; } Ogre::Real VolumeRenderable::getSquaredViewDepth(const Ogre::Camera* cam) const { Ogre::Vector3 min, max, mid, dist; min = mBox.getMinimum(); max = mBox.getMaximum(); mid = ((min - max) * 0.5) + min; dist = cam->getDerivedPosition() - mid; return dist.squaredLength(); }
[ "ithiliel@1610d384-d83c-11de-a027-019ae363d039", "juanj.mostazo@1610d384-d83c-11de-a027-019ae363d039" ]
[ [ [ 1, 2 ], [ 17, 17 ] ], [ [ 3, 16 ], [ 18, 231 ] ] ]
197fe7812d5590d8fc8d8fd36de17c483a8a8828
e8c9bfda96c507c814b3378a571b56de914eedd4
/engineTest/configurator.cpp
c0752b0526dc5197bd85e8e4f24dc109fa2b4cfd
[]
no_license
VirtuosoChris/quakethecan
e2826f832b1a32c9d52fb7f6cf2d972717c4275d
3159a75117335f8e8296f699edcfe87f20d97720
refs/heads/master
2021-01-18T09:20:44.959838
2009-04-20T13:32:36
2009-04-20T13:32:36
32,121,382
0
0
null
null
null
null
UTF-8
C++
false
false
943
cpp
#include "irrlicht.h" using namespace irr; using namespace io; #include <string> // we use STL strings to store data in this example void readConfig() { IrrXMLReader* xml = createIrrXMLReader("../config/config.xml"); // strings for storing the data we want to get out of the file std::string modelFile; std::string messageText; std::string caption; // parse the file until end reached while(xml && xml->read()) { switch(xml->getNodeType()) { case EXN_TEXT: // in this xml file, the only text which occurs is the messageText messageText = xml->getNodeData(); break; case EXN_ELEMENT: { if (!strcmp("startUpModel", xml->getNodeName())) modelFile = xml->getAttributeValue("file"); else if (!strcmp("messageText", xml->getNodeName())) caption = xml->getAttributeValue("caption"); } break; } } // delete the xml parser after usage delete xml; }
[ "cthomas.mail@f96ad80a-2d29-11de-ba44-d58fe8a9ce33" ]
[ [ [ 1, 39 ] ] ]
c83c8e738e9a078768b391fa4767e798c774fb6c
16d8b25d0d1c0f957c92f8b0d967f71abff1896d
/obse/obse/Commands_FileIO.cpp
b58dfda86b1b2466bbc6446bde7394a3a248d25e
[]
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
4,561
cpp
#include <stdio.h> #include <string.h> #include "Commands_FileIO.h" #include "GameAPI.h" #ifdef OBLIVION /* Return a float value from the given file. * syntax: FloatFromFile filename line_number * shortname: ffromf * * Gets a float from the given line from the file [filename], starting with line 0. * -If line_number <= 0, get the first line of the file. * -If line_number >= (lines_in_file - 1), get the last line of the file. * * -Filename is relative to the path where Oblivion.exe is located. * -Integers can be read from file, but will be returned as floats (range limits on floats may apply). * -This function has been tested using the Oblivion console. More testing might be needed in scripts to make sure the * returned value is correct. * -Prints an error to the console and returns nothing if the file is not found. */ bool Cmd_FloatFromFile_Execute(COMMAND_ARGS) { *result = 0.0; char lineBuffer[BUFSIZ]; FILE* fileptr; int currLine = 0; char filename[129]; int linePos; //just return with error message if file can't be opened if (!(ExtractArgs(paramInfo, arg1, opcodeOffsetPtr, thisObj, arg3, scriptObj, eventList, &filename, &linePos)) || fopen_s(&fileptr, filename, "r")) { Console_Print ("File %s could not be opened.", filename); return true; } //fgets() will move the file pointer to next line for us, allowing for variable line lengths while (fgets (lineBuffer, BUFSIZ, fileptr) && currLine < linePos) { currLine++; } *result = (float) atof(lineBuffer); //Console_Print ("Line %d: %f", linePos, *result); fclose (fileptr); return true; } /* Write float to specified line in file * syntax: FloatToFile filename line_number float_to_write * shortname: ftof * * Writes the specified floating-point value to the file at the given line number (starting at 0). This will replace * whatever used to be at that line. This function copies the given file to "temp.txt" and replaces the given line while * doing so. The contents of the temp file are then copied back to the original, updating it. * -If line_number is < 0 or > (lines_in_file - 1), the function will not write anything. * * -Filename is relative to where Oblivion.exe is located. * -Integers can be written, but will be written as floats (range limits on floats may apply), so 5 will be written * as 5.00000. * -This was tested using the console, with FloatFromFile to verify results. It should work fine in a script. * -Prints error message to console and does nothing if file does not exist. */ bool Cmd_FloatToFile_Execute(COMMAND_ARGS) { *result = 0.0; char lineBuffer[BUFSIZ]; FILE* fileptr; FILE* tempptr; int currLine = 0; char filename[128]; int linePos; float input; if (!(ExtractArgs(paramInfo, arg1, opcodeOffsetPtr, thisObj, arg3, scriptObj, eventList, &filename, &linePos, &input)) || fopen_s(&fileptr, filename, "r")) { Console_Print ("File %s could not be opened.", filename); return true; } fopen_s (&tempptr, "temp.txt", "w"); //Console_Print ("input: %f", input); //read from original to temp while (fgets (lineBuffer, BUFSIZ, fileptr)) { if (currLine == linePos) //replace line with given input { sprintf_s (lineBuffer, sizeof(lineBuffer), "%f\n", input); //Console_Print("wrote: %s",lineBuffer); } currLine++; fputs (lineBuffer, tempptr); } //is there a better way to change stream modes? fclose (tempptr); fclose (fileptr); fopen_s (&tempptr, "temp.txt", "r"); fopen_s (&fileptr, filename, "w"); //write data back to original file while (fgets (lineBuffer, BUFSIZ, tempptr)) { fputs (lineBuffer, fileptr); } fclose (tempptr); fclose (fileptr); return true; } #endif static ParamInfo kParams_ReadFromFile[2] = { {"string", kParamType_String, 0}, { "int", kParamType_Integer, 0} }; static ParamInfo kParams_WriteToFile[3] = { {"string", kParamType_String, 0}, { "int", kParamType_Integer, 0}, { "float", kParamType_Float, 0} }; CommandInfo kCommandInfo_FloatFromFile = { "FloatFromFile", "ffromf", 0, "Read a number from specified line in file", 0, 2, kParams_ReadFromFile, HANDLER(Cmd_FloatFromFile_Execute), Cmd_Default_Parse, NULL, 0 }; CommandInfo kCommandInfo_FloatToFile = { "FloatToFile", "ftof", 0, "Write a number to specified line in file", 0, 3, kParams_WriteToFile, HANDLER(Cmd_FloatToFile_Execute), Cmd_Default_Parse, NULL, 0 };
[ "masterfreek64@2644d07b-d655-0410-af38-4bee65694944" ]
[ [ [ 1, 159 ] ] ]
ca73252d29b2b17cff6d7096825bf4c1e6399e11
6c8c4728e608a4badd88de181910a294be56953a
/UiModule/Ether/View/Classical/TraditionalLoginWidget.h
f4cc621c460460ad6ab2c1a01ee82ca35d9c2374
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
caocao/naali
29c544e121703221fe9c90b5c20b3480442875ef
67c5aa85fa357f7aae9869215f840af4b0e58897
refs/heads/master
2021-01-21T00:25:27.447991
2010-03-22T15:04:19
2010-03-22T15:04:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,267
h
// For conditions of distribution and use, see copyright notice in license.txt #ifndef incl_UiModule_TraditionalLoginWidget_h #define incl_UiModule_TraditionalLoginWidget_h #include "ui_TraditionalLoginWidget.h" #include <QTimer> namespace CoreUi { namespace Classical { class TraditionalLoginWidget : public QWidget, private Ui::TraditionalLoginWidget { Q_OBJECT public: TraditionalLoginWidget(QWidget *parent, QMap<QString,QString> stored_login_data); public slots: void RemoveEtherButton(); QMap<QString, QString> GetLoginInfo(); void StatusUpdate(bool connecting, QString message); private slots: void InitWidget(QMap<QString,QString> stored_login_data); void ParseInputAndConnect(); void UpdateProgressBar(); private: QTimer *progress_timer_; int progress_direction_; signals: void ConnectOpenSim(QMap<QString, QString>); void ConnectRealXtend(QMap<QString, QString>); void ConnectingUiUpdate(QString message); }; } } #endif // incl_UiModule_TraditionalLoginWidget_h
[ "[email protected]@5b2332b8-efa3-11de-8684-7d64432d61a3" ]
[ [ [ 1, 44 ] ] ]
4d2c9a17f8d8759e024cbc87752a9cc91b4d1306
e192bb584e8051905fc9822e152792e9f0620034
/tags/sources_0_1/base/implantation/noeud_composition.h
e2547881bf9a50ca539f51b116a1e5a6ec8ef260
[]
no_license
BackupTheBerlios/projet-univers-svn
708ffadce21f1b6c83e3b20eb68903439cf71d0f
c9488d7566db51505adca2bc858dab5604b3c866
refs/heads/master
2020-05-27T00:07:41.261961
2011-07-31T20:55:09
2011-07-31T20:55:09
40,817,685
0
0
null
null
null
null
ISO-8859-1
C++
false
false
2,356
h
/*************************************************************************** * Copyright (C) 2004 by Equipe Projet Univers * * [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.1 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 for more details. * * * * You should have received a copy of the GNU General Lesser 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 _PU_BASE_NOEUD_COMPOSITION_H_ #define _PU_BASE_NOEUD_COMPOSITION_H_ #include "noeud_abstrait.h" namespace ProjetUnivers { namespace Base { template <class OBJET> class IterateurListeComposition ; /* CLASS NoeudComposition Classe des noeuds de ObCompositionList. */ template <class OBJET> class NoeudComposition : public NoeudAbstrait { public: ///////////////// // Constructeur. NoeudComposition(OBJET* _elt) ; ///////////////// // Libère l'élément . OBJET* Liberer() ; private: /////////////// // Elément. Composition< OBJET > element ; friend class IterateurListeComposition<OBJET> ; }; #include "noeud_composition.cxx" } } #endif
[ "rogma@fb75c231-3be1-0310-9bb4-c95e2f850c73" ]
[ [ [ 1, 67 ] ] ]
eacd68189640d55f8b2082d81862ac7164b82345
9d3fb15c6c417ce0f2354a11cdb094bdcf2e8a46
/nxtOSEK/etrobo2010sample_cpp/NXTway_GS.h
56842c5159c9050deb977bcaa0a29fcfc6b73fae
[]
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
UTF-8
C++
false
false
2,760
h
// // NXTway_GS.h // #ifndef NXTWAY_GS_H_ #define NXTWAY_GS_H_ #include "Vector.h" #include "Nxt.h" #include "GyroSensor.h" #include "Motor.h" #include "Clock.h" using namespace ecrobot; #include "NXTway_GS_data.h" #include "Driver.h" extern "C" { #include "balancer.h" }; /** * A wrapper class of NXTway-GS balancer C API */ class NXTway_GS { public: /** * Constructor. * @param nxt NXT device object * @param gyro Gyro Sensor device object * @param motorL Motor device object for left wheel * @param motorR Motor device object for right wheel */ NXTway_GS(const Nxt& nxt, const GyroSensor& gyro, Motor& motorL, Motor& motorR); /** * Calibrate the Gyro Sensor offset value dynamically. It takes approximately 400msec. * While calibrating the robot, robot should be held statically to measure the Gyro Sensor value at zero angular velocity. * @return Calibrated Gyro Sensor offset value */ S16 calGyroOffset(void); /** * Get Gyro Sensor offset value in use. * @return Gyro Sensor offset value in use. */ S16 getGyroOffset(void) { return mNxtwayGsData.gyroOffset; } /** * Set Gyro Sensor offset value. Gyro Sensor offset value means the sensor value at angular velocity is equal to zero. * @param offset Gyro Sensor offset value */ void setGyroOffset(S16 offset); /** * Get Motor PWM values calculated by NXTway-GS balancer. Inside of this API, NXTway-GS balancer is invoked to calculate the PWM values, * but the PWM values are not set to the motors. Thus the calculated PWM values should be set to the motors manually. * Note that this API might be useful to enhance the NXTway-GS control in conjunction with the NXTway-GS balancer. * @param cmd cmd.mX:Foward command/cmd.mY:Turn command * @return motor pwm values (mX:motor pwm for left wheel/mY:motor pwm for right wheel) */ VectorT<S8> calcPWM(VectorT<S16> cmd); /** * Reset NXTway-GS. (turn off the motors, reset motor encoders to zero and initialize NXTway-GS balancer) * @param offset Gyro Sensor offset value (optional) */ void reset(S16 offset=GyroSensor::DEFAULT_OFFSET); /** * Drive NXTway-GS by command. * @param cmd Robot control command (cmd.mX:forward, cmd.mY:turn) */ void drive(VectorT<S16> cmd); /** * Stop NXTway-GS. (turn off the motors and reset the motor encoders to zero) */ void stop(void); /** * Read NXTway-GS internal data (read only) * @return NXTway-GS internal data */ const NXTway_GS_data* readInternalData(void) const { return &mNxtwayGsData; } private: const Nxt& mrNxt; const GyroSensor& mrGyro; Motor& mrMotorL; Motor& mrMotorR; NXTway_GS_data mNxtwayGsData; }; #endif
[ [ [ 1, 98 ] ] ]
98f9ef435e8c9f235b4c96c1a08d914be7a0ff6d
27d5670a7739a866c3ad97a71c0fc9334f6875f2
/CPP/Targets/Nav2lib/symbian/SprocketTalker.h
347d9d0e967963799479ee298d77923f5c68871e
[ "BSD-3-Clause" ]
permissive
ravustaja/Wayfinder-S60-Navigator
ef506c418b8c2e6498ece6dcae67e583fb8a4a95
14d1b729b2cea52f726874687e78f17492949585
refs/heads/master
2021-01-16T20:53:37.630909
2010-06-28T09:51:10
2010-06-28T09:51:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,783
h
/* Copyright (c) 1999 - 2010, Vodafone Group Services Ltd 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 Vodafone Group Services Ltd nor the names of its 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 HOLDER 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. */ #ifndef SPROCKETTALKER_H #define SPROCKETTALKER_H class MSprocketTalker { public: virtual void ConnectedL() {} virtual void ReceiveMessageL(const class TDesC8& aMessage) = 0; virtual void Panic() {} }; #endif
[ [ [ 1, 26 ] ] ]
8ffb22c94a752b6531ac6296b769b4b8a5b253c6
e31046aee3ad2d4600c7f35aaeeba76ee2b99039
/trunk/libs/bullet/includes/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h
9d0d93f0acf1567a89beb5661ca1e5b8888cf9b3
[]
no_license
BackupTheBerlios/trinitas-svn
ddea265cf47aff3e8853bf6d46861e0ed3031ea1
7d3ff64a7d0e5ba37febda38e6ce0b2d0a4b6cca
refs/heads/master
2021-01-23T08:14:44.215249
2009-02-18T19:37:51
2009-02-18T19:37:51
40,749,519
0
0
null
null
null
null
UTF-8
C++
false
false
4,547
h
/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef SIMPLE_BROADPHASE_H #define SIMPLE_BROADPHASE_H #include "btOverlappingPairCache.h" struct btSimpleBroadphaseProxy : public btBroadphaseProxy { btVector3 m_min; btVector3 m_max; int m_nextFree; // int m_handleId; btSimpleBroadphaseProxy() {}; btSimpleBroadphaseProxy(const btPoint3& minpt,const btPoint3& maxpt,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,void* multiSapProxy) :btBroadphaseProxy(userPtr,collisionFilterGroup,collisionFilterMask,multiSapProxy), m_min(minpt),m_max(maxpt) { (void)shapeType; } SIMD_FORCE_INLINE void SetNextFree(int next) {m_nextFree = next;} SIMD_FORCE_INLINE int GetNextFree() const {return m_nextFree;} }; ///The SimpleBroadphase is just a unit-test for btAxisSweep3, bt32BitAxisSweep3, or btDbvtBroadphase, so use those classes instead. ///It is a brute force aabb culling broadphase based on O(n^2) aabb checks class btSimpleBroadphase : public btBroadphaseInterface { protected: int m_numHandles; // number of active handles int m_maxHandles; // max number of handles btSimpleBroadphaseProxy* m_pHandles; // handles pool void* m_pHandlesRawPtr; int m_firstFreeHandle; // free handles list int allocHandle() { btAssert(m_numHandles < m_maxHandles); int freeHandle = m_firstFreeHandle; m_firstFreeHandle = m_pHandles[freeHandle].GetNextFree(); m_numHandles++; return freeHandle; } void freeHandle(btSimpleBroadphaseProxy* proxy) { int handle = int(proxy-m_pHandles); btAssert(handle >= 0 && handle < m_maxHandles); proxy->SetNextFree(m_firstFreeHandle); m_firstFreeHandle = handle; m_numHandles--; } btOverlappingPairCache* m_pairCache; bool m_ownsPairCache; int m_invalidPair; inline btSimpleBroadphaseProxy* getSimpleProxyFromProxy(btBroadphaseProxy* proxy) { btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(proxy); return proxy0; } void validate(); protected: public: btSimpleBroadphase(int maxProxies=16384,btOverlappingPairCache* overlappingPairCache=0); virtual ~btSimpleBroadphase(); static bool aabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1); virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy); virtual void calculateOverlappingPairs(btDispatcher* dispatcher); virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher); virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher); btOverlappingPairCache* getOverlappingPairCache() { return m_pairCache; } const btOverlappingPairCache* getOverlappingPairCache() const { return m_pairCache; } bool testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); ///getAabb returns the axis aligned bounding box in the 'global' coordinate frame ///will add some transform later virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const { aabbMin.setValue(-1e30f,-1e30f,-1e30f); aabbMax.setValue(1e30f,1e30f,1e30f); } virtual void printStats() { // printf("btSimpleBroadphase.h\n"); // printf("numHandles = %d, maxHandles = %d\n",m_numHandles,m_maxHandles); } }; #endif //SIMPLE_BROADPHASE_H
[ "paradoxon@ab3bda7c-5b37-0410-9911-e7f4556ba333" ]
[ [ [ 1, 151 ] ] ]
2b4597931ec6c24195e41f440554f556b7d698ea
74c8da5b29163992a08a376c7819785998afb588
/NetAnimal/Game/Hunter/NewGameNeedle/UnitTest/include/RotationComponentUT.h
5bbe63473b5a9fa337ce228298779334cb906b91
[]
no_license
dbabox/aomi
dbfb46c1c9417a8078ec9a516cc9c90fe3773b78
4cffc8e59368e82aed997fe0f4dcbd7df626d1d0
refs/heads/master
2021-01-13T14:05:10.813348
2011-06-07T09:36:41
2011-06-07T09:36:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,025
h
#ifndef __Orz_UnitTest_RotationComponentUT__ #define __Orz_UnitTest_RotationComponentUT__ #include "UnitTestConfig.h" #include "CNewGameSceneInterface.h" #include "CGameNeedleInterface.h" #include "CRotationInterface.h" BOOST_AUTO_TEST_CASE(RotationComponentUT) { using namespace Orz; // ComponentPtr sceneComp = ComponentFactories::getInstance().create("NewGameScene"); // CNewGameSceneInterface * scene = sceneComp->queryInterface<CNewGameSceneInterface>(); ComponentPtr needleComp = ComponentFactories::getInstance().create("GameNeedle"); CGameNeedleInterface * needle = needleComp->queryInterface<CGameNeedleInterface>(); scene->load(); BOOST_CHECK(needle != NULL); //std::cout<<scene->getHelper(24); needle->load(scene->getHelper(CNewGameSceneInterface::Helper24)); //for(int i = 0; i< 25; ++i) //{ // std::cout<<scene->getHelper(CNewGameSceneInterface::HELPERS(i)); //} ComponentPtr rotationComp = ComponentFactories::getInstance().create("Rotation"); CRotationInterface * rotation = rotationComp->queryInterface<CRotationInterface>(); BOOST_CHECK(rotation != NULL); rotation->init(scene->getHelper(CNewGameSceneInterface::Helper24), CRotationInterface::Clockwise, 90.f); rotation->reset(0.f); rotation->play(100.f*3, 3.f); while( rotation->update(0.015f)) { UnitTestEnvironmen::system->run(); } TimeType time = 0.f; while(time<1.f) { time+= 0.015f; UnitTestEnvironmen::system->run(); } rotation->play(100.f*3, 3.f); while( rotation->update(0.015f)) { UnitTestEnvironmen::system->run(); } rotation->reset(120.f); rotation->play(360 * 3, 10.f); while( rotation->update(0.015f)) { UnitTestEnvironmen::system->run(); } time = 0.f; while(time<3.f) { time+= 0.015f; UnitTestEnvironmen::system->run(); } time = 0.f; while(time<3.f) { time+= 0.015f; UnitTestEnvironmen::system->run(); } scene->unload(); } #endif
[ [ [ 1, 102 ] ] ]
8910a8bfc1916e4475605d9b98d09cc96a34cda4
33f59b1ba6b12c2dd3080b24830331c37bba9fe2
/Depend/Foundation/Mathematics/Wm4Matrix2.cpp
28fca3b30d7cbfc7bef8f32a9f3e591d19e6a6fa
[]
no_license
daleaddink/flagship3d
4835c223fe1b6429c12e325770c14679c42ae3c6
6cce5b1ff7e7a2d5d0df7aa0594a70d795c7979a
refs/heads/master
2021-01-15T16:29:12.196094
2009-11-01T10:18:11
2009-11-01T10:18:11
37,734,654
1
0
null
null
null
null
UTF-8
C++
false
false
840
cpp
// Geometric Tools, Inc. // http://www.geometrictools.com // Copyright (c) 1998-2006. All Rights Reserved // // The Wild Magic Version 4 Foundation Library source code is supplied // under the terms of the license agreement // http://www.geometrictools.com/License/Wm4FoundationLicense.pdf // and may not be copied or disclosed except in accordance with the terms // of that agreement. #include "Wm4FoundationPCH.h" #include "Wm4Matrix2.h" using namespace Wm4; template<> const Matrix2<float> Matrix2<float>::ZERO( 0.0f,0.0f, 0.0f,0.0f); template<> const Matrix2<float> Matrix2<float>::IDENTITY( 1.0f,0.0f, 0.0f,1.0f); template<> const Matrix2<double> Matrix2<double>::ZERO( 0.0,0.0, 0.0,0.0); template<> const Matrix2<double> Matrix2<double>::IDENTITY( 1.0,0.0, 0.0,1.0);
[ "yf.flagship@e79fdf7c-a9d8-11de-b950-3d5b5f4ea0aa" ]
[ [ [ 1, 27 ] ] ]
8e76f63021d02f1c02a675b5eb3e22204dac7a5f
b2a86534c6e4feebb1e4cc8d2371fb3f93e13da0
/colosseum/colosseumCtrl.cpp
4b04c8f30c8d108e23b0e38dc82f516e7c167d0c
[]
no_license
emad-elsaid/Colosseum-plugin
192c8ebb535e177773e706a7146b4dad9bbe3da9
08d2b524f9abe72752361c62d15f588ae78cef42
refs/heads/master
2021-05-27T19:31:11.479132
2010-12-17T22:27:35
2010-12-17T22:30:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
17,509
cpp
// colosseumCtrl.cpp : Implementation of the CColosseumCtrl ActiveX Control class. #include "stdafx.h" #include "colosseum.h" #include "colosseumCtrl.h" #include "colosseumPropPage.h" #include "IFCEngineInteract.h" #include <assert.h> #ifdef _DEBUG #define new DEBUG_NEW #endif /* An error indication value non-zero if error exists */ int g_directXStatus = 0; float * g_pVerticesDeviceBuffer; extern int g_noVertices, g_noIndices, * g_pIndices; extern float * g_pVertices; D3DXVECTOR3 g_vecOrigin; IMPLEMENT_DYNCREATE(CColosseumCtrl, COleControl) // Message map BEGIN_MESSAGE_MAP(CColosseumCtrl, COleControl) ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties) ON_WM_KEYDOWN() ON_WM_SHOWWINDOW() ON_WM_MOUSEMOVE() END_MESSAGE_MAP() // Dispatch map BEGIN_DISPATCH_MAP(CColosseumCtrl, COleControl) DISP_FUNCTION_ID(CColosseumCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE) END_DISPATCH_MAP() // Event map BEGIN_EVENT_MAP(CColosseumCtrl, COleControl) END_EVENT_MAP() // Property pages // TODO: Add more property pages as needed. Remember to increase the count! BEGIN_PROPPAGEIDS(CColosseumCtrl, 1) PROPPAGEID(CcolosseumPropPage::guid) END_PROPPAGEIDS(CColosseumCtrl) // Initialize class factory and guid IMPLEMENT_OLECREATE_EX(CColosseumCtrl, "COLOSSEUM.colosseumCtrl.1", 0x70217189, 0x66e8, 0x4874, 0x9f, 0xd2, 0x53, 0x52, 0xfd, 0xf4, 0x67, 0x34) // Type library ID and version IMPLEMENT_OLETYPELIB(CColosseumCtrl, _tlid, _wVerMajor, _wVerMinor) // Interface IDs const IID BASED_CODE IID_Dcolosseum = { 0xE8B8A0AD, 0x761C, 0x4631, { 0x88, 0xCF, 0xD5, 0xD2, 0xDD, 0xEA, 0xEE, 0x79 } }; const IID BASED_CODE IID_DcolosseumEvents = { 0xE9D4851E, 0x590E, 0x4C56, { 0x9C, 0xEF, 0x9E, 0xC4, 0x95, 0x96, 0x1E, 0xDD } }; // Control type information static const DWORD BASED_CODE _dwcolosseumOleMisc = OLEMISC_ACTIVATEWHENVISIBLE | OLEMISC_SETCLIENTSITEFIRST | OLEMISC_INSIDEOUT | OLEMISC_CANTLINKINSIDE | OLEMISC_RECOMPOSEONRESIZE; IMPLEMENT_OLECTLTYPE(CColosseumCtrl, IDS_COLOSSEUM, _dwcolosseumOleMisc) // CColosseumCtrl::CColosseumCtrlFactory::UpdateRegistry - // Adds or removes system registry entries for CColosseumCtrl BOOL CColosseumCtrl::CColosseumCtrlFactory::UpdateRegistry(BOOL bRegister) { // TODO: Verify that your control follows apartment-model threading rules. // Refer to MFC TechNote 64 for more information. // If your control does not conform to the apartment-model rules, then // you must modify the code below, changing the 6th parameter from // afxRegApartmentThreading to 0. if (bRegister) return AfxOleRegisterControlClass( AfxGetInstanceHandle(), m_clsid, m_lpszProgID, IDS_COLOSSEUM, IDB_COLOSSEUM, afxRegApartmentThreading, _dwcolosseumOleMisc, _tlid, _wVerMajor, _wVerMinor); else return AfxOleUnregisterClass(m_clsid, m_lpszProgID); } // CColosseumCtrl::CColosseumCtrl - Constructor CColosseumCtrl::CColosseumCtrl() : m_width(0), m_height(0), m_server(""), MULTIPLY_RATIO(0.030f) { InitializeIIDs(&IID_Dcolosseum, &IID_DcolosseumEvents); // TODO: Initialize your control's instance data here. m_pD3D = NULL; m_pd3dDevice = NULL; m_pVB = NULL; m_initialized = false; m_engineInteract = new CIFCEngineInteract(); m_camera = new CCamera(D3DXVECTOR3(0,0,-2.5f)); /* Reset D3DPRESENT_PARAMETERS structure */ memset( &m_d3dpp, 0, sizeof(m_d3dpp) ); } /* Called when a key is pressed */ void CColosseumCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { /* This method is called by the MFC messaging system when a WM_ONKEYDOWN * is sent this handles the keys pressed when using the control * The keys handled are * W key for moving forward * S for moving backward * A for left strafing * D for right straging */ switch( nChar ) { case 0x57: //W KEY m_camera->moveForward(MULTIPLY_RATIO); if (m_initialized) { render(); } break; case 0x53: // S KEY /* Inverse the direction by multiplying with -1*/ m_camera->moveForward(-1.0f * MULTIPLY_RATIO); if (m_initialized) { render(); } break; case 0x41:// A KEY /* Inverse the direction by multiplying with -1*/ m_camera->moveRight(-1.0f * MULTIPLY_RATIO); if(m_initialized) render(); break; case 0x44: // D KEY m_camera->moveRight( MULTIPLY_RATIO ); if(m_initialized) render(); break; } } /* Called when the control is Shown*/ void CColosseumCtrl::OnShowWindow(BOOL bShow, UINT nStatus) { /* This method is called the instance the control is show to the user * What happens here is that we get the file name from m_server and convert it from * CString to char* and send it to the CIFCEngineInteract object to retrieve information * from the file and initialize the CIFCEngineInteract object. * We then initialize the m_width and m_height with the width and height of the control * sent with <OBJECT> tag in the html file. * After that we assign to m_hwndRenderWindow the handle of the window that we are going to draw * in because we are going to use to initialize the DirectX device module and initialize the device buffer . * Lastly we render the changes. */ if ( 0 == m_engineInteract->retrieveObjectGroups((m_server.GetBuffer(0)))) m_engineInteract->enrichObjectGroups(); else ASSERT(1==0); CRect rc; GetWindowRect(&rc); m_width = rc.Width(); m_height = rc.Height(); m_hwndRenderWindow = this->m_hWnd; initializeDevice(); initializeDeviceBuffer(); if(m_initialized) render(); } int iZoomMouseX, iZoomMouseY; void CColosseumCtrl::OnMouseMove(UINT nFlags, CPoint point) { /* This method handle the mouse movement and adjust the view of the camera * according to the changes made to the coordinates * NOTE: Remember the camera i am talking about is a First Person Shooter camera */ int iMouseX = point.x, iMouseY = point.y; switch(nFlags) { case MK_LBUTTON: //SetCapture(); SetCursor(NULL); m_camera->rotateCamera((float)(iMouseY-iZoomMouseY), (float)(iMouseX-iZoomMouseX)); if (m_initialized) { render(); } //ReleaseCapture(); iZoomMouseX = iMouseX; iZoomMouseY = iMouseY; break; } } LRESULT CColosseumCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { /* I left the WindowProc method so that leave the window rendering while * there are no messages to handle. * I left some message handling to determine the coordinates of the previous frame * so that it is dealt with in the OnMouseMove method */ switch (message) { case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: /* Note the lParam is sent as 4 bytes each 2 bytes contain the X coordinates of the mouse * and Y coordinates of the mouse the lower 2 bytes are for the X component and the higher 2 bytes are * for the Y. * Example:- * 0x010e01b5 the low bytes are 0x01b5 which is equal to 437 decimal therefore the X-Coordinate's value is 437 * the higher bytes are 0x010e which is equal to 270 decimal therefore the Y-Coordinates's value is 270 * hope that you got it right */ iZoomMouseX = LOWORD(lParam); iZoomMouseY = HIWORD(lParam); break; } if(m_initialized) render(); return COleControl::WindowProc(message, wParam, lParam); } // CColosseumCtrl::~CColosseumCtrl - Destructor CColosseumCtrl::~CColosseumCtrl() { // TODO: Cleanup your control's instance data here. delete m_engineInteract; delete m_camera; } // CColosseumCtrl::OnDraw - Drawing function void CColosseumCtrl::OnDraw( CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid) { if (!pdc) return; // TODO: Replace the following code with your own drawing code. } // CColosseumCtrl::DoPropExchange - Persistence support void CColosseumCtrl::DoPropExchange(CPropExchange* pPX) { ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor)); COleControl::DoPropExchange(pPX); // TODO: Call PX_ functions for each persistent custom property. PX_String(pPX, _T("server"), m_server, _T("")); } // CColosseumCtrl::GetControlFlags - // Flags to customize MFC's implementation of ActiveX controls. // DWORD CColosseumCtrl::GetControlFlags() { DWORD dwFlags = COleControl::GetControlFlags(); // The control will not be redrawn when making the transition // between the active and inactivate state. dwFlags |= noFlickerActivate; return dwFlags; } // CColosseumCtrl::OnResetState - Reset control to default state void CColosseumCtrl::OnResetState() { COleControl::OnResetState(); // Resets defaults found in DoPropExchange // TODO: Reset any other control state here. } // CColosseumCtrl::AboutBox - Display an "About" box to the user void CColosseumCtrl::AboutBox() { CDialog dlgAbout(IDD_ABOUTBOX_COLOSSEUM); dlgAbout.DoModal(); } // CColosseumCtrl message handlers LONG CColosseumCtrl::GetHeight() const { return m_height; } LONG CColosseumCtrl::GetWidth() const { return m_width; } BSTR CColosseumCtrl::GetServer() const { return m_server.AllocSysString(); } void CColosseumCtrl::initializeDevice() { if( m_pVB != NULL ) { if( FAILED( m_pVB->Release() ) ) { g_directXStatus = -1; ASSERT(1==0); return; } } if( m_pd3dDevice != NULL ) { if( FAILED( m_pd3dDevice->Release() ) ) { g_directXStatus = -1; ASSERT(1==0); return; } } if( m_pD3D != NULL ) { if( FAILED( m_pD3D->Release() ) ) { g_directXStatus = -1; ASSERT(1==0); return; } } m_pD3D = Direct3DCreate9( D3D_SDK_VERSION ); ASSERT(m_pD3D); m_d3dpp.Windowed = TRUE; m_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; m_d3dpp.hDeviceWindow = this->GetSafeHwnd(); m_d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; m_d3dpp.EnableAutoDepthStencil = TRUE; m_d3dpp.AutoDepthStencilFormat = D3DFMT_D16; if( FAILED( m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hwndRenderWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING, &m_d3dpp, &m_pd3dDevice ) ) ) { if( FAILED( m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hwndRenderWindow, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &m_d3dpp, &m_pd3dDevice ) ) ) { ASSERT(1==0); return; } } ASSERT(m_pd3dDevice); m_initialized = true; if( FAILED( m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ) ) ) { ASSERT(1==0); return; } if( FAILED( m_pd3dDevice->SetRenderState( D3DRS_MULTISAMPLEANTIALIAS, TRUE) ) ) { ASSERT(1==0); return; } // Turn on the zbuffer if( FAILED( m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE ) ) ) { ASSERT(1==0); return; } } void CColosseumCtrl::initializeDeviceBuffer() { if (g_noVertices) { if (!g_directXStatus) { if( FAILED( m_pd3dDevice->CreateVertexBuffer( g_noIndices * sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &m_pVB, NULL ) ) ) { ASSERT(1==0); return; } if( FAILED( m_pVB->Lock( 0, 0, (void **)&g_pVerticesDeviceBuffer, 0 ) ) ) { ASSERT(1==0); return; } int i = 0; while (i < g_noIndices) { ASSERT(g_pIndices[i] < g_noVertices); memcpy(&(((CUSTOMVERTEX *) g_pVerticesDeviceBuffer)[i]), &(((CUSTOMVERTEX *) g_pVertices)[g_pIndices[i]]), sizeof(CUSTOMVERTEX)); i++; } if (FAILED( m_pVB->Unlock())) { ASSERT(1==0); return; } } } } void CColosseumCtrl::render() { if (m_initialized) { // Clear the backbuffer and the zbuffer if( FAILED( m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 ) ) ) { g_directXStatus = -1; return; } // Begin the scene if (SUCCEEDED(m_pd3dDevice->BeginScene())) { // Setup the lights and materials if (setupLights()) { g_directXStatus = -1; return; } // Setup the world, view, and projection matrices if (setupMatrices()) { g_directXStatus = -1; return; } if (m_pd3dDevice->SetStreamSource(0, m_pVB, 0, sizeof(CUSTOMVERTEX))) { g_directXStatus = -1; return; } m_pd3dDevice->SetVertexShader(NULL); m_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX); D3DMATERIAL9 mtrl; mtrl.Diffuse.r = mtrl.Ambient.r = mtrl.Specular.r = 0.4f; mtrl.Diffuse.g = mtrl.Ambient.g = mtrl.Specular.g = 0.1f; mtrl.Diffuse.b = mtrl.Ambient.b = mtrl.Specular.b = 0.7f; mtrl.Diffuse.a = mtrl.Ambient.a = mtrl.Specular.a = 1.0f; mtrl.Emissive.r = 0.1f; mtrl.Emissive.g = 0.4f; mtrl.Emissive.b = 0.02f; mtrl.Emissive.a = 0.5f; m_pd3dDevice->SetMaterial(&mtrl); STRUCT_INSTANCES * instance = m_engineInteract->getFirstInstance(); while (instance) { if ( (instance->parent) && (instance->select == ITEM_CHECKED) ){ m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, instance->startIndex, instance->primitiveCount); } instance = instance->next; } // End the scene if( FAILED( m_pd3dDevice->EndScene() ) ) { g_directXStatus = -1; return; } } // Present the backbuffer contents to the display if( FAILED( m_pd3dDevice->Present( NULL, NULL, NULL, NULL ) ) ) { g_directXStatus = -1; return; } } } int CColosseumCtrl::setupLights() { float max = 1; // Set up a white, directional light, with an oscillating direction. // Note that many lights may be active at a time (but each one slows down // the rendering of our scene). However, here we are just using one. Also, // we need to set the D3DRS_LIGHTING renderstate to enable lighting D3DXVECTOR3 vecDir; D3DLIGHT9 light; ZeroMemory(&light, sizeof(D3DLIGHT9)); light.Type = D3DLIGHT_DIRECTIONAL; light.Diffuse.r = 3.4f; light.Diffuse.g = 3.4f; light.Diffuse.b = 3.4f; light.Diffuse.a = 3.4f; light.Specular.r = 0.1f; light.Specular.g = 0.1f; light.Specular.b = 0.1f; light.Specular.a = 0.5f; light.Ambient.r = 0.5f; light.Ambient.g = 0.5f; light.Ambient.b = 0.5f; light.Ambient.a = 1.0f; light.Position.x = (float) -2.0f; light.Position.y = (float) -2.0f; light.Position.z = (float) -2.0f; vecDir.x = -2.0f; vecDir.y = -6.0f; vecDir.z = -1.0f; D3DXVec3Normalize((D3DXVECTOR3*)&light.Direction, &vecDir); light.Range = 5.0f; if (FAILED(m_pd3dDevice->SetLight(0, &light))) { g_directXStatus = -1; return 1; } if (FAILED(m_pd3dDevice->LightEnable(0, TRUE))) { g_directXStatus = -1; return 1; } D3DLIGHT9 light1; ZeroMemory(&light1, sizeof(D3DLIGHT9)); light1.Type = D3DLIGHT_DIRECTIONAL; light1.Diffuse.r = 3.4f; light1.Diffuse.g = 3.4f; light1.Diffuse.b = 3.4f; light1.Diffuse.a = 3.4f; light1.Specular.r = 0.1f; light1.Specular.g = 0.1f; light1.Specular.b = 0.1f; light1.Specular.a = 0.5f; light1.Ambient.r = 0.5f; light1.Ambient.g = 0.5f; light1.Ambient.b = 0.5f; light1.Ambient.a = 1.0f; light1.Position.x = (float) 2.0f; light1.Position.y = (float) 2.0f; light1.Position.z = (float) 2.0f; vecDir.x = 2.0f; vecDir.y = 6.0f; vecDir.z = 1.0f; D3DXVec3Normalize((D3DXVECTOR3*)&light1.Direction, &vecDir); light1.Range = 5.0f; if (FAILED(m_pd3dDevice->SetLight(1, &light1))) { g_directXStatus = -1; return 1; } if (FAILED(m_pd3dDevice->LightEnable(1, TRUE))) { g_directXStatus = -1; return 1; } if (FAILED(m_pd3dDevice->SetRenderState(D3DRS_LIGHTING, TRUE))) { g_directXStatus = -1; return 1; } // Finally, turn on some ambient light. m_pd3dDevice->SetRenderState(D3DRS_AMBIENT, 0x00707070); return 0; } int CColosseumCtrl::setupMatrices() { D3DXMATRIX matWorld; D3DXMatrixIdentity( &matWorld ); matWorld._22 = -1.0f; D3DXVec3TransformCoord((D3DXVECTOR3 *) &matWorld._41, &g_vecOrigin, &matWorld); if( FAILED( m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ) ) ) { g_directXStatus = -1; return 1; } // For the projection matrix, we set up a perspective transform (which // transforms geometry from 3D view space to 2D viewport space, with // a perspective divide making objects smaller in the distance). To build // a perpsective transform, we need the field of view (1/4 pi is common), // the aspect ratio, and the near and far clipping planes (which define at // what distances geometry should be no longer be rendered). D3DXMATRIX matProj; D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, (float) m_width/(float) m_height, 0.03f, 10.0f ); if( FAILED( m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ) ) ) { g_directXStatus = -1; return 1; } D3DXMATRIXA16 matrix; //Calculate the new view matrix for the camera this->m_camera->calculateViewMatrix(&matrix); if( FAILED( m_pd3dDevice->SetTransform( D3DTS_VIEW, &matrix ) ) ) { g_directXStatus = -1; } return 0; }
[ [ [ 1, 15 ], [ 17, 138 ], [ 140, 146 ], [ 149, 160 ], [ 170, 170 ], [ 177, 177 ], [ 188, 243 ], [ 245, 247 ], [ 249, 250 ], [ 252, 290 ], [ 292, 523 ], [ 525, 666 ], [ 668, 674 ] ], [ [ 16, 16 ], [ 139, 139 ], [ 147, 148 ], [ 161, 169 ], [ 171, 176 ], [ 178, 187 ], [ 244, 244 ], [ 248, 248 ], [ 251, 251 ], [ 291, 291 ], [ 524, 524 ], [ 667, 667 ] ] ]
98c83e66665ceba25937747d99faf82afcee5429
2920ac8b9d3f25edf9f48cb8231d2422dffb485c
/source/code/TestModule.h
bb3a3d50c4496160381e94bf1c81ec7f83d48582
[]
no_license
TheBuzzSaw/legacy-dejarix
0b2e028fc6a2eeb50ed733750b0f69dab7b80d6d
0a119a465c9097f918c19153e1056ba9eabc18e7
refs/heads/master
2021-01-10T20:19:40.595842
2011-01-23T22:18:16
2011-01-23T22:18:16
41,321,281
0
0
null
null
null
null
UTF-8
C++
false
false
2,805
h
/** * This file is part of Dejarix. * * Dejarix 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. * * Dejarix 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 Dejarix. If not, see <http://www.gnu.org/licenses/>. */ #ifndef TESTMODULE_H #define TESTMODULE_H #include "Module.h" #include "CardProgram.h" #include "CardModel.h" #include "MatrixStack.h" #include "Camera.h" #include "Vector2D.h" #define NUM_TEXTURES 61 class TestModule : public Module { public: TestModule(); virtual ~TestModule(); enum MouseModes { NONE, DRAGGING }; /// module operation virtual void onLoad(); virtual void onOpen(); virtual void onLoop(); virtual void onFrame(); virtual void onClose(); virtual void onUnload(); protected: static bool unproject(float inX, float inY, float inZ, const Matrix3D& inMVM, const Matrix3D& inPM, const Vector3D<int>& inViewport, Vector3D<float>& inResult); static void transformPoint(const Matrix3D& inMatrix, const Vector3D<float>& inVector, Vector3D<float>& inResult); virtual void onKeyDown(SDLKey inSym, SDLMod inMod, Uint16 inUnicode); virtual void onMouseWheel(bool inUp, bool inDown); virtual void onMouseMove(int inX, int inY, int inRelX, int inRelY, bool inLeft, bool inRight, bool inMiddle); virtual void onLButtonDown(int inX, int inY); virtual void onLButtonUp(int inX, int inY); virtual void onRButtonDown(int inX, int inY); private: void loadCardImage(const char* inFile, GLuint inTexture); void processPosition(); Camera mCamera; MatrixStack mModelView; Matrix3D mProjection; Matrix3D mMVPM; CardProgram mCardProgram; ShaderVBO mTable; CardModel mCard; GLuint mTextures[NUM_TEXTURES]; Pixel mMouseCoordinates; Pixel mWindowCenter; Vector3D<GLfloat> mPointer; Vector3D<GLfloat> mDragAnchor; Vector3D<GLfloat> mCardDragSource; Vector3D<GLfloat> mCardTranslate; Vector3D<GLfloat> mCardColor; Vector3D<GLint> mViewport; MouseModes mMouseMode; bool mSpin; size_t mCurrentTexture; Uint8* mKeyState; }; #endif
[ "TheBuzzSaw@35cf13a5-3602-408e-9700-a7e2e4f0c3b8" ]
[ [ [ 1, 87 ] ] ]
fd056688e2b34593fad88601518ba376c71b3611
ed9ecdcba4932c1adacac9218c83e19f71695658
/CJAudioEngine/trunk/CJAudioEngine/IOpenAL.cpp
48ec336123cdf48ca13f0d58bca21e0b87fe2275
[]
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
255
cpp
#include "IOpenAL.h" CRITICAL_SECTION * IOpenAL::_openal_access = 0; IOpenAL::IOpenAL(void) { if (_openal_access==0) _openal_access = new CRITICAL_SECTION; InitializeCriticalSection(_openal_access); } IOpenAL::~IOpenAL(void) { }
[ "clems71@52ecbd26-af3e-11de-a2ab-0da4ed5138bb" ]
[ [ [ 1, 16 ] ] ]
2d1c3641b88c01bb937917f4a503e1dee78db291
3d24f3a3ad16eae19b41812f4f0610321d73a970
/S60DbView/S60DbView/group/s60dbview.uid.cpp
d93a74918e12e2961c3cc6cf7abec101dfaf7dd0
[]
no_license
SymbiSoft/s60dbview
26b0042492f785da447a3d4899f89f61be725b38
a5fbc620949c22e7d27eb0fabc1d855883442787
refs/heads/master
2021-01-10T15:04:45.176140
2008-05-18T13:53:31
2008-05-18T13:53:31
48,187,129
0
0
null
null
null
null
UTF-8
C++
false
false
155
cpp
// Makmake-generated uid source file #include <E32STD.H> #pragma data_seg(".E32_UID") __WINS_UID(0x10000079,0x100039ce,0x0e5e58da) #pragma data_seg()
[ "yyc520@aaf011ab-804d-0410-8e4c-c1c04eb9eed9" ]
[ [ [ 1, 5 ] ] ]
cae107a3ae12e299accb8a636c5bcebd1bb6d5c5
fac8de123987842827a68da1b580f1361926ab67
/inc/physics/Common/Base/Reflection/Registry/hkClassNameRegistry.h
7535924abf9fba163cf18eedd8adbe6a2ff8c548
[]
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,790
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 HK_CLASS_NAME_REGISTRY_H #define HK_CLASS_NAME_REGISTRY_H class hkClass; /// Associates string type names with hkClass objects. class hkClassNameRegistry : public hkReferencedObject { public: /// Get name of the registry. virtual const char* getName() const = 0; /// Get a class by name or HK_NULL if it was not registered. virtual const hkClass* getClassByName( const char* className ) const = 0; /// Get array of registered classes, e.g. to iterate through them. virtual void getClasses( hkArray<const hkClass*>& classes ) const = 0; }; #endif // HK_CLASS_NAME_REGISTRY_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, 41 ] ] ]
dfd84441ac75f132e6810bbdfa9b0da2cc695ec4
3ec3b97044e4e6a87125470cfa7eef535f26e376
/timorg-chuzzle_bejeweled_clone/chuzzle_board.cpp
c6b79643983c37411a125dbb33a57a095b3dde6c
[]
no_license
strategist922/TINS-Is-not-speedhack-2010
6d7a43ebb9ab3b24208b3a22cbcbb7452dae48af
718b9d037606f0dbd9eb6c0b0e021eeb38c011f9
refs/heads/master
2021-01-18T14:14:38.724957
2010-10-17T14:04:40
2010-10-17T14:04:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,070
cpp
#include "chuzzle_board.h" CHUZZLE_BOARD::CHUZZLE_BOARD(int w, int h) : BOARD(w, h) { } // this is run after all the clicking and decision to move are made void CHUZZLE_BOARD::logic(CP_OBJECT_MANAGER<TILE> &manager) { std::list<counted_ptr<TILE> > nukable; GRID_DATA temp = data; int rotate_count = 0; bool no_nukable = true; if ((direction == N) || (direction == S)) { for (int c = 0; c < data.height(); c++) { rotate_count = c; temp.rotate(selection.x, direction); //nukable = int nukable_size = temp.find_nukable(); // nukable = temp.remove_nukable(); if (nukable_size > 0) { /* // add all nuked to the manager for (std::list<counted_ptr<TILE> >::iterator i = nukable.begin(); i != nukable.end(); i++) { // (*i)->ungrid(); manager.add(counted_ptr<TILE>(*i)); } */ no_nukable = false; break; } } if (!no_nukable) { rotate_count++; for (int c = 0; c < rotate_count; c++) { data.rotate(selection.x, direction); } data.shove_line(selection.x, direction); data.shove_all(); } } else if ((direction == E) ||(direction == W)) { for (int c = 0; c < data.width(); c++) { rotate_count = c; temp.rotate(selection.y, direction); //nukable = int nukable_size = temp.find_nukable(); // nukable = temp.remove_nukable(); if (nukable_size > 0) { /* // add all nuked to the manager for (std::list<counted_ptr<TILE> >::iterator i = nukable.begin(); i != nukable.end(); i++) { // (*i)->ungrid(); manager.add(counted_ptr<TILE>(*i)); } */ no_nukable = false; break; } } if (!no_nukable) { rotate_count++; for (int c = 0; c < rotate_count; c++) { data.rotate(selection.y, direction); } data.shove_line(selection.y, direction); data.shove_all(); } } if ((direction == N) || (direction == S)) { for(int y = 0; y < data.height(); y++) { counted_ptr<TILE> &t = data.at(POSITION(selection.x, y)); if (no_nukable) t->shove(t->pos, direction, false); } } else if ((direction == E) ||(direction == W)) { for(int x = 0; x < data.width(); x++) { counted_ptr<TILE> &t = data.at(POSITION(x, selection.y)); if (no_nukable) t->shove(t->pos, direction, false); } } }
[ [ [ 1, 105 ] ] ]
3a424b681d7628e7afa33d4bfcb3884087d10aad
96e96a73920734376fd5c90eb8979509a2da25c0
/BulletPhysics/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp
42d01c7c56280263863bfde096026d8e6a85f701
[]
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
47,404
cpp
/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ //#define COMPUTE_IMPULSE_DENOM 1 //It is not necessary (redundant) to refresh contact manifolds, this refresh has been moved to the collision algorithms. #include "btSequentialImpulseConstraintSolver.h" #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" #include "BulletDynamics/Dynamics/btRigidBody.h" #include "btContactConstraint.h" #include "btSolve2LinearConstraint.h" #include "btContactSolverInfo.h" #include "LinearMath/btIDebugDraw.h" #include "btJacobianEntry.h" #include "LinearMath/btMinMax.h" #include "BulletDynamics/ConstraintSolver/btTypedConstraint.h" #include <new> #include "LinearMath/btStackAlloc.h" #include "LinearMath/btQuickprof.h" #include "btSolverBody.h" #include "btSolverConstraint.h" #include "LinearMath/btAlignedObjectArray.h" #include <string.h> //for memset int gNumSplitImpulseRecoveries = 0; btSequentialImpulseConstraintSolver::btSequentialImpulseConstraintSolver() :m_btSeed2(0) { } btSequentialImpulseConstraintSolver::~btSequentialImpulseConstraintSolver() { } #ifdef USE_SIMD #include <emmintrin.h> #define vec_splat(x, e) _mm_shuffle_ps(x, x, _MM_SHUFFLE(e,e,e,e)) static inline __m128 _vmathVfDot3( __m128 vec0, __m128 vec1 ) { __m128 result = _mm_mul_ps( vec0, vec1); return _mm_add_ps( vec_splat( result, 0 ), _mm_add_ps( vec_splat( result, 1 ), vec_splat( result, 2 ) ) ); } #endif//USE_SIMD // Project Gauss Seidel or the equivalent Sequential Impulse void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGenericSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c) { #ifdef USE_SIMD __m128 cpAppliedImp = _mm_set1_ps(c.m_appliedImpulse); __m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit); __m128 upperLimit1 = _mm_set1_ps(c.m_upperLimit); __m128 deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhs), _mm_mul_ps(_mm_set1_ps(c.m_appliedImpulse),_mm_set1_ps(c.m_cfm))); __m128 deltaVel1Dotn = _mm_add_ps(_vmathVfDot3(c.m_contactNormal.mVec128,body1.m_deltaLinearVelocity.mVec128), _vmathVfDot3(c.m_relpos1CrossNormal.mVec128,body1.m_deltaAngularVelocity.mVec128)); __m128 deltaVel2Dotn = _mm_sub_ps(_vmathVfDot3(c.m_relpos2CrossNormal.mVec128,body2.m_deltaAngularVelocity.mVec128),_vmathVfDot3((c.m_contactNormal).mVec128,body2.m_deltaLinearVelocity.mVec128)); deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel1Dotn,_mm_set1_ps(c.m_jacDiagABInv))); deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel2Dotn,_mm_set1_ps(c.m_jacDiagABInv))); btSimdScalar sum = _mm_add_ps(cpAppliedImp,deltaImpulse); btSimdScalar resultLowerLess,resultUpperLess; resultLowerLess = _mm_cmplt_ps(sum,lowerLimit1); resultUpperLess = _mm_cmplt_ps(sum,upperLimit1); __m128 lowMinApplied = _mm_sub_ps(lowerLimit1,cpAppliedImp); deltaImpulse = _mm_or_ps( _mm_and_ps(resultLowerLess, lowMinApplied), _mm_andnot_ps(resultLowerLess, deltaImpulse) ); c.m_appliedImpulse = _mm_or_ps( _mm_and_ps(resultLowerLess, lowerLimit1), _mm_andnot_ps(resultLowerLess, sum) ); __m128 upperMinApplied = _mm_sub_ps(upperLimit1,cpAppliedImp); deltaImpulse = _mm_or_ps( _mm_and_ps(resultUpperLess, deltaImpulse), _mm_andnot_ps(resultUpperLess, upperMinApplied) ); c.m_appliedImpulse = _mm_or_ps( _mm_and_ps(resultUpperLess, c.m_appliedImpulse), _mm_andnot_ps(resultUpperLess, upperLimit1) ); __m128 linearComponentA = _mm_mul_ps(c.m_contactNormal.mVec128,body1.m_invMass.mVec128); __m128 linearComponentB = _mm_mul_ps((c.m_contactNormal).mVec128,body2.m_invMass.mVec128); __m128 impulseMagnitude = deltaImpulse; body1.m_deltaLinearVelocity.mVec128 = _mm_add_ps(body1.m_deltaLinearVelocity.mVec128,_mm_mul_ps(linearComponentA,impulseMagnitude)); body1.m_deltaAngularVelocity.mVec128 = _mm_add_ps(body1.m_deltaAngularVelocity.mVec128 ,_mm_mul_ps(c.m_angularComponentA.mVec128,impulseMagnitude)); body2.m_deltaLinearVelocity.mVec128 = _mm_sub_ps(body2.m_deltaLinearVelocity.mVec128,_mm_mul_ps(linearComponentB,impulseMagnitude)); body2.m_deltaAngularVelocity.mVec128 = _mm_add_ps(body2.m_deltaAngularVelocity.mVec128 ,_mm_mul_ps(c.m_angularComponentB.mVec128,impulseMagnitude)); #else resolveSingleConstraintRowGeneric(body1,body2,c); #endif } // Project Gauss Seidel or the equivalent Sequential Impulse void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGeneric(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c) { btScalar deltaImpulse = c.m_rhs-btScalar(c.m_appliedImpulse)*c.m_cfm; const btScalar deltaVel1Dotn = c.m_contactNormal.dot(body1.m_deltaLinearVelocity) + c.m_relpos1CrossNormal.dot(body1.m_deltaAngularVelocity); const btScalar deltaVel2Dotn = -c.m_contactNormal.dot(body2.m_deltaLinearVelocity) + c.m_relpos2CrossNormal.dot(body2.m_deltaAngularVelocity); const btScalar delta_rel_vel = deltaVel1Dotn-deltaVel2Dotn; deltaImpulse -= deltaVel1Dotn*c.m_jacDiagABInv; deltaImpulse -= deltaVel2Dotn*c.m_jacDiagABInv; const btScalar sum = btScalar(c.m_appliedImpulse) + deltaImpulse; if (sum < c.m_lowerLimit) { deltaImpulse = c.m_lowerLimit-c.m_appliedImpulse; c.m_appliedImpulse = c.m_lowerLimit; } else if (sum > c.m_upperLimit) { deltaImpulse = c.m_upperLimit-c.m_appliedImpulse; c.m_appliedImpulse = c.m_upperLimit; } else { c.m_appliedImpulse = sum; } body1.applyImpulse(c.m_contactNormal*body1.m_invMass,c.m_angularComponentA,deltaImpulse); body2.applyImpulse(-c.m_contactNormal*body2.m_invMass,c.m_angularComponentB,deltaImpulse); } void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowLowerLimitSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c) { #ifdef USE_SIMD __m128 cpAppliedImp = _mm_set1_ps(c.m_appliedImpulse); __m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit); __m128 upperLimit1 = _mm_set1_ps(c.m_upperLimit); __m128 deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhs), _mm_mul_ps(_mm_set1_ps(c.m_appliedImpulse),_mm_set1_ps(c.m_cfm))); __m128 deltaVel1Dotn = _mm_add_ps(_vmathVfDot3(c.m_contactNormal.mVec128,body1.m_deltaLinearVelocity.mVec128), _vmathVfDot3(c.m_relpos1CrossNormal.mVec128,body1.m_deltaAngularVelocity.mVec128)); __m128 deltaVel2Dotn = _mm_sub_ps(_vmathVfDot3(c.m_relpos2CrossNormal.mVec128,body2.m_deltaAngularVelocity.mVec128),_vmathVfDot3((c.m_contactNormal).mVec128,body2.m_deltaLinearVelocity.mVec128)); deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel1Dotn,_mm_set1_ps(c.m_jacDiagABInv))); deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel2Dotn,_mm_set1_ps(c.m_jacDiagABInv))); btSimdScalar sum = _mm_add_ps(cpAppliedImp,deltaImpulse); btSimdScalar resultLowerLess,resultUpperLess; resultLowerLess = _mm_cmplt_ps(sum,lowerLimit1); resultUpperLess = _mm_cmplt_ps(sum,upperLimit1); __m128 lowMinApplied = _mm_sub_ps(lowerLimit1,cpAppliedImp); deltaImpulse = _mm_or_ps( _mm_and_ps(resultLowerLess, lowMinApplied), _mm_andnot_ps(resultLowerLess, deltaImpulse) ); c.m_appliedImpulse = _mm_or_ps( _mm_and_ps(resultLowerLess, lowerLimit1), _mm_andnot_ps(resultLowerLess, sum) ); __m128 linearComponentA = _mm_mul_ps(c.m_contactNormal.mVec128,body1.m_invMass.mVec128); __m128 linearComponentB = _mm_mul_ps((c.m_contactNormal).mVec128,body2.m_invMass.mVec128); __m128 impulseMagnitude = deltaImpulse; body1.m_deltaLinearVelocity.mVec128 = _mm_add_ps(body1.m_deltaLinearVelocity.mVec128,_mm_mul_ps(linearComponentA,impulseMagnitude)); body1.m_deltaAngularVelocity.mVec128 = _mm_add_ps(body1.m_deltaAngularVelocity.mVec128 ,_mm_mul_ps(c.m_angularComponentA.mVec128,impulseMagnitude)); body2.m_deltaLinearVelocity.mVec128 = _mm_sub_ps(body2.m_deltaLinearVelocity.mVec128,_mm_mul_ps(linearComponentB,impulseMagnitude)); body2.m_deltaAngularVelocity.mVec128 = _mm_add_ps(body2.m_deltaAngularVelocity.mVec128 ,_mm_mul_ps(c.m_angularComponentB.mVec128,impulseMagnitude)); #else resolveSingleConstraintRowLowerLimit(body1,body2,c); #endif } // Project Gauss Seidel or the equivalent Sequential Impulse void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowLowerLimit(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c) { btScalar deltaImpulse = c.m_rhs-btScalar(c.m_appliedImpulse)*c.m_cfm; const btScalar deltaVel1Dotn = c.m_contactNormal.dot(body1.m_deltaLinearVelocity) + c.m_relpos1CrossNormal.dot(body1.m_deltaAngularVelocity); const btScalar deltaVel2Dotn = -c.m_contactNormal.dot(body2.m_deltaLinearVelocity) + c.m_relpos2CrossNormal.dot(body2.m_deltaAngularVelocity); deltaImpulse -= deltaVel1Dotn*c.m_jacDiagABInv; deltaImpulse -= deltaVel2Dotn*c.m_jacDiagABInv; const btScalar sum = btScalar(c.m_appliedImpulse) + deltaImpulse; if (sum < c.m_lowerLimit) { deltaImpulse = c.m_lowerLimit-c.m_appliedImpulse; c.m_appliedImpulse = c.m_lowerLimit; } else { c.m_appliedImpulse = sum; } body1.applyImpulse(c.m_contactNormal*body1.m_invMass,c.m_angularComponentA,deltaImpulse); body2.applyImpulse(-c.m_contactNormal*body2.m_invMass,c.m_angularComponentB,deltaImpulse); } void btSequentialImpulseConstraintSolver::resolveSplitPenetrationImpulseCacheFriendly( btSolverBody& body1, btSolverBody& body2, const btSolverConstraint& c) { if (c.m_rhsPenetration) { gNumSplitImpulseRecoveries++; btScalar deltaImpulse = c.m_rhsPenetration-btScalar(c.m_appliedPushImpulse)*c.m_cfm; const btScalar deltaVel1Dotn = c.m_contactNormal.dot(body1.m_pushVelocity) + c.m_relpos1CrossNormal.dot(body1.m_turnVelocity); const btScalar deltaVel2Dotn = -c.m_contactNormal.dot(body2.m_pushVelocity) + c.m_relpos2CrossNormal.dot(body2.m_turnVelocity); deltaImpulse -= deltaVel1Dotn*c.m_jacDiagABInv; deltaImpulse -= deltaVel2Dotn*c.m_jacDiagABInv; const btScalar sum = btScalar(c.m_appliedPushImpulse) + deltaImpulse; if (sum < c.m_lowerLimit) { deltaImpulse = c.m_lowerLimit-c.m_appliedPushImpulse; c.m_appliedPushImpulse = c.m_lowerLimit; } else { c.m_appliedPushImpulse = sum; } body1.internalApplyPushImpulse(c.m_contactNormal*body1.m_invMass,c.m_angularComponentA,deltaImpulse); body2.internalApplyPushImpulse(-c.m_contactNormal*body2.m_invMass,c.m_angularComponentB,deltaImpulse); } } void btSequentialImpulseConstraintSolver::resolveSplitPenetrationSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c) { #ifdef USE_SIMD if (!c.m_rhsPenetration) return; gNumSplitImpulseRecoveries++; __m128 cpAppliedImp = _mm_set1_ps(c.m_appliedPushImpulse); __m128 lowerLimit1 = _mm_set1_ps(c.m_lowerLimit); __m128 upperLimit1 = _mm_set1_ps(c.m_upperLimit); __m128 deltaImpulse = _mm_sub_ps(_mm_set1_ps(c.m_rhsPenetration), _mm_mul_ps(_mm_set1_ps(c.m_appliedPushImpulse),_mm_set1_ps(c.m_cfm))); __m128 deltaVel1Dotn = _mm_add_ps(_vmathVfDot3(c.m_contactNormal.mVec128,body1.m_pushVelocity.mVec128), _vmathVfDot3(c.m_relpos1CrossNormal.mVec128,body1.m_turnVelocity.mVec128)); __m128 deltaVel2Dotn = _mm_sub_ps(_vmathVfDot3(c.m_relpos2CrossNormal.mVec128,body2.m_turnVelocity.mVec128),_vmathVfDot3((c.m_contactNormal).mVec128,body2.m_pushVelocity.mVec128)); deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel1Dotn,_mm_set1_ps(c.m_jacDiagABInv))); deltaImpulse = _mm_sub_ps(deltaImpulse,_mm_mul_ps(deltaVel2Dotn,_mm_set1_ps(c.m_jacDiagABInv))); btSimdScalar sum = _mm_add_ps(cpAppliedImp,deltaImpulse); btSimdScalar resultLowerLess,resultUpperLess; resultLowerLess = _mm_cmplt_ps(sum,lowerLimit1); resultUpperLess = _mm_cmplt_ps(sum,upperLimit1); __m128 lowMinApplied = _mm_sub_ps(lowerLimit1,cpAppliedImp); deltaImpulse = _mm_or_ps( _mm_and_ps(resultLowerLess, lowMinApplied), _mm_andnot_ps(resultLowerLess, deltaImpulse) ); c.m_appliedImpulse = _mm_or_ps( _mm_and_ps(resultLowerLess, lowerLimit1), _mm_andnot_ps(resultLowerLess, sum) ); __m128 linearComponentA = _mm_mul_ps(c.m_contactNormal.mVec128,body1.m_invMass.mVec128); __m128 linearComponentB = _mm_mul_ps((c.m_contactNormal).mVec128,body2.m_invMass.mVec128); __m128 impulseMagnitude = deltaImpulse; body1.m_pushVelocity.mVec128 = _mm_add_ps(body1.m_pushVelocity.mVec128,_mm_mul_ps(linearComponentA,impulseMagnitude)); body1.m_turnVelocity.mVec128 = _mm_add_ps(body1.m_turnVelocity.mVec128 ,_mm_mul_ps(c.m_angularComponentA.mVec128,impulseMagnitude)); body2.m_pushVelocity.mVec128 = _mm_sub_ps(body2.m_pushVelocity.mVec128,_mm_mul_ps(linearComponentB,impulseMagnitude)); body2.m_turnVelocity.mVec128 = _mm_add_ps(body2.m_turnVelocity.mVec128 ,_mm_mul_ps(c.m_angularComponentB.mVec128,impulseMagnitude)); #else resolveSplitPenetrationImpulseCacheFriendly(body1,body2,c); #endif } unsigned long btSequentialImpulseConstraintSolver::btRand2() { m_btSeed2 = (1664525L*m_btSeed2 + 1013904223L) & 0xffffffff; return m_btSeed2; } //See ODE: adam's all-int straightforward(?) dRandInt (0..n-1) int btSequentialImpulseConstraintSolver::btRandInt2 (int n) { // seems good; xor-fold and modulus const unsigned long un = static_cast<unsigned long>(n); unsigned long r = btRand2(); // note: probably more aggressive than it needs to be -- might be // able to get away without one or two of the innermost branches. if (un <= 0x00010000UL) { r ^= (r >> 16); if (un <= 0x00000100UL) { r ^= (r >> 8); if (un <= 0x00000010UL) { r ^= (r >> 4); if (un <= 0x00000004UL) { r ^= (r >> 2); if (un <= 0x00000002UL) { r ^= (r >> 1); } } } } } return (int) (r % un); } void btSequentialImpulseConstraintSolver::initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject) { btRigidBody* rb = collisionObject? btRigidBody::upcast(collisionObject) : 0; solverBody->m_deltaLinearVelocity.setValue(0.f,0.f,0.f); solverBody->m_deltaAngularVelocity.setValue(0.f,0.f,0.f); solverBody->m_pushVelocity.setValue(0.f,0.f,0.f); solverBody->m_turnVelocity.setValue(0.f,0.f,0.f); if (rb) { solverBody->m_invMass = btVector3(rb->getInvMass(),rb->getInvMass(),rb->getInvMass())*rb->getLinearFactor(); solverBody->m_originalBody = rb; solverBody->m_angularFactor = rb->getAngularFactor(); } else { solverBody->m_invMass.setValue(0,0,0); solverBody->m_originalBody = 0; solverBody->m_angularFactor.setValue(1,1,1); } } btScalar btSequentialImpulseConstraintSolver::restitutionCurve(btScalar rel_vel, btScalar restitution) { btScalar rest = restitution * -rel_vel; return rest; } void applyAnisotropicFriction(btCollisionObject* colObj,btVector3& frictionDirection); void applyAnisotropicFriction(btCollisionObject* colObj,btVector3& frictionDirection) { if (colObj && colObj->hasAnisotropicFriction()) { // transform to local coordinates btVector3 loc_lateral = frictionDirection * colObj->getWorldTransform().getBasis(); const btVector3& friction_scaling = colObj->getAnisotropicFriction(); //apply anisotropic friction loc_lateral *= friction_scaling; // ... and transform it back to global coordinates frictionDirection = colObj->getWorldTransform().getBasis() * loc_lateral; } } btSolverConstraint& btSequentialImpulseConstraintSolver::addFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation) { btRigidBody* body0=btRigidBody::upcast(colObj0); btRigidBody* body1=btRigidBody::upcast(colObj1); btSolverConstraint& solverConstraint = m_tmpSolverContactFrictionConstraintPool.expand(); memset(&solverConstraint,0xff,sizeof(btSolverConstraint)); solverConstraint.m_contactNormal = normalAxis; solverConstraint.m_solverBodyIdA = solverBodyIdA; solverConstraint.m_solverBodyIdB = solverBodyIdB; solverConstraint.m_frictionIndex = frictionIndex; solverConstraint.m_friction = cp.m_combinedFriction; solverConstraint.m_originalContactPoint = 0; solverConstraint.m_appliedImpulse = 0.f; solverConstraint.m_appliedPushImpulse = 0.f; { btVector3 ftorqueAxis1 = rel_pos1.cross(solverConstraint.m_contactNormal); solverConstraint.m_relpos1CrossNormal = ftorqueAxis1; solverConstraint.m_angularComponentA = body0 ? body0->getInvInertiaTensorWorld()*ftorqueAxis1*body0->getAngularFactor() : btVector3(0,0,0); } { btVector3 ftorqueAxis1 = rel_pos2.cross(-solverConstraint.m_contactNormal); solverConstraint.m_relpos2CrossNormal = ftorqueAxis1; solverConstraint.m_angularComponentB = body1 ? body1->getInvInertiaTensorWorld()*ftorqueAxis1*body1->getAngularFactor() : btVector3(0,0,0); } #ifdef COMPUTE_IMPULSE_DENOM btScalar denom0 = rb0->computeImpulseDenominator(pos1,solverConstraint.m_contactNormal); btScalar denom1 = rb1->computeImpulseDenominator(pos2,solverConstraint.m_contactNormal); #else btVector3 vec; btScalar denom0 = 0.f; btScalar denom1 = 0.f; if (body0) { vec = ( solverConstraint.m_angularComponentA).cross(rel_pos1); denom0 = body0->getInvMass() + normalAxis.dot(vec); } if (body1) { vec = ( -solverConstraint.m_angularComponentB).cross(rel_pos2); denom1 = body1->getInvMass() + normalAxis.dot(vec); } #endif //COMPUTE_IMPULSE_DENOM btScalar denom = relaxation/(denom0+denom1); solverConstraint.m_jacDiagABInv = denom; #ifdef _USE_JACOBIAN solverConstraint.m_jac = btJacobianEntry ( rel_pos1,rel_pos2,solverConstraint.m_contactNormal, body0->getInvInertiaDiagLocal(), body0->getInvMass(), body1->getInvInertiaDiagLocal(), body1->getInvMass()); #endif //_USE_JACOBIAN { btScalar rel_vel; btScalar vel1Dotn = solverConstraint.m_contactNormal.dot(body0?body0->getLinearVelocity():btVector3(0,0,0)) + solverConstraint.m_relpos1CrossNormal.dot(body0?body0->getAngularVelocity():btVector3(0,0,0)); btScalar vel2Dotn = -solverConstraint.m_contactNormal.dot(body1?body1->getLinearVelocity():btVector3(0,0,0)) + solverConstraint.m_relpos2CrossNormal.dot(body1?body1->getAngularVelocity():btVector3(0,0,0)); rel_vel = vel1Dotn+vel2Dotn; btScalar positionalError = 0.f; btSimdScalar velocityError = - rel_vel; btSimdScalar velocityImpulse = velocityError * btSimdScalar(solverConstraint.m_jacDiagABInv); solverConstraint.m_rhs = velocityImpulse; solverConstraint.m_cfm = 0.f; solverConstraint.m_lowerLimit = 0; solverConstraint.m_upperLimit = 1e10f; } return solverConstraint; } int btSequentialImpulseConstraintSolver::getOrInitSolverBody(btCollisionObject& body) { int solverBodyIdA = -1; if (body.getCompanionId() >= 0) { //body has already been converted solverBodyIdA = body.getCompanionId(); } else { btRigidBody* rb = btRigidBody::upcast(&body); if (rb && rb->getInvMass()) { solverBodyIdA = m_tmpSolverBodyPool.size(); btSolverBody& solverBody = m_tmpSolverBodyPool.expand(); initSolverBody(&solverBody,&body); body.setCompanionId(solverBodyIdA); } else { return 0;//assume first one is a fixed solver body } } return solverBodyIdA; } #include <stdio.h> void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal) { btCollisionObject* colObj0=0,*colObj1=0; colObj0 = (btCollisionObject*)manifold->getBody0(); colObj1 = (btCollisionObject*)manifold->getBody1(); int solverBodyIdA=-1; int solverBodyIdB=-1; if (manifold->getNumContacts()) { solverBodyIdA = getOrInitSolverBody(*colObj0); solverBodyIdB = getOrInitSolverBody(*colObj1); } ///avoid collision response between two static objects if (!solverBodyIdA && !solverBodyIdB) return; btVector3 rel_pos1; btVector3 rel_pos2; btScalar relaxation; for (int j=0;j<manifold->getNumContacts();j++) { btManifoldPoint& cp = manifold->getContactPoint(j); if (cp.getDistance() <= manifold->getContactProcessingThreshold()) { const btVector3& pos1 = cp.getPositionWorldOnA(); const btVector3& pos2 = cp.getPositionWorldOnB(); rel_pos1 = pos1 - colObj0->getWorldTransform().getOrigin(); rel_pos2 = pos2 - colObj1->getWorldTransform().getOrigin(); relaxation = 1.f; btScalar rel_vel; btVector3 vel; int frictionIndex = m_tmpSolverContactConstraintPool.size(); { btSolverConstraint& solverConstraint = m_tmpSolverContactConstraintPool.expand(); btRigidBody* rb0 = btRigidBody::upcast(colObj0); btRigidBody* rb1 = btRigidBody::upcast(colObj1); solverConstraint.m_solverBodyIdA = solverBodyIdA; solverConstraint.m_solverBodyIdB = solverBodyIdB; solverConstraint.m_originalContactPoint = &cp; btVector3 torqueAxis0 = rel_pos1.cross(cp.m_normalWorldOnB); solverConstraint.m_angularComponentA = rb0 ? rb0->getInvInertiaTensorWorld()*torqueAxis0*rb0->getAngularFactor() : btVector3(0,0,0); btVector3 torqueAxis1 = rel_pos2.cross(cp.m_normalWorldOnB); solverConstraint.m_angularComponentB = rb1 ? rb1->getInvInertiaTensorWorld()*-torqueAxis1*rb1->getAngularFactor() : btVector3(0,0,0); { #ifdef COMPUTE_IMPULSE_DENOM btScalar denom0 = rb0->computeImpulseDenominator(pos1,cp.m_normalWorldOnB); btScalar denom1 = rb1->computeImpulseDenominator(pos2,cp.m_normalWorldOnB); #else btVector3 vec; btScalar denom0 = 0.f; btScalar denom1 = 0.f; if (rb0) { vec = ( solverConstraint.m_angularComponentA).cross(rel_pos1); denom0 = rb0->getInvMass() + cp.m_normalWorldOnB.dot(vec); } if (rb1) { vec = ( -solverConstraint.m_angularComponentB).cross(rel_pos2); denom1 = rb1->getInvMass() + cp.m_normalWorldOnB.dot(vec); } #endif //COMPUTE_IMPULSE_DENOM btScalar denom = relaxation/(denom0+denom1); solverConstraint.m_jacDiagABInv = denom; } solverConstraint.m_contactNormal = cp.m_normalWorldOnB; solverConstraint.m_relpos1CrossNormal = rel_pos1.cross(cp.m_normalWorldOnB); solverConstraint.m_relpos2CrossNormal = rel_pos2.cross(-cp.m_normalWorldOnB); btVector3 vel1 = rb0 ? rb0->getVelocityInLocalPoint(rel_pos1) : btVector3(0,0,0); btVector3 vel2 = rb1 ? rb1->getVelocityInLocalPoint(rel_pos2) : btVector3(0,0,0); vel = vel1 - vel2; rel_vel = cp.m_normalWorldOnB.dot(vel); btScalar penetration = cp.getDistance()+infoGlobal.m_linearSlop; solverConstraint.m_friction = cp.m_combinedFriction; btScalar restitution = 0.f; if (cp.m_lifeTime>infoGlobal.m_restingContactRestitutionThreshold) { restitution = 0.f; } else { restitution = restitutionCurve(rel_vel, cp.m_combinedRestitution); if (restitution <= btScalar(0.)) { restitution = 0.f; }; } ///warm starting (or zero if disabled) if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) { solverConstraint.m_appliedImpulse = cp.m_appliedImpulse * infoGlobal.m_warmstartingFactor; if (rb0) m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA].applyImpulse(solverConstraint.m_contactNormal*rb0->getInvMass()*rb0->getLinearFactor(),solverConstraint.m_angularComponentA,solverConstraint.m_appliedImpulse); if (rb1) m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB].applyImpulse(solverConstraint.m_contactNormal*rb1->getInvMass()*rb1->getLinearFactor(),-solverConstraint.m_angularComponentB,-solverConstraint.m_appliedImpulse); } else { solverConstraint.m_appliedImpulse = 0.f; } solverConstraint.m_appliedPushImpulse = 0.f; { btScalar rel_vel; btScalar vel1Dotn = solverConstraint.m_contactNormal.dot(rb0?rb0->getLinearVelocity():btVector3(0,0,0)) + solverConstraint.m_relpos1CrossNormal.dot(rb0?rb0->getAngularVelocity():btVector3(0,0,0)); btScalar vel2Dotn = -solverConstraint.m_contactNormal.dot(rb1?rb1->getLinearVelocity():btVector3(0,0,0)) + solverConstraint.m_relpos2CrossNormal.dot(rb1?rb1->getAngularVelocity():btVector3(0,0,0)); rel_vel = vel1Dotn+vel2Dotn; btScalar positionalError = 0.f; positionalError = -penetration * infoGlobal.m_erp/infoGlobal.m_timeStep; btScalar velocityError = restitution - rel_vel;// * damping; btScalar penetrationImpulse = positionalError*solverConstraint.m_jacDiagABInv; btScalar velocityImpulse = velocityError *solverConstraint.m_jacDiagABInv; if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold)) { //combine position and velocity into rhs solverConstraint.m_rhs = penetrationImpulse+velocityImpulse; solverConstraint.m_rhsPenetration = 0.f; } else { //split position and velocity into rhs and m_rhsPenetration solverConstraint.m_rhs = velocityImpulse; solverConstraint.m_rhsPenetration = penetrationImpulse; } solverConstraint.m_cfm = 0.f; solverConstraint.m_lowerLimit = 0; solverConstraint.m_upperLimit = 1e10f; } /////setup the friction constraints if (1) { solverConstraint.m_frictionIndex = m_tmpSolverContactFrictionConstraintPool.size(); if (!(infoGlobal.m_solverMode & SOLVER_ENABLE_FRICTION_DIRECTION_CACHING) || !cp.m_lateralFrictionInitialized) { cp.m_lateralFrictionDir1 = vel - cp.m_normalWorldOnB * rel_vel; btScalar lat_rel_vel = cp.m_lateralFrictionDir1.length2(); if (!(infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > SIMD_EPSILON) { cp.m_lateralFrictionDir1 /= btSqrt(lat_rel_vel); if((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) { cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB); cp.m_lateralFrictionDir2.normalize();//?? applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2); applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2); addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); } applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1); applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1); addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); cp.m_lateralFrictionInitialized = true; } else { //re-calculate friction direction every frame, todo: check if this is really needed btPlaneSpace1(cp.m_normalWorldOnB,cp.m_lateralFrictionDir1,cp.m_lateralFrictionDir2); if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) { applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2); applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2); addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); } applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1); applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1); addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); cp.m_lateralFrictionInitialized = true; } } else { addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); } if (infoGlobal.m_solverMode & SOLVER_USE_FRICTION_WARMSTARTING) { { btSolverConstraint& frictionConstraint1 = m_tmpSolverContactFrictionConstraintPool[solverConstraint.m_frictionIndex]; if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) { frictionConstraint1.m_appliedImpulse = cp.m_appliedImpulseLateral1 * infoGlobal.m_warmstartingFactor; if (rb0) m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA].applyImpulse(frictionConstraint1.m_contactNormal*rb0->getInvMass()*rb0->getLinearFactor(),frictionConstraint1.m_angularComponentA,frictionConstraint1.m_appliedImpulse); if (rb1) m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB].applyImpulse(frictionConstraint1.m_contactNormal*rb1->getInvMass()*rb1->getLinearFactor(),-frictionConstraint1.m_angularComponentB,-frictionConstraint1.m_appliedImpulse); } else { frictionConstraint1.m_appliedImpulse = 0.f; } } if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) { btSolverConstraint& frictionConstraint2 = m_tmpSolverContactFrictionConstraintPool[solverConstraint.m_frictionIndex+1]; if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) { frictionConstraint2.m_appliedImpulse = cp.m_appliedImpulseLateral2 * infoGlobal.m_warmstartingFactor; if (rb0) m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA].applyImpulse(frictionConstraint2.m_contactNormal*rb0->getInvMass(),frictionConstraint2.m_angularComponentA,frictionConstraint2.m_appliedImpulse); if (rb1) m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB].applyImpulse(frictionConstraint2.m_contactNormal*rb1->getInvMass(),-frictionConstraint2.m_angularComponentB,-frictionConstraint2.m_appliedImpulse); } else { frictionConstraint2.m_appliedImpulse = 0.f; } } } else { btSolverConstraint& frictionConstraint1 = m_tmpSolverContactFrictionConstraintPool[solverConstraint.m_frictionIndex]; frictionConstraint1.m_appliedImpulse = 0.f; if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) { btSolverConstraint& frictionConstraint2 = m_tmpSolverContactFrictionConstraintPool[solverConstraint.m_frictionIndex+1]; frictionConstraint2.m_appliedImpulse = 0.f; } } } } } } } btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCollisionObject** /*bodies */,int /*numBodies */,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc) { BT_PROFILE("solveGroupCacheFriendlySetup"); (void)stackAlloc; (void)debugDrawer; if (!(numConstraints + numManifolds)) { // printf("empty\n"); return 0.f; } if (1) { int j; for (j=0;j<numConstraints;j++) { btTypedConstraint* constraint = constraints[j]; constraint->buildJacobian(); } } btSolverBody& fixedBody = m_tmpSolverBodyPool.expand(); initSolverBody(&fixedBody,0); //btRigidBody* rb0=0,*rb1=0; //if (1) { { int totalNumRows = 0; int i; m_tmpConstraintSizesPool.resize(numConstraints); //calculate the total number of contraint rows for (i=0;i<numConstraints;i++) { btTypedConstraint::btConstraintInfo1& info1 = m_tmpConstraintSizesPool[i]; constraints[i]->getInfo1(&info1); totalNumRows += info1.m_numConstraintRows; } m_tmpSolverNonContactConstraintPool.resize(totalNumRows); ///setup the btSolverConstraints int currentRow = 0; for (i=0;i<numConstraints;i++) { const btTypedConstraint::btConstraintInfo1& info1 = m_tmpConstraintSizesPool[i]; if (info1.m_numConstraintRows) { btAssert(currentRow<totalNumRows); btSolverConstraint* currentConstraintRow = &m_tmpSolverNonContactConstraintPool[currentRow]; btTypedConstraint* constraint = constraints[i]; btRigidBody& rbA = constraint->getRigidBodyA(); btRigidBody& rbB = constraint->getRigidBodyB(); int solverBodyIdA = getOrInitSolverBody(rbA); int solverBodyIdB = getOrInitSolverBody(rbB); btSolverBody* bodyAPtr = &m_tmpSolverBodyPool[solverBodyIdA]; btSolverBody* bodyBPtr = &m_tmpSolverBodyPool[solverBodyIdB]; int j; for ( j=0;j<info1.m_numConstraintRows;j++) { memset(&currentConstraintRow[j],0,sizeof(btSolverConstraint)); currentConstraintRow[j].m_lowerLimit = -FLT_MAX; currentConstraintRow[j].m_upperLimit = FLT_MAX; currentConstraintRow[j].m_appliedImpulse = 0.f; currentConstraintRow[j].m_appliedPushImpulse = 0.f; currentConstraintRow[j].m_solverBodyIdA = solverBodyIdA; currentConstraintRow[j].m_solverBodyIdB = solverBodyIdB; } bodyAPtr->m_deltaLinearVelocity.setValue(0.f,0.f,0.f); bodyAPtr->m_deltaAngularVelocity.setValue(0.f,0.f,0.f); bodyBPtr->m_deltaLinearVelocity.setValue(0.f,0.f,0.f); bodyBPtr->m_deltaAngularVelocity.setValue(0.f,0.f,0.f); btTypedConstraint::btConstraintInfo2 info2; info2.fps = 1.f/infoGlobal.m_timeStep; info2.erp = infoGlobal.m_erp; info2.m_J1linearAxis = currentConstraintRow->m_contactNormal; info2.m_J1angularAxis = currentConstraintRow->m_relpos1CrossNormal; info2.m_J2linearAxis = 0; info2.m_J2angularAxis = currentConstraintRow->m_relpos2CrossNormal; info2.rowskip = sizeof(btSolverConstraint)/sizeof(btScalar);//check this ///the size of btSolverConstraint needs be a multiple of btScalar btAssert(info2.rowskip*sizeof(btScalar)== sizeof(btSolverConstraint)); info2.m_constraintError = &currentConstraintRow->m_rhs; info2.cfm = &currentConstraintRow->m_cfm; info2.m_lowerLimit = &currentConstraintRow->m_lowerLimit; info2.m_upperLimit = &currentConstraintRow->m_upperLimit; info2.m_numIterations = infoGlobal.m_numIterations; constraints[i]->getInfo2(&info2); ///finalize the constraint setup for ( j=0;j<info1.m_numConstraintRows;j++) { btSolverConstraint& solverConstraint = currentConstraintRow[j]; { const btVector3& ftorqueAxis1 = solverConstraint.m_relpos1CrossNormal; solverConstraint.m_angularComponentA = constraint->getRigidBodyA().getInvInertiaTensorWorld()*ftorqueAxis1*constraint->getRigidBodyA().getAngularFactor(); } { const btVector3& ftorqueAxis2 = solverConstraint.m_relpos2CrossNormal; solverConstraint.m_angularComponentB = constraint->getRigidBodyB().getInvInertiaTensorWorld()*ftorqueAxis2*constraint->getRigidBodyB().getAngularFactor(); } { btVector3 iMJlA = solverConstraint.m_contactNormal*rbA.getInvMass(); btVector3 iMJaA = rbA.getInvInertiaTensorWorld()*solverConstraint.m_relpos1CrossNormal; btVector3 iMJlB = solverConstraint.m_contactNormal*rbB.getInvMass();//sign of normal? btVector3 iMJaB = rbB.getInvInertiaTensorWorld()*solverConstraint.m_relpos2CrossNormal; btScalar sum = iMJlA.dot(solverConstraint.m_contactNormal); sum += iMJaA.dot(solverConstraint.m_relpos1CrossNormal); sum += iMJlB.dot(solverConstraint.m_contactNormal); sum += iMJaB.dot(solverConstraint.m_relpos2CrossNormal); solverConstraint.m_jacDiagABInv = btScalar(1.)/sum; } ///fix rhs ///todo: add force/torque accelerators { btScalar rel_vel; btScalar vel1Dotn = solverConstraint.m_contactNormal.dot(rbA.getLinearVelocity()) + solverConstraint.m_relpos1CrossNormal.dot(rbA.getAngularVelocity()); btScalar vel2Dotn = -solverConstraint.m_contactNormal.dot(rbB.getLinearVelocity()) + solverConstraint.m_relpos2CrossNormal.dot(rbB.getAngularVelocity()); rel_vel = vel1Dotn+vel2Dotn; btScalar restitution = 0.f; btScalar positionalError = solverConstraint.m_rhs;//already filled in by getConstraintInfo2 btScalar velocityError = restitution - rel_vel;// * damping; btScalar penetrationImpulse = positionalError*solverConstraint.m_jacDiagABInv; btScalar velocityImpulse = velocityError *solverConstraint.m_jacDiagABInv; solverConstraint.m_rhs = penetrationImpulse+velocityImpulse; solverConstraint.m_appliedImpulse = 0.f; } } } currentRow+=m_tmpConstraintSizesPool[i].m_numConstraintRows; } } { int i; btPersistentManifold* manifold = 0; btCollisionObject* colObj0=0,*colObj1=0; for (i=0;i<numManifolds;i++) { manifold = manifoldPtr[i]; convertContact(manifold,infoGlobal); } } } btContactSolverInfo info = infoGlobal; int numConstraintPool = m_tmpSolverContactConstraintPool.size(); int numFrictionPool = m_tmpSolverContactFrictionConstraintPool.size(); ///@todo: use stack allocator for such temporarily memory, same for solver bodies/constraints m_orderTmpConstraintPool.resize(numConstraintPool); m_orderFrictionConstraintPool.resize(numFrictionPool); { int i; for (i=0;i<numConstraintPool;i++) { m_orderTmpConstraintPool[i] = i; } for (i=0;i<numFrictionPool;i++) { m_orderFrictionConstraintPool[i] = i; } } return 0.f; } btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(btCollisionObject** /*bodies */,int /*numBodies*/,btPersistentManifold** /*manifoldPtr*/, int /*numManifolds*/,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* /*debugDrawer*/,btStackAlloc* /*stackAlloc*/) { BT_PROFILE("solveGroupCacheFriendlyIterations"); int numConstraintPool = m_tmpSolverContactConstraintPool.size(); int numFrictionPool = m_tmpSolverContactFrictionConstraintPool.size(); //should traverse the contacts random order... int iteration; { for ( iteration = 0;iteration<infoGlobal.m_numIterations;iteration++) { int j; if (infoGlobal.m_solverMode & SOLVER_RANDMIZE_ORDER) { if ((iteration & 7) == 0) { for (j=0; j<numConstraintPool; ++j) { int tmp = m_orderTmpConstraintPool[j]; int swapi = btRandInt2(j+1); m_orderTmpConstraintPool[j] = m_orderTmpConstraintPool[swapi]; m_orderTmpConstraintPool[swapi] = tmp; } for (j=0; j<numFrictionPool; ++j) { int tmp = m_orderFrictionConstraintPool[j]; int swapi = btRandInt2(j+1); m_orderFrictionConstraintPool[j] = m_orderFrictionConstraintPool[swapi]; m_orderFrictionConstraintPool[swapi] = tmp; } } } if (infoGlobal.m_solverMode & SOLVER_SIMD) { ///solve all joint constraints, using SIMD, if available for (j=0;j<m_tmpSolverNonContactConstraintPool.size();j++) { btSolverConstraint& constraint = m_tmpSolverNonContactConstraintPool[j]; resolveSingleConstraintRowGenericSIMD(m_tmpSolverBodyPool[constraint.m_solverBodyIdA],m_tmpSolverBodyPool[constraint.m_solverBodyIdB],constraint); } for (j=0;j<numConstraints;j++) { int bodyAid = getOrInitSolverBody(constraints[j]->getRigidBodyA()); int bodyBid = getOrInitSolverBody(constraints[j]->getRigidBodyB()); btSolverBody& bodyA = m_tmpSolverBodyPool[bodyAid]; btSolverBody& bodyB = m_tmpSolverBodyPool[bodyBid]; constraints[j]->solveConstraintObsolete(bodyA,bodyB,infoGlobal.m_timeStep); } ///solve all contact constraints using SIMD, if available int numPoolConstraints = m_tmpSolverContactConstraintPool.size(); for (j=0;j<numPoolConstraints;j++) { const btSolverConstraint& solveManifold = m_tmpSolverContactConstraintPool[m_orderTmpConstraintPool[j]]; resolveSingleConstraintRowLowerLimitSIMD(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold); } ///solve all friction constraints, using SIMD, if available int numFrictionPoolConstraints = m_tmpSolverContactFrictionConstraintPool.size(); for (j=0;j<numFrictionPoolConstraints;j++) { btSolverConstraint& solveManifold = m_tmpSolverContactFrictionConstraintPool[m_orderFrictionConstraintPool[j]]; btScalar totalImpulse = m_tmpSolverContactConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse; if (totalImpulse>btScalar(0)) { solveManifold.m_lowerLimit = -(solveManifold.m_friction*totalImpulse); solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse; resolveSingleConstraintRowGenericSIMD(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA], m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold); } } } else { ///solve all joint constraints for (j=0;j<m_tmpSolverNonContactConstraintPool.size();j++) { btSolverConstraint& constraint = m_tmpSolverNonContactConstraintPool[j]; resolveSingleConstraintRowGeneric(m_tmpSolverBodyPool[constraint.m_solverBodyIdA],m_tmpSolverBodyPool[constraint.m_solverBodyIdB],constraint); } for (j=0;j<numConstraints;j++) { int bodyAid = getOrInitSolverBody(constraints[j]->getRigidBodyA()); int bodyBid = getOrInitSolverBody(constraints[j]->getRigidBodyB()); btSolverBody& bodyA = m_tmpSolverBodyPool[bodyAid]; btSolverBody& bodyB = m_tmpSolverBodyPool[bodyBid]; constraints[j]->solveConstraintObsolete(bodyA,bodyB,infoGlobal.m_timeStep); } ///solve all contact constraints int numPoolConstraints = m_tmpSolverContactConstraintPool.size(); for (j=0;j<numPoolConstraints;j++) { const btSolverConstraint& solveManifold = m_tmpSolverContactConstraintPool[m_orderTmpConstraintPool[j]]; resolveSingleConstraintRowLowerLimit(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold); } ///solve all friction constraints int numFrictionPoolConstraints = m_tmpSolverContactFrictionConstraintPool.size(); for (j=0;j<numFrictionPoolConstraints;j++) { btSolverConstraint& solveManifold = m_tmpSolverContactFrictionConstraintPool[m_orderFrictionConstraintPool[j]]; btScalar totalImpulse = m_tmpSolverContactConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse; if (totalImpulse>btScalar(0)) { solveManifold.m_lowerLimit = -(solveManifold.m_friction*totalImpulse); solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse; resolveSingleConstraintRowGeneric(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA], m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold); } } } } if (infoGlobal.m_splitImpulse) { if (infoGlobal.m_solverMode & SOLVER_SIMD) { for ( iteration = 0;iteration<infoGlobal.m_numIterations;iteration++) { { int numPoolConstraints = m_tmpSolverContactConstraintPool.size(); int j; for (j=0;j<numPoolConstraints;j++) { const btSolverConstraint& solveManifold = m_tmpSolverContactConstraintPool[m_orderTmpConstraintPool[j]]; resolveSplitPenetrationSIMD(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA], m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold); } } } } else { for ( iteration = 0;iteration<infoGlobal.m_numIterations;iteration++) { { int numPoolConstraints = m_tmpSolverContactConstraintPool.size(); int j; for (j=0;j<numPoolConstraints;j++) { const btSolverConstraint& solveManifold = m_tmpSolverContactConstraintPool[m_orderTmpConstraintPool[j]]; resolveSplitPenetrationImpulseCacheFriendly(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA], m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold); } } } } } } return 0.f; } /// btSequentialImpulseConstraintSolver Sequentially applies impulses btScalar btSequentialImpulseConstraintSolver::solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc,btDispatcher* /*dispatcher*/) { BT_PROFILE("solveGroup"); //we only implement SOLVER_CACHE_FRIENDLY now //you need to provide at least some bodies btAssert(bodies); btAssert(numBodies); int i; solveGroupCacheFriendlySetup( bodies, numBodies, manifoldPtr, numManifolds,constraints, numConstraints,infoGlobal,debugDrawer, stackAlloc); solveGroupCacheFriendlyIterations(bodies, numBodies, manifoldPtr, numManifolds,constraints, numConstraints,infoGlobal,debugDrawer, stackAlloc); int numPoolConstraints = m_tmpSolverContactConstraintPool.size(); int j; for (j=0;j<numPoolConstraints;j++) { const btSolverConstraint& solveManifold = m_tmpSolverContactConstraintPool[j]; btManifoldPoint* pt = (btManifoldPoint*) solveManifold.m_originalContactPoint; btAssert(pt); pt->m_appliedImpulse = solveManifold.m_appliedImpulse; if (infoGlobal.m_solverMode & SOLVER_USE_FRICTION_WARMSTARTING) { pt->m_appliedImpulseLateral1 = m_tmpSolverContactFrictionConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse; pt->m_appliedImpulseLateral2 = m_tmpSolverContactFrictionConstraintPool[solveManifold.m_frictionIndex+1].m_appliedImpulse; } //do a callback here? } if (infoGlobal.m_splitImpulse) { for ( i=0;i<m_tmpSolverBodyPool.size();i++) { m_tmpSolverBodyPool[i].writebackVelocity(infoGlobal.m_timeStep); } } else { for ( i=0;i<m_tmpSolverBodyPool.size();i++) { m_tmpSolverBodyPool[i].writebackVelocity(); } } m_tmpSolverBodyPool.resize(0); m_tmpSolverContactConstraintPool.resize(0); m_tmpSolverNonContactConstraintPool.resize(0); m_tmpSolverContactFrictionConstraintPool.resize(0); return 0.f; } void btSequentialImpulseConstraintSolver::reset() { m_btSeed2 = 0; }
[ "caiocsabino@7e2be596-0d54-0410-9f9d-cf4183935158" ]
[ [ [ 1, 1147 ] ] ]
0eb6d90ec8d2b2c593b960fb6803ff5517c6e0ef
14a00dfaf0619eb57f1f04bb784edd3126e10658
/Lab1/SupportCode/ColorMap.cpp
45aab22d1e47211ff7859b19aae5c51bffc55a58
[]
no_license
SHINOTECH/modanimation
89f842262b1f552f1044d4aafb3d5a2ce4b587bd
43d0fde55cf75df9d9a28a7681eddeb77460f97c
refs/heads/master
2021-01-21T09:34:18.032922
2010-04-07T12:23:13
2010-04-07T12:23:13
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
1,999
cpp
/************************************************************************************************* * * Modeling and animation (TNM079) 2007 * Code base for lab assignments. Copyright: * Gunnar Johansson ([email protected]) * Ken Museth ([email protected]) * Michael Bang Nielsen ([email protected]) * Ola Nilsson ([email protected]) * Andreas Söderström ([email protected]) * *************************************************************************************************/ #include "ColorMap.h" //----------------------------------------------------------------------------- ColorMap::ColorMap() { /* % A matlab script to export colormaps function f=pcmap(cmap) s = size(cmap); for i=1:s(1,1) fprintf(1, 'colors.push_back(Vector3<float>(%f, %f, %f));\n', cmap(i,1), cmap(i,2), cmap(i,3)); end */ // run the above script with for example the colormap jet: pcmap(jet) // and paste the result below to change colormap // A simple red-black-blue colormap colors.push_back(Vector3<float>(1, 0, 0)); colors.push_back(Vector3<float>(0, 0, 0)); colors.push_back(Vector3<float>(1, 0, 1)); } //----------------------------------------------------------------------------- Vector3<float> ColorMap::map(float val, float low, float high) const { float h = switch1(val, low, high); h = clamp(h, 0.f, 1.f); float pos = h*(colors.size()-1); float t = pos - floorf(pos); unsigned int index = (unsigned int) floorf(pos); // linear interpolation return colors[index]*(1-t) + colors[index+1]*t; } //----------------------------------------------------------------------------- Vector3<float> ColorMap::map(Vector3<float> vec, float low, float high) const { return Vector3<float>(switch1(vec.x(), low, high),switch1(vec.y(), low, high),switch1(vec.z(), low, high)); } //-----------------------------------------------------------------------------
[ "jpjorge@da195381-492e-0410-b4d9-ef7979db4686" ]
[ [ [ 1, 46 ] ] ]
35f240b76facbd56c2f376af4b4474451e35d8c5
191d4160cba9d00fce9041a1cc09f17b4b027df5
/ZeroLag/ZeroLag/ZeroLag.h
940f7dc1b1fec1733d5f12f2b6d200fc802995a2
[]
no_license
zapline/zero-lag
f71d35efd7b2f884566a45b5c1dc6c7eec6577dd
1651f264c6d2dc64e4bdcb6529fb6280bbbfbcf4
refs/heads/master
2021-01-22T16:45:46.430952
2011-05-07T13:22:52
2011-05-07T13:22:52
32,774,187
3
2
null
null
null
null
GB18030
C++
false
false
491
h
// ZeroLag.h : PROJECT_NAME 应用程序的主头文件 // #pragma once #ifndef __AFXWIN_H__ #error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件" #endif #include "resource.h" // 主符号 // CZeroLagApp: // 有关此类的实现,请参阅 ZeroLag.cpp // class CZeroLagApp : public CWinApp { public: CZeroLagApp(); // 重写 public: virtual BOOL InitInstance(); // 实现 DECLARE_MESSAGE_MAP() }; extern CZeroLagApp theApp;
[ "Administrator@PC-200201010241" ]
[ [ [ 1, 31 ] ] ]
c8f61430e4ff9d6c732d872983cbf05b728af3f4
7b4c786d4258ce4421b1e7bcca9011d4eeb50083
/数据结构(C语言版)/第3章 栈和队列/stack_test_20090925.cpp
d49a1909badd40dc4007ffd465777a5e4202d10c
[]
no_license
lzq123218/guoyishi-works
dbfa42a3e2d3bd4a984a5681e4335814657551ef
4e78c8f2e902589c3f06387374024225f52e5a92
refs/heads/master
2021-12-04T11:11:32.639076
2011-05-30T14:12:43
2011-05-30T14:12:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,797
cpp
/////////////////////////////////////////////////////////////////////////// // Data: 2009-09-25 // Author: Yishi Guo // Copy: http://www.cse.unr.edu/~bebis/CS308/PowerPoint/Stacks.ppt // About: Stacks | Data Structures /////////////////////////////////////////////////////////////////////////// #include <iostream.h> #define MAX_ITEMS 100 template <class ItemType> class StackType { public: StackType(); void MakeEmpty(); bool isEmpty() const; bool isFull() const; bool Push(ItemType); bool Pop(ItemType&); private: int top; ItemType items[MAX_ITEMS]; }; template <class ItemType> StackType<ItemType>::StackType() { top = -1; } template <class ItemType> void StackType<ItemType>::MakeEmpty() { top = -1; } template <class ItemType> bool StackType<ItemType>::isEmpty() const { return (top == -1); } template <class ItemType> bool StackType<ItemType>::isFull() const { return (top == MAX_ITEMS - 1); } template <class ItemType> bool StackType<ItemType>::Push(ItemType item) { if (!isFull()) { top++; items[top] = item; } else { return false; } return true; } template <class ItemType> bool StackType<ItemType>::Pop(ItemType& item) { if (!isEmpty()) { item = items[top]; top--; } else { return false; } return true; } /******************************************* // Test the stack int main() { StackType<int> stack_int; int i; stack_int.Push(1); stack_int.Push(2); stack_int.Push(3); stack_int.Pop(i); stack_int.Push(4); stack_int.Push(5); stack_int.Pop(i); stack_int.Push(6); while (!stack_int.isEmpty()) { stack_int.Pop(i); cout << i << ", "; } cout << endl; return 0; } ********************************************/
[ "baicaibang@70501136-4834-11de-8855-c187e5f49513" ]
[ [ [ 1, 95 ] ] ]
f83d40f63f05a3bbb491f9cc794d8da4a42d9ab5
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/nGENE Proj/PrefabCylinder.cpp
6dc532d58330a2cd5b0028ce9ec0c05b27fee23b
[]
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
9,634
cpp
/* --------------------------------------------------------------------------- This source file is part of nGENE Tech. Copyright (c) 2006- Wojciech Toman This program is free software. File: PrefabCylinder.cpp Version: 0.02 --------------------------------------------------------------------------- */ #include "PrecompiledHeaders.h" #include "PrefabCylinder.h" #include "VertexBufferManager.h" namespace nGENE { // Initialize static members TypeInfo PrefabCylinder::Type(L"PrefabCylinder", &NodePrefab::Type); PrefabCylinder::PrefabCylinder(uint _slices, uint _stacks, float _radius, float _height, bool _closed, const Vector2& _texCoordMul): NodePrefab(_texCoordMul), m_fRadius(_radius), m_fHeight(_height), m_nSlices(_slices), m_nStacks(_stacks), m_bClosed(_closed) { } //---------------------------------------------------------------------- PrefabCylinder::PrefabCylinder() { } //---------------------------------------------------------------------- PrefabCylinder::~PrefabCylinder() { cleanup(); } //---------------------------------------------------------------------- void PrefabCylinder::init() { updateGeometry(); } //---------------------------------------------------------------------- void PrefabCylinder::cleanup() { } //---------------------------------------------------------------------- void PrefabCylinder::serialize(ISerializer* _serializer, bool _serializeType, bool _serializeChildren) { if(!m_bIsSerializable) return; if(_serializeType) _serializer->addObject(this->Type); NodePrefab::serialize(_serializer, false, _serializeChildren); // Serialize cylinder Property <float> prRadius(m_fRadius); Property <float> prHeight(m_fHeight); _serializer->addProperty("Radius", prRadius); _serializer->addProperty("Height", prHeight); Property <uint> prSlices(m_nSlices); _serializer->addProperty("Slices", prSlices); Property <uint> prStacks(m_nStacks); _serializer->addProperty("Stacks", prStacks); Property <bool> prClosed(m_bClosed); _serializer->addProperty("IsClosed", prClosed); if(_serializeType) _serializer->endObject(this->Type); } //---------------------------------------------------------------------- void PrefabCylinder::deserialize(ISerializer* _serializer) { // Deserialize cylinder Property <float> prRadius(m_fRadius); Property <float> prHeight(m_fHeight); _serializer->getProperty("Radius", prRadius); _serializer->getProperty("Height", prHeight); Property <uint> prSlices(m_nSlices); _serializer->getProperty("Slices", prSlices); Property <uint> prStacks(m_nStacks); _serializer->getProperty("Stacks", prStacks); Property <bool> prClosed(m_bClosed); _serializer->getProperty("IsClosed", prClosed); NodePrefab::deserialize(_serializer); } //---------------------------------------------------------------------- void PrefabCylinder::updateGeometry() { // Create cylinders's geometry uint index = 0; // Set vertices dword dwNumVertices = m_nStacks * (m_nSlices + 1) + (m_bClosed ? 2 : 0); SVertex* pVertices = new SVertex[dwNumVertices]; memset(pVertices, 0, dwNumVertices * sizeof(SVertex)); float inverseRadial = 1.0f / m_nSlices; float inverseAxisLess = 1.0f / (m_bClosed ? m_nStacks - 3 : m_nStacks - 1); float inverseAxisLessTexture = 1.0f / (m_nStacks - 1); float halfHeight = 0.5f * m_fHeight; float* sin = new float[m_nSlices + 1]; float* cos = new float[m_nSlices + 1]; for (uint i = 0; i < m_nSlices; ++i) { float angle = Maths::PI_DOUBLE * inverseRadial * i; cos[i] = Maths::fcos(angle); sin[i] = Maths::fsin(angle); } sin[m_nSlices] = sin[0]; cos[m_nSlices] = cos[0]; Vector3 tempNormal; for(uint stack = 0; stack < m_nStacks; ++stack) { float stackFrac; float stackFracTex; int topBottom = 0; if(!m_bClosed) { stackFrac = stack * inverseAxisLess; stackFracTex = stackFrac; } else { if(!stack) { topBottom = -1; stackFrac = 0; stackFracTex = inverseAxisLessTexture; } else if(stack == m_nStacks - 1) { topBottom = 1; stackFrac = 1; stackFracTex = 1 - inverseAxisLessTexture; } else { stackFrac = (stack - 1) * inverseAxisLess; stackFracTex = stack * inverseAxisLessTexture; } } float y = -halfHeight + m_fHeight * stackFrac; Vector3 centre(0.0f, y, 0.0f); int prevIndex = index; for(uint slice = 0; slice < m_nSlices; ++slice) { float radialFrac = slice * inverseRadial; tempNormal.set(cos[slice], 0.0f, sin[slice]); if(topBottom) pVertices[index].vecNormal = Vector3::UNIT_Y * topBottom; else pVertices[index].vecNormal = tempNormal; tempNormal *= m_fRadius; tempNormal += centre; pVertices[index].vecPosition = tempNormal; pVertices[index].vecTexCoord.x = radialFrac * m_vecTexCoordMul.x; pVertices[index].vecTexCoord.y = (1.0f - stackFracTex) * m_vecTexCoordMul.y; pVertices[index].dwColour = 0xffffffff; ++index; } pVertices[index].vecNormal = pVertices[prevIndex].vecNormal; pVertices[index].dwColour = 0xffffffff; pVertices[index].vecPosition = pVertices[prevIndex].vecPosition; pVertices[index].vecTexCoord.x = 1.0f * m_vecTexCoordMul.x; pVertices[index].vecTexCoord.y = (1.0f - stackFracTex) * m_vecTexCoordMul.y; ++index; } if(m_bClosed) { pVertices[index].vecPosition = Vector3(0.0f, -halfHeight, 0.0f); pVertices[index].vecNormal = Vector3::UNIT_Y; pVertices[index].vecTexCoord = Vector2(0.5f, 1.0f); ++index; pVertices[index].vecPosition = Vector3(0.0f, halfHeight, 0.0f); pVertices[index].vecNormal = Vector3::UNIT_Y; pVertices[index].vecTexCoord = Vector2(0.5f, 0.0f); ++index; } // Set indices dword dwNumIndices = 3 * (((m_bClosed ? 2 : 0) + 2 * (m_nStacks - 1)) * m_nSlices); short* pIndices = new short[dwNumIndices]; index = 0; uint baseIndex = 0; for(uint stack = 0; stack < m_nStacks - 1; ++stack) { uint index0 = baseIndex; uint index1 = index0 + 1; baseIndex += m_nSlices + 1; uint index2 = baseIndex; uint index3 = index2 + 1; for(uint i = 0; i < m_nSlices; ++i) { if(m_bClosed && !stack) { pIndices[index++] = index0++; pIndices[index++] = dwNumVertices - 2; pIndices[index++] = index1++; } else if(m_bClosed && stack == m_nStacks - 2) { pIndices[index++] = index2++; pIndices[index++] = index3++; pIndices[index++] = dwNumVertices - 1; } else { pIndices[index++] = index0++; pIndices[index++] = index1; pIndices[index++] = index2; pIndices[index++] = index1++; pIndices[index++] = index3++; pIndices[index++] = index2++; } } } VertexBuffer* vb; IndexedBuffer* ivb; VertexBufferManager& manager = VertexBufferManager::getSingleton(); INDEXEDBUFFER_DESC ivbDesc; ivbDesc.indices = pIndices; ivbDesc.indicesNum = dwNumIndices; ivb = manager.createIndexedBuffer(ivbDesc); VERTEXBUFFER_DESC vbDesc; vbDesc.vertices = pVertices; vbDesc.verticesNum = dwNumVertices; vbDesc.primitivesNum = dwNumIndices / 3; vbDesc.primitivesType = PT_TRIANGLELIST; vbDesc.indices = ivb; vbDesc.vertexDeclaration = manager.getVertexDeclaration(L"Default"); vb = manager.createVertexBuffer(vbDesc); updateSurface(L"Base", vb); // Create normals surface SVertex* pNormals = new SVertex[dwNumVertices * 2]; for(uint i = 0; i < dwNumVertices * 2; i += 2) { pNormals[i].vecPosition = pVertices[i / 2].vecPosition; pNormals[i + 1].vecPosition = pVertices[i / 2].vecPosition + pVertices[i / 2].vecNormal * 0.25f; pNormals[i].dwColour = pNormals[i + 1].dwColour = 0xffffffff; pNormals[i].vecTexCoord = pNormals[i + 1].vecTexCoord = Vector2::ZERO_VECTOR; pNormals[i].vecNormal = pNormals[i + 1].vecNormal = Vector3::UNIT_Y; } VERTEXBUFFER_DESC vbDescNormals; vbDescNormals.vertices = pNormals; vbDescNormals.verticesNum = dwNumVertices * 2; vbDescNormals.primitivesNum = dwNumVertices; vbDescNormals.primitivesType = PT_LINELIST; vbDescNormals.vertexDeclaration = manager.getVertexDeclaration(L"Default"); VertexBuffer* vbNormals = manager.createVertexBuffer(vbDescNormals); Surface* pSurface = updateSurface(L"Normals", vbNormals); pSurface->setPickable(false); NGENE_DELETE_ARRAY(sin); NGENE_DELETE_ARRAY(cos); NGENE_DELETE_ARRAY(pNormals); NGENE_DELETE_ARRAY(pIndices); NGENE_DELETE_ARRAY(pVertices); calculateBoundingBox(); } //---------------------------------------------------------------------- void PrefabCylinder::setRadius(Real _radius) { m_fRadius = _radius; updateGeometry(); } //---------------------------------------------------------------------- void PrefabCylinder::setHeight(Real _radius) { m_fHeight = _radius; updateGeometry(); } //---------------------------------------------------------------------- void PrefabCylinder::setSlices(uint _slices) { m_nSlices = _slices; updateGeometry(); } //---------------------------------------------------------------------- void PrefabCylinder::setStacks(uint _slices) { m_nStacks = _slices; updateGeometry(); } //---------------------------------------------------------------------- }
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 337 ] ] ]
a430fd563d5bef06a67016cd8cd4b0276beb4edf
12ea67a9bd20cbeed3ed839e036187e3d5437504
/winxgui/GuiLib/Samples/OutlookDemo/GuiToolBar.cpp
8fff7f5f1cd9a99c7ec3bd9578114597a0b25fef
[]
no_license
cnsuhao/winxgui
e0025edec44b9c93e13a6c2884692da3773f9103
348bb48994f56bf55e96e040d561ec25642d0e46
refs/heads/master
2021-05-28T21:33:54.407837
2008-09-13T19:43:38
2008-09-13T19:43:38
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
3,618
cpp
// GuiToolBar.cpp: implementation of the GuiToolBar class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "OutlookDemo.h" #include "GuiToolBar.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// BEGIN_MESSAGE_MAP(GuiToolBar, CControlBar) //{{AFX_MSG_MAP(GuiToolBar) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code ! ON_WM_CREATE() ON_WM_PAINT() ON_WM_NCPAINT() ON_WM_NCCALCSIZE() ON_WM_WINDOWPOSCHANGING() ON_WM_CAPTURECHANGED() ON_WM_SETTINGCHANGE() ON_WM_LBUTTONUP() ON_WM_MOUSEMOVE() ON_WM_NCLBUTTONDOWN() ON_WM_LBUTTONDOWN() ON_WM_LBUTTONDBLCLK() ON_WM_RBUTTONDOWN() ON_WM_NCMOUSEMOVE() ON_WM_NCHITTEST() ON_WM_CLOSE() ON_WM_SIZE() //}}AFX_MSG_MAP END_MESSAGE_MAP() GuiToolBar::GuiToolBar() { m_iBorder=4; cb.CreateSysColorBrush(COLOR_BTNFACE); } GuiToolBar::~GuiToolBar() { } BOOL GuiToolBar::Create (CWnd* pParentWnd,CString m_szTitle, UINT uID,DWORD dwStyle) { ASSERT_VALID(pParentWnd); // return FALSE; CString m_szClassName=::AfxRegisterWndClass(CS_DBLCLKS,LoadCursor(NULL,IDC_ARROW),cb); if (!CWnd::Create(m_szClassName,m_szTitle,dwStyle,CRect(0,0,0,0),pParentWnd,uID)) return FALSE; return TRUE; } void GuiToolBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler) { //in this moment nothing to do } CSize GuiToolBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) { //incialmente esta barra no flotara lo que nos obliga //a ignorar los parametros de la función CRect rcWindow; //necesitamos hallar el ancho de la ventana, por que el Alto //le indicamos al sistema que lo tome total m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_LEFT)->GetWindowRect(&rcWindow); return CSize(rcWindow.Width(),32767); } int GuiToolBar::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CControlBar::OnCreate(lpCreateStruct)==-1) return -1; return 0; } void GuiToolBar::OnNcPaint() { CRect rcWindow; CWindowDC dc(this); EraseNonClient(); GetWindowRect(&rcWindow); dc.FillSolidRect(rcWindow.right,rcWindow.top,rcWindow.right+1,rcWindow.bottom,::GetSysColor(COLOR_BTNSHADOW)); } void GuiToolBar::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) { //esta función si es muy importante, porque le daremos //el tamaño del area cliente lpncsp->rgrc[0].top+=m_iBorder; lpncsp->rgrc[0].bottom-=m_iBorder; lpncsp->rgrc[0].left+=m_iBorder; lpncsp->rgrc[0].right-=m_iBorder; GetWindowRect(&mrcBorder); mrcBorder.left=mrcBorder.right-m_iBorder; } UINT GuiToolBar::OnNcHitTest(CPoint point) { CRect m_rcWindow; GetWindowRect(&m_rcWindow); point.Offset(-m_rcWindow.left,-m_rcWindow.top); if (m_rcWindow.PtInRect(point)) return HTSIZE; else return CControlBar::OnNcHitTest(point); } void GuiToolBar::OnNcLButtonDown(UINT nHitTest, CPoint point) { /* if (nHitTest == HTSIZE) { //CPoint cp; //GetCursorPos(&cp); //if (mrcBorder.PtInRect(point)) // ; //permita redimensionar la ventana } else CControlBar::OnNcLButtonDown(UINT nHitTest, CPoint point);*/ } void GuiToolBar::OnLButtonUp(UINT nFlags, CPoint point) { //m_pDockSite->RecalcLayout(); }
[ "xushiweizh@86f14454-5125-0410-a45d-e989635d7e98" ]
[ [ [ 1, 150 ] ] ]
3823dc465196493bc1313f97a5040440f620e3ba
6253ab92ce2e85b4db9393aa630bde24655bd9b4
/Common/Ibeo/IbeoTahoeCalibration.h
e58f3b0ab7b8d6fe16ec041401df1c40bacbd649
[]
no_license
Aand1/cornell-urban-challenge
94fd4df18fd4b6cc6e12d30ed8eed280826d4aed
779daae8703fe68e7c6256932883de32a309a119
refs/heads/master
2021-01-18T11:57:48.267384
2008-10-01T06:43:18
2008-10-01T06:43:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,468
h
#ifndef IBEO_TAHOE_CALIBRATION_H_SEPT_28_2007_SVL5 #define IBEO_TAHOE_CALIBRATION_H_SEPT_28_2007_SVL5 #include "../Math/Angle.h" #include "../Fusion/Sensor.h" #define __IBEO_SENSOR_CALIBRATION_CHEAT\ inline Sensor SensorCalibration(){\ Sensor ret;\ ret.SensorX = x;\ ret.SensorY = y;\ ret.SensorZ = z;\ ret.SensorYaw = yaw;\ ret.SensorPitch = pitch;\ ret.SensorRoll = roll;\ return ret;\ } #define __IBEO_CALIBRATION_XYZ_YPR_RAD(X,Y,Z,YAW,PITCH,ROLL)\ const float x=(float)X),y=(float)(Y),z=(float)(Z),yaw=(float)(YAW),pitch=(float)(PITCH),roll=(float)(ROLL);\ __IBEO_SENSOR_CALIBRATION_CHEAT; #define __IBEO_CALIBRATION_XYZ_YPR_DEG(X,Y,Z,YAW,PITCH,ROLL)\ const float x=(float)(X),y=(float)(Y),z=(float)(Z),yaw=Deg2Rad((float)(YAW)),pitch=Deg2Rad((float)(PITCH)),roll=Deg2Rad((float)(ROLL));\ __IBEO_SENSOR_CALIBRATION_CHEAT; // all parameters IMU-relative namespace IBEO_CALIBRATION{ namespace AUG_2007{ namespace FRONT_LEFT{ __IBEO_CALIBRATION_XYZ_YPR_DEG(3.5306,0.8,-0.5118,37.05,-1.1,-0.9); } namespace FRONT_CENTER{ __IBEO_CALIBRATION_XYZ_YPR_DEG(3.6449,0.0f,-0.0508,0,0,0); } namespace FRONT_RIGHT{ __IBEO_CALIBRATION_XYZ_YPR_DEG(3.5306,-0.8,-0.5118,-41.5,-.7,1); } } namespace SEPT_21_2007{ namespace FRONT_LEFT{ __IBEO_CALIBRATION_XYZ_YPR_DEG(3.5306,0.8,-0.4118,-37.05,1.1,0.4); } namespace FRONT_CENTER{ __IBEO_CALIBRATION_XYZ_YPR_DEG(3.6449,0.0f,-0.0508,0,0,0); } namespace FRONT_RIGHT{ __IBEO_CALIBRATION_XYZ_YPR_DEG(3.5306,-0.8,-0.4118,41.5,.7,-.2); } } namespace OCT_2_2007{ namespace FRONT_LEFT{ __IBEO_CALIBRATION_XYZ_YPR_DEG(3.5306,0.8,-0.4118,-37.05,1.1,0.4); } namespace FRONT_CENTER{ __IBEO_CALIBRATION_XYZ_YPR_DEG(3.6449,0.0f,-0.0508,0,0,0); } namespace FRONT_RIGHT{ __IBEO_CALIBRATION_XYZ_YPR_DEG(3.5306,-0.8,-0.4118,41.5,.9,-.3); } } //OCT_2_2007 namespace CURRENT{ namespace FRONT_LEFT{ __IBEO_CALIBRATION_XYZ_YPR_DEG(3.5306,0.8,-0.4118,-37.05,1.1,0.4); } namespace FRONT_CENTER{ __IBEO_CALIBRATION_XYZ_YPR_DEG(3.6449,0.0f,-0.0508,0,0,0); } namespace FRONT_RIGHT{ __IBEO_CALIBRATION_XYZ_YPR_DEG(3.5306,-0.8,-0.4118,41.5,1,-.4); } } }; #endif //IBEO_TAHOE_CALIBRATION_H_SEPT_28_2007_SVL5
[ "anathan@5031bdca-8e6f-11dd-8a4e-8714b3728bc5" ]
[ [ [ 1, 88 ] ] ]
c8fe1cf1f63f28f26e27b7ac68a1aca2ad1e28d6
dde32744a06bb6697823975956a757bd6c666e87
/bwapi/SCProjects/BTHAIModule/Source/.svn/text-base/ForgeAgent.h.svn-base
859cecca788141565909d4adc883c0355d3165e1
[]
no_license
zarac/tgspu-bthai
30070aa8f72585354ab9724298b17eb6df4810af
1c7e06ca02e8b606e7164e74d010df66162c532f
refs/heads/master
2021-01-10T21:29:19.519754
2011-11-16T16:21:51
2011-11-16T16:21:51
2,533,389
0
0
null
null
null
null
UTF-8
C++
false
false
680
#ifndef __FORGEAGENT_H__ #define __FORGEAGENT_H__ #include <BWAPI.h> #include "StructureAgent.h" using namespace BWAPI; using namespace std; /** The ForgeAgent handles Protoss Forge buildings. * * Implemented abilities: * - Upgrades to Plasma Shields. * - Upgrades to Ground Armor. * - Upgrades to Ground Weapons. * * Author: Johan Hagelback ([email protected]) */ class ForgeAgent : public StructureAgent { private: int level; public: ForgeAgent(Unit* mUnit); /** Called each update to issue orders. */ void computeActions(); /** Returns the unique type name for structure agents. */ string getTypeName(); }; #endif
[ "rymdpung@.(none)" ]
[ [ [ 1, 34 ] ] ]
9d7068ba76edf09f4de90441c73a38f62c4ce85f
5ff30d64df43c7438bbbcfda528b09bb8fec9e6b
/kcore/sys/Platform.cpp
e36d3e9f0c21a30a92f1b9a4c5a019767017dde9
[]
no_license
lvtx/gamekernel
c80cdb4655f6d4930a7d035a5448b469ac9ae924
a84d9c268590a294a298a4c825d2dfe35e6eca21
refs/heads/master
2016-09-06T18:11:42.702216
2011-09-27T07:22:08
2011-09-27T07:22:08
38,255,025
3
1
null
null
null
null
UTF-8
C++
false
false
74
cpp
#include "stdafx.h" #include <kcore/sys/Platform.h> // empty for now
[ "darkface@localhost" ]
[ [ [ 1, 5 ] ] ]
800ec0d5a1bbb180e901c8170c88388999590119
b7c505dcef43c0675fd89d428e45f3c2850b124f
/Src/SimulatorQt/Util/qt/Win32/include/Qt/q3groupbox.h
b78bfda9a96377869443173cf02b75aac4e3664c
[ "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
5,610
h
/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information ([email protected]) ** ** This file is part of the Qt3Support 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 Q3GROUPBOX_H #define Q3GROUPBOX_H #include <QtGui/qgroupbox.h> QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Qt3SupportLight) class Q3GroupBoxPrivate; class Q_COMPAT_EXPORT Q3GroupBox : public QGroupBox { Q_OBJECT public: enum #if defined(Q_MOC_RUN) FrameShape #else DummyFrame #endif { Box = QFrame::Box, Sunken = QFrame::Sunken, Plain = QFrame::Plain, Raised = QFrame::Raised, MShadow=QFrame::Shadow_Mask, NoFrame = QFrame::NoFrame, Panel = QFrame::Panel, StyledPanel = QFrame::StyledPanel, HLine = QFrame::HLine, VLine = QFrame::VLine, WinPanel = QFrame::WinPanel,ToolBarPanel = QFrame::StyledPanel, MenuBarPanel = QFrame::StyledPanel, PopupPanel = QFrame::StyledPanel, LineEditPanel = QFrame::StyledPanel,TabWidgetPanel = QFrame::StyledPanel, GroupBoxPanel = 0x0007, MShape = QFrame::Shape_Mask}; typedef DummyFrame FrameShape; Q_ENUMS(FrameShape) Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation DESIGNABLE false) Q_PROPERTY(int columns READ columns WRITE setColumns DESIGNABLE false) Q_PROPERTY(QRect frameRect READ frameRect WRITE setFrameRect DESIGNABLE false) Q_PROPERTY(FrameShape frameShape READ frameShape WRITE setFrameShape) Q_PROPERTY(FrameShape frameShadow READ frameShadow WRITE setFrameShadow) Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth) Q_PROPERTY(int midLineWidth READ midLineWidth WRITE setMidLineWidth) Q_PROPERTY(int margin READ margin WRITE setMargin) public: explicit Q3GroupBox(QWidget* parent=0, const char* name=0); explicit Q3GroupBox(const QString &title, QWidget* parent=0, const char* name=0); Q3GroupBox(int strips, Qt::Orientation o, QWidget* parent=0, const char* name=0); Q3GroupBox(int strips, Qt::Orientation o, const QString &title, QWidget* parent=0, const char* name=0); ~Q3GroupBox(); virtual void setColumnLayout(int strips, Qt::Orientation o); int columns() const; void setColumns(int); Qt::Orientation orientation() const; void setOrientation(Qt::Orientation); int insideMargin() const; int insideSpacing() const; void setInsideMargin(int m); void setInsideSpacing(int s); void addSpace(int); void setFrameRect(QRect); QRect frameRect() const; #ifdef qdoc void setFrameShadow(FrameShape); FrameShape frameShadow() const; void setFrameShape(FrameShape); FrameShape frameShape() const; #else void setFrameShadow(DummyFrame); DummyFrame frameShadow() const; void setFrameShape(DummyFrame); DummyFrame frameShape() const; #endif void setFrameStyle(int); int frameStyle() const; int frameWidth() const; void setLineWidth(int); int lineWidth() const; void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); } int margin() const { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; } void setMidLineWidth(int); int midLineWidth() const; protected: void childEvent(QChildEvent *); void resizeEvent(QResizeEvent *); void changeEvent(QEvent *); bool event(QEvent *); private: void skip(); void init(); void calculateFrame(); void insertWid(QWidget*); void drawFrame(QPainter *p); Q3GroupBoxPrivate * d; Q_DISABLE_COPY(Q3GroupBox) }; QT_END_NAMESPACE QT_END_HEADER #endif // Q3GROUPBOX_H
[ "alon@rogue.(none)" ]
[ [ [ 1, 159 ] ] ]
504e19677a337caf1a8d57e7f431f0c17081af7b
02a0f2ff9542df43d95e7dbe54d4bd21e68a0056
/spepcpp/src/spep/authn/AuthnProcessorData.cpp
0e32ef73bac2b784dde03f92e17acabb44bd11de
[ "Apache-2.0" ]
permissive
stevehs/esoeproject
a510a12a7f27d25491f0cdfac328c993c396bd6c
584772580a668c562a1e24e6ff64a74315c57931
refs/heads/master
2021-01-16T21:20:18.967631
2009-11-19T06:55:23
2009-11-19T06:55:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,173
cpp
/* Copyright 2006-2007, Queensland University of Technology * 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. * * Author: Shaun Mangelsdorf * Creation Date: 19/02/2007 * * Purpose: */ #include "spep/authn/AuthnProcessorData.h" spep::AuthnProcessorData::AuthnProcessorData() { _disableAttributeQuery = false; } std::string spep::AuthnProcessorData::getRequestURL() { return _requestURL; } void spep::AuthnProcessorData::setRequestURL( const std::string &requestURL ) { _requestURL = requestURL; } std::string spep::AuthnProcessorData::getBaseRequestURL() { return _baseRequestURL; } void spep::AuthnProcessorData::setBaseRequestURL( const std::string& baseRequestURL ) { _baseRequestURL = baseRequestURL; } std::string spep::AuthnProcessorData::getSessionID() { return _sessionID; } void spep::AuthnProcessorData::setSessionID( const std::string &sessionID ) { _sessionID = sessionID; } const saml2::SAMLDocument& spep::AuthnProcessorData::getRequestDocument() { return _requestDocument; } void spep::AuthnProcessorData::setRequestDocument( const saml2::SAMLDocument& document ) { _requestDocument = document; } const saml2::SAMLDocument& spep::AuthnProcessorData::getResponseDocument() { return _responseDocument; } void spep::AuthnProcessorData::setResponseDocument( const saml2::SAMLDocument& document ) { _responseDocument = document; } void spep::AuthnProcessorData::setDisableAttributeQuery( bool value ) { _disableAttributeQuery = value; } bool spep::AuthnProcessorData::getDisableAttributeQuery() { return _disableAttributeQuery; }
[ [ [ 1, 85 ] ] ]
c13d0fdd0fc12ddd2667bf113ab6515fbe7fa5ce
0f457762985248f4f6f06e29429955b3fd2c969a
/irrlicht/sdk/irr_bullet/BulletFpsCamAnimator.cpp
cb032f3e69ff87eca1975d828ecc7cfaf75b60b1
[]
no_license
tk8812/ukgtut
f19e14449c7e75a0aca89d194caedb9a6769bb2e
3146ac405794777e779c2bbb0b735b0acd9a3f1e
refs/heads/master
2021-01-01T16:55:07.417628
2010-11-15T16:02:53
2010-11-15T16:02:53
37,515,002
0
0
null
null
null
null
UHC
C++
false
false
13,440
cpp
//저작권: //물리 fps 애니메이터 //수정 2008.8.12 //미구현 사항 : 점푸구현 // //수정 2009.8.6 #pragma warning (disable:4819) #include "CBulletAnimatorManager.h" #include "BulletFpsCamAnimator.h" #include "IVideoDriver.h" #include "ISceneManager.h" #include "Keycodes.h" #include "ICursorControl.h" #include "ICameraSceneNode.h" #include "btBulletDynamicsCommon.h" #include "BulletCollision/Gimpact/btGImpactShape.h" #include "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h" namespace irr { namespace scene { //! constructor CBulletFpsCamAnimator::CBulletFpsCamAnimator(gui::ICursorControl* cursorControl, f32 rotateSpeed, f32 moveSpeed, f32 jumpSpeed, SKeyMap* keyMapArray, u32 keyMapSize, bool noVerticalMovement) : CursorControl(cursorControl), MaxVerticalAngle(88.0f), MoveSpeed(moveSpeed/1000.0f), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed), LastAnimationTime(0), firstUpdate(true), NoVerticalMovement(noVerticalMovement) { #ifdef _DEBUG setDebugName("CCameraSceneNodeAnimatorFPS"); #endif if (CursorControl) CursorControl->grab(); allKeysUp(); // create key map if (!keyMapArray || !keyMapSize) { // create default key map KeyMap.push_back(SCamKeyMap(0, irr::KEY_UP)); KeyMap.push_back(SCamKeyMap(1, irr::KEY_DOWN)); KeyMap.push_back(SCamKeyMap(2, irr::KEY_LEFT)); KeyMap.push_back(SCamKeyMap(3, irr::KEY_RIGHT)); KeyMap.push_back(SCamKeyMap(4, irr::KEY_KEY_J)); } else { // create custom key map setKeyMap(keyMapArray, keyMapSize); } m_LocalPos = irr::core::vector3df(0,0,0); } //! destructor CBulletFpsCamAnimator::~CBulletFpsCamAnimator() { if (CursorControl) CursorControl->drop(); } //! It is possible to send mouse and key events to the camera. Most cameras //! may ignore this input, but camera scene nodes which are created for //! example with scene::ISceneManager::addMayaCameraSceneNode or //! scene::ISceneManager::addFPSCameraSceneNode, may want to get this input //! for changing their position, look at target or whatever. //! 아래의이벤트핸들러가 호출되는 이유는 현재활성화된 카메라노드에 자식으로 붙어있는 애니매이터는 //! 무조건 이밴트핸들러가 호출이된다. bool CBulletFpsCamAnimator::OnEvent(const SEvent& evt) { switch(evt.EventType) { case EET_KEY_INPUT_EVENT: for (u32 i=0; i<KeyMap.size(); ++i) { if (KeyMap[i].keycode == evt.KeyInput.Key) { CursorKeys[KeyMap[i].action] = evt.KeyInput.PressedDown; return true; } } break; case EET_MOUSE_INPUT_EVENT: if (evt.MouseInput.Event == EMIE_MOUSE_MOVED) { CursorPos = CursorControl->getRelativePosition(); return true; } break; default: break; } return false; } //------------------------------------------------------------------------------ //! CreateInstance //! Creates CBulletChracterAnimator or returns NULL //! CBulletObjectAnimator와 달리 각회전을 제한(서있는상태를 유지하기위해서는 쓰러짐을 제어하기위해서...) CBulletFpsCamAnimator* CBulletFpsCamAnimator::createInstance( ISceneManager* pSceneManager, ISceneNode* pSceneNode, gui::ICursorControl *CursorControl, CBulletAnimatorManager* pBulletMgr, CBulletObjectAnimatorGeometry* pGeom, CBulletObjectAnimatorParams* pPhysicsParam) { //CursorControl = CursorControl; // get node scaling core::vector3df scaling = pSceneNode->getScale(); btStridingMeshInterface* triangleMesh = NULL; // prepare collision shape btCollisionShape* collisionShape = CreateBulletCollisionShape(pSceneManager, pGeom, scaling, triangleMesh); if (collisionShape == NULL) return NULL; CBulletFpsCamAnimator* bulletAnimator = new CBulletFpsCamAnimator(CursorControl,100.f,50.f); bulletAnimator->geometry = *pGeom; bulletAnimator->physicsParams = *pPhysicsParam; bulletAnimator->bulletMesh = triangleMesh; bulletAnimator->collisionShape = collisionShape; bulletAnimator->sceneNode = pSceneNode; bulletAnimator->sceneManager = pSceneManager; bulletAnimator->bulletMgr = pBulletMgr; bulletAnimator->CursorControl = CursorControl; bulletAnimator->InitPhysics(); //추가 물리 속성 //쓰러짐 제어를 위해 각회전 제한 bulletAnimator->getRigidBody()->setAngularFactor(0.0f); bulletAnimator->getRigidBody()->setSleepingThresholds (0.0, 0.0); return bulletAnimator; } void CBulletFpsCamAnimator::animateNode(ISceneNode* node, u32 timeMs) { if (node->getType() != ESNT_CAMERA) return; ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node); if (firstUpdate) { if (CursorControl && camera) { CursorControl->setPosition(0.5f, 0.5f); CursorPos = CenterCursor = CursorControl->getRelativePosition(); } LastAnimationTime = timeMs; firstUpdate = false; } // get time f32 timeDiff = (f32) ( timeMs - LastAnimationTime ); LastAnimationTime = timeMs; // update position core::vector3df pos = camera->getPosition(); // Update rotation core::vector3df target = (camera->getTarget() - camera->getAbsolutePosition()); core::vector3df relativeRotation = target.getHorizontalAngle(); if (CursorControl) { if (CursorPos != CenterCursor) { relativeRotation.Y -= (0.5f - CursorPos.X) * RotateSpeed; relativeRotation.X -= (0.5f - CursorPos.Y) * RotateSpeed; // X < MaxVerticalAngle or X > 360-MaxVerticalAngle if (relativeRotation.X > MaxVerticalAngle*2 && relativeRotation.X < 360.0f-MaxVerticalAngle) { relativeRotation.X = 360.0f-MaxVerticalAngle; } else if (relativeRotation.X > MaxVerticalAngle && relativeRotation.X < 360.0f-MaxVerticalAngle) { relativeRotation.X = MaxVerticalAngle; } // reset cursor position CursorControl->setPosition(0.5f, 0.5f); CenterCursor = CursorControl->getRelativePosition(); //ggf::irr_util::DebugOutputFmt(NULL,"test %f \n",relativeRotation.Y); } } // set target target.set(0,0,100); core::vector3df movedir = target; core::matrix4 mat; mat.setRotationDegrees(core::vector3df(relativeRotation.X, relativeRotation.Y, 0)); mat.transformVect(target); if (NoVerticalMovement) { mat.setRotationDegrees(core::vector3df(0, relativeRotation.Y, 0)); mat.transformVect(movedir); } else { movedir = target; } movedir.normalize(); //if (CursorKeys[0]) //pos += movedir * timeDiff * MoveSpeed; //if (CursorKeys[1]) //pos -= movedir * timeDiff * MoveSpeed; // strafing //core::vector3df strafevect = target; //strafevect = strafevect.crossProduct(camera->getUpVector()); //if (NoVerticalMovement) // strafevect.Y = 0.0f; //strafevect.normalize(); if (CursorKeys[2]) { //pos += strafevect * timeDiff * MoveSpeed; //ggf::irr_util::DebugOutputFmt(NULL,"test %f \n",relativeRotation.Y); } if (CursorKeys[3]) //pos -= strafevect * timeDiff * MoveSpeed; // jumping ( need's a gravity , else it's a fly to the World-UpVector ) if (CursorKeys[4]) { //pos += camera->getUpVector() * timeDiff * JumpSpeed; } // write translation //camera->setPosition(pos); /////////////////////////gbox///////////////////////// //gbox patch 08.07.27 rotation bug fix camera->setRotation(mat.getRotationDegrees()); /////////////////////////gbox///////////////////////// // write right target TargetVector = target; //target += pos; //camera->setTarget(target); irr::f32 Speed = 0;// = timeDiff * MoveSpeed; irr::f32 Strife_Speed = 0; irr::f32 Angle = relativeRotation.Y; if (CursorKeys[0]) { //Speed = timeDiff * MoveSpeed; Speed = MoveSpeed; } if (CursorKeys[1]) { //Speed = -(timeDiff * MoveSpeed); Speed = -MoveSpeed; } if (CursorKeys[2]) { Strife_Speed = MoveSpeed; //Strife_Speed = (timeDiff * MoveSpeed); } if (CursorKeys[3]) { Strife_Speed = -MoveSpeed; //Strife_Speed = -(timeDiff * MoveSpeed); } //전처리 스탭(충돌 처리) { btTransform xform; rigidBody->getMotionState()->getWorldTransform (xform); btVector3 down = -xform.getBasis()[1]; //Y축 정보 btVector3 forward = xform.getBasis()[2]; //Z축 정보 down.normalize (); forward.normalize(); forward.setX(-forward.getX()); //오른손좌표계롤 왼손좌표계로... m_raySource[0] = xform.getOrigin(); m_raySource[1] = xform.getOrigin(); m_rayTarget[0] = m_raySource[0] + down * ((geometry.Capsule.hight * 0.5f) + geometry.Capsule.radius ) * btScalar(1.1); m_rayTarget[1] = m_raySource[1] + forward * (geometry.Capsule.radius ) * btScalar(1.1); class ClosestNotMe : public btCollisionWorld::ClosestRayResultCallback { public: ClosestNotMe (btRigidBody* me) : btCollisionWorld::ClosestRayResultCallback(btVector3(0.0, 0.0, 0.0), btVector3(0.0, 0.0, 0.0)) { m_me = me; } virtual btScalar AddSingleResult(btCollisionWorld::LocalRayResult& rayResult,bool normalInWorldSpace) { if (rayResult.m_collisionObject == m_me) return 1.0; return ClosestRayResultCallback::addSingleResult (rayResult, normalInWorldSpace ); } protected: btRigidBody* m_me; }; ClosestNotMe rayCallback(rigidBody); { btDynamicsWorld* dynamicsWorld = bulletMgr->getBulletWorldByID(bulletWorldID)->getWorld(); int i = 0; for (i = 0; i < 2; i++) { rayCallback.m_closestHitFraction = 1.0; dynamicsWorld->rayTest (m_raySource[i], m_rayTarget[i], rayCallback); if (rayCallback.hasHit()) { m_rayLambda[i] = rayCallback.m_closestHitFraction; //충돌비율값 } else { m_rayLambda[i] = 1.0; //충돌하지않음 } } } } //후처리 { btTransform xform; rigidBody->getMotionState()->getWorldTransform (xform); xform.setRotation (btQuaternion (btVector3(0.0, 1.0, 0.0), Angle * irr::core::DEGTORAD)); btVector3 linearVelocity = rigidBody->getLinearVelocity(); if(m_rayLambda[0] < 1.0) { linearVelocity.setY(0); } btVector3 forwardDir = xform.getBasis()[2]; btVector3 SideDir = xform.getBasis()[0]; //축변환 및 정규화 forwardDir.normalize (); forwardDir.setX(-forwardDir.getX()); SideDir.normalize(); SideDir.setX(-SideDir.getX()); btVector3 velocity = (forwardDir * Speed); velocity += (SideDir * Strife_Speed); irr::core::vector3df fowardvec = irr::core::vector3df(forwardDir.getX(),forwardDir.getY(),forwardDir.getZ()); irr::core::vector3df sidevec = irr::core::vector3df(-SideDir.getX(),SideDir.getY(),SideDir.getZ()); //ggf::irr_util::DebugOutputFmt(NULL,"%f %f, %f, %f\n",Angle,velocity.getX(),velocity.getY(),velocity.getZ()); //ggf::irr_util::DebugOutputFmt(NULL,"%f/%f %f, %f, %f\n",fowardvec.getHorizontalAngle().Y, sidevec.getHorizontalAngle().Y,SideDir.getX(),SideDir.getY(),SideDir.getZ()); velocity.setY(linearVelocity.getY()); rigidBody->setLinearVelocity (velocity); rigidBody->getMotionState()->setWorldTransform (xform); rigidBody->setCenterOfMassTransform (xform); //camera->setTarget(target); } //물리엔진 변환적용 if (physicsParams.mass != 0.0f && rigidBody && rigidBody->getMotionState()) { btTransform xform; rigidBody->getMotionState()->getWorldTransform (xform); btVector3 forwardDir = xform.getBasis()[2]; forwardDir.normalize (); // set pos btVector3 p = rigidBody->getCenterOfMassPosition(); irr::core::vector3df vforward = irr::core::vector3df(-forwardDir.getX(),forwardDir.getY(),forwardDir.getZ()); irr::core::vector3df eye_pos = core::vector3df(p.getX(), p.getY(), p.getZ()) + m_LocalPos; sceneNode->setPosition(eye_pos); camera->setTarget(eye_pos + TargetVector); } } void CBulletFpsCamAnimator::allKeysUp() { for (u32 i=0; i<6; ++i) CursorKeys[i] = false; } //! Sets the rotation speed void CBulletFpsCamAnimator::setRotateSpeed(f32 speed) { RotateSpeed = speed; } //! Sets the movement speed void CBulletFpsCamAnimator::setMoveSpeed(f32 speed) { MoveSpeed = speed; } //! Gets the rotation speed f32 CBulletFpsCamAnimator::getRotateSpeed() const { return RotateSpeed; } // Gets the movement speed f32 CBulletFpsCamAnimator::getMoveSpeed() const { return MoveSpeed; } //! Sets the keyboard mapping for this animator void CBulletFpsCamAnimator::setKeyMap(SKeyMap *map, u32 count) { // clear the keymap KeyMap.clear(); // add actions for (u32 i=0; i<count; ++i) { switch(map[i].Action) { case EKA_MOVE_FORWARD: KeyMap.push_back(SCamKeyMap(0, map[i].KeyCode)); break; case EKA_MOVE_BACKWARD: KeyMap.push_back(SCamKeyMap(1, map[i].KeyCode)); break; case EKA_STRAFE_LEFT: KeyMap.push_back(SCamKeyMap(2, map[i].KeyCode)); break; case EKA_STRAFE_RIGHT: KeyMap.push_back(SCamKeyMap(3, map[i].KeyCode)); break; case EKA_JUMP_UP: KeyMap.push_back(SCamKeyMap(4, map[i].KeyCode)); break; default: break; } } } //! Sets whether vertical movement should be allowed. void CBulletFpsCamAnimator::setVerticalMovement(bool allow) { NoVerticalMovement = !allow; } } // namespace scene } // namespace irr
[ "gbox3d@58f0f68e-7603-11de-abb5-1d1887d8974b" ]
[ [ [ 1, 505 ] ] ]
077f9c1aa7d0356b6e843340aa476628f2479c96
29c5bc6757634a26ac5103f87ed068292e418d74
/src/tlclasses/CLogicTimer.h
144093cafad61f155982a899ef5f5e6afeea94a1
[]
no_license
drivehappy/tlapi
d10bb75f47773e381e3ba59206ff50889de7e66a
56607a0243bd9d2f0d6fb853cddc4fce3e7e0eb9
refs/heads/master
2021-03-19T07:10:57.343889
2011-04-18T22:58:29
2011-04-18T22:58:29
32,191,364
5
0
null
null
null
null
UTF-8
C++
false
false
240
h
#pragma once #include "CEditorBaseObject.h" namespace TLAPI { #pragma pack(1) struct CLogicTimer : CEditorBaseObject { PVOID unk0; CLogicTimerDescriptor *pCLogicTimerDescriptor; }; #pragma pack() };
[ "drivehappy@53ea644a-42e2-1498-a4e7-6aa81ae25522" ]
[ [ [ 1, 18 ] ] ]
d3a24b92a8e8f8bac75f3cac2bcbd8693a38317b
5ac13fa1746046451f1989b5b8734f40d6445322
/minimangalore/Nebula2/code/nebula2/src/kernel/nloghandler.cc
5ec272c498a35213ba303805c4f92a49847f184b
[]
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
2,047
cc
//------------------------------------------------------------------------------ // nloghandler.cc // (C) 2003 RadonLabs GmbH //------------------------------------------------------------------------------ #include "kernel/nloghandler.h" //------------------------------------------------------------------------------ /** */ nLogHandler::nLogHandler() : isOpen(false) { // empty } //------------------------------------------------------------------------------ /** */ nLogHandler::~nLogHandler() { // empty } //------------------------------------------------------------------------------ /** */ bool nLogHandler::Open() { n_assert(!this->isOpen); this->isOpen = true; return true; } //------------------------------------------------------------------------------ /** */ void nLogHandler::Close() { n_assert(this->isOpen); this->isOpen = false; } //------------------------------------------------------------------------------ /** */ void nLogHandler::Print(const char* /* str*/, va_list /* argList */) { // empty } //------------------------------------------------------------------------------ /** */ void nLogHandler::Message(const char* /* str */, va_list /* argList */) { // empty } //------------------------------------------------------------------------------ /** */ void nLogHandler::Error(const char* /* str */, va_list /* argList */) { // empty } //------------------------------------------------------------------------------ /** - 26-Mar-05 kims created */ void nLogHandler::OutputDebug(const char* /* str */, va_list /* argList */) { // empty } //------------------------------------------------------------------------------ /** Subclasses may log all messages in an internal line buffer. If they chose to do so, this must be a nLineBuffer class and override the GetLineBuffer() method. */ nLineBuffer* nLogHandler::GetLineBuffer() { return 0; }
[ "BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c" ]
[ [ [ 1, 92 ] ] ]
8bc3a1b70c97aff1a991ea3ee8e9bd4cb33994fe
80959be98b57106e6bd41c33c5bfb7dd5e9c88cd
/Camera.h
ae81cf7465ca48af7bf5f52c0dcf095458fd16ef
[]
no_license
dalorin/FPSDemo
e9ab067cfad73d404cc0ea01190212d5192405b0
cf29b61a9654652a3f8d60d742072e1a8eaa3ca7
refs/heads/master
2020-07-26T17:42:10.801273
2010-12-27T00:16:55
2010-12-27T00:16:55
1,199,462
1
0
null
null
null
null
UTF-8
C++
false
false
779
h
#pragma once #include "objects.h" class GameEngine; // Forward declaration of GameEngine class. class Weapon; // Forward declaration of Weapon class. class Camera : public Object { public: Camera(GameEngine* engine); ~Camera(void); const char* getType(); void setSubject(GLfloat x, GLfloat y, GLfloat z); void adjustPitch(GLfloat angle); void adjustYaw(GLfloat angle); void resetPitch(); void resetYaw(); void moveForward(); void moveBackward(); void strafeLeft(GLfloat step); void strafeRight(GLfloat step); void adjustBob(bool forward); GLfloat getBob() { return m_bobValue; } void reposition(); Vector3 getSubject(); Vector3 getSubjectRelative(); private: Vector3* m_subject; bool m_bobUp; GLfloat m_bobValue; };
[ [ [ 1, 35 ] ] ]
67fdce6ea7e621b56083cd256ce295e0030a00a6
5fb9b06a4bf002fc851502717a020362b7d9d042
/developertools/GumpEditor/entity/GumpButton.cpp
c24ad263edf58c5851d2801b5c4cd88fffdfe525
[]
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
5,446
cpp
#include "stdafx.h" #include "GumpEditor.h" #include ".\gumpbutton.h" #include "StdGrfx.h" #include "GumpEditorDoc.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CGumpButton LPCTSTR CGumpButton::m_szButtonType[CGumpButton::NUM_TYPE] = { "button", "checkbox", "radio" }; void CGumpButton::SetButtonTypeStr(CString strType) { m_eType = (TYPE)StrToEnum(strType, m_szButtonType, NUM_TYPE, m_eType); } CGumpButton::CGumpButton(CGumpPtr pNormal, CGumpPtr pHover, CGumpPtr pPressed, TYPE eType, bool bChecked, bool bGrouped) { //ASSERT(pNormal); SetButtonType(eType); SetChecked(bChecked); SetGrouped(bGrouped); SetGump(pNormal, pHover, pPressed); SetTitle("button"); SetType("button"); CString strName; strName.Format("button_%x", pNormal ? pNormal->GetGumpID() : 0); SetName(strName); AddPropertyPage( &m_page ); } CDiagramEntity* CGumpButton::Clone() { CGumpButton* obj = new CGumpButton(m_pGump[NORMAL], m_pGump[HOVER], m_pGump[PRESSED], m_eType, m_bChecked, m_bGrouped); obj->Copy( this ); return obj; } void CGumpButton::Draw( CDC* dc, CRect rect ) { CGumpPtr pGump = m_pGump[NORMAL]; if (!pGump) { if (m_eType == RADIO) CGumpEntity::DrawRadiobutton(dc, rect); else if (m_eType == CHECKBOX) CGumpEntity::DrawCheckbox(dc, rect); else CGumpEntity::DrawButton(dc, rect); return; } if (m_eType == BUTTON) { pGump->DrawGump(dc, rect.TopLeft(), GetZoom()); return; } CSize size = pGump->GetDimensions(); if (rect.Size().cy > size.cy) rect.top += (rect.Size().cy - size.cy) / 2; if (GetTextAlign() == ALIGN_LEFT) { pGump->DrawGump(dc, rect.TopLeft(), GetZoom()); rect.left += size.cx + TEXT_MARGIN; } else { pGump->DrawGump(dc, CPoint(rect.right - size.cx, rect.top), GetZoom()); rect.right -= size.cx + TEXT_MARGIN; } CGumpStatic::Draw(dc, rect); } CGumpEntity* CGumpButton::CreateFromNode( XML::Node* node ) { CGumpButton* obj = new CGumpButton(NULL,NULL,NULL); if (!obj->FromString( node )) { delete obj; obj = NULL; } return obj; } BOOL CGumpButton::FromString( XML::Node* node ) { if (!CGumpStatic::FromString(node)) return FALSE; int normal=0, over=0, pressed=0; XML::Node* gump_node = node->findNode("gump"); if (gump_node) { gump_node->lookupAttribute("normal", normal); gump_node->lookupAttribute("over", over); gump_node->lookupAttribute("pressed", pressed); } std::string type="push"; int checked=0, grouped=0; XML::Node* button_node = node->findNode("button"); if (button_node) { button_node->lookupAttribute("type", type); button_node->lookupAttribute("checked", checked); button_node->lookupAttribute("grouped", grouped); } CSize size = GetRect().Size(); //SetConstraints(size,size); CGumpEditorDoc* pDoc = GfxGetGumpDocument(); ASSERT(pDoc); m_pGump[NORMAL] = pDoc->GetGump(normal); m_pGump[HOVER] = pDoc->GetGump(over); m_pGump[PRESSED] = pDoc->GetGump(pressed); SetButtonTypeStr(type.c_str()); SetChecked(checked); SetGrouped(grouped); if (GetButtonType() == BUTTON) { SetConstraints(size,size); } else { size.cx += DEFAULT_SIZE; SetConstraints(CSize(1, 1), CSize(-1, -1)); } return TRUE; } CString CGumpButton::GetString(BOOL bBegin) const { CString ret, str; if (bBegin) { ret += CGumpStatic::GetString(TRUE) + "\n"; str.Format(" <gump normal='0x%X' over='0x%X' pressed='0x%X'/>", GetGumpID(NORMAL), GetGumpID(HOVER), GetGumpID(PRESSED)); ret += str; str.Format(" <button type='%s' checked='%d' grouped='%d'/>", GetButtonTypeStr(), IsChecked(), IsGrouped()); ret += str; } else { ret += CGumpStatic::GetString(FALSE); } return ret; } bool CGumpButton::SetGump(CGumpPtr pNormal, CGumpPtr pHover, CGumpPtr pPressed) { if (!pNormal || !pHover || !pPressed) return false; SetGump(NORMAL, pNormal); SetGump(HOVER, pHover); SetGump(PRESSED, pPressed); return true; } void CGumpButton::GetGump(CGumpPtr& pNormal, CGumpPtr& pHover, CGumpPtr& pPressed) { pNormal = m_pGump[NORMAL]; pHover = m_pGump[HOVER]; pPressed = m_pGump[PRESSED]; } CGumpPtr CGumpButton::GetGump(STATE state) { return m_pGump[state]; } int CGumpButton::GetGumpID(STATE state) const { return m_pGump[state] ? m_pGump[state]->GetGumpID() : -1; } void CGumpButton::SetGump(STATE state, CGumpPtr pGump) { //ASSERT(pGump); m_pGump[state] = pGump; if (NORMAL==state && pGump) { CRect rect = GetRect(); CSize size = pGump->GetDimensions(); if (m_eType == BUTTON) { SetConstraints(size,size); } else { size.cx += DEFAULT_SIZE; SetConstraints(CSize(1, 1), CSize(-1, -1)); } SetRect(rect.left, rect.top, rect.left + size.cx, rect.top + size.cy); } } void CGumpButton::SetButtonType(TYPE eType) { if (m_eType == eType) return; bool bDontUpdateSize = m_eType != BUTTON && eType != BUTTON; m_eType = eType; CGumpPtr pGump = m_pGump[NORMAL]; if (!pGump || bDontUpdateSize) return; CSize size = pGump->GetDimensions(); if (m_eType == BUTTON) { SetConstraints(size,size); } else { size.cx += DEFAULT_SIZE; SetConstraints(CSize(1, 1), CSize(-1, -1)); } }
[ "sience@a725d9c3-d2eb-0310-b856-fa980ef11a19" ]
[ [ [ 1, 234 ] ] ]
6f2dee2d9f4e4df0201dc330f48364bc83611d97
5ed707de9f3de6044543886ea91bde39879bfae6
/ASFantasy/ASFIsapi/Source/ASFantasyGameResultsPage.cpp
bda386fc9c8952965cda741985535b310bd198c1
[]
no_license
grtvd/asifantasysports
9e472632bedeec0f2d734aa798b7ff00148e7f19
76df32c77c76a76078152c77e582faa097f127a8
refs/heads/master
2020-03-19T02:25:23.901618
1999-12-31T16:00:00
2018-05-31T19:48:19
135,627,290
0
0
null
null
null
null
UTF-8
C++
false
false
2,065
cpp
/* ASFantasyGameResultsPage.cpp */ /******************************************************************************/ /******************************************************************************/ #include "CBldVCL.h" #pragma hdrstop #include "ASFantasyGameResultsPage.h" namespace asfantasy { /******************************************************************************/ class ASFantasyGameResultsJavaPanelHtmlView : public TJavaPanelHtmlView { protected: CStrVar fGameDate; public: ASFantasyGameResultsJavaPanelHtmlView(THtmlPageOptions& pageOptions, ASFantasyJavaArchive javaArchive,const char* javaClass,int javaWidth, int javaHeight,const char* gameDate) : TJavaPanelHtmlView(pageOptions, javaArchive,javaClass,javaWidth,javaHeight),fGameDate(gameDate) {} virtual void WriteParameters(THTMLWriter& htmlWriter); }; /******************************************************************************/ void ASFantasyGameResultsJavaPanelHtmlView::WriteParameters(THTMLWriter& htmlWriter) { if(fGameDate.hasLen()) htmlWriter.JavaParamString("GameDate",fGameDate.c_str()); } /******************************************************************************/ /******************************************************************************/ void ASFantasyGameResultsPageHtmlView::initialize() { fGameDate.copy(fIsHtmlServer.getStringField("GameDate",cam_MayNotExist).c_str()); } /******************************************************************************/ void ASFantasyGameResultsPageHtmlView::writeBodyViewBody() { ASFantasyGameResultsJavaPanelHtmlView htmlView(fPageOptions,fja_Season, "GameResultsApplet",getBodyViewWidth(),getBodyViewBodyHeight(), fGameDate); fHtmlWriter.WriteView(htmlView); } /******************************************************************************/ }; //namespace asfantasy /******************************************************************************/ /******************************************************************************/
[ [ [ 1, 62 ] ] ]
cb54637ade5d6a4f267c80356100810aee50c922
971b000b9e6c4bf91d28f3723923a678520f5bcf
/PaperSizeScroll/_snip_pieces/xsl-fo_open/srcm/scene/GraphicsScene.cpp
0cc403e9b97e6fb8f60ba246cfaab617fe292d60
[]
no_license
google-code-export/fop-miniscribus
14ce53d21893ce1821386a94d42485ee0465121f
966a9ca7097268c18e690aa0ea4b24b308475af9
refs/heads/master
2020-12-24T17:08:51.551987
2011-09-02T07:55:05
2011-09-02T07:55:05
32,133,292
2
0
null
null
null
null
UTF-8
C++
false
false
7,926
cpp
#include <QGraphicsScene> #include "GraphicsScene.h" GraphicsScene::GraphicsScene( QObject * parent ) : QGraphicsScene( parent ),bridge(0) { QApplication::restoreOverrideCursor(); QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); } GraphicsScene::GraphicsScene( const QRectF & sceneRect, QObject * parent ) : QGraphicsScene( sceneRect, parent ),bridge(0) { setSceneRect( sceneRect ); QApplication::restoreOverrideCursor(); QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); //////QPalette p = palette(); //////////p.setColor(QPalette::Text,_DOCUMENT_TXT_COLOR_); //////////setPalette(p); } GraphicsScene::GraphicsScene( qreal x, qreal y, qreal width, qreal height, QObject * parent ) : QGraphicsScene(x,y,width,height,parent ),bridge(0) { setSceneRect(x,y,width,height); /////////QPalette p = palette(); ////////// p.setColor(QPalette::Text,_DOCUMENT_TXT_COLOR_); ///////////setPalette(p); QApplication::restoreOverrideCursor(); QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); } void GraphicsScene::paste( bool cloneornot ) { emit LayerPaste(cloneornot); } void GraphicsScene::reload() { update(); } void GraphicsScene::storno() { bridge = 0; emit SelectOn(bridge); } void GraphicsScene::clearSelection() { QGraphicsScene::clearSelection(); } void GraphicsScene::clear() { clearSelection(); const QList<QGraphicsItem*> items = QGraphicsScene::items(); QList<QGraphicsItem*> topLevelItems; foreach(QGraphicsItem* item, items) { if (!item->parentItem()) { topLevelItems << item; } } foreach(QGraphicsItem* item, topLevelItems) { delete item; } storno(); } qreal GraphicsScene::zmax() { qreal mValue = 0.00; QList<QGraphicsItem *> items = QGraphicsScene::items(); for (int o=0;o<items.size();o++) { mValue = qMax(items[o]->zValue(),mValue); } return mValue; } qreal GraphicsScene::zmin() { qreal mValue = zmax(); QList<QGraphicsItem *> items = QGraphicsScene::items(); for (int o=0;o<items.size();o++) { mValue = qMin(items[o]->zValue(),mValue); } return mValue; } /* filter only item a top Zindex / zValue */ bool GraphicsScene::WakeUp( const QPointF incomming ) { QList<QGraphicsItem *> listing = QGraphicsScene::items(incomming); qreal thebest = 0; /* zindex on front */ for (int o=0;o<listing.size();o++) { listing[o]->setSelected(false); listing[o]->setFlag(QGraphicsItem::ItemIsSelectable,false); thebest = qMax(listing[o]->zValue(),thebest); } ///////qDebug() << "### thebest->" << thebest; /* activate item at top z-index zValue / not the down not visible!!!! */ for (int e=0;e<listing.size();e++) { if (listing[e]->zValue() == thebest) { listing[e]->setFlag(QGraphicsItem::ItemIsSelectable,true); listing[e]->setSelected(true); bridge = listing[e]; emit SelectOn(listing[e]); return true; } } emit SelectOn(bridge); return false; } void GraphicsScene::mousePressEvent( QGraphicsSceneMouseEvent * event ) { if (WakeUp(QPointF(event->scenePos().x(),event->scenePos().y()))) { event->setAccepted ( true ) ; clearSelection(); } else { storno(); } QGraphicsScene::mousePressEvent(event); } void GraphicsScene::mouseReleaseEvent( QGraphicsSceneMouseEvent * event ) { if (WakeUp(QPointF(event->scenePos().x(),event->scenePos().y()))) { event->setAccepted ( true ) ; clearSelection(); } else { storno(); } QGraphicsScene::mouseReleaseEvent(event); } void GraphicsScene::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * event ) { if (WakeUp(QPointF(event->scenePos().x(),event->scenePos().y()))) { event->setAccepted ( true ) ; clearSelection(); } else { storno(); } QGraphicsScene::mouseDoubleClickEvent(event); } void GraphicsScene::setSceneRect( qreal x, qreal y, qreal w, qreal h ) { ///////Area = QRectF(x,y,w,h); QGraphicsScene::setSceneRect(x,y,w,h); } void GraphicsScene::setSceneRect( const QRectF & rect ) { ///////Area = rect; QGraphicsScene::setSceneRect(rect); } int GraphicsScene::PrintPageSumm( QPrinter * printer ) { bool portrait = printer->orientation() == QPrinter::Portrait ? true : false; const qreal wit = qMin(printer->pageRect().width(),printer->paperRect().width()); const qreal hei = qMin(printer->pageRect().height(),printer->paperRect().height()); const qreal faktor_print = qMax(wit,hei) / qMin(wit,hei); qreal onepagescene_HI = sceneRect().width() * faktor_print; if (!portrait) { onepagescene_HI = sceneRect().width() / faktor_print; } QRectF rectScenePiece = QRectF (0.,0.,sceneRect().width(),onepagescene_HI); /* first slice from scene */ const qreal page = sceneRect().height() / onepagescene_HI; /* page need */ qDebug() << "### page math " << page; int PageSumm = page; if (page > PageSumm) { PageSumm++; /* float to next int */ } qDebug() << "### page int " << PageSumm; return PageSumm; } void GraphicsScene::printPage(int index, int percentual , QPainter &painter, QPrinter * printer) { QPixmap pixmap(painter.viewport().width(),painter.viewport().height()); /* virtual paper */ bool portrait = printer->orientation() == QPrinter::Portrait ? true : false; const qreal wit = qMin(printer->pageRect().width(),printer->paperRect().width()); const qreal hei = qMin(printer->pageRect().height(),printer->paperRect().height()); const qreal faktor_print = qMax(wit,hei) / qMin(wit,hei); const QRect Paper_Rect = printer->pageRect(); qreal onepagescene_HI = sceneRect().width() * faktor_print; if (!portrait) { onepagescene_HI = sceneRect().width() / faktor_print; } QRectF rectScenePiece = QRectF (0.,0.,sceneRect().width(),onepagescene_HI); /* first slice from scene */ const qreal page = sceneRect().height() / onepagescene_HI; /* page need */ int PageSumm = page; if (page > PageSumm) { PageSumm++; /* float to next int */ } if ( index > PageSumm ) { return; /* not having this page */ } qreal InitOnYtop = 0; if (index != 0) { InitOnYtop = rectScenePiece.height() * index; } QRect pagepiece = QRect(0,InitOnYtop,rectScenePiece.width(),rectScenePiece.height()); //////////qDebug() << "### page " << index << "," << percentual << "," << printer->pageRect(); const qreal smallpart = qMax(pixmap.width(),pixmap.height()) / faktor_print; QRectF AFormatPaper; /* Paper dimension from printer Faktor run */ if (portrait) { AFormatPaper = QRect(0,0,smallpart,qMax(pixmap.width(),pixmap.height())); } else { AFormatPaper = QRect(0,0,qMax(pixmap.width(),pixmap.height()),smallpart); } QRectF ZoomFaktorPage = Reduce(AFormatPaper,percentual); /* zoom rect */ QRect WhitePaper = CenterRectSlaveFromMaster(pixmap.rect(),AFormatPaper).toRect(); QRect RenderPage = CenterRectSlaveFromMaster(pixmap.rect(),ZoomFaktorPage).toRect(); painter.fillRect(painter.viewport(),QBrush(Qt::lightGray)); /* device to cover */ painter.fillRect(WhitePaper,QBrush(Qt::white)); /* paper */ /////////painter.fillRect(RenderPage,QBrush(Qt::red)); /* page result */ render(&painter,RenderPage,pagepiece,Qt::KeepAspectRatio); }
[ "ppkciz@9af58faf-7e3e-0410-b956-55d145112073" ]
[ [ [ 1, 277 ] ] ]
e7f369ec0632c389cd509cc6aa7e14c5c664fb5d
836523304390560c1b0b655888a4abef63a1b4a5
/OEProxy/OEProxy.cpp
0459c13fae7e4ac0189fd5fd423c5e2126abe8a6
[]
no_license
paranoiagu/UDSOnlineEditor
4675ed403fe5acf437ff034a17f3eaa932e7b780
7eaae6fef51a01f09d28021ca6e6f2affa7c9658
refs/heads/master
2021-01-11T03:19:59.238691
2011-10-03T06:02:35
2011-10-03T06:02:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,077
cpp
// OEProxy.cpp : Implementation of DLL Exports. #include "stdafx.h" #include "resource.h" #include "OEProxy_i.h" #include "dllmain.h" #include "dlldatax.h" // Used to determine whether the DLL can be unloaded by OLE STDAPI DllCanUnloadNow(void) { #ifdef _MERGE_PROXYSTUB HRESULT hr = PrxDllCanUnloadNow(); if (hr != S_OK) return hr; #endif return _AtlModule.DllCanUnloadNow(); } // Returns a class factory to create an object of the requested type STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) { #ifdef _MERGE_PROXYSTUB if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK) return S_OK; #endif return _AtlModule.DllGetClassObject(rclsid, riid, ppv); } // DllRegisterServer - Adds entries to the system registry STDAPI DllRegisterServer(void) { // registers object, typelib and all interfaces in typelib HRESULT hr = _AtlModule.DllRegisterServer(); #ifdef _MERGE_PROXYSTUB if (FAILED(hr)) return hr; hr = PrxDllRegisterServer(); #endif return hr; } // DllUnregisterServer - Removes entries from the system registry STDAPI DllUnregisterServer(void) { HRESULT hr = _AtlModule.DllUnregisterServer(); #ifdef _MERGE_PROXYSTUB if (FAILED(hr)) return hr; hr = PrxDllRegisterServer(); if (FAILED(hr)) return hr; hr = PrxDllUnregisterServer(); #endif return hr; } // DllInstall - Adds/Removes entries to the system registry per user // per machine. STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine) { HRESULT hr = E_FAIL; static const wchar_t szUserSwitch[] = _T("user"); if (pszCmdLine != NULL) { if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0) { AtlSetPerUserRegistration(true); } } if (bInstall) { hr = DllRegisterServer(); if (FAILED(hr)) { DllUnregisterServer(); } } else { hr = DllUnregisterServer(); } return hr; }
[ [ [ 1, 93 ] ] ]
f0e63c3c4f5a075718f43dbdec5d8a7a0b9cf53c
069ae105affa645fee9b4966c940807495342406
/c++/windows/winthread_demo/winthread_demo/MsgPumpThread.h
d031cefe781c2326411c66ac3996103f3d4a69ac
[]
no_license
sburke56/example_code
2996beb4d97d987a66b40c48511729ed24d1eb44
537c6db4b645df8e3ddaa711ff659770991352d2
refs/heads/master
2020-05-20T11:38:19.110176
2011-06-09T01:52:53
2011-06-09T01:52:53
1,868,717
0
0
null
null
null
null
UTF-8
C++
false
false
483
h
#pragma once // CMsgPumpThread class CMsgPumpThread : public CWinThread { DECLARE_DYNCREATE(CMsgPumpThread) protected: virtual ~CMsgPumpThread(); public: //TODO: research why this constructor is protected in the template CMsgPumpThread(); // protected constructor used by dynamic creation virtual BOOL InitInstance(); virtual int ExitInstance(); void OnUsrHelp(WPARAM wParam, LPARAM lParam); protected: DECLARE_MESSAGE_MAP() };
[ [ [ 1, 26 ] ] ]
f8640eaf228c332923b6c29f3366008dc48aa3d4
25a6c9e6ec8755ac80414b5ab101ec88a421f1f8
/dollUploader/src/tttDownloader.h
aac20db08e236435d651fb883332ff16f4796c22
[]
no_license
roikr/ttt
1029e9635b31b4e595478453f76ef9a4575f224a
bb1fc73f5f93bd04543122ee11387f729d3c0520
refs/heads/master
2021-01-02T08:47:53.465120
2011-02-24T12:24:26
2011-02-24T12:24:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,346
h
#pragma once #include <string> #include <windows.h> using namespace std; #define MAX_BLOCK_WORDS 512 #define FEAT1_REPORT_SIZE 16 #define FEAT2_REPORT_SIZE (MAX_BLOCK_WORDS*2+8) #define FEAT_SMALL_REPORT_SIZE 16 #define FEAT_LARGE_REPORT_SIZE (MAX_BLOCK_WORDS*2+8) #define u08 unsigned char #define u16 unsigned short #define u32 unsigned long #define s16 short #define s32 long class tttDownloader { public: tttDownloader() : bDetected(false),rdata((u16*)&reportBuffer[1]),memoryDevice(0) {}; bool detectDevice(); bool getDeviceInfo(bool info); bool write(string filename); bool setDoll(int code); bool getDoll(int &code); private: bool bDetected; u16 vendorId, productId, versionNumber; u08 *pathName; // buffer for sending/receiving feature reports // it should be 1 byte more than the actual report payload because the HID API wants the // report ID included as the first byte. // most of the payload is handled as u16's u08 reportBuffer[FEAT_LARGE_REPORT_SIZE+1]; u16 *rdata; // default start/end addresses reported by device for up-to-4 flash memories u32 devStartAddress[4]; u32 devEndAddress[4]; u16 memoryDevice; int Command(int cmd, int device, int sendLongReportFlag, int getLongReportFlag, HANDLE h); int nlpdltest(char * filename); };
[ [ [ 1, 51 ] ] ]
7d91fa4ea50c11785767c79b76bbaffd7230a6ac
463c3b62132d215e245a097a921859ecb498f723
/lib/dlib/xml_parser/xml_parser_kernel_1.h
e8fe53a5bdbde50cc632200beb6cc97192e20628
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
athulan/cppagent
58f078cee55b68c08297acdf04a5424c2308cfdc
9027ec4e32647e10c38276e12bcfed526a7e27dd
refs/heads/master
2021-01-18T23:34:34.691846
2009-05-05T00:19:54
2009-05-05T00:19:54
197,038
4
1
null
null
null
null
UTF-8
C++
false
false
47,595
h
// Copyright (C) 2003 Davis E. King ([email protected]) // License: Boost Software License See LICENSE.txt for the full license. #ifndef DLIB_XML_PARSER_KERNEl_1_ #define DLIB_XML_PARSER_KERNEl_1_ #include <string> #include <iostream> #include "xml_parser_kernel_interfaces.h" #include "xml_parser_kernel_abstract.h" #include "../algs.h" namespace dlib { template < typename map, typename stack, typename seq_dh, typename seq_eh > class xml_parser_kernel_1 { /*! REQUIREMENTS ON map is an implementation of map/map_kernel_abstract.h or is an implementation of hash_map/hash_map_kernel_abstract.h and is instantiated to map items of type std::string to std::string REQUIREMENTS ON stack is an implementation of stack/stack_kernel_abstract.h and is instantiated with std::string REQUIREMENTS ON seq_dh is an implementation of sequence/sequence_kernel_abstract.h and is instantiated with document_handler* REQUIREMENTS ON seq_eh is an implementation of sequence/sequence_kernel_abstract.h and is instantiated with error_handler* INITIAL VALUE dh_list.size() == 0 eh_list.size() == 0 CONVENTION dh_list == a sequence of pointers to all the document_handlers that have been added to the xml_parser eh_list == a sequence of pointers to all the error_handlers that have been added to the xml_parser use of template parameters: map is used to implement the attribute_list interface stack is used just inside the parse function seq_dh is used to make the dh_list member variable seq_eh is used to make the eh_list member variable !*/ public: xml_parser_kernel_1( ); virtual ~xml_parser_kernel_1( ); void clear( ); void parse ( std::istream& in ); void add_document_handler ( document_handler& item ); void add_error_handler ( error_handler& item ); void swap ( xml_parser_kernel_1<map,stack,seq_dh,seq_eh>& item ); private: // ----------------------------------- // attribute_list interface implementation class attrib_list : public attribute_list { public: // the list of attribute name/value pairs map list; bool is_in_list ( const std::string& key ) const { return list.is_in_domain(key); } const std::string& operator[] ( const std::string& key ) const { return list[key]; } bool at_start ( ) const { return list.at_start(); } void reset ( ) const { return list.reset(); } bool current_element_valid ( ) const { return list.current_element_valid(); } const type& element ( ) const { return list.element(); } type& element ( ) { return list.element(); } bool move_next ( ) const { return list.move_next(); } unsigned long size ( ) const { return list.size(); } }; // ----------------------------------- enum token_type { element_start, // the first tag of an element element_end, // the last tag of an element empty_element, // the singular tag of an empty element pi, // processing instruction chars, // the non-markup data between tags chars_cdata, // the data from a CDATA section eof, // this token is returned when we reach the end of input error, // this token indicates that the tokenizer couldn't // determine which category the next token fits into dtd, // this token is for an entire dtd comment // this is a token for comments }; /* notes about the tokens: the tokenizer guarantees that the following tokens to not contain the '<' character except as the first character of the token element_start, element_end, empty_element, and pi. they also only contain the '>' characer as their last character. it is also guaranteed that pi is at least of the form <??>. that is to say that it always always begins with <? and ends with ?>. it is also guaranteed that all markup tokens will begin with the '<' character and end with the '>'. there won't be any leading or trailing whitespaces. this whitespace is considered a chars token. */ // private member functions void get_next_token( std::istream& in, std::string& token_text, int& token_kind, unsigned long& line_number ); /*! ensures gets the next token from in and puts it in token_text and token_kind == the kind of the token found and line_number is incremented every time a '\n' is encountered and entity references are translated into the characters they represent only for chars tokens !*/ int parse_element ( const std::string& token, std::string& name, attrib_list& atts ); /*! requires token is a token of kind start_element or empty_element ensures gets the element name and puts it into the string name and parses out the attributes and puts them into the attribute_list atts return 0 upon success or returns -1 if it failed to parse token !*/ int parse_pi ( const std::string& token, std::string& target, std::string& data ); /*! requires token is a token of kind pi ensures the target from the processing instruction is put into target and the data from the processing instruction is put into data return 0 upon success or returns -1 if it failed to parse token !*/ int parse_element_end ( const std::string& token, std::string& name ); /*! requires token is a token of kind element_end ensures the name from the ending element tag is put into the string name return 0 upon success or returns -1 if it failed to parse token !*/ inline int change_entity ( std::istream& in ); /*! ensures performs the following translations and returns the new character amp; -> & lt; -> < gt; -> > apos; -> ' quot; -> " or returns -1 if we hit an undefined entity reference or EOF. (i.e. it was not one of the entities listed above) !*/ // ----------------------------------- // private member data seq_dh dh_list; seq_eh eh_list; // ----------------------------------- // restricted functions: assignment and copy construction xml_parser_kernel_1(xml_parser_kernel_1<map,stack,seq_dh,seq_eh>&); xml_parser_kernel_1<map,stack,seq_dh,seq_eh>& operator= ( xml_parser_kernel_1<map,stack,seq_dh,seq_eh>& ); }; template < typename map, typename stack, typename seq_dh, typename seq_eh > inline void swap ( xml_parser_kernel_1<map,stack,seq_dh,seq_eh>& a, xml_parser_kernel_1<map,stack,seq_dh,seq_eh>& b ) { a.swap(b); } // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- // member function definitions // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- template < typename map, typename stack, typename seq_dh, typename seq_eh > xml_parser_kernel_1<map,stack,seq_dh,seq_eh>:: xml_parser_kernel_1( ) { } // ---------------------------------------------------------------------------------------- template < typename map, typename stack, typename seq_dh, typename seq_eh > xml_parser_kernel_1<map,stack,seq_dh,seq_eh>:: ~xml_parser_kernel_1( ) { } // ---------------------------------------------------------------------------------------- template < typename map, typename stack, typename seq_dh, typename seq_eh > void xml_parser_kernel_1<map,stack,seq_dh,seq_eh>:: clear( ) { // unregister all event handlers eh_list.clear(); dh_list.clear(); } // ---------------------------------------------------------------------------------------- template < typename map, typename stack, typename seq_dh, typename seq_eh > void xml_parser_kernel_1<map,stack,seq_dh,seq_eh>:: parse ( std::istream& in ) { // save which exceptions in will throw and make it so it won't throw any // for the life of this function std::ios::iostate old_exceptions = in.exceptions(); // set it to not throw anything in.exceptions(std::ios::goodbit); try { unsigned long line_number = 1; // skip any whitespace before the start of the document while (in.peek() == ' ' || in.peek() == '\t' || in.peek() == '\n' || in.peek() == '\r' ) { if (in.peek() == '\n') ++line_number; in.get(); } stack tags; // this stack contains the last start tag seen bool seen_fatal_error = false; bool seen_root_tag = false; // this is true after we have seen the root tag // notify all the document_handlers that we are about to being parsing for (unsigned long i = 0; i < dh_list.size(); ++i) { dh_list[i]->start_document(); } std::string chars_buf; // used to collect chars data between consecutive // chars and chars_cdata tokens so that // document_handlers receive all chars data between // tags in one call // variables to be used with the parsing functions attrib_list atts; std::string name; std::string target; std::string data; // variables to use with the get_next_token() function std::string token_text; int token_kind; get_next_token(in,token_text,token_kind,line_number); while (token_kind != eof) { bool is_empty = false; // this becomes true when this token is an empty_element switch (token_kind) { case empty_element: is_empty = true; case element_start: { seen_root_tag = true; int status = parse_element(token_text,name,atts); // if there was no error parsing the element if (status == 0) { // notify all the document_handlers for (unsigned long i = 0; i < dh_list.size(); ++i) { dh_list[i]->start_element(line_number,name,atts); if (is_empty) dh_list[i]->end_element(line_number,name); } } else { seen_fatal_error = true; } // if this is an element_start token then push the name of // the element on to the stack if (token_kind == element_start) { tags.push(name); } }break; // ---------------------------------------- case element_end: { int status = parse_element_end (token_text,name); // if there was no error parsing the element if (status == 0) { // make sure this ending element tag matches the last start // element tag we saw if ( tags.size() == 0 || name != tags.current()) { // they don't match so signal a fatal error seen_fatal_error = true; } else { // notify all the document_handlers for (unsigned long i = 0; i < dh_list.size(); ++i) { dh_list[i]->end_element(line_number,name); } // they match so throw away this element name tags.pop(name); } } else { seen_fatal_error = true; } }break; // ---------------------------------------- case pi: { int status = parse_pi (token_text,target,data); // if there was no error parsing the element if (status == 0) { // notify all the document_handlers for (unsigned long i = 0; i < dh_list.size(); ++i) { dh_list[i]->processing_instruction(line_number,target,data); } } else { // notify all the error_handlers for (unsigned long i = 0; i < eh_list.size(); ++i) { eh_list[i]->error(line_number); } } while (in.peek() == ' ' || in.peek() == '\t' || in.peek() == '\n' || in.peek() == '\r' ) { if (in.peek() == '\n') ++line_number; in.get(); } }break; // ---------------------------------------- case chars: { if (tags.size() != 0) { chars_buf += token_text; } else if (token_text.find_first_not_of(" \t\r\n") != std::string::npos) { // you can't have non whitespace chars data outside the root element seen_fatal_error = true; } }break; // ---------------------------------------- case chars_cdata: { if (tags.size() != 0) { chars_buf += token_text; } else { // you can't have chars_data outside the root element seen_fatal_error = true; } }break; // ---------------------------------------- case eof: break; // ---------------------------------------- case error: { seen_fatal_error = true; }break; // ---------------------------------------- case dtd: // fall though case comment: // do nothing break; // ---------------------------------------- } // if there was a fatal error then quit loop if (seen_fatal_error) break; // if we have seen the last tag then quit the loop if (tags.size() == 0 && seen_root_tag) break; get_next_token(in,token_text,token_kind,line_number); // if the next token is not a chars or chars_cdata token then flush // the chars_buf to the document_handlers if ( (token_kind != chars) && (token_kind != chars_cdata) && (token_kind != dtd) && (token_kind != comment) && (chars_buf.size() != 0) ) { // notify all the document_handlers for (unsigned long i = 0; i < dh_list.size(); ++i) { dh_list[i]->characters(chars_buf); } chars_buf.erase(); } } //while (token_kind != eof) // you can't have any unmatched tags or any fatal erros if (tags.size() != 0 || seen_fatal_error) { // notify all the error_handlers for (unsigned long i = 0; i < eh_list.size(); ++i) { eh_list[i]->fatal_error(line_number); } } // notify all the document_handlers that we have ended parsing for (unsigned long i = 0; i < dh_list.size(); ++i) { dh_list[i]->end_document(); } } catch (...) { // notify all the document_handlers that we have ended parsing for (unsigned long i = 0; i < dh_list.size(); ++i) { dh_list[i]->end_document(); } // restore the old exception settings to in in.exceptions(old_exceptions); } // restore the old exception settings to in in.exceptions(old_exceptions); } // ---------------------------------------------------------------------------------------- template < typename map, typename stack, typename seq_dh, typename seq_eh > void xml_parser_kernel_1<map,stack,seq_dh,seq_eh>:: add_document_handler ( document_handler& item ) { document_handler* temp = &item; dh_list.add(dh_list.size(),temp); } // ---------------------------------------------------------------------------------------- template < typename map, typename stack, typename seq_dh, typename seq_eh > void xml_parser_kernel_1<map,stack,seq_dh,seq_eh>:: add_error_handler ( error_handler& item ) { error_handler* temp = &item; eh_list.add(eh_list.size(),temp); } // ---------------------------------------------------------------------------------------- template < typename map, typename stack, typename seq_dh, typename seq_eh > void xml_parser_kernel_1<map,stack,seq_dh,seq_eh>:: swap ( xml_parser_kernel_1<map,stack,seq_dh,seq_eh>& item ) { dh_list.swap(item.dh_list); eh_list.swap(item.eh_list); } // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- // private member function definitions // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- template < typename map, typename stack, typename seq_dh, typename seq_eh > void xml_parser_kernel_1<map,stack,seq_dh,seq_eh>:: get_next_token( std::istream& in, std::string& token_text, int& token_kind, unsigned long& line_number ) { token_text.erase(); std::istream::int_type ch1 = in.get(); std::istream::int_type ch2; switch (ch1) { // ----------------------------------------- // this is the start of some kind of a tag case '<': { ch2 = in.get(); switch (ch2) { // --------------------------------- // this is a dtd, comment, or chars_cdata token case '!': { // if this is a CDATA section ******************************* if ( in.peek() == '[') { token_kind = chars_cdata; // throw away the '[' in.get(); // make sure the next chars are CDATA[ std::istream::int_type ch = in.get(); if (ch != 'C') token_kind = error; ch = in.get(); if (ch != 'D') token_kind = error; ch = in.get(); if (ch != 'A') token_kind = error; ch = in.get(); if (ch != 'T') token_kind = error; ch = in.get(); if (ch != 'A') token_kind = error; ch = in.get(); if (ch != '[') token_kind = error; // if this is an error token then end if (token_kind == error) break; // get the rest of the chars and put them into token_text int brackets_seen = 0; // this is the number of ']' chars // we have seen in a row bool seen_closing = false; // true if we have seen ]]> do { ch = in.get(); if (ch == '\n') ++line_number; token_text += ch; // if this is the closing if (brackets_seen == 2 && ch == '>') seen_closing = true; // if we are seeing a bracket else if (ch == ']') ++brackets_seen; // if we didn't see a bracket else brackets_seen = 0; } while ( (!seen_closing) && (ch != EOF) ); // check if this is an error token if (ch == EOF) { token_kind = error; } else { token_text.erase(token_text.size()-3); } } // this is a comment token **************************** else if (in.peek() == '-') { token_text += ch1; token_text += ch2; token_text += '-'; token_kind = comment; // throw away the '-' char in.get(); // make sure the next char is another '-' std::istream::int_type ch = in.get(); if (ch != '-') { token_kind = error; break; } token_text += '-'; // get the rest of the chars and put them into token_text int hyphens_seen = 0; // this is the number of '-' chars // we have seen in a row bool seen_closing = false; // true if we have seen ]]> do { ch = in.get(); if (ch == '\n') ++line_number; token_text += ch; // if this should be a closing block if (hyphens_seen == 2) { if (ch == '>') seen_closing = true; else // this isn't a closing so make it signal error ch = EOF; } // if we are seeing a hyphen else if (ch == '-') ++hyphens_seen; // if we didn't see a hyphen else hyphens_seen = 0; } while ( (!seen_closing) && (ch != EOF) ); // check if this is an error token if (ch == EOF) { token_kind = error; } } else // this is a dtd token ************************* { token_text += ch1; token_text += ch2; int bracket_depth = 1; // this is the number of '<' chars seen // minus the number of '>' chars seen std::istream::int_type ch; do { ch = in.get(); if (ch == '>') --bracket_depth; else if (ch == '<') ++bracket_depth; else if (ch == '\n') ++line_number; token_text += ch; } while ( (bracket_depth > 0) && (ch != EOF) ); // make sure we didn't just hit EOF if (bracket_depth == 0) { token_kind = dtd; } else { token_kind = error; } } } break; // --------------------------------- // this is a pi token case '?': { token_text += ch1; token_text += ch2; std::istream::int_type ch; do { ch = in.get(); token_text += ch; if (ch == '\n') ++line_number; // else if we hit a < then thats an error else if (ch == '<') ch = EOF; } while (ch != '>' && ch != EOF); // if we hit the end of the pi if (ch == '>') { // make sure there was a trailing '?' if ( (token_text.size() > 3) && (token_text[token_text.size()-2] != '?') ) { token_kind = error; } else { token_kind = pi; } } // if we hit EOF unexpectidely then error else { token_kind = error; } } break; // --------------------------------- // this is an error token case EOF: { token_kind = error; } break; // --------------------------------- // this is an element_end token case '/': { token_kind = element_end; token_text += ch1; token_text += ch2; std::istream::int_type ch; do { ch = in.get(); if (ch == '\n') ++line_number; // else if we hit a < then thats an error else if (ch == '<') ch = EOF; token_text += ch; } while ( (ch != '>') && (ch != EOF)); // check if this is an error token if (ch == EOF) { token_kind = error; } } break; // --------------------------------- // this is an element_start or empty_element token default: { token_text += ch1; token_text += ch2; std::istream::int_type ch = '\0'; std::istream::int_type last; do { last = ch; ch = in.get(); if (ch == '\n') ++line_number; // else if we hit a < then thats an error else if (ch == '<') ch = EOF; token_text += ch; } while ( (ch != '>') && (ch != EOF)); // check if this is an error token if (ch == EOF) { token_kind = error; } // if this is an empty_element else if (last == '/') { token_kind = empty_element; } else { token_kind = element_start; } } break; // --------------------------------- } } break; // ----------------------------------------- // this is an eof token case EOF: { token_kind = eof; } break; // ----------------------------------------- // this is a chars token default: { if (ch1 == '\n') { ++line_number; token_text += ch1; } // if the first thing in this chars token is an entity reference else if (ch1 == '&') { int temp = change_entity(in); if (temp == -1) { token_kind = error; break; } else { token_text += temp; } } else { token_text += ch1; } token_kind = chars; std::istream::int_type ch = 0; while (in.peek() != '<' && in.peek() != EOF) { ch = in.get(); if (ch == '\n') ++line_number; // if this is one of the predefined entity references then change it if (ch == '&') { int temp = change_entity(in); if (temp == -1) { ch = EOF; break; } else token_text += temp; } else { token_text += ch; } } // if this is an error token if (ch == EOF) { token_kind = error; } } break; // ----------------------------------------- } } // ---------------------------------------------------------------------------------------- template < typename map, typename stack, typename seq_dh, typename seq_eh > int xml_parser_kernel_1<map,stack,seq_dh,seq_eh>:: parse_element ( const std::string& token, std::string& name, attrib_list& atts ) { name.erase(); atts.list.clear(); // there must be at least one character between the <> if (token[1] == '>') return -1; std::string::size_type i; std::istream::int_type ch = token[1]; i = 2; // fill out name. the name can not contain any of the following characters while ( (ch != '>') && (ch != ' ') && (ch != '=') && (ch != '/') && (ch != '\t') && (ch != '\r') && (ch != '\n') ) { name += ch; ch = token[i]; ++i; } // skip any whitespaces while ( ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r' ) { ch = token[i]; ++i; } // find any attributes while (ch != '>' && ch != '/') { std::string attribute_name; std::string attribute_value; // fill out attribute_name while ( (ch != '=') && (ch != ' ') && (ch != '\t') && (ch != '\r') && (ch != '\n') && (ch != '>') ) { attribute_name += ch; ch = token[i]; ++i; } // you can't have empty attribute names if (attribute_name.size() == 0) return -1; // if we hit > too early then return error if (ch == '>') return -1; // skip any whitespaces while (ch == ' ' || ch == '\t' || ch =='\n' || ch =='\r') { ch = token[i]; ++i; } // the next char should be a '=', error if it's not if (ch != '=') return -1; // get the next char ch = token[i]; ++i; // skip any whitespaces while (ch == ' ' || ch == '\t' || ch =='\n' || ch =='\r') { ch = token[i]; ++i; } // get the delimiter for the attribute value std::istream::int_type delimiter = ch; // this should be either a ' or " character ch = token[i]; // get the next char ++i; if (delimiter != '\'' && delimiter!='"') return -1; // fill out attribute_value while ( (ch != delimiter) && (ch != '>') ) { attribute_value += ch; ch = token[i]; ++i; } // if there was no delimiter then this is an error if (ch == '>') { return -1; } // go to the next char ch = token[i]; ++i; // the next char must be either a '>' or '/' (denoting the end of the tag) // or a white space character if (ch != '>' && ch != ' ' && ch != '/' && ch != '\t' && ch !='\n' && ch !='\r') return -1; // skip any whitespaces while (ch == ' ' || ch == '\t' || ch =='\n' || ch =='\r') { ch = token[i]; ++i; } // add attribute_value and attribute_name to atts if (atts.list.is_in_domain(attribute_name)) { // attributes may not be multiply defined return -1; } else { atts.list.add(attribute_name,attribute_value); } } // you can't have an element with no name if (name.size() == 0) return -1; return 0; } // ---------------------------------------------------------------------------------------- template < typename map, typename stack, typename seq_dh, typename seq_eh > int xml_parser_kernel_1<map,stack,seq_dh,seq_eh>:: parse_pi ( const std::string& token, std::string& target, std::string& data ) { target.erase(); data.erase(); std::istream::int_type ch = token[2]; std::string::size_type i = 3; while (ch != ' ' && ch != '?' && ch != '\t' && ch != '\n' && ch!='\r') { target += ch; ch = token[i]; ++i; } if (target.size() == 0) return -1; // if we aren't at a ? character then go to the next character if (ch != '?' ) { ch = token[i]; ++i; } // if we still aren't at the end of the processing instruction then // set this stuff in the data section while (ch != '?') { data += ch; ch = token[i]; ++i; } return 0; } // ---------------------------------------------------------------------------------------- template < typename map, typename stack, typename seq_dh, typename seq_eh > int xml_parser_kernel_1<map,stack,seq_dh,seq_eh>:: parse_element_end ( const std::string& token, std::string& name ) { name.erase(); std::string::size_type end = token.size()-1; for (std::string::size_type i = 2; i < end; ++i) { if (token[i] == ' ' || token[i] == '\t' || token[i] == '\n'|| token[i] == '\r') break; name += token[i]; } if (name.size() == 0) return -1; return 0; } // ---------------------------------------------------------------------------------------- template < typename map, typename stack, typename seq_dh, typename seq_eh > int xml_parser_kernel_1<map,stack,seq_dh,seq_eh>:: change_entity ( std::istream& in ) { std::istream::int_type buf[6]; buf[1] = in.get(); // if this is an undefined entity reference then return error if (buf[1] != 'a' && buf[1] != 'l' && buf[1] != 'g' && buf[1] != 'q' ) return -1; buf[2] = in.get(); // if this is an undefined entity reference then return error if (buf[2] != 'm' && buf[2] != 't' && buf[2] != 'p' && buf[2] != 'u' ) return -1; buf[3] = in.get(); // if this is an undefined entity reference then return error if (buf[3] != 'p' && buf[3] != ';' && buf[3] != 'o' ) return -1; // check if this is &lt; or &gt; if (buf[3] == ';') { if (buf[2] != 't') return -1; // if this is &lt; then return '<' if (buf[1] == 'l') return '<'; // if this is &gt; then return '>' if (buf[1] == 'g') return '>'; // it is neither so it must be an undefined entity reference return -1; } buf[4] = in.get(); // if this should be &amp; if (buf[4] == ';') { // if this is not &amp; then return error if (buf[1] != 'a' || buf[2] != 'm' || buf[3] != 'p' ) return -1; return '&'; } buf[5] = in.get(); // if this should be &apos; if (buf[1] == 'a' && buf[2] == 'p' && buf[3] == 'o' && buf[4] == 's' && buf[5] == ';' ) return '\''; // if this should be &quot; if (buf[1] == 'q' && buf[2] == 'u' && buf[3] == 'o' && buf[4] == 't' && buf[5] == ';' ) return '"'; // it was an undefined entity reference return -1; } // ---------------------------------------------------------------------------------------- } #endif // DLIB_XML_PARSER_KERNEl_1_
[ "jimmy@DGJ3X3B1.(none)" ]
[ [ [ 1, 1463 ] ] ]
d0f63bfe7f2f060509133d73d65172141f820bdf
df5277b77ad258cc5d3da348b5986294b055a2be
/Spaceships/GameObjectVisitor.cpp
261a66317cb33c405ce9ad788e028b9b1e0df496
[]
no_license
beentaken/cs260-last2
147eaeb1ab15d03c57ad7fdc5db2d4e0824c0c22
61b2f84d565cc94a0283cc14c40fb52189ec1ba5
refs/heads/master
2021-03-20T16:27:10.552333
2010-04-26T00:47:13
2010-04-26T00:47:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
915
cpp
#include "precompiled.h" #include "GameObjectVisitor.h" GameObjectVisitor::GameObjectVisitor(void) { } GameObjectVisitor::~GameObjectVisitor(void) { } void GameObjectVisitor::VisitorAccepted(GameObject* objectToVisit, Controller* controller) { objectVisiting = objectToVisit; owningController = controller; OnAccept(); } void GameObjectVisitor::Leave() { OnLeave(); this->objectVisiting->PassMessageDirect( new Message(MessageType::GAME_OBJECT_ACTION, MessageContent::VISITOR_LEAVE, (void*)this)); } void GameObjectVisitor::Visit(GameObject* object) { OnVisit(object); } void GameObjectVisitor::PassMessage(Message* msg) { messages.push_back(msg); } void GameObjectVisitor::ProcessMessages() { list<Message*>::iterator msgIter; while(messages.size() > 0) { Message* message = messages.front(); messages.pop_front(); ProcessMessage(message); } }
[ "ProstheticMind43@af704e40-745a-32bd-e5ce-d8b418a3b9ef" ]
[ [ [ 1, 45 ] ] ]
18f5fc47fc0d804cb5921b4fb4213103452286bb
7b379862f58f587d9327db829ae4c6493b745bb1
/Source/AbltonStyleOSCComponent.h
bdf298f125bef6c463db5a57d554f1efdf7cdc5a
[]
no_license
owenvallis/Nomestate
75e844e8ab68933d481640c12019f0d734c62065
7fe7c06c2893421a3c77b5180e5f27ab61dd0ffd
refs/heads/master
2021-01-19T07:35:14.301832
2011-12-28T07:42:50
2011-12-28T07:42:50
2,950,072
2
0
null
null
null
null
UTF-8
C++
false
false
1,017
h
/* ============================================================================== AbletonStyleOSCComponent.h Created: 5 Dec 2011 12:16:23pm Author: Owen Vallis ============================================================================== */ #ifndef __ABLETONSTYLEOSCCOMPONENT_H_3A13D744__ #define __ABLETONSTYLEOSCCOMPONENT_H_3A13D744__ #include "../../JuceLibraryCode/JuceHeader.h" class AbletonStyleOSCComponent : public Component, public ButtonListener { public: //============================================================================== AbletonStyleOSCComponent (); ~AbletonStyleOSCComponent(); //============================================================================== void paint (Graphics& g); void resized(); void buttonClicked (Button* buttonThatWasClicked); private: TextButton setOSCPrefix; }; #endif // __ABLETONSTYLEOSCCOMPONENT_H_3A13D744__
[ "ow3nskip" ]
[ [ [ 1, 39 ] ] ]
4bb03c421f58ea606573628798403effe660b535
e7c45d18fa1e4285e5227e5984e07c47f8867d1d
/Common/Models/MDLBASE/CTRL_IO.CPP
a70c6e0e5942598d093764a2fc1e656d95fab419
[]
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
10,257
cpp
//================== SysCAD - Copyright Kenwalt (Pty) Ltd =================== // $Nokeywords: $ //=========================================================================== // SysCAD Copyright Kenwalt (Pty) Ltd 1992 #include "stdafx.h" #include <string.h> #include <math.h> #include <stdio.h> #define __CTRL_IO_CPP #include "ctrl_io.h" //=========================================================================== //=========================================================================== // // // //=========================================================================== //void CIO_Logic::DDBAdd_OnOff(DataDefnBlk & DDB, pchar pTag, pflag pOn, flag bOffisBlank) // { // DDB.Bool("", pTag, DC_, "", pOn, this, isParm); // DDB.IndexedStrValue((int)False, bOffisBlank ? "" : "Off"); // DDB.IndexedStrValue((int)True, "On"); // } // ////--------------------------------------------------------------------------- // //void CIO_Logic::DDBAdd_YesNo(DataDefnBlk & DDB, pchar pTag, pflag pYes, flag bNoisBlank) // { // DDB.Bool("", pTag, DC_, "", pYes, this, isParm); // DDB.IndexedStrValue((int)False, bNoisBlank ? "" : "No"); // DDB.IndexedStrValue((int)True, "Yes"); // } //--------------------------------------------------------------------------- pchar CIO_Logic::LogicName() { static Strng S; Class()->GetShortDesc(S); return S(); } //=========================================================================== // // // //=========================================================================== CIO_Blk::CIO_Blk(pchar Group, pchar Name, pTaggedObject pAttach, CPwrUser * pPwr) { pGroup=Group; m_pPwr=pPwr; pLogic=CreateLogic(Name, pAttach); }; //-------------------------------------------------------------------------- CIO_Blk::~CIO_Blk() { if (pLogic) delete pLogic; }; //-------------------------------------------------------------------------- CIO_Logic * CIO_Blk::CreateLogic(pchar Name_, pTaggedObject pAttach) { CIO_Logic * pLog=NULL; if (Name_ && strlen(Name_)>0) pLog=(CIO_Logic *)TagObjClass::Construct(pGroup, Name_, NULL, "Logic", pAttach, pAttach ? TOA_Embedded : TOA_Free); if (pLog) pLog->m_pPwr=m_pPwr; return pLog; }; // ------------------------------------------------------------------------- void CIO_Blk::ChangeLogic(pchar Name_) { ASSERT(pLogic); if (Name_ && (_stricmp(Name_, pLogic->ClassId())!=0)) { ASSERT(pLogic->pAttachedTo); pLogic->StructureChanged(pLogic->pAttachedTo); CIO_Logic * pLog=CreateLogic(Name_, pLogic->pAttachedTo); if (pLog) { pLog->CopyFrom(pLogic); if (pLogic) delete pLogic; pLogic=pLog; } } }; //-------------------------------------------------------------------------- void CIO_Blk::BuildDataDefn(DataDefnBlk & DDB, pTaggedObject pOwnObj, pchar pName, dword dwUserInfo, pchar pComment, int HandleOffset) { ASSERT(pGroup); if (DDB.BeginStruct(pOwnObj, pName, pComment, DDB_NoPage, dwUserInfo)) { DDBValueLstMem DDB0; TagObjClass::GetSDescValueLst(pGroup, DDB0); DDB.String ("Type", "", DC_ , "", xidLogicNm+HandleOffset , pOwnObj ,isParm|SetOnChange, DDB0()); if (pLogic) pLogic->BuildDataDefn(DDB); } DDB.EndStruct(); }; //-------------------------------------------------------------------------- flag CIO_Blk::DataXchg(DataChangeBlk & DCB, int HandleOffset) { if (pLogic && pLogic->DataXchg(DCB)) return True; switch (DCB.lHandle-HandleOffset) { case xidLogicNm: { if (DCB.rpC) { Strng S; for (int i=0; ;i++) { pTagObjClass pC=TagObjClass::FindClassIndexed(pGroup, i); if (pC==NULL) break; else { pC->GetShortDesc(S); if (S.XStrICmp(DCB.rpC)==0) { ChangeLogic(pC->ClassId()); break; } } } } DCB.pC=LogicName(); return True; } } return False; }; //=========================================================================== // // // //=========================================================================== CIO_DLogic::CIO_DLogic() { pbSet=NULL; }; //--------------------------------------------------------------------------- void CIO_DLogic::AttachValue(pflag pSet) { pbSet=pSet; }; //--------------------------------------------------------------------------- void CIO_DLogic::Set(flag Set) { *pbSet=Set; }; //--------------------------------------------------------------------------- void CIO_DLogic::BuildDataDefn(pTaggedObject pObj, pchar pTag, DataDefnBlk & DDB) { DDB.Bool("", "On", DC_, "", pbSet, pObj, isParm, DDBOnOff); }; //--------------------------------------------------------------------------- flag CIO_DLogic::DataXchg(DataChangeBlk & DCB) { return 0; }; //--------------------------------------------------------------------------- void CIO_DLogic::EvalDiscrete(FlwNode* pNd) { }; void CIO_DLogic::EvalCtrlActions(FlwNode* pNd) { }; void CIO_DLogic::EvalCtrlStrategy(FlwNode* pNd) { }; //=========================================================================== CIO_Digital::CIO_Digital() { bSet=1; pLogic=NULL; }; //--------------------------------------------------------------------------- void CIO_Digital::AttachLogic(pCIO_DLogic Logic) { pLogic=Logic; if (pLogic) pLogic->AttachValue(&bSet); }; //--------------------------------------------------------------------------- pCIO_DLogic CIO_Digital::DetachLogic() { pCIO_DLogic RetLogic=pLogic; pLogic=NULL; return RetLogic; }; //--------------------------------------------------------------------------- flag CIO_Digital::Set(flag SetIt) { if (pLogic) pLogic->Set(SetIt); else bSet=(flag)SetIt; return bSet; }; //--------------------------------------------------------------------------- void CIO_Digital::BuildDataDefn(pTaggedObject pObj, pchar pTag, DataDefnBlk & DDB) { if (pLogic) { if (DDB.BeginStruct(pObj, pTag, NULL, DDB_NoPage)) pLogic->BuildDataDefn(pObj, pTag, DDB); DDB.EndStruct(); } else { Strng Tg(pTag?pTag:pObj->Tag(), ".", "On"); DDB.CheckBoxBtn("", "On", DC_, "", &bSet, pObj, isParm, DDBOnOff); //DDB.Bool("", "On", DC_, "", &bSet, pObj, isParm, DDBOnOff); } }; //--------------------------------------------------------------------------- flag CIO_Digital::DataXchg(DataChangeBlk & DCB) { if (pLogic) return pLogic->DataXchg(DCB); return 0; }; //--------------------------------------------------------------------------- void CIO_Digital::EvalDiscrete(FlwNode* pNd) { }; void CIO_Digital::EvalCtrlActions(FlwNode* pNd) { }; void CIO_Digital::EvalCtrlStrategy(FlwNode* pNd) { }; //=========================================================================== CIO_ALogic::CIO_ALogic() { pdVal=NULL; }; //--------------------------------------------------------------------------- void CIO_ALogic::AttachValue(pdouble pVal) { pdVal=pVal; }; //--------------------------------------------------------------------------- void CIO_ALogic::Set(double Val) { *pdVal=Val; }; //--------------------------------------------------------------------------- void CIO_ALogic::BuildDataDefn(pTaggedObject pObj, pchar pTag, DataDefnBlk & DDB) { DDB.Double("Signal", "Y", DC_Frac, "%", pdVal, pObj, isParm); }; //--------------------------------------------------------------------------- flag CIO_ALogic::DataXchg(DataChangeBlk & DCB) { return 0; }; //--------------------------------------------------------------------------- void CIO_ALogic::EvalDiscrete(FlwNode* pNd) { }; void CIO_ALogic::EvalCtrlActions(FlwNode* pNd) { }; void CIO_ALogic::EvalCtrlStrategy(FlwNode* pNd) { }; //=========================================================================== CIO_Analog::CIO_Analog() { dVal=1.0; pLogic=NULL; }; //--------------------------------------------------------------------------- void CIO_Analog::AttachLogic(pCIO_ALogic Logic) { pLogic=Logic; if (pLogic) pLogic->AttachValue(&dVal); }; //--------------------------------------------------------------------------- pCIO_ALogic CIO_Analog::DetachLogic() { pCIO_ALogic RetLogic=pLogic; pLogic=NULL; return RetLogic; }; //--------------------------------------------------------------------------- double CIO_Analog::Set(double Val) { if (pLogic) pLogic->Set(Val); else dVal=Val; return dVal; }; //--------------------------------------------------------------------------- void CIO_Analog::BuildDataDefn(pTaggedObject pObj, pchar pTag, DataDefnBlk & DDB) { if (DDB.BeginStruct(pObj, pTag, NULL, DDB_NoPage)) { if (pLogic) pLogic->BuildDataDefn(pObj, pTag, DDB); else { DDB.Double("Signal", "Y", DC_Frac, "%", &dVal, pObj, isParm); } } DDB.EndStruct(); }; //--------------------------------------------------------------------------- flag CIO_Analog::DataXchg(DataChangeBlk & DCB) { if (pLogic) return pLogic->DataXchg(DCB); return 0; }; //--------------------------------------------------------------------------- void CIO_Analog::EvalDiscrete(FlwNode* pNd) { }; void CIO_Analog::EvalCtrlActions(FlwNode* pNd) { }; void CIO_Analog::EvalCtrlStrategy(FlwNode* pNd) { }; //=========================================================================== // // // //===========================================================================
[ [ [ 1, 84 ], [ 86, 246 ], [ 248, 248 ], [ 250, 250 ], [ 252, 252 ], [ 259, 413 ] ], [ [ 85, 85 ], [ 247, 247 ], [ 249, 249 ], [ 251, 251 ], [ 253, 258 ] ] ]
fe7eae70d5715200e8f1e5875e9b7921673056c1
40e58042e635ea2a61a6216dc3e143fd3e14709c
/chopshop11/CameraTask.h
3b55ace5185883a9da334bb60e2ed2060816fbd5
[]
no_license
chopshop-166/frc-2011
005bb7f0d02050a19bdb2eb33af145d5d2916a4d
7ef98f84e544a17855197f491fc9f80247698dd3
refs/heads/master
2016-09-05T10:59:54.976527
2011-10-20T22:50:17
2011-10-20T22:50:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,392
h
/******************************************************************************* * Project : Chopshop11 * File Name : CameraTask.h * Owner : Software Group (FIRST Chopshop Team 166) * File Description : Task to run the camera and tracking * File Description : Definition of CameraTask class and associated data *******************************************************************************/ /*----------------------------------------------------------------------------*/ /* Copyright (c) MHS Chopshop Team 166, 2010. All Rights Reserved. */ /*----------------------------------------------------------------------------*/ #pragma once #include "WPILib.h" #include "Robot.h" #include "Proxy.h" #include "Vision/AxisCamera.h" #include "TrackAPI.h" // // This constant defines how often we want this task to run in the form // of miliseconds. Max allowed time is 999 miliseconds. #define CAMERA_CYCLE_TIME (20) // ms /** Private NI function needed to write to the VxWorks target */ IMAQ_FUNC int Priv_SetWriteFileAllowed(UINT32 enable); /** * Store an Image to the cRIO in the specified path */ #if SAVE_IMAGES void SaveImage(char* imageName, Image* image); #endif class CameraTask : public Team166Task { public: // task constructor CameraTask(void); // task destructor virtual ~CameraTask(void); // Main function of the task virtual int Main(int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10); // Take a picture and store to cRIO // Any task should be able to call this to take and save a snapshot static void TakeSnapshot(char* imageName); // Search for Target bool FindCircleTargets(); bool FindLightTargets(); private: Proxy *proxy; // Handle to proxy Robot *lHandle; // Local handle AxisCamera &camera; static CameraTask *myHandle; // handle to myself for static function //values to log double targetHAngle; double targetVAngle; double targetSize; int widestParticleIndex; ParticleAnalysisReport Biggest; int CameraTask::GetWidestParticle(Image* binaryImage, int* widestParticleIndex); double targetCenterNormalized; int CameraTask::ProcessImage(double* targetCenterNormalized); /*ddduuurrrrr...? */ int imageProcessResult; Range R_Range; Range B_Range; Range G_Range; };
[ "", "[email protected]", "devnull@localhost", "[email protected]" ]
[ [ [ 1, 1 ], [ 3, 4 ], [ 7, 15 ], [ 17, 17 ], [ 19, 24 ], [ 34, 49 ], [ 53, 53 ], [ 56, 60 ], [ 79, 79 ] ], [ [ 2, 2 ] ], [ [ 5, 6 ], [ 16, 16 ], [ 18, 18 ], [ 25, 30 ], [ 32, 32 ], [ 50, 52 ], [ 54, 55 ], [ 61, 78 ] ], [ [ 31, 31 ], [ 33, 33 ] ] ]
fa6030bdd31eeb4299fd50d427f6f051f2b194ea
28aa23d9cb8f5f4e8c2239c70ef0f8f6ec6d17bc
/mytesgnikrow --username hotga2801/Project/MotionAdaboost/Develop/hbp/classColourClasifier.cpp
0d875fcd265251d6c637c6089d2110571950b8c9
[]
no_license
taicent/mytesgnikrow
09aed8836e1297a24bef0f18dadd9e9a78ec8e8b
9264faa662454484ade7137ee8a0794e00bf762f
refs/heads/master
2020-04-06T04:25:30.075548
2011-02-17T13:37:16
2011-02-17T13:37:16
34,991,750
0
0
null
null
null
null
UTF-8
C++
false
false
4,544
cpp
/*************************************************************************** classColourClassifier.cpp Used to classify the type and distribution of colours. This is used for classifying people's clothing Comments are included in machine readable XML format, for possible future production of program documentation begin : Thu Feb 19 2004 copyright : (C) 2004 by Bob Mottram email : [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. * * * ***************************************************************************/ #include "stdafx.h" /// <summary> /// Constructor /// </summary> classColourClassifier::classColourClassifier() { clear(); } /// <summary> /// Destructor /// </summary> classColourClassifier::~classColourClassifier() { } /// <summary> /// Clear all data /// </summary> void classColourClassifier::clear() { NoOfGroups=0; top_x = 99999; top_y = 99999; bottom_x = 0; bottom_y = 0; tollerance=50; total_pixels=0; sorted=false; } /// <summary> /// Sort the colours based upon the number of hits /// </summary> void classColourClassifier::sort() { int i,j,max,winner,temp[5]; for (i=0;i<NoOfGroups-1;i++) { max=0; winner=-1; for (j=i;j<NoOfGroups;j++) { if (colour_group[i][3] > max) { max = colour_group[i][3]; winner=j; } } if (winner>-1) { //swap for (j=0;j<5;j++) { temp[j] = colour_group[i][j]; colour_group[i][j] = colour_group[winner][j]; colour_group[winner][j] = temp[j]; } } } sorted=true; } /// <summary> /// Update /// </summary> /// <param name="r">red component of the detected colour</param> /// <param name="g">green component of the detected colour</param> /// <param name="b">blue component of the detected colour</param> /// <param name="x">x coordinate of the detected colour blob</param> /// <param name="y">y coordinate of the detected colour blob</param> void classColourClassifier::update(int r, int g, int b, int x, int y) { int i,dist,r2,g2,b2; bool found; long hits; if (x<top_x) top_x = x; if (y<top_y) top_y = y; if (x>bottom_x) bottom_x = x; if (y>bottom_y) bottom_y = y; i=0; found=false; while ((i<NoOfGroups) && (!found)) { hits = colour_group[i][3]; r2 = colour_group[i][0] / hits; g2 = colour_group[i][1] / hits; b2 = colour_group[i][2] / hits; dist = abs(r2 - r) + abs(g2 - g) + abs(b2 - b); if (dist<tollerance) { colour_group[i][0] += r; colour_group[i][1] += g; colour_group[i][2] += b; colour_group[i][3]++; total_pixels++; found=true; } i++; } if ((!found) && (NoOfGroups<100)) { colour_group[NoOfGroups][0] = r; colour_group[NoOfGroups][1] = g; colour_group[NoOfGroups][2] = b; colour_group[NoOfGroups][3] = 1; NoOfGroups++; } } /// <summary> /// Returns the data for a colour group, and its coverage in the range 0-100 /// </summary> /// <param name="index">An index number for the colour group</param> /// <param name="r">Returned red component of the colour group</param> /// <param name="g">Returned green component of the colour group</param> /// <param name="b">Returned blue component of the colour group</param> /// <param name="coverage">The size of the blob compared to the image, in the range 0-100</param> void classColourClassifier::getGroupColour(int index, int &r, int &g, int &b, int &coverage) { long hits; if (index<NoOfGroups) { //sort the groups if they are not already sorted if (!sorted) sort(); hits = colour_group[index][3]; r = colour_group[index][0] / hits; g = colour_group[index][1] / hits; b = colour_group[index][2] / hits; coverage = (hits * 100) / total_pixels; } }
[ "hotga2801@ecd9aaca-b8df-3bf4-dfa7-576663c5f076" ]
[ [ [ 1, 176 ] ] ]
b5af0c624f459b267fc7708fd6af2409470fae0a
967868cbef4914f2bade9ef8f6c300eb5d14bc57
/Virtual/VirtualMemory.cpp
5ea3ffb51eb404564fa150cc03bd6edb1baba532
[]
no_license
saminigod/baseclasses-001
159c80d40f69954797f1c695682074b469027ac6
381c27f72583e0401e59eb19260c70ee68f9a64c
refs/heads/master
2023-04-29T13:34:02.754963
2009-10-29T11:22:46
2009-10-29T11:22:46
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
11,971
cpp
/* © Vestris Inc., Geneva Switzerland http://www.vestris.com, 1998, All Rights Reserved __________________________________________________ Virtual Memory Implementation (aka Malloc) written by Daniel Doubrovkine - [email protected] */ #include <baseclasses.hpp> #include "VirtualMemory.hpp" #define VM_DEFAULT_PAGESIZE (64 * MBYTE) CVirtualMemory * CVirtualMemory :: m_pSwap = NULL; CVirtualMemory :: CVirtualMemory(void) : m_bEnabled(vsDisabled), m_pVirtualMemory(NULL), m_pCacheNextPage(NULL) { m_PageSize = GetPageSize(); memset(& m_AccountingInfo, 0, sizeof(VMAccounting)); } CVirtualMemory :: ~CVirtualMemory(void) { Dispose(); } bool CVirtualMemory :: FreePages(void) { if (m_bEnabled == vsTerminating) return true; bool bResult = true; m_VMMutex.StartWriting(); VMPage * pCurrentPage = m_pVirtualMemory; while (pCurrentPage) { VMPage * pNextPage = pCurrentPage->m_pNext; if (! FreePage(pCurrentPage)) bResult = false; pCurrentPage = pNextPage; } m_pVirtualMemory = NULL; // reset the accounting information memset(& m_AccountingInfo, 0, sizeof(VMAccounting)); m_VMMutex.StopWriting(); return true; } // // pages are allocated in reverse linked list for straightforward deletion // bool CVirtualMemory :: AllocatePage(size_t PageSize, VMPage ** pPage) { assert(pPage); assert(* pPage == NULL); if (PageSize < VM_DEFAULT_PAGESIZE) PageSize = VM_DEFAULT_PAGESIZE; // allocate a block of page size if (! AllocateMemory(PageSize, (void **) pPage)) return false; // pointer to next page (* pPage)->m_pNext = NULL; new(& (* pPage)->m_Mutex) CRWMutex; VMBlock * pBlock = (* pPage)->GetFirstBlock(); pBlock->m_fUsed = false; pBlock->m_fLast = true; pBlock->m_pPage = (* pPage); // size of memory remaining in page is the entire new block pBlock->m_nSize = PageSize - sizeof(VMPage) - sizeof(VMBlock); // update accounting information m_AccountingInfo.stTotal += pBlock->m_nSize; // memory actually used m_AccountingInfo.stVirtual += PageSize; // memory actually used m_AccountingInfo.nBlockCount++; (* pPage)->m_nMaxBlock = pBlock->m_nSize; (* pPage)->m_pCacheNextBlock = pBlock; #ifdef _DEBUG (* pPage)->m_pLowerBound = (size_t) (* pPage) + PageSize; assert((size_t) pBlock + sizeof(VMBlock) + pBlock->m_nSize == (* pPage)->m_pLowerBound); #endif return true; } void CVirtualMemory :: Dump(void) { m_VMMutex.StartReading(); VMPage * pPage = m_pVirtualMemory; while (pPage) { // ----------------- pPage->m_Mutex.StartReading(); cout << "page at " << (long) pPage << endl; VMBlock * pBlock = pPage->GetFirstBlock(); while (pBlock) { cout << "block at " << (long) pBlock; cout << " of " << pBlock->m_nSize << " bytes"; cout << ((pBlock->m_fUsed) ? ", used" : ", free"); cout << endl; pBlock = pBlock->GetNextBlock(); } pPage->m_Mutex.StopReading(); // ----------------- pPage = pPage->m_pNext; } m_VMMutex.StopReading(); } bool CVirtualMemory :: AllocateBlock(VMPage * pPage, size_t Size, VMBlock ** pBlock) { assert(pPage); assert(pBlock); bool bResult = false; // // this will miss when the block of the max size gets allocated // if (pPage->m_nMaxBlock >= Size) { pPage->m_Mutex.StartWriting(); if (pPage->m_nMaxBlock >= Size) { * pBlock = (pPage->m_pCacheNextBlock ? pPage->m_pCacheNextBlock : pPage->GetFirstBlock()); while (* pBlock) { // the adequate block must have space for the memory and a new descriptor if (! (* pBlock)->m_fUsed && (* pBlock)->m_nSize >= Size + sizeof(VMBlock)) { size_t BlockSize = (* pBlock)->m_nSize; bool fLastBlock = (* pBlock)->m_fLast; (* pBlock)->m_fUsed = true; (* pBlock)->m_nSize = Size; (* pBlock)->m_fLast = false; VMBlock * pNextBlock = (* pBlock)->GetNextBlock(); // next block gets a new descriptor pNextBlock->m_fUsed = false; pNextBlock->m_nSize = BlockSize - Size - sizeof(_VMBlock); pNextBlock->m_fLast = fLastBlock; pNextBlock->m_pPage = (* pBlock)->m_pPage; #ifdef _DEBUG // check that still within page bounds assert((size_t) pNextBlock < (* pBlock)->m_pPage->m_pLowerBound); // last block aligned with lower page boundary if (pNextBlock->m_fLast) { assert((size_t) pNextBlock + sizeof(VMBlock) + pNextBlock->m_nSize == (* pBlock)->m_pPage->m_pLowerBound); } #endif // reset the cache if (pPage->m_nMaxBlock == BlockSize) { pPage->m_nMaxBlock = pNextBlock->m_nSize; } pPage->m_pCacheNextBlock = pNextBlock; m_pCacheNextPage = pPage; // update accounting information m_AccountingInfo.stUsed += Size; // memory actually used m_AccountingInfo.stTotal -= sizeof(VMBlock); // total virtual memory available m_AccountingInfo.nBlockCount++; // current block was split bResult = true; break; } (* pBlock) = (* pBlock)->GetNextBlock(); } } pPage->m_Mutex.StopWriting(); } return bResult; } bool CVirtualMemory :: AllocateBlock(size_t Size, VMBlock ** pBlock) { assert(pBlock); assert(* pBlock == NULL); bool bResult = false; m_VMMutex.StartReading(); bResult = AllocateExistingBlock(Size, pBlock); m_VMMutex.StopReading(); if (bResult) return true; // create a new page, avoid creating many pages from many threads, hence this is locked size_t NewPageSize = GetBlockSize(Size); VMPage * pPage = NULL; // cout << (long) GetCurrentThreadId() << "Failed to allocate a block of " << (long) Size << " bytes." << endl; m_VMMutex.StartWriting(); m_pCacheNextPage = NULL; // cout << (long) GetCurrentThreadId() << "Attempting to lock-allocate a block of " << (long) Size << " bytes." << endl; bResult = AllocateExistingBlock(Size, pBlock); // cout << (long) GetCurrentThreadId() << "Allocation result is " << (bResult ? "true" : "false") << endl; if (! bResult) { // cout << (long) GetCurrentThreadId() << "Allocating page of " << NewPageSize << " bytes." << endl; if (AllocatePage(NewPageSize, & pPage)) { // allocate a block on the new page pPage->m_pNext = m_pVirtualMemory; m_pVirtualMemory = pPage; m_pCacheNextPage = pPage; bResult = AllocateBlock(pPage, Size, pBlock); if (! bResult) { cerr << "VirtualMemory: AllocateBlock failed for " << Size << " bytes on a new page." << endl; assert(bResult); exit(-1); } } } m_VMMutex.StopWriting(); return bResult; } void CVirtualMemory :: Free(void * pMem) { if (m_bEnabled == vsTerminating) return; if (m_bEnabled != vsEnabled) { free(pMem); return; } VMBlock * pBlock = GetBlock(pMem); VMPage * pPage = pBlock->m_pPage; assert(pBlock->m_fUsed); pPage->m_Mutex.StartWriting(); // update accounting information m_AccountingInfo.stUsed -= pBlock->m_nSize; // memory actually used pBlock->m_fUsed = false; if (pPage->m_nMaxBlock < pBlock->m_nSize) { pPage->m_nMaxBlock = pBlock->m_nSize; } // always reset, otherwise after merge the block may not exist pPage->m_pCacheNextBlock = pBlock; m_pCacheNextPage = pPage; VMBlock * pNextBlock = NULL; while (! pBlock->m_fLast && ! (pNextBlock = pBlock->GetNextBlock())->m_fUsed) { // can link with next block pBlock->m_nSize += sizeof(_VMBlock); pBlock->m_nSize += pNextBlock->m_nSize; pBlock->m_fLast = pNextBlock->m_fLast; // update accounting information m_AccountingInfo.stTotal += sizeof(VMBlock); // total virtual memory available m_AccountingInfo.nBlockCount--; // current block was split } #ifdef _DEBUG // check that still within page bounds assert((size_t) pBlock < pBlock->m_pPage->m_pLowerBound); // last block aligned with lower page boundary if (pBlock->m_fLast) { assert((size_t) pBlock + sizeof(VMBlock) + pBlock->m_nSize == pBlock->m_pPage->m_pLowerBound); } #endif pPage->m_Mutex.StopWriting(); } bool CVirtualMemory :: FindPage(VMBlock * pBlock, VMPage ** pPage) { assert(pPage); assert(* pPage == NULL); assert(m_pVirtualMemory); m_VMMutex.StartReading(); VMPage * pCurrentPage = m_pVirtualMemory; while (pCurrentPage) { if (((size_t) pBlock > (size_t) pCurrentPage) && ((size_t) pBlock - (size_t)pCurrentPage < (size_t) pBlock - (size_t) (* pPage))) { * pPage = pCurrentPage; } pCurrentPage = pCurrentPage->m_pNext; } m_VMMutex.StopReading(); assert(* pPage); return true; } // void CVirtualMemory :: GetAccountingInfo(VMPage * pPage, VMAccounting * pAccountingInfo) const { // pAccountingInfo->stVirtual += sizeof(VMPage); // pPage->m_Mutex.StartReading(); // VMBlock * pBlock = pPage->GetFirstBlock(); // bool bFreeBusy = false; // while (pBlock) { // if ((pBlock->m_fUsed != bFreeBusy) || (! pBlock->m_fUsed && ! bFreeBusy)) // pAccountingInfo->nFragCount++; // bFreeBusy = pBlock->m_fUsed; // pAccountingInfo->nBlockCount++; // pAccountingInfo->stTotal += pBlock->m_nSize; // pAccountingInfo->stVirtual += pBlock->m_nSize; // pAccountingInfo->stVirtual += sizeof(VMBlock); // pAccountingInfo->stUsed += ((pBlock->m_fUsed) ? pBlock->m_nSize : 0); // pBlock = pBlock->GetNextBlock(); // } // pPage->m_Mutex.StopReading(); // } void CVirtualMemory :: GetAccountingInfo(VMAccounting * pAccountingInfo) const { assert(pAccountingInfo); m_VMMutex.StartReading(); memcpy(pAccountingInfo, & m_AccountingInfo, sizeof(VMAccounting)); m_VMMutex.StopReading(); // memset(pAccountingInfo, 0, sizeof(VMAccounting)); // m_VMMutex.StartReading(); // VMPage * pCurrentPage = m_pVirtualMemory; // while (pCurrentPage) { // GetAccountingInfo(pCurrentPage, pAccountingInfo); // pCurrentPage = pCurrentPage->m_pNext; // } // m_VMMutex.StopReading(); }
[ [ [ 1, 413 ] ] ]
f7d6007f585bc977ac2c68867cd923d9e2d3d3bf
d2996420f8c3a6bbeef63a311dd6adc4acc40436
/src/net/UdpClient.cpp
8114e17328a1de48cf0ebcbae07f172add0d1273
[]
no_license
aruwen/graviator
4d2e06e475492102fbf5d65754be33af641c0d6c
9a881db9bb0f0de2e38591478429626ab8030e1d
refs/heads/master
2021-01-19T00:13:10.843905
2011-03-13T13:15:25
2011-03-13T13:15:25
32,136,578
0
0
null
null
null
null
UTF-8
C++
false
false
3,755
cpp
#include "UdpClient.h" using namespace net; UdpClient::UdpClient() : mConnection(&mSocket) { mIsRunning = false; mIsSearchingForServer = false; mSearchingTimeout = 10.0f; mSearchingInterval = 1.0f; mConnection.setAutoReconnect(10); } UdpClient::~UdpClient() { stop(); } bool UdpClient::start(unsigned short port) { if (mIsRunning) return false; if ( !mSocket.open(port) ) return false; mIsRunning = true; return true; } bool UdpClient::isRunning() { return mIsRunning; } void UdpClient::connect( const Address &address) { if (mIsRunning) { mConnection.connect(address); } } void UdpClient::connectToFirstResponingServer() { if (!mIsRunning) return; mMulticastSender.open( Address(225,1,1,1,1337) ); string portString = toString(mSocket.getPort()); mMulticastSender.send(portString.c_str(), portString.size()); mIsSearchingForServer = true; mSearchingTimeoutTimer.start(); mSearchingIntervalTimer.start(); } bool UdpClient::isConnected() { return mConnection.isReady(); } bool UdpClient::hasConnectFailed() { return mConnection.hasConnectFailed(); } bool UdpClient::isDisconnected() { return mConnection.isDisconnected(); } void UdpClient::disconnect() { mConnection.disconnect(); } void UdpClient::stop() { if (mIsRunning) { mConnection.disconnect(); mSocket.close(); mIsRunning = false; mIsSearchingForServer = false; } } unsigned int UdpClient::getId() { return mConnection.getId(); } bool UdpClient::send(string data) { if (!mIsRunning) return false; if (!mConnection.isReady()) return false; return mConnection.sendData(data); } void UdpClient::update() { processReadReady(); mConnection.update(); if (mIsSearchingForServer && mSearchingTimeoutTimer.getTime() > mSearchingTimeout) { mIsSearchingForServer = false; mSearchingIntervalTimer.reset(); mSearchingTimeoutTimer.reset(); } else if (mIsSearchingForServer && mSearchingIntervalTimer.getTime() > mSearchingInterval) { mSearchingIntervalTimer.restart(); string portString = toString(mSocket.getPort()); mMulticastSender.send(portString.c_str(), portString.size()); } } string UdpClient::getData() { string tempString; if (mConnection.isReady()) tempString = mConnection.getData(); return tempString; } queue<string> UdpClient::getDataQueue() { queue<string> tempQueue; if (mConnection.isReady()) tempQueue = mConnection.getDataQueue(); return tempQueue; } void UdpClient::processReadReady() { int receivedBytes = 0; Address sender; char data[1024]; string dataString = data; int size = 1024; memset(data, 0, 1024); receivedBytes = mSocket.receive(sender, data, size); while (receivedBytes > 0) { dataString = data; if (mIsSearchingForServer) { // TODO: handle more information from server if (dataString == "I_AM_A_SERVER") { mIsSearchingForServer = false; connect(sender); return; } } else if (sender == mConnection.getAddress()) { mConnection.handleIncomming(dataString); } memset(data, 0, 1024); receivedBytes = mSocket.receive(sender, data, size); } }
[ "[email protected]@c8d5bfcc-1391-a108-90e5-e810ef6ef867" ]
[ [ [ 1, 181 ] ] ]
2f46f9671e980a9996ce3b0c9a5c5d2c0c374398
e743f7cb85ebc6710784a39e2941e277bd359508
/directmidi/C3DListener.cpp
9ea2a9830911590de82518d007685ddce20383fa
[]
no_license
aidinabedi/directmidi4unity
8c982802de97855fcdaab36709c6b1c8eb0b2e52
8c3e33e7b44c3fe248e0718e4b8f9e2260d9cd8f
refs/heads/master
2021-01-20T15:30:16.131068
2009-12-03T08:37:36
2009-12-03T08:37:36
90,773,445
1
0
null
null
null
null
WINDOWS-1250
C++
false
false
9,222
cpp
/* ____ _ ____ _____ _____ ______ __ __ _ ____ _ | _ \ | || _ \| __// __//_ _/ | \/ || || _ \ | | | |_| || || |> /| _| | <__ | | | |\/| || || |_| || | |____/ |_||_|\_\|____\\____/ |_| |_| |_||_||____/ |_| //////////////////////////////////////////////////////////////////////// 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. This library 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 this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Copyright (c) 2002-2004 by Carlos Jiménez de Parga All rights reserved. For any suggestion or failure report, please contact me by: e-mail: [email protected] Note: I would appreciate very much if you could provide a brief description of your project, as well as any report on bugs or errors. This will help me improve the code for the benefit of your application and the other users /////////////////////////////////////////////////////////////////////// Version: 2.3b Module : C3DListener.cpp Purpose: Code implementation for C3DListener class Created: CJP / 02-08-2002 History: CJP / 20-02-2004 Date format: Day-month-year Update: 20/09/2002 1. Improved class destructors 2. Check member variables for NULL values before performing an operation 3. Restructured the class system 4. Better method to enumerate and select MIDI ports 5. Adapted the external thread to a pure virtual function 6. SysEx reception and sending enabled 7. Added flexible conversion functions 8. Find out how to activate the Microsoft software synth. 9. Added DLS support Update: 25/03/2003 10. Added exception handling 11. Fixed bugs with channel groups 12. Redesigned class hierarchy 13. DirectMidi wrapped in the directmidi namespace 14. UNICODE/MBCS support for instruments and ports 15. Added DELAY effect to software synthesizer ports 16. Project released under GNU (General Public License) terms Update: 03/10/2003 17. Redesigned class interfaces 18. Safer input port termination thread 19. New CMasterClock class 20. DLS files can be loaded from resources 21. DLS instruments note range support 22. New CSampleInstrument class added to the library 23. Direct download of samples to wave-table memory 24. .WAV file sample format supported 25. New methods added to the output port class 26. Fixed small bugs Update: 20/02/2004 27. Added new DirectMusic classes for Audio handling 28. Improved CMidiPort class with internal buffer run-time resizing 29. 3D audio positioning */ #include "CAudioPart.h" using namespace directmidi; // Constructor C3DListener::C3DListener() { m_pListener = NULL; } // Destructor C3DListener::~C3DListener() { ReleaseListener(); } // Commits any deferred settings made since the last call to this method HRESULT C3DListener::CommitDeferredSettings() { TCHAR strMembrFunc[] = _T("C3DListener::CommitDeferredSettings()"); DM_ASSERT(strMembrFunc,__LINE__,m_pListener==NULL); DM_ASSERT_HR(strMembrFunc,__LINE__,m_pListener->CommitDeferredSettings()); return S_OK; } // Retrieves all 3-D parameters of the sound environment and the listener HRESULT C3DListener::GetAllListenerParameters(LPDS3DLISTENER pListener) { TCHAR strMembrFunc[] = _T("C3DListener::GetAllListenerParameters()"); DM_ASSERT(strMembrFunc,__LINE__,m_pListener==NULL,pListener==NULL); DM_ASSERT_HR(strMembrFunc,__LINE__,m_pListener->GetAllParameters(pListener)); return S_OK; } // Sets all 3-D parameters of the sound environment and the listener HRESULT C3DListener::SetAllListenerParameters(LPCDS3DLISTENER pcListener,DWORD dwApply) { TCHAR strMembrFunc[] = _T("C3DListener::SetAllListenerParameters()"); DM_ASSERT(strMembrFunc,__LINE__,m_pListener==NULL,pcListener==NULL); DM_ASSERT_HR(strMembrFunc,__LINE__,m_pListener->SetAllParameters(pcListener,dwApply)); return S_OK; } // Retrieves the distance factor, which is the number of meters in a vector unit HRESULT C3DListener::GetDistanceFactor(D3DVALUE *pflDistanceFactor) { TCHAR strMembrFunc[] = _T("C3DListener::GetDistanceFactor()"); DM_ASSERT(strMembrFunc,__LINE__,m_pListener==NULL,pflDistanceFactor==NULL); DM_ASSERT_HR(strMembrFunc,__LINE__,m_pListener->GetDistanceFactor(pflDistanceFactor)); return S_OK; } // Retrieves the multiplier for the Doppler effect HRESULT C3DListener::GetDopplerFactor(D3DVALUE *pflDopplerFactor) { TCHAR strMembrFunc[] = _T("C3DListener::GetDopplerFactor()"); DM_ASSERT(strMembrFunc,__LINE__,m_pListener==NULL,pflDopplerFactor==NULL); DM_ASSERT_HR(strMembrFunc,__LINE__,m_pListener->GetDopplerFactor(pflDopplerFactor)); return S_OK; } // Retrieves the rolloff factor, which determines the rate of attenuation over distance HRESULT C3DListener::GetRolloffFactor(D3DVALUE *pflRolloffFactor) { TCHAR strMembrFunc[] = _T("C3DListener::GetRolloffFactor()"); DM_ASSERT(strMembrFunc,__LINE__,m_pListener==NULL,pflRolloffFactor==NULL); DM_ASSERT_HR(strMembrFunc,__LINE__,m_pListener->GetRolloffFactor(pflRolloffFactor)); return S_OK; } // Sets the distance factor HRESULT C3DListener::SetDistanceFactor(D3DVALUE flDistanceFactor,DWORD dwApply) { TCHAR strMembrFunc[] = _T("C3DListener::SetDistanceFactor()"); DM_ASSERT(strMembrFunc,__LINE__,m_pListener==NULL); DM_ASSERT_HR(strMembrFunc,__LINE__,m_pListener->SetDistanceFactor(flDistanceFactor,dwApply)); return S_OK; } // Sets the multiplier for the Doppler effect HRESULT C3DListener::SetDopplerFactor(D3DVALUE flDopplerFactor,DWORD dwApply) { TCHAR strMembrFunc[] = _T("C3DListener:SetDopplerFactor()"); DM_ASSERT(strMembrFunc,__LINE__,m_pListener==NULL); DM_ASSERT_HR(strMembrFunc,__LINE__,m_pListener->SetDopplerFactor(flDopplerFactor,dwApply)); return S_OK; } // Sets the rolloff factor HRESULT C3DListener::SetRolloffFactor(D3DVALUE flRolloffFactor,DWORD dwApply) { TCHAR strMembrFunc[] = _T("C3DListener::SetRolloffFactor()"); DM_ASSERT(strMembrFunc,__LINE__,m_pListener==NULL); DM_ASSERT_HR(strMembrFunc,__LINE__,m_pListener->SetRolloffFactor(flRolloffFactor,dwApply)); return S_OK; } // Retrieves the orientation of the listener's head HRESULT C3DListener::GetOrientation(D3DVECTOR *pvOrientFront,D3DVECTOR *pvOrientTop) { TCHAR strMembrFunc[] = _T("C3DListener::GetOrientation()"); DM_ASSERT(strMembrFunc,__LINE__,m_pListener==NULL,pvOrientFront==NULL,pvOrientTop==NULL); DM_ASSERT_HR(strMembrFunc,__LINE__,m_pListener->GetOrientation(pvOrientFront,pvOrientTop)); return S_OK; } // Retrieves the listener's position HRESULT C3DListener::GetListenerPosition(D3DVECTOR *pvPosition) { TCHAR strMembrFunc[] = _T("C3DListener::GetListenerPosition()"); DM_ASSERT(strMembrFunc,__LINE__,m_pListener==NULL,pvPosition==NULL); DM_ASSERT_HR(strMembrFunc,__LINE__,m_pListener->GetPosition(pvPosition)); return S_OK; } // Retrieves the listener's velocity HRESULT C3DListener::GetVelocity(D3DVECTOR *pvVelocity) { TCHAR strMembrFunc[] = _T("C3DListener::GetVelocity()"); DM_ASSERT(strMembrFunc,__LINE__,m_pListener==NULL,pvVelocity==NULL); DM_ASSERT_HR(strMembrFunc,__LINE__,m_pListener->GetVelocity(pvVelocity)); return S_OK; } // Sets the orientation of the listener's head HRESULT C3DListener::SetOrientation(D3DVALUE xFront,D3DVALUE yFront,D3DVALUE zFront,D3DVALUE xTop, D3DVALUE yTop,D3DVALUE zTop,DWORD dwApply) { TCHAR strMembrFunc[] = _T("C3DListener::SetOrientation()"); DM_ASSERT(strMembrFunc,__LINE__,m_pListener==NULL); DM_ASSERT_HR(strMembrFunc,__LINE__,m_pListener->SetOrientation(xFront,yFront,zFront,xTop,yTop,zTop,dwApply)); return S_OK; } // Sets the listener's position HRESULT C3DListener::SetListenerPosition(D3DVALUE x,D3DVALUE y,D3DVALUE z,DWORD dwApply) { TCHAR strMembrFunc[] = _T("C3DListener::SetListenerPosition()"); DM_ASSERT(strMembrFunc,__LINE__,m_pListener==NULL); DM_ASSERT_HR(strMembrFunc,__LINE__,m_pListener->SetPosition(x,y,z,dwApply)); return S_OK; } // Sets the listener's velocity HRESULT C3DListener::SetVelocity(D3DVALUE x,D3DVALUE y,D3DVALUE z,DWORD dwApply) { TCHAR strMembrFunc[] = _T("C3DListener::SetVelocity()"); DM_ASSERT(strMembrFunc,__LINE__,m_pListener==NULL); DM_ASSERT_HR(strMembrFunc,__LINE__,m_pListener->SetVelocity(x,y,z,dwApply)); return S_OK; } // Releases the listener object HRESULT C3DListener::ReleaseListener() { if (m_pListener) { SAFE_RELEASE(m_pListener); return S_OK; } else return S_FALSE; }
[ [ [ 1, 288 ] ] ]
3814438021976b7ee3026c739cabc98f25c45dab
c1b7571589975476405feab2e8b72cdd2a592f8f
/chopshop10/RobotCamera166.cpp
ec453885f024609fa1ffd5fb97a8dc4ea6bea095
[]
no_license
chopshop-166/frc-2010
ea9cd83f85c9eb86cc44156f21894410a9a4b0b5
e15ceff05536768c29fad54fdefe65dba9a5fab5
refs/heads/master
2021-01-21T11:40:07.493930
2010-12-10T02:04:05
2010-12-10T02:04:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,735
cpp
/******************************************************************************* * Project : chopshop10 - 2010 Chopshop Robot Controller Code * File Name : RobotCamera166.cpp * Owner : Software Group (FIRST Chopshop Team 166) * Creation Date : January 18, 2010 * Revision History : From Explorer with TortoiseSVN, Use "Show log" menu item * File Description : Calls to get camera information *******************************************************************************/ /*----------------------------------------------------------------------------*/ /* Copyright (c) MHS Chopshop Team 166, 2010. All Rights Reserved. */ /*----------------------------------------------------------------------------*/ #include "WPILib.h" #include "BaeUtilities.h" #include "RobotCamera166.h" #include "Proxy166.h" // needed for Camera Init #include "AxisCamera.h" #include "AxisCameraParams.h" #include "FrcError.h" #include "PCVideoServer.h" #include "nivision.h" #include "Vision166.h" // To locally enable debug printing: set true, to disable false #define DPRINTF if(false)dprintf //! Used to fetch the target X and Y positions. // Create storage space for camera AxisCamera *camera166 = 0; // Camera setup parameters go here // Image size (larger images take longer to process) AxisCameraParams::Resolution_t resolution = AxisCameraParams::kResolution_160x120; // k640x480, k640x360, k320x240, k160x120 // Use rotation of 180 if camera is mounted updside down AxisCameraParams::Rotation_t rotation = AxisCameraParams::kRotation_0; // k0, k180 /** * start the CameraTask **/ void StartCamera() { /* read a configuration file and send it to the camera */ char *imageName = "166StartPic.png"; //camera166 = AxisCamera::getInstance(); camera166 = &AxisCamera::GetInstance(); if ( 0 == camera166) { DPRINTF( LOG_DEBUG,"Failed to spawn camera task; exiting. Error code %s", GetVisionErrorText(GetLastVisionError()) ); } else { SetupCamera(resolution, rotation); TakeSnapshot(imageName); } } /** * Get an image from camera and store it on the cRIO * @param imageName stored on home directory of cRIO ( "/" ) **/ void TakeSnapshot(char* imageName) { /* allow writing to vxWorks target */ //Priv_SetWriteFileAllowed(1); DPRINTF(LOG_DEBUG, "taking a SNAPSHOT "); Image* cameraImage = frcCreateImage(IMAQ_IMAGE_HSL); if (!cameraImage) { DPRINTF (LOG_INFO,"frcCreateImage failed - errorcode %i",GetLastVisionError()); } if ( !camera166->GetImage(cameraImage) ) { DPRINTF (LOG_INFO,"\nImage Acquisition from camera failed %i", GetLastVisionError()); } else { DPRINTF (LOG_DEBUG, "calling frcWriteImage for %s", imageName); if (!frcWriteImage(cameraImage, imageName) ) { int errCode = GetLastVisionError(); DPRINTF (LOG_INFO,"frcWriteImage failed - errorcode %i", errCode); char *errString = GetVisionErrorText(errCode); DPRINTF (LOG_INFO,"errString= %s", errString); } else { DPRINTF (LOG_INFO,"\n>>>>> Saved image to %s", imageName); // always dispose of image objects when done frcDispose(cameraImage); } } } /** * Pass to the camera the configuration settings and store an image on the cRIO * @param ResolutionT camera resolution * @param RotationT camera rotation (k0, k180) **/ void SetupCamera(AxisCameraParams::Resolution_t res, AxisCameraParams::Rotation_t rot) { camera166->WriteResolution(res); camera166->WriteRotation(rot); } /** * Sets Joystick X and Y values to drive towards the target during Operater mode. * This function will do nothing if the camera is inactive (Team166VisionObject.IsActive() is false) * This function assumes Tank drive. * This function will force the calling thread to wait until the Proxy is initialized. */ void DriveTowardsTarget() { /** * Power to the left side is proportional to how far to the right the target is. * Power to the right side is proportional to how far to the left the target is. */ Proxy166 *pHandle = NULL; // Wait until the Proxy is initialized while(0 == pHandle) { pHandle = Proxy166::getInstance(); Wait(0.05); } if(pHandle->GetVisionStatus()) { float bearing = pHandle->GetCameraScoreToTargetX(); float distance_left = fabs(1.0 - bearing) / 2.0; // How far to the left the target is float distance_right = fabs(-1.0 - bearing) / 2.0; // How far to the right the target is pHandle->SetJoystickY(DRIVE_JOYSTICK_LEFT, DRIVE_PROPORTIONAL_CONSTANT * distance_right); pHandle->SetJoystickY(DRIVE_JOYSTICK_RIGHT, DRIVE_PROPORTIONAL_CONSTANT * distance_left); } }
[ [ [ 1, 130 ] ] ]
a60acfefeca1bcd8e23a23de66ad0613728fe166
0b1a87e3aac9d80f719a34e5522796cdb061d64d
/win32util.h
7bf284c771be326c4e62e5b973b48354f0084868
[]
no_license
xiangruipuzhao/qaac
6769239471d920d42095a916c94ab0e706a76619
ed2a1392a3c6c9df2046bd559b6486965928af53
refs/heads/master
2021-01-21T01:39:23.237184
2011-02-05T14:01:10
2011-02-05T14:01:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,457
h
#ifndef _WIN32UTIL_H #define _WIN32UTIL_H #include <string> #include <vector> #ifndef NOMINMAX #define NOMINMAX #endif #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include <windows.h> #include <shlwapi.h> void throw_win32_error(const std::string& msg, DWORD error); class ProcAddress { FARPROC fp_; public: ProcAddress(HMODULE module, LPCSTR name) { fp_ = GetProcAddress(module, name); } template <typename T> operator T() const { return reinterpret_cast<T>(fp_); } }; inline std::wstring GetFullPathNameX(const std::wstring &path) { DWORD length = GetFullPathNameW(path.c_str(), 0, 0, 0); std::vector<wchar_t> buffer(length); length = GetFullPathNameW(path.c_str(), buffer.size(), &buffer[0], 0); return std::wstring(&buffer[0], &buffer[length]); } inline std::wstring PathReplaceExtension(const std::wstring &path, const wchar_t *ext) { std::wstring s(path.c_str(), PathFindExtensionW(path.c_str())); if (ext[0] != L'.') s.push_back(L'.'); s += ext; return s; } inline std::wstring PathFindFileNameX(const std::wstring &path) { return PathFindFileNameW(path.c_str()); } inline std::wstring PathCombineX(const std::wstring &basedir, const std::wstring &filename) { wchar_t buffer[MAX_PATH]; PathCombineW(buffer, basedir.c_str(), filename.c_str()); return buffer; } inline std::wstring GetCurrentDirectoryX() { DWORD len = GetCurrentDirectoryW(0, 0); std::vector<wchar_t> buffer(len + 1); len = GetCurrentDirectoryW(buffer.size(), &buffer[0]); return std::wstring(&buffer[0], &buffer[len]); } inline std::wstring GetModuleFileNameX() { std::vector<wchar_t> buffer(32); DWORD cclen = GetModuleFileNameW(0, &buffer[0], buffer.size()); while (cclen >= buffer.size() - 1) { buffer.resize(buffer.size() * 2); cclen = GetModuleFileNameW(0, &buffer[0], buffer.size()); } return std::wstring(&buffer[0], &buffer[cclen]); } inline std::wstring GetTempPathX() { DWORD len = GetTempPathW(0, 0); std::vector<wchar_t> buffer(len + 1); len = GetTempPathW(buffer.size(), &buffer[0]); return std::wstring(&buffer[0], &buffer[len]); } class DirectorySaver { std::wstring m_pwd; public: DirectorySaver() { m_pwd = GetCurrentDirectoryX(); } ~DirectorySaver() { SetCurrentDirectoryW(m_pwd.c_str()); } }; #endif
[ [ [ 1, 98 ] ] ]
5578f1f21f441e08cefc601870c6d4c70180bc7e
1de7bc93ba6d2e2000683eaf97277b35679ab873
/CryptoPP/cryptopp.h
8648d7ba3176dca0786d7c6e88dd273a7b63f150
[]
no_license
mohamadpk/secureimplugin
b184642095e24b623b618d02cc7c946fc9bed6bf
6ebfa5477b1aa8baaccea3f86f402f6d7f808de1
refs/heads/master
2021-03-12T23:50:12.141449
2010-04-28T06:54:37
2010-04-28T06:54:37
37,033,105
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
8,246
h
#ifndef __CRYPTOPP_H__ #define __CRYPTOPP_H__ #include <queue> #include <deque> #include <list> #include <map> //#pragma warning(push) // 4231: nonstandard extension used : 'extern' before template explicit instantiation // 4250: dominance // 4251: member needs to have dll-interface // 4275: base needs to have dll-interface // 4660: explicitly instantiating a class that's already implicitly instantiated // 4661: no suitable definition provided for explicit template instantiation request // 4700: unused variable names... // 4706: long names... // 4786: identifer was truncated in debug information // 4355: 'this' : used in base member initializer list #pragma warning(disable: 4231 4250 4251 4275 4660 4661 4700 4706 4786 4355) #define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 #include "crypto/modes.h" #include "crypto/osrng.h" #include "crypto/rsa.h" #include "crypto/aes.h" #include "crypto/dh.h" #include "crypto/crc.h" #include "crypto/ripemd.h" #include "crypto/sha.h" #include "crypto/tiger.h" #include "crypto/gzip.h" #include "crypto/zlib.h" #include "crypto/files.h" //#pragma warning(pop) USING_NAMESPACE(CryptoPP); USING_NAMESPACE(std) #define KEYSIZE 256 #define DEFMSGS 4096 #define HEADER 0xABCD1234 #define FOOTER 0x9876FEDC #define EMPTYH 0xF1E2D3C4 typedef struct __CNTX { u_int header; // HEADER short mode; // mode of encoding short features; // features of client short error; // error code of last operation PBYTE pdata; // data block PVOID udata; // user data LPSTR tmp; // return string u_int deleted; // delete time&flag to delete u_int footer; // FOOTER } CNTX; typedef CNTX* pCNTX; #define FEATURES_UTF8 0x01 #define FEATURES_BASE64 0x02 #define FEATURES_GZIP 0x04 #define FEATURES_CRC32 0x08 #define FEATURES_PSK 0x10 #define FEATURES_NEWPG 0x20 #define FEATURES_RSA 0x40 #define MODE_BASE16 0x0000 #define MODE_BASE64 0x0001 #define MODE_PGP 0x0002 #define MODE_GPG 0x0004 #define MODE_GPG_ANSI 0x0008 #define MODE_PRIV_KEY 0x0010 #define MODE_RSA_2048 0x0020 #define MODE_RSA_4096 0x0040 #define MODE_RSA MODE_RSA_4096 #define MODE_RSA_ONLY 0x0080 #define MODE_RSA_ZLIB 0x0100 #define MODE_RSA_BER 0x0200 #define DATA_GZIP 1 typedef struct __SIMDATA { DH *dh; // diffie-hellman PBYTE PubA; // public keyA 2048 bit PBYTE KeyA; // private keyA 2048 bit PBYTE KeyB; // public keyB 2048 bit PBYTE KeyX; // secret keyX 192 bit PBYTE KeyP; // pre-shared keyP 192 bit } SIMDATA; typedef SIMDATA* pSIMDATA; typedef struct __PGPDATA { PBYTE pgpKeyID; // PGP KeyID PBYTE pgpKey; // PGP Key } PGPDATA; typedef PGPDATA* pPGPDATA; typedef struct __GPGDATA { BYTE *gpgKeyID; // GPG KeyID } GPGDATA; typedef GPGDATA* pGPGDATA; #define RSA_KEYSIZE SHA1::DIGESTSIZE #define RSA_CalculateDigest SHA1().CalculateDigest typedef struct __RSAPRIV { string priv_k; // private key string string priv_s; // hash(priv_k) RSA::PrivateKey priv; // private key string pub_k; // public key string string pub_s; // hash(pub_k) } RSAPRIV; typedef RSAPRIV* pRSAPRIV; typedef deque<string, allocator<string> > STRINGDEQUE; typedef queue<string,STRINGDEQUE> STRINGQUEUE; typedef struct __RSADATA { short state; // 0 - нифига нет, 1..6 - keyexchange, 7 - соединение установлено u_int time; // для прерывания keyexchange, если долго нет ответа string pub_k; // public key string string pub_s; // hash(pub_k) RSA::PublicKey pub; // public key string aes_k; // aes key string aes_v; // aes iv HANDLE thread; // thread handle BOOL thread_exit; HANDLE event; // thread event STRINGQUEUE *queue; // thread queue } RSADATA; typedef RSADATA* pRSADATA; #define ERROR_NONE 0 #define ERROR_SEH 1 #define ERROR_NO_KEYA 2 #define ERROR_NO_KEYB 3 #define ERROR_NO_KEYX 4 #define ERROR_BAD_LEN 5 #define ERROR_BAD_CRC 6 #define ERROR_NO_PSK 7 #define ERROR_BAD_PSK 8 #define ERROR_BAD_KEYB 9 #define ERROR_NO_PGP_KEY 10 #define ERROR_NO_PGP_PASS 11 #define ERROR_NO_GPG_KEY 12 #define ERROR_NO_GPG_PASS 13 #if defined(_DEBUG) #define FEATURES (FEATURES_UTF8 | FEATURES_BASE64 | FEATURES_GZIP | FEATURES_CRC32 | FEATURES_NEWPG) #else #define FEATURES (FEATURES_UTF8 | FEATURES_BASE64 | FEATURES_GZIP | FEATURES_CRC32 | FEATURES_NEWPG | FEATURES_RSA) #endif #define DLLEXPORT __declspec(dllexport) extern LPCSTR szModuleName; extern LPCSTR szVersionStr; extern HINSTANCE g_hInst; pCNTX get_context_on_id(int); pCNTX get_context_on_id(HANDLE); void cpp_free_keys(pCNTX); BYTE *cpp_gzip(BYTE*,int,int&); BYTE *cpp_gunzip(BYTE*,int,int&); string cpp_zlibc(string&); string cpp_zlibd(string&); typedef struct { int (__cdecl *rsa_gen_keypair)(short); // генерит RSA-ключи для указанной длины (либо тока 2048, либо 2048 и 4096) int (__cdecl *rsa_get_keypair)(short,PBYTE,int*,PBYTE,int*); // возвращает пару ключей для указанной длины int (__cdecl *rsa_get_keyhash)(short,PBYTE,int*,PBYTE,int*); // возвращает hash пары ключей для указанной длины int (__cdecl *rsa_set_keypair)(short,PBYTE,int); // устанавливает ключи, указанной длины int (__cdecl *rsa_get_pubkey)(HANDLE,PBYTE,int*); // возвращает паблик ключ из указанного контекста int (__cdecl *rsa_set_pubkey)(HANDLE,PBYTE,int); // загружает паблик ключ для указанного контекста void (__cdecl *rsa_set_timeout)(int); // установить таймаут для установки секюрного соединения int (__cdecl *rsa_get_state)(HANDLE); // получить статус указанного контекста int (__cdecl *rsa_get_hash)(PBYTE,int,PBYTE,int*); // вычисляет SHA1(key) int (__cdecl *rsa_connect)(HANDLE); // запускает процесс установки содинения с указанным контекстом int (__cdecl *rsa_disconnect)(HANDLE); // разрывает соединение с указанным контекстом int (__cdecl *rsa_disabled)(HANDLE); // разрывает соединение по причине "disabled" LPSTR (__cdecl *rsa_recv)(HANDLE,LPCSTR); // необходимо передавать сюда все входящие протокольные сообщения int (__cdecl *rsa_send)(HANDLE,LPCSTR); // вызываем для отправки сообщения клиенту int (__cdecl *rsa_encrypt_file)(HANDLE,LPCSTR,LPCSTR); int (__cdecl *rsa_decrypt_file)(HANDLE,LPCSTR,LPCSTR); LPSTR (__cdecl *utf8encode)(LPCWSTR); LPWSTR (__cdecl *utf8decode)(LPCSTR); int (__cdecl *is_7bit_string)(LPCSTR); int (__cdecl *is_utf8_string)(LPCSTR); int (__cdecl *rsa_export_keypair)(short,LPSTR,LPSTR,LPSTR); // export private key int (__cdecl *rsa_import_keypair)(short,LPSTR,LPSTR); // import & activate private key int (__cdecl *rsa_export_pubkey)(HANDLE,LPSTR); // export public key from context int (__cdecl *rsa_import_pubkey)(HANDLE,LPSTR); // import public key into context } RSA_EXPORT; typedef RSA_EXPORT* pRSA_EXPORT; typedef struct { int (__cdecl *rsa_inject)(HANDLE,LPCSTR); // вставляет сообщение в очередь на отправку int (__cdecl *rsa_check_pub)(HANDLE,PBYTE,int,PBYTE,int); // проверяет интерактивно SHA и сохраняет ключ, если все нормально void (__cdecl *rsa_notify)(HANDLE,int); // нотификация о смене состояния } RSA_IMPORT; typedef RSA_IMPORT* pRSA_IMPORT; NAMESPACE_BEGIN(CryptoPP) typedef RSASS<PKCS1v15, SHA256>::Signer RSASSA_PKCS1v15_SHA256_Signer; typedef RSASS<PKCS1v15, SHA256>::Verifier RSASSA_PKCS1v15_SHA256_Verifier; NAMESPACE_END #endif
[ "balookrd@d641cd86-4a32-0410-994c-055de1cff029" ]
[ [ [ 1, 216 ] ] ]
63820d94f168abcf13202b1bef2effce1c002546
9e2c39ce4b2a226a6db1f5a5d361dea4b2f02345
/tools/LePlatz/GraphicsView/PlatzGraphicsItem.cpp
5d7314dd2cddc28a23413c037a88ef9328c0872b
[]
no_license
gonzalodelgado/uzebox-paul
38623933e0fb34d7b8638b95b29c4c1d0b922064
c0fa12be79a3ff6bbe70799f2e8620435ce80a01
refs/heads/master
2016-09-05T22:24:29.336414
2010-07-19T07:37:17
2010-07-19T07:37:17
33,088,815
0
0
null
null
null
null
UTF-8
C++
false
false
4,369
cpp
/* * LePlatz - A level editor for the Platz toolset (Uzebox - supports VIDEO_MODE 3) * Copyright (C) 2009 Paul McPhee * * 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 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 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/>. */ #include <QPainter> #include <QStyleOption> #include <WorldItem.h> #include <PlatzGraphicsScene.h> #include "PlatzGraphicsItem.h" PlatzGraphicsItem::PlatzGraphicsItem() : itemParent(0), bounds(QRectF(0.0, 0.0, 0.0, 0.0)), offsetX(0.0), displayMode(Platz::NORMAL) { } PlatzGraphicsItem::PlatzGraphicsItem(WorldItem *parent, Platz::ItemDisplayMode mode) : itemParent(parent), displayMode(mode) { } PlatzGraphicsItem::PlatzGraphicsItem(PlatzGraphicsItem *item) : itemParent(0), bounds(QRectF(0.0, 0.0, 0.0, 0.0)), offsetX(0.0), displayMode(Platz::NORMAL) { *this = *item; } PlatzGraphicsItem& PlatzGraphicsItem::operator=(const PlatzGraphicsItem &rhs) { itemParent = const_cast<PlatzGraphicsItem&>(rhs).parent(); displayMode = rhs.mode(); return *this; } WorldItem* PlatzGraphicsItem::parent() const { return itemParent; } QRectF PlatzGraphicsItem::relativeBoundingRect() const { if (parent()) return parent()->relativeBoundingRect(); else return bounds; } QRectF PlatzGraphicsItem::boundingRect() const { if (parent()) return parent()->boundingRect(); else return bounds.adjusted(offsetX, 0.0, offsetX, 0.0); // For orphaned items (like selection box) } void PlatzGraphicsItem::platzPrepareGeometryChange() { prepareGeometryChange(); } void PlatzGraphicsItem::setBoundingRect(const QRectF &r) { if (parent()) { parent()->setBoundingRect(r); } else { prepareGeometryChange(); bounds = r.adjusted(-offsetX, 0, -offsetX, 0); } } void PlatzGraphicsItem::setRelativeBoundingRect(const QRectF &r) { if (parent()) setBoundingRect(r.adjusted(parent()->offsetX(), 0, parent()->offsetX(), 0)); else bounds = r; } QRectF PlatzGraphicsItem::limitRect() const { if (parent()) return parent()->limitRect(); else return QRectF(0.0, 0.0, 0.0, 0.0); } void PlatzGraphicsItem::setOffsetX(qreal offset) { offsetX = offset; } void PlatzGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem*, QWidget *) { int index; switch (displayMode) { case Platz::NORMAL: if (!parent()) return; switch (parent()->type()) { case WorldItem::Outer: index = 0; break; case WorldItem::Inner: index = 1; break; case WorldItem::Mutable: index = 2; break; case WorldItem::Object: index = 3; break; case WorldItem::PlatformPath: index = 4; break; case WorldItem::Platform: index = 5; break; default: index = -1; return; } break; case Platz::SELECTED: index = 6; break; default: return; } painter->setPen(PlatzGraphicsScene::pens.at(index)); painter->setBrush(PlatzGraphicsScene::brushes.at(index)); painter->drawRect(boundingRect()); } Platz::ItemDisplayMode PlatzGraphicsItem::mode() const { return displayMode; } void PlatzGraphicsItem::setMode(Platz::ItemDisplayMode mode) { displayMode = mode; update(); }
[ "[email protected]@08aac7ea-4340-11de-bfec-d9b18e096ff9" ]
[ [ [ 1, 158 ] ] ]
5384f8dadf1314865be396992dd639f87603235a
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/zombie/nnavmesh/src/nnavmesh/nnavutils.cc
f8f8c7d2d80cb40518fd33edff60701cd955ec80
[]
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
12,292
cc
//----------------------------------------------------------------------------- // nnavutils_main.cc // (C) 2006 Conjurer Services, S.A. //----------------------------------------------------------------------------- #include "precompiled/pchnnavmesh.h" #include "nnavmesh/nnavutils.h" #include "nphysics/nphysicsserver.h" #include "nphysics/nphysicsgeom.h" #include "nphysics/ncphysicsobj.h" #include "nspatial/nspatialserver.h" #include "ngeomipmap/ncterraingmmclass.h" //----------------------------------------------------------------------------- namespace nNavUtils { //----------------------------------------------------------------------------- // To cast the ray used to found the ground height below a position, this offset is added to the position // as the start point of the ray so ground bump and small obstacles are climbed correctly // (but the value should not be too high or otherwise there's the risk to "climb up" to the top floor) // History: // - 2006/03/15 1.0 used as initial ground height offset value // - 2006/05/08 1.0 has proven to be a way too much and can cause agents // to climb obstacles too high for them. Changed to 0.5 // - 2006/08/08 Moved to global variable server as // -GroundSeekStartDistance //const float GroundHeightOffset( 0.5f ); // Max distance to look for the ground below a position // History: // - 2006/03/15 It's recommended that ray offset above floor is greater // than below so if the agent accidentally "climbs down" // to a lower floor when walking over a small hole, it has // a chance to return back. // Value = 0.5 + ground height offset // - 2006/05/08 With the addition of physics ramp category now it's // rather desired to have a greater offset value below the // floor to allow agent to "climb down" and let designer // handle special cases caused by some small holes. // Value increased to 1.0 + ground height offset // - 2006/05/16 Value increased to 4.0 + ground height offset // This value forces aliens to climb down when they // accidentally climb up ramps due to pathfinding not // considering the alien body size yet. // - 2006/08/08 Moved to global variable server as // GroundSeekEndDistance - GroundSeekStartDistance //const float GroundSeekDistance( 4.0f + GroundHeightOffset ); //------------------------------------------------------------------------------ /** Get the height of the closest ground below the give point The ground is any static or ramp physics surface found by a ray with origin slightly above the given point and casted down with some predefined length. The highest contact point is the returned height. If no ground is found, the height of the given point is returned. Anyway, don't assume this to be the default behavior forever, it's just a convenience value that can change in a future (even to a value so different such as -FLT_MAX for instance). So rather check the boolean value returned for a more robust usage. Global variables GroundSeekStartDistance and GroundSeekEndDistance are used to build the ray pointing downwards. Distances are relative to the given point's y: ray start = point.y - GroundSeekStartDistance, ray end = point.y + GroundSeekEndDistance @param point Point for which a ground is looked for @retval groundHeight Height of the closest ground found @return True if a ground has been found, false otherwise */ bool GetGroundHeight( const vector3& point, float& groundHeight ) { // Cast a ray slightly above the given position and towards the ground // to find the height of the ground below the position const float GroundSeekStart = nVariableServer::Instance()->GetFloatVariable("GroundSeekStartDistance"); const float GroundSeekEnd = nVariableServer::Instance()->GetFloatVariable("GroundSeekEndDistance"); const float GroundSeekDistance = GroundSeekEnd - GroundSeekStart; vector3 origin(point); origin.y -= GroundSeekStart; const int MaxContacts( 10 ); nPhyCollide::nContact contact[ MaxContacts ]; int contactsNumber( nPhysicsServer::Collide( origin, vector3(0,-1,0), GroundSeekDistance, MaxContacts, contact, nPhysicsGeom::Static | nPhysicsGeom::Ramp ) ); if ( contactsNumber == 0 ) { // No ground found -> return given height as ground level groundHeight = point.y; return false; } // Take the closest contact as the ground level float closestHeight( -FLT_MAX ); for ( int c(0); c < contactsNumber; ++c ) { vector3 contactPos; contact[c].GetContactPosition( contactPos ); if ( contactPos.y > closestHeight ) { closestHeight = contactPos.y; } } groundHeight = closestHeight; return true; } //------------------------------------------------------------------------------ /** Get the height of the closest ground physics geometry below the given point This method works like GetGroundHeight, but skiping those objects that aren't marked as ground. The terrain is considered as a ground too. @param point Point for which a ground is looked for @retval groundHeight Height of the closest ground found @return True if a ground has been found, false otherwise @see GetGroundHeight @todo Mix this and GetGroundHeight into a single method to simplify mantenaince */ bool GetGroundLevelHeight( const vector3& point, float& groundHeight ) { // Cast a ray slightly above the given position and pointing down // to find the height of the ground below the position const float GroundSeekStart = nVariableServer::Instance()->GetFloatVariable("GroundSeekStartDistance"); const float GroundSeekEnd = nVariableServer::Instance()->GetFloatVariable("GroundSeekEndDistance"); const float GroundSeekDistance = GroundSeekEnd - GroundSeekStart; vector3 origin(point); origin.y -= GroundSeekStart; const int MaxContacts( 10 ); nPhyCollide::nContact contact[ MaxContacts ]; int contactsNumber( nPhysicsServer::Collide( origin, vector3(0,-1,0), GroundSeekDistance, MaxContacts, contact, nPhysicsGeom::Static ) ); // Take the closest ground contact as the ground level, // ignoring non ground objects bool groundFound( false ); float closestHeight( -FLT_MAX ); for ( int c(0); c < contactsNumber; ++c ) { if ( contact[c].GetGeometryA()->HasAttributes( nPhysicsGeom::ground ) || contact[c].GetGeometryA()->Type() == nPhysicsGeom::HeightMap || contact[c].GetGeometryB()->HasAttributes( nPhysicsGeom::ground ) || contact[c].GetGeometryB()->Type() == nPhysicsGeom::HeightMap ) { vector3 contactPos; contact[c].GetContactPosition( contactPos ); if ( contactPos.y > closestHeight ) { closestHeight = contactPos.y; groundFound = true; } } } // Return closest ground found and if a ground has been found at all if ( !groundFound ) { // No ground found -> return given height as ground level groundHeight = point.y; } else { // Ground found -> return height of closest ground groundHeight = closestHeight; } return groundFound; } //------------------------------------------------------------------------------ /** Check if there's a clear LoS between two points Only static, ramps and stairs objects (excluding the terrain) can block LoS. */ bool IsLineOfSight( const vector3& source, const vector3& target ) { // Build LoS vector3 los( target - source ); float losLength( los.len() ); if ( losLength <= TINY ) { // No need for LoS test if 0 long ray return true; } los.norm(); // Test for LoS const int MaxContacts( 10 ); nPhyCollide::nContact contact[ MaxContacts ]; int numContacts( nPhysicsServer::Collide( source, los, losLength, 1, contact, nPhysicsGeom::Static | nPhysicsGeom::Ramp | nPhysicsGeom::Stairs ) ); for ( int i(0); i < numContacts; ++i ) { // Get collider nPhysicsGeom* collider( contact[i].GetGeometryA() ); n_assert( collider ); if ( collider->Type() == nPhysicsGeom::Ray ) { collider = contact[i].GetGeometryB(); n_assert( collider ); } // If found an obstacle other than the terrain there's no LoS if ( collider->Type() != nPhysicsGeom::HeightMap ) { return false; } } // No obstacle found, there's a clear LoS return true; } //------------------------------------------------------------------------------ /** Check if an entity can walk between two points (unidirectional check) A LoS check is done between the two given points, moved slightly up to prevent that the ground blocks the LoS but to detect those obstacles near the ground. An additional check to detect holes is performed, but it hasn't an accurate resolution, so don't use this method to detect small or narrow holes for now. Given entity's gameplay component is completely ignored by now. @todo Consider entity attributes like body height, body size, max walkable slope, max climb up/down height, etc. @todo Detect holes more accurately and rather faster */ bool IsWalkable( const vector3& source, const vector3& target, const ncGameplayClass* /*entityConfig*/ ) { // Project given points over ground vector3 groundSource( source ); if ( !nNavUtils::GetGroundHeight( groundSource, groundSource.y ) ) { // No ground found near, and no ground means you cannot walk return false; } vector3 groundTarget( target ); if ( !nNavUtils::GetGroundHeight( groundTarget, groundTarget.y ) ) { // No ground found near, and no ground means you cannot walk return false; } // Move up given points a bit over ground const float GroundOffset( 0.5f ); vector3 sourceUp( groundSource ); sourceUp.y += GroundOffset; vector3 targetUp( groundTarget ); targetUp.y += GroundOffset; // Test for LoS if ( !nNavUtils::IsLineOfSight( sourceUp, targetUp ) ) { return false; } // Look for holes by sampling the ground height below each 'step' towards the end point const float stepSize( 0.5f ); const float heightTolerance( 0.5f ); vector3 travelDir( groundTarget - groundSource ); float travelDistance( travelDir.len() ); travelDir.norm(); for ( float distance( stepSize ); distance < travelDistance; distance += stepSize ) { vector3 pos( groundSource + travelDir * distance ); float groundHeight; if ( !nNavUtils::GetGroundHeight( pos, groundHeight ) ) { return false; } if ( pos.y - groundHeight > heightTolerance ) { return false; } } // All tests have successfully passed, the surface from start to end point is walkable return true; } //------------------------------------------------------------------------------ /** Get the terrain height map */ nFloatMap* GetHeightMap() { nEntityObject* outdoor( nSpatialServer::Instance()->GetOutdoorEntity() ); n_assert( outdoor ); ncTerrainGMMClass* terrainGMM( outdoor->GetClassComponentSafe< ncTerrainGMMClass >() ); nFloatMap* heightMap( terrainGMM->GetHeightMap() ); n_assert( heightMap ); return heightMap; } //----------------------------------------------------------------------------- } // namespace nNavUtils
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 305 ] ] ]
f06457c0f7d745dbead12f3a1eec5d084df5c44f
8f71027712982e2e070a7932b2b59c7b265b6099
/3pp/twitcurl/oauthlib.cpp
683696fb36c47f3078200bacbeb09b85ddfc1111
[]
no_license
peteb/tankage
7c4e9ea40d1d111e930924bfb073abcac4176d23
9b109093081bb838d9bd91dfedebe3a2593a9d78
refs/heads/master
2021-01-10T00:53:17.050277
2011-04-13T18:10:34
2011-04-13T18:10:34
918,597
4
0
null
null
null
null
UTF-8
C++
false
false
16,842
cpp
#include "oauthlib.h" #include "HMAC_SHA1.h" #include "base64.h" #include "urlencode.h" #include <cstdlib> /*++ * @method: oAuth::oAuth * * @description: constructor * * @input: none * * @output: none * *--*/ oAuth::oAuth(): m_consumerKey( "" ), m_consumerSecret( "" ), m_oAuthTokenKey( "" ), m_oAuthTokenSecret( "" ), m_oAuthPin( "" ), m_nonce( "" ), m_timeStamp( "" ), m_oAuthScreenName( "" ) { } /*++ * @method: oAuth::~oAuth * * @description: destructor * * @input: none * * @output: none * *--*/ oAuth::~oAuth() { } /*++ * @method: oAuth::getConsumerKey * * @description: this method gives consumer key that is being used currently * * @input: none * * @output: consumer key * *--*/ void oAuth::getConsumerKey( std::string& consumerKey ) { consumerKey = m_consumerKey; } /*++ * @method: oAuth::setConsumerKey * * @description: this method saves consumer key that should be used * * @input: consumer key * * @output: none * *--*/ void oAuth::setConsumerKey( const std::string& consumerKey ) { m_consumerKey.assign( consumerKey.c_str() ); } /*++ * @method: oAuth::getConsumerSecret * * @description: this method gives consumer secret that is being used currently * * @input: none * * @output: consumer secret * *--*/ void oAuth::getConsumerSecret( std::string& consumerSecret ) { consumerSecret = m_consumerSecret; } /*++ * @method: oAuth::setConsumerSecret * * @description: this method saves consumer secret that should be used * * @input: consumer secret * * @output: none * *--*/ void oAuth::setConsumerSecret( const std::string& consumerSecret ) { m_consumerSecret = consumerSecret; } /*++ * @method: oAuth::getOAuthTokenKey * * @description: this method gives OAuth token (also called access token) that is being used currently * * @input: none * * @output: OAuth token * *--*/ void oAuth::getOAuthTokenKey( std::string& oAuthTokenKey ) { oAuthTokenKey = m_oAuthTokenKey; } /*++ * @method: oAuth::setOAuthTokenKey * * @description: this method saves OAuth token that should be used * * @input: OAuth token * * @output: none * *--*/ void oAuth::setOAuthTokenKey( const std::string& oAuthTokenKey ) { m_oAuthTokenKey = oAuthTokenKey; } /*++ * @method: oAuth::getOAuthTokenSecret * * @description: this method gives OAuth token secret that is being used currently * * @input: none * * @output: OAuth token secret * *--*/ void oAuth::getOAuthTokenSecret( std::string& oAuthTokenSecret ) { oAuthTokenSecret = m_oAuthTokenSecret; } /*++ * @method: oAuth::setOAuthTokenSecret * * @description: this method saves OAuth token that should be used * * @input: OAuth token secret * * @output: none * *--*/ void oAuth::setOAuthTokenSecret( const std::string& oAuthTokenSecret ) { m_oAuthTokenSecret = oAuthTokenSecret; } /*++ * @method: oAuth::getOAuthScreenName * * @description: this method gives authorized user's screenname * * @input: none * * @output: screen name * *--*/ void oAuth::getOAuthScreenName( std::string& oAuthScreenName ) { oAuthScreenName = m_oAuthScreenName; } /*++ * @method: oAuth::setOAuthScreenName * * @description: this method sets authorized user's screenname * * @input: screen name * * @output: none * *--*/ void oAuth::setOAuthScreenName( const std::string& oAuthScreenName ) { m_oAuthScreenName = oAuthScreenName; } /*++ * @method: oAuth::getOAuthPin * * @description: this method gives OAuth verifier PIN * * @input: none * * @output: OAuth verifier PIN * *--*/ void oAuth::getOAuthPin( std::string& oAuthPin ) { oAuthPin = m_oAuthPin; } /*++ * @method: oAuth::setOAuthPin * * @description: this method sets OAuth verifier PIN * * @input: OAuth verifier PIN * * @output: none * *--*/ void oAuth::setOAuthPin( const std::string& oAuthPin ) { m_oAuthPin = oAuthPin; } /*++ * @method: oAuth::generateNonceTimeStamp * * @description: this method generates nonce and timestamp for OAuth header * * @input: none * * @output: none * * @remarks: internal method * *--*/ void oAuth::generateNonceTimeStamp() { char szTime[oAuthLibDefaults::OAUTHLIB_BUFFSIZE]; char szRand[oAuthLibDefaults::OAUTHLIB_BUFFSIZE]; memset( szTime, 0, oAuthLibDefaults::OAUTHLIB_BUFFSIZE ); memset( szRand, 0, oAuthLibDefaults::OAUTHLIB_BUFFSIZE ); srand( time( NULL ) ); sprintf( szRand, "%x", rand()%1000 ); sprintf( szTime, "%ld", time( NULL ) ); m_nonce.assign( szTime ); m_nonce.append( szRand ); m_timeStamp.assign( szTime ); } /*++ * @method: oAuth::buildOAuthTokenKeyValuePairs * * @description: this method prepares key-value pairs required for OAuth header * and signature generation. * * @input: includeOAuthVerifierPin - flag to indicate whether oauth_verifer key-value * pair needs to be included. oauth_verifer is only * used during exchanging request token with access token. * rawData - url encoded data. this is used during signature generation. * oauthSignature - base64 and url encoded OAuth signature. * * @output: keyValueMap - map in which key-value pairs are populated * * @remarks: internal method * *--*/ bool oAuth::buildOAuthTokenKeyValuePairs( const bool includeOAuthVerifierPin, const std::string& rawData, const std::string& oauthSignature, oAuthKeyValuePairs& keyValueMap ) { /* Generate nonce and timestamp if required */ generateNonceTimeStamp(); /* Consumer key and its value */ keyValueMap[oAuthLibDefaults::OAUTHLIB_CONSUMERKEY_KEY] = m_consumerKey; /* Nonce key and its value */ keyValueMap[oAuthLibDefaults::OAUTHLIB_NONCE_KEY] = m_nonce; /* Signature if supplied */ if( oauthSignature.length() > 0 ) { keyValueMap[oAuthLibDefaults::OAUTHLIB_SIGNATURE_KEY] = oauthSignature; } /* Signature method, only HMAC-SHA1 as of now */ keyValueMap[oAuthLibDefaults::OAUTHLIB_SIGNATUREMETHOD_KEY] = std::string( "HMAC-SHA1" ); /* Timestamp */ keyValueMap[oAuthLibDefaults::OAUTHLIB_TIMESTAMP_KEY] = m_timeStamp; /* Token */ if( m_oAuthTokenKey.length() > 0 ) { keyValueMap[oAuthLibDefaults::OAUTHLIB_TOKEN_KEY] = m_oAuthTokenKey; } /* Verifier */ if( includeOAuthVerifierPin && ( m_oAuthPin.length() > 0 ) ) { keyValueMap[oAuthLibDefaults::OAUTHLIB_VERIFIER_KEY] = m_oAuthPin; } /* Version */ keyValueMap[oAuthLibDefaults::OAUTHLIB_VERSION_KEY] = std::string( "1.0" ); /* Data if it's present */ if( rawData.length() > 0 ) { /* Data should already be urlencoded once */ std::string dummyStrKey( "" ); std::string dummyStrValue( "" ); size_t nPos = rawData.find_first_of( "=" ); if( std::string::npos != nPos ) { dummyStrKey = rawData.substr( 0, nPos ); dummyStrValue = rawData.substr( nPos + 1 ); keyValueMap[dummyStrKey] = dummyStrValue; } } return ( keyValueMap.size() > 0 ) ? true : false; } /*++ * @method: oAuth::getSignature * * @description: this method calculates HMAC-SHA1 signature of OAuth header * * @input: eType - HTTP request type * rawUrl - raw url of the HTTP request * rawKeyValuePairs - key-value pairs containing OAuth headers and HTTP data * * @output: oAuthSignature - base64 and url encoded signature * * @remarks: internal method * *--*/ bool oAuth::getSignature( const eOAuthHttpRequestType eType, const std::string& rawUrl, const oAuthKeyValuePairs& rawKeyValuePairs, std::string& oAuthSignature ) { std::string rawParams( "" ); std::string paramsSeperator( "" ); std::string sigBase( "" ); /* Initially empty signature */ oAuthSignature.assign( "" ); /* Build a string using key-value pairs */ paramsSeperator = "&"; getStringFromOAuthKeyValuePairs( rawKeyValuePairs, rawParams, paramsSeperator ); /* Start constructing base signature string. Refer http://dev.twitter.com/auth#intro */ switch( eType ) { case eOAuthHttpGet: { sigBase.assign( "GET&" ); } break; case eOAuthHttpPost: { sigBase.assign( "POST&" ); } break; case eOAuthHttpDelete: { sigBase.assign( "DELETE&" ); } break; default: { return false; } break; } sigBase.append( urlencode( rawUrl ) ); sigBase.append( "&" ); sigBase.append( urlencode( rawParams ) ); /* Now, hash the signature base string using HMAC_SHA1 class */ CHMAC_SHA1 objHMACSHA1; std::string secretSigningKey( "" ); unsigned char strDigest[oAuthLibDefaults::OAUTHLIB_BUFFSIZE_LARGE]; memset( strDigest, 0, oAuthLibDefaults::OAUTHLIB_BUFFSIZE_LARGE ); /* Signing key is composed of consumer_secret&token_secret */ secretSigningKey.assign( m_consumerSecret.c_str() ); secretSigningKey.append( "&" ); if( m_oAuthTokenSecret.length() > 0 ) { secretSigningKey.append( m_oAuthTokenSecret.c_str() ); } objHMACSHA1.HMAC_SHA1( (unsigned char*)sigBase.c_str(), sigBase.length(), (unsigned char*)secretSigningKey.c_str(), secretSigningKey.length(), strDigest ); /* Do a base64 encode of signature */ std::string base64Str = base64_encode( strDigest, 20 /* SHA 1 digest is 160 bits */ ); /* Do an url encode */ oAuthSignature = urlencode( base64Str ); return ( oAuthSignature.length() > 0 ) ? true : false; } /*++ * @method: oAuth::getOAuthHeader * * @description: this method builds OAuth header that should be used in HTTP requests to twitter * * @input: eType - HTTP request type * rawUrl - raw url of the HTTP request * rawData - HTTP data * includeOAuthVerifierPin - flag to indicate whether or not oauth_verifier needs to included * in OAuth header * * @output: oAuthHttpHeader - OAuth header * *--*/ bool oAuth::getOAuthHeader( const eOAuthHttpRequestType eType, const std::string& rawUrl, const std::string& rawData, std::string& oAuthHttpHeader, const bool includeOAuthVerifierPin ) { oAuthKeyValuePairs rawKeyValuePairs; std::string rawParams( "" ); std::string oauthSignature( "" ); std::string paramsSeperator( "" ); std::string pureUrl( rawUrl ); /* Clear header string initially */ oAuthHttpHeader.assign( "" ); rawKeyValuePairs.clear(); /* If URL itself contains ?key=value, then extract and put them in map */ size_t nPos = rawUrl.find_first_of( "?" ); if( std::string::npos != nPos ) { /* Get only URL */ pureUrl = rawUrl.substr( 0, nPos ); /* Get only key=value data part */ std::string dataPart = rawUrl.substr( nPos + 1 ); size_t nPos2 = dataPart.find_first_of( "=" ); if( std::string::npos != nPos2 ) { std::string dataKey = dataPart.substr( 0, nPos2 ); std::string dataVal = dataPart.substr( nPos2 + 1 ); /* Put this key=value pair in map */ rawKeyValuePairs[dataKey] = urlencode( dataVal ); } } /* Build key-value pairs needed for OAuth request token, without signature */ buildOAuthTokenKeyValuePairs( includeOAuthVerifierPin, rawData, std::string( "" ), rawKeyValuePairs ); /* Get url encoded base64 signature using request type, url and parameters */ getSignature( eType, pureUrl, rawKeyValuePairs, oauthSignature ); /* Now, again build key-value pairs with signature this time */ buildOAuthTokenKeyValuePairs( includeOAuthVerifierPin, std::string( "" ), oauthSignature, rawKeyValuePairs ); /* Get OAuth header in string format */ paramsSeperator = ","; getStringFromOAuthKeyValuePairs( rawKeyValuePairs, rawParams, paramsSeperator ); /* Build authorization header */ oAuthHttpHeader.assign( oAuthLibDefaults::OAUTHLIB_AUTHHEADER_STRING.c_str() ); oAuthHttpHeader.append( rawParams.c_str() ); return ( oAuthHttpHeader.length() > 0 ) ? true : false; } /*++ * @method: oAuth::getStringFromOAuthKeyValuePairs * * @description: this method builds a sorted string from key-value pairs * * @input: rawParamMap - key-value pairs map * paramsSeperator - sepearator, either & or , * * @output: rawParams - sorted string of OAuth parameters * * @remarks: internal method * *--*/ bool oAuth::getStringFromOAuthKeyValuePairs( const oAuthKeyValuePairs& rawParamMap, std::string& rawParams, const std::string& paramsSeperator ) { rawParams.assign( "" ); if( rawParamMap.size() ) { oAuthKeyValueList keyValueList; std::string dummyStr( "" ); /* Push key-value pairs to a list of strings */ keyValueList.clear(); oAuthKeyValuePairs::const_iterator itMap = rawParamMap.begin(); for( ; itMap != rawParamMap.end(); itMap++ ) { dummyStr.assign( itMap->first ); dummyStr.append( "=" ); if( paramsSeperator == "," ) { dummyStr.append( "\"" ); } dummyStr.append( itMap->second ); if( paramsSeperator == "," ) { dummyStr.append( "\"" ); } keyValueList.push_back( dummyStr ); } /* Sort key-value pairs based on key name */ keyValueList.sort(); /* Now, form a string */ dummyStr.assign( "" ); oAuthKeyValueList::iterator itKeyValue = keyValueList.begin(); for( ; itKeyValue != keyValueList.end(); itKeyValue++ ) { if( dummyStr.length() > 0 ) { dummyStr.append( paramsSeperator ); } dummyStr.append( itKeyValue->c_str() ); } rawParams.assign( dummyStr ); } return ( rawParams.length() > 0 ) ? true : false; } /*++ * @method: oAuth::extractOAuthTokenKeySecret * * @description: this method extracts oauth token key and secret from * twitter's HTTP response * * @input: requestTokenResponse - response from twitter * * @output: none * *--*/ bool oAuth::extractOAuthTokenKeySecret( const std::string& requestTokenResponse ) { if( requestTokenResponse.length() > 0 ) { size_t nPos = std::string::npos; std::string strDummy( "" ); /* Get oauth_token key */ nPos = requestTokenResponse.find( oAuthLibDefaults::OAUTHLIB_TOKEN_KEY.c_str() ); if( std::string::npos != nPos ) { nPos = nPos + oAuthLibDefaults::OAUTHLIB_TOKEN_KEY.length() + strlen( "=" ); strDummy = requestTokenResponse.substr( nPos ); nPos = strDummy.find( "&" ); if( std::string::npos != nPos ) { m_oAuthTokenKey = strDummy.substr( 0, nPos ); } } /* Get oauth_token_secret */ nPos = requestTokenResponse.find( oAuthLibDefaults::OAUTHLIB_TOKENSECRET_KEY.c_str() ); if( std::string::npos != nPos ) { nPos = nPos + oAuthLibDefaults::OAUTHLIB_TOKENSECRET_KEY.length() + strlen( "=" ); strDummy = requestTokenResponse.substr( nPos ); nPos = strDummy.find( "&" ); if( std::string::npos != nPos ) { m_oAuthTokenSecret = strDummy.substr( 0, nPos ); } } /* Get screen_name */ nPos = requestTokenResponse.find( oAuthLibDefaults::OAUTHLIB_SCREENNAME_KEY.c_str() ); if( std::string::npos != nPos ) { nPos = nPos + oAuthLibDefaults::OAUTHLIB_SCREENNAME_KEY.length() + strlen( "=" ); strDummy = requestTokenResponse.substr( nPos ); m_oAuthScreenName = strDummy; } } return true; }
[ [ [ 1, 603 ] ] ]
9bbed7b537f63c67036b82b397895c857c6aca14
075043812c30c1914e012b52c60bc3be2cfe49cc
/src/ShokoRocket++/GridTextureCreator.h
e94025fcf3dc0fb9ca7d20d908e753fe018f1898
[]
no_license
Luke-Vulpa/Shoko-Rocket
8a916d70bf777032e945c711716123f692004829
6f727a2cf2f072db11493b739cc3736aec40d4cb
refs/heads/master
2020-12-28T12:03:14.055572
2010-02-28T11:58:26
2010-02-28T11:58:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
172
h
#pragma once #include <boost/shared_ptr.hpp> #include <World.h> class Animation; Animation* CreateGridTexture(boost::shared_ptr<World> _world, Vector2i _grid_size);
[ [ [ 1, 7 ] ] ]
4065a8a1c901af846487154b6b52b05ac70929e1
f95341dd85222aa39eaa225262234353f38f6f97
/DesktopX/Plugins/DXSystemEx/DXSystemEx/Volume/MixerAPI.cpp
801f75adab2f0439c5abf9f2d700cb3285d07061
[]
no_license
Templier/threeoaks
367b1a0a45596b8fe3607be747b0d0e475fa1df2
5091c0f54bd0a1b160ddca65a5e88286981c8794
refs/heads/master
2020-06-03T11:08:23.458450
2011-10-31T04:33:20
2011-10-31T04:33:20
32,111,618
0
0
null
null
null
null
UTF-8
C++
false
false
7,954
cpp
/////////////////////////////////////////////////////////////////////////////////////////////// // // MixerAPI (CAlexfMixer) - simple mixer control wrapper // // Copyright (c)1999, Alexander Fedorov // You may do whatever you want with this code, as long as you include this // copyright notice in your implementation files. // If you wish to add new classes to this collection, feel free to do so. // But please send me your code so that I can update the collection. // Comments and bug reports: [email protected] // /////////////////////////////////////////////////////////////////////////////////////////////// // * $LastChangedRevision$ // * $LastChangedDate$ // * $LastChangedBy$ /////////////////////////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "MixerAPI.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// void MixerAPI::ZeroAll() { m_HMixer = NULL; m_iMixerControlID = 0; mmr = MMSYSERR_NOERROR; m_dwChannels = 0; m_bSuccess = FALSE; } MixerAPI::MixerAPI(DWORD DstType, DWORD SrcType, DWORD ControlType) { ZeroAll(); if(mixerGetNumDevs() < 1) return; mmr = mixerOpen(&m_HMixer, 0, 0, 0L, CALLBACK_NULL); if (mmr != MMSYSERR_NOERROR) return; // get dwLineID MIXERLINE mxl; mxl.cbStruct = sizeof(MIXERLINE); // DstType mxl.dwComponentType = DstType; if (mixerGetLineInfo((HMIXEROBJ)m_HMixer, &mxl, MIXER_OBJECTF_HMIXER | MIXER_GETLINEINFOF_COMPONENTTYPE) != MMSYSERR_NOERROR) return; // SrcType if( SrcType != NO_SOURCE ) { UINT nconn = mxl.cConnections; DWORD DstIndex = mxl.dwDestination; for( UINT j = 0; j < nconn; j++ ) { mxl.cbStruct = sizeof( MIXERLINE ); mxl.dwSource = j; mxl.dwDestination = DstIndex; if(mixerGetLineInfo( ( HMIXEROBJ )m_HMixer, &mxl, MIXER_GETLINEINFOF_SOURCE ) != MMSYSERR_NOERROR) return; if( mxl.dwComponentType == SrcType ) break; } } // get dwControlID MIXERCONTROL mxc; MIXERLINECONTROLS mxlc; mxlc.cbStruct = sizeof(MIXERLINECONTROLS); mxlc.dwLineID = mxl.dwLineID; mxlc.dwControlType = ControlType; mxlc.cControls = 1; mxlc.cbmxctrl = sizeof(MIXERCONTROL); mxlc.pamxctrl = &mxc; if (mixerGetLineControls((HMIXEROBJ)m_HMixer, &mxlc, MIXER_OBJECTF_HMIXER | MIXER_GETLINECONTROLSF_ONEBYTYPE) != MMSYSERR_NOERROR) return; m_iMixerControlID = mxc.dwControlID; m_dwChannels = mxl.cChannels; m_bSuccess = TRUE; } MixerAPI::MixerAPI(HWND hwnd, DWORD DstType, DWORD SrcType, DWORD ControlType) { ZeroAll(); if(mixerGetNumDevs() < 1) return; mmr = mixerOpen(&m_HMixer, 0, (DWORD)hwnd, 0L, CALLBACK_WINDOW); if (mmr != MMSYSERR_NOERROR) return; // get dwLineID MIXERLINE mxl; mxl.cbStruct = sizeof(MIXERLINE); // DstType mxl.dwComponentType = DstType; if (mixerGetLineInfo((HMIXEROBJ)m_HMixer, &mxl, MIXER_OBJECTF_HMIXER | MIXER_GETLINEINFOF_COMPONENTTYPE) != MMSYSERR_NOERROR) return; // SrcType if( SrcType != NO_SOURCE ) { UINT nconn = mxl.cConnections; DWORD DstIndex = mxl.dwDestination; for( UINT j = 0; j < nconn; j++ ) { mxl.cbStruct = sizeof( MIXERLINE ); mxl.dwSource = j; mxl.dwDestination = DstIndex; if(mixerGetLineInfo( ( HMIXEROBJ )m_HMixer, &mxl, MIXER_GETLINEINFOF_SOURCE ) != MMSYSERR_NOERROR) return; if( mxl.dwComponentType == SrcType ) break; } } // get dwControlID MIXERCONTROL mxc; MIXERLINECONTROLS mxlc; mxlc.cbStruct = sizeof(MIXERLINECONTROLS); mxlc.dwLineID = mxl.dwLineID; mxlc.dwControlType = ControlType; mxlc.cControls = 1; mxlc.cbmxctrl = sizeof(MIXERCONTROL); mxlc.pamxctrl = &mxc; if (mixerGetLineControls((HMIXEROBJ)m_HMixer, &mxlc, MIXER_OBJECTF_HMIXER | MIXER_GETLINECONTROLSF_ONEBYTYPE) != MMSYSERR_NOERROR) return; m_iMixerControlID = mxc.dwControlID; m_bSuccess = TRUE; } MixerAPI::~MixerAPI() { if (m_HMixer) mixerClose(m_HMixer); } /****************************************************************************** * * Name: GetControlValue * * Description: Get value(s) from the control * * Parameters: dwResults - results from the call * * Returns: length of dwResults (aka. the number of channels) * * Notes: dwResults needs to get cleaned up by the calling program * *******************************************************************************/ DWORD MixerAPI::GetControlValue(DWORD **dwResults) { if (!m_bSuccess) return 0; m_bSuccess = FALSE; MIXERCONTROLDETAILS mxcd; MIXERCONTROLDETAILS_UNSIGNED *mxcd_u = new MIXERCONTROLDETAILS_UNSIGNED[m_dwChannels]; *dwResults = new DWORD[m_dwChannels]; mxcd.cbStruct = sizeof(mxcd); mxcd.dwControlID = m_iMixerControlID; mxcd.cChannels = m_dwChannels; mxcd.cMultipleItems = 0; mxcd.cbDetails = sizeof(mxcd_u); mxcd.paDetails = mxcd_u; mmr = mixerGetControlDetails((HMIXEROBJ)m_HMixer, &mxcd, 0L); if (MMSYSERR_NOERROR != mmr) { delete [] mxcd_u; return 0; } m_bSuccess = TRUE; for( DWORD i=0; i<m_dwChannels; i++ ) { (*dwResults)[i] = mxcd_u[i].dwValue; } /* cleanup */ delete [] mxcd_u; return m_dwChannels; } /****************************************************************************** * * Name: GetMuteValue * * Description: Get value from the mute control * * Parameters: dwResults - result from the call * * Return Value: FALSE if an error occurred, TRUE otherwise * *******************************************************************************/ BOOL MixerAPI::GetMuteValue(LONG *dwResult) { if (!m_bSuccess) return m_bSuccess; m_bSuccess = FALSE; MIXERCONTROLDETAILS mxcd; MIXERCONTROLDETAILS_BOOLEAN mxcdMute; mxcd.cbStruct = sizeof(mxcd); mxcd.dwControlID = m_iMixerControlID; mxcd.cChannels = 1; mxcd.cMultipleItems = 0; mxcd.cbDetails = sizeof(mxcdMute); mxcd.paDetails = &mxcdMute; mmr = mixerGetControlDetails((HMIXEROBJ)m_HMixer, &mxcd, 0L); if (MMSYSERR_NOERROR != mmr) return m_bSuccess; m_bSuccess = TRUE; *dwResult = mxcdMute.fValue; return m_bSuccess; } /****************************************************************************** * * Name: SetControlValue * * Description: Set value(s) of the control * * Parameters: dwData - data to send to the control * dwDataLen - length of the data * * Returns: success/failure * * Notes: if dwDataLen == 1, it will force the # of channels to be set to * 1 - this is to make mute work ( aka. On(), Off() ) * *******************************************************************************/ BOOL MixerAPI::SetControlValue(DWORD *dwData, DWORD dwDataLen) { if (!m_bSuccess) return m_bSuccess; if (dwDataLen > m_dwChannels) return m_bSuccess; m_bSuccess = FALSE; MIXERCONTROLDETAILS mxcd; MIXERCONTROLDETAILS_UNSIGNED *mxcd_u = new MIXERCONTROLDETAILS_UNSIGNED[m_dwChannels]; mxcd.cbStruct = sizeof(mxcd); mxcd.dwControlID = m_iMixerControlID; /* XXX - not sure this is always the case */ mxcd.cChannels = dwDataLen==1 ? 1 : m_dwChannels; mxcd.cMultipleItems = 0; mxcd.cbDetails = sizeof(mxcd_u); mxcd.paDetails = mxcd_u; mmr = mixerGetControlDetails((HMIXEROBJ)m_HMixer, &mxcd, 0L); if (MMSYSERR_NOERROR != mmr) goto cleanup; for( DWORD i=0; i<dwDataLen; i++ ) { mxcd_u[i].dwValue = *(dwData+i); } mmr = mixerSetControlDetails((HMIXEROBJ)m_HMixer, &mxcd, 0L); if (MMSYSERR_NOERROR != mmr) return m_bSuccess; m_bSuccess = TRUE; cleanup: /* cleanup */ delete [] mxcd_u; return m_bSuccess; } BOOL MixerAPI::On() { DWORD tmp = 0; return SetControlValue(&tmp); } BOOL MixerAPI::Off() { DWORD tmp = 1; return SetControlValue(&tmp); }
[ "julien.templier@ab80709b-eb45-0410-bb3a-633ce738720d" ]
[ [ [ 1, 303 ] ] ]
6f748cbed9750468cb961290952e30f48cccf569
4a99fa98abd0285bc3b5671f237b932114123340
/physics/BulletDynamics/ConstraintSolver/btSliderConstraint.h
80256e493f7a0af1368abeeac340b448a3140558
[]
no_license
automenta/crittergod1.5
937cd925a4ba57b3e8cfa4899a81ba24fe3e4138
4786fe9d621c0e61cdd43ca3a363bfce6510e3c0
refs/heads/master
2020-12-24T16:58:32.854270
2010-04-12T03:25:39
2010-04-12T03:25:39
520,917
1
0
null
null
null
null
UTF-8
C++
false
false
10,877
h
/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* Added by Roman Ponomarev ([email protected]) April 04, 2008 TODO: - add clamping od accumulated impulse to improve stability - add conversion for ODE constraint solver */ #ifndef SLIDER_CONSTRAINT_H #define SLIDER_CONSTRAINT_H #include "LinearMath/btVector3.h" #include "btJacobianEntry.h" #include "btTypedConstraint.h" class btRigidBody; #define SLIDER_CONSTRAINT_DEF_SOFTNESS (btScalar(1.0)) #define SLIDER_CONSTRAINT_DEF_DAMPING (btScalar(1.0)) #define SLIDER_CONSTRAINT_DEF_RESTITUTION (btScalar(0.7)) class btSliderConstraint : public btTypedConstraint { protected: ///for backwards compatibility during the transition to 'getInfo/getInfo2' bool m_useSolveConstraintObsolete; bool m_useOffsetForConstraintFrame; btTransform m_frameInA; btTransform m_frameInB; // use frameA fo define limits, if true bool m_useLinearReferenceFrameA; // linear limits btScalar m_lowerLinLimit; btScalar m_upperLinLimit; // angular limits btScalar m_lowerAngLimit; btScalar m_upperAngLimit; // softness, restitution and damping for different cases // DirLin - moving inside linear limits // LimLin - hitting linear limit // DirAng - moving inside angular limits // LimAng - hitting angular limit // OrthoLin, OrthoAng - against constraint axis btScalar m_softnessDirLin; btScalar m_restitutionDirLin; btScalar m_dampingDirLin; btScalar m_softnessDirAng; btScalar m_restitutionDirAng; btScalar m_dampingDirAng; btScalar m_softnessLimLin; btScalar m_restitutionLimLin; btScalar m_dampingLimLin; btScalar m_softnessLimAng; btScalar m_restitutionLimAng; btScalar m_dampingLimAng; btScalar m_softnessOrthoLin; btScalar m_restitutionOrthoLin; btScalar m_dampingOrthoLin; btScalar m_softnessOrthoAng; btScalar m_restitutionOrthoAng; btScalar m_dampingOrthoAng; // for interlal use bool m_solveLinLim; bool m_solveAngLim; btJacobianEntry m_jacLin[3]; btScalar m_jacLinDiagABInv[3]; btJacobianEntry m_jacAng[3]; btScalar m_timeStep; btTransform m_calculatedTransformA; btTransform m_calculatedTransformB; btVector3 m_sliderAxis; btVector3 m_realPivotAInW; btVector3 m_realPivotBInW; btVector3 m_projPivotInW; btVector3 m_delta; btVector3 m_depth; btVector3 m_relPosA; btVector3 m_relPosB; btScalar m_linPos; btScalar m_angPos; btScalar m_angDepth; btScalar m_kAngle; bool m_poweredLinMotor; btScalar m_targetLinMotorVelocity; btScalar m_maxLinMotorForce; btScalar m_accumulatedLinMotorImpulse; bool m_poweredAngMotor; btScalar m_targetAngMotorVelocity; btScalar m_maxAngMotorForce; btScalar m_accumulatedAngMotorImpulse; //------------------------ void initParams(); public: // constructors btSliderConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA); btSliderConstraint(btRigidBody& rbB, const btTransform& frameInB, bool useLinearReferenceFrameB); btSliderConstraint(); // overrides virtual void buildJacobian(); virtual void getInfo1 (btConstraintInfo1* info); void getInfo1NonVirtual(btConstraintInfo1* info); virtual void getInfo2 (btConstraintInfo2* info); void getInfo2NonVirtual(btConstraintInfo2* info, const btTransform& transA, const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB, btScalar rbAinvMass,btScalar rbBinvMass); void getInfo2NonVirtualUsingFrameOffset(btConstraintInfo2* info, const btTransform& transA, const btTransform& transB,const btVector3& linVelA,const btVector3& linVelB, btScalar rbAinvMass,btScalar rbBinvMass); virtual void solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep); // access const btRigidBody& getRigidBodyA() const { return m_rbA; } const btRigidBody& getRigidBodyB() const { return m_rbB; } const btTransform & getCalculatedTransformA() const { return m_calculatedTransformA; } const btTransform & getCalculatedTransformB() const { return m_calculatedTransformB; } const btTransform & getFrameOffsetA() const { return m_frameInA; } const btTransform & getFrameOffsetB() const { return m_frameInB; } btTransform & getFrameOffsetA() { return m_frameInA; } btTransform & getFrameOffsetB() { return m_frameInB; } btScalar getLowerLinLimit() { return m_lowerLinLimit; } void setLowerLinLimit(btScalar lowerLimit) { m_lowerLinLimit = lowerLimit; } btScalar getUpperLinLimit() { return m_upperLinLimit; } void setUpperLinLimit(btScalar upperLimit) { m_upperLinLimit = upperLimit; } btScalar getLowerAngLimit() { return m_lowerAngLimit; } void setLowerAngLimit(btScalar lowerLimit) { m_lowerAngLimit = btNormalizeAngle(lowerLimit); } btScalar getUpperAngLimit() { return m_upperAngLimit; } void setUpperAngLimit(btScalar upperLimit) { m_upperAngLimit = btNormalizeAngle(upperLimit); } bool getUseLinearReferenceFrameA() { return m_useLinearReferenceFrameA; } btScalar getSoftnessDirLin() { return m_softnessDirLin; } btScalar getRestitutionDirLin() { return m_restitutionDirLin; } btScalar getDampingDirLin() { return m_dampingDirLin ; } btScalar getSoftnessDirAng() { return m_softnessDirAng; } btScalar getRestitutionDirAng() { return m_restitutionDirAng; } btScalar getDampingDirAng() { return m_dampingDirAng; } btScalar getSoftnessLimLin() { return m_softnessLimLin; } btScalar getRestitutionLimLin() { return m_restitutionLimLin; } btScalar getDampingLimLin() { return m_dampingLimLin; } btScalar getSoftnessLimAng() { return m_softnessLimAng; } btScalar getRestitutionLimAng() { return m_restitutionLimAng; } btScalar getDampingLimAng() { return m_dampingLimAng; } btScalar getSoftnessOrthoLin() { return m_softnessOrthoLin; } btScalar getRestitutionOrthoLin() { return m_restitutionOrthoLin; } btScalar getDampingOrthoLin() { return m_dampingOrthoLin; } btScalar getSoftnessOrthoAng() { return m_softnessOrthoAng; } btScalar getRestitutionOrthoAng() { return m_restitutionOrthoAng; } btScalar getDampingOrthoAng() { return m_dampingOrthoAng; } void setSoftnessDirLin(btScalar softnessDirLin) { m_softnessDirLin = softnessDirLin; } void setRestitutionDirLin(btScalar restitutionDirLin) { m_restitutionDirLin = restitutionDirLin; } void setDampingDirLin(btScalar dampingDirLin) { m_dampingDirLin = dampingDirLin; } void setSoftnessDirAng(btScalar softnessDirAng) { m_softnessDirAng = softnessDirAng; } void setRestitutionDirAng(btScalar restitutionDirAng) { m_restitutionDirAng = restitutionDirAng; } void setDampingDirAng(btScalar dampingDirAng) { m_dampingDirAng = dampingDirAng; } void setSoftnessLimLin(btScalar softnessLimLin) { m_softnessLimLin = softnessLimLin; } void setRestitutionLimLin(btScalar restitutionLimLin) { m_restitutionLimLin = restitutionLimLin; } void setDampingLimLin(btScalar dampingLimLin) { m_dampingLimLin = dampingLimLin; } void setSoftnessLimAng(btScalar softnessLimAng) { m_softnessLimAng = softnessLimAng; } void setRestitutionLimAng(btScalar restitutionLimAng) { m_restitutionLimAng = restitutionLimAng; } void setDampingLimAng(btScalar dampingLimAng) { m_dampingLimAng = dampingLimAng; } void setSoftnessOrthoLin(btScalar softnessOrthoLin) { m_softnessOrthoLin = softnessOrthoLin; } void setRestitutionOrthoLin(btScalar restitutionOrthoLin) { m_restitutionOrthoLin = restitutionOrthoLin; } void setDampingOrthoLin(btScalar dampingOrthoLin) { m_dampingOrthoLin = dampingOrthoLin; } void setSoftnessOrthoAng(btScalar softnessOrthoAng) { m_softnessOrthoAng = softnessOrthoAng; } void setRestitutionOrthoAng(btScalar restitutionOrthoAng) { m_restitutionOrthoAng = restitutionOrthoAng; } void setDampingOrthoAng(btScalar dampingOrthoAng) { m_dampingOrthoAng = dampingOrthoAng; } void setPoweredLinMotor(bool onOff) { m_poweredLinMotor = onOff; } bool getPoweredLinMotor() { return m_poweredLinMotor; } void setTargetLinMotorVelocity(btScalar targetLinMotorVelocity) { m_targetLinMotorVelocity = targetLinMotorVelocity; } btScalar getTargetLinMotorVelocity() { return m_targetLinMotorVelocity; } void setMaxLinMotorForce(btScalar maxLinMotorForce) { m_maxLinMotorForce = maxLinMotorForce; } btScalar getMaxLinMotorForce() { return m_maxLinMotorForce; } void setPoweredAngMotor(bool onOff) { m_poweredAngMotor = onOff; } bool getPoweredAngMotor() { return m_poweredAngMotor; } void setTargetAngMotorVelocity(btScalar targetAngMotorVelocity) { m_targetAngMotorVelocity = targetAngMotorVelocity; } btScalar getTargetAngMotorVelocity() { return m_targetAngMotorVelocity; } void setMaxAngMotorForce(btScalar maxAngMotorForce) { m_maxAngMotorForce = maxAngMotorForce; } btScalar getMaxAngMotorForce() { return m_maxAngMotorForce; } btScalar getLinearPos() { return m_linPos; } // access for ODE solver bool getSolveLinLimit() { return m_solveLinLim; } btScalar getLinDepth() { return m_depth[0]; } bool getSolveAngLimit() { return m_solveAngLim; } btScalar getAngDepth() { return m_angDepth; } // internal void buildJacobianInt(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB); void solveConstraintInt(btRigidBody& rbA, btSolverBody& bodyA,btRigidBody& rbB, btSolverBody& bodyB); // shared code used by ODE solver void calculateTransforms(const btTransform& transA,const btTransform& transB); void testLinLimits(); void testAngLimits(); // access for PE Solver btVector3 getAncorInA(); btVector3 getAncorInB(); // access for UseFrameOffset bool getUseFrameOffset() { return m_useOffsetForConstraintFrame; } void setUseFrameOffset(bool frameOffsetOnOff) { m_useOffsetForConstraintFrame = frameOffsetOnOff; } }; #endif //SLIDER_CONSTRAINT_H
[ [ [ 1, 238 ] ] ]
f97a4070a434b38cb8a4fe305c2c3b19c4061688
6c8c4728e608a4badd88de181910a294be56953a
/AssetModule/TinyJson/TinyJson.h
36ad22992330b78306f345b35b5a8c0f139bb19c
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
caocao/naali
29c544e121703221fe9c90b5c20b3480442875ef
67c5aa85fa357f7aae9869215f840af4b0e58897
refs/heads/master
2021-01-21T00:25:27.447991
2010-03-22T15:04:19
2010-03-22T15:04:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,039
h
/* * TinyJson 1.3.0 * A Minimalistic JSON Reader Based On Boost.Spirit, Boost.Any, and Boost.Smart_Ptr. * * Copyright (c) 2008 Thomas Jansen ([email protected]) * * 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://blog.beef.de/projects/tinyjson/ for documentation. * * (view source with tab-size = 3) * * 29 Mar 2008 - use strict_real_p for number parsing, small cleanup (Thomas Jansen) * 26 Mar 2008 - made json::grammar a template (Boris Schaeling) * 20 Mar 2008 - optimized by using boost::shared_ptr (Thomas Jansen) * 29 Jan 2008 - Small bugfixes (Thomas Jansen) * 04 Jan 2008 - Released to the public (Thomas Jansen) * 13 Nov 2007 - initial release (Thomas Jansen) * * * 29 Mar 2008 */ #ifndef TINYJSON_HPP #define TINYJSON_HPP #include <boost/shared_ptr.hpp> #include <boost/any.hpp> // Boost recommends doing this here: but it is not compatible with this header... //#include <boost/spirit/include/classic_core.hpp> //#include <boost/spirit/include/classic_loops.hpp> #include <boost/spirit/core.hpp> #include <boost/spirit/utility/loops.hpp> #include <boost/lexical_cast.hpp> #include <string> #include <stack> #include <utility> #include <deque> #include <map> namespace json { // ========================================================================================================== // === U N I C O D E _ C O N V E R T === // ========================================================================================================== template< typename Char > struct unicodecvt { static std::basic_string< Char > convert(int iUnicode) { return std::basic_string< Char >(1, static_cast< Char >(iUnicode)); } }; // ---[ TEMPLATE SPECIALIZATION FOR CHAR ]-------------------------------------------------------------------- template<> struct unicodecvt< char > { static std::string convert(int iUnicode) { std::string strString; if(iUnicode < 0x0080) { // character 0x0000 - 0x007f... strString.push_back(0x00 | ((iUnicode & 0x007f) >> 0)); } else if(iUnicode < 0x0800) { // character 0x0080 - 0x07ff... strString.push_back(0xc0 | ((iUnicode & 0x07c0) >> 6)); strString.push_back(0x80 | ((iUnicode & 0x003f) >> 0)); } else { // character 0x0800 - 0xffff... strString.push_back(0xe0 | ((iUnicode & 0x00f000) >> 12)); strString.push_back(0x80 | ((iUnicode & 0x000fc0) >> 6)); strString.push_back(0x80 | ((iUnicode & 0x00003f) >> 0)); } return strString; } }; // ========================================================================================================== // === T H E J S O N G R A M M A R === // ========================================================================================================== template< typename Char > class grammar : public boost::spirit::grammar< grammar< Char > > { public: // ---[ TYPEDEFINITIONS ]--------------------------------------------------------------------------------- typedef boost::shared_ptr< boost::any > variant; // pointer to a shared variant typedef std::stack< variant > stack; // a stack of json variants typedef std::pair< std::basic_string< Char >, variant > pair; // a pair as it appears in json typedef std::deque< variant > array; // an array of json variants typedef std::map< std::basic_string< Char >, variant > object; // an object with json pairs protected: // ---[ SEMANTIC ACTION: PUSH A STRING ON THE STACK (AND ENCODE AS UTF-8) ]------------------------------- struct push_string { stack & m_stack; push_string(stack & stack) : m_stack(stack) { } template <typename Iterator> void operator() (Iterator szStart, Iterator szEnd) const { // 1: skip the quotes... ++szStart; --szEnd; // 2: traverse through the original string and check for escape codes.. std::basic_string< typename Iterator::value_type > strString; while(szStart < szEnd) { // 2.1: if it's no escape code, just append to the resulting string... if(*szStart != static_cast< typename Iterator::value_type >('\\')) { // 2.1.1: append the character... strString.push_back(*szStart); } else { // 2.1.2: otherwise, check the escape code... ++szStart; switch(*szStart) { default: strString.push_back(*szStart); break; case 'b': strString.push_back(static_cast< typename Iterator::value_type >('\b')); break; case 'f': strString.push_back(static_cast< typename Iterator::value_type >('\f')); break; case 'n': strString.push_back(static_cast< typename Iterator::value_type >('\n')); break; case 'r': strString.push_back(static_cast< typename Iterator::value_type >('\r')); break; case 't': strString.push_back(static_cast< typename Iterator::value_type >('\t')); break; case 'u': { // 2.1.2.1: convert the following hex value into an int... int iUnicode; std::basic_istringstream< Char >(std::basic_string< typename Iterator::value_type >(&szStart[1], 4)) >> std::hex >> iUnicode; szStart += 4; // 2.1.2.2: append the unicode int... strString.append(unicodecvt< typename Iterator::value_type >::convert(iUnicode)); } } } // 2.2: go on with the next character... ++szStart; } // 3: finally, push the string on the stack... m_stack.push(variant(new boost::any(strString))); } }; // ---[ SEMANTIC ACTION: PUSH A REAL ON THE STACK ]------------------------------------------------------- struct push_double { stack & m_stack; push_double(stack & stack) : m_stack(stack) { } void operator() (double dValue) const { m_stack.push(variant(new boost::any(dValue))); } }; // ---[ SEMANTIC ACTION: PUSH AN INT ON THE STACK ]------------------------------------------------------- struct push_int { stack & m_stack; push_int(stack & stack) : m_stack(stack) { } void operator() (int iValue) const { m_stack.push(variant(new boost::any(iValue))); } }; // ---[ SEMANTIC ACTION: PUSH A BOOLEAN ON THE STACK ]---------------------------------------------------- struct push_boolean { stack & m_stack; push_boolean(stack & stack) : m_stack(stack) { } template <typename Iterator> void operator() (Iterator szStart, Iterator /* szEnd */ ) const { // 1: push a boolean that is "true" if the string starts with 't' and "false" otherwise... m_stack.push(variant(new boost::any(*szStart == static_cast< typename Iterator::value_type >('t')))); } }; // ---[ SEMANTIC ACTION: PUSH A NULL VALUE ON THE STACK ]------------------------------------------------- struct push_null { stack & m_stack; push_null(stack & stack) : m_stack(stack) { } template <typename Iterator> void operator() (Iterator /* szStart */ , Iterator /* szEnd */ ) const { m_stack.push(variant(new boost::any())); } }; // ---[ SEMANTIC ACTION: CREATE A "JSON PAIR" ON THE STACK ]---------------------------------------------- struct create_pair { stack & m_stack; create_pair(stack & stack) : m_stack(stack) { } template <typename Iterator> void operator() (Iterator /* szStart */, Iterator /* szEnd */ ) const { // 1: get the variant from the stack... variant var = m_stack.top(); m_stack.pop(); // 2: get the name from the stack... std::basic_string< typename Iterator::value_type > strName; try { strName = boost::any_cast< std::basic_string< typename Iterator::value_type > >(*m_stack.top()); } catch(boost::bad_any_cast &) { /* NOTHING */ } m_stack.pop(); // 3: push a pair of both on the stack... m_stack.push(variant(new boost::any(pair(strName, var)))); } }; // ---[ SEMANTIC ACTION: BEGIN AN ARRAY ]----------------------------------------------------------------- class array_delimiter { /* EMPTY CLASS */ }; struct begin_array { stack & m_stack; begin_array(stack & stack) : m_stack(stack) { } template <typename Iterator> void operator() (Iterator /* cCharacter */) const { m_stack.push(variant(new boost::any(array_delimiter()))); } }; // ---[ SEMANTIC ACTION: CREATE AN ARRAY FROM THE VALUES ON THE STACK ]----------------------------------- struct end_array { stack & m_stack; end_array(stack & stack) : m_stack(stack) { } // - -[ functional operator ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template <typename Iterator> void operator() (Iterator /* cCharacter */) const { // 1: create an array object and push everything in it, that's on the stack... variant varArray(new boost::any(array())); while(!m_stack.empty()) { // 1.1: get the top most variant of the stack... variant var = m_stack.top(); m_stack.pop(); // 1.2: is it the end of the array? if yes => break the loop... if(boost::any_cast< array_delimiter >(var.get()) != NULL) { break; } // 1.3: otherwise, add to the array... boost::any_cast< array >(varArray.get())->push_front(var); } // 2: finally, push the array at the end of the stack... m_stack.push(varArray); } }; // ---[ SEMANTIC ACTION: BEGIN AN OBJECT ]---------------------------------------------------------------- class object_delimiter { /* EMPTY CLASS */ }; struct begin_object { stack & m_stack; begin_object(stack & stack) : m_stack(stack) { } template <typename Iterator> void operator() (Iterator /* cCharacter */) const { m_stack.push(variant(new boost::any(object_delimiter()))); } }; // ---[ SEMANTIC ACTION: CREATE AN OBJECT FROM THE VALUES ON THE STACK ]---------------------------------- struct end_object { stack & m_stack; end_object(stack & stack) : m_stack(stack) { } template <typename Iterator> void operator() (Iterator /* cCharacter */) const { // 1: create an array object and push everything in it, that's on the stack... variant varObject(new boost::any(object())); while(!m_stack.empty()) { // 1.1: get the top most variant of the stack... variant var = m_stack.top(); m_stack.pop(); // 1.2: is it the end of the array? if yes => break the loop... if(boost::any_cast< object_delimiter >(var.get()) != NULL) { break; } // 1.3: if this is not a pair, we have a problem... pair * pPair = boost::any_cast< pair >(var.get()); if(!pPair) { /* BIG PROBLEM!! */ continue; } // 1.4: set the child of this object... boost::any_cast< object >(varObject.get())->insert(std::make_pair(pPair->first, pPair->second)); } // 2: finally, push the array at the end of the stack... m_stack.push(varObject); } }; public: stack & m_stack; grammar(stack & stack) : m_stack(stack) { } // ---[ THE ACTUAL GRAMMAR DEFINITION ]------------------------------------------------------------------- template <typename SCANNER> class definition { boost::spirit::rule< SCANNER > m_object; boost::spirit::rule< SCANNER > m_array; boost::spirit::rule< SCANNER > m_pair; boost::spirit::rule< SCANNER > m_value; boost::spirit::rule< SCANNER > m_string; boost::spirit::rule< SCANNER > m_number; boost::spirit::rule< SCANNER > m_boolean; boost::spirit::rule< SCANNER > m_null; public: boost::spirit::rule< SCANNER > const & start() const { return m_object; } // - -[ create the definition ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - definition(grammar const & self) { using namespace boost::spirit; // 1: an object is an unordered set of pairs (seperated by commas)... m_object = ch_p('{') [ begin_object(self.m_stack) ] >> !(m_pair >> *(ch_p(',') >> m_pair)) >> ch_p('}') [ end_object (self.m_stack) ]; // 2: an array is an ordered collection of values (seperated by commas)... m_array = ch_p('[') [ begin_array(self.m_stack) ] >> !(m_value >> *(ch_p(',') >> m_value)) >> ch_p(']') [ end_array (self.m_stack) ]; // 3: a pair is given by a name and a value... m_pair = ( m_string >> ch_p(':') >> m_value ) [ create_pair(self.m_stack) ] ; // 4: a value can be a string in double quotes, a number, a boolean, an object or an array. m_value = m_string | m_number | m_object | m_array | m_boolean | m_null ; // 5: a string is a collection of zero or more unicode characters, wrapped in double quotes... m_string = lexeme_d [ ( ch_p('"') >> *( ( (anychar_p - (ch_p('"') | ch_p('\\'))) | ch_p('\\') >> ( ch_p('\"') | ch_p('\\') | ch_p('/') | ch_p('b') | ch_p('f') | ch_p('n') | ch_p('r') | ch_p('t') | (ch_p('u') >> repeat_p(4)[ xdigit_p ]) ) )) >> ch_p('"') ) [ push_string(self.m_stack) ] ] ; // 6: a number is very much like a C or java number... m_number = strict_real_p [ push_double(self.m_stack) ] | int_p [ push_int (self.m_stack) ] ; // 7: a boolean can be "true" or "false"... m_boolean = ( str_p("true") | str_p("false") ) [ push_boolean(self.m_stack) ] ; // 8: finally, a value also can be a 'null', i.e. an empty item... m_null = str_p("null") [ push_null(self.m_stack) ] ; } }; }; // ========================================================================================================== // === T H E F I N A L P A R S I N G R O U T I N E === // ========================================================================================================== template <typename Iterator> typename json::grammar< typename Iterator::value_type >::variant parse(Iterator const & szFirst, Iterator const & szEnd) { // 1: parse the input... typename json::grammar< typename Iterator::value_type >::stack st; json::grammar< typename Iterator::value_type > gr(st); boost::spirit::parse_info<Iterator> pi = boost::spirit::parse(szFirst, szEnd, gr, boost::spirit::space_p); // 2: skip any spaces at the end of the parsed section... while((pi.stop != szEnd) && (*pi.stop == static_cast< typename Iterator::value_type >(' '))) { ++pi.stop; } // 3: if the input's end wasn't reached or if there is more than one object on the stack => cancel... if((pi.stop != szEnd) || (st.size() != 1)) { typename json::grammar< typename Iterator::value_type >::variant result (new boost::any()); return result; } // 4: otherwise, return the result... return st.top(); } }; #endif // TINYJSON_HPP
[ "tuoki@5b2332b8-efa3-11de-8684-7d64432d61a3", "jujjyl@5b2332b8-efa3-11de-8684-7d64432d61a3" ]
[ [ [ 1, 29 ], [ 34, 580 ] ], [ [ 30, 33 ] ] ]
f25b58663b10e7f3c78b76487e7a1bc027a30b1c
da48afcbd478f79d70767170da625b5f206baf9a
/tbmessage/src/SearchPage.h
b086b5ad4f60a35fd25dc38185cd6ab16ae1c1bd
[]
no_license
haokeyy/fahister
5ba50a99420dbaba2ad4e5ab5ee3ab0756563d04
c71dc56a30b862cc4199126d78f928fce11b12e5
refs/heads/master
2021-01-10T19:09:22.227340
2010-05-06T13:17:35
2010-05-06T13:17:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
882
h
#pragma once #include "afxwin.h" #include "MemberSearch.h" // CSearchPage dialog class CSearchPage : public CDialog { DECLARE_DYNAMIC(CSearchPage) public: CSearchPage(CWnd* pParent = NULL); // standard constructor virtual ~CSearchPage(); // Dialog Data enum { IDD = IDD_SEARCH_VIEW }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual BOOL OnInitDialog(); DECLARE_MESSAGE_MAP() public: CComboBox m_CmbCategory; CComboBox m_CmbLocation; CMemberSearch *m_pMemberSearch; CString szTaobaoSearchUrl; void InitCategory(); void InitLocation(); int m_nFoundCount; CString m_szSearchUrl; afx_msg LRESULT OnFoundMember(WPARAM wParam, LPARAM lParam); afx_msg void OnBnClickedBtnSearch(); afx_msg void OnBnClickedBtnDistinct(); };
[ "[email protected]@d41c10be-1f87-11de-a78b-a7aca27b2395" ]
[ [ [ 1, 41 ] ] ]
99c11ea09cfaef1067e45361432df013a7fe7c14
c714d315df7783d97c495e2745866035dfaf8f89
/test2/main1.cpp
0426ee81ee25e4e214bf4107a131509ab842b0c8
[]
no_license
derekja/uvic-seng466-2010
e2fb51e86ffb472f88d8acac03251e36e79f1827
c54e2f2042318392ffda12627878d7afe4501998
refs/heads/master
2016-09-05T21:38:52.887956
2010-01-27T00:07:36
2010-01-27T00:07:36
32,115,127
0
0
null
null
null
null
UTF-8
C++
false
false
3,391
cpp
/* * main.cpp * * Created on: 9-Jan-2010 * Author: nrqm * * This example program sets up the radio, then builds a data packet and transmits it. * The program waits for the packet to be transmitted, then turns on the LED. The * return value of Radio_Transmit isn't checked here; it will tell you if the * transmission succeeded or failed, which might be useful in your projects (note: * the function doesn't have the right return type, see the RADIO_TX_STATUS enumeration * in radio.h for the correct values). * * The radio should be connected as follows: * * Radio Seeeduino * Vcc 48 * CE 8 * CSN 7 * SCK 52 * MOSI 51 * MISO 50 * IRQ 2 * GND GND * * If you don't like the CE and CSN pins way off on the other side of the board then * you can change them to another digital I/O port (they're defined at the top of * radio.cpp). The IRQ pin can be moved to another interrupt pin (see online docs * for attachInterrupt function; also the interrupt number is hardcoded in the driver * because I'm irresponsible). */ #include "radio/radio.h" #include "radio/packet.h" #include "WProgram.h" extern "C" void __cxa_pure_virtual(void); void __cxa_pure_virtual(void) {} uint8_t rx_addr[RADIO_ADDRESS_LENGTH] = { 0x12, 0x34, 0x56, 0x78, 0x90 }; uint8_t tx_addr[RADIO_ADDRESS_LENGTH] = { 0x98, 0x76, 0x54, 0x32, 0x10 }; radiopacket_t packet; int main() { init(); Serial.begin(57600); // Blink the LED once to indicate that the program has started (this step is useless). pinMode(13, OUTPUT); pinMode(48, OUTPUT); digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); digitalWrite(48, LOW); delay(50); digitalWrite(48, HIGH); // Initialize the SPI connection, configure the I/O pins, and set the register defaults Radio_Init(); // Configure pipe 0 as a receiver. Pipe 0 has to be enabled for the radio's link layer // protocol to work. This line shouldn't be necessary since pipe 0 is enabled by // default, but it's nice to be explicit. Radio_Configure_Rx(RADIO_PIPE_0, rx_addr, ENABLE); // Configure the radio's data rate (must match the other radio) and the broadcast power Radio_Configure(RADIO_2MBPS, RADIO_HIGHEST_POWER); // set the address to send to, dangling prepositions be damned. Radio_Set_Tx_Addr(tx_addr); // give the packet type MESSAGE and populate the message type's data fields packet.type = MESSAGE; // The message type contains a return address. In this demo the receiver doesn't // send anything back, so thie address field isn't used (but it's set here anyway). memcpy(packet.payload.message.address, rx_addr, RADIO_ADDRESS_LENGTH); packet.payload.message.messageid = 41; snprintf((char*)packet.payload.message.messagecontent, 20, "xazzy"); // Send the packet to the address specified with Radio_Set_Tx_Addr above. Radio_Transmit(&packet, RADIO_WAIT_FOR_TX); // Indicate that the transmit function returned. If the LED doesn't light up then the // Seeeduino probably didn't get the interrupt from the radio for some reason. digitalWrite(13, HIGH); // main() should never return, even if the program has completed. for (;;); return 0; } void radio_rxhandler(uint8_t pipenumber) { // this station doesn't receive anything. }
[ "derekja@5231ca88-fc88-11de-9b1c-9fe8246cf834" ]
[ [ [ 1, 99 ] ] ]
3c32230827cbeb1876322471dcf8a541b76c1900
14e30c5f520f0ed28117914101d9bdf2f3d5dac7
/project/source/renderer/renderer.cpp
3617574c0f619ada6a3240b216631c277b9d2ba6
[]
no_license
danielePiracci/arlight
f356eb5a162d0cd62a759720cbc6da41a820642f
15a68c4c80c97f2fe7458e7ddf03f3e1063e25a4
refs/heads/master
2016-08-11T13:45:35.252916
2011-01-24T20:22:50
2011-01-24T20:22:50
44,962,821
0
0
null
null
null
null
UTF-8
C++
false
false
393
cpp
/// \file renderer/renderer.cpp /// \author Juan Carlos De Abreu ([email protected]) /// \date 2009/11/07 /// \version 1.0 /// /// \brief This file implements the DissertationProject::Renderer class, /// declared at renderer/renderer.h. #include "renderer/renderer.h" BEGIN_PROJECT_NAMESPACE(); Renderer::Renderer() { } Renderer::~Renderer() { } END_PROJECT_NAMESPACE();
[ "jcabreur@db05138c-34b8-7cfb-67b9-2db12d2e1ab0" ]
[ [ [ 1, 16 ] ] ]
a12c1da361ae6bfb24927ba90ed812de9ed70dcc
f9351a01f0e2dec478e5b60c6ec6445dcd1421ec
/itl/src/itl/functors.hpp
5fd8f9e061212ea58a9eee02fdb1afa547fb7af0
[ "BSL-1.0" ]
permissive
WolfgangSt/itl
e43ed68933f554c952ddfadefef0e466612f542c
6609324171a96565cabcf755154ed81943f07d36
refs/heads/master
2016-09-05T20:35:36.628316
2008-11-04T11:44:44
2008-11-04T11:44:44
327,076
0
1
null
null
null
null
UTF-8
C++
false
false
6,119
hpp
/*----------------------------------------------------------------------------+ Copyright (c) 2007-2008: Joachim Faulhaber +-----------------------------------------------------------------------------+ Boost Software License - Version 1.0 - August 17th, 2003 Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +----------------------------------------------------------------------------*/ #ifndef __itl_functors_H_JOFA_080315__ #define __itl_functors_H_JOFA_080315__ #include <itl/itl_value.hpp> namespace itl { // ------------------------------------------------------------------------ template <typename Type> struct neutron { inline Type operator()()const { return Type(); } }; template<> inline std::string unary_template<neutron>::to_string() { return "0"; } // ------------------------------------------------------------------------ template <typename Type> struct inplace_identity { void operator()(Type& object, const Type& operand)const{} }; template<> inline std::string unary_template<inplace_identity>::to_string() { return "i="; } // ------------------------------------------------------------------------ template <typename Type> struct inplace_erasure { void operator()(Type& object, const Type& operand)const { if(object == operand) object = Type(); //object -= operand; } }; template<> inline std::string unary_template<inplace_erasure>::to_string() { return "0="; } // ------------------------------------------------------------------------ template <typename Type> struct inplace_plus { typedef Type type; void operator()(Type& object, const Type& operand)const { object += operand; } static void complement(Type& object, const Type& operand) { object -= operand; } }; template<> inline std::string unary_template<inplace_plus>::to_string() { return "+="; } // ------------------------------------------------------------------------ template <typename Type> struct inplace_minus { typedef Type type; void operator()(Type& object, const Type& operand)const { object -= operand; } static void complement(Type& object, const Type& operand) { object += operand; } }; template<> inline std::string unary_template<inplace_minus>::to_string() { return "-="; } // ------------------------------------------------------------------------ template <typename Type> struct inserter { void operator()(Type& object, const Type& operand)const { insert(object,operand); } }; template<> inline std::string unary_template<inserter>::to_string() { return "ins="; } // ------------------------------------------------------------------------ template <typename Type> struct eraser { void operator()(Type& object, const Type& operand)const { erase(object,operand); } }; template<> inline std::string unary_template<eraser>::to_string() { return "ers="; } // ------------------------------------------------------------------------ template <typename Type> struct inplace_star { void operator()(Type& object, const Type& operand)const { object *= operand; } }; template<> inline std::string unary_template<inplace_star>::to_string() { return "*="; } // ------------------------------------------------------------------------ template <typename Type> struct inplace_max { void operator()(Type& object, const Type& operand)const { if(object < operand) object = operand; } }; template<> inline std::string unary_template<inplace_max>::to_string() { return "max="; } // ------------------------------------------------------------------------ template <typename Type> struct inplace_min { void operator()(Type& object, const Type& operand)const { if(object > operand) object = operand; } }; template<> inline std::string unary_template<inplace_min>::to_string() { return "min="; } // ------------------------------------------------------------------------ template<template<class>class InplaceBinaryOp, class Type> struct complement { void operator()(typename InplaceBinaryOp<Type>::type& object, const typename InplaceBinaryOp<Type>::type& operand) { return InplaceBinaryOp<Type>::complement(object, operand); } }; } // namespace itl #endif
[ "jofaber@6b8beb3d-354a-0410-8f2b-82c74c7fef9a" ]
[ [ [ 1, 170 ] ] ]
e5f48b886d6ec8e11e6518d934e740a8e38e0476
28ba648bc8e18d3ad3878885ad39a05ebfb9259c
/CGWorkOpenGL/Light.h
cd145c6bc2134632c3e75b40cec0e46adf1f4e85
[]
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
1,090
h
#pragma once typedef enum { LIGHT_ID_AMBIENT=-1, LIGHT_ID_1=0, LIGHT_ID_2, LIGHT_ID_3, LIGHT_ID_4, LIGHT_ID_5, LIGHT_ID_6, LIGHT_ID_7, LIGHT_ID_8, MAX_LIGHT } LightID; typedef enum { LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_POINT, LIGHT_TYPE_SPOT } LightType; typedef enum { LIGHT_SPACE_VIEW, LIGHT_SPACE_LOCAL } LightSpace; class LightParams { public: //light enabled bool enabled; //type directional,point,spot LightType type; //local or view space LightSpace space; //color 0-255 RGB int colorR; int colorG; int colorB; //position double posX; double posY; double posZ; //direction double dirX; double dirY; double dirZ; LightParams() { reset(); } void reset(){ enabled = false; type = LIGHT_TYPE_POINT; space = LIGHT_SPACE_VIEW; colorR = colorG = colorB = 255; posX = posY = posZ = 3; dirX = dirY = 0; dirZ = -1; } protected: private: };
[ "slavak@2ff579a8-b8b1-c11a-477f-bc6c74f83876", "hanashubin@2ff579a8-b8b1-c11a-477f-bc6c74f83876" ]
[ [ [ 1, 56 ], [ 71, 74 ] ], [ [ 57, 70 ] ] ]
5ad081b857df6b1a11a20317fdf558ed5c2cce6e
c70941413b8f7bf90173533115c148411c868bad
/plugins/SwfPlugin/include/vtxswfStructureParser.h
3fd261799cc600885ebbb528255f290c0032650a
[]
no_license
cnsuhao/vektrix
ac6e028dca066aad4f942b8d9eb73665853fbbbe
9b8c5fa7119ff7f3dc80fb05b7cdba335cf02c1a
refs/heads/master
2021-06-23T11:28:34.907098
2011-03-27T17:39:37
2011-03-27T17:39:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,721
h
/* ----------------------------------------------------------------------------- This source file is part of "vektrix" (the rich media and vector graphics rendering library) For the latest info, see http://www.fuse-software.com/ Copyright (c) 2009-2010 Fuse-Software (tm) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------------- */ #ifndef __vtxswfStructureParser_H__ #define __vtxswfStructureParser_H__ #include "vtxswf.h" #include "vtxswfParserTypes.h" namespace vtx { namespace swf { //----------------------------------------------------------------------- class StructureParser { public: StructureParser(SwfParser* parser); virtual ~StructureParser(); void handleDefineButton2(); void handleDefineSprite(); void handlePlaceObject(const uint& tag_start, const UI32& length); void handlePlaceObject2(); void handleRemoveObject2(); void handleShowFrame(); void handleEnd(); void handleDefineScalingGrid(); void handleDoABC(const TagTypes& tag_type, const uint& tag_length, SwfParser* parser); void handleSymbolClass(const TagTypes& tag_type, const uint& tag_length, SwfParser* parser); bool isParsingMovieClip() const; protected: SwfParser* mParser; // movieclips uint mMovieClipFrameIndex; MovieClipResource* mCurrentMovieClip; Timeline* mMovieClipTimeline; Keyframe* mMovieClipKeyframe; // main movieclip uint mMainFrameIndex; MovieClipResource* mMainMovieClip; Timeline* mMainTimeline; Keyframe* mMainKeyframe; Keyframe* mCurrKeyframe; }; //----------------------------------------------------------------------- }} #endif
[ "stonecold_@9773a11d-1121-4470-82d2-da89bd4a628a" ]
[ [ [ 1, 78 ] ] ]
7cf6983691eaff1a8f6c594ae70ea45adb4177fa
2e6bb5ab6f8ad09f30785c386ce5ac66258df252
/project/HappyHunter/Core/ParticleSystem.cpp
275cb47f457c3396691b04574f2e886de09b3c39
[]
no_license
linfuqing/happyhunter
961061f84947a91256980708357b583c6ad2c492
df38d8a0872b3fd2ea0e1545de3ed98434c12c5e
refs/heads/master
2016-09-06T04:00:30.779303
2010-08-26T15:41:09
2010-08-26T15:41:09
34,051,578
0
0
null
null
null
null
UTF-8
C++
false
false
121
cpp
#include "StdAfx.h" #include "ParticleSystem.h" #include "Camera.h" #include "basicutils.h" using namespace zerO;
[ "linfuqing0@c6a4b443-94a6-74e8-d042-0855a5ab0aac" ]
[ [ [ 1, 6 ] ] ]
7450a5450f68e93219d0b09c196eafc1c5f7f7e0
e1bad5dd96351610f5771becc9334523bb005b8a
/complexite-Ex5/Arc.h
0c05731bec9d0ab60406689462a0f90c80e1c35b
[]
no_license
SuzanneSoy/2010-m1s1-complexite
2dd2f2ea3832752b4ec38f74d08ab3dcc717ee3b
9fbb0236481db38f636c54154c87ecd78f75adfb
refs/heads/master
2021-10-11T02:26:34.380721
2011-01-04T12:39:17
2011-01-04T12:39:17
null
0
0
null
null
null
null
ISO-8859-2
C++
false
false
1,110
h
#ifndef ARC_H_INCLUDED #define ARC_H_INCLUDED #include <iostream> #include <vector> using namespace std; class Arc { private : unsigned int a; // Somment de départ unsigned int b; // Sommet d'arrivé. unsigned int capacite; // Capacité de l'arc. unsigned int flot; // Flot circulant dans l'arc. bool arcRetour; // Vrai si arc retour, faux sinon public : Arc(unsigned int a, unsigned int b, unsigned int c, unsigned int f); Arc(const Arc*); ~Arc(); void setS1(unsigned int val); unsigned int getS1() const; void setS2(unsigned int val); unsigned int getS2() const; void setFlot(unsigned int val); unsigned int getFlot() const; void setCapacite(unsigned int val); unsigned int getCapacite() const; bool getArcRetour(); void setArcRetour(bool); void afficheArc(); }; // Liste d'arcs sans classement par sommets. typedef vector<Arc*> listeArcs_t; #endif // ARC_H_INCLUDED
[ [ [ 1, 39 ] ] ]