blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 5
146
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
7
| license_type
stringclasses 2
values | repo_name
stringlengths 6
79
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 4
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.07k
426M
⌀ | star_events_count
int64 0
27
| fork_events_count
int64 0
12
| gha_license_id
stringclasses 3
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 6
values | src_encoding
stringclasses 26
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 1
class | length_bytes
int64 20
6.28M
| extension
stringclasses 20
values | content
stringlengths 20
6.28M
| authors
listlengths 1
16
| author_lines
listlengths 1
16
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
33cd4415710b9f72776abf6f28def69aab7e6ced | 6477cf9ac119fe17d2c410ff3d8da60656179e3b | /Projects/openredalert/src/ui/SidebarError.cpp | 5b6e5b5e878df80333ec4308e617bb29b2705a55 | []
| no_license | crutchwalkfactory/motocakerteam | 1cce9f850d2c84faebfc87d0adbfdd23472d9f08 | 0747624a575fb41db53506379692973e5998f8fe | refs/heads/master | 2021-01-10T12:41:59.321840 | 2010-12-13T18:19:27 | 2010-12-13T18:19:27 | 46,494,539 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 914 | cpp | // SidebarError.h
// 1.0
// This file is part of OpenRedAlert.
//
// OpenRedAlert 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, version 2 of the License.
//
// OpenRedAlert 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 OpenRedAlert. If not, see <http://www.gnu.org/licenses/>.
#include "SidebarError.h"
#include <string>
#include <stdexcept>
using std::string;
using std::runtime_error;
SidebarError::SidebarError(const string& msg) :
std::runtime_error(msg)
{
}
| [
"[email protected]"
]
| [
[
[
1,
29
]
]
]
|
8db508a8461c870d6c3ab61f09be38278dccdb02 | 5ac13fa1746046451f1989b5b8734f40d6445322 | /minimangalore/Nebula2/code/contrib/nopende/src/opende/nopendecapsulegeom_main.cc | 8ebbf5df7702bf4dedbe12febbd42422eba88275 | []
| 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 | 1,910 | cc | //----------------------------------------------------------------------------
// (c) 2004 Vadim Macagon
//----------------------------------------------------------------------------
#include "opende/nopendecapsulegeom.h"
nNebulaScriptClass(nOpendeCapsuleGeom, "nopendegeom");
//----------------------------------------------------------------------------
/**
*/
nOpendeCapsuleGeom::nOpendeCapsuleGeom()
{
// empty
}
//----------------------------------------------------------------------------
/**
*/
void nOpendeCapsuleGeom::Create( const char* space )
{
nOpendeGeom::Create( space );
this->geomId = nOpende::CreateCCylinder( this->getSpace(), 1, 1 );
}
//----------------------------------------------------------------------------
/**
*/
nOpendeCapsuleGeom::~nOpendeCapsuleGeom()
{
// empty
}
//----------------------------------------------------------------------------
/**
*/
void nOpendeCapsuleGeom::SetParams( float radius, float length )
{
n_assert( this->id() && "nOpendeCapsuleGeom::id not valid!" );
nOpende::GeomCCylinderSetParams( this->id(), radius, length );
}
//----------------------------------------------------------------------------
/**
*/
void nOpendeCapsuleGeom::GetParams( float* radius, float* length )
{
n_assert( this->id() && "nOpendeCapsuleGeom::id not valid!" );
nOpende::GeomCCylinderGetParams( this->id(), radius, length );
}
//----------------------------------------------------------------------------
/**
*/
float nOpendeCapsuleGeom::PointDepth( const vector3& p )
{
n_assert( this->id() && "nOpendeCapsuleGeom::id not valid!" );
return nOpende::GeomCCylinderPointDepth( this->id(), p );
}
//----------------------------------------------------------------------------
// EOF
//----------------------------------------------------------------------------
| [
"BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c"
]
| [
[
[
1,
62
]
]
]
|
8fb6ebe09c86be52bfdc94ab00b856372a253c80 | d7910157c6f2b58f159ec8dc2634e0acfe6d678e | /qtdemo/mainwindow.cpp | 37c264f284820935dc1fef1aa5121a9f749c0a9c | []
| no_license | TheProjecter/qtdemo-plugin | 7699b19242aacea9c5b2c741e615e6b1e62c6c11 | 4db5ffe7e8607e01686117820ce1fcafb72eb311 | refs/heads/master | 2021-01-19T06:30:22.017229 | 2010-02-05T06:36:25 | 2010-02-05T06:36:25 | 43,904,026 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,720 | cpp | /****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation ([email protected])
**
** This file is part of the demonstration applications 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.1, 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 have questions regarding the use of this file, please contact
** Nokia at [email protected].
** $QT_END_LICENSE$
**
****************************************************************************/
#include "mainwindow.h"
#include "menumanager.h"
#include "colors.h"
#include "dockitem.h"
#include "demotextitem.h"
#include "imageitem.h"
#include "demoitem.h"
#include "demoscene.h"
#ifndef QT_NO_OPENGL
#include <QGLWidget>
#endif
//#define QT_NO_OPENGL
MainWindow::MainWindow(QWidget *parent) : QGraphicsView(parent), updateTimer(this)
{
this->currentFps = Colors::fps;
this->loop = false;
this->fpsMedian = -1;
this->fpsLabel = 0;
this->pausedLabel = 0;
this->doneAdapt = false;
this->useTimer = false;
this->updateTimer.setSingleShot(true);
this->companyLogo = 0;
this->qtLogo = 0;
this->setupWidget();
this->setupScene();
this->setupSceneItems();
this->drawBackgroundToPixmap();
}
MainWindow::~MainWindow()
{
delete this->companyLogo;
delete this->qtLogo;
}
void MainWindow::setupWidget()
{
QRect screenRect = QApplication::desktop()->screenGeometry(QApplication::desktop()->primaryScreen());
QRect windowRect(0, 0, 800, 600);
if (screenRect.width() < 800)
windowRect.setWidth(screenRect.width());
if (screenRect.height() < 600)
windowRect.setHeight(screenRect.height());
windowRect.moveCenter(screenRect.center());
this->setGeometry(windowRect);
this->setMinimumSize(80, 60);
setWindowTitle(tr("Qt Examples and Demos"));
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setFrameStyle(QFrame::NoFrame);
this->setRenderingSystem();
connect(&this->updateTimer, SIGNAL(timeout()), this, SLOT(tick()));
}
void MainWindow::setRenderingSystem()
{
QWidget *viewport = 0;
#ifndef QT_NO_OPENGL
if (Colors::openGlRendering) {
QGLWidget *glw = new QGLWidget(QGLFormat(QGL::SampleBuffers));
if (Colors::noScreenSync)
glw->format().setSwapInterval(0);
glw->setAutoFillBackground(false);
viewport = glw;
setCacheMode(QGraphicsView::CacheNone);
if (Colors::verbose)
qDebug() << "- using OpenGL";
} else // software rendering
#endif
{
// software rendering
viewport = new QWidget;
setCacheMode(QGraphicsView::CacheBackground);
if (Colors::verbose)
qDebug() << "- using software rendering";
}
setViewport(viewport);
}
void MainWindow::start()
{
this->switchTimerOnOff(true);
this->demoStartTime.restart();
MenuManager::instance()->itemSelected(MenuManager::ROOT, Colors::rootMenuName);
if (Colors::verbose)
qDebug("- starting demo");
}
void MainWindow::enableMask(bool enable)
{
if (!enable || Colors::noWindowMask)
this->clearMask();
else {
QPolygon region;
region.setPoints(9,
// north side:
0, 0,
800, 0,
// east side:
// 800, 70,
// 790, 90,
// 790, 480,
// 800, 500,
800, 600,
// south side:
700, 600,
670, 590,
130, 590,
100, 600,
0, 600,
// west side:
// 0, 550,
// 10, 530,
// 10, 520,
// 0, 520,
0, 0);
this->setMask(QRegion(region));
}
}
void MainWindow::setupScene()
{
this->scene = new DemoScene(this);
this->scene->setSceneRect(0, 0, 800, 600);
setScene(this->scene);
this->scene->setItemIndexMethod(QGraphicsScene::NoIndex);
}
void MainWindow::drawItems(QPainter *painter, int numItems, QGraphicsItem **items, const QStyleOptionGraphicsItem* options)
{
QGraphicsView::drawItems(painter, numItems, items, options);
}
void MainWindow::switchTimerOnOff(bool on)
{
bool ticker = MenuManager::instance()->ticker && MenuManager::instance()->ticker->scene();
if (ticker)
MenuManager::instance()->ticker->tickOnPaint = !on || Colors::noTimerUpdate;
if (on && !Colors::noTimerUpdate){
this->useTimer = true;
this->setViewportUpdateMode(QGraphicsView::NoViewportUpdate);
this->fpsTime = QTime::currentTime();
this->updateTimer.start(int(1000 / Colors::fps));
}
else{
this->useTimer = false;
this->updateTimer.stop();
if (Colors::softwareRendering)
if (Colors::noTicker)
this->setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
else
this->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
else
this->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
}
}
bool MainWindow::measureFps()
{
// Calculate time diff:
float t = this->fpsTime.msecsTo(QTime::currentTime());
if (t == 0)
t = 0.01f;
this->currentFps = (1000.0f / t);
this->fpsHistory += this->currentFps;
this->fpsTime = QTime::currentTime();
// Calculate median:
int size = this->fpsHistory.size();
if (size == 10){
qSort(this->fpsHistory.begin(), this->fpsHistory.end());
this->fpsMedian = this->fpsHistory.at(int(size/2));
if (this->fpsMedian == 0)
this->fpsMedian = 0.01f;
this->fpsHistory.clear();
return true;
}
return false;
}
/**
Used for adaption in case things are so slow
that no median yet has been calculated
*/
void MainWindow::forceFpsMedianCalculation()
{
if (this->fpsMedian != -1)
return;
int size = this->fpsHistory.size();
if (size == 0){
this->fpsMedian = 0.01f;
return;
}
qSort(this->fpsHistory.begin(), this->fpsHistory.end());
this->fpsMedian = this->fpsHistory.at(int(size/2));
if (this->fpsMedian == 0)
this->fpsMedian = 0.01f;
}
void MainWindow::tick()
{
bool medianChanged = this->measureFps();
this->checkAdapt();
if (medianChanged && this->fpsLabel && Colors::showFps)
this->fpsLabel->setText(QString("FPS: ") + QString::number(int(this->currentFps)));
if (MenuManager::instance()->ticker)
MenuManager::instance()->ticker->tick();
this->viewport()->update();
if (this->useTimer)
this->updateTimer.start(int(1000 / Colors::fps));
}
void MainWindow::setupSceneItems()
{
if (Colors::showFps){
this->fpsLabel = new DemoTextItem(QString("FPS: --"), Colors::buttonFont(), Qt::white, -1, this->scene, 0, DemoTextItem::DYNAMIC_TEXT);
this->fpsLabel->setZValue(100);
this->fpsLabel->setPos(Colors::stageStartX, 600 - QFontMetricsF(Colors::buttonFont()).height() - 5);
}
this->companyLogo = new ImageItem(QImage(":/images/trolltech-logo.png"), 1000, 1000, this->scene, 0, true, 0.5f);
this->qtLogo = new ImageItem(QImage(":/images/qtlogo_small.png"), 1000, 1000, this->scene, 0, true, 0.5f);
this->companyLogo->setZValue(100);
this->qtLogo->setZValue(100);
this->pausedLabel = new DemoTextItem(QString("PAUSED"), Colors::buttonFont(), Qt::white, -1, this->scene, 0);
this->pausedLabel->setZValue(100);
QFontMetricsF fm(Colors::buttonFont());
this->pausedLabel->setPos(Colors::stageWidth - fm.width("PAUSED"), 590 - fm.height());
this->pausedLabel->setRecursiveVisible(false);
}
void MainWindow::checkAdapt()
{
if (this->doneAdapt
|| Colors::noTimerUpdate
|| this->demoStartTime.elapsed() < 2000)
return;
this->doneAdapt = true;
this->forceFpsMedianCalculation();
Colors::benchmarkFps = this->fpsMedian;
if (Colors::verbose)
qDebug() << "- benchmark:" << QString::number(Colors::benchmarkFps) << "FPS";
if (Colors::noAdapt)
return;
if (this->fpsMedian < 30){
if (MenuManager::instance()->ticker && MenuManager::instance()->ticker->scene()){
this->scene->removeItem(MenuManager::instance()->ticker);
Colors::noTimerUpdate = true;
this->switchTimerOnOff(false);
if (this->fpsLabel)
this->fpsLabel->setText(QString("FPS: (") + QString::number(this->fpsMedian) + QString(")"));
if (Colors::verbose)
qDebug() << "- benchmark adaption: removed ticker (fps < 30)";
}
if (this->fpsMedian < 20){
Colors::noAnimations = true;
if (Colors::verbose)
qDebug() << "- benchmark adaption: animations switched off (fps < 20)";
}
Colors::adapted = true;
}
}
int MainWindow::performBenchmark()
{
/*
QTime time;
time.restart();
while (time.elapsed() < 2000)
QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
*/
return 0;
}
void MainWindow::drawBackgroundToPixmap()
{
const QRectF r = this->scene->sceneRect();
this->background = QPixmap(qRound(r.width()), qRound(r.height()));
this->background.fill(Qt::black);
QPainter painter(&this->background);
if (false && Colors::useEightBitPalette){
painter.fillRect(r, Colors::sceneBg1);
} else {
QImage bg(":/images/demobg.png");
painter.drawImage(0, 0, bg);
}
}
void MainWindow::drawBackground(QPainter *painter, const QRectF &rect)
{
Q_UNUSED(rect);
painter->drawPixmap(QPoint(0, 0), this->background);
}
void MainWindow::showEvent(QShowEvent * event)
{
Q_UNUSED(event);
QGraphicsView::showEvent(event);
}
void MainWindow::toggleFullscreen()
{
if (this->isFullScreen()){
this->enableMask(true);
this->showNormal();
if (MenuManager::instance()->ticker)
MenuManager::instance()->ticker->pause(false);
}
else {
this->enableMask(false);
this->showFullScreen();
}
}
void MainWindow::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Escape){
// disable escape key press
// this->loop = false;
// QApplication::quit();
}
else if (event->key() == Qt::Key_1){
QString s("");
s += "Rendering system: ";
if (Colors::openGlRendering)
s += "OpenGL";
else
s += "software";
s += "\nAdapt: ";
s += Colors::noAdapt ? "off" : "on";
s += "\nAdaption occured: ";
s += Colors::adapted ? "yes" : "no";
s += "\nOpenGL version: ";
s += Colors::glVersion;
QWidget w;
s += "\nColor bit depth: ";
s += QString::number(w.depth());
s += "\nWanted FPS: ";
s += QString::number(Colors::fps);
s += "\nBenchmarked FPS: ";
s += Colors::benchmarkFps != -1 ? QString::number(Colors::benchmarkFps) : "not calculated";
s += "\nAnimations: ";
s += Colors::noAnimations ? "off" : "on";
s += "\nBlending: ";
s += Colors::useEightBitPalette ? "off" : "on";
s += "\nTicker: ";
s += Colors::noTicker ? "off" : "on";
s += "\nPixmaps: ";
s += Colors::usePixmaps ? "on" : "off";
s += "\nRescale images on resize: ";
s += Colors::noRescale ? "off" : "on";
s += "\nTimer based updates: ";
s += Colors::noTimerUpdate ? "off" : "on";
s += "\nSeparate loop: ";
s += Colors::useLoop ? "yes" : "no";
s += "\nScreen sync: ";
s += Colors::noScreenSync ? "no" : "yes";
QMessageBox::information(0, QString("Current configuration"), s);
}
}
void MainWindow::focusInEvent(QFocusEvent *)
{
if (!Colors::pause)
return;
if (MenuManager::instance()->ticker)
MenuManager::instance()->ticker->pause(false);
int code = MenuManager::instance()->currentMenuCode;
if (code == MenuManager::ROOT || code == MenuManager::MENU1)
this->switchTimerOnOff(true);
this->pausedLabel->setRecursiveVisible(false);
}
void MainWindow::focusOutEvent(QFocusEvent *)
{
if (!Colors::pause)
return;
if (MenuManager::instance()->ticker)
MenuManager::instance()->ticker->pause(true);
int code = MenuManager::instance()->currentMenuCode;
if (code == MenuManager::ROOT || code == MenuManager::MENU1)
this->switchTimerOnOff(false);
this->pausedLabel->setRecursiveVisible(true);
}
void MainWindow::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
this->resetMatrix();
this->scale(event->size().width() / 800.0, event->size().height() / 600.0);
QGraphicsView::resizeEvent(event);
DemoItem::setMatrix(this->matrix());
if (this->companyLogo){
const QRectF r = this->scene->sceneRect();
QRectF ttb = this->companyLogo->boundingRect();
this->companyLogo->setPos(int((r.width() - ttb.width()) / 2), 595 - ttb.height());
QRectF qtb = this->qtLogo->boundingRect();
this->qtLogo->setPos(802 - qtb.width(), 0);
}
// Changing size will almost always
// hurt FPS during the changing. So
// ignore it.
this->fpsHistory.clear();
}
void MainWindow::updateExamples(const QString& examplePath, const QString& demosPath, const QString &sourcePath)
{
QMessageBox mbox(this);
QStringList slist;
slist << "examplePath:" << examplePath << "\n"
<< "demosPath:" << demosPath << "\n"
<< "sourcePath:" << sourcePath;
mbox.setText(slist.join(""));
mbox.exec();
QString demoxml = demosPath + "/qtdemo/xml/examples.xml";
if (!QFile::exists(demoxml)) {
demoxml = sourcePath + "/demos/qtdemo/xml/examples.xml";
if (!QFile::exists(demoxml))
return;
}
QFile description(demoxml);
if (!description.open(QFile::ReadOnly))
return;
#if 0
ui->examplesComboBox->clear();
ui->examplesComboBox->setEnabled(true);
ui->examplesComboBox->addItem(tr("Choose an example..."));
QFont f = font();
f.setItalic(true);
ui->examplesComboBox->setItemData(0, f, Qt::FontRole);
f.setItalic(false);
bool inExamples = false;
QString dirName;
QXmlStreamReader reader(&description);
while (!reader.atEnd()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement:
if (reader.name() == "category") {
QString name = reader.attributes().value(QLatin1String("name")).toString();
if (name.contains("tutorial"))
break;
dirName = reader.attributes().value(QLatin1String("dirname")).toString();
ui->examplesComboBox->addItem(name);
f.setBold(true);
ui->examplesComboBox->setItemData(ui->examplesComboBox->count()-1, f, Qt::FontRole);
f.setBold(false);
inExamples = true;
}
if (inExamples && reader.name() == "example") {
QString name = reader.attributes().value(QLatin1String("name")).toString();
QString fn = reader.attributes().value(QLatin1String("filename")).toString();
QString relativeProPath = '/' + dirName + '/' + fn + '/' + fn + ".pro";
QString fileName = examplePath + relativeProPath;
if (!QFile::exists(fileName))
fileName = sourcePath + "/examples" + relativeProPath;
QString helpPath = "qthelp://com.trolltech.qt/qdoc/" + dirName.replace("/", "-") + "-" + fn + ".html";
ui->examplesComboBox->addItem(" " + name, fileName);
ui->examplesComboBox->setItemData(ui->examplesComboBox->count()-1, helpPath, Qt::UserRole+1);
}
break;
case QXmlStreamReader::EndElement:
if (reader.name() == "category")
inExamples = false;
break;
default:
break;
}
}
#endif
}
| [
"douyongwang@152bb772-114e-11df-9f54-17e475596acb"
]
| [
[
[
1,
544
]
]
]
|
40f77278be8e5f7886e4fed014b284acf6d06108 | 7347ab0d3daab6781af407d43ac29243daeae438 | /src/graphics/texture.h | c9636b8c89f555be9a21ed7adcd4462fb9a086b5 | []
| no_license | suprafun/smalltowns | e096cdfc11e329674a7f76486452f4cd58ddaace | c722da7dd3a1d210d07f22a6c322117b540e63da | refs/heads/master | 2021-01-10T03:09:47.664318 | 2011-06-03T01:22:29 | 2011-06-03T01:22:29 | 50,808,558 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,587 | h | /*********************************************
*
* Author: David Athay
*
* License: New BSD License
*
* Copyright (c) 2008, CT Games
* 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 CT Games 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 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
*
* Date of file creation: 08-09-21
*
* $Id$
*
********************************************/
/**
* The Texture class is used to store a texture's data
*/
#ifndef ST_TEXTURE_HEADER
#define ST_TEXTURE_HEADER
#include <SDL_opengl.h>
#include <string>
struct SDL_Surface;
namespace ST
{
class Texture
{
public:
/**
* Constructor
*/
Texture(std::string name);
Texture(std::string name, int width, int height);
/**
* Destructor
*/
~Texture();
/**
* Set Pixels
* Puts a SDL Surface's pixels into a GL Texture
*/
void setPixels(SDL_Surface *surface);
/**
* Set Image
* Stores the SDL Surface
*/
void setImage(SDL_Surface *surface);
/**
* Set GL texture
* When we already have a created texture
*/
void setGLTexture(unsigned int texture);
/**
* Set Size
* Sets the size of the texture
*/
void setSize(unsigned int w, unsigned int h);
/**
* Increase instance count
*/
void increaseCount() { ++mInstances; }
/**
* Get Name
* @return Returns the name of the texture
*/
std::string getName() const;
/**
* Get Height
* @return Returns the height of the texture
*/
int getHeight() const;
/**
* Get Width
* @return Returns the width of the texture
*/
int getWidth() const;
/**
* Get GL Texture
* @return Returns the GL Texture
*/
GLuint getGLTexture();
/**
* Get SDL Surface
* @return Returns the SDL Surface
*/
SDL_Surface* getSDLSurface();
/**
* Remove
* This will eventually delete the texture
* when the number of instances equals 0
*/
void remove();
private:
std::string mName;
int mInstances;
int mWidth;
int mHeight;
GLuint mGLTexture;
SDL_Surface *mSurface;
};
}
#endif
| [
"ko2fan@2ae5cb60-8703-11dd-9899-c7ba65f7c4c7"
]
| [
[
[
1,
144
]
]
]
|
96b92e2ba193c2f001c1c264cf8f0edf56fd9a23 | dc4b6ab7b120262779e29d8b2d96109517f35551 | /stdafx.h | 1fc0e3b92f0a7c4606a0586d6fbf1fb787559e0b | []
| no_license | cnsuhao/wtlhelper9 | 92daef29b61f95f44a10e3277d8835c2dd620616 | 681df3a014fc71597e9380b0a60bd3cd23e22efe | refs/heads/master | 2021-07-17T19:59:07.143192 | 2009-05-18T14:24:48 | 2009-05-18T14:24:48 | 108,361,858 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,830 | h | ////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004 Sergey Solozhentsev
// Author: Sergey Solozhentsev e-mail: [email protected]
// Product: WTL Helper
// File: stdafx.h
// Created: 16.11.2004 8:55
//
// Using this software in commercial applications requires an author
// permission. The permission will be granted to everyone excluding the cases
// when someone simply tries to resell the code.
// This file may be redistributed by any means PROVIDING it is not sold for
// profit without the authors written consent, and providing that this notice
// and the authors name is included.
// This file is provided "as is" with no expressed or implied warranty. The
// author accepts no liability if it causes any damage to you or your computer
// whatsoever.
//
////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef STRICT
#define STRICT
#endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0500 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target Windows 2000 or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0500 // Change this to the appropriate value to target IE 5.0 or later.
#endif
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off ATL's hiding of some common and often safely ignored warning messages
#define _ATL_ALL_WARNINGS
#define ISOLATION_AWARE_ENABLED 1
#define _WTL_NO_CSTRING
#include <atlstr.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlsafe.h>
#include <atlcoll.h>
#include <atlapp.h>
#include <atlwin.h>
#include <atlctrls.h>
#include <atlmisc.h>
#include <atlddx.h>
using namespace ATL;
#include "Settings.h"
#include "CollSerialize.h"
#include <windows.h>
#include <objbase.h>
#include "imports.h"
//wParam - BOOL is modified
#define WTLH_SETMODIFIED (WM_USER + 500)
//wParam = HWND of the toolbar
#define WTLH_SETACTIVE (WM_USER + 501)
#define FIRST_TOOLBAR_COMMAND 20000
#define IfFailGo(x) { hr=(x); if (FAILED(hr)) goto Error; }
#define IfFailGoCheck(x, p) { hr=(x); if (FAILED(hr)) goto Error; if(p == NULL) {hr = E_FAIL; goto Error; } }
#if defined(_FOR_VS2008)
class DECLSPEC_UUID("D193ECB0-D5E8-483a-922E-E0F5AD020262") WtlHelperLib;
#elif defined(_FOR_VS2005)
class DECLSPEC_UUID("E2CBD4CB-D05B-480f-B9A3-76F31CB0973E") WtlHelperLib;
#else
class DECLSPEC_UUID("730B33D4-7AEB-476B-9018-703AB582E457") WtlHelperLib;
#endif
enum eWTLVersion
{
eWTL71 = 0,
eWTL75 = 1,
eWTL80 = 2,
eWTL81 = 3,
};
class CAddInModule : public CAtlDllModuleT< CAddInModule >,
public CSettings<CAddInModule>
{
public:
CAddInModule() : m_eWTLVersion(eWTL75)
{
m_hInstance = NULL;
}
DECLARE_LIBID(__uuidof(WtlHelperLib))
inline HINSTANCE GetResourceInstance()
{
return m_hInstance;
}
inline void SetResourceInstance(HINSTANCE hInstance)
{
m_hInstance = hInstance;
}
CAtlArray<CString> m_DialogClasses;
bool IsMacro(CString MacroName);
bool LoadAll();
void Destroy();
CString m_RegMessages;
CString m_CommonFile;
eWTLVersion m_eWTLVersion;
BEGIN_SETTINGS_MAP()
SETTINGS_VARIABLE_RO(m_RegMessages)
SETTINGS_VARIABLE_RO(m_CommonFile)
ALT_SETTINGS_MAP(1)
SETTINGS_OBJECT_RO(m_DialogClasses, CAtlArraySerializer<CString>)
SETTINGS_OBJECT_RO(m_MacroMasks, CAtlArraySerializer<CString>)
ALT_SETTINGS_MAP(2)
SETTINGS_ENUM_OPT_RO(m_eWTLVersion)
END_SETTINGS_MAP()
private:
HINSTANCE m_hInstance;
CAtlArray<CString> m_MacroMasks;
bool IsMatchMask(LPCTSTR Name, LPCTSTR Mask);
};
template<class T>
class CSmartAtlArray : public CAtlArray<T>
{
public:
CSmartAtlArray(const CSmartAtlArray<T>& ar)
{
Copy(ar);
}
CSmartAtlArray() : CAtlArray<T>(){};
CSmartAtlArray& operator =(const CSmartAtlArray<T> ar)
{
Copy(ar);
return *this;
}
};
extern CAddInModule _AtlModule;
#ifdef _DEBUG
//profile macros
#define START_PROFILE(shortname) \
LARGE_INTEGER start_##shortname, end_##shortname;\
QueryPerformanceCounter(&start_##shortname);
#define END_PROFILE(shortname, str)\
QueryPerformanceCounter(&end_##shortname);\
__int64 res_##shortname = *(__int64*)&(end_##shortname) - *(__int64*)&(start_##shortname);\
LARGE_INTEGER freq_##shortname; QueryPerformanceFrequency(&freq_##shortname);\
__int64 ifreq_##shortname = *(__int64*)&(freq_##shortname);\
double millisec_##shortname = (double)(res_##shortname * 1000) / (double)ifreq_##shortname;\
CString str_##shortname; str_##shortname.Format(_T("\r\n%s - %f ms\r\n\r\n"), str, millisec_##shortname);\
OutputDebugString(str_##shortname);
#else
#define START_PROFILE(shortname)
#define END_PROFILE(str, shortname)
#endif
#ifndef _countof
#define _countof(_Array) sizeof(_Array) / sizeof((_Array)[0])
#endif
#define STR_WTL_WIZARDS _T("Software\\SaloS\\WTL Wizards")
#define STR_WTL_HELPER_KEY _T("Software\\SaloS\\WtlHelper")
#define STR_WTL_HELPER_W L"WTL Helper"
#define STR_WTL_HELPER_A "WTL Helper"
#ifdef UNICODE
#define STR_WTL_HELPER STR_WTL_HELPER_W
#else
#define STR_WTL_HELPER STR_WTL_HELPER_A
#endif
| [
"free2000fly@eea8f18a-16fd-41b0-b60a-c1204a6b73d1"
]
| [
[
[
1,
198
]
]
]
|
f5fce0ee6f46b768981ebfd769bc46df377ccfef | d01196cdfc4451c4e1c88343bdb1eb4db9c5ac18 | /source/client/global/aurora.cpp | a9a9ac07df0d40c91049e56313abd54d6635efda | []
| no_license | ferhan66h/Xash3D_ancient | 7491cd4ff1c7d0b48300029db24d7e08ba96e88a | 075e0a6dae12a0952065eb9b2954be4a8827c72f | refs/heads/master | 2021-12-10T07:55:29.592432 | 2010-05-09T00:00:00 | 2016-07-30T17:37:36 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 27,284 | cpp | //=======================================================================
// Copyright XashXT Group 2008 ©
// aurora.cpp - famous Laurie Cheers Aurora system
//=======================================================================
#include "extdll.h"
#include "utils.h"
#include "triangle_api.h"
#include "hud.h"
#include "aurora.h"
extern ref_params_t *gpViewParams;
ParticleSystemManager* g_pParticleSystems = NULL;
void CreateAurora( int idx, char *file )
{
ParticleSystem *pSystem = new ParticleSystem( idx, file );
g_pParticleSystems->AddSystem( pSystem );
}
ParticleSystemManager::ParticleSystemManager( void )
{
m_pFirstSystem = NULL;
}
ParticleSystemManager::~ParticleSystemManager( void )
{
ClearSystems();
}
void ParticleSystemManager::AddSystem( ParticleSystem* pNewSystem )
{
pNewSystem->m_pNextSystem = m_pFirstSystem;
m_pFirstSystem = pNewSystem;
}
ParticleSystem *ParticleSystemManager::FindSystem( edict_t* pEntity )
{
for( ParticleSystem *pSys = m_pFirstSystem; pSys; pSys = pSys->m_pNextSystem )
{
if( pEntity->serialnumber == pSys->m_iEntIndex )
return pSys;
}
return NULL;
}
// blended particles don't use the z-buffer, so we need to sort them before drawing.
// for efficiency, only the systems are sorted - individual particles just get drawn in order of creation.
// (this should actually make things look better - no ugly popping when one particle passes through another.)
void ParticleSystemManager::SortSystems( void )
{
ParticleSystem* pSystem;
ParticleSystem* pLast;
ParticleSystem* pBeforeCompare, *pCompare;
if (!m_pFirstSystem) return;
// calculate how far away each system is from the viewer
for( pSystem = m_pFirstSystem; pSystem; pSystem = pSystem->m_pNextSystem )
pSystem->CalculateDistance();
// do an insertion sort on the systems
pLast = m_pFirstSystem;
pSystem = pLast->m_pNextSystem;
while ( pSystem )
{
if ( pLast->m_fViewerDist < pSystem->m_fViewerDist )
{
// pSystem is in the wrong place! First, let's unlink it from the list
pLast->m_pNextSystem = pSystem->m_pNextSystem;
// then find somewhere to insert it
if (m_pFirstSystem == pLast || m_pFirstSystem->m_fViewerDist < pSystem->m_fViewerDist)
{
// pSystem comes before the first system, insert it there
pSystem->m_pNextSystem = m_pFirstSystem;
m_pFirstSystem = pSystem;
}
else
{
// insert pSystem somewhere within the sorted part of the list
pBeforeCompare = m_pFirstSystem;
pCompare = pBeforeCompare->m_pNextSystem;
while (pCompare != pLast)
{
if (pCompare->m_fViewerDist < pSystem->m_fViewerDist)
{
// pSystem comes before pCompare. We've found where it belongs.
break;
}
pBeforeCompare = pCompare;
pCompare = pBeforeCompare->m_pNextSystem;
}
// we've found where pSystem belongs. Insert it between pBeforeCompare and pCompare.
pBeforeCompare->m_pNextSystem = pSystem;
pSystem->m_pNextSystem = pCompare;
}
}
else
{
//pSystem is in the right place, move on
pLast = pSystem;
}
pSystem = pLast->m_pNextSystem;
}
}
void ParticleSystemManager::UpdateSystems( void )
{
static float fOldTime, fTime;
fOldTime = fTime;
fTime = GetClientTime();
float frametime = fTime - fOldTime;
ParticleSystem* pSystem;
ParticleSystem* pLast = NULL;
ParticleSystem*pLastSorted = NULL;
SortSystems();
pSystem = m_pFirstSystem;
while( pSystem )
{
if( pSystem->UpdateSystem( frametime ))
{
pSystem->DrawSystem();
pLast = pSystem;
pSystem = pSystem->m_pNextSystem;
}
else // delete this system
{
if (pLast)
{
pLast->m_pNextSystem = pSystem->m_pNextSystem;
delete pSystem;
pSystem = pLast->m_pNextSystem;
}
else // deleting the first system
{
m_pFirstSystem = pSystem->m_pNextSystem;
delete pSystem;
pSystem = m_pFirstSystem;
}
}
}
g_engfuncs.pTriAPI->RenderMode(kRenderNormal);
}
void ParticleSystemManager::ClearSystems( void )
{
ParticleSystem* pSystem = m_pFirstSystem;
ParticleSystem* pTemp;
while( pSystem )
{
pTemp = pSystem->m_pNextSystem;
delete pSystem;
pSystem = pTemp;
}
m_pFirstSystem = NULL;
}
float ParticleSystem::c_fCosTable[360 + 90];
bool ParticleSystem::c_bCosTableInit = false;
ParticleType::ParticleType( ParticleType *pNext )
{
m_pSprayType = m_pOverlayType = NULL;
m_StartAngle = RandomRange(45);
m_SpriteIndex = 0;
m_pNext = pNext;
m_szName[0] = 0;
m_StartRed = m_StartGreen = m_StartBlue = m_StartAlpha = RandomRange(1);
m_EndRed = m_EndGreen = m_EndBlue = m_EndAlpha = RandomRange(1);
m_iRenderMode = kRenderTransAdd;
m_iDrawCond = 0;
m_bEndFrame = false;
m_bIsDefined = false;
m_iCollision = 0;
}
particle* ParticleType::CreateParticle(ParticleSystem *pSys)//particle *pPart)
{
if (!pSys) return NULL;
particle *pPart = pSys->ActivateParticle();
if (!pPart) return NULL;
pPart->age = 0.0;
pPart->age_death = m_Life.GetInstance();
InitParticle(pPart, pSys);
return pPart;
}
void ParticleType::InitParticle(particle *pPart, ParticleSystem *pSys)
{
float fLifeRecip = 1/pPart->age_death;
particle *pOverlay = NULL;
if (m_pOverlayType)
{
// create an overlay for this particle
pOverlay = pSys->ActivateParticle();
if (pOverlay)
{
pOverlay->age = pPart->age;
pOverlay->age_death = pPart->age_death;
m_pOverlayType->InitParticle(pOverlay, pSys);
}
}
pPart->m_pOverlay = pOverlay;
pPart->pType = this;
pPart->velocity[0] = pPart->velocity[1] = pPart->velocity[2] = 0;
pPart->accel[0] = pPart->accel[1] = 0;
pPart->accel[2] = m_Gravity.GetInstance();
pPart->m_iEntIndex = 0;
if (m_pSprayType)
{
pPart->age_spray = 1/m_SprayRate.GetInstance();
}
else
{
pPart->age_spray = 0.0f;
}
pPart->m_fSize = m_StartSize.GetInstance();
if (m_EndSize.IsDefined())
pPart->m_fSizeStep = m_EndSize.GetOffset(pPart->m_fSize) * fLifeRecip;
else
pPart->m_fSizeStep = m_SizeDelta.GetInstance();
//pPart->m_fSizeStep = m_EndSize.GetOffset(pPart->m_fSize) * fLifeRecip;
pPart->frame = m_StartFrame.GetInstance();
if (m_EndFrame.IsDefined( ))
pPart->m_fFrameStep = m_EndFrame.GetOffset( pPart->frame ) * fLifeRecip;
else pPart->m_fFrameStep = m_FrameRate.GetInstance();
pPart->m_fAlpha = m_StartAlpha.GetInstance();
pPart->m_fAlphaStep = m_EndAlpha.GetOffset(pPart->m_fAlpha) * fLifeRecip;
pPart->m_fRed = m_StartRed.GetInstance();
pPart->m_fRedStep = m_EndRed.GetOffset(pPart->m_fRed) * fLifeRecip;
pPart->m_fGreen = m_StartGreen.GetInstance();
pPart->m_fGreenStep = m_EndGreen.GetOffset(pPart->m_fGreen) * fLifeRecip;
pPart->m_fBlue = m_StartBlue.GetInstance();
pPart->m_fBlueStep = m_EndBlue.GetOffset(pPart->m_fBlue) * fLifeRecip;
pPart->m_fAngle = m_StartAngle.GetInstance();
pPart->m_fAngleStep = m_AngleDelta.GetInstance();
pPart->m_fDrag = m_Drag.GetInstance();
float fWindStrength = m_WindStrength.GetInstance();
float fWindYaw = m_WindYaw.GetInstance();
pPart->m_vecWind.x = fWindStrength*ParticleSystem::CosLookup(fWindYaw);
pPart->m_vecWind.y = fWindStrength*ParticleSystem::SinLookup(fWindYaw);
pPart->m_vecWind.z = 0;
}
//============================================
RandomRange::RandomRange( char *szToken )
{
char *cOneDot = NULL;
m_bDefined = true;
for( char *c = szToken; *c; c++ )
{
if (*c == '.')
{
if (cOneDot != NULL)
{
// found two dots in a row - it's a range
*cOneDot = 0; // null terminate the first number
m_fMin = atof( szToken ); // parse the first number
*cOneDot = '.'; // change it back, just in case
c++;
m_fMax = atof( c ); // parse the second number
return;
}
else
{
cOneDot = c;
}
}
else
{
cOneDot = NULL;
}
}
// no range, just record the number
m_fMin = m_fMax = atof( szToken );
}
//============================================
ParticleSystem::ParticleSystem( int iEntIndex, char *szFilename )
{
int iParticles = 100; // default
m_iEntIndex = iEntIndex;
m_pNextSystem = NULL;
m_pFirstType = NULL;
if ( !c_bCosTableInit )
{
for ( int i = 0; i < 360 + 90; i++ )
{
c_fCosTable[i] = cos( i * M_PI / 180.0 );
}
c_bCosTableInit = true;
}
const char *memFile;
const char *szFile = (char *)LOAD_FILE( szFilename, NULL );
char *szToken;
if( !szFile )
{
ALERT( at_error, "particle %s not found.\n", szFilename );
return;
}
else
{
memFile = szFile;
szToken = COM_ParseToken( &szFile );
while ( szToken )
{
if ( !stricmp( szToken, "particles" ) )
{
szToken = COM_ParseToken( &szFile );
iParticles = atof(szToken);
}
else if ( !stricmp( szToken, "maintype" ) )
{
szToken = COM_ParseToken( &szFile );
m_pMainType = AddPlaceholderType(szToken);
}
else if ( !stricmp( szToken, "attachment" ) )
{
szToken = COM_ParseToken( &szFile );
m_iEntAttachment = atof(szToken);
}
else if ( !stricmp( szToken, "killcondition" ) )
{
szToken = COM_ParseToken( &szFile );
if ( !stricmp( szToken, "empty" ) )
{
m_iKillCondition = CONTENTS_EMPTY;
}
else if ( !stricmp( szToken, "water" ) )
{
m_iKillCondition = CONTENTS_WATER;
}
else if ( !stricmp( szToken, "solid" ) )
{
m_iKillCondition = CONTENTS_SOLID;
}
}
else if ( !stricmp( szToken, "{" ) )
{
// parse new type
this->ParseType( &szFile ); // parses the type, moves the file pointer
}
szToken = COM_ParseToken( &szFile );
}
}
FREE_FILE( (void *)memFile );
AllocateParticles( iParticles );
}
void ParticleSystem::AllocateParticles( int iParticles )
{
m_pAllParticles = new particle[iParticles];
m_pFreeParticle = m_pAllParticles;
m_pActiveParticle = NULL;
m_pMainParticle = NULL;
// initialise the linked list
particle *pLast = m_pAllParticles;
particle *pParticle = pLast+1;
for( int i = 1; i < iParticles; i++ )
{
pLast->nextpart = pParticle;
pLast = pParticle;
pParticle++;
}
pLast->nextpart = NULL;
}
ParticleSystem::~ParticleSystem( void )
{
delete[] m_pAllParticles;
ParticleType *pType = m_pFirstType;
ParticleType *pNext;
while (pType)
{
pNext = pType->m_pNext;
delete pType;
pType = pNext;
}
}
// returns the ParticleType with the given name, if there is one
ParticleType *ParticleSystem::GetType( const char *szName )
{
for (ParticleType *pType = m_pFirstType; pType; pType = pType->m_pNext)
{
if (!stricmp(pType->m_szName, szName))
return pType;
}
return NULL;
}
ParticleType *ParticleSystem::AddPlaceholderType( const char *szName )
{
m_pFirstType = new ParticleType( m_pFirstType );
strncpy(m_pFirstType->m_szName, szName, sizeof(m_pFirstType->m_szName) );
return m_pFirstType;
}
// creates a new particletype from the given file
// NB: this changes the value of szFile.
ParticleType *ParticleSystem::ParseType( const char **szFile )
{
ParticleType *pType = new ParticleType();
// parse the .aur file
char *szToken;
szToken = COM_ParseToken( szFile );
while ( stricmp( szToken, "}" ) )
{
if (!szFile)
break;
if ( !stricmp( szToken, "name" ) )
{
szToken = COM_ParseToken( szFile );
strncpy(pType->m_szName, szToken, sizeof(pType->m_szName) );
ParticleType *pTemp = GetType(szToken);
if (pTemp)
{
// there's already a type with this name
if (pTemp->m_bIsDefined)
ALERT( at_warning, "Particle type %s is defined more than once!\n", szToken);
// copy all our data into the existing type, throw away the type we were making
*pTemp = *pType;
delete pType;
pType = pTemp;
pType->m_bIsDefined = true; // record the fact that it's defined, so we won't need to add it to the list
}
}
else if ( !stricmp( szToken, "gravity" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_Gravity = RandomRange( szToken );
}
else if ( !stricmp( szToken, "windyaw" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_WindYaw = RandomRange( szToken );
}
else if ( !stricmp( szToken, "windstrength" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_WindStrength = RandomRange( szToken );
}
else if ( !stricmp( szToken, "sprite" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_SpriteIndex = g_engfuncs.pEventAPI->EV_FindModelIndex( szToken );
}
else if ( !stricmp( szToken, "startalpha" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_StartAlpha = RandomRange( szToken );
}
else if ( !stricmp( szToken, "endalpha" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_EndAlpha = RandomRange( szToken );
}
else if ( !stricmp( szToken, "startred" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_StartRed = RandomRange( szToken );
}
else if ( !stricmp( szToken, "endred" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_EndRed = RandomRange( szToken );
}
else if ( !stricmp( szToken, "startgreen" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_StartGreen = RandomRange( szToken );
}
else if ( !stricmp( szToken, "endgreen" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_EndGreen = RandomRange( szToken );
}
else if ( !stricmp( szToken, "startblue" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_StartBlue = RandomRange( szToken );
}
else if ( !stricmp( szToken, "endblue" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_EndBlue = RandomRange( szToken );
}
else if ( !stricmp( szToken, "startsize" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_StartSize = RandomRange( szToken );
}
else if ( !stricmp( szToken, "sizedelta" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_SizeDelta = RandomRange( szToken );
}
else if ( !stricmp( szToken, "endsize" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_EndSize = RandomRange( szToken );
}
else if ( !stricmp( szToken, "startangle" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_StartAngle = RandomRange( szToken );
}
else if ( !stricmp( szToken, "angledelta" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_AngleDelta = RandomRange( szToken );
}
else if ( !stricmp( szToken, "startframe" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_StartFrame = RandomRange( szToken );
}
else if ( !stricmp( szToken, "endframe" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_EndFrame = RandomRange( szToken );
pType->m_bEndFrame = true;
}
else if ( !stricmp( szToken, "framerate" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_FrameRate = RandomRange( szToken );
}
else if ( !stricmp( szToken, "lifetime" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_Life = RandomRange( szToken );
}
else if ( !stricmp( szToken, "spraytype" ) )
{
szToken = COM_ParseToken( szFile );
ParticleType *pTemp = GetType(szToken);
if (pTemp) pType->m_pSprayType = pTemp;
else pType->m_pSprayType = AddPlaceholderType(szToken);
}
else if ( !stricmp( szToken, "overlaytype" ) )
{
szToken = COM_ParseToken( szFile );
ParticleType *pTemp = GetType(szToken);
if (pTemp) pType->m_pOverlayType = pTemp;
else pType->m_pOverlayType = AddPlaceholderType(szToken);
}
else if ( !stricmp( szToken, "sprayrate" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_SprayRate = RandomRange( szToken );
}
else if ( !stricmp( szToken, "sprayforce" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_SprayForce = RandomRange( szToken );
}
else if ( !stricmp( szToken, "spraypitch" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_SprayPitch = RandomRange( szToken );
}
else if ( !stricmp( szToken, "sprayyaw" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_SprayYaw = RandomRange( szToken );
}
else if ( !stricmp( szToken, "drag" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_Drag = RandomRange( szToken );
}
else if ( !stricmp( szToken, "bounce" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_Bounce = RandomRange( szToken );
if (pType->m_Bounce.m_fMin != 0 || pType->m_Bounce.m_fMax != 0)
pType->m_bBouncing = true;
}
else if ( !stricmp( szToken, "bouncefriction" ) )
{
szToken = COM_ParseToken( szFile );
pType->m_BounceFriction = RandomRange( szToken );
}
else if ( !stricmp( szToken, "rendermode" ) )
{
szToken = COM_ParseToken( szFile );
if ( !stricmp( szToken, "additive" ) )
{
pType->m_iRenderMode = kRenderTransAdd;
}
else if ( !stricmp( szToken, "solid" ) )
{
pType->m_iRenderMode = kRenderTransAlpha;
}
else if ( !stricmp( szToken, "texture" ) )
{
pType->m_iRenderMode = kRenderTransTexture;
}
else if ( !stricmp( szToken, "color" ) )
{
pType->m_iRenderMode = kRenderTransColor;
}
}
else if ( !stricmp( szToken, "drawcondition" ) )
{
szToken = COM_ParseToken( szFile );
if ( !stricmp( szToken, "empty" ) )
{
pType->m_iDrawCond = CONTENTS_EMPTY;
}
else if ( !stricmp( szToken, "water" ) )
{
pType->m_iDrawCond = CONTENTS_WATER;
}
else if ( !stricmp( szToken, "solid" ) )
{
pType->m_iDrawCond = CONTENTS_SOLID;
}
}
else if ( !stricmp( szToken, "collision" ) )
{
szToken = COM_ParseToken( szFile );
if ( !stricmp( szToken, "none" ) )
{
pType->m_iCollision = COLLISION_NONE;
}
else if ( !stricmp( szToken, "die" ) )
{
pType->m_iCollision = COLLISION_DIE;
}
else if ( !stricmp( szToken, "bounce" ) )
{
pType->m_iCollision = COLLISION_BOUNCE;
}
}
// get the next token
szToken = COM_ParseToken( szFile );
}
if (!pType->m_bIsDefined)
{
// if this is a newly-defined type, we need to add it to the list
pType->m_pNext = m_pFirstType;
m_pFirstType = pType;
pType->m_bIsDefined = true;
}
return pType;
}
particle *ParticleSystem::ActivateParticle()
{
particle* pActivated = m_pFreeParticle;
if (pActivated)
{
m_pFreeParticle = pActivated->nextpart;
pActivated->nextpart = m_pActiveParticle;
m_pActiveParticle = pActivated;
}
return pActivated;
}
extern Vector v_origin;
void ParticleSystem::CalculateDistance()
{
if (!m_pActiveParticle)
return;
Vector offset = v_origin - m_pActiveParticle->origin; // just pick one
m_fViewerDist = offset[0]*offset[0] + offset[1]*offset[1] + offset[2]*offset[2];
}
bool ParticleSystem::UpdateSystem( float frametime )
{
// the entity emitting this system
edict_t *source = GetEntityByIndex( m_iEntIndex );
if( !source ) return false;
// Don't update if the system is outside the player's PVS.
enable = (source->v.renderfx == kRenderFxAurora);
// check for contents to remove
if( POINT_CONTENTS( source->v.origin ) == m_iKillCondition )
{
enable = 0;
}
if( m_pMainParticle == NULL )
{
if ( enable )
{
ParticleType *pType = m_pMainType;
if ( pType )
{
m_pMainParticle = pType->CreateParticle( this );
if ( m_pMainParticle )
{
m_pMainParticle->m_iEntIndex = m_iEntIndex;
m_pMainParticle->age_death = -1; // never die
}
}
}
}
else if ( !enable )
{
m_pMainParticle->age_death = 0; // die now
m_pMainParticle = NULL;
}
particle* pParticle = m_pActiveParticle;
particle* pLast = NULL;
while( pParticle )
{
if ( UpdateParticle( pParticle, frametime ))
{
pLast = pParticle;
pParticle = pParticle->nextpart;
}
else // deactivate it
{
if ( pLast )
{
pLast->nextpart = pParticle->nextpart;
pParticle->nextpart = m_pFreeParticle;
m_pFreeParticle = pParticle;
pParticle = pLast->nextpart;
}
else // deactivate the first particle in the list
{
m_pActiveParticle = pParticle->nextpart;
pParticle->nextpart = m_pFreeParticle;
m_pFreeParticle = pParticle;
pParticle = m_pActiveParticle;
}
}
}
return true;
}
void ParticleSystem :: DrawSystem( void )
{
Vector normal, forward, right, up;
GetViewAngles( normal );
AngleVectors( normal, forward, right, up );
particle* pParticle = m_pActiveParticle;
for( pParticle = m_pActiveParticle; pParticle; pParticle = pParticle->nextpart )
{
DrawParticle( pParticle, right, up );
}
}
bool ParticleSystem::ParticleIsVisible( particle* part )
{
vec3_t normal, forward, right, up;
GetViewAngles( normal );
AngleVectors( normal, forward, right, up );
Vector vec = ( part->origin - v_origin );
Vector vecDir = vec.Normalize( );
float distance = vec.Length();
if ( DotProduct ( vecDir, forward ) < 0.0f )
return false;
return true;
}
bool ParticleSystem::UpdateParticle( particle *part, float frametime )
{
if( frametime == 0 ) return true;
part->age += frametime;
edict_t *source = GetEntityByIndex( m_iEntIndex );
if( !source ) return false; // total paranoia :)
// is this particle bound to an entity?
if( part->m_iEntIndex )
{
if ( enable )
{
if( m_iEntAttachment )
{
Vector pos = Vector( 0, 0, 0 );
GET_ATTACHMENT( source, m_iEntAttachment, pos, NULL );
if( pos == Vector( 0, 0, 0 )) pos = source->v.origin; // missed attachment
part->velocity = (pos - part->origin ) / frametime;
part->origin = pos;
}
else
{
part->velocity = ( source->v.origin - part->origin ) / frametime;
part->origin = source->v.origin;
}
}
else
{
// entity is switched off, die
return false;
}
}
else
{
// not tied to an entity, check whether it's time to die
if( part->age_death >= 0 && part->age > part->age_death )
return false;
// apply acceleration and velocity
Vector vecOldPos = part->origin;
if ( part->m_fDrag )
part->velocity = part->velocity + (-part->m_fDrag * frametime) * ( part->velocity - part->m_vecWind );
part->velocity = part->velocity + frametime * part->accel;
part->origin = part->origin + frametime * part->velocity;
if( part->pType->m_bBouncing )
{
Vector vecTarget = part->origin + frametime * part->velocity;
TraceResult tr;
TRACE_LINE( part->origin, vecTarget, true, source, &tr );
if( tr.flFraction < 1.0f )
{
part->origin = tr.vecEndPos;
float bounceforce = DotProduct( tr.vecPlaneNormal, part->velocity );
float newspeed = (1.0f - part->pType->m_BounceFriction.GetInstance());
part->velocity = part->velocity * newspeed;
part->velocity = part->velocity + (-bounceforce * ( newspeed + part->pType->m_Bounce.GetInstance())) * tr.vecPlaneNormal;
}
}
}
// spray children
if ( part->age_spray && part->age > part->age_spray )
{
part->age_spray = part->age + 1/part->pType->m_SprayRate.GetInstance();
// particle *pChild = ActivateParticle();
if (part->pType->m_pSprayType)
{
particle *pChild = part->pType->m_pSprayType->CreateParticle(this);
if (pChild)
{
pChild->origin = part->origin;
float fSprayForce = part->pType->m_SprayForce.GetInstance();
pChild->velocity = part->velocity;
if (fSprayForce)
{
float fSprayPitch = part->pType->m_SprayPitch.GetInstance() - source->v.angles.x;
float fSprayYaw = part->pType->m_SprayYaw.GetInstance() - source->v.angles.y;
float fSprayRoll = source->v.angles.z;
float fForceCosPitch = fSprayForce*CosLookup(fSprayPitch);
pChild->velocity.x += CosLookup(fSprayYaw) * fForceCosPitch;
pChild->velocity.y += SinLookup(fSprayYaw) * fForceCosPitch + SinLookup(fSprayYaw) * fSprayForce * SinLookup(fSprayRoll);
pChild->velocity.z -= SinLookup(fSprayPitch) * fSprayForce * CosLookup(fSprayRoll);
}
}
}
}
part->m_fSize += part->m_fSizeStep * frametime;
part->m_fAlpha += part->m_fAlphaStep * frametime;
part->m_fRed += part->m_fRedStep * frametime;
part->m_fGreen += part->m_fGreenStep * frametime;
part->m_fBlue += part->m_fBlueStep * frametime;
part->frame += part->m_fFrameStep * frametime;
if ( part->m_fAngleStep )
{
part->m_fAngle += part->m_fAngleStep * frametime;
while ( part->m_fAngle < 0 ) part->m_fAngle += 360;
while ( part->m_fAngle > 360 ) part->m_fAngle -= 360;
}
return true;
}
void ParticleSystem::DrawParticle( particle *part, Vector &right, Vector &up )
{
float fSize = part->m_fSize;
Vector point1, point2, point3, point4;
Vector origin = part->origin;
// nothing to draw?
if ( fSize == 0 ) return;
// frustrum visible check
if( !ParticleIsVisible( part )) return;
float fCosSize = CosLookup( part->m_fAngle ) * fSize;
float fSinSize = SinLookup( part->m_fAngle ) * fSize;
// calculate the four corners of the sprite
point1 = origin + fSinSize * up;
point1 = point1 + (-fCosSize) * right;
point2 = origin + fCosSize * up;
point2 = point2 + fSinSize * right;
point3 = origin + (-fSinSize) * up;
point3 = point3 + fCosSize * right;
point4 = origin + (-fCosSize) * up;
point4 = point4 + (-fSinSize) * right;
int iContents = 0;
g_engfuncs.pTriAPI->Enable( TRI_SHADER );
for ( particle *pDraw = part; pDraw; pDraw = pDraw->m_pOverlay )
{
if( pDraw->pType->m_SpriteIndex == 0 )
continue;
if ( pDraw->pType->m_iDrawCond )
{
if ( iContents == 0 )
iContents = POINT_CONTENTS( origin );
if ( iContents != pDraw->pType->m_iDrawCond )
continue;
}
int numFrames = GetModelFrames( pDraw->pType->m_SpriteIndex );
// ALERT( at_console, "UpdParticle %d: age %f, life %f, R:%f G:%f, B, %f \n", pDraw->pType->m_hSprite, part->age, part->age_death, pDraw->m_fRed, pDraw->m_fGreen, pDraw->m_fBlue);
// if we've reached the end of the sprite's frames, loop back
while ( pDraw->frame > numFrames )
pDraw->frame -= numFrames;
while ( pDraw->frame < 0 )
pDraw->frame += numFrames;
HSPRITE m_hSprite;
m_hSprite = g_engfuncs.pTriAPI->GetSpriteTexture( pDraw->pType->m_SpriteIndex, int( pDraw->frame ));
g_engfuncs.pTriAPI->RenderMode( pDraw->pType->m_iRenderMode );
g_engfuncs.pTriAPI->Color4f( pDraw->m_fRed, pDraw->m_fGreen, pDraw->m_fBlue, pDraw->m_fAlpha );
g_engfuncs.pTriAPI->Bind( m_hSprite, int( pDraw->frame ));
g_engfuncs.pTriAPI->Begin( TRI_QUADS );
g_engfuncs.pTriAPI->TexCoord2f ( 0, 0 );
g_engfuncs.pTriAPI->Vertex3fv( point1 );
g_engfuncs.pTriAPI->TexCoord2f ( 1, 0 );
g_engfuncs.pTriAPI->Vertex3fv ( point2 );
g_engfuncs.pTriAPI->TexCoord2f ( 1, 1 );
g_engfuncs.pTriAPI->Vertex3fv ( point3 );
g_engfuncs.pTriAPI->TexCoord2f ( 0, 1 );
g_engfuncs.pTriAPI->Vertex3fv ( point4 );
g_engfuncs.pTriAPI->End();
}
g_engfuncs.pTriAPI->Disable( TRI_SHADER );
} | [
"[email protected]"
]
| [
[
[
1,
1016
]
]
]
|
a17265d573658a2257f38786efcdd493d2fea4e0 | 1d2705c9be9ee0f974c224eb794f2f8a9e9a3d50 | /thread_sync_test/grabber_t.cpp | bc7615c80ae3ed6eba595dccee657a7066da075f | []
| no_license | llvllrbreeze/alcorapp | dfe2551f36d346d73d998f59d602c5de46ef60f7 | 3ad24edd52c19f0896228f55539aa8bbbb011aac | refs/heads/master | 2021-01-10T07:36:01.058011 | 2008-12-16T12:51:50 | 2008-12-16T12:51:50 | 47,865,136 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 791 | cpp | #include "grabber_t.hpp"
#include "alcor/core/core.h"
grabber_t::grabber_t(sync_data_t* sync_data, int n) {
_sync_data = sync_data;
_running = true;
_n = n;
}
void grabber_t::do_op()
{
printf("getting data from %d\n", _n);
all::core::BOOST_SLEEP(10*_n);
}
void grabber_t::grab_loop() {
printf("%i: init grabbing\n", _n);
while (_running) {
//wait that all grabbers are ready to grab and that main asks to grab
_sync_data->grab_barrier.wait();
printf("%i: query frame\n", _n);
//
all::core::BOOST_SLEEP(10*_n);
//wait for all grabbers query
//_sync_data->query_barrier.wait();
printf("%i: retrieve frame\n", _n);
//wait on this so main knows when all data is ready
_sync_data->retrieve_barrier.wait();
}
} | [
"stefano.marra@1ffd000b-a628-0410-9a29-793f135cad17",
"andrea.carbone@1ffd000b-a628-0410-9a29-793f135cad17"
]
| [
[
[
1,
1
],
[
3,
9
],
[
17,
27
],
[
30,
30
],
[
32,
40
]
],
[
[
2,
2
],
[
10,
16
],
[
28,
29
],
[
31,
31
]
]
]
|
e2dd87fb05afcec8b6d835b09b80c43e1a01eda1 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.0/bctestaknsound/src/bctestaknsoundview.cpp | 0c28b78e9497b652864a59f4d4bf8d6d321660ab | []
| no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,335 | cpp | /*
* Copyright (c) 2006 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: view class
*
*/
#include <aknviewappui.h>
#include "bctestaknsound.hrh"
#include <bctestaknsound.rsg>
#include "bctestaknsoundview.h"
#include "bctestaknsoundcontainer.h"
#include "bctestutil.h"
#include "bctestaknsoundinfocase.h"
#include "bctestaknsoundsystemcase.h"
_LIT( KAknSoundInfoCase, "Avkon Sound Info test case" );
_LIT( KAknSoundSystemCase, "Avkon Sound System test case" );
// ======== MEMBER FUNCTIONS ========
// ---------------------------------------------------------------------------
// Symbian 2nd static Constructor
// ---------------------------------------------------------------------------
//
CBCTestAknSoundView* CBCTestAknSoundView::NewL()
{
CBCTestAknSoundView* self = new( ELeave ) CBCTestAknSoundView();
CleanupStack::PushL( self );
self->ConstructL();
CleanupStack::Pop( self );
return self;
}
// ---------------------------------------------------------------------------
// C++ default Constructor
// ---------------------------------------------------------------------------
//
CBCTestAknSoundView::CBCTestAknSoundView()
{
}
// ---------------------------------------------------------------------------
// Symbian 2nd Constructor
// ---------------------------------------------------------------------------
//
void CBCTestAknSoundView::ConstructL()
{
BaseConstructL( R_BCTESTAKNSOUND_VIEW );
iContainer = new( ELeave ) CBCTestAknSoundContainer();
iContainer->SetMopParent( this );
iContainer->ConstructL( ClientRect() );
AppUi()->AddToStackL( *this, iContainer );
iContainer->MakeVisible( ETrue );
iTestUtil = CBCTestUtil::NewL();
// Add test case here.
iTestUtil->AddTestCaseL( CBCTestAknSoundInfoCase::NewL( iContainer ),
KAknSoundInfoCase );
iTestUtil->AddTestCaseL( CBCTestAknSoundSystemCase::NewL( iContainer ),
KAknSoundSystemCase );
}
// ---------------------------------------------------------------------------
// Destructor
// ---------------------------------------------------------------------------
//
CBCTestAknSoundView::~CBCTestAknSoundView()
{
if ( iContainer )
{
AppUi()->RemoveFromStack( iContainer );
}
delete iContainer;
delete iTestUtil;
}
// ---------------------------------------------------------------------------
// CBCTestAknSoundView::Id
// ---------------------------------------------------------------------------
//
TUid CBCTestAknSoundView::Id() const
{
return KBCTestAknSoundViewId;
}
// ---------------------------------------------------------------------------
// CBCTestAknSoundView::DoActivateL
// ---------------------------------------------------------------------------
//
void CBCTestAknSoundView::DoActivateL( const TVwsViewId&, TUid, const TDesC8& )
{
}
// ---------------------------------------------------------------------------
// CBCTestAknSoundView::DoDeactivate
// ---------------------------------------------------------------------------
//
void CBCTestAknSoundView::DoDeactivate()
{
}
// ---------------------------------------------------------------------------
// CBCTestAknSoundView::HandleCommandL
// ---------------------------------------------------------------------------
//
void CBCTestAknSoundView::HandleCommandL( TInt aCommand )
{
switch ( aCommand )
{
case EProgCmdAutoTest:
iTestUtil->RunL();
break;
default:
if ( aCommand > EBCTestCmdEmptyOutline &&
aCommand < EBCTestCmdMaxOutline )
{
iTestUtil->RunL( aCommand );
}
break;
}
}
| [
"none@none"
]
| [
[
[
1,
136
]
]
]
|
baec49a2702c1e31bcca04b8e812d0fa1d8df9e2 | eb59f8abb82f425dfc067c7bdfaaf914756c5384 | /DepositDlg.cpp | e3b34d39d4396cc63aacfb8796a280be5037f634 | []
| no_license | congchenutd/congchenmoney | 321cfafb28a0ae9190c65baab9b2de49b88f409c | 4d57d3a3111600f7cf763fd37cb84ef6c3253736 | refs/heads/master | 2021-01-22T02:08:34.493176 | 2011-04-03T04:53:42 | 2011-04-03T04:53:42 | 32,358,806 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 3,907 | cpp | #include "DepositDlg.h"
#include "InterestRateDlg.h"
#include "BankDlg.h"
#include <QDate>
#include <QSqlTableModel>
#include <QSqlQuery>
DepositDlg::DepositDlg(QWidget* parent) : QDialog(parent)
{
months << 3 << 6 << 12 << 24 << 36 << 60;
ui.setupUi(this);
model = new QSqlTableModel(this);
model->setTable("Banks");
model->select();
ui.comboBoxBank->setModel(model);
connect(ui.buttonRate, SIGNAL(clicked()), this, SLOT(slotInterestDlg()));
connect(ui.buttonBank, SIGNAL(clicked()), this, SLOT(slotBank()));
connect(ui.checkBoxReDeposit, SIGNAL(clicked()), this, SLOT(slotCalcEndDate()));
connect(ui.dateEditStart, SIGNAL(dateChanged(QDate)), this, SLOT(slotCalcEndDate()));
connect(ui.comboBoxPeriod, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCalcEndDate()));
connect(ui.comboBoxPeriod, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCalcRate()));
connect(ui.dateEditStart, SIGNAL(dateChanged(QDate)), this, SLOT(slotCalcInterests()));
connect(ui.dSpinBoxAmount, SIGNAL(valueChanged(double)), this, SLOT(slotCalcInterests()));
connect(ui.dSpinBoxRate, SIGNAL(valueChanged(double)), this, SLOT(slotCalcInterests()));
ui.dateEditStart->setDate(QDate::currentDate());
ui.dSpinBoxAmount->selectAll();
slotCalcRate();
}
DepositInfo DepositDlg::getDepositInfo() const
{
DepositInfo result;
result.bank = ui.comboBoxBank->currentText();
result.amount = ui.dSpinBoxAmount->value();
result.start = ui.dateEditStart->date();
result.period = ui.comboBoxPeriod->currentText();
result.end = ui.dateEditEnd->date();
result.rate = ui.dSpinBoxRate->value();
result.interests = ui.dSpinBoxInterestsReal->value();
return result;
}
void DepositDlg::setDepositInfo(const DepositInfo& info)
{
int bankRow = ui.comboBoxBank->findText(info.bank);
ui.comboBoxBank->setCurrentIndex(bankRow == -1 ? 0 : bankRow);
int periodRow = ui.comboBoxPeriod->findText(info.period);
ui.comboBoxPeriod->setCurrentIndex(periodRow == -1 ? 0 : periodRow);
ui.dSpinBoxAmount->setValue(info.amount);
ui.dateEditStart->setDate(info.start);
ui.dSpinBoxRate->setValue(info.rate);
}
void DepositDlg::slotCalcEndDate()
{
QDate startDate = ui.dateEditStart->date();
int period = getPeriod();
QDate endDate = startDate.addMonths(months[period]);
monthsDeposited = months[period];
if(ui.checkBoxReDeposit->isChecked())
{
QDate today = QDate::currentDate();
while(endDate < today)
{
endDate = endDate.addMonths(months[period]);
monthsDeposited += months[period];
}
}
ui.dateEditEnd->setDate(endDate);
}
void DepositDlg::slotCalcRate()
{
QSqlTableModel model;
model.setTable("InterestRate");
model.select();
ui.dSpinBoxRate->setValue(model.data(model.index(getPeriod(), 1)).toDouble());
}
void DepositDlg::slotCalcInterests()
{
double rate = ui.dSpinBoxRate->value() / 100.0;
double amount = ui.dSpinBoxAmount->value();
int interval = months[getPeriod()];
double intervalRate = interval / 12.0 * rate;
for(int month = 0; month < monthsDeposited; month += interval)
amount += amount * intervalRate;
double interests = amount - ui.dSpinBoxAmount->value();
ui.dSpinBoxInterests->setValue(interests);
QSqlQuery query;
query.exec(tr("select Interest from InterestRate where Interval = \"ÀûϢ˰ÂÊ\""));
double taxRate = query.next() ? query.value(0).toDouble() : 0;
ui.dSpinBoxInterestsReal->setValue(interests * (1-taxRate/100));
}
void DepositDlg::slotInterestDlg()
{
InterestRateDlg dlg(this);
dlg.exec();
}
int DepositDlg::getPeriod() const {
return ui.comboBoxPeriod->currentIndex();
}
void DepositDlg::slotBank()
{
BankDlg dlg(this);
if(dlg.exec() == QDialog::Accepted)
model->select();
} | [
"congchenutd@0e65ccb0-1e74-186d-738f-84c7691c4446"
]
| [
[
[
1,
120
]
]
]
|
16941e996684a0b15b4de5b170b5215ba1eb8e6c | 3643bb671f78a0669c8e08935476551a297ce996 | /C_Verbs_Inventory.cpp | c6c613b97940071d3b6aca0c13083fc514b6ab86 | []
| no_license | mattfischer/3dportal | 44b3b9fb2331650fc406596b941f6228f37ff14b | e00f7d601138f5cf72aac35f4d15bdf230c518d9 | refs/heads/master | 2020-12-25T10:36:51.991814 | 2010-08-29T22:53:06 | 2010-08-29T22:53:06 | 65,869,788 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 815 | cpp | #include "C_Verb.h"
#include "G_Inventory.h"
namespace Cog
{
Type_Float GetInv( Type_Thing thing_num, Type_Int bin )
{
return Game::Items[bin].value;
}
Type_Float GetInvMax( Type_Thing thing_num, Type_Int bin )
{
return Game::Items[bin].max;
}
Type_Float GetInvMin( Type_Thing thing_num, Type_Int bin )
{
return Game::Items[bin].min;
}
Type_Float ChangeInv( Type_Thing thing_num, Type_Int bin, Type_Float delta )
{
Game::Items[bin].value += delta;
if( Game::Items[bin].value > Game::Items[bin].max )
Game::Items[bin].value = Game::Items[bin].max;
if( Game::Items[bin].value < Game::Items[bin].min )
Game::Items[bin].value = Game::Items[bin].min;
return Game::Items[bin].value;
}
} | [
"devnull@localhost"
]
| [
[
[
1,
32
]
]
]
|
1af3405f7b9a73b2c7d85ff7559498827fbfbb1a | b668c5a2161d35b5c3a0690a2d958a2ca1e3a5d8 | /AES_CPU/src/AES_CPU_Impl_O2.cpp | 2449c09299e2981501391af317c21fe8bb53db95 | [
"Apache-2.0"
]
| permissive | Bizonu/amclibrary | 5babe5ae7c7e3679a126856578c8d19979af4345 | 6dacc2386064bc1fb0ad9ef1cf0774c5fed56bed | refs/heads/master | 2021-01-10T19:31:01.970127 | 2011-12-28T18:38:03 | 2011-12-28T18:38:03 | 37,608,522 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 39,373 | cpp | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// File: AES_CPU_Impl_O2.cpp
/// Description: The CPU implementation for the AES using full optimizations
/// ( SubBytes, ShiftRows, MixColumns and AddRoundKey in one step,
/// also working only with UINT32 ).
/// Author: Chiuta Adrian Marius
/// Created: 15-11-2009
///
/// 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.
///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "platform.h"
#include "AES_CPU_Impl_O2.h"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//The following tables were generated using the code:
//
//void AddTable(FILE* fout, const char *tableName, const char *boxTable, const UINT8 *sbox, UINT32 v1, UINT32 v2, UINT32 v3, UINT32 v4)
//{
// fprintf(fout, "/*\n\tFor every value found at index we have:\n"
// "\t\t- bits 0..7 represent Multiply(%s[index], 0x%02X).\n"
// "\t\t- bits 8..15 represent Multiply(%s[index], 0x%02X).\n"
// "\t\t- bits 16..23 represent Multiply(%s[index], 0x%02X).\n"
// "\t\t- bits 24..31 represent Multiply(%s[index], 0x%02X).\n"
// "*/\n", boxTable, v1, boxTable, v2, boxTable, v3, boxTable, v4);
//
// fprintf(fout, "static const UINT32 %s[256] =\n{\n", tableName);
//
// UINT32 c = 0;
// for(UINT32 i = 0; i < 256; i++)
// {
// if(c == 0 )
// fprintf(fout, "\t");
//
// UINT32 iBox = sbox[i];
// UINT32 value = (Multiply(iBox, v1) & 0xFF) | ((Multiply(iBox, v2) & 0xFF) << 8) | ((Multiply(iBox, v3) & 0xFF) << 16) | ((Multiply(iBox, v4) & 0xFF) << 24);
//
// if( i != 255 )
// fprintf(fout, "0x%08X, ", value);
// else
// fprintf(fout, "0x%08X", value);
// if( c == 7 )
// fprintf(fout, "\n");
//
// c = (c + 1) & 7;
// }
//
// fprintf(fout, "};\n");
//}
//
//void CreateTables(char *fileName)
//{
// FILE *fout = fopen(fileName, "wt");
//
// AddTable(fout, "sBoxMixColumn_a", "sbox", sbox, 0x02, 0x01, 0x01, 0x03);
// AddTable(fout, "sBoxMixColumn_b", "sbox", sbox, 0x03, 0x02, 0x01, 0x01);
// AddTable(fout, "sBoxMixColumn_c", "sbox", sbox, 0x01, 0x03, 0x02, 0x01);
// AddTable(fout, "sBoxMixColumn_d", "sbox", sbox, 0x01, 0x01, 0x03, 0x02);
//
// AddTable(fout, "rsBoxInvMixColumn_a", "rsbox", rsbox, 0x0e, 0x09, 0x0d, 0x0b);
// AddTable(fout, "rsBoxInvMixColumn_b", "rsbox", rsbox, 0x0b, 0x0e, 0x09, 0x0d);
// AddTable(fout, "rsBoxInvMixColumn_c", "rsbox", rsbox, 0x0d, 0x0b, 0x0e, 0x09);
// AddTable(fout, "rsBoxInvMixColumn_d", "rsbox", rsbox, 0x09, 0x0d, 0x0b, 0x0e);
//
// fclose(fout);
//}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
For every value found at index we have:
- bits 0..7 represent Multiply(sbox[index], 0x02).
- bits 8..15 represent Multiply(sbox[index], 0x01).
- bits 16..23 represent Multiply(sbox[index], 0x01).
- bits 24..31 represent Multiply(sbox[index], 0x03).
*/
__declspec(align(16)) static const UINT32 sBoxMixColumn_a[256] =
{
0xA56363C6, 0x847C7CF8, 0x997777EE, 0x8D7B7BF6, 0x0DF2F2FF, 0xBD6B6BD6, 0xB16F6FDE, 0x54C5C591,
0x50303060, 0x03010102, 0xA96767CE, 0x7D2B2B56, 0x19FEFEE7, 0x62D7D7B5, 0xE6ABAB4D, 0x9A7676EC,
0x45CACA8F, 0x9D82821F, 0x40C9C989, 0x877D7DFA, 0x15FAFAEF, 0xEB5959B2, 0xC947478E, 0x0BF0F0FB,
0xECADAD41, 0x67D4D4B3, 0xFDA2A25F, 0xEAAFAF45, 0xBF9C9C23, 0xF7A4A453, 0x967272E4, 0x5BC0C09B,
0xC2B7B775, 0x1CFDFDE1, 0xAE93933D, 0x6A26264C, 0x5A36366C, 0x413F3F7E, 0x02F7F7F5, 0x4FCCCC83,
0x5C343468, 0xF4A5A551, 0x34E5E5D1, 0x08F1F1F9, 0x937171E2, 0x73D8D8AB, 0x53313162, 0x3F15152A,
0x0C040408, 0x52C7C795, 0x65232346, 0x5EC3C39D, 0x28181830, 0xA1969637, 0x0F05050A, 0xB59A9A2F,
0x0907070E, 0x36121224, 0x9B80801B, 0x3DE2E2DF, 0x26EBEBCD, 0x6927274E, 0xCDB2B27F, 0x9F7575EA,
0x1B090912, 0x9E83831D, 0x742C2C58, 0x2E1A1A34, 0x2D1B1B36, 0xB26E6EDC, 0xEE5A5AB4, 0xFBA0A05B,
0xF65252A4, 0x4D3B3B76, 0x61D6D6B7, 0xCEB3B37D, 0x7B292952, 0x3EE3E3DD, 0x712F2F5E, 0x97848413,
0xF55353A6, 0x68D1D1B9, 0x00000000, 0x2CEDEDC1, 0x60202040, 0x1FFCFCE3, 0xC8B1B179, 0xED5B5BB6,
0xBE6A6AD4, 0x46CBCB8D, 0xD9BEBE67, 0x4B393972, 0xDE4A4A94, 0xD44C4C98, 0xE85858B0, 0x4ACFCF85,
0x6BD0D0BB, 0x2AEFEFC5, 0xE5AAAA4F, 0x16FBFBED, 0xC5434386, 0xD74D4D9A, 0x55333366, 0x94858511,
0xCF45458A, 0x10F9F9E9, 0x06020204, 0x817F7FFE, 0xF05050A0, 0x443C3C78, 0xBA9F9F25, 0xE3A8A84B,
0xF35151A2, 0xFEA3A35D, 0xC0404080, 0x8A8F8F05, 0xAD92923F, 0xBC9D9D21, 0x48383870, 0x04F5F5F1,
0xDFBCBC63, 0xC1B6B677, 0x75DADAAF, 0x63212142, 0x30101020, 0x1AFFFFE5, 0x0EF3F3FD, 0x6DD2D2BF,
0x4CCDCD81, 0x140C0C18, 0x35131326, 0x2FECECC3, 0xE15F5FBE, 0xA2979735, 0xCC444488, 0x3917172E,
0x57C4C493, 0xF2A7A755, 0x827E7EFC, 0x473D3D7A, 0xAC6464C8, 0xE75D5DBA, 0x2B191932, 0x957373E6,
0xA06060C0, 0x98818119, 0xD14F4F9E, 0x7FDCDCA3, 0x66222244, 0x7E2A2A54, 0xAB90903B, 0x8388880B,
0xCA46468C, 0x29EEEEC7, 0xD3B8B86B, 0x3C141428, 0x79DEDEA7, 0xE25E5EBC, 0x1D0B0B16, 0x76DBDBAD,
0x3BE0E0DB, 0x56323264, 0x4E3A3A74, 0x1E0A0A14, 0xDB494992, 0x0A06060C, 0x6C242448, 0xE45C5CB8,
0x5DC2C29F, 0x6ED3D3BD, 0xEFACAC43, 0xA66262C4, 0xA8919139, 0xA4959531, 0x37E4E4D3, 0x8B7979F2,
0x32E7E7D5, 0x43C8C88B, 0x5937376E, 0xB76D6DDA, 0x8C8D8D01, 0x64D5D5B1, 0xD24E4E9C, 0xE0A9A949,
0xB46C6CD8, 0xFA5656AC, 0x07F4F4F3, 0x25EAEACF, 0xAF6565CA, 0x8E7A7AF4, 0xE9AEAE47, 0x18080810,
0xD5BABA6F, 0x887878F0, 0x6F25254A, 0x722E2E5C, 0x241C1C38, 0xF1A6A657, 0xC7B4B473, 0x51C6C697,
0x23E8E8CB, 0x7CDDDDA1, 0x9C7474E8, 0x211F1F3E, 0xDD4B4B96, 0xDCBDBD61, 0x868B8B0D, 0x858A8A0F,
0x907070E0, 0x423E3E7C, 0xC4B5B571, 0xAA6666CC, 0xD8484890, 0x05030306, 0x01F6F6F7, 0x120E0E1C,
0xA36161C2, 0x5F35356A, 0xF95757AE, 0xD0B9B969, 0x91868617, 0x58C1C199, 0x271D1D3A, 0xB99E9E27,
0x38E1E1D9, 0x13F8F8EB, 0xB398982B, 0x33111122, 0xBB6969D2, 0x70D9D9A9, 0x898E8E07, 0xA7949433,
0xB69B9B2D, 0x221E1E3C, 0x92878715, 0x20E9E9C9, 0x49CECE87, 0xFF5555AA, 0x78282850, 0x7ADFDFA5,
0x8F8C8C03, 0xF8A1A159, 0x80898909, 0x170D0D1A, 0xDABFBF65, 0x31E6E6D7, 0xC6424284, 0xB86868D0,
0xC3414182, 0xB0999929, 0x772D2D5A, 0x110F0F1E, 0xCBB0B07B, 0xFC5454A8, 0xD6BBBB6D, 0x3A16162C
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
For every value found at index we have:
- bits 0..7 represent Multiply(sbox[index], 0x03).
- bits 8..15 represent Multiply(sbox[index], 0x02).
- bits 16..23 represent Multiply(sbox[index], 0x01).
- bits 24..31 represent Multiply(sbox[index], 0x01).
*/
__declspec(align(16)) static const UINT32 sBoxMixColumn_b[256] =
{
0x6363C6A5, 0x7C7CF884, 0x7777EE99, 0x7B7BF68D, 0xF2F2FF0D, 0x6B6BD6BD, 0x6F6FDEB1, 0xC5C59154,
0x30306050, 0x01010203, 0x6767CEA9, 0x2B2B567D, 0xFEFEE719, 0xD7D7B562, 0xABAB4DE6, 0x7676EC9A,
0xCACA8F45, 0x82821F9D, 0xC9C98940, 0x7D7DFA87, 0xFAFAEF15, 0x5959B2EB, 0x47478EC9, 0xF0F0FB0B,
0xADAD41EC, 0xD4D4B367, 0xA2A25FFD, 0xAFAF45EA, 0x9C9C23BF, 0xA4A453F7, 0x7272E496, 0xC0C09B5B,
0xB7B775C2, 0xFDFDE11C, 0x93933DAE, 0x26264C6A, 0x36366C5A, 0x3F3F7E41, 0xF7F7F502, 0xCCCC834F,
0x3434685C, 0xA5A551F4, 0xE5E5D134, 0xF1F1F908, 0x7171E293, 0xD8D8AB73, 0x31316253, 0x15152A3F,
0x0404080C, 0xC7C79552, 0x23234665, 0xC3C39D5E, 0x18183028, 0x969637A1, 0x05050A0F, 0x9A9A2FB5,
0x07070E09, 0x12122436, 0x80801B9B, 0xE2E2DF3D, 0xEBEBCD26, 0x27274E69, 0xB2B27FCD, 0x7575EA9F,
0x0909121B, 0x83831D9E, 0x2C2C5874, 0x1A1A342E, 0x1B1B362D, 0x6E6EDCB2, 0x5A5AB4EE, 0xA0A05BFB,
0x5252A4F6, 0x3B3B764D, 0xD6D6B761, 0xB3B37DCE, 0x2929527B, 0xE3E3DD3E, 0x2F2F5E71, 0x84841397,
0x5353A6F5, 0xD1D1B968, 0x00000000, 0xEDEDC12C, 0x20204060, 0xFCFCE31F, 0xB1B179C8, 0x5B5BB6ED,
0x6A6AD4BE, 0xCBCB8D46, 0xBEBE67D9, 0x3939724B, 0x4A4A94DE, 0x4C4C98D4, 0x5858B0E8, 0xCFCF854A,
0xD0D0BB6B, 0xEFEFC52A, 0xAAAA4FE5, 0xFBFBED16, 0x434386C5, 0x4D4D9AD7, 0x33336655, 0x85851194,
0x45458ACF, 0xF9F9E910, 0x02020406, 0x7F7FFE81, 0x5050A0F0, 0x3C3C7844, 0x9F9F25BA, 0xA8A84BE3,
0x5151A2F3, 0xA3A35DFE, 0x404080C0, 0x8F8F058A, 0x92923FAD, 0x9D9D21BC, 0x38387048, 0xF5F5F104,
0xBCBC63DF, 0xB6B677C1, 0xDADAAF75, 0x21214263, 0x10102030, 0xFFFFE51A, 0xF3F3FD0E, 0xD2D2BF6D,
0xCDCD814C, 0x0C0C1814, 0x13132635, 0xECECC32F, 0x5F5FBEE1, 0x979735A2, 0x444488CC, 0x17172E39,
0xC4C49357, 0xA7A755F2, 0x7E7EFC82, 0x3D3D7A47, 0x6464C8AC, 0x5D5DBAE7, 0x1919322B, 0x7373E695,
0x6060C0A0, 0x81811998, 0x4F4F9ED1, 0xDCDCA37F, 0x22224466, 0x2A2A547E, 0x90903BAB, 0x88880B83,
0x46468CCA, 0xEEEEC729, 0xB8B86BD3, 0x1414283C, 0xDEDEA779, 0x5E5EBCE2, 0x0B0B161D, 0xDBDBAD76,
0xE0E0DB3B, 0x32326456, 0x3A3A744E, 0x0A0A141E, 0x494992DB, 0x06060C0A, 0x2424486C, 0x5C5CB8E4,
0xC2C29F5D, 0xD3D3BD6E, 0xACAC43EF, 0x6262C4A6, 0x919139A8, 0x959531A4, 0xE4E4D337, 0x7979F28B,
0xE7E7D532, 0xC8C88B43, 0x37376E59, 0x6D6DDAB7, 0x8D8D018C, 0xD5D5B164, 0x4E4E9CD2, 0xA9A949E0,
0x6C6CD8B4, 0x5656ACFA, 0xF4F4F307, 0xEAEACF25, 0x6565CAAF, 0x7A7AF48E, 0xAEAE47E9, 0x08081018,
0xBABA6FD5, 0x7878F088, 0x25254A6F, 0x2E2E5C72, 0x1C1C3824, 0xA6A657F1, 0xB4B473C7, 0xC6C69751,
0xE8E8CB23, 0xDDDDA17C, 0x7474E89C, 0x1F1F3E21, 0x4B4B96DD, 0xBDBD61DC, 0x8B8B0D86, 0x8A8A0F85,
0x7070E090, 0x3E3E7C42, 0xB5B571C4, 0x6666CCAA, 0x484890D8, 0x03030605, 0xF6F6F701, 0x0E0E1C12,
0x6161C2A3, 0x35356A5F, 0x5757AEF9, 0xB9B969D0, 0x86861791, 0xC1C19958, 0x1D1D3A27, 0x9E9E27B9,
0xE1E1D938, 0xF8F8EB13, 0x98982BB3, 0x11112233, 0x6969D2BB, 0xD9D9A970, 0x8E8E0789, 0x949433A7,
0x9B9B2DB6, 0x1E1E3C22, 0x87871592, 0xE9E9C920, 0xCECE8749, 0x5555AAFF, 0x28285078, 0xDFDFA57A,
0x8C8C038F, 0xA1A159F8, 0x89890980, 0x0D0D1A17, 0xBFBF65DA, 0xE6E6D731, 0x424284C6, 0x6868D0B8,
0x414182C3, 0x999929B0, 0x2D2D5A77, 0x0F0F1E11, 0xB0B07BCB, 0x5454A8FC, 0xBBBB6DD6, 0x16162C3A
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
For every value found at index we have:
- bits 0..7 represent Multiply(sbox[index], 0x01).
- bits 8..15 represent Multiply(sbox[index], 0x03).
- bits 16..23 represent Multiply(sbox[index], 0x02).
- bits 24..31 represent Multiply(sbox[index], 0x01).
*/
__declspec(align(16)) static const UINT32 sBoxMixColumn_c[256] =
{
0x63C6A563, 0x7CF8847C, 0x77EE9977, 0x7BF68D7B, 0xF2FF0DF2, 0x6BD6BD6B, 0x6FDEB16F, 0xC59154C5,
0x30605030, 0x01020301, 0x67CEA967, 0x2B567D2B, 0xFEE719FE, 0xD7B562D7, 0xAB4DE6AB, 0x76EC9A76,
0xCA8F45CA, 0x821F9D82, 0xC98940C9, 0x7DFA877D, 0xFAEF15FA, 0x59B2EB59, 0x478EC947, 0xF0FB0BF0,
0xAD41ECAD, 0xD4B367D4, 0xA25FFDA2, 0xAF45EAAF, 0x9C23BF9C, 0xA453F7A4, 0x72E49672, 0xC09B5BC0,
0xB775C2B7, 0xFDE11CFD, 0x933DAE93, 0x264C6A26, 0x366C5A36, 0x3F7E413F, 0xF7F502F7, 0xCC834FCC,
0x34685C34, 0xA551F4A5, 0xE5D134E5, 0xF1F908F1, 0x71E29371, 0xD8AB73D8, 0x31625331, 0x152A3F15,
0x04080C04, 0xC79552C7, 0x23466523, 0xC39D5EC3, 0x18302818, 0x9637A196, 0x050A0F05, 0x9A2FB59A,
0x070E0907, 0x12243612, 0x801B9B80, 0xE2DF3DE2, 0xEBCD26EB, 0x274E6927, 0xB27FCDB2, 0x75EA9F75,
0x09121B09, 0x831D9E83, 0x2C58742C, 0x1A342E1A, 0x1B362D1B, 0x6EDCB26E, 0x5AB4EE5A, 0xA05BFBA0,
0x52A4F652, 0x3B764D3B, 0xD6B761D6, 0xB37DCEB3, 0x29527B29, 0xE3DD3EE3, 0x2F5E712F, 0x84139784,
0x53A6F553, 0xD1B968D1, 0x00000000, 0xEDC12CED, 0x20406020, 0xFCE31FFC, 0xB179C8B1, 0x5BB6ED5B,
0x6AD4BE6A, 0xCB8D46CB, 0xBE67D9BE, 0x39724B39, 0x4A94DE4A, 0x4C98D44C, 0x58B0E858, 0xCF854ACF,
0xD0BB6BD0, 0xEFC52AEF, 0xAA4FE5AA, 0xFBED16FB, 0x4386C543, 0x4D9AD74D, 0x33665533, 0x85119485,
0x458ACF45, 0xF9E910F9, 0x02040602, 0x7FFE817F, 0x50A0F050, 0x3C78443C, 0x9F25BA9F, 0xA84BE3A8,
0x51A2F351, 0xA35DFEA3, 0x4080C040, 0x8F058A8F, 0x923FAD92, 0x9D21BC9D, 0x38704838, 0xF5F104F5,
0xBC63DFBC, 0xB677C1B6, 0xDAAF75DA, 0x21426321, 0x10203010, 0xFFE51AFF, 0xF3FD0EF3, 0xD2BF6DD2,
0xCD814CCD, 0x0C18140C, 0x13263513, 0xECC32FEC, 0x5FBEE15F, 0x9735A297, 0x4488CC44, 0x172E3917,
0xC49357C4, 0xA755F2A7, 0x7EFC827E, 0x3D7A473D, 0x64C8AC64, 0x5DBAE75D, 0x19322B19, 0x73E69573,
0x60C0A060, 0x81199881, 0x4F9ED14F, 0xDCA37FDC, 0x22446622, 0x2A547E2A, 0x903BAB90, 0x880B8388,
0x468CCA46, 0xEEC729EE, 0xB86BD3B8, 0x14283C14, 0xDEA779DE, 0x5EBCE25E, 0x0B161D0B, 0xDBAD76DB,
0xE0DB3BE0, 0x32645632, 0x3A744E3A, 0x0A141E0A, 0x4992DB49, 0x060C0A06, 0x24486C24, 0x5CB8E45C,
0xC29F5DC2, 0xD3BD6ED3, 0xAC43EFAC, 0x62C4A662, 0x9139A891, 0x9531A495, 0xE4D337E4, 0x79F28B79,
0xE7D532E7, 0xC88B43C8, 0x376E5937, 0x6DDAB76D, 0x8D018C8D, 0xD5B164D5, 0x4E9CD24E, 0xA949E0A9,
0x6CD8B46C, 0x56ACFA56, 0xF4F307F4, 0xEACF25EA, 0x65CAAF65, 0x7AF48E7A, 0xAE47E9AE, 0x08101808,
0xBA6FD5BA, 0x78F08878, 0x254A6F25, 0x2E5C722E, 0x1C38241C, 0xA657F1A6, 0xB473C7B4, 0xC69751C6,
0xE8CB23E8, 0xDDA17CDD, 0x74E89C74, 0x1F3E211F, 0x4B96DD4B, 0xBD61DCBD, 0x8B0D868B, 0x8A0F858A,
0x70E09070, 0x3E7C423E, 0xB571C4B5, 0x66CCAA66, 0x4890D848, 0x03060503, 0xF6F701F6, 0x0E1C120E,
0x61C2A361, 0x356A5F35, 0x57AEF957, 0xB969D0B9, 0x86179186, 0xC19958C1, 0x1D3A271D, 0x9E27B99E,
0xE1D938E1, 0xF8EB13F8, 0x982BB398, 0x11223311, 0x69D2BB69, 0xD9A970D9, 0x8E07898E, 0x9433A794,
0x9B2DB69B, 0x1E3C221E, 0x87159287, 0xE9C920E9, 0xCE8749CE, 0x55AAFF55, 0x28507828, 0xDFA57ADF,
0x8C038F8C, 0xA159F8A1, 0x89098089, 0x0D1A170D, 0xBF65DABF, 0xE6D731E6, 0x4284C642, 0x68D0B868,
0x4182C341, 0x9929B099, 0x2D5A772D, 0x0F1E110F, 0xB07BCBB0, 0x54A8FC54, 0xBB6DD6BB, 0x162C3A16
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
For every value found at index we have:
- bits 0..7 represent Multiply(sbox[index], 0x01).
- bits 8..15 represent Multiply(sbox[index], 0x01).
- bits 16..23 represent Multiply(sbox[index], 0x03).
- bits 24..31 represent Multiply(sbox[index], 0x02).
*/
__declspec(align(16)) static const UINT32 sBoxMixColumn_d[256] =
{
0xC6A56363, 0xF8847C7C, 0xEE997777, 0xF68D7B7B, 0xFF0DF2F2, 0xD6BD6B6B, 0xDEB16F6F, 0x9154C5C5,
0x60503030, 0x02030101, 0xCEA96767, 0x567D2B2B, 0xE719FEFE, 0xB562D7D7, 0x4DE6ABAB, 0xEC9A7676,
0x8F45CACA, 0x1F9D8282, 0x8940C9C9, 0xFA877D7D, 0xEF15FAFA, 0xB2EB5959, 0x8EC94747, 0xFB0BF0F0,
0x41ECADAD, 0xB367D4D4, 0x5FFDA2A2, 0x45EAAFAF, 0x23BF9C9C, 0x53F7A4A4, 0xE4967272, 0x9B5BC0C0,
0x75C2B7B7, 0xE11CFDFD, 0x3DAE9393, 0x4C6A2626, 0x6C5A3636, 0x7E413F3F, 0xF502F7F7, 0x834FCCCC,
0x685C3434, 0x51F4A5A5, 0xD134E5E5, 0xF908F1F1, 0xE2937171, 0xAB73D8D8, 0x62533131, 0x2A3F1515,
0x080C0404, 0x9552C7C7, 0x46652323, 0x9D5EC3C3, 0x30281818, 0x37A19696, 0x0A0F0505, 0x2FB59A9A,
0x0E090707, 0x24361212, 0x1B9B8080, 0xDF3DE2E2, 0xCD26EBEB, 0x4E692727, 0x7FCDB2B2, 0xEA9F7575,
0x121B0909, 0x1D9E8383, 0x58742C2C, 0x342E1A1A, 0x362D1B1B, 0xDCB26E6E, 0xB4EE5A5A, 0x5BFBA0A0,
0xA4F65252, 0x764D3B3B, 0xB761D6D6, 0x7DCEB3B3, 0x527B2929, 0xDD3EE3E3, 0x5E712F2F, 0x13978484,
0xA6F55353, 0xB968D1D1, 0x00000000, 0xC12CEDED, 0x40602020, 0xE31FFCFC, 0x79C8B1B1, 0xB6ED5B5B,
0xD4BE6A6A, 0x8D46CBCB, 0x67D9BEBE, 0x724B3939, 0x94DE4A4A, 0x98D44C4C, 0xB0E85858, 0x854ACFCF,
0xBB6BD0D0, 0xC52AEFEF, 0x4FE5AAAA, 0xED16FBFB, 0x86C54343, 0x9AD74D4D, 0x66553333, 0x11948585,
0x8ACF4545, 0xE910F9F9, 0x04060202, 0xFE817F7F, 0xA0F05050, 0x78443C3C, 0x25BA9F9F, 0x4BE3A8A8,
0xA2F35151, 0x5DFEA3A3, 0x80C04040, 0x058A8F8F, 0x3FAD9292, 0x21BC9D9D, 0x70483838, 0xF104F5F5,
0x63DFBCBC, 0x77C1B6B6, 0xAF75DADA, 0x42632121, 0x20301010, 0xE51AFFFF, 0xFD0EF3F3, 0xBF6DD2D2,
0x814CCDCD, 0x18140C0C, 0x26351313, 0xC32FECEC, 0xBEE15F5F, 0x35A29797, 0x88CC4444, 0x2E391717,
0x9357C4C4, 0x55F2A7A7, 0xFC827E7E, 0x7A473D3D, 0xC8AC6464, 0xBAE75D5D, 0x322B1919, 0xE6957373,
0xC0A06060, 0x19988181, 0x9ED14F4F, 0xA37FDCDC, 0x44662222, 0x547E2A2A, 0x3BAB9090, 0x0B838888,
0x8CCA4646, 0xC729EEEE, 0x6BD3B8B8, 0x283C1414, 0xA779DEDE, 0xBCE25E5E, 0x161D0B0B, 0xAD76DBDB,
0xDB3BE0E0, 0x64563232, 0x744E3A3A, 0x141E0A0A, 0x92DB4949, 0x0C0A0606, 0x486C2424, 0xB8E45C5C,
0x9F5DC2C2, 0xBD6ED3D3, 0x43EFACAC, 0xC4A66262, 0x39A89191, 0x31A49595, 0xD337E4E4, 0xF28B7979,
0xD532E7E7, 0x8B43C8C8, 0x6E593737, 0xDAB76D6D, 0x018C8D8D, 0xB164D5D5, 0x9CD24E4E, 0x49E0A9A9,
0xD8B46C6C, 0xACFA5656, 0xF307F4F4, 0xCF25EAEA, 0xCAAF6565, 0xF48E7A7A, 0x47E9AEAE, 0x10180808,
0x6FD5BABA, 0xF0887878, 0x4A6F2525, 0x5C722E2E, 0x38241C1C, 0x57F1A6A6, 0x73C7B4B4, 0x9751C6C6,
0xCB23E8E8, 0xA17CDDDD, 0xE89C7474, 0x3E211F1F, 0x96DD4B4B, 0x61DCBDBD, 0x0D868B8B, 0x0F858A8A,
0xE0907070, 0x7C423E3E, 0x71C4B5B5, 0xCCAA6666, 0x90D84848, 0x06050303, 0xF701F6F6, 0x1C120E0E,
0xC2A36161, 0x6A5F3535, 0xAEF95757, 0x69D0B9B9, 0x17918686, 0x9958C1C1, 0x3A271D1D, 0x27B99E9E,
0xD938E1E1, 0xEB13F8F8, 0x2BB39898, 0x22331111, 0xD2BB6969, 0xA970D9D9, 0x07898E8E, 0x33A79494,
0x2DB69B9B, 0x3C221E1E, 0x15928787, 0xC920E9E9, 0x8749CECE, 0xAAFF5555, 0x50782828, 0xA57ADFDF,
0x038F8C8C, 0x59F8A1A1, 0x09808989, 0x1A170D0D, 0x65DABFBF, 0xD731E6E6, 0x84C64242, 0xD0B86868,
0x82C34141, 0x29B09999, 0x5A772D2D, 0x1E110F0F, 0x7BCBB0B0, 0xA8FC5454, 0x6DD6BBBB, 0x2C3A1616
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
For every value found at index we have:
- bits 0..7 represent Multiply(rsbox[index], 0x0E).
- bits 8..15 represent Multiply(rsbox[index], 0x09).
- bits 16..23 represent Multiply(rsbox[index], 0x0D).
- bits 24..31 represent Multiply(rsbox[index], 0x0B).
*/
__declspec(align(16)) static const UINT32 rsBoxInvMixColumn_a[256] =
{
0x50A7F451, 0x5365417E, 0xC3A4171A, 0x965E273A, 0xCB6BAB3B, 0xF1459D1F, 0xAB58FAAC, 0x9303E34B,
0x55FA3020, 0xF66D76AD, 0x9176CC88, 0x254C02F5, 0xFCD7E54F, 0xD7CB2AC5, 0x80443526, 0x8FA362B5,
0x495AB1DE, 0x671BBA25, 0x980EEA45, 0xE1C0FE5D, 0x02752FC3, 0x12F04C81, 0xA397468D, 0xC6F9D36B,
0xE75F8F03, 0x959C9215, 0xEB7A6DBF, 0xDA595295, 0x2D83BED4, 0xD3217458, 0x2969E049, 0x44C8C98E,
0x6A89C275, 0x78798EF4, 0x6B3E5899, 0xDD71B927, 0xB64FE1BE, 0x17AD88F0, 0x66AC20C9, 0xB43ACE7D,
0x184ADF63, 0x82311AE5, 0x60335197, 0x457F5362, 0xE07764B1, 0x84AE6BBB, 0x1CA081FE, 0x942B08F9,
0x58684870, 0x19FD458F, 0x876CDE94, 0xB7F87B52, 0x23D373AB, 0xE2024B72, 0x578F1FE3, 0x2AAB5566,
0x0728EBB2, 0x03C2B52F, 0x9A7BC586, 0xA50837D3, 0xF2872830, 0xB2A5BF23, 0xBA6A0302, 0x5C8216ED,
0x2B1CCF8A, 0x92B479A7, 0xF0F207F3, 0xA1E2694E, 0xCDF4DA65, 0xD5BE0506, 0x1F6234D1, 0x8AFEA6C4,
0x9D532E34, 0xA055F3A2, 0x32E18A05, 0x75EBF6A4, 0x39EC830B, 0xAAEF6040, 0x069F715E, 0x51106EBD,
0xF98A213E, 0x3D06DD96, 0xAE053EDD, 0x46BDE64D, 0xB58D5491, 0x055DC471, 0x6FD40604, 0xFF155060,
0x24FB9819, 0x97E9BDD6, 0xCC434089, 0x779ED967, 0xBD42E8B0, 0x888B8907, 0x385B19E7, 0xDBEEC879,
0x470A7CA1, 0xE90F427C, 0xC91E84F8, 0x00000000, 0x83868009, 0x48ED2B32, 0xAC70111E, 0x4E725A6C,
0xFBFF0EFD, 0x5638850F, 0x1ED5AE3D, 0x27392D36, 0x64D90F0A, 0x21A65C68, 0xD1545B9B, 0x3A2E3624,
0xB1670A0C, 0x0FE75793, 0xD296EEB4, 0x9E919B1B, 0x4FC5C080, 0xA220DC61, 0x694B775A, 0x161A121C,
0x0ABA93E2, 0xE52AA0C0, 0x43E0223C, 0x1D171B12, 0x0B0D090E, 0xADC78BF2, 0xB9A8B62D, 0xC8A91E14,
0x8519F157, 0x4C0775AF, 0xBBDD99EE, 0xFD607FA3, 0x9F2601F7, 0xBCF5725C, 0xC53B6644, 0x347EFB5B,
0x7629438B, 0xDCC623CB, 0x68FCEDB6, 0x63F1E4B8, 0xCADC31D7, 0x10856342, 0x40229713, 0x2011C684,
0x7D244A85, 0xF83DBBD2, 0x1132F9AE, 0x6DA129C7, 0x4B2F9E1D, 0xF330B2DC, 0xEC52860D, 0xD0E3C177,
0x6C16B32B, 0x99B970A9, 0xFA489411, 0x2264E947, 0xC48CFCA8, 0x1A3FF0A0, 0xD82C7D56, 0xEF903322,
0xC74E4987, 0xC1D138D9, 0xFEA2CA8C, 0x360BD498, 0xCF81F5A6, 0x28DE7AA5, 0x268EB7DA, 0xA4BFAD3F,
0xE49D3A2C, 0x0D927850, 0x9BCC5F6A, 0x62467E54, 0xC2138DF6, 0xE8B8D890, 0x5EF7392E, 0xF5AFC382,
0xBE805D9F, 0x7C93D069, 0xA92DD56F, 0xB31225CF, 0x3B99ACC8, 0xA77D1810, 0x6E639CE8, 0x7BBB3BDB,
0x097826CD, 0xF418596E, 0x01B79AEC, 0xA89A4F83, 0x656E95E6, 0x7EE6FFAA, 0x08CFBC21, 0xE6E815EF,
0xD99BE7BA, 0xCE366F4A, 0xD4099FEA, 0xD67CB029, 0xAFB2A431, 0x31233F2A, 0x3094A5C6, 0xC066A235,
0x37BC4E74, 0xA6CA82FC, 0xB0D090E0, 0x15D8A733, 0x4A9804F1, 0xF7DAEC41, 0x0E50CD7F, 0x2FF69117,
0x8DD64D76, 0x4DB0EF43, 0x544DAACC, 0xDF0496E4, 0xE3B5D19E, 0x1B886A4C, 0xB81F2CC1, 0x7F516546,
0x04EA5E9D, 0x5D358C01, 0x737487FA, 0x2E410BFB, 0x5A1D67B3, 0x52D2DB92, 0x335610E9, 0x1347D66D,
0x8C61D79A, 0x7A0CA137, 0x8E14F859, 0x893C13EB, 0xEE27A9CE, 0x35C961B7, 0xEDE51CE1, 0x3CB1477A,
0x59DFD29C, 0x3F73F255, 0x79CE1418, 0xBF37C773, 0xEACDF753, 0x5BAAFD5F, 0x146F3DDF, 0x86DB4478,
0x81F3AFCA, 0x3EC468B9, 0x2C342438, 0x5F40A3C2, 0x72C31D16, 0x0C25E2BC, 0x8B493C28, 0x41950DFF,
0x7101A839, 0xDEB30C08, 0x9CE4B4D8, 0x90C15664, 0x6184CB7B, 0x70B632D5, 0x745C6C48, 0x4257B8D0
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
For every value found at index we have:
- bits 0..7 represent Multiply(rsbox[index], 0x0B).
- bits 8..15 represent Multiply(rsbox[index], 0x0E).
- bits 16..23 represent Multiply(rsbox[index], 0x09).
- bits 24..31 represent Multiply(rsbox[index], 0x0D).
*/
__declspec(align(16)) static const UINT32 rsBoxInvMixColumn_b[256] =
{
0xA7F45150, 0x65417E53, 0xA4171AC3, 0x5E273A96, 0x6BAB3BCB, 0x459D1FF1, 0x58FAACAB, 0x03E34B93,
0xFA302055, 0x6D76ADF6, 0x76CC8891, 0x4C02F525, 0xD7E54FFC, 0xCB2AC5D7, 0x44352680, 0xA362B58F,
0x5AB1DE49, 0x1BBA2567, 0x0EEA4598, 0xC0FE5DE1, 0x752FC302, 0xF04C8112, 0x97468DA3, 0xF9D36BC6,
0x5F8F03E7, 0x9C921595, 0x7A6DBFEB, 0x595295DA, 0x83BED42D, 0x217458D3, 0x69E04929, 0xC8C98E44,
0x89C2756A, 0x798EF478, 0x3E58996B, 0x71B927DD, 0x4FE1BEB6, 0xAD88F017, 0xAC20C966, 0x3ACE7DB4,
0x4ADF6318, 0x311AE582, 0x33519760, 0x7F536245, 0x7764B1E0, 0xAE6BBB84, 0xA081FE1C, 0x2B08F994,
0x68487058, 0xFD458F19, 0x6CDE9487, 0xF87B52B7, 0xD373AB23, 0x024B72E2, 0x8F1FE357, 0xAB55662A,
0x28EBB207, 0xC2B52F03, 0x7BC5869A, 0x0837D3A5, 0x872830F2, 0xA5BF23B2, 0x6A0302BA, 0x8216ED5C,
0x1CCF8A2B, 0xB479A792, 0xF207F3F0, 0xE2694EA1, 0xF4DA65CD, 0xBE0506D5, 0x6234D11F, 0xFEA6C48A,
0x532E349D, 0x55F3A2A0, 0xE18A0532, 0xEBF6A475, 0xEC830B39, 0xEF6040AA, 0x9F715E06, 0x106EBD51,
0x8A213EF9, 0x06DD963D, 0x053EDDAE, 0xBDE64D46, 0x8D5491B5, 0x5DC47105, 0xD406046F, 0x155060FF,
0xFB981924, 0xE9BDD697, 0x434089CC, 0x9ED96777, 0x42E8B0BD, 0x8B890788, 0x5B19E738, 0xEEC879DB,
0x0A7CA147, 0x0F427CE9, 0x1E84F8C9, 0x00000000, 0x86800983, 0xED2B3248, 0x70111EAC, 0x725A6C4E,
0xFF0EFDFB, 0x38850F56, 0xD5AE3D1E, 0x392D3627, 0xD90F0A64, 0xA65C6821, 0x545B9BD1, 0x2E36243A,
0x670A0CB1, 0xE757930F, 0x96EEB4D2, 0x919B1B9E, 0xC5C0804F, 0x20DC61A2, 0x4B775A69, 0x1A121C16,
0xBA93E20A, 0x2AA0C0E5, 0xE0223C43, 0x171B121D, 0x0D090E0B, 0xC78BF2AD, 0xA8B62DB9, 0xA91E14C8,
0x19F15785, 0x0775AF4C, 0xDD99EEBB, 0x607FA3FD, 0x2601F79F, 0xF5725CBC, 0x3B6644C5, 0x7EFB5B34,
0x29438B76, 0xC623CBDC, 0xFCEDB668, 0xF1E4B863, 0xDC31D7CA, 0x85634210, 0x22971340, 0x11C68420,
0x244A857D, 0x3DBBD2F8, 0x32F9AE11, 0xA129C76D, 0x2F9E1D4B, 0x30B2DCF3, 0x52860DEC, 0xE3C177D0,
0x16B32B6C, 0xB970A999, 0x489411FA, 0x64E94722, 0x8CFCA8C4, 0x3FF0A01A, 0x2C7D56D8, 0x903322EF,
0x4E4987C7, 0xD138D9C1, 0xA2CA8CFE, 0x0BD49836, 0x81F5A6CF, 0xDE7AA528, 0x8EB7DA26, 0xBFAD3FA4,
0x9D3A2CE4, 0x9278500D, 0xCC5F6A9B, 0x467E5462, 0x138DF6C2, 0xB8D890E8, 0xF7392E5E, 0xAFC382F5,
0x805D9FBE, 0x93D0697C, 0x2DD56FA9, 0x1225CFB3, 0x99ACC83B, 0x7D1810A7, 0x639CE86E, 0xBB3BDB7B,
0x7826CD09, 0x18596EF4, 0xB79AEC01, 0x9A4F83A8, 0x6E95E665, 0xE6FFAA7E, 0xCFBC2108, 0xE815EFE6,
0x9BE7BAD9, 0x366F4ACE, 0x099FEAD4, 0x7CB029D6, 0xB2A431AF, 0x233F2A31, 0x94A5C630, 0x66A235C0,
0xBC4E7437, 0xCA82FCA6, 0xD090E0B0, 0xD8A73315, 0x9804F14A, 0xDAEC41F7, 0x50CD7F0E, 0xF691172F,
0xD64D768D, 0xB0EF434D, 0x4DAACC54, 0x0496E4DF, 0xB5D19EE3, 0x886A4C1B, 0x1F2CC1B8, 0x5165467F,
0xEA5E9D04, 0x358C015D, 0x7487FA73, 0x410BFB2E, 0x1D67B35A, 0xD2DB9252, 0x5610E933, 0x47D66D13,
0x61D79A8C, 0x0CA1377A, 0x14F8598E, 0x3C13EB89, 0x27A9CEEE, 0xC961B735, 0xE51CE1ED, 0xB1477A3C,
0xDFD29C59, 0x73F2553F, 0xCE141879, 0x37C773BF, 0xCDF753EA, 0xAAFD5F5B, 0x6F3DDF14, 0xDB447886,
0xF3AFCA81, 0xC468B93E, 0x3424382C, 0x40A3C25F, 0xC31D1672, 0x25E2BC0C, 0x493C288B, 0x950DFF41,
0x01A83971, 0xB30C08DE, 0xE4B4D89C, 0xC1566490, 0x84CB7B61, 0xB632D570, 0x5C6C4874, 0x57B8D042
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
For every value found at index we have:
- bits 0..7 represent Multiply(rsbox[index], 0x0D).
- bits 8..15 represent Multiply(rsbox[index], 0x0B).
- bits 16..23 represent Multiply(rsbox[index], 0x0E).
- bits 24..31 represent Multiply(rsbox[index], 0x09).
*/
__declspec(align(16)) static const UINT32 rsBoxInvMixColumn_c[256] =
{
0xF45150A7, 0x417E5365, 0x171AC3A4, 0x273A965E, 0xAB3BCB6B, 0x9D1FF145, 0xFAACAB58, 0xE34B9303,
0x302055FA, 0x76ADF66D, 0xCC889176, 0x02F5254C, 0xE54FFCD7, 0x2AC5D7CB, 0x35268044, 0x62B58FA3,
0xB1DE495A, 0xBA25671B, 0xEA45980E, 0xFE5DE1C0, 0x2FC30275, 0x4C8112F0, 0x468DA397, 0xD36BC6F9,
0x8F03E75F, 0x9215959C, 0x6DBFEB7A, 0x5295DA59, 0xBED42D83, 0x7458D321, 0xE0492969, 0xC98E44C8,
0xC2756A89, 0x8EF47879, 0x58996B3E, 0xB927DD71, 0xE1BEB64F, 0x88F017AD, 0x20C966AC, 0xCE7DB43A,
0xDF63184A, 0x1AE58231, 0x51976033, 0x5362457F, 0x64B1E077, 0x6BBB84AE, 0x81FE1CA0, 0x08F9942B,
0x48705868, 0x458F19FD, 0xDE94876C, 0x7B52B7F8, 0x73AB23D3, 0x4B72E202, 0x1FE3578F, 0x55662AAB,
0xEBB20728, 0xB52F03C2, 0xC5869A7B, 0x37D3A508, 0x2830F287, 0xBF23B2A5, 0x0302BA6A, 0x16ED5C82,
0xCF8A2B1C, 0x79A792B4, 0x07F3F0F2, 0x694EA1E2, 0xDA65CDF4, 0x0506D5BE, 0x34D11F62, 0xA6C48AFE,
0x2E349D53, 0xF3A2A055, 0x8A0532E1, 0xF6A475EB, 0x830B39EC, 0x6040AAEF, 0x715E069F, 0x6EBD5110,
0x213EF98A, 0xDD963D06, 0x3EDDAE05, 0xE64D46BD, 0x5491B58D, 0xC471055D, 0x06046FD4, 0x5060FF15,
0x981924FB, 0xBDD697E9, 0x4089CC43, 0xD967779E, 0xE8B0BD42, 0x8907888B, 0x19E7385B, 0xC879DBEE,
0x7CA1470A, 0x427CE90F, 0x84F8C91E, 0x00000000, 0x80098386, 0x2B3248ED, 0x111EAC70, 0x5A6C4E72,
0x0EFDFBFF, 0x850F5638, 0xAE3D1ED5, 0x2D362739, 0x0F0A64D9, 0x5C6821A6, 0x5B9BD154, 0x36243A2E,
0x0A0CB167, 0x57930FE7, 0xEEB4D296, 0x9B1B9E91, 0xC0804FC5, 0xDC61A220, 0x775A694B, 0x121C161A,
0x93E20ABA, 0xA0C0E52A, 0x223C43E0, 0x1B121D17, 0x090E0B0D, 0x8BF2ADC7, 0xB62DB9A8, 0x1E14C8A9,
0xF1578519, 0x75AF4C07, 0x99EEBBDD, 0x7FA3FD60, 0x01F79F26, 0x725CBCF5, 0x6644C53B, 0xFB5B347E,
0x438B7629, 0x23CBDCC6, 0xEDB668FC, 0xE4B863F1, 0x31D7CADC, 0x63421085, 0x97134022, 0xC6842011,
0x4A857D24, 0xBBD2F83D, 0xF9AE1132, 0x29C76DA1, 0x9E1D4B2F, 0xB2DCF330, 0x860DEC52, 0xC177D0E3,
0xB32B6C16, 0x70A999B9, 0x9411FA48, 0xE9472264, 0xFCA8C48C, 0xF0A01A3F, 0x7D56D82C, 0x3322EF90,
0x4987C74E, 0x38D9C1D1, 0xCA8CFEA2, 0xD498360B, 0xF5A6CF81, 0x7AA528DE, 0xB7DA268E, 0xAD3FA4BF,
0x3A2CE49D, 0x78500D92, 0x5F6A9BCC, 0x7E546246, 0x8DF6C213, 0xD890E8B8, 0x392E5EF7, 0xC382F5AF,
0x5D9FBE80, 0xD0697C93, 0xD56FA92D, 0x25CFB312, 0xACC83B99, 0x1810A77D, 0x9CE86E63, 0x3BDB7BBB,
0x26CD0978, 0x596EF418, 0x9AEC01B7, 0x4F83A89A, 0x95E6656E, 0xFFAA7EE6, 0xBC2108CF, 0x15EFE6E8,
0xE7BAD99B, 0x6F4ACE36, 0x9FEAD409, 0xB029D67C, 0xA431AFB2, 0x3F2A3123, 0xA5C63094, 0xA235C066,
0x4E7437BC, 0x82FCA6CA, 0x90E0B0D0, 0xA73315D8, 0x04F14A98, 0xEC41F7DA, 0xCD7F0E50, 0x91172FF6,
0x4D768DD6, 0xEF434DB0, 0xAACC544D, 0x96E4DF04, 0xD19EE3B5, 0x6A4C1B88, 0x2CC1B81F, 0x65467F51,
0x5E9D04EA, 0x8C015D35, 0x87FA7374, 0x0BFB2E41, 0x67B35A1D, 0xDB9252D2, 0x10E93356, 0xD66D1347,
0xD79A8C61, 0xA1377A0C, 0xF8598E14, 0x13EB893C, 0xA9CEEE27, 0x61B735C9, 0x1CE1EDE5, 0x477A3CB1,
0xD29C59DF, 0xF2553F73, 0x141879CE, 0xC773BF37, 0xF753EACD, 0xFD5F5BAA, 0x3DDF146F, 0x447886DB,
0xAFCA81F3, 0x68B93EC4, 0x24382C34, 0xA3C25F40, 0x1D1672C3, 0xE2BC0C25, 0x3C288B49, 0x0DFF4195,
0xA8397101, 0x0C08DEB3, 0xB4D89CE4, 0x566490C1, 0xCB7B6184, 0x32D570B6, 0x6C48745C, 0xB8D04257
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
For every value found at index we have:
- bits 0..7 represent Multiply(rsbox[index], 0x09).
- bits 8..15 represent Multiply(rsbox[index], 0x0D).
- bits 16..23 represent Multiply(rsbox[index], 0x0B).
- bits 24..31 represent Multiply(rsbox[index], 0x0E).
*/
__declspec(align(16)) static const UINT32 rsBoxInvMixColumn_d[256] =
{
0x5150A7F4, 0x7E536541, 0x1AC3A417, 0x3A965E27, 0x3BCB6BAB, 0x1FF1459D, 0xACAB58FA, 0x4B9303E3,
0x2055FA30, 0xADF66D76, 0x889176CC, 0xF5254C02, 0x4FFCD7E5, 0xC5D7CB2A, 0x26804435, 0xB58FA362,
0xDE495AB1, 0x25671BBA, 0x45980EEA, 0x5DE1C0FE, 0xC302752F, 0x8112F04C, 0x8DA39746, 0x6BC6F9D3,
0x03E75F8F, 0x15959C92, 0xBFEB7A6D, 0x95DA5952, 0xD42D83BE, 0x58D32174, 0x492969E0, 0x8E44C8C9,
0x756A89C2, 0xF478798E, 0x996B3E58, 0x27DD71B9, 0xBEB64FE1, 0xF017AD88, 0xC966AC20, 0x7DB43ACE,
0x63184ADF, 0xE582311A, 0x97603351, 0x62457F53, 0xB1E07764, 0xBB84AE6B, 0xFE1CA081, 0xF9942B08,
0x70586848, 0x8F19FD45, 0x94876CDE, 0x52B7F87B, 0xAB23D373, 0x72E2024B, 0xE3578F1F, 0x662AAB55,
0xB20728EB, 0x2F03C2B5, 0x869A7BC5, 0xD3A50837, 0x30F28728, 0x23B2A5BF, 0x02BA6A03, 0xED5C8216,
0x8A2B1CCF, 0xA792B479, 0xF3F0F207, 0x4EA1E269, 0x65CDF4DA, 0x06D5BE05, 0xD11F6234, 0xC48AFEA6,
0x349D532E, 0xA2A055F3, 0x0532E18A, 0xA475EBF6, 0x0B39EC83, 0x40AAEF60, 0x5E069F71, 0xBD51106E,
0x3EF98A21, 0x963D06DD, 0xDDAE053E, 0x4D46BDE6, 0x91B58D54, 0x71055DC4, 0x046FD406, 0x60FF1550,
0x1924FB98, 0xD697E9BD, 0x89CC4340, 0x67779ED9, 0xB0BD42E8, 0x07888B89, 0xE7385B19, 0x79DBEEC8,
0xA1470A7C, 0x7CE90F42, 0xF8C91E84, 0x00000000, 0x09838680, 0x3248ED2B, 0x1EAC7011, 0x6C4E725A,
0xFDFBFF0E, 0x0F563885, 0x3D1ED5AE, 0x3627392D, 0x0A64D90F, 0x6821A65C, 0x9BD1545B, 0x243A2E36,
0x0CB1670A, 0x930FE757, 0xB4D296EE, 0x1B9E919B, 0x804FC5C0, 0x61A220DC, 0x5A694B77, 0x1C161A12,
0xE20ABA93, 0xC0E52AA0, 0x3C43E022, 0x121D171B, 0x0E0B0D09, 0xF2ADC78B, 0x2DB9A8B6, 0x14C8A91E,
0x578519F1, 0xAF4C0775, 0xEEBBDD99, 0xA3FD607F, 0xF79F2601, 0x5CBCF572, 0x44C53B66, 0x5B347EFB,
0x8B762943, 0xCBDCC623, 0xB668FCED, 0xB863F1E4, 0xD7CADC31, 0x42108563, 0x13402297, 0x842011C6,
0x857D244A, 0xD2F83DBB, 0xAE1132F9, 0xC76DA129, 0x1D4B2F9E, 0xDCF330B2, 0x0DEC5286, 0x77D0E3C1,
0x2B6C16B3, 0xA999B970, 0x11FA4894, 0x472264E9, 0xA8C48CFC, 0xA01A3FF0, 0x56D82C7D, 0x22EF9033,
0x87C74E49, 0xD9C1D138, 0x8CFEA2CA, 0x98360BD4, 0xA6CF81F5, 0xA528DE7A, 0xDA268EB7, 0x3FA4BFAD,
0x2CE49D3A, 0x500D9278, 0x6A9BCC5F, 0x5462467E, 0xF6C2138D, 0x90E8B8D8, 0x2E5EF739, 0x82F5AFC3,
0x9FBE805D, 0x697C93D0, 0x6FA92DD5, 0xCFB31225, 0xC83B99AC, 0x10A77D18, 0xE86E639C, 0xDB7BBB3B,
0xCD097826, 0x6EF41859, 0xEC01B79A, 0x83A89A4F, 0xE6656E95, 0xAA7EE6FF, 0x2108CFBC, 0xEFE6E815,
0xBAD99BE7, 0x4ACE366F, 0xEAD4099F, 0x29D67CB0, 0x31AFB2A4, 0x2A31233F, 0xC63094A5, 0x35C066A2,
0x7437BC4E, 0xFCA6CA82, 0xE0B0D090, 0x3315D8A7, 0xF14A9804, 0x41F7DAEC, 0x7F0E50CD, 0x172FF691,
0x768DD64D, 0x434DB0EF, 0xCC544DAA, 0xE4DF0496, 0x9EE3B5D1, 0x4C1B886A, 0xC1B81F2C, 0x467F5165,
0x9D04EA5E, 0x015D358C, 0xFA737487, 0xFB2E410B, 0xB35A1D67, 0x9252D2DB, 0xE9335610, 0x6D1347D6,
0x9A8C61D7, 0x377A0CA1, 0x598E14F8, 0xEB893C13, 0xCEEE27A9, 0xB735C961, 0xE1EDE51C, 0x7A3CB147,
0x9C59DFD2, 0x553F73F2, 0x1879CE14, 0x73BF37C7, 0x53EACDF7, 0x5F5BAAFD, 0xDF146F3D, 0x7886DB44,
0xCA81F3AF, 0xB93EC468, 0x382C3424, 0xC25F40A3, 0x1672C31D, 0xBC0C25E2, 0x288B493C, 0xFF41950D,
0x397101A8, 0x08DEB30C, 0xD89CE4B4, 0x6490C156, 0x7B6184CB, 0xD570B632, 0x48745C6C, 0xD04257B8
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
AES_CPU_Impl_O2::EncryptBlock(UINT8 *dst, const UINT8 *src)
{
UINT32 *r_key = (UINT32*)m_keyEnc,
*src32 = (UINT32*)src,
*dst32 = (UINT32*)dst;
// First round will copy the data in the state and add the round key
UINT32 s1 = src32[0] ^ r_key[0];
UINT32 s2 = src32[1] ^ r_key[1];
UINT32 s3 = src32[2] ^ r_key[2];
UINT32 s4 = src32[3] ^ r_key[3];
// Do the rest of the rounds
r_key += 4;
UINT32 round = m_Nr - 1;
do
{
// Make SubBytes, ShiftRows, MixColumns and AddRoundKey in the same step and put the result back the state
UINT32 st1 = sBoxMixColumn_a[s1 & 0xFF] ^
sBoxMixColumn_b[(s2 >> 8) & 0xFF] ^
sBoxMixColumn_c[(s3 >> 16) & 0xFF] ^
sBoxMixColumn_d[s4 >> 24] ^
r_key[0];
UINT32 st2 = sBoxMixColumn_a[s2 & 0xFF] ^
sBoxMixColumn_b[(s3 >> 8) & 0xFF] ^
sBoxMixColumn_c[(s4 >> 16) & 0xFF] ^
sBoxMixColumn_d[s1 >> 24] ^
r_key[1];
UINT32 st3 = sBoxMixColumn_a[s3 & 0xFF] ^
sBoxMixColumn_b[(s4 >> 8) & 0xFF] ^
sBoxMixColumn_c[(s1 >> 16) & 0xFF] ^
sBoxMixColumn_d[s2 >> 24] ^
r_key[2];
UINT32 st4 = sBoxMixColumn_a[s4 & 0xFF] ^
sBoxMixColumn_b[(s1 >> 8) & 0xFF] ^
sBoxMixColumn_c[(s2 >> 16) & 0xFF] ^
sBoxMixColumn_d[s3 >> 24] ^
r_key[3];
s1 = st1;
s2 = st2;
s3 = st3;
s4 = st4;
r_key += 4;
}while (--round);
// The last round is special because does not have MixColumns
// Make SubBytes, ShiftRows and AddRoundKey in the same step and copy the result in destination
dst32[0] = ( sbox[s1 & 0xFF] |
(sbox[(s2 >> 8) & 0xFF] << 8) |
(sbox[(s3 >> 16) & 0xFF] << 16) |
(sbox[s4 >> 24] << 24)
) ^ r_key[0];
dst32[1] = ( sbox[s2 & 0xFF] |
(sbox[(s3 >> 8) & 0xFF] << 8) |
(sbox[(s4 >> 16) & 0xFF] << 16) |
(sbox[s1 >> 24] << 24)
) ^ r_key[1];
dst32[2] = ( sbox[s3 & 0xFF] |
(sbox[(s4 >> 8) & 0xFF] << 8) |
(sbox[(s1 >> 16) & 0xFF] << 16) |
(sbox[s2 >> 24] << 24)
) ^ r_key[2];
dst32[3] = ( sbox[s4 & 0xFF] |
(sbox[(s1 >> 8) & 0xFF] << 8) |
(sbox[(s2 >> 16) & 0xFF] << 16) |
(sbox[s3 >> 24] << 24)
) ^ r_key[3];
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
AES_CPU_Impl_O2::DecryptBlock(UINT8 *dst, const UINT8 *src)
{
UINT32 *r_key = (UINT32*)m_keyDec,
*src32 = (UINT32*)src,
*dst32 = (UINT32*)dst;
// First round will copy the data in the state and add the round key
UINT32 s1 = src32[0] ^ r_key[0];
UINT32 s2 = src32[1] ^ r_key[1];
UINT32 s3 = src32[2] ^ r_key[2];
UINT32 s4 = src32[3] ^ r_key[3];
// Do the rest of the rounds
r_key += 4;
UINT32 round = m_Nr - 1;
do
{
// Make InvShiftRows, InvSubBytes, InvMixColumns and AddRoundKey in the same step and put the result back in the state
UINT32 st1 = rsBoxInvMixColumn_a[s1 & 0xFF] ^
rsBoxInvMixColumn_b[(s4 >> 8) & 0xFF] ^
rsBoxInvMixColumn_c[(s3 >> 16) & 0xFF] ^
rsBoxInvMixColumn_d[s2 >> 24] ^
r_key[0];
UINT32 st2 = rsBoxInvMixColumn_a[s2 & 0xFF] ^
rsBoxInvMixColumn_b[(s1 >> 8) & 0xFF] ^
rsBoxInvMixColumn_c[(s4 >> 16) & 0xFF] ^
rsBoxInvMixColumn_d[s3 >> 24] ^
r_key[1];
UINT32 st3 = rsBoxInvMixColumn_a[s3 & 0xFF] ^
rsBoxInvMixColumn_b[(s2 >> 8) & 0xFF] ^
rsBoxInvMixColumn_c[(s1 >> 16) & 0xFF] ^
rsBoxInvMixColumn_d[s4 >> 24] ^
r_key[2];
UINT32 st4 = rsBoxInvMixColumn_a[s4 & 0xFF] ^
rsBoxInvMixColumn_b[(s3 >> 8) & 0xFF] ^
rsBoxInvMixColumn_c[(s2 >> 16) & 0xFF] ^
rsBoxInvMixColumn_d[s1 >> 24] ^
r_key[3];
s1 = st1;
s2 = st2;
s3 = st3;
s4 = st4;
r_key += 4;
}while(--round);
// The last round is special because does not have InvMixColumns
// Make InvShiftRows, InvSubBytes and AddRoundKey in the same step and copy the result in destination
dst32[0] = ( rsbox[s1 & 0xFF] |
(rsbox[(s4 >> 8) & 0xFF] << 8) |
(rsbox[(s3 >> 16) & 0xFF] << 16)|
(rsbox[s2 >> 24] << 24)
) ^ r_key[0];
dst32[1] = ( rsbox[s2 & 0xFF] |
(rsbox[(s1 >> 8) & 0xFF] << 8) |
(rsbox[(s4 >> 16) & 0xFF] << 16)|
(rsbox[s3 >> 24] << 24)
) ^ r_key[1];
dst32[2] = ( rsbox[s3 & 0xFF] |
(rsbox[(s2 >> 8) & 0xFF] << 8) |
(rsbox[(s1 >> 16) & 0xFF] << 16)|
(rsbox[s4 >> 24] << 24)
) ^ r_key[2];
dst32[3] = ( rsbox[s4 & 0xFF] |
(rsbox[(s3 >> 8) & 0xFF] << 8) |
(rsbox[(s2 >> 16) & 0xFF] << 16)|
(rsbox[s1 >> 24] << 24)
) ^ r_key[3];
}
| [
"[email protected]"
]
| [
[
[
1,
572
]
]
]
|
369b3c125c4debc255f1fb9a3116da49d04e8197 | 0e25e68e96c9883edcc85cbee6d24fdfd49cf8e5 | /source/SquareImageProvider.cpp | f7fcbef5b7a8fb24d9c5f94dcf294a4cda23fece | []
| no_license | dpembo/tetwiis | ff334a52ce2b41e79790c37fbe6630d26b1eb2b7 | 207692026d767b1a3aa9909ba9c6297cfd78fae0 | refs/heads/master | 2021-08-17T10:36:38.264831 | 2011-08-03T11:25:21 | 2011-08-03T11:25:21 | 32,199,080 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,291 | cpp | /**
*
* Tetwiis
* (C)2009 http://www.pembo.co.uk
*
**/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
# include "SquareImageProvider.h"
//------------------------------------------------------------------------------
// Externals
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Globals
//------------------------------------------------------------------------------
static GRRLIB_texImg *tex_sqimage;
//_______________________________________________________________________________
/**
* constructor
*/
SquareImageProvider::SquareImageProvider()
{
}
//_______________________________________________________________________________
/**
* destructor
*/
SquareImageProvider::~SquareImageProvider()
{
free(tex_sqimage);
}
void SquareImageProvider::initialise()
{
tex_sqimage=GRRLIB_LoadTexturePNG(squareimage);
}
void SquareImageProvider::drawSquare(int x, int y, int rotation, int zoomx, int zoomy, u32 color)
{
GRRLIB_DrawImg(x,y,tex_sqimage,rotation,zoomx,zoomy,color);
}
| [
"[email protected]@d3020fdf-8559-019b-6164-6b32d0407fe0"
]
| [
[
[
1,
50
]
]
]
|
a8ce1e1e4d0e6aac01b8e8ed2ade7aa059b1bd4f | 81b7033dd0d0203290795b51513a4014b084d39d | /hash/sha256.h | 940beea02d54dc6060e6e30696484eb02518457a | []
| no_license | starcid/lua-binding-libraries | d27f5c2fccfeae2d667fdb60c86c3244d9ddc065 | e33c85f773d88d3b31b026464066264820e4c302 | refs/heads/master | 2016-08-04T19:57:05.839477 | 2010-11-15T12:02:08 | 2010-11-15T12:02:08 | 35,589,712 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,399 | h | #ifndef HASH_SHA256_H_
#define HASH_SHA256_H_
#define SHA256Ch(x,y,z) (z ^ (x & (y ^ z)))
#define SHA256Maj(x,y,z) (((x | y) & z) | (x & y))
#define SHA256S(x, n) RORc((x),(n))
#define SHA256R(x, n) (((x)&0xFFFFFFFFUL)>>(n))
#define SHA256Sigma0(x) (SHA256S(x, 2) ^ SHA256S(x, 13) ^ SHA256S(x, 22))
#define SHA256Sigma1(x) (SHA256S(x, 6) ^ SHA256S(x, 11) ^ SHA256S(x, 25))
#define SHA256Gamma0(x) (SHA256S(x, 7) ^ SHA256S(x, 18) ^ SHA256R(x, 3))
#define SHA256Gamma1(x) (SHA256S(x, 17) ^ SHA256S(x, 19) ^ SHA256R(x, 10))
struct SHA256_CTX {
ulong64 length;
ulong32 state[8], curlen;
unsigned char buf[64];
};
class CSHA256 : public CHashUpdate<CSHA256>
{
protected:
SHA256_CTX m_context;
public:
enum { nDigestLength =32 };
int Compress(unsigned char *buf)
{
ulong32 S[8], W[64], t0, t1;
int i;
/* copy state into S */
for (i = 0; i < 8; i++) {
S[i] = m_context.state[i];
}
/* copy the state into 512-bits into W[0..15] */
for (i = 0; i < 16; i++) {
LOAD32H(W[i], buf + (4*i));
}
/* fill W[16..63] */
for (i = 16; i < 64; i++) {
W[i] = SHA256Gamma1(W[i - 2]) + W[i - 7] + SHA256Gamma0(W[i - 15]) + W[i - 16];
}
/* Compress */
#define SHA256RND(a,b,c,d,e,f,g,h,i,ki) \
t0 = h + SHA256Sigma1(e) + SHA256Ch(e, f, g) + ki + W[i]; \
t1 = SHA256Sigma0(a) + SHA256Maj(a, b, c); \
d += t0; \
h = t0 + t1;
SHA256RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],0,0x428a2f98);
SHA256RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],1,0x71374491);
SHA256RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],2,0xb5c0fbcf);
SHA256RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],3,0xe9b5dba5);
SHA256RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],4,0x3956c25b);
SHA256RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],5,0x59f111f1);
SHA256RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],6,0x923f82a4);
SHA256RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],7,0xab1c5ed5);
SHA256RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],8,0xd807aa98);
SHA256RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],9,0x12835b01);
SHA256RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],10,0x243185be);
SHA256RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],11,0x550c7dc3);
SHA256RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],12,0x72be5d74);
SHA256RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],13,0x80deb1fe);
SHA256RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],14,0x9bdc06a7);
SHA256RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],15,0xc19bf174);
SHA256RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],16,0xe49b69c1);
SHA256RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],17,0xefbe4786);
SHA256RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],18,0x0fc19dc6);
SHA256RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],19,0x240ca1cc);
SHA256RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],20,0x2de92c6f);
SHA256RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],21,0x4a7484aa);
SHA256RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],22,0x5cb0a9dc);
SHA256RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],23,0x76f988da);
SHA256RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],24,0x983e5152);
SHA256RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],25,0xa831c66d);
SHA256RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],26,0xb00327c8);
SHA256RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],27,0xbf597fc7);
SHA256RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],28,0xc6e00bf3);
SHA256RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],29,0xd5a79147);
SHA256RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],30,0x06ca6351);
SHA256RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],31,0x14292967);
SHA256RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],32,0x27b70a85);
SHA256RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],33,0x2e1b2138);
SHA256RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],34,0x4d2c6dfc);
SHA256RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],35,0x53380d13);
SHA256RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],36,0x650a7354);
SHA256RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],37,0x766a0abb);
SHA256RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],38,0x81c2c92e);
SHA256RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],39,0x92722c85);
SHA256RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],40,0xa2bfe8a1);
SHA256RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],41,0xa81a664b);
SHA256RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],42,0xc24b8b70);
SHA256RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],43,0xc76c51a3);
SHA256RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],44,0xd192e819);
SHA256RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],45,0xd6990624);
SHA256RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],46,0xf40e3585);
SHA256RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],47,0x106aa070);
SHA256RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],48,0x19a4c116);
SHA256RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],49,0x1e376c08);
SHA256RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],50,0x2748774c);
SHA256RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],51,0x34b0bcb5);
SHA256RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],52,0x391c0cb3);
SHA256RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],53,0x4ed8aa4a);
SHA256RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],54,0x5b9cca4f);
SHA256RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],55,0x682e6ff3);
SHA256RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],56,0x748f82ee);
SHA256RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],57,0x78a5636f);
SHA256RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],58,0x84c87814);
SHA256RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],59,0x8cc70208);
SHA256RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],60,0x90befffa);
SHA256RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],61,0xa4506ceb);
SHA256RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],62,0xbef9a3f7);
SHA256RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],63,0xc67178f2);
#undef SHA256RND
/* feedback */
for (i = 0; i < 8; i++)
{
m_context.state[i] = m_context.state[i] + S[i];
}
return 0;
}
int Init()
{
m_context.curlen = 0;
m_context.length = 0;
m_context.state[0] = 0x6A09E667UL;
m_context.state[1] = 0xBB67AE85UL;
m_context.state[2] = 0x3C6EF372UL;
m_context.state[3] = 0xA54FF53AUL;
m_context.state[4] = 0x510E527FUL;
m_context.state[5] = 0x9B05688CUL;
m_context.state[6] = 0x1F83D9ABUL;
m_context.state[7] = 0x5BE0CD19UL;
return 0;
}
int Update(unsigned char * pData, unsigned long ulLen)
{
return CHashUpdate<CSHA256>::Update(pData,
ulLen,
m_context.curlen,
m_context.length,
m_context.buf,
sizeof(m_context.buf));
}
int Final(unsigned char *pszOut)
{
int i;
if (m_context.curlen >= sizeof(m_context.buf))
{
return -1;
}
/* increase the length of the message */
m_context.length += m_context.curlen * 8;
/* append the '1' bit */
m_context.buf[m_context.curlen++] = (unsigned char)0x80;
/* if the length is currently above 56 bytes we append zeros
* then compress. Then we can fall back to padding zeros and length
* encoding like normal.
*/
if (m_context.curlen > 56)
{
while (m_context.curlen < 64)
{
m_context.buf[m_context.curlen++] = (unsigned char)0;
}
Compress(m_context.buf);
m_context.curlen = 0;
}
/* pad upto 56 bytes of zeroes */
while (m_context.curlen < 56)
{
m_context.buf[m_context.curlen++] = (unsigned char)0;
}
/* store length */
STORE64H(m_context.length, m_context.buf+56);
Compress(m_context.buf);
/* copy output */
for (i = 0; i < 8; i++)
{
STORE32H(m_context.state[i], pszOut+(4*i));
}
return 0;
}
};
class CSHA224 : public CSHA256
{
public:
enum { nDigestLength =28 };
int Init()
{
m_context.curlen = 0;
m_context.length = 0;
m_context.state[0] = 0xc1059ed8UL;
m_context.state[1] = 0x367cd507UL;
m_context.state[2] = 0x3070dd17UL;
m_context.state[3] = 0xf70e5939UL;
m_context.state[4] = 0xffc00b31UL;
m_context.state[5] = 0x68581511UL;
m_context.state[6] = 0x64f98fa7UL;
m_context.state[7] = 0xbefa4fa4UL;
return 0;
}
int Final(unsigned char *pszOut)
{
unsigned char buf[32];
int err = CSHA256::Final(buf);
memcpy(pszOut, buf, 28);
return err;
}
};
#endif | [
"missdeer@959521e0-e54e-11de-9298-fbd6a473cdd1"
]
| [
[
[
1,
235
]
]
]
|
9ae97e37683bb9e28636a17b56a088c57b5bab74 | 48ab31a0a6a8605d57b5e140309c910f46eb5b35 | /Root/Implementation/ObjectStore.h | 0e1ba37f5e683255c93bff481401a1739fa53615 | []
| no_license | firebreath/indexeddb | 4c3106027a70e233eb0f91c6e0b5d60847d75800 | 50136d2fadced369788a42d249157b8a0d06eb88 | refs/heads/master | 2023-08-31T11:28:42.664028 | 2011-01-03T23:29:46 | 2011-01-03T23:29:46 | 1,218,008 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,876 | h | /**********************************************************\
Copyright Brandon Haynes
http://code.google.com/p/indexeddb
GNU Lesser General Public License
\**********************************************************/
#ifndef BRANDONHAYNES_INDEXEDDB_IMPLEMENTATION_OBJECTSTORE_H
#define BRANDONHAYNES_INDEXEDDB_IMPLEMENTATION_OBJECTSTORE_H
#include <list>
#include <boost/optional.hpp>
#include "Transaction.h"
namespace BrandonHaynes {
namespace IndexedDB {
namespace Implementation {
class Key;
class Data;
///<summary>
/// This interface represents the implementation of an Indexed Database API object store
///</summary>
class ObjectStore
{
public:
// An enumeration representing the available object store read/write modes
enum Mode { READ_WRITE = 0, READ_ONLY = 1, SNAPSHOT_READ = 2 };
virtual ~ObjectStore() { }
// Get a value from the object store identified by the given key
virtual Data get(const Key& key, TransactionContext& transactionContext) = 0;
// Put a value into the object store identified by the given key (possibly overwriting an existing value)
virtual void put(const Key& key, const Data& data, const bool noOverwrite, TransactionContext& transactionContext) = 0;
// Remove an item from the object store as identified by a key
virtual void remove(const Key& key, TransactionContext& transactionContext) = 0;
// Close this object store
virtual void close() = 0;
// Remove an index associated with the object store
virtual void removeIndex(const std::string& name, TransactionContext& transactionContext) = 0;
};
// This typedef represents an optional list of object store implementations. It is used
// primarily to manage static transactions.
typedef boost::optional<std::list<ObjectStore*>> ObjectStoreImplementationList;
}
}
}
#endif | [
"[email protected]"
]
| [
[
[
1,
52
]
]
]
|
0e79070dc40fedb2c100d8ce614900954522d51e | cfa6cdfaba310a2fd5f89326690b5c48c6872a2a | /Sources/Library/wsock/wsock/ServerSock.h | d9d3f6d63d574bdc06245b868a2a161dc2afdf9c | []
| 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 | WINDOWS-1252 | C++ | false | false | 1,079 | h | /*
Author : Bill Kim ([email protected], [email protected], [email protected])
Release Date : 2009. 04. 08.
File Name : Server 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
Server Socket Header
2009 ¨Ï Copyright MIS Corporation. All Rights Reserved.
*/
#pragma once
#include "afxsock.h"
#define WM_SERVER_ACCEPT WM_USER + 0
HWND g_ServerhWnd;
class _DLL CServerSock : public CAsyncSocket
{
// Operations
public:
CServerSock();
virtual ~CServerSock();
// Overrides
public:
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CServerSock)
public:
virtual void OnAccept(int nErrorCode);
//}}AFX_VIRTUAL
// Generated message map functions
//{{AFX_MSG(CServerSock)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
// Implementation
protected:
};
| [
"[email protected]"
]
| [
[
[
1,
48
]
]
]
|
0eebc4d011a5fec76c0e44d733236279b3b77b5e | fb8ab028c5e7865229f7032052ef6419cce6d843 | /patterndemo/src/recognize_engine.cpp | b59bb0df560f6d25c9635b9faf3d096939283c2d | []
| no_license | alexunder/autumtao | d3fbca5b87fef96606501de8bfd600825b628e42 | 296db161b50c96efab48b05b5846e6f1ac90c38a | refs/heads/master | 2016-09-05T09:43:36.361738 | 2011-03-25T16:13:51 | 2011-03-25T16:13:51 | 33,286,987 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 8,954 | cpp |
#include "recognize_engine.h"
#include "Bit_Process.h"
#include "point_stack.h"
#include <vector>
using namespace std;
/*======================================================================*/
/* OTSU global thresholding routine */
/* takes a 2D unsigned char array pointer, number of rows, and */
/* number of cols in the array. returns the value of the threshold */
/*======================================================================*/
int otsu (unsigned char *image, int rows, int cols, int x0, int y0, int dx, int dy, int vvv)
{
unsigned char *np; // 图像指针
int thresholdValue=1; // 阈值
int ihist[256]; // 图像直方图,256个点
int i, j, k; // various counters
int n, n1, n2, gmin, gmax;
double m1, m2, sum, csum, fmax, sb;
// 对直方图置零...
memset(ihist, 0, sizeof(ihist));
gmin=255; gmax=0;
// 生成直方图
for (i = y0 + 1; i < y0 + dy - 1; i++)
{
np = &image[i*cols+x0+1];
for (j = x0 + 1; j < x0 + dx - 1; j++)
{
ihist[*np]++;
if(*np > gmax) gmax=*np;
if(*np < gmin) gmin=*np;
np++; /* next pixel */
}
}
// set up everything
sum = csum = 0.0;
n = 0;
for (k = 0; k <= 255; k++)
{
sum += (double) k * (double) ihist[k]; /* x*f(x) 质量矩*/
n += ihist[k]; /* f(x) 质量 */
}
if (!n)
{
// if n has no value, there is problems...
fprintf (stderr, "NOT NORMAL thresholdValue = 160\n");
return (160);
}
// do the otsu global thresholding method
fmax = -1.0;
n1 = 0;
for (k = 0; k < 255; k++)
{
n1 += ihist[k];
if (!n1)
{
continue;
}
n2 = n - n1;
if (n2 == 0)
{
break;
}
csum += (double) k *ihist[k];
m1 = csum / n1;
m2 = (sum - csum) / n2;
sb = (double) n1 *(double) n2 *(m1 - m2) * (m1 - m2);
/* bbg: note: can be optimized. */
if (sb > fmax)
{
fmax = sb;
thresholdValue = k;
}
}
// at this point we have our thresholding value
// debug code to display thresholding values
if ( vvv & 1 )
fprintf(stderr,"# OTSU: thresholdValue = %d gmin=%d gmax=%d\n",
thresholdValue, gmin, gmax);
return(thresholdValue);
}
int averagefilter( unsigned char *image, int width, int heigth )
{
if ( image == NULL )
{
return 0;
}
int i;
int j;
for( i = 1; i <= heigth - 2; i++ )
for( j = 1; j <= width - 2; j++ )
{
unsigned char value1 = 2*image[i*width + j];
unsigned char value2 = image[(i-1)*width + j - 1];
unsigned char value3 = image[(i-1)*width + j];
unsigned char value4 = image[(i-1)*width + j + 1];
unsigned char value5 = image[i*width + j - 1];
unsigned char value6 = image[i*width + j + 1];
unsigned char value7 = image[(i+1)*width + j - 1];
unsigned char value8 = image[(i+1)*width + j];
unsigned char value9 = image[(i+1)*width + j + 1];
image[i*width + j] = (/*value1 +*/ value2 + value3 + value4 + value5 + value6 + value7 + value8 + value9)/8;
}
return 1;
}
unsigned char sortretmid( unsigned char * array, int size )
{
int i,j,key;
for( j=1; j<size; j++ )
{
key = array[j];
i=j-1;
while( i>=0&&array[i]>key )
{
array[i+1] = array[i];
i--;
}
array[i+1] = key;
}
int tmp = size/2;
return array[size/2];
}
int middlefilter( unsigned char *image, int width, int heigth )
{
if ( image == NULL )
{
return 0;
}
int i;
int j;
unsigned char value[9];
memset( value, 0, 9 );
for( i = 1; i <= heigth - 2; i++ )
for( j = 1; j <= width - 2; j++ )
{
value[0] = image[i*width + j];
value[1] = image[(i-1)*width + j - 1];
value[2] = image[(i-1)*width + j];
value[3] = image[(i-1)*width + j + 1];
value[4] = image[i*width + j - 1];
value[5] = image[i*width + j + 1];
value[6] = image[(i+1)*width + j - 1];
value[7] = image[(i+1)*width + j];
value[8] = image[(i+1)*width + j + 1];
image[i*width + j] = sortretmid( value, 9 );
}
return 1;
}
static int x_seqence[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
static int y_seqence[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int NoizyFilter( unsigned char *image, int width, int heigth, int Threshold )
{
if ( image == NULL )
{
return 0;
}
int i = 0;
int j = 0;
int k = 0;
bit_process_tool bitflag;
bitflag.init_bit_matrix( width, heigth );
Point_Stack pt_stk;
pt_stk.SetThreshold( Threshold );
vector<POINT> pt_vector;
for( i = 1; i < heigth - 1; i++ )
for( j = 1; j < width - 1; j++ )
{
if ( image[i*width + j] == 0 && !bitflag.GetBitValue( j, i ) )
{
POINT pt;
pt.x = j;
pt.y = i;
bitflag.SetBitValue( j, i, true );
pt_stk.PushPoint( pt );
pt_vector.clear();
pt_vector.push_back( pt );
while ( pt_stk.isStackNotClear() )
{
POINT current;
pt_stk.PopPoint( current );
for ( k =0; k < 8; k++ )
{
int x_position = current.x + x_seqence[k];
int y_position = current.y + y_seqence[k];
if ( x_position >= 1 && x_position < width - 1 &&
y_position >= 1 && y_position < heigth - 1 &&
image[x_position + y_position*width] == 0 &&
!bitflag.GetBitValue( x_position, y_position ) )
{
bitflag.SetBitValue( x_position, y_position, true );
POINT pt;
pt.x = x_position;
pt.y = y_position;
bool ret = pt_stk.PushPoint( pt );
pt_vector.push_back( pt );
if ( !ret )
{
pt_vector.clear();
pt_stk.ClearStack();
break;
}
}
}
}
vector<POINT>::iterator ipos;
for ( ipos = pt_vector.begin(); ipos != pt_vector.end(); ipos++ )
{
POINT pt = *ipos;
image[pt.y*width+pt.x] = 0xFF;
}
}
}
return 1;
}
int find_content( unsigned char *image, int width, int heigth,
int * xpos, int * ypos )
{
if ( image == NULL )
{
return 0;
}
bool * x_project = (bool*)malloc( width*sizeof(bool) );
memset( x_project, 1, width*sizeof(bool) );
bool * y_project = (bool*)malloc( heigth );
memset( y_project, 1, heigth*sizeof(bool) );
int i;
int j;
//x
for ( i = 1; i < width; i++ )
{
//x_project[i] = 0xff;
for ( j = 1; j < heigth-1; j++ )
{
if ( image[j*width + i] == 0 )
{
x_project[i] = 0;
break;
}
}
}
//y
for ( i = 1; i < heigth - 1; i++ )
{
//y_project[i] = 0xff;
for ( j = 1; j < width-5; j++ )
{
if ( image[i*width + j] == 0 )
{
y_project[i] = 0;
break;
}
}
}
printf( "x_project:\n" );
for ( i = 0; i < width; i++ )
{
printf( "%d ", x_project[i] );
}
printf( "\n" );
printf( "y_project:\n" );
for ( i = 0; i < heigth; i++ )
{
printf( "%d ", y_project[i] );
}
printf( "\n" );
//check the content in x
int count_x = 0;
int x_content_pos = 0;
for ( i = 0; i < width; i++ )
{
if ( x_project[i] == 0 )
{
count_x++;
if ( count_x == 0 )
{
x_content_pos = i;
}
}
else
{
if ( count_x > 10 )
{
break;
}
count_x = 0;
}
}
//check the content in y
int count_y = 0;
int y_content_pos = 0;
for ( i = 0; i < heigth; i++ )
{
if ( y_project[i] == 0 )
{
count_y++;
if ( count_y == 0 )
{
y_content_pos = i;
}
}
else
{
if ( count_y > 10 )
{
break;
}
count_y = 0;
}
}
*xpos = x_content_pos;
*ypos = y_content_pos;
free( x_project );
free( y_project );
return 0;
}
int scan_objects( unsigned char *image, int width, int heigth )
{
//horizontal projection
unsigned char * x_project = (unsigned char*)malloc( width*sizeof(unsigned char) );
memset( x_project, 0, width*sizeof(unsigned char) );
int i;
int j;
//x
for ( i = 1; i < width; i++ )
{
//x_project[i] = 0xff;
for ( j = 1; j < heigth-1; j++ )
{
if ( image[j*width + i] == 0 )
{
x_project[i]++;
}
}
}
char bufTemp[20];
memset(bufTemp, 0, 20);
int cnt = 0;
for ( i = 1; i < width; i++ )
{
if(x_project[i] > 2 && cnt == 0)
{
bufTemp[cnt++] = i - 1;
}
if(x_project[i] < 2)
{
while(x_project[i++] <= 2);
bufTemp[cnt++] = i - 1;
}
}
for(i = 0; i < cnt; i++)
{
for(j = 0; j < heigth; j++)
{
image[j*width + bufTemp[i]] = 0;
}
}
return 0;
} | [
"Xalexu@59d19903-2beb-cf48-5e42-6f21bef2d45e"
]
| [
[
[
1,
436
]
]
]
|
65b3b644501cd27d3b3a7d8c0f65d565c614d7a0 | 842997c28ef03f8deb3422d0bb123c707732a252 | /src/uslsext/USDistance.cpp | 0fc060d8dca4fcbbbc04e84aebd8d422779e6612 | []
| no_license | bjorn/moai-beta | e31f600a3456c20fba683b8e39b11804ac88d202 | 2f06a454d4d94939dc3937367208222735dd164f | refs/heads/master | 2021-01-17T11:46:46.018377 | 2011-06-10T07:33:55 | 2011-06-10T07:33:55 | 1,837,561 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,756 | cpp | // Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved.
// http://getmoai.com
#include "pch.h"
#include <uslsext/USDistance.h>
#include <uslsext/USTrig.h>
// TODO: this threshold should probably be passed in; dangerous to assume
#define FP_NEAR 0.000001f
//================================================================//
// USDist
//================================================================//
//----------------------------------------------------------------//
float USDist::PointToPlane2D ( const USVec2D& p, const USPlane2D& plane ) {
float d = p.Dot ( plane.mNorm ) + plane.mDist;
return (( d < FP_NEAR ) && ( d > -FP_NEAR )) ? 0.0f : d;
}
//----------------------------------------------------------------//
float USDist::PointToPoint ( const USVec2D& p1, const USVec2D& p2 ) {
float x = p2.mX - p1.mX;
float y = p2.mY - p1.mY;
float d = sqrtf (( x * x ) + ( y * y ));
return (( d < FP_NEAR ) && ( d > -FP_NEAR )) ? 0.0f : d;
}
//----------------------------------------------------------------//
float USDist::PointToPointSqrd ( const USVec2D& p1, const USVec2D& p2 ) {
float x = p2.mX - p1.mX;
float y = p2.mY - p1.mY;
return (( x * x ) + ( y * y ));
}
//----------------------------------------------------------------//
float USDist::SnapToPlane ( USVec3D& p, const USPlane3D& plane ) {
float dist = USDist::VecToPlane ( p, plane );
p.mX = p.mX + ( plane.mNorm.mX * dist );
p.mY = p.mY + ( plane.mNorm.mY * dist );
p.mZ = p.mZ + ( plane.mNorm.mZ * dist );
return dist;
}
//----------------------------------------------------------------//
float USDist::SnapToPlane2D ( USVec2D& p, const USPlane2D& plane ) {
float dist = USDist::PointToPlane2D ( p, plane );
p.mX = p.mX - ( plane.mNorm.mX * dist );
p.mY = p.mY - ( plane.mNorm.mY * dist );
return dist;
}
//----------------------------------------------------------------//
float USDist::VecToPlane ( const USVec3D& v, const USPlane3D& p ) {
float d = v.Dot ( p.mNorm ) + p.mDist;
return (( d < FP_NEAR ) && ( d > -FP_NEAR )) ? 0.0f : d;
}
//----------------------------------------------------------------//
float USDist::VecToVec ( const USVec3D& v1, const USVec3D& v2 ) {
float x = v2.mX - v1.mX;
float y = v2.mY - v1.mY;
float z = v2.mZ - v1.mZ;
float d = sqrtf (( x * x ) + ( y * y ) + ( z * z ));
return (( d < FP_NEAR ) && ( d > -FP_NEAR )) ? 0.0f : d;
}
//----------------------------------------------------------------//
float USDist::VecToVecSqrd ( const USVec3D& v1, const USVec3D& v2 ) {
float x = v2.mX - v1.mX;
float y = v2.mY - v1.mY;
float z = v2.mZ - v1.mZ;
return (( x * x ) + ( y * y ) + ( z * z ));
}
| [
"[email protected]",
"Patrick@agile.(none)"
]
| [
[
[
1,
15
],
[
17,
22
],
[
24,
33
],
[
35,
42
],
[
44,
54
],
[
56,
65
],
[
67,
72
],
[
74,
84
],
[
86,
92
]
],
[
[
16,
16
],
[
23,
23
],
[
34,
34
],
[
43,
43
],
[
55,
55
],
[
66,
66
],
[
73,
73
],
[
85,
85
]
]
]
|
ba6c22b7eb10a31e75e01aee81c867764e20118b | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/Dependencies/Xerces/include/xercesc/framework/XMLDocumentHandler.hpp | ae36a00361db62e8bb12dfc718948706847f2629 | []
| 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 | 12,205 | hpp | /*
* Copyright 1999-2000,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XMLDocumentHandler.hpp 191054 2005-06-17 02:56:35Z jberry $
*/
#if !defined(XMLDOCUMENTHANDLER_HPP)
#define XMLDOCUMENTHANDLER_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/RefVectorOf.hpp>
#include <xercesc/framework/XMLAttr.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLElementDecl;
class XMLEntityDecl;
/**
* This abstract class provides the interface for the scanner to return
* XML document information up to the parser as it scans through the
* document.
*
* The interface is very similar to org.sax.DocumentHandler, but
* has some extra methods required to get all the data out.
*/
class XMLPARSER_EXPORT XMLDocumentHandler
{
public:
// -----------------------------------------------------------------------
// Constructors are hidden, just the virtual destructor is exposed
// -----------------------------------------------------------------------
/** @name Destructor */
//@{
virtual ~XMLDocumentHandler()
{
}
//@}
/** @name The document handler interface */
//@{
/** Receive notification of character data.
*
* <p>The scanner will call this method to report each chunk of
* character data. The scanner may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* will come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The parser must not attempt to read from the array
* outside of the specified range.</p>
*
* @param chars The content (characters) between markup from the XML
* document.
* @param length The number of characters to read from the array.
* @param cdataSection Indicates that this data is inside a CDATA
* section.
* @see #ignorableWhitespace
* @see Locator
*/
virtual void docCharacters
(
const XMLCh* const chars
, const unsigned int length
, const bool cdataSection
) = 0;
/** Receive notification of comments in the XML content being parsed.
*
* This scanner will call this method for any comments found in the
* content of the document.
*
* @param comment The text of the comment.
*/
virtual void docComment
(
const XMLCh* const comment
) = 0;
/** Receive notification of PI's parsed in the XML content.
*
* The scanner will call this method for any PIs it finds within the
* content of the document.
*
* @param target The name of the PI.
* @param data The body of the PI. This may be an empty string since
* the body is optional.
*/
virtual void docPI
(
const XMLCh* const target
, const XMLCh* const data
) = 0;
/** Receive notification after the scanner has parsed the end of the
* document.
*
* The scanner will call this method when the current document has been
* fully parsed. The handler may use this opportunity to do something with
* the data, clean up temporary data, etc...
*/
virtual void endDocument() = 0;
/** Receive notification of the end of an element.
*
* This method is called when scanner encounters the end of element tag.
* There will be a corresponding startElement() event for every
* endElement() event, but not necessarily the other way around. For
* empty tags, there is only a startElement() call.
*
* @param elemDecl The name of the element whose end tag was just
* parsed.
* @param uriId The ID of the URI in the URI pool (only valid if
* name spaces is enabled)
* @param isRoot Indicates if this is the root element.
* @param prefixName The string representing the prefix name
*/
virtual void endElement
(
const XMLElementDecl& elemDecl
, const unsigned int uriId
, const bool isRoot
, const XMLCh* const prefixName = 0
) = 0;
/** Receive notification when a referenced entity's content ends
*
* This method is called when scanner encounters the end of an entity
* reference.
*
* @param entDecl The name of the entity reference just scanned.
*/
virtual void endEntityReference
(
const XMLEntityDecl& entDecl
) = 0;
/** Receive notification of ignorable whitespace in element content.
*
* <p>Validating Parsers must use this method to report each chunk
* of ignorable whitespace (see the W3C XML 1.0 recommendation,
* section 2.10): non-validating parsers may also use this method
* if they are capable of parsing and using content models.</p>
*
* <p>The scanner may return all contiguous whitespace in a single
* chunk, or it may split it into several chunks; however, all of
* the characters in any single event will come from the same
* external entity, so that the Locator provides useful
* information.</p>
*
* <p>The parser must not attempt to read from the array
* outside of the specified range.</p>
*
* @param chars The whitespace characters from the XML document.
* @param length The number of characters to read from the array.
* @param cdataSection Indicates that this data is inside a CDATA
* section.
* @see #characters
*/
virtual void ignorableWhitespace
(
const XMLCh* const chars
, const unsigned int length
, const bool cdataSection
) = 0;
/** Reset the document handler's state, if required
*
* This method is used to give the registered document handler a
* chance to reset itself. Its called by the scanner at the start of
* every parse.
*/
virtual void resetDocument() = 0;
/** Receive notification of the start of a new document
*
* This method is the first callback called the scanner at the
* start of every parse. This is before any content is parsed.
*/
virtual void startDocument() = 0;
/** Receive notification of a new start tag
*
* This method is called when scanner encounters the start of an element tag.
* All elements must always have a startElement() tag. Empty tags will
* only have the startElement() tag and no endElement() tag.
*
* @param elemDecl The name of the element whose start tag was just
* parsed.
* @param uriId The ID of the URI in the URI pool (only valid if
* name spaces is enabled)
* @param prefixName The string representing the prefix name
* @param attrList List of attributes in the element
* @param attrCount Count of the attributes in the element
* @param isEmpty Indicates if the element is empty, in which case
* you should not expect an endElement() event.
* @param isRoot Indicates if this is the root element.
*/
virtual void startElement
(
const XMLElementDecl& elemDecl
, const unsigned int uriId
, const XMLCh* const prefixName
, const RefVectorOf<XMLAttr>& attrList
, const unsigned int attrCount
, const bool isEmpty
, const bool isRoot
) = 0;
/** Receive notification when the scanner hits an entity reference.
*
* This is currently useful only to DOM parser configurations as SAX
* does not provide any api to return this information.
*
* @param entDecl The name of the entity that was referenced.
*/
virtual void startEntityReference(const XMLEntityDecl& entDecl) = 0;
/** Receive notification of an XML declaration
*
* Currently neither DOM nor SAX provide API's to return back this
* information.
*
* @param versionStr The value of the <code>version</code> pseudoattribute
* of the XML decl.
* @param encodingStr The value of the <code>encoding</code> pseudoattribute
* of the XML decl.
* @param standaloneStr The value of the <code>standalone</code>
* pseudoattribute of the XML decl.
* @param autoEncodingStr The encoding string auto-detected by the
* scanner. In absence of any 'encoding' attribute in the
* XML decl, the XML standard specifies how a parser can
* auto-detect. If there is no <code>encodingStr</code>
* this is what will be used to try to decode the file.
*/
virtual void XMLDecl
(
const XMLCh* const versionStr
, const XMLCh* const encodingStr
, const XMLCh* const standaloneStr
, const XMLCh* const autoEncodingStr
) = 0;
/** Receive notification of the name and namespace of the type that validated
* the element corresponding to the most recent endElement event.
* This event will be fired immediately after the
* endElement() event that signifies the end of the element
* to which it applies; no other events will intervene.
* This method is <em>EXPERIMENTAL</em> and may change, disappear
* or become pure virtual at any time.
*
* This corresponds to a part of the information required by DOM Core
* level 3's TypeInfo interface.
*
* @param typeName local name of the type that actually validated
* the content of the element corresponding to the
* most recent endElement() callback
* @param typeURI namespace of the type that actually validated
* the content of the element corresponding to the
* most recent endElement() callback
* @deprecated
*/
virtual void elementTypeInfo
(
const XMLCh* const /* typeName */
, const XMLCh* const /* typeURI */
) { /* non pure virtual to permit backward compatibility of implementations. */ };
//@}
protected :
// -----------------------------------------------------------------------
// Hidden Constructors
// -----------------------------------------------------------------------
XMLDocumentHandler()
{
}
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLDocumentHandler(const XMLDocumentHandler&);
XMLDocumentHandler& operator=(const XMLDocumentHandler&);
};
XERCES_CPP_NAMESPACE_END
#endif
| [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
]
| [
[
[
1,
307
]
]
]
|
8d07179b77d029eb5360362c46c06b5c74f90e44 | 0f8559dad8e89d112362f9770a4551149d4e738f | /Wall_Destruction/Havok/Source/Physics/Collide/Shape/hkpShape.inl | 907bcbb87b59ff42e7cab76ec4ae4f81fac2c249 | []
| no_license | TheProjecter/olafurabertaymsc | 9360ad4c988d921e55b8cef9b8dcf1959e92d814 | 456d4d87699342c5459534a7992f04669e75d2e1 | refs/heads/master | 2021-01-10T15:15:49.289873 | 2010-09-20T12:58:48 | 2010-09-20T12:58:48 | 45,933,002 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,867 | inl | /*
*
* 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-2009 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
hkpShape::hkpShape( hkpShapeType type )
{
m_userData = 0;
m_type = type;
}
HK_CLASSALIGN16(class) hkAlignedShape: public hkpShape{
hkAlignedShape();
};
hkpShapeType hkpShape::getType() const
{
return static_cast<const hkAlignedShape*>(this)->m_type;
}
inline hkUlong hkpShape::getUserData() const
{
return m_userData;
}
inline void hkpShape::setUserData( hkUlong data )
{
m_userData = data;
}
void hkpShape::getAabb( const hkTransform& localToWorld, hkReal tolerance, hkAabb& out ) const
{
getAabbImpl( localToWorld, tolerance, out );
}
hkBool hkpShape::castRay( const hkpShapeRayCastInput& input, hkpShapeRayCastOutput& output ) const
{
return castRayImpl( input, output );
}
void hkpShape::castRayWithCollector( const hkpShapeRayCastInput& input, const hkpCdBody& cdBody, hkpRayHitCollector& collector ) const
{
return castRayWithCollectorImpl( input, cdBody, collector );
}
hkVector4Comparison hkpShape::castRayBundle( const hkpShapeRayBundleCastInput& input, hkpShapeRayBundleCastOutput& output ) const
{
//HK_WARN(0x3a6a6dc4, "castRayBundle called without a mask. This will probably cause more narrowphase checks than you intended.");
//HK_ASSERT2(0x15315fcc, false, "castRayBundle called without a mask. This will probably cause more narrowphase checks than you intended.");
hkVector4Comparison mask; mask.set(hkVector4Comparison::MASK_XYZW);
return castRayBundleImpl( input, output, mask );
}
hkVector4Comparison hkpShape::castRayBundle( const hkpShapeRayBundleCastInput& input, hkpShapeRayBundleCastOutput& output, hkVector4ComparisonParameter mask ) const
{
return castRayBundleImpl( input, output, mask );
}
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20091222)
*
* Confidential Information of Havok. (C) Copyright 1999-2009
* 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.
*
*/
| [
"[email protected]"
]
| [
[
[
1,
76
]
]
]
|
a077204bcac010eb9f7df48cc77cca75bfbe1bf2 | de98f880e307627d5ce93dcad1397bd4813751dd | /3libs/ut/include/OXSpinCtrl.h | 77a639dad5f2fa55e3cb45352d179bee6232ae0a | []
| no_license | weimingtom/sls | 7d44391bc0c6ae66f83ddcb6381db9ae97ee0dd8 | d0d1de9c05ecf8bb6e4eda8a260c7a2f711615dd | refs/heads/master | 2021-01-10T22:20:55.638757 | 2011-03-19T06:23:49 | 2011-03-19T06:23:49 | 44,464,621 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,786 | h | // ==========================================================================
// Class Specification : COXSpinCtrl
// ==========================================================================
// Header file : OXSpinCtrl.h
// Version: 9.3
// Properties :
// NO Abstract class (does not have any objects)
// YES Derived from CSpinButtonCtrl
// YES Is a CWnd.
// YES Two stage creation (constructor & Create())
// YES Has a message map
// YES Needs a resource (template)
// NO Persistent objects (saveable on disk)
// NO Uses exceptions
// //////////////////////////////////////////////////////////////////////////
// Description :
// The class COXSpinCtrl is a class that extends the MFC class CSpinButtonCtrl.
// It extends the functionality of the common control (spin) that is being wrapped by MFC.
// Apart from the two buttons (up and down) it shows a small rectangle (spin thumb) in
// between these two buttons. When the user clicks and holds this rectangle, the mouse cursor
// will change shape, and he can drag the mouse to increase or decrease the value. Up and down
// buttons have the same effect as the standard control. Extended functionality can be
// switched off (even at run-time), so COXSpinCtrl can be used as the standard spin common
// control. Functionality of CSpinButtonCtrl is completely supported by COXSpinCtrl.
// Example :
// COXSpinCtrl m_SpinEx;
// ...
// m_SpinEx.Create(WS_VISIBLE | UDS_HORZ | UDS_SETBUDDYINT, rectSpin, this, IDC_SPINEX);
// m_SpinEx.SetBuddy(&m_Buddy);
// m_SpinEx.SetRange(0, 100);
// m_SpinEx.SetPos(50);
// Remarks :
// 1. Double click on the thumb swaps the spin value between the outer limits.
// 2. When user clicks the thumb and drags the mouse, change of mouse coordinates
// is translated to spin value change. COXSpinCtrl supports two methods of such
// translation:
// a) one screen pixel corresponds to one spin unit;
// b) screen borders are considered as spin value limits, so one spin
// unit can be correlated with various number of pixels.
// These methods are:
// a) represented by special constants (see below);
// b) carried out by virtual function ComputeValueFromDeltaPixel().
// So user can define his/her own constants and override
// ComputeValueFromDeltaPixel() to realize his/her own translation methods.
// Prerequisites (necessary conditions):
// Cursor files SpinHor.cur (ID = IDC_OXSPINHORCUR) and SpinVer.cur (ID = IDC_OXSPINVERCUR).
// Do not forget to include OXSpinCtrl.rc in your project
// The following resource ID ranges are reserved for use by this class
// 23930 -> 23949 and 53930 -> 53949
/////////////////////////////////////////////////////////////////////////////
#ifndef __OXSPINCTRL_H__
#define __OXSPINCTRL_H__
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include "OXDllExt.h"
// //////////////////////////////////////////////////////////////////////////
// Definition of constants for computation method representation.
#define OX_SPIN_DELTA_PIXEL_IS_DELTA_VALUE 0 // one screen pixel = one spin unit
#define OX_SPIN_SCREEN_AREA 1 // screen borders <=> spin value limits
// //////////////////////////////////////////////////////////////////////////
class OX_CLASS_DECL COXSpinCtrl : public CSpinButtonCtrl
{
// Data members -------------------------------------------------------------
public:
protected:
BOOL m_bEnable;
BOOL m_bHoriz;
BYTE m_ucWasPressed;
int m_nComputationMethod;
int m_nSpinWidth;
int m_nSpinHeight;
int m_nThumbTop;
int m_nThumbBottom;
int m_nOriginalPixel;
int m_nMaxPixel;
int m_nOriginalValue;
int m_nMinValue;
int m_nMaxValue;
DWORD m_dwClickTicks;
HCURSOR m_hThumbHorCursor;
HCURSOR m_hThumbVerCursor;
HCURSOR m_hThumbDefCursor;
private:
// Member functions ---------------------------------------------------------
public:
COXSpinCtrl(BOOL bEnable = TRUE);
// --- In : bEnable : Flag that indicates whether the spin thumb is initially
// enabled (TRUE) or disabled (FALSE).
// --- Out :
// --- Returns :
// --- Effect : Constructs the COXSpinCtrl object and set the spin thumb enabled or disabled.
// By default the thumb is enabled, but it can be disabled later.
virtual ~COXSpinCtrl();
// --- In :
// --- Out :
// --- Returns :
// --- Effect : Destroys the COXSpinCtrl object.
inline BOOL IsThumbEnabled() const { return m_bEnable; }
// --- In :
// --- Out :
// --- Returns : TRUE - if the spin thumb is enabled, FALSE - otherwise.
// --- Effect : This inline function returns whether extended functionality of
// spin control - spin thumb - is currently enabled.
void EnableThumb(BOOL bEnable = TRUE);
// --- In : bEnable : Flag to enable (TRUE) or disable (FALSE) the spin thumb.
// --- Out :
// --- Returns :
// --- Effect : Enables (by default) or disables the spin thumb.
inline int GetComputationMethod() const { return m_nComputationMethod; }
// --- In :
// --- Out :
// --- Returns : Current computation method constant.
// --- Effect : Retrieves the current spin value change computation method
// (initially OX_SPIN_DELTA_PIXEL_IS_DELTA_VALUE).
inline void SetComputationMethod(int nComputationMethod) { m_nComputationMethod = nComputationMethod; }
// --- In : Valid computation method constant.
// --- Out :
// --- Returns :
// --- Effect : Sets the current spin value change computation method.
virtual int ComputeValueFromDeltaPixel(int nDeltaPixel) const;
// --- In : Pixel change (the difference between initial and
// terminal points of mouse moving to be translated).
// --- Out :
// --- Returns : Spin value change, that corresponds to specified pixel change.
// --- Effect : Translates specified pixel change to the spin value change,
// according to current computation method. Initially COXSpinCtrl
// supports two such methods, but this function can be overridden
// to support user-defined value change computation methods.
protected:
void GetSizeAndOrientation();
void ThumbUpDownDefine();
void ThumbDraw(CPaintDC* pdc, DWORD dwStateThumb);
void ArrowsDraw(CPaintDC* pdc, DWORD dwStateUp, DWORD dwStateDown);
void ArrowTriangle(CPaintDC* pdc, int nWid, int nHei, int nShift, int nUL);
BOOL IsDoubleClick();
//{{AFX_MSG(COXSpinCtrl)
afx_msg void OnPaint();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
//}}AFX_MSG
//{{AFX_VIRTUAL(COXSpinCtrl)
//}}AFX_VIRTUAL
DECLARE_MESSAGE_MAP()
private:
};
#endif // __OXSPINCTRL_H__
| [
"[email protected]"
]
| [
[
[
1,
183
]
]
]
|
9410f7c431d89f913b8b5a26ffcfcff3429f77a8 | 3949d20551a203cf29801d888844d83d297d8118 | /Sources/LudoCore/LudoInput.h | 1252ee92d8f0ab9b64888f02f898a8254d004ddd | []
| no_license | Cuihuo/sorgamedev | 2197cf5f19a6e8b3b7bba51d46ebc1f8c1f5731e | fa6eb43a586b0e175ac291e8cd583343c0f7a337 | refs/heads/master | 2021-01-10T17:38:50.996616 | 2008-11-28T17:13:19 | 2008-11-28T17:13:19 | 49,120,070 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 378 | h | #pragma once
class InputMouse;
class InputKeyboard;
class LudoInput
{
public:
LudoInput();
~LudoInput();
bool Init();
bool Update();
void PostUpdate();
bool IsEventTriggered(int eventNumber);
InputKeyboard* GetKeyboard();
InputMouse* GetMouse();
private:
InputMouse *m_Mouse;
InputKeyboard *m_Keyboard;
}; | [
"sikhan.ariel.lee@a3e5f5c2-bd6c-11dd-94c0-21daf384169b"
]
| [
[
[
1,
24
]
]
]
|
ef465594d2c3504ebf57e833ae7810fe90ee7ec2 | 05f4bd87bd001ab38701ff8a71d91b198ef1cb72 | /TPTaller/TP3/src/Circulo.cpp | 9a0c8192585e7ce43a89fb1308205592b92aa5ac | []
| no_license | oscarcp777/tpfontela | ef6828a57a0bc52dd7313cde8e55c3fd9ff78a12 | 2489442b81dab052cf87b6dedd33cbb51c2a0a04 | refs/heads/master | 2016-09-01T18:40:21.893393 | 2011-12-03T04:26:33 | 2011-12-03T04:26:33 | 35,110,434 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,071 | cpp | #include "Circulo.h"
#include <string>
#include <iostream>
#include "Escenario.h"
#include "Define.h"
#include<math.h>
Circulo::Circulo(void){
}
Circulo::~Circulo(){
if(!this->imagenAuxiliar){
SDL_FreeSurface(this->imagenAuxiliar);
}
delete this->pos;
if(DEBUG_DESTRUCTOR==1)
std::cout<<" entro al destructor de Circulo"<<endl;
}
Circulo::Circulo(std::string id,int r,Posicion *p){
this->id = id;
this->radio = r;
this->pos = p;
this->imagen=NULL;
this->imagenAuxiliar=NULL;
this->setAltoInfluencia(this->radio*2);
this->setAnchoInfluencia(this->radio*2);
this->setXInfluencia(p->getX()-this->radio);
this->setYInfluencia(p->getY()-this->radio);
this->escalada = false;
}
int calcularDistancia(int izqX, int izqY,int derX, int derY){
int x,y;
int raiz=0;
std::cout<<izqX<<izqY<<derX<<derY;
x=abs(derX-izqX);
y=abs(derY-izqY);
raiz=(int)sqrt(pow(x,2)+pow(y,2));
return raiz;
}
void Circulo::calcularRadioDeInfluencia(){}
int Circulo::dibujar(SDL_Surface *screen){
this->color = getColorFigura()->getColor();
SDL_Surface* image;
if(this->imagen==NULL){
//si la textura no es NULL es porque le seteo algun idTextura
if(this->getIdTextura().compare("NULL") != 0){
//si se le seteo algun idTextura busco el path
std::string path = Escenario::obtenerInstancia()->obtenerPathTextura(this->getIdTextura());
//si el path NO es NULL intento levantar la imagen
if(path.compare("NULL") != 0){
image = IMG_Load (path.begin());
//si la imagen no es null (es decir si la levanto bien) la escalo
if(image != NULL){
image = ScaleSurface(image, this->getRadio()*2, this->getRadio()*2);
}
//si no la levanto es porque el path no es correcto o la imagen no existe
else{
escribirMensajeLog(*Escenario::obtenerInstancia()->getLog(),"error al intentar cargar la imagen: "+path);
}
}
//si el path ES null, tiro error (no existe path para dicho idTextura)
else{
escribirMensajeLog(*Escenario::obtenerInstancia()->getLog(),"no se encontro el path correspondiente al idTextura: "+this->getIdTextura());
}
}
//si el idTextura es NULL intento levantar la imagen del escenario por default
else{
std::string path = Escenario::obtenerInstancia()->obtenerPathTextura(Escenario::obtenerInstancia()->getTexturaFig());
image = IMG_Load (path.begin());
if( image!= NULL){
image = ScaleSurface(image, this->getRadio()*2, this->getRadio()*2);
}
}
SDL_SetColorKey(image,SDL_SRCCOLORKEY|SDL_RLEACCEL,SDL_MapRGB(image->format,0,0,0));
this->imagen=SDL_DisplayFormat(image);
SDL_FreeSurface(image);
}
if(this->imagenBonus!=NULL && !this->getEscalada()){
this->imagenBonus=ScaleSurface(this->imagenBonus,this->getRadio()*2, this->getRadio()*2);
SDL_SetColorKey(this->imagenBonus,SDL_SRCCOLORKEY|SDL_RLEACCEL,SDL_MapRGB(this->imagenBonus->format,0 ,0, 0));
this->imagenAuxiliar = SDL_DisplayFormat(this->imagenBonus);
this->setEscalada(true);
}
if(this->imagenBonus!=NULL){
SDL_Rect rect;
rect.x =this->getX()-this->getRadio();
rect.y = this->getY()-this->getRadio();
SDL_BlitSurface(this->imagenAuxiliar, NULL, screen, &rect);
}
else if(this->imagen!=NULL){
SDL_Rect rect;
rect.x =this->getX()-this->getRadio();
rect.y = this->getY()-this->getRadio();
SDL_BlitSurface(this->imagen, NULL, screen, &rect);
}
// float ang;
// float radio;
//
// //(Xinicial,Yinicial) es la posicion de imagen desde donde copiara el circulo
// int XiniColor = 0;//imagen->w/2;
// int YiniColor = 0;//imagen->h/2;
// //x e y van guardando las posiciones mientras se recorre la circunferencia y se grafica el cirulo
// float xCirculo= this->getPosicion()->getX();
// float yCirculo= this->getPosicion()->getY();
//
//
// for(ang = 0;ang<360;ang+=0.2){
//
// for(radio = 0;radio<=this->getRadio();radio+=0.3){
//
//
// //valido que x e y esten dentro del escenario
// if(xCirculo>=0 && xCirculo<Escenario::obtenerInstancia()->getAncho() && yCirculo>=0 && yCirculo<Escenario::obtenerInstancia()->getAlto()){
//
// if(this->getRadio()-radio <= 1|| radio > this->getRadio() ){
// this->putpixel(screen,xCirculo,yCirculo,getColorLinea()->getColor());
// }
// else{
// if(imagen!= NULL){
// this->color = this->getpixel(imagen,XiniColor,YiniColor);
// XiniColor=imagen->w/2+radio*cos(PI*ang/180);
// YiniColor=imagen->h/2+radio*sin(PI*ang/180);
// }
// this->putpixel(screen,xCirculo,yCirculo,this->color);
// }
//
// }
// xCirculo=this->getPosicion()->getX()+radio*cos(PI*ang/180);
// yCirculo=this->getPosicion()->getY()+radio*sin(PI*ang/180);
// }
//
// }
return 0;
}
int Circulo::getRadio(){
return this->radio;
}
void Circulo::setRadio(int radio){
this->radio=radio;
}
Posicion* Circulo::getPosicion(){
return this->pos;
}
void Circulo::setPosicion(Posicion*posicion){
this->pos = posicion;
}
| [
"rdubini@a1477896-89e5-11dd-84d8-5ff37064ad4b",
"caceres.oscar7@a1477896-89e5-11dd-84d8-5ff37064ad4b"
]
| [
[
[
1,
87
],
[
89,
94
],
[
96,
169
]
],
[
[
88,
88
],
[
95,
95
]
]
]
|
783d48d4c9731aec2dc166547fc7b870fe318ad6 | 335783c9e5837a1b626073d1288b492f9f6b057f | /source/fbxcmd/daolib/Model/MMH/BBOX.cpp | 61bfcb1ddab03a2a7297db052bb9950598f5d3a2 | [
"BSD-3-Clause",
"LicenseRef-scancode-warranty-disclaimer",
"BSD-2-Clause"
]
| permissive | code-google-com/fbx4eclipse | 110766ee9760029d5017536847e9f3dc09e6ebd2 | cc494db4261d7d636f8c4d0313db3953b781e295 | refs/heads/master | 2016-09-08T01:55:57.195874 | 2009-12-03T20:35:48 | 2009-12-03T20:35:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,149 | cpp |
/**********************************************************************
*<
FILE: BBOX.h
DESCRIPTION: MMH File Format
HISTORY:
*> Copyright (c) 2009, All Rights Reserved.
**********************************************************************/
#include <stdafx.h>
#include "GFF/GFFCommon.h"
#include "GFF/GFFField.h"
#include "GFF/GFFList.h"
#include "GFF/GFFStruct.h"
#include "MMH/MMHCommon.h"
#include "MMH/BBOX.h"
using namespace std;
using namespace DAO;
using namespace DAO::GFF;
using namespace DAO::MMH;
///////////////////////////////////////////////////////////////////
ShortString BBOX::type("BBOX");BBOX::BBOX(GFFStructRef owner) : impl(owner) {
}
Vector4f BBOX::get_boundingBoxMin() const {
return impl->GetField(GFF_MMH_BOUNDING_BOX_MIN)->asVector4f();
}
void BBOX::set_boundingBoxMin(Vector4f value) {
impl->GetField(GFF_MMH_BOUNDING_BOX_MIN)->assign(value);
}
Vector4f BBOX::get_boundingBoxMax() const {
return impl->GetField(GFF_MMH_BOUNDING_BOX_MAX)->asVector4f();
}
void BBOX::set_boundingBoxMax(Vector4f value) {
impl->GetField(GFF_MMH_BOUNDING_BOX_MAX)->assign(value);
}
| [
"tazpn314@ccf8930c-dfc1-11de-9043-17b7bd24f792"
]
| [
[
[
1,
42
]
]
]
|
f31281d05f4fed4fc660007fa31a01edf468dc86 | 1e01b697191a910a872e95ddfce27a91cebc57dd | /GrfProduceHTML.cpp | ea39bda4a95a0e5fa19d2baecc3c91aabfdc26b7 | []
| no_license | canercandan/codeworker | 7c9871076af481e98be42bf487a9ec1256040d08 | a68851958b1beef3d40114fd1ceb655f587c49ad | refs/heads/master | 2020-05-31T22:53:56.492569 | 2011-01-29T19:12:59 | 2011-01-29T19:12:59 | 1,306,254 | 7 | 5 | null | null | null | null | IBM852 | C++ | false | false | 1,889 | cpp | /* "CodeWorker": a scripting language for parsing and generating text.
Copyright (C) 1996-1997, 1999-2010 CÚdric Lemaire
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
To contact the author: [email protected]
*/
#ifdef WIN32
#pragma warning (disable : 4786)
#endif
#include "ScpStream.h"
#include "CppCompilerEnvironment.h"
#include "CGRuntime.h"
#include "ExprScriptExpression.h"
#include <string>
#include "GrfProduceHTML.h"
namespace CodeWorker {
GrfProduceHTML::~GrfProduceHTML() {
delete _pScriptFileName;
delete _pHTMLFileName;
}
SEQUENCE_INTERRUPTION_LIST GrfProduceHTML::executeInternal(DtaScriptVariable& visibility) {
std::string sScriptFileName = _pScriptFileName->getValue(visibility);
std::string sHTMLFileName = _pHTMLFileName->getValue(visibility);
return CGRuntime::produceHTML(sScriptFileName, sHTMLFileName);
}
void GrfProduceHTML::compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_INDENT << "CGRuntime::produceHTML(";
_pScriptFileName->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
_pHTMLFileName->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ");";
CW_BODY_ENDL;
}
}
| [
"cedric.p.r.lemaire@28b3f5f3-d42e-7560-b87f-5f53cf622bc4"
]
| [
[
[
1,
53
]
]
]
|
256e41c35055daab57cc6ce05e607e648dc711eb | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /Common/Scd/ScdLib/NRECIPE.CPP | df28351234677eecd2d82e101b5dbd4a7c18cbfc | []
| 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,585 | cpp | //================== SysCAD - Copyright Kenwalt (Pty) Ltd ===================
// $Nokeywords: $
//===========================================================================
#include "stdafx.h"
#include "sc_defs.h"
#include "dbgetc.h"
#define __NRECIPE_CPP
#include "nrecipe.h"
extern "C"
{
#define ANSI
#include "nr.h"
#include "nrutil.h"
}
//===========================================================================
//
//
//
//===========================================================================
CNRSimplex::CNRSimplex()
{
m_N=0;
m_M1=0;
m_M2=0;
m_M3=0;
}
//---------------------------------------------------------------------------
CNRSimplex::CNRSimplex(int n, int m1, int m2, int m3)
{
m_N=0;
m_M1=0;
m_M2=0;
m_M3=0;
SetSize(n, m1, m2, m3);
}
//---------------------------------------------------------------------------
CNRSimplex::~CNRSimplex()
{
Free();
}
//---------------------------------------------------------------------------
void CNRSimplex::SetSize(int n, int m1, int m2, int m3)
{
if (m_N==n && m_M1==m1 && m_M2==m2 && m_M3==m3)
return;
if (m_N>0)
Free();
m_N=n;
m_M=m1+m2+m3;
m_M1=m1;
m_M2=m2;
m_M3=m3;
m_MP=m_M+2;
m_NP=m_N+1;
m_l1=ivector(1,m_N+1);
m_l2=ivector(1,m_M);
m_l3=ivector(1,m_M);
m_izrov=ivector(1,m_N);
m_iposv=ivector(1,m_M);
// m_c=malloc(m_MP*m_NP*sizeof(double));
m_Prob=matrix(0,m_MP-1,0,m_NP-1);
m_c=matrix(1,m_MP,1,m_NP);
// m_a=convert_matrix(&m_c[0][0],1,m_MP,1,m_NP);
for (int i=0; i<m_MP; i++)
for (int j=0; j<m_NP; j++)
m_Prob[i][j]=0.0;
}
//---------------------------------------------------------------------------
void CNRSimplex::Free()
{
free_ivector(m_l3,1,m_M);
free_ivector(m_l2,1,m_M);
free_ivector(m_l1,1,m_N+1);
free_ivector(m_izrov,1,m_N);
free_ivector(m_iposv,1,m_M);
free_matrix(m_Prob,0,m_MP-1,0,m_NP-1);
free_matrix(m_c,1,m_MP,1,m_NP);
// free_convert_matrix(m_a,1,m_MP,1,m_NP);
m_N=0;
}
//---------------------------------------------------------------------------
int CNRSimplex::Solve()
{
int icase;
for (int i=0; i<m_MP; i++)
for (int j=0; j<m_NP; j++)
m_c[i+1][j+1]=m_Prob[i][j];
simplx(m_c, m_M, m_N, m_M1, m_M2, m_M3, &icase, m_izrov, m_iposv, m_l1, m_l2, m_l3);
return icase;
}
//---------------------------------------------------------------------------
double CNRSimplex::Value(int iX)
{
int i;
for (i=1;i<=m_M+1; i++)
if (m_iposv[i-1]==iX) return m_c[i][1];
return 0.0;
}
//---------------------------------------------------------------------------
void CNRSimplex::Dump(char * Where, int Problem, char *Fmt)
{
if (dbgfile())
{
dbglock();
dbgfileflush(1);
if (Problem)
DumpA(Where, dbgp, m_Prob, 0, m_MP-1, 0, m_NP-1, Fmt);
else
DumpA(Where, dbgp, m_c, 1, m_MP, 1, m_NP, Fmt);
dbgfileflush(0);
dbgunlock();
}
}
//---------------------------------------------------------------------------
void CNRSimplex::Example()
{
CNRSimplex S;
// static double c[MP][NP]=
// { 0., 0., 0., 0., 0., 1.0, 1.0,
// 10.0, 0., 0., 0., 0., -1.0, 0.,
// 20.0, 0., 0., 0., 0., 0., -1.0,
// 999.0, -1.0, 0., 0., 0., -1.0, -1.0,
// 999.0, 0., -1.0, 0., 0., -1.0, 0.,
// 0., 0., 0., -1.0, 0., 2.0, -1.0,
// 0., 0., 0., 0., -1.0, 0., 2.0,
// 0., 0., 0., 0., 0., 0., 0.};
S.SetSize(6, 2, 0, 4);
S.SetFnXiVal(5, 1);
S.SetFnXiVal(6, 1);
S.SetLEConst(1, 10);
S.SetLEXiVal(1, 5, -1);
S.SetLEConst(2, 20);
S.SetLEXiVal(2, 6, -1);
S.SetEqConst(1, 100);
S.SetEqXiVal(1, 1, -1);
S.SetEqXiVal(1, 5, -1);
S.SetEqXiVal(1, 6, -1);
S.SetEqConst(2, 100);
S.SetEqXiVal(2, 2, -1);
S.SetEqXiVal(2, 5, -1);
S.SetEqConst(3, -0);
S.SetEqXiVal(3, 3, -1);
S.SetEqXiVal(3, 5, 2);
S.SetEqXiVal(3, 6, -1);
S.SetEqConst(4, 0);
S.SetEqXiVal(4, 4, -1);
S.SetEqXiVal(4, 6, 2);
if (S.Solve()==0)
{
for (int i=1; i<=6; i++)
{
double xx=S.Value(i);
int yy=0;
}
}
}
//===========================================================================
//
//
//
//===========================================================================
| [
"[email protected]"
]
| [
[
[
1,
200
]
]
]
|
1b451653d908513430a5b7c93cf891f357a3a34a | e8d9619e262531453688550db22d0e78f1b51dab | /sametime/utils.cpp | bac35f50096611bf3a19a2e4abb0952afe44b769 | []
| no_license | sje397/sje-miranda-plugins | e9c562f402daef2cfbe333ce9a8a888cd81c9573 | effb7ea736feeab1c68db34a86da8a2be2b78626 | refs/heads/master | 2016-09-05T16:42:34.162442 | 2011-05-22T14:48:15 | 2011-05-22T14:48:15 | 1,784,020 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 9,046 | cpp | #include "utils.h"
HICON hProtoIcon;
//LRESULT CALLBACK NullWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
static int NullWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message ) {
case WM_COMMAND: {
if (HIWORD(wParam) == STN_CLICKED) { //It was a click on the Popup.
PUDeletePopUp( hWnd );
return TRUE;
}
break;
}
case WM_CONTEXTMENU:
PUDeletePopUp( hWnd );
return TRUE;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
void CALLBACK sttPopupProcA( ULONG param ) {
//DWORD sttPopupProcA(LPVOID param) {
POPUPDATAEX* ppd = ( POPUPDATAEX* )param;
if ( ServiceExists(MS_POPUP_ADDPOPUPEX) )
CallService( MS_POPUP_ADDPOPUPEX, ( WPARAM )ppd, 0 );
else
if ( ServiceExists(MS_POPUP_ADDPOPUP) )
CallService( MS_POPUP_ADDPOPUP, ( WPARAM )ppd, 0 );
free( ppd );
//return 0;
}
void CALLBACK sttPopupProcW( ULONG param ) {
//DWORD sttPopupProcW(LPVOID param) {
POPUPDATAW* ppd = ( POPUPDATAW* )param;
if ( ServiceExists(MS_POPUP_ADDPOPUPW) )
CallService( MS_POPUP_ADDPOPUPW, ( WPARAM )ppd, 0 );
free( ppd );
//return 0;
}
void ShowPopupA( const char* line1, const char* line2, int flags )
{
if(CallService(MS_SYSTEM_TERMINATED, 0, 0)) return;
if ( !ServiceExists( MS_POPUP_ADDPOPUP )) {
char title[256];
sprintf(title, "%s Message", PROTO);
if(line1 && line2) {
char *message = new char[strlen(line1) + strlen(line2) + 2]; // newline and null terminator
sprintf(message, "%s\n%s", line1, line2);
MessageBoxA( NULL, message, title, MB_OK | MB_ICONINFORMATION );
delete message;
} else if(line1) {
MessageBoxA( NULL, line1, title, MB_OK | MB_ICONINFORMATION );
} else if(line2) {
MessageBoxA( NULL, line2, title, MB_OK | MB_ICONINFORMATION );
}
return;
}
POPUPDATAEX* ppd = ( POPUPDATAEX* )malloc( sizeof( POPUPDATAEX ));
memset((void *)ppd, 0, sizeof(POPUPDATAEX));
ppd->lchContact = NULL;
ppd->lchIcon = hProtoIcon;
if(line1 && line2) {
strncpy( ppd->lpzContactName, line1, MAX_CONTACTNAME );
strncpy( ppd->lpzText, line2, MAX_SECONDLINE );
} else if(line1) strncpy( ppd->lpzText, line1, MAX_SECONDLINE );
else if(line2) strncpy( ppd->lpzText, line2, MAX_SECONDLINE );
//ppd->colorBack = GetSysColor( COLOR_BTNFACE );
//ppd->colorText = GetSysColor( COLOR_WINDOWTEXT );
//ppd->colorText = 0x00FFFFFF; // for old popup modules
//ppd->colorBack = POPUP_USE_SKINNED_BG;
ppd->iSeconds = 0;
ppd->PluginWindowProc = ( WNDPROC )NullWindowProc;
ppd->PluginData = NULL;
QueueUserAPC( sttPopupProcA , mainThread, ( ULONG )ppd );
//CloseHandle(CreateThread(0, 0, (LPTHREAD_START_ROUTINE)sttPopupProcA, (LPVOID)ppd, 0, 0));
//sttPopupProcA((ULONG)ppd);
}
void ShowPopupW( const wchar_t* line1, const wchar_t* line2, int flags )
{
if(CallService(MS_SYSTEM_TERMINATED, 0, 0)) return;
if ( !ServiceExists( MS_POPUP_ADDPOPUPW )) {
wchar_t title[256], *ws;
swprintf(title, L"%s Message", TranslateW(ws = a2w(PROTO)));
free(ws);
if(line1 && line2) {
wchar_t *message = new wchar_t[wcslen(line1) + wcslen(line2) + 2]; // newline and null terminator
swprintf(message, L"%s\n%s", line1, line2);
MessageBoxW( NULL, message, title, MB_OK | MB_ICONINFORMATION );
delete message;
} else if(line1) {
MessageBoxW( NULL, line1, title, MB_OK | MB_ICONINFORMATION );
} else if(line2) {
MessageBoxW( NULL, line2, title, MB_OK | MB_ICONINFORMATION );
}
return;
}
POPUPDATAW* ppd = ( POPUPDATAW* )malloc( sizeof( POPUPDATAW ));
memset((void *)ppd, 0, sizeof(POPUPDATAW));
ppd->lchContact = NULL;
ppd->lchIcon = hProtoIcon;
if(line1 && line2) {
wcsncpy( ppd->lpwzContactName, line1, MAX_CONTACTNAME );
wcsncpy( ppd->lpwzText, line2, MAX_SECONDLINE );
} else if(line1) wcsncpy( ppd->lpwzText, line1, MAX_SECONDLINE );
else if(line2) wcsncpy( ppd->lpwzText, line2, MAX_SECONDLINE );
//ppd->colorBack = GetSysColor( COLOR_BTNFACE );
//ppd->colorText = GetSysColor( COLOR_WINDOWTEXT );
//ppd->colorText = 0x00FFFFFF; // for old popup modules
//ppd->colorBack = POPUP_USE_SKINNED_BG;
ppd->iSeconds = 0;
ppd->PluginWindowProc = ( WNDPROC )NullWindowProc;
ppd->PluginData = NULL;
QueueUserAPC( sttPopupProcW , mainThread, ( ULONG )ppd );
//CloseHandle(CreateThread(0, 0, (LPTHREAD_START_ROUTINE)sttPopupProcW, (LPVOID)ppd, 0, 0));
//sttPopupProcW((ULONG)ppd);
}
void ShowWarning(TCHAR *msg) {
TCHAR buffer[512];
ErrorDisplay disp = options.err_method;
// funny logic :) ... try to avoid message boxes
// if want baloons but no balloons, try popups
// if want popups but no popups, try baloons
// if, after that, you want balloons but no balloons, revert to message boxes
if(disp == ED_BAL && !ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) disp = ED_POP;
if(disp == ED_POP && !ServiceExists(MS_POPUP_SHOWMESSAGE)) disp = ED_BAL;
if(disp == ED_BAL && !ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) disp = ED_MB;
#ifdef _UNICODE
wsprintf(buffer, L"%s Warning", TranslateTS(PROTO));
#else
sprintf(buffer, "%s Warning", Translate(PROTO));
#endif
switch(disp) {
case ED_POP:
ShowPopup(buffer, msg, 0);
break;
case ED_MB:
MessageBox(0, msg, buffer, MB_OK | MB_ICONWARNING);
break;
case ED_BAL:
{
MIRANDASYSTRAYNOTIFY sn = {0};
sn.cbSize = sizeof(sn);
sn.szProto = PROTO;
sn.szInfoTitle = t2a(buffer);
sn.szInfo = t2a(msg);
sn.dwInfoFlags = NIIF_WARNING;
sn.uTimeout = 10;
CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&sn);
free(sn.szInfoTitle);
free(sn.szInfo);
}
break;
}
}
void ShowError(TCHAR *msg) {
TCHAR buffer[512];
ErrorDisplay disp = options.err_method;
// funny logic :) ... try to avoid message boxes
// if want baloons but no balloons, try popups
// if want popups but no popups, try baloons
// if, after that, you want balloons but no balloons, revert to message boxes
if(disp == ED_BAL && !ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) disp = ED_POP;
if(disp == ED_POP && !ServiceExists(MS_POPUP_SHOWMESSAGE)) disp = ED_BAL;
if(disp == ED_BAL && !ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) disp = ED_MB;
#ifdef _UNICODE
wchar_t *ws = a2w(PROTO);
wsprintf(buffer, L"%s Error", TranslateW(ws));
free(ws);
#else
sprintf(buffer, "%s Error", Translate(PROTO));
#endif
switch(disp) {
case ED_POP:
ShowPopup(buffer, msg, 0);
break;
case ED_MB:
MessageBox(0, msg, buffer, MB_OK | MB_ICONWARNING);
break;
case ED_BAL:
{
MIRANDASYSTRAYNOTIFY sn = {0};
sn.cbSize = sizeof(sn);
sn.szProto = PROTO;
sn.szInfoTitle = t2a(buffer);
sn.szInfo = t2a(msg);
sn.dwInfoFlags = NIIF_ERROR;
sn.uTimeout = 10;
CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&sn);
free(sn.szInfoTitle);
free(sn.szInfo);
}
break;
}
}
void InitUtils() {
hProtoIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_PROTO), IMAGE_ICON, SM_CXSMICON, SM_CYSMICON, 0);
//hProtoIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_PROTO), IMAGE_ICON, SM_CXICON, SM_CYICON, 0);
}
void DeinitUtils() {
DestroyIcon(hProtoIcon);
}
char *w2u(const wchar_t *ws) {
if(ws) {
int size = WideCharToMultiByte(CP_UTF8, 0, ws, -1, 0, 0, 0, 0);
char *buff = (char *)malloc(size);
WideCharToMultiByte(CP_UTF8, 0, ws, -1, buff, size, 0, 0);
return buff;
} else
return 0;
}
wchar_t *u2w(const char *utfs) {
if(utfs) {
int size = MultiByteToWideChar(CP_UTF8, 0, utfs, -1, 0, 0);
wchar_t *buff = (wchar_t *)malloc(size * sizeof(wchar_t));
MultiByteToWideChar(CP_UTF8, 0, utfs, -1, buff, size);
return buff;
} else
return 0;
}
wchar_t *a2w(const char *as) {
int size = MultiByteToWideChar(code_page, 0, as, -1, 0, 0);
wchar_t *buff = (wchar_t *)malloc(size * sizeof(wchar_t));
MultiByteToWideChar(code_page, 0, as, -1, buff, size);
return buff;
}
char *w2a(const wchar_t *ws) {
int size = WideCharToMultiByte(code_page, 0, ws, -1, 0, 0, 0, 0);
char *buff = (char *)malloc(size);
WideCharToMultiByte(code_page, 0, ws, -1, buff, size, 0, 0);
return buff;
}
char *t2a(const TCHAR *ts) {
#ifdef _UNICODE
return w2a(ts);
#else
return _strdup(ts);
#endif
}
TCHAR *a2t(const char *as) {
#ifdef _UNICODE
return a2w(as);
#else
return _strdup(as);
#endif
}
TCHAR *u2t(const char *utfs) {
#ifdef _UNICODE
return u2w(utfs);
#else
wchar_t *ws = u2w(utfs);
char *ret = w2a(ws);
free(ws);
return ret;
#endif
}
char *t2u(const TCHAR *ts) {
#ifdef _UNICODE
return w2u(ts);
#else
wchar_t *ws = a2w(ts);
char *ret = w2u(ws);
free(ws);
return ret;
#endif
}
char *u2a(const char *utfs) {
wchar_t *ws = u2w(utfs);
char *ret = w2a(ws);
free(ws);
return ret;
}
char *a2u(const char *as) {
wchar_t *ws = a2w(as);
char *ret = w2u(ws);
free(ws);
return ret;
}
| [
"[email protected]"
]
| [
[
[
1,
335
]
]
]
|
333cf69de77e84561a664251e4e06f5503f84a84 | 796687b684b1604bc7d8a178d20e7071dec5b0e1 | /game/src/Game.cpp | 30d842478b09c27ac8580843414bffcee458feeb | []
| no_license | josenavas/ale-vj-qt2011 | 965498af5474bc65a015ab13e42878cb0451ce85 | 6e4e5ad486e5b2c4cfc1aa2044d35263f6acd263 | refs/heads/master | 2021-01-22T03:13:49.635483 | 2011-12-19T23:45:14 | 2011-12-19T23:45:14 | 32,129,957 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,154 | cpp | #include "Game.h"
#include <OgreConfigFile.h>
#include <OgreException.h>
#include <OgreFontManager.h>
Game::Game(void)
: mRoot(0),
mResourcesCfg(Ogre::StringUtil::BLANK),
mPluginsCfg(Ogre::StringUtil::BLANK)
{
}
Game::~Game(void)
{
Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, mInputMgr);
mInputMgr->windowClosed(mWindow);
delete mInputMgr;
delete mRoot;
}
bool Game::go(void)
{
#ifdef _DEBUG
mResourcesCfg = "resources_d.cfg";
mPluginsCfg = "plugins_d.cfg";
#else
mResourcesCfg = "resources.cfg";
mPluginsCfg = "plugins.cfg";
#endif
//Construct Ogre::Root
mRoot = new Ogre::Root(mPluginsCfg);
loadResources();
bool ret = createRenderSystem();
if(!ret) return false;
initialisingResources();
mInputMgr = new InputManager(mWindow, mRoot);
mInputMgr->windowResized(mWindow);
Ogre::WindowEventUtilities::addWindowEventListener(mWindow, mInputMgr);
mRoot->addFrameListener(mInputMgr);
mRoot->startRendering();
return true;
}
void Game::loadResources(void)
{
//set up resources
//Load resource paths from config file
Ogre::ConfigFile cf;
cf.load(mResourcesCfg);
//Go through all sections & settins in the file
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
Ogre::String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for( i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
}
}
}
bool Game::createRenderSystem(void)
{
// configure
// Show the configuration dialog and initialise the system
if(!(mRoot->restoreConfig() || mRoot->showConfigDialog())) return false;
mWindow = mRoot->initialise(true, "Game");
return true;
}
void Game::initialisingResources(void)
{
//Set default mipmap level
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
//initialise all resource groups
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
Ogre::ResourceManager::ResourceMapIterator iter = Ogre::FontManager::getSingleton().getResourceIterator();
while(iter.hasMoreElements())
{
iter.getNext()->load();
}
}
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif
#ifdef __cplusplus
extern"C" {
#endif
#if OGRE__PLATFORM == OGRE_PLATFORM_WIN32
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main (int argc, char *argv[])
#endif
{
Game app;
try {
app.go();
} catch(Ogre::Exception& e) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
std::cerr << "An exception has occured: " <<
e.getFullDescription().c_str() << std::endl;
#endif
}
return 0;
}
#ifdef __cplusplus
}
#endif | [
"[email protected]@55d2aa0d-96bd-598c-80cb-e06a2779e390"
]
| [
[
[
1,
132
]
]
]
|
67b70fab33a32d79f3cc3682f2d121138cefa33a | e2e49023f5a82922cb9b134e93ae926ed69675a1 | /tools/aoslcpp/include/aosl/change_switch.hpp | 346fe93f3ffddf0c9db72c740822d22316f7faa3 | []
| no_license | invy/mjklaim-freewindows | c93c867e93f0e2fe1d33f207306c0b9538ac61d6 | 30de8e3dfcde4e81a57e9059dfaf54c98cc1135b | refs/heads/master | 2021-01-10T10:21:51.579762 | 2011-12-12T18:56:43 | 2011-12-12T18:56:43 | 54,794,395 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,512 | hpp | // Copyright (C) 2005-2010 Code Synthesis Tools CC
//
// This program was generated by CodeSynthesis XSD, an XML Schema
// to C++ data binding compiler, in the Proprietary License mode.
// You should have received a proprietary license from Code Synthesis
// Tools CC prior to generating this code. See the license text for
// conditions.
//
/**
* @file
* @brief Generated from change_switch.xsd.
*/
#ifndef AOSLCPP_AOSL__CHANGE_SWITCH_HPP
#define AOSLCPP_AOSL__CHANGE_SWITCH_HPP
// Begin prologue.
//
#include <aoslcpp/common.hpp>
//
// End prologue.
#include <xsd/cxx/config.hxx>
#if (XSD_INT_VERSION != 3030000L)
#error XSD runtime version mismatch
#endif
#include <xsd/cxx/pre.hxx>
#include "aosl/change_switch_forward.hpp"
#include <memory> // std::auto_ptr
#include <limits> // std::numeric_limits
#include <algorithm> // std::binary_search
#include <xsd/cxx/xml/char-utf8.hxx>
#include <xsd/cxx/tree/exceptions.hxx>
#include <xsd/cxx/tree/elements.hxx>
#include <xsd/cxx/tree/containers.hxx>
#include <xsd/cxx/tree/list.hxx>
#include <xsd/cxx/xml/dom/parsing-header.hxx>
#include <xsd/cxx/tree/containers-wildcard.hxx>
#ifndef XSD_DONT_INCLUDE_INLINE
#define XSD_DONT_INCLUDE_INLINE
#include "aosl/change.hpp"
#undef XSD_DONT_INCLUDE_INLINE
#else
#include "aosl/change.hpp"
#endif // XSD_DONT_INCLUDE_INLINE
/**
* @brief C++ namespace for the %artofsequence.org/aosl/1.0
* schema namespace.
*/
namespace aosl
{
/**
* @brief Class corresponding to the %change_switch schema type.
*
* Change that will activate the object if it's deactivated or deactivate
* it if it's activated.
*
* @nosubgrouping
*/
class Change_switch: public ::aosl::Change
{
public:
/**
* @name Constructors
*/
//@{
/**
* @brief Create an instance from the ultimate base and
* initializers for required elements and attributes.
*/
Change_switch (const ObjectType&);
/**
* @brief Create an instance from a DOM element.
*
* @param e A DOM element to extract the data from.
* @param f Flags to create the new instance with.
* @param c A pointer to the object that will contain the new
* instance.
*/
Change_switch (const ::xercesc::DOMElement& e,
::xml_schema::Flags f = 0,
::xml_schema::Container* c = 0);
/**
* @brief Copy constructor.
*
* @param x An instance to make a copy of.
* @param f Flags to create the copy with.
* @param c A pointer to the object that will contain the copy.
*
* For polymorphic object models use the @c _clone function instead.
*/
Change_switch (const Change_switch& x,
::xml_schema::Flags f = 0,
::xml_schema::Container* c = 0);
/**
* @brief Copy the instance polymorphically.
*
* @param f Flags to create the copy with.
* @param c A pointer to the object that will contain the copy.
* @return A pointer to the dynamically allocated copy.
*
* This function ensures that the dynamic type of the instance is
* used for copying and should be used for polymorphic object
* models instead of the copy constructor.
*/
virtual Change_switch*
_clone (::xml_schema::Flags f = 0,
::xml_schema::Container* c = 0) const;
//@}
/**
* @brief Destructor.
*/
virtual
~Change_switch ();
};
}
#ifndef XSD_DONT_INCLUDE_INLINE
#include "aosl/change.inl"
#endif // XSD_DONT_INCLUDE_INLINE
#include <iosfwd>
namespace aosl
{
::std::ostream&
operator<< (::std::ostream&, const Change_switch&);
}
#include <iosfwd>
#include <xercesc/sax/InputSource.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMErrorHandler.hpp>
namespace aosl
{
}
#include <iosfwd>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMErrorHandler.hpp>
#include <xercesc/framework/XMLFormatter.hpp>
#include <xsd/cxx/xml/dom/auto-ptr.hxx>
namespace aosl
{
void
operator<< (::xercesc::DOMElement&, const Change_switch&);
}
#ifndef XSD_DONT_INCLUDE_INLINE
#include "aosl/change_switch.inl"
#endif // XSD_DONT_INCLUDE_INLINE
#include <xsd/cxx/post.hxx>
// Begin epilogue.
//
//
// End epilogue.
#endif // AOSLCPP_AOSL__CHANGE_SWITCH_HPP
| [
"klaim@localhost"
]
| [
[
[
1,
190
]
]
]
|
22a7d9f2b8575412db03bdb8bddea16f10a91306 | 3daaefb69e57941b3dee2a616f62121a3939455a | /mgllib/src/game/MyuFPS.cpp | df99901ec828bcfbb50d34509cdf0d5dba42e1c6 | []
| 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 | 1,298 | cpp | //////////////////////////////////////////////////////////
//
// MyuFPS
// - FPS管理クラス
//
//////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MyuFPS.h"
#define WAIT_TIME (GET_WAIT_FROM_FPS(m_nFPS))
// コンストラクタ
CMyuFPS::CMyuFPS()
{
m_nFPS = DEFAULT_FPS;
m_fNowFps = 0;
m_dwAdjust = 0;
//m_timer.Init( INTERVAL_TYPE_TIME, 100 );
}
// デストラクタ
CMyuFPS::~CMyuFPS()
{
}
// スリープ処理
void CMyuFPS::Sleep()
{
//Sleep(0); // これしないと時間が上手く取得できない(ノД`)
int nGetTime = m_timer.Get();
int nWaitTime = (m_dwAdjust>>16) - nGetTime;
// スリープ。でもSleep精度は最低でも1msなので
// 1ms少なめにSleepし↓で空回し
if ( nWaitTime > 0 )
::Sleep( nWaitTime-1 );
// ↑の説明どおり。空回し。
while( m_timer.Get() < (m_dwAdjust>>16) );
// いち早くタイマー更新
m_timer.Update();
int nFrameTime = nWaitTime+nGetTime;
if ( nWaitTime < 0 )
m_fNowFps = GET_FPS_FROM_TIME( nGetTime );
else
m_fNowFps = GET_FPS_FROM_TIME( nFrameTime );
// - 0x100 ← オーバーヘッドとか考慮して詐欺る(爆
m_dwAdjust += ( WAIT_TIME - nFrameTime ) * 0x10000 - 0x100;
}
| [
"myun2@6d62ff88-fa28-0410-b5a4-834eb811a934"
]
| [
[
[
1,
56
]
]
]
|
2f31f9d978fef76d7eb981ce77f152d68ee77788 | ce262ae496ab3eeebfcbb337da86d34eb689c07b | /SEFoundation/SEMath/SESphere3.h | 2d1bfa98903b281877ce3ec06df2d86f95c7a2cc | []
| no_license | pizibing/swingengine | d8d9208c00ec2944817e1aab51287a3c38103bea | e7109d7b3e28c4421c173712eaf872771550669e | refs/heads/master | 2021-01-16T18:29:10.689858 | 2011-06-23T04:27:46 | 2011-06-23T04:27:46 | 33,969,301 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,583 | h | // Swing Engine Version 1 Source Code
// Most of techniques in the engine are mainly based on David Eberly's
// Wild Magic 4 open-source code.The author of Swing Engine learned a lot
// from Eberly's experience of architecture and algorithm.
// Several sub-systems are totally new,and others are re-implimented or
// re-organized based on Wild Magic 4's sub-systems.
// Copyright (c) 2007-2010. All Rights Reserved
//
// Eberly's permission:
// Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2006. All Rights Reserved
//
// 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. The license is available for reading at
// the location:
// http://www.gnu.org/copyleft/lgpl.html
#ifndef Swing_Sphere3_H
#define Swing_Sphere3_H
#include "SEVector3.h"
namespace Swing
{
//----------------------------------------------------------------------------
// Description:
// Author:Sun Che
// Date:20070621
//----------------------------------------------------------------------------
class SE_FOUNDATION_API SESphere3f
{
public:
SESphere3f(void);
SESphere3f(const SEVector3f& rCenter, float fRadius);
SESphere3f(const SESphere3f& rSphere);
SESphere3f& operator = (const SESphere3f& rSphere);
public:
SEVector3f Center;
float Radius;
};
#include "SESphere3.inl"
}
#endif
| [
"[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac"
]
| [
[
[
1,
52
]
]
]
|
dbe70e3522f16076cc4ee5676781f9b4c7122bea | 1cc5720e245ca0d8083b0f12806a5c8b13b5cf98 | /v1/p193/p193.as.cpp | 523b329666e761eedf836bb181ebdb84cb4e0368 | []
| no_license | Emerson21/uva-problems | 399d82d93b563e3018921eaff12ca545415fd782 | 3079bdd1cd17087cf54b08c60e2d52dbd0118556 | refs/heads/master | 2021-01-18T09:12:23.069387 | 2010-12-15T00:38:34 | 2010-12-15T00:38:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,554 | cpp | #include <stdio.h>
#include <vector>
using namespace std;
#define INCOLOR 0
#define BLACK 1
#define WHITE 2
struct node {
int id;
int color;
vector<node *> filhos;
int nfilhos;
};
// os nodes cacheados e a lista de estado
int nodeCount;
vector<node> pool;
int maxBlackCount;
bool melhor[100];
void recursao(int i,int blackCount,int whiteCount) {
// se chegou no ultimo no
if(i==nodeCount) {
if(blackCount>maxBlackCount) {
maxBlackCount = blackCount;
for(int z=0;z!=nodeCount;z++) {
melhor[z] = (pool[z].color==BLACK);
}
//cout << "melhor novo: " << maxBlackCount << endl;
}
return;
}
// se o maximo de numeros faltando
if((nodeCount-i)+blackCount<=maxBlackCount) {
// nao adianta todos serem pretos
return;
}
if(pool[i].nfilhos==0) {
pool[i].color = BLACK;
recursao(i+1,blackCount+1,whiteCount);
pool[i].color = INCOLOR;
return;
}
// tenta com white
pool[i].color = WHITE;
recursao(i+1,blackCount,whiteCount+1);
pool[i].color = INCOLOR;
// se algum dos filhos for black, nao pode ser black
for(int z=0;z!=pool[i].nfilhos;z++) {
if(pool[i].filhos[z]->color==BLACK) return;
}
pool[i].color = BLACK;
recursao(i+1,blackCount+1,whiteCount);
pool[i].color = INCOLOR;
}
int main(int argc, char **argv) {
int inst;
scanf("%d",&inst);
// cacheia todos os nos
for(int i=0;i!=100;i++) {
node n;
n.id = i;
pool.push_back(n);
}
while(inst--!=0) {
// limpa todos os nos
maxBlackCount = 0;
long int n;
int a,b;
scanf("%d %ld",&nodeCount,&n);
for(int i=0;i!=nodeCount;i++) {
pool[i].color = INCOLOR;
pool[i].filhos.clear();
}
// le todos as conexoes
for(int i=0;i!=n;i++) {
scanf("%d %d", &a, &b);
pool[a-1].filhos.push_back(&pool[b-1]);
pool[b-1].filhos.push_back(&pool[a-1]);
//pool[a-1].filhos.push_back(b-1);
//pool[b-1].filhos.push_back(a-1);
}
// seta o numero de conexoes de cada um, e as cores do estado inicial
for(int i=0;i!=nodeCount;i++) {
pool[i].nfilhos = pool[i].filhos.size();
}
recursao(0,0,nodeCount);
// imprime o resultado
printf("%d\n",maxBlackCount);
for(int i=0;i!=nodeCount;i++) {
if(melhor[i]) {
if(--maxBlackCount==0) printf("%d",i+1);
else printf("%d ",i+1);
}
}
printf("\n");
}
return 0;
}
// o primeiro teste tem que retornar 3
// o segundo teste tem que retornar 2
// o terceiro teste retorna 1
// o quarto retorna 6
| [
"[email protected]"
]
| [
[
[
1,
126
]
]
]
|
4ea39fd0724c4b4affe85e536d2f3b95c67c7340 | 6188f1aaaf5508e046cde6da16b56feb3d5914bc | /Doc/Web/Shaders/Samples/Tutorials-0.8-src/cwc/simpleGL.cpp | f5bf5507fe91a40a00fd2d0c6d042c002f34e075 | []
| no_license | dogtwelve/fighter3d | 7bb099f0dc396e8224c573743ee28c54cdd3d5a2 | c073194989bc1589e4aa665714c5511f001e6400 | refs/heads/master | 2021-04-30T15:58:11.300681 | 2011-06-27T18:51:30 | 2011-06-27T18:51:30 | 33,675,635 | 1 | 0 | null | null | null | null | ISO-8859-3 | C++ | false | false | 14,584 | cpp | /**********************************************************
This source is used to make *SIMPLE* OGLSL Demos.
Basically it is a minimal GLUT setup code.
The user/student just has to add basic OpenGL code
and GLSL variable management to test GLSL programs.
There are also some functions for
* Loading and creating textures (24 and 32 bit RAW)
* Drawing in 2D (for image processing OGLSL programs)
* Simple Text Output
Last update: January 27, 2004
Version: 0.0.5
author: Martin Christen, [email protected]
**********************************************************/
#include <iostream>
#include <string>
#include <sstream>
#include <stdlib.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "simpleGL.h"
#include <vector>
using namespace std;
// Define this in main.cpp
extern void DrawFrame(void);
extern void AppExit(void);
extern void AppInit(void);
// simple Camera:
float camera[3];
float lookat[3];
float cam[3];
// Mouse rotation (currently not trackball)
static int mousepos_x = 0, mousepos_y = 0, tmpX, tmpY;
bool rotate=false;
// other globals:
bool _use_shader = true; // false: user turned off shader functionality.
// Default Shader
aShaderObject* _DefaultShader = 0;
aVertexShader* _DefaultVertexShader = 0;
aFragmentShader* _DefaultFragmentShader = 0;
// ---------------------------------------------------------------------------------------
// switch to 2D-Coordinate System:
// x,y: Screen coordinates to set origin in screen Space
// note: (0,0) is TOP LEFT!!
void begin2d(float x, float y)
{
int win_width = glutGet(GLUT_WINDOW_WIDTH);
int win_height = glutGet(GLUT_WINDOW_HEIGHT);
glPushAttrib(GL_ENABLE_BIT | GL_TRANSFORM_BIT);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
// Koordinaten 2D:
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, win_width, 0, -win_height);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glTranslatef((float)x, (float)y-win_height, 0.0);
glRasterPos2f(0, 0);
}
// ---------------------------------------------------------------------------------------
// Stop drawing in Screen Coordinates and use old GL Settings
void end2d(void)
{
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glPopAttrib();
}
// ---------------------------------------------------------------------------------------
// mcDrawString: Draw a string in screen coordinates
// (0,0) is top left.
static GLvoid *font_style = GLUT_BITMAP_HELVETICA_18;
// GLUT_BITMAP_HELVETICA_10, GLUT_BITMAP_HELVETICA_12, GLUT_BITMAP_HELVETICA_18
// GLUT_BITMAP_TIMES_ROMAN_10, GLUT_BITMAP_TIMES_ROMAN_24
// GLUT_BITMAP_8_BY_13, GLUT_BITMAP_9_BY_15
void mcDrawString(float x, float y, stringstream& stream)
{
begin2d(x,y);
for (unsigned int i=0; i<(strlen(stream.str().c_str())); i++)
glutBitmapCharacter(font_style, stream.str().c_str()[i]);
stream.str("");
end2d();
}
// ---------------------------------------------------------------------------------------
//Load RAW quadratic texture (24bit or 32bit)
// store all textures in a master list:
vector<char*> Texture_MasterList;
char* LoadTexture(char* filename, int width, int nbytes) // load RAW N x N Texture RGBA (4byte) or RGB (3byte)
{
if ((nbytes !=3) && (nbytes !=4))
{
cout << "error: supported Textures: 24bit (3 bytes) or 32bit (4 bytes)";
return 0;
}
char* optr;
ifstream file;
file.open(filename, ios::in | ios::binary);
if(!file)
{
cout << "** FATAL ERROR: Can't open texture\n";
exit(-1);
}
// get file length:
file.seekg(0,ios::end);
unsigned long L = file.tellg();
file.seekg(ios::beg);
if (L/nbytes/width!=width)
{
cout << file << " is not a " << width << "x" << width << " Texture with " << nbytes << " bytes per pixel\n";
exit(-1);
}
optr = new char[L+1];
optr[0] = (char) nbytes; // first byte stores number of bytes per pixel, 3 or 4
file.read(optr+1, L);
Texture_MasterList.push_back(optr);
return optr;
}
// ---------------------------------------------------------------------------------------
// create Texture from data
void createTexture(char* data, GLuint* num)
{
glGenTextures(1, num);
glBindTexture(GL_TEXTURE_2D, *num);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
if (data[0] == 4) // RGBA Texture: 4 Bytes per pixel
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA ,GL_UNSIGNED_BYTE, data+1);
else if (data[0] == 3) // RGB Texture: 3 Bytes per pixel
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 256, 0, GL_RGB ,GL_UNSIGNED_BYTE, data+1);
}
// ----------------------------------------------------------
void init(void)
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//glShadeModel(GL_FLAT);
//glEnable(GL_BLEND);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
//glDepthFunc(GL_LESS);
//glEnable(GL_CULL_FACE);
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
AppInit();
}
// ---------------------------------------------------------------------------------------
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Modelview Transformation
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(camera[0], camera[1], camera[2], lookat[0], lookat[1], lookat[2], 0, 1, 0);
//glTranslatef(0.0,0.0,-5.0);
glTranslatef(cam[0],cam[1],cam[2]);
// Simple mouse rotation:
glRotatef((GLfloat) mousepos_x, -1.0, 0.0, 0.0);
glRotatef((GLfloat) mousepos_y, 0.0, -1.0, 0.0);
// Call user draw function
DrawFrame();
glutSwapBuffers();
}
// ---------------------------------------------------------------------------------------
void reshape(int w, int h)
{
float aspect = (float) w/((h)?h:1);
glViewport(0,0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, aspect, 1.0f, 100.0f);
glViewport(0,0,w,h);
glMatrixMode(GL_MODELVIEW);
}
// ---------------------------------------------------------------------------------------
void animate(void)
{
glutPostRedisplay();
}
// ---------------------------------------------------------------------------------------
void keyboard(unsigned char key, int x, int y)
{
switch (key)
{
case 27: // escape: exit
AppExit();
exit(0);
break;
case 'w':
cam[1] += 0.1;
break;
case 's':
cam[1] -= 0.1;
break;
case 'a':
cam[0] += 0.1;
break;
case 'd':
cam[0] -= 0.1;
break;
case 'r':
cam[2] += 0.1;
break;
case 'f':
cam[2] -= 0.1;
break;
case 'p': // turn Shader on/off
_use_shader = !_use_shader;
aShaderObject::useShader(_use_shader);
break;
}
#ifdef CUSTOM_KEYBOARD_FUNCTION
CUSTOM_KEYBOARD_FUNCTION(key);
#endif
}
// ---------------------------------------------------------------------------------------
void mouse(int button, int state, int x, int z)
{
switch(button){
case GLUT_LEFT_BUTTON:
if (state == GLUT_DOWN)
{
tmpX = x;
tmpY = z;
rotate = true;
}
else
{
rotate = false;
}
break;
}
#ifdef CUSTOM_MOUSE_FUNCTION
CUSTOM_MOUSE_FUNCTION(x,y,(state==GLUT_DOWN));
#endif
}
// ---------------------------------------------------------------------------------------
void motion(int x, int z)
{
if(rotate) //Rotiere, wenn linke maustaste gedrückt
{
mousepos_y = (mousepos_y + (x - tmpX))%360;
mousepos_x = (mousepos_x + (z - tmpY))%360;
tmpX = x;
tmpY = z;
glutPostRedisplay();
}
}
// ---------------------------------------------------------------------------------------
int main(int argc, char* argv[])
{
atexit(DefaultCleanup);
camera[0] = 0.0f;
camera[1] = 0.0f;
camera[2] = 5.0f;
cam[0] = cam[1] = cam[2] = 0.0f;
lookat[0] = 0.0f-camera[0];
lookat[1] = 0.0f-camera[1];
lookat[2] = 5.0f-camera[2];
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB);
glutInitWindowSize(640,480);
glutInitWindowPosition(0,0);
glutCreateWindow(argv[0]);
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
//glutSpecialFunc(specialkeys);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutIdleFunc(animate);
glutMainLoop();
AppExit();
return 0;
}
// ---------------------------------------------------------------------------------------
// Setup a 'nice' default lighting
// you can call this function in main.cpp
void DefaultLighting(void)
{
// ---------------------------------------
// OpenGL Settings
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
// Light model parameters:
// -------------------------------------------
GLfloat lmKa[] = {0.0, 0.0, 0.0, 0.0 };
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmKa);
glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, 1.0);
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, 0.0);
// -------------------------------------------
// Spotlight Attenuation
GLfloat spot_direction[] = {1.0, -1.0, -1.0 };
GLint spot_exponent = 30;
GLint spot_cutoff = 180;
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spot_direction);
glLighti(GL_LIGHT0, GL_SPOT_EXPONENT, spot_exponent);
glLighti(GL_LIGHT0, GL_SPOT_CUTOFF, spot_cutoff);
GLfloat Kc = 1.0;
GLfloat Kl = 0.0;
GLfloat Kq = 0.0;
glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION,Kc);
glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, Kl);
glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, Kq);
// -------------------------------------------
// Lighting parameters:
GLfloat light_pos[] = { 0.0, 5.0, 5.0, 1.0};
GLfloat light_Ka[] = {1.0, 0.5, 0.5, 1.0};
GLfloat light_Kd[] = {0.1, 0.1, 0.1, 1.0};
GLfloat light_Ks[] = {1.0, 1.0, 1.0, 1.0};
glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
glLightfv(GL_LIGHT0, GL_AMBIENT, light_Ka);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_Kd);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_Ks);
// -------------------------------------------
// Material parameters:
GLfloat material_Ka[] = {0.5, 0.0, 0.0, 1.0};
GLfloat material_Kd[] = {0.4, 0.4, 0.5, 1.0};
GLfloat material_Ks[] = {0.8, 0.8, 0.0, 1.0};
GLfloat material_Ke[] = {0.1, 0.0, 0.0, 0.0};
GLfloat material_Se = 20.0;
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, material_Ka);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, material_Kd);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, material_Ks);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, material_Ke);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material_Se);
}
// ---------------------------------------------------------------------------------------
// ShaderSetup loads a vertex and a fragment shader
// and returns the Object. (You can set Fragment or Vertex
// Filename to 0 and default shader is used.)
// I don't want load / compile / link source code in every
// tutorial main file when I don't need OGLSL libraries.
aShaderObject* DefaultShaderSetup(char* vertex, char* fragment)
{
_DefaultShader = new aShaderObject;
if (vertex!=0) _DefaultVertexShader = new aVertexShader;
if (fragment!=0) _DefaultFragmentShader = new aFragmentShader;
// load vertex program
if (vertex!=0)
if (_DefaultVertexShader->load(vertex) != 0)
{
cout << "can't load vertex shader!\n";
exit(-1); // if file is missing: major error, better exit
}
// Load fragment program
if (fragment!=0)
if (_DefaultFragmentShader->load(fragment) != 0)
{
cout << "can't load fragment shader!\n";
exit(-1); // if file is missing: major error, better exit
}
// Compile vertex program
if (vertex!=0)
if (!_DefaultVertexShader->compile())
{
cout << "***COMPILER ERROR (Vertex Shader):\n";
cout << _DefaultVertexShader->getCompilerLog() << endl;
exit(-1);
}
// Compile fragment program
if (fragment!=0)
if (!_DefaultFragmentShader->compile())
{
cout << "***COMPILER ERROR (Fragment Shader):\n";
cout << _DefaultFragmentShader->getCompilerLog() << endl;
exit(-1);
}
// Add to object
if (vertex!=0) _DefaultShader->addShader(_DefaultVertexShader);
if (fragment!=0) _DefaultShader->addShader(_DefaultFragmentShader);
// link
if (!_DefaultShader->link())
{
cout << "**LINKER ERROR\n";
cout << _DefaultShader->getLinkerLog() << endl;
exit(-1);
}
return _DefaultShader;
}
// ---------------------------------------------------------------------------------------
// exit handler calls DefaultCleanup
void DefaultCleanup(void)
{
// free default Shaders if defined
if (_DefaultShader!=0) delete _DefaultShader; _DefaultShader=0;
if (_DefaultVertexShader!=0) delete _DefaultVertexShader; _DefaultVertexShader=0;
if (_DefaultFragmentShader!=0) delete _DefaultFragmentShader; _DefaultFragmentShader=0;
// free textures
vector<char*>::iterator i = Texture_MasterList.begin();
while (i!=Texture_MasterList.end())
{
free(*i);
i = Texture_MasterList.erase(i);
}
}
| [
"dmaciej1@f75eed02-8a0f-11dd-b20b-83d96e936561"
]
| [
[
[
1,
540
]
]
]
|
f258d30c281aeff1f27eceff3b1a5d46dae651c9 | a04058c189ce651b85f363c51f6c718eeb254229 | /Src/Moriarty.cpp | 3bd24b0d9331516aa3d2fa2852846feb718d46e0 | []
| no_license | kjk/moriarty-palm | 090f42f61497ecf9cc232491c7f5351412fba1f3 | a83570063700f26c3553d5f331968af7dd8ff869 | refs/heads/master | 2016-09-05T19:04:53.233536 | 2006-04-04T06:51:31 | 2006-04-04T06:51:31 | 18,799 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 666 | cpp |
#include "MoriartyApplication.hpp"
void std::__msl_error(const char* str)
{
ErrFatalDisplay(str);
ErrThrow(sysErrParamErr);
}
void ArsLexis::handleBadAlloc()
{
ErrThrow(memErrNotEnoughSpace);
}
UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
{
return Application::main<MoriartyApplication>(cmd, cmdPBP, launchFlags);
}
const char rsaPublicKey[] = "\xdb\xa6\x0a\x13\x10\x98\xb7\xfc\x9d\x78\x47\x9f\x40\xf0\x10\xdd\xe6\x52\xad\xe7\x21\xc6\x12\xdb\x22\x4a\xb2\x90\x58\x3c\x5f\x98\xae\xf1\xd2\x6b\x66\xca\x33\xf9\x16\xa6\xa2\xdb\xdc\x8a\x42\x34\x96\x80\x42\x81\x7e\xc9\xab\x0c\x76\x79\x4d\x46\x08\xa4\x7a\xd3"; | [
"andrzejc@a75a507b-23da-0310-9e0c-b29376b93a3c"
]
| [
[
[
1,
20
]
]
]
|
6183ec3cd46fa2ba893a4b9328616f0a5fe9f8cf | ed6cf601b35e94525080e09e84a26cd8effe5039 | /trunk/lib/band.h | 178f9dc4c9a9006abd96ffa2d98d7cb4c42bec2a | []
| no_license | BackupTheBerlios/libdwic-svn | ebab15e6981ed087f477e58b4b3946e2967954d3 | cef0dc6fa449de683b39a425021c2529732670e4 | refs/heads/master | 2020-05-29T14:08:03.525985 | 2007-05-05T18:14:20 | 2007-05-05T18:14:20 | 40,799,904 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,750 | h | /***************************************************************************
* Copyright (C) 2006-2007 by Nicolas BOTTI <[email protected]> *
* *
* This software is a computer program whose purpose is to compress *
* images. *
* *
* This software is governed by the CeCILL v2 license under French law and *
* abiding by the rules of distribution of free software. You can use, *
* modify and/ or redistribute the software under the terms of the *
* CeCILL v2 license as circulated by CEA, CNRS and INRIA at the following *
* URL "http://www.cecill.info". *
* *
* As a counterpart to the access to the source code and rights to copy, *
* modify and redistribute granted by the license, users are provided only *
* with a limited warranty and the software's author, the holder of the *
* economic rights, and the successive licensors have only limited *
* liability. *
* *
* In this respect, the user's attention is drawn to the risks associated *
* with loading, using, modifying and/or developing or reproducing the *
* software by the user in light of its specific status of free software, *
* that may mean that it is complicated to manipulate, and that also *
* therefore means that it is reserved for developers and experienced *
* professionals having in-depth computer knowledge. Users are therefore *
* encouraged to load and test the software's suitability as regards their *
* requirements in conditions enabling the security of their systems *
* and/or data to be ensured and, more generally, to use and operate it *
* in the same conditions as regards security. *
* *
* The fact that you are presently reading this means that you have had *
* knowledge of the CeCILL v2 license and that you accept its terms. *
***************************************************************************/
#pragma once
#include "muxcodec.h"
namespace libdwic {
#define LL_BAND 0
#define V_BAND 1
#define H_BAND 2
#define D1_BAND 3 // diag direction = "\"
#define D2_BAND 4 // diag direction = "/"
typedef union {
float f;
int i;
} flint;
class CBand
{
public:
CBand(void);
virtual ~CBand();
unsigned int DimX; // Width of the band (Datas)
unsigned int DimY; // Height of the band
unsigned int DimXAlign; // Alignement Width (Buffer)
unsigned int BandSize; // (DimXAlign * DimY), the band size in SAMPLES
int Max; // Max of the band
int Min; // Min of the band
unsigned int Dist; // Distortion (Square Error)
unsigned int Count; // Count of non-zero coeffs
float Weight; // Weighting of the band distortion
// (used for Quant calc and PSNR calc)
CBand *pParent; // Parent Band
CBand *pChild; // Child Band
CBand *pNeighbor[3]; // Band neighbors (other component bands
// that can be used for context modeling)
flint *pBand; // Band datas
void Init(unsigned int x = 0, unsigned int y = 0, int Align = ALIGN);
// Quantification
unsigned int Thres(float Thres);
unsigned int TSUQ(float Quant, float Thres);
void TSUQi( float Quant, float RecLevel);
void SimpleQuant(int quant);
template <bool high_band> void buildTree();
// Codage
template <cmode mode>
void enu(CMuxCodec * pCodec);
template <cmode mode>
void pred(CMuxCodec * pCodec);
template <cmode mode>
void tree(CMuxCodec * pCodec);
// Statistiques
void Mean(float & Mean, float & Var);
// Utilitaires
void Add(float val);
void GetBand(float * pOut);
void Clear(bool recurse = false);
private:
char * pData;
// Codage
void CoefCode(int i, int j, CMuxCodec * pCodec);
void CoefDecode(int i, int j, CMuxCodec * pCodec);
template <bool directK>
static unsigned int enuCode4x4(CMuxCodec * pCodec, int * pCur,
int stride, unsigned int kPred);
template <bool directK>
static unsigned int enuDecode4x4(CMuxCodec * pCodec, int * pCur,
int stride, unsigned int kPred);
static const unsigned short cumProba[33][18];
static const unsigned short * pcumProba[33];
static const int golombK[17];
};
}
| [
"nibo637x@b08776e6-7308-0410-831e-fd3d7badec12"
]
| [
[
[
1,
119
]
]
]
|
712a017d9c9b17406a43ddf7101604bff077ec39 | 2199870f3077e1005a36cd1cb2382368aeb977de | /TennisTrack2/TennisTrack2/TennisTrack2.cpp | 90cabff84cb6139944faaa0ed6ef0f020579a78b | []
| no_license | caomw/CVTrack | 89f39cd579f6a419258f74baebb10470f0c02058 | a384d63a1831beb724e8b11463f9b00f3015b1f8 | refs/heads/master | 2020-12-31T02:22:20.345394 | 2011-06-04T15:45:09 | 2011-06-04T15:45:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,173 | cpp | // TennisTrack2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
/*****************************************************************************************
* Name : Fast object tracking using the OpenCV library *
* Author : Lior Chen <[email protected]> *
* Notice : Copyright (c) Jun 2010, Lior Chen, All Rights Reserved *
* : *
* Site : http://www.lirtex.com *
* WebPage : http://www.lirtex.com/robotics/fast-object-tracking-robot-computer-vision *
* : *
* Version : 1.0 *
* Notes : By default this code will open the first connected camera. *
* : In order to change to another camera, change *
* : CvCapture* capture = cvCaptureFromCAM( 0 ); to 1,2,3, etc. *
* : Also, the code is currently configured to tracking RED objects. *
* : This can be changed by changing the hsv_min and hsv_max vectors *
* : *
* License : 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 <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
#include <CLEyeMulticam.h>
class CLEyeCameraCapture
{
CHAR _windowName[256];
GUID _cameraGUID;
CLEyeCameraInstance _cam;
CLEyeCameraColorMode _mode;
CLEyeCameraResolution _resolution;
float _fps;
HANDLE _hThread;
bool _running;
public:
CLEyeCameraCapture(LPSTR windowName, GUID cameraGUID, CLEyeCameraColorMode mode, CLEyeCameraResolution resolution, float fps) :
_cameraGUID(cameraGUID), _cam(NULL), _mode(mode), _resolution(resolution), _fps(fps), _running(false)
{
strcpy(_windowName, windowName);
}
bool StartCapture()
{
_running = true;
// Start CLEye image capture thread
_hThread = CreateThread(NULL, 0, &CLEyeCameraCapture::CaptureThread, this, 0, 0);
if(_hThread == NULL)
{
MessageBox(NULL,"Could not create capture thread","CLEyeMulticamTest", MB_ICONEXCLAMATION);
return false;
}
return true;
}
void StopCapture()
{
if(!_running) return;
_running = false;
WaitForSingleObject(_hThread, 1000);
}
void IncrementCameraParameter(int param)
{
if(!_cam) return;
CLEyeSetCameraParameter(_cam, (CLEyeCameraParameter)param, CLEyeGetCameraParameter(_cam, (CLEyeCameraParameter)param)+10);
}
void DecrementCameraParameter(int param)
{
if(!_cam) return;
CLEyeSetCameraParameter(_cam, (CLEyeCameraParameter)param, CLEyeGetCameraParameter(_cam, (CLEyeCameraParameter)param)-10);
}
void Run()
{
int w, h;
IplImage *pCapImage;
PBYTE pCapBuffer = NULL;
// Create camera instance
_cam = CLEyeCreateCamera(_cameraGUID, _mode, _resolution, _fps);
if(_cam == NULL) return;
// Get camera frame dimensions
CLEyeCameraGetFrameDimensions(_cam, w, h);
// Depending on color mode chosen, create the appropriate OpenCV image
if(_mode == CLEYE_COLOR_PROCESSED || _mode == CLEYE_COLOR_RAW)
pCapImage = cvCreateImage(cvSize(w, h), IPL_DEPTH_8U, 4);
else
pCapImage = cvCreateImage(cvSize(w, h), IPL_DEPTH_8U, 1);
// Set some camera parameters
//CLEyeSetCameraParameter(_cam, CLEYE_GAIN, 30);
//CLEyeSetCameraParameter(_cam, CLEYE_EXPOSURE, 500);
//CLEyeSetCameraParameter(_cam, CLEYE_AUTO_EXPOSURE, false);
//CLEyeSetCameraParameter(_cam, CLEYE_AUTO_GAIN, false);
//CLEyeSetCameraParameter(_cam, CLEYE_AUTO_WHITEBALANCE, false);
//CLEyeSetCameraParameter(_cam, CLEYE_WHITEBALANCE_RED, 100);
//CLEyeSetCameraParameter(_cam, CLEYE_WHITEBALANCE_BLUE, 200);
//CLEyeSetCameraParameter(_cam, CLEYE_WHITEBALANCE_GREEN, 200);
// Start capturing
CLEyeCameraStart(_cam);
CvMemStorage* storage = cvCreateMemStorage(0);
IplImage* hsv_frame = cvCreateImage(cvSize(pCapImage->width, pCapImage->height), IPL_DEPTH_8U, 3);
IplImage* thresholded = cvCreateImage(cvSize(pCapImage->width, pCapImage->height), IPL_DEPTH_8U, 1);
IplImage* temp = cvCreateImage(cvSize(pCapImage->width >> 1, pCapImage->height >> 1), IPL_DEPTH_8U, 3);
// Create a window in which the captured images will be presented
cvNamedWindow( "Camera" , CV_WINDOW_AUTOSIZE );
cvNamedWindow( "HSV", CV_WINDOW_AUTOSIZE );
cvNamedWindow( "EdgeDetection", CV_WINDOW_AUTOSIZE );
//int hl = 100, hu = 115, sl = 95, su = 135, vl = 115, vu = 200;
int hl = 5, hu = 75, sl = 40, su = 245, vl = 105, vu = 175;
// image capturing loop
while(_running)
{
// Detect a red ball
CvScalar hsv_min = cvScalar(hl, sl, vl, 0);
CvScalar hsv_max = cvScalar(hu, su, vu, 0);
cvGetImageRawData(pCapImage, &pCapBuffer);
CLEyeCameraGetFrame(_cam, pCapBuffer);
cvConvertImage(pCapImage, hsv_frame);
// Get one frame
if( !pCapImage )
{
fprintf( stderr, "ERROR: frame is null...\n" );
getchar();
break;
}
// Covert color space to HSV as it is much easier to filter colors in the HSV color-space.
cvCvtColor(pCapImage, hsv_frame, CV_RGB2HSV);
// Filter out colors which are out of range.
cvInRangeS(hsv_frame, hsv_min, hsv_max, thresholded);
// Memory for hough circles
CvMemStorage* storage = cvCreateMemStorage(0);
// hough detector works better with some smoothing of the image
cvSmooth( thresholded, thresholded, CV_GAUSSIAN, 9, 9 );
CvSeq* circles = cvHoughCircles(thresholded, storage, CV_HOUGH_GRADIENT, 2,
thresholded->height/4, 100, 50, 10, 400);
for (int i = 0; i < circles->total; i++)
{
float* p = (float*)cvGetSeqElem( circles, i );
//printf("Ball! x=%f y=%f r=%f\n\r",p[0],p[1],p[2] );
cvCircle( pCapImage, cvPoint(cvRound(p[0]),cvRound(p[1])),
3, CV_RGB(0,255,0), -1, 8, 0 );
cvCircle( pCapImage, cvPoint(cvRound(p[0]),cvRound(p[1])),
cvRound(p[2]), CV_RGB(255,0,0), 3, 8, 0 );
}
cvShowImage( "Camera", pCapImage ); // Original stream with detected ball overlay
cvShowImage( "HSV", hsv_frame); // Original stream in the HSV color space
cvShowImage( "EdgeDetection", thresholded ); // The stream after color filtering
cvReleaseMemStorage(&storage);
// Do not release the frame!
//If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
//remove higher bits using AND operator
int key = cvWaitKey(10);
switch(key){
case 'q' : hu += 5; break;
case 'Q' : hu -= 5; break;
case 'a' : hl -= 5; break;
case 'A' : hl += 5; break;
case 'w' : su += 5; break;
case 'W' : su -= 5; break;
case 's' : sl -= 5; break;
case 'S' : sl += 5; break;
case 'e' : vu += 5; break;
case 'E' : vu -= 5; break;
case 'd' : vl -= 5; break;
case 'D' : vl += 5; break;
}
if (key != -1){
printf("H: %i, S: %i, V: %i\nH: %i, S: %i, V: %i\n\n", hu, su, vu, hl, sl, vl);
}
}
cvReleaseImage(&temp);
cvReleaseImage(&pCapImage);
// Stop camera capture
CLEyeCameraStop(_cam);
// Destroy camera object
CLEyeDestroyCamera(_cam);
// Destroy the allocated OpenCV image
cvReleaseImage(&pCapImage);
_cam = NULL;
}
static DWORD WINAPI CaptureThread(LPVOID instance)
{
// seed the rng with current tick count and thread id
srand(GetTickCount() + GetCurrentThreadId());
// forward thread to Capture function
CLEyeCameraCapture *pThis = (CLEyeCameraCapture *)instance;
pThis->Run();
return 0;
}
};
int main(int argc, _TCHAR* argv[])
{
CLEyeCameraCapture *cam = NULL;
// Query for number of connected cameras
int numCams = CLEyeGetCameraCount();
if(numCams == 0)
{
printf("No PS3Eye cameras detected\n");
return -1;
}
char windowName[64];
// Query unique camera uuid
GUID guid = CLEyeGetCameraUUID(0);
printf("Camera GUID: [%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x]\n",
guid.Data1, guid.Data2, guid.Data3,
guid.Data4[0], guid.Data4[1], guid.Data4[2],
guid.Data4[3], guid.Data4[4], guid.Data4[5],
guid.Data4[6], guid.Data4[7]);
sprintf(windowName, "Face Tracker Window");
// Create camera capture object
// Randomize resolution and color mode
cam = new CLEyeCameraCapture(windowName, guid, CLEYE_COLOR_PROCESSED, CLEYE_VGA, 75);
printf("Starting capture\n");
cam->StartCapture();
printf("Use the following keys to change camera parameters:\n"
"\t'g' - select gain parameter\n"
"\t'e' - select exposure parameter\n"
"\t'z' - select zoom parameter\n"
"\t'r' - select rotation parameter\n"
"\t'+' - increment selected parameter\n"
"\t'-' - decrement selected parameter\n");
// The <ESC> key will exit the program
CLEyeCameraCapture *pCam = NULL;
int param = -1, key;
while((key = cvWaitKey(0)) != 0x1b)
{
switch(key)
{
case 'g': case 'G': printf("Parameter Gain\n"); param = CLEYE_GAIN; break;
case 'e': case 'E': printf("Parameter Exposure\n"); param = CLEYE_EXPOSURE; break;
case 'z': case 'Z': printf("Parameter Zoom\n"); param = CLEYE_ZOOM; break;
case 'r': case 'R': printf("Parameter Rotation\n"); param = CLEYE_ROTATION; break;
case '+': if(cam) cam->IncrementCameraParameter(param); break;
case '-': if(cam) cam->DecrementCameraParameter(param); break;
}
}
cam->StopCapture();
delete cam;
return 0;
} | [
"[email protected]"
]
| [
[
[
1,
303
]
]
]
|
0e6ab1990e27cab2229bb391852acf0163f23510 | cb1c6c586d769f919ed982e9364d92cf0aa956fe | /include/TRTPacketFrustum.h | 67c9caad17ce6c68d850747fac707a8b5eaef834 | []
| no_license | jrk/tinyrt | 86fd6e274d56346652edbf50f0dfccd2700940a6 | 760589e368a981f321e5f483f6d7e152d2cf0ea6 | refs/heads/master | 2016-09-01T18:24:22.129615 | 2010-01-07T15:19:44 | 2010-01-07T15:19:44 | 462,454 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,164 | h | //=====================================================================================================================
//
// TRTPacketFrustum.h
//
// Definition of class: TinyRT::PacketFrustum
//
// Part of the TinyRT Raytracing Library.
// Author: Joshua Barczak
//
// Copyright 2008 Joshua Barczak. All rights reserved.
// See Doc/LICENSE.txt for terms and conditions.
//
//=====================================================================================================================
#ifndef _TRT_PACKETFRUSTUM_H_
#define _TRT_PACKETFRUSTUM_H_
namespace TinyRT
{
//=====================================================================================================================
/// \ingroup TinyRT
/// \brief Encapsulates a four-plane frustum which bounds a group of rays
///
/// This class provides an implementation of various SIMD-optimized frustum intersection tests,
/// but it is designed around the fast frustum/box test described by Reshetov et al. in the MLRT paper (Siggraph 2005).
///
/// The frustum is defined by a set of four planes whose normals point inside frustum
///
//=====================================================================================================================
class PacketFrustum
{
public:
/// Result codes used for precise culling tests
enum CullResult
{
CULL_INSIDE, ///< The bounding volume is completely contained in the frustum
CULL_OUTSIDE, ///< The bounding volume is completely outside the frustum
CULL_STRADDLE ///< The bounding volume is straddling the frustum
};
/// \brief Derives a bounding frustum for a set of common-origin bounding rays
/// \param rOrigin The shared ray origin
/// \param vBoundingRays The four ray directions which bound the ray set.
/// Elements 0,1,and 2 contain X,Y, and Z components, respectively.
/// The rays must NOT be degenerate (all four rays must be unique).
inline void SetFromBoundingRays( const Vec3f& rOrigin, const SimdVec4f vBoundingRays[3] )
{
// The bounding rays are laid out like this:
// A B ^
// C D U |
// *--> V
//
// The normals for the four planes are: AxC, DxB, CxD, and BxA (left,right,bottom,top)
// If we look at the ray indices its: 0x2, 3x1, 2x3, and 1x0
//
// We compute the plane normals using a vectorized cross product
SimdVec4f vA[4] = {
vBoundingRays[0].Swizzle<0,3,2,1>(),
vBoundingRays[1].Swizzle<0,3,2,1>(),
vBoundingRays[2].Swizzle<0,3,2,1>()
};
SimdVec4f vB[4] = {
vBoundingRays[0].Swizzle<2,1,3,0>(),
vBoundingRays[1].Swizzle<2,1,3,0>(),
vBoundingRays[2].Swizzle<2,1,3,0>()
};
SimdVec4f vNormals[3];
Cross3( vA, vB, vNormals );
// compute 'D' term using vectorized dot product (note that it needs to be negated)
SimdVec4f vOrigin[3] = { SimdVec4f( -rOrigin[0] ), SimdVec4f( -rOrigin[1] ), SimdVec4f( -rOrigin[2] ) };
SimdVec4f vD = Dot3( vNormals, vOrigin );
SetFromPlanes( vNormals[0], vNormals[1], vNormals[2], vD );
};
/// \brief Sets the four bounding planes for the frustum explicitly, based on four plane equations.
///
/// We use the plane equation form: Ax + By + Cz + D = 0
/// The plane order is: left, right, bottom, top. Plane normals must point inside the frustum
inline void SetFromPlanes( const SimdVec4f& vA, const SimdVec4f& vB, const SimdVec4f& vC, const SimdVec4f& vD )
{
X[0] = (vA < 0.0f) & vA ;
X[1] = (vA > 0.0f) & vA ;
Y[0] = (vB < 0.0f) & vB ;
Y[1] = (vB > 0.0f) & vB ;
Z[0] = (vC < 0.0f) & vC ;
Z[1] = (vC > 0.0f) & vC ;
D = vD;
}
/// \brief Performs a conservative frustum-box rejection test. Returns true if the frustum and box are seperated.
inline bool RejectBox( const Vec3f& rMin, const Vec3f& rMax ) const
{
// frustum-box trivial rejection test, based on Reshetov's MLRT paper
// This code is basically doing four plane-point dot-products in parallel. The X[0],X[1] stuff
// is there to select the appropriate corner of the bounding box for each plane
SimdVec4f vPlane = D;
vPlane += ( X[0]*SimdVec4f(rMin.x) ) + ( X[1]*SimdVec4f(rMax.x) );
vPlane += ( Y[0]*SimdVec4f(rMin.y) ) + ( Y[1]*SimdVec4f(rMax.y) );
vPlane += ( Z[0]*SimdVec4f(rMin.z) ) + ( Z[1]*SimdVec4f(rMax.z) );
int nMask = SimdVec4f::Mask( vPlane < SimdVec4f::Zero() );
return ( nMask != 0 );
};
/// \brief Performs a frustum-triangle rejection test. Returns true if the frustum and triangle are seperated
inline bool RejectTri( const Vec3f& v0, const Vec3f& v1, const Vec3f& v2 ) const
{
SimdVec4f t0 = ( X[0] + X[1] ) * SimdVec4f(-v0.x);
t0 += ( Y[0] + Y[1] ) * SimdVec4f(-v0.y);
t0 += ( Z[0] + Z[1] ) * SimdVec4f(-v0.z);
SimdVec4f t1 = ( X[0] + X[1] ) * SimdVec4f(-v1.x);
t1 += ( Y[0] + Y[1] ) * SimdVec4f(-v1.y);
t1 += ( Z[0] + Z[1] ) * SimdVec4f(-v1.z);
SimdVec4f t2 = ( X[0] + X[1] ) * SimdVec4f(-v2.x);
t2 += ( Y[0] + Y[1] ) * SimdVec4f(-v2.y);
t2 += ( Z[0] + Z[1] ) * SimdVec4f(-v2.z);
int nMask = SimdVec4f::Mask( D < SimdVec4f::Min( t0, SimdVec4f::Min( t1, t2 ) ) );
return ( nMask != 0 );
}
/// \sa RejectBox
/// \brief Performs a richer frustum culling test and returns one of three cases: OUTSIDE, INSIDE, STRADDLING
inline CullResult CullBox( const Vec3f& rMin, const Vec3f& rMax ) const
{
// In this case, we want a ternary result (inside, outside, or straddling)
// test near corner
SimdVec4f vPlane = D;
vPlane += ( X[0]*SimdVec4f(rMin.x) ) + ( X[1]*SimdVec4f(rMax.x) );
vPlane += ( Y[0]*SimdVec4f(rMin.y) ) + ( Y[1]*SimdVec4f(rMax.y) );
vPlane += ( Z[0]*SimdVec4f(rMin.z) ) + ( Z[1]*SimdVec4f(rMax.z) );
int nMask = SimdVec4f::Mask( vPlane < SimdVec4f::Zero() );
if( nMask != 0 )
return CULL_OUTSIDE; // nearest corner is outside a plane, reject
// test far corner
vPlane = D;
vPlane += ( X[1]*SimdVec4f(rMin.x) ) + ( X[0]*SimdVec4f(rMax.x) );
vPlane += ( Y[1]*SimdVec4f(rMin.y) ) + ( Y[0]*SimdVec4f(rMax.y) );
vPlane += ( Z[1]*SimdVec4f(rMin.z) ) + ( Z[0]*SimdVec4f(rMax.z) );
nMask = SimdVec4f::Mask( vPlane < SimdVec4f::Zero() );
if( nMask != 0 )
return CULL_STRADDLE; // furthest corner is outside a plane, straddling case
else
return CULL_INSIDE; // near and far corners are inside all planes
};
/// Returns true if a particular point is outside the frustum
inline bool RejectPoint( const Vec3f& rPoint ) const
{
SimdVec4f vPlane = D;
vPlane += ( X[1]*SimdVec4f(rPoint.x) ) + ( X[0]*SimdVec4f(rPoint.x) );
vPlane += ( Y[1]*SimdVec4f(rPoint.y) ) + ( Y[0]*SimdVec4f(rPoint.y) );
vPlane += ( Z[1]*SimdVec4f(rPoint.z) ) + ( Z[0]*SimdVec4f(rPoint.z) );
return SimdVec4f::Mask( vPlane < SimdVec4f::Zero() ) != 0 ;
};
/// \brief Helper method which calls 'RejectBox' on the two corners of an AxisAlignedBox
/// \sa RejectBox
inline bool RejectBox( const AxisAlignedBox& rBox ) const { return RejectBox( rBox.Min(), rBox.Max() ); };
/// \brief Helper method which calls 'CullBox' on the two corners of an AxisAlignedBox
/// \sa CullBox
inline CullResult CullBox( const AxisAlignedBox& rBox ) const { return CullBox( rBox.Min(), rBox.Max() ); };
// Each of the X,Y, and Z members contains two copies of the corresponding component of the plane normals.
// The X[0], Y[0] and Z[0] terms contain the plane normal values (if it is negative), or 0 otherwise.
// The X[1], Y[1] and Z[1] terms contain the plane normal values (if they are positive), or 0 otherwise.
SimdVec4f X[2];
SimdVec4f Y[2];
SimdVec4f Z[2];
SimdVec4f D;
};
}
#endif // _TRT_PACKETFRUSTUM_H_
| [
"jbarcz1@6ce04321-59f9-4392-9e3f-c0843787e809"
]
| [
[
[
1,
192
]
]
]
|
f94e1a690f9e0f77787af7e940e14536f40c88ae | 444a151706abb7bbc8abeb1f2194a768ed03f171 | /trunk/ENIGMAsystem/SHELL/Graphics_Systems/OpenGLES/GScolors.cpp | ba479d577f145a105d2a30d684d6b8fa5a75a3d4 | []
| no_license | amorri40/Enigma-Game-Maker | 9d01f70ab8de42f7c80af9a0f8c7a66e412d19d6 | c6b701201b6037f2eb57c6938c184a5d4ba917cf | refs/heads/master | 2021-01-15T11:48:39.834788 | 2011-11-22T04:09:28 | 2011-11-22T04:09:28 | 1,855,342 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,848 | cpp | /********************************************************************************\
** **
** Copyright (C) 2008 Josh Ventura **
** Copyright (C) 2011 Alasdair Morrison **
** **
** This file is a part of the ENIGMA Development Environment. **
** **
** **
** ENIGMA 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, version 3 of the license or any later version. **
** **
** This application and its source code is distributed AS-IS, 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 recieved a copy of the GNU General Public License along **
** with this code. If not, see <http://www.gnu.org/licenses/> **
** **
** ENIGMA is an environment designed to create games and other programs with a **
** high-level, fully compilable language. Developers of ENIGMA or anything **
** associated with ENIGMA are in no way responsible for its users or **
** applications created by its users, or damages caused by the environment **
** or programs made in the environment. **
** **
\********************************************************************************/
#include "OpenGLHeaders.h"
#include <math.h>
#define __GETR(x) ((x & 0x0000FF))
#define __GETG(x) ((x & 0x00FF00)>>8)
#define __GETB(x) ((x & 0xFF0000)>>16)
/*#define __GETRf(x) fmod(x,256)
#define __GETGf(x) fmod(x/256,256)
#define __GETBf(x) fmod(x/65536,256)*/
#define bind_alpha(alpha) (alpha>1?255:(alpha<0?0:(unsigned char)(alpha*255)))
namespace enigma {
extern unsigned char currentcolor[4];
}
void draw_unbind_all()
{
glBindTexture(GL_TEXTURE_2D, 0);
}
void draw_clear_alpha(int col,float alpha)
{
//Unfortunately, we lack a 255-based method for setting ClearColor.
glClearColor(__GETR(col)/255.0,__GETG(col)/255.0,__GETB(col)/255.0,alpha);
glClear(GL_COLOR_BUFFER_BIT);
}
void draw_clear(int col)
{
glClearColor(__GETR(col)/255.0,__GETG(col)/255.0,__GETB(col)/255.0,1);
glClear(GL_COLOR_BUFFER_BIT);
}
int merge_color(int c1,int c2,double amount)
{
amount = amount > 1 ? 1 : (amount < 0 ? 0 : amount);
return
(unsigned char)(fabs(__GETR(c1)+(__GETR(c2)-__GETR(c1))*amount))
| (unsigned char)(fabs(__GETG(c1)+(__GETG(c2)-__GETG(c1))*amount))<<8
| (unsigned char)(fabs(__GETB(c1)+(__GETB(c2)-__GETB(c1))*amount))<<16;
}
void draw_set_color(int color)
{
enigma::currentcolor[0] = __GETR(color);
enigma::currentcolor[1] = __GETG(color);
enigma::currentcolor[2] = __GETB(color);
glColor4ub(enigma::currentcolor[0],enigma::currentcolor[1],enigma::currentcolor[2],enigma::currentcolor[3]);
}
void draw_set_color_rgb(unsigned char red,unsigned char green,unsigned char blue)
{
enigma::currentcolor[0] = red;
enigma::currentcolor[1] = green;
enigma::currentcolor[2] = blue;
glColor4ub(enigma::currentcolor[0],enigma::currentcolor[1],enigma::currentcolor[2],enigma::currentcolor[3]);
}
void draw_set_alpha(float alpha)
{
enigma::currentcolor[3] = bind_alpha(alpha);
glColor4ub(enigma::currentcolor[0],enigma::currentcolor[1],enigma::currentcolor[2],enigma::currentcolor[3]);
}
void draw_set_color_rgba(unsigned char red,unsigned char green,unsigned char blue,float alpha)
{
enigma::currentcolor[0] = red;
enigma::currentcolor[1] = green;
enigma::currentcolor[2] = blue;
enigma::currentcolor[3] = bind_alpha(alpha);
glColor4ub(enigma::currentcolor[0],enigma::currentcolor[1],enigma::currentcolor[2],enigma::currentcolor[3]);
}
int draw_get_color() {
return enigma::currentcolor[0] | (enigma::currentcolor[1] << 8) | (enigma::currentcolor[2] << 16);
}
int draw_get_red() { return enigma::currentcolor[0]; }
int draw_get_green() { return enigma::currentcolor[1]; }
int draw_get_blue() { return enigma::currentcolor[2]; }
float draw_get_alpha() {
return enigma::currentcolor[3] / 255.0;
}
int make_color_rgb(unsigned char r, unsigned char g, unsigned char b) {
return r + (g << 8) + (b << 16);
}
int color_get_red (int c) { return __GETR(c); }
int color_get_green(int c) { return __GETG(c); }
int color_get_blue (int c) { return __GETB(c); }
int color_get_hue(int c)
{
int r = __GETR(c),g = __GETG(c),b = __GETB(c);
int cmpmax = r>g ? (r>b?r:b) : (g>b?g:b);
if(!cmpmax) return 0;
double cmpdel = cmpmax - (r<g ? (r<b?r:b) : (g<b?g:b)); //Maximum difference
double h = (r == cmpmax ? (g-b)/cmpdel : (g==cmpmax ? 2-(r-g)/cmpdel : 4+(r-g)/cmpdel));
return int((h<0 ? h+6 : h) * 42.5); //42.5 = 60/360*255
}
int color_get_value(int c)
{
int r = __GETR(c), g = __GETG(c), b = __GETB(c);
return r>g ? (r>b?r:b) : (g>b?g:b);
}
int color_get_saturation(int color)
{
int r = __GETR(color), g = __GETG(color), b = __GETB(color);
int cmpmax = r>g ? (r>b ? r : b) : (g>b ? g : b);
return cmpmax ? 255 - int(255 * (r<g ? (r<b?r:b) : (g<b?g:b)) / double(cmpmax)) : 0;
}
static inline int min(int x,int y) { return x<y ? x:y; }
static inline int max(int x,int y) { return x>y ? x:y; }
static inline int bclamp(int x) { return x > 255 ? 255 : x < 0 ? 0 : x; }
int make_color_hsv(int hue,int saturation,int value)
{
int h = hue&255, s = saturation&255,v = value&255;
double vf = v; vf /= 255.0;
double
red = bclamp(510 - min(h, 255-h) * 6) * vf,
green = bclamp(510 - max(85-h, h-85) * 6) * vf,
blue = bclamp(510 - max(170-h, h-170) * 6) * vf;
red += (v-red) * (1 - s/255.0);
green += (v-green) * (1 - s/255.0);
blue += (v-blue) * (1 - s/255.0);
int redr = int(red);
int greenr = int(green);
int bluer = int(blue);
return (redr>0 ? redr : 0) | (greenr>0 ? (greenr<<8) : 0) | (bluer>0 ? (bluer<<16) : 0);
}
| [
"[email protected]"
]
| [
[
[
1,
163
]
]
]
|
6b7dfb10258c3b551def01db01b6f48ba120b24f | c7120eeec717341240624c7b8a731553494ef439 | /src/cplusplus/freezone-samp/src/core/utility/directory.hpp | 99a5c44f4f0e4f2d465fd02387cdd3184df01b3e | []
| no_license | neverm1ndo/gta-paradise-sa | d564c1ed661090336621af1dfd04879a9c7db62d | 730a89eaa6e8e4afc3395744227527748048c46d | refs/heads/master | 2020-04-27T22:00:22.221323 | 2010-09-04T19:02:28 | 2010-09-04T19:02:28 | 174,719,907 | 1 | 0 | null | 2019-03-09T16:44:43 | 2019-03-09T16:44:43 | null | WINDOWS-1251 | C++ | false | false | 1,183 | hpp | #ifndef DIRECTORY_HPP
#define DIRECTORY_HPP
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <regex>
template <typename func_t>
inline void iterate_directory_impl(boost::filesystem::path const& work, std::tr1::regex const& regex, bool is_recurse, func_t func) {
if (exists(work)) {
for (boost::filesystem::directory_iterator it(work), end; it != end; ++it) {
if (is_directory(it->status()) && is_recurse) {
iterate_directory_impl(it->path(), regex, is_recurse, func);
}
else if (is_regular_file(it->status())) {
if (regex_match(it->leaf(), regex)) {
func(it->path());
}
}
}
}
}
// Использовать например:
// iterate_directory("freemode/etc", ".*\\.conf", tt, true);
template <typename func_t>
inline void iterate_directory(boost::filesystem::path root, std::string const& math_regex, func_t func, bool is_recurse = false) {
std::tr1::regex regex(math_regex);
iterate_directory_impl(root, regex, is_recurse, func);
}
#endif // DIRECTORY_HPP
| [
"dimonml@19848965-7475-ded4-60a4-26152d85fbc5"
]
| [
[
[
1,
31
]
]
]
|
23007da1e1981cfc1adae92f25b6c052bd31df2c | 709cd826da3ae55945fd7036ecf872ee7cdbd82a | /Term/Assignment/CG_2nd/Frustum.h | c1222034fedc8a02e0dac7b18e60c6bbb8823923 | []
| no_license | argapratama/kucgbowling | 20dbaefe1596358156691e81ccceb9151b15efb0 | 65e40b6f33c5511bddf0fa350c1eefc647ace48a | refs/heads/master | 2018-01-08T15:27:44.784437 | 2011-06-19T15:23:39 | 2011-06-19T15:23:39 | 36,738,655 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 565 | h | #pragma once
// Frustum 대화 상자입니다.
class Frustum : public CDialog
{
DECLARE_DYNAMIC(Frustum)
public:
Frustum(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~Frustum();
float f_left, f_right, f_bottom, f_top, f_near, f_far;
// 대화 상자 데이터입니다.
enum { IDD = IDD_DIALOG_FRUSTUM };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButtonOk();
afx_msg void OnBnClickedButtonCancel();
};
| [
"[email protected]"
]
| [
[
[
1,
25
]
]
]
|
96ce6096b334accf2f46dcb3a23478006aa08a09 | a7be5e861b208609b7291715fc234341b6389296 | /dolphin-dinput8/MultiDI.h | e382e04295ce5bdf3e77c6a44cdc6a871deb2e6a | []
| no_license | lfzawacki/dinput-samples | c71ed99d7f60ebb3247312e237d86112be19c4b7 | ff98015af0c22b3908e0cd730c8ec9039f438a68 | refs/heads/master | 2021-01-13T01:29:43.500968 | 2011-07-14T04:22:29 | 2011-07-14T04:22:29 | 1,708,404 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,194 | h | //-----------------------------------------------------------------------------
// File: MultiDI.h
//
// Desc: Multiple user DirectInput support using action mapping
//
// Copyright (C) Microsoft Corporation. All Rights Reserved.
//-----------------------------------------------------------------------------
#ifndef MULTIDI_H
#define MULTIDI_H
#ifndef DIRECTINPUT_VERSION
#define DIRECTINPUT_VERSION 0x0800
#endif
#include <dinput.h>
//-----------------------------------------------------------------------------
// Miscellaneous helper functions
//-----------------------------------------------------------------------------
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
HRESULT DXUtil_WriteStringRegKey( HKEY hKey, LPCTSTR strRegName, LPCTSTR strValue );
HRESULT DXUtil_ReadStringRegKeyCch( HKEY hKey, LPCTSTR strRegName, TCHAR* strDest, DWORD cchDest, LPCTSTR strDefault );
HRESULT DXUtil_ConvertGUIDToStringCch( const GUID* pGuidSrc, TCHAR* strDest, int cchDestChar );
HRESULT DXUtil_ConvertWideStringToGenericCch( TCHAR* tstrDestination, const WCHAR* wstrSource, int cchDestChar );
//-----------------------------------------------------------------------------
// Name: DXUtil_Timer()
// Desc: Performs timer opertations. Use the following commands:
// TIMER_RESET - to reset the timer
// TIMER_START - to start the timer
// TIMER_STOP - to stop (or pause) the timer
// TIMER_ADVANCE - to advance the timer by 0.1 seconds
// TIMER_GETABSOLUTETIME - to get the absolute system time
// TIMER_GETAPPTIME - to get the current time
// TIMER_GETELAPSEDTIME - to get the time that elapsed between
// TIMER_GETELAPSEDTIME calls
//-----------------------------------------------------------------------------
enum TIMER_COMMAND { TIMER_RESET, TIMER_START, TIMER_STOP, TIMER_ADVANCE,
TIMER_GETABSOLUTETIME, TIMER_GETAPPTIME, TIMER_GETELAPSEDTIME };
FLOAT __stdcall DXUtil_Timer( TIMER_COMMAND command );
// E_DIUTILERR_PLAYERWITHOUTDEVICE is returned by the manager class after configuring
// device, and there's a player that hasn't been assigned a device.
#define E_DIUTILERR_PLAYERWITHOUTDEVICE MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF,997)
// E_DIUTILERR_DEVICESTAKEN is returned by the manager class when one player
// on the machine has enough RECENT devices to prevent other players from
// playing. This return code is needed because this sample attempts to give
// all RECENT devices to that player.
#define E_DIUTILERR_DEVICESTAKEN MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF,998)
// E_DIUTILERR_TOOMANYUSERS is returned by the manager class when the number of
// players exceeds the number of devices present on the system. For example,
// if you ask for 4 players on a machine that only has a keyboard and mouse,
// you're 2 short of what you need.
#define E_DIUTILERR_TOOMANYUSERS MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF,999)
//-----------------------------------------------------------------------------
// Name: class CMultiplayerInputDeviceManager
// Desc: Input device manager using DX8 action mapping
//-----------------------------------------------------------------------------
class CMultiplayerInputDeviceManager
{
public:
struct PlayerInfo
{
DWORD dwPlayerIndex; // 0-based player number
TCHAR strPlayerName[MAX_PATH]; // player name
DWORD dwMaxDevices; // max number of elements in pDevices array
DWORD dwNumDevices; // current number of elements in pDevices array
BOOL bFoundDeviceForPlayer; // if a device has been found for this player yet
};
struct DeviceInfo
{
LPDIRECTINPUTDEVICE8 pdidDevice; // dinput device pointer
PlayerInfo* pPlayerInfo; // Player who owns this device
BOOL bRelativeAxis; // TRUE if device is using relative axis
BOOL bMapsPri1Actions; // TRUE if device maps pri 1 actions
BOOL bMapsPri2Actions; // TRUE if device maps pri 2 actions
LPVOID pParam; // app defined pointer assoicated with this device
DIDEVICEINSTANCE didi; // device instance info
};
typedef HRESULT (CALLBACK *LPDIMANAGERCALLBACK)(CMultiplayerInputDeviceManager::PlayerInfo* pPlayerInfo, CMultiplayerInputDeviceManager::DeviceInfo* pDeviceInfo, const DIDEVICEINSTANCE* pdidi, LPVOID);
private:
BOOL m_bCleanupCOM;
HWND m_hWnd;
LPDIRECTINPUT8 m_pDI;
DIACTIONFORMAT* m_pdiaf;
PlayerInfo** m_pUsers;
DWORD m_dwNumUsers;
DeviceInfo* m_pDeviceList;
DWORD m_dwNumDevices;
DWORD m_dwMaxDevices;
LPDIMANAGERCALLBACK m_AddDeviceCallback;
LPVOID m_AddDeviceCallbackParam;
TCHAR* m_strKey;
HKEY m_hKey;
public:
static BOOL CALLBACK StaticEnumSuitableDevicesCB( LPCDIDEVICEINSTANCE pdidi, LPDIRECTINPUTDEVICE8 pdidDevice, DWORD dwFlags, DWORD dwRemainingDevices, VOID* pContext );
static BOOL CALLBACK StaticBuildDeviceListCB( LPCDIDEVICEINSTANCE pdidi, VOID* pContext );
// Device control
BOOL EnumDevice( const DIDEVICEINSTANCE* pdidi, LPDIRECTINPUTDEVICE8 pdidDevice, DWORD dwFlags, DWORD dwDeviceRemaining );
BOOL BuildDeviceListCB( LPCDIDEVICEINSTANCE pdidi );
HRESULT AddDevice( DeviceInfo* pDeviceInfo, BOOL bForceReset );
HRESULT GetDevices( DeviceInfo** ppDeviceInfo, DWORD* pdwNumDevices );
HRESULT ConfigureDevices( HWND hWnd, IUnknown* pSurface, VOID* pCallback, DWORD dwFlags, LPVOID pvCBParam );
DWORD GetNumDevices() { return m_dwNumDevices; }
VOID UnacquireDevices();
VOID SetFocus( HWND hWnd );
PlayerInfo* LookupPlayer( TCHAR* strPlayerName );
HRESULT SaveDeviceOwnershipKeys();
VOID DeleteDeviceOwnershipKeys();
HRESULT UpdateDeviceOwnership();
HRESULT AssignDevices();
HRESULT VerifyAssignment();
HRESULT AddAssignedDevices( BOOL bResetMappings );
HRESULT BuildDeviceList();
VOID CleanupDeviceList();
// Construction
HRESULT SetActionFormat( DIACTIONFORMAT* pdiaf, BOOL bReenumerate, BOOL bResetOwnership, BOOL bResetMappings );
HRESULT Create( HWND hWnd, TCHAR* strUserNames[], DWORD dwNumUsers, DIACTIONFORMAT* pdiaf, LPDIMANAGERCALLBACK AddDeviceCallback, LPVOID pCallbackParam, BOOL bResetOwnership, BOOL bResetMappings );
CMultiplayerInputDeviceManager( TCHAR* strRegKey );
~CMultiplayerInputDeviceManager();
VOID Cleanup();
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
147
]
]
]
|
f47645b0fc587f85f5daefd4469fc1ae381698b1 | cf58ec40b7ea828aba01331ee3ab4c7f2195b6ca | /Nestopia/core/board/NstBoardBandaiLz93d50ex.cpp | 2ddcbb5b17d8d743d8a853d5166752d248821bfe | []
| no_license | nicoya/OpenEmu | e2fd86254d45d7aa3d7ef6a757192e2f7df0da1e | dd5091414baaaddbb10b9d50000b43ee336ab52b | refs/heads/master | 2021-01-16T19:51:53.556272 | 2011-08-06T18:52:40 | 2011-08-06T18:52:40 | 2,131,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,055 | cpp | ////////////////////////////////////////////////////////////////////////////////////////
//
// Nestopia - NES/Famicom emulator written in C++
//
// Copyright (C) 2003-2008 Martin Freij
//
// This file is part of Nestopia.
//
// Nestopia 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.
//
// Nestopia 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 Nestopia; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
////////////////////////////////////////////////////////////////////////////////////////
#include <cstring>
#include "../NstClock.hpp"
#include "NstBoard.hpp"
#include "NstBoardBandai.hpp"
namespace Nes
{
namespace Core
{
namespace Boards
{
namespace Bandai
{
#ifdef NST_MSVC_OPTIMIZE
#pragma optimize("s", on)
#endif
Lz93d50Ex::Lz93d50Ex(const Context& c)
:
Lz93d50 (c),
x24c01 (board == Type::BANDAI_DATACH || board == Type::BANDAI_LZ93D50_24C01 ? new X24C01 : NULL),
x24c02 (board == Type::BANDAI_DATACH || board == Type::BANDAI_LZ93D50_24C02 ? new X24C02 : NULL)
{
}
void Lz93d50Ex::SubReset(const bool hard)
{
Lz93d50::SubReset( hard );
if (x24c01)
x24c01->Reset();
if (x24c02)
x24c02->Reset();
if (x24c01 && x24c02)
{
for (uint i=0x6000; i < 0x8000; i += 0x100)
Map( i, &Lz93d50Ex::Peek_6000_24c01_24c02 );
for (dword i=0x6000; i < 0x10000; i += 0x10)
{
Map( uint(i + 0x0), uint(i + 0x7), &Lz93d50Ex::Poke_8000_24c01_24c02 );
Map( uint(i + 0xD), &Lz93d50Ex::Poke_800D_24c01_24c02 );
}
}
else if (x24c01)
{
for (uint i=0x6000; i < 0x8000; i += 0x100)
Map( i, &Lz93d50Ex::Peek_6000_24c01 );
for (dword i=0x600D; i < 0x10000; i += 0x10)
Map( uint(i), &Lz93d50Ex::Poke_800D_24c01 );
}
else
{
for (uint i=0x6000; i < 0x8000; i += 0x100)
Map( i, &Lz93d50Ex::Peek_6000_24c02 );
for (dword i=0x600D; i < 0x10000; i += 0x10)
Map( uint(i), &Lz93d50Ex::Poke_800D_24c02 );
}
}
void Lz93d50Ex::Load(File& file)
{
const File::LoadBlock block[] =
{
{ x24c02 ? x24c02->GetData() : NULL, x24c02 ? X24C02::SIZE : 0 },
{ x24c01 ? x24c01->GetData() : NULL, x24c01 ? X24C01::SIZE : 0 }
};
file.Load( File::EEPROM, block );
}
void Lz93d50Ex::Save(File& file) const
{
const File::SaveBlock block[] =
{
{ x24c02 ? x24c02->GetData() : NULL, x24c02 ? X24C02::SIZE : 0 },
{ x24c01 ? x24c01->GetData() : NULL, x24c01 ? X24C01::SIZE : 0 }
};
file.Save( File::EEPROM, block );
}
void Lz93d50Ex::SubLoad(State::Loader& state,const dword baseChunk)
{
if (baseChunk == AsciiId<'B','L','E'>::V)
{
while (const dword chunk = state.Begin())
{
switch (chunk)
{
case AsciiId<'C','0','1'>::V:
NST_VERIFY( x24c01 );
if (x24c01)
x24c01->LoadState( state );
break;
case AsciiId<'C','0','2'>::V:
NST_VERIFY( x24c02 );
if (x24c02)
x24c02->LoadState( state );
break;
}
state.End();
}
}
else
{
Lz93d50::SubLoad( state, baseChunk );
}
}
void Lz93d50Ex::SubSave(State::Saver& state) const
{
Lz93d50::SubSave( state );
state.Begin( AsciiId<'B','L','E'>::V );
if (x24c01)
x24c01->SaveState( state, AsciiId<'C','0','1'>::V );
if (x24c02)
x24c02->SaveState( state, AsciiId<'C','0','2'>::V );
state.End();
}
#ifdef NST_MSVC_OPTIMIZE
#pragma optimize("", on)
#endif
NES_PEEK(Lz93d50Ex,6000_24c01)
{
return x24c01->Read();
}
NES_PEEK(Lz93d50Ex,6000_24c02)
{
return x24c02->Read();
}
NES_PEEK(Lz93d50Ex,6000_24c01_24c02)
{
return x24c01->Read() & x24c02->Read();
}
NES_POKE_D(Lz93d50Ex,8000_24c01_24c02)
{
x24c01->SetScl( data << 2 & 0x20 );
}
NES_POKE_D(Lz93d50Ex,800D_24c01)
{
x24c01->Set( data & 0x20, data & 0x40 );
}
NES_POKE_D(Lz93d50Ex,800D_24c02)
{
x24c02->Set( data & 0x20, data & 0x40 );
}
NES_POKE_D(Lz93d50Ex,800D_24c01_24c02)
{
x24c01->SetSda( data & 0x40 );
x24c02->Set( data & 0x20, data & 0x40 );
}
}
}
}
}
| [
"[email protected]"
]
| [
[
[
1,
204
]
]
]
|
6c5ab0aab51a92e5b2e1c457993c95bfca6970b2 | 0f8559dad8e89d112362f9770a4551149d4e738f | /Wall_Destruction/Havok/Source/Common/Base/Thread/Job/ThreadPool/hkJobThreadPool.h | 1b79bc4905616e8240d3bcb51ac2021bc532740b | []
| no_license | TheProjecter/olafurabertaymsc | 9360ad4c988d921e55b8cef9b8dcf1959e92d814 | 456d4d87699342c5459534a7992f04669e75d2e1 | refs/heads/master | 2021-01-10T15:15:49.289873 | 2010-09-20T12:58:48 | 2010-09-20T12:58:48 | 45,933,002 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,972 | 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-2009 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_UTILITIES2_JOB_THREAD_POOL_H
#define HK_UTILITIES2_JOB_THREAD_POOL_H
#include <Common/Base/Object/hkReferencedObject.h>
#include <Common/Base/Thread/JobQueue/hkJobQueue.h>
class hkJobQueue;
struct hkTimerData;
class hkJobThreadPool : public hkReferencedObject
{
public:
virtual ~hkJobThreadPool() {}
virtual void processAllJobs( hkJobQueue* queue, hkJobType firstJobType = HK_JOB_TYPE_MAX ) = 0;
virtual void waitForCompletion( ) = 0;
virtual bool isProcessing() = 0;
virtual int getNumThreads() = 0;
virtual void setNumThreads( int numThreads ) = 0;
virtual void appendTimerData( hkArrayBase<hkTimerData>& timerDataOut, hkMemoryAllocator& alloc ) = 0;
virtual void clearTimerData() = 0;
};
#endif // HK_UTILITIES2_JOB_THREAD_POOL_H
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20091222)
*
* Confidential Information of Havok. (C) Copyright 1999-2009
* 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.
*
*/
| [
"[email protected]"
]
| [
[
[
1,
53
]
]
]
|
44bf61adb3c1834628a7e516aded91d74f6fa60d | 51febe6598848c79ffa36890655e25ed05652d7d | /MarioBros/MarioBros/Score.h | 7791f09f4bd77e492d1d5c592e87a53fb054b267 | []
| no_license | vohoangviet/game-mario-directx | d6db92457ad10fa97d2241394a2c46457fdbe2c3 | e7ad07e7335cd7a2c0cb6b3d1a02af36798cafc4 | refs/heads/master | 2021-01-10T01:33:15.453400 | 2011-12-08T14:15:39 | 2011-12-08T14:15:39 | 43,821,369 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 393 | h | #pragma once
#include "GAnimation.h"
#include "GSprite.h"
#include "GObject.h"
#include <list>
using namespace std;
class Score:public GObject
{
public:
float distanceMove;
float vy;
bool isNeedDelete;
int score;
Score();
Score(GSprite* _sprite,float _x,float _y,int _score);
void Update(float TPF);
void Render(GCamera* camera);
int GetVar(char* varName);
}; | [
"[email protected]"
]
| [
[
[
1,
22
]
]
]
|
32eed255e890d4f3862cf1261e7335b369b14d0a | 01acea32aaabe631ce84ff37340c6f20da3065a6 | /ship.h | 2fd2b81c521fa1721e5c17e1004d519552ef91f4 | []
| no_license | olooney/pattern-space | db2804d75249fe42427c15260ecb665bc489e012 | dcf07e63a6cb7644452924212ed087d45c301e78 | refs/heads/master | 2021-01-20T09:38:41.065323 | 2011-04-20T01:25:58 | 2011-04-20T01:25:58 | 1,638,393 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,418 | h | /*
Ship, Controls
The Ship is the Solid that represents the user, so it responds to key presses
by accelerating.
Note that Ship implements the Solid interface. That means we can simply add
it to the Universe and have it participate in the physics simulation and get
drawn to the screen, no differently than any other Solid.
Note that the Ship 'has-a' Mass and Image. This means we can swap the
implementations of the ship's Mass and Image at run-time. In particular,
we can offer the user a different 'feel' by changing the implementation class
of the Mass; I've found that FrictionMass is the most intuitive to control.
*/
#ifndef PATTERN_SPACE_SHIP_INCLUSION_GUARD
#define PATTERN_SPACE_SHIP_INCLUSION_GUARD
#include <boost/shared_ptr.hpp>
#include "solid.h"
namespace PatternSpace {
/********************* Controls *********************/
// interface used to communicate to user input to a Solid
class Controls {
public:
virtual void up(bool) = 0;
virtual void down(bool) = 0;
virtual void left(bool) = 0;
virtual void right(bool) = 0;
virtual void primary(bool) = 0;
}; // end class Controls
/********************* Ship *********************/
class Ship: public NormalSolid, public Controls {
public:
Ship( std::auto_ptr<Mass> pMass, std::auto_ptr<Image> pImage):
NormalSolid(pMass,pImage,10000,0,3),
upState(false),
downState(false),
leftState(false),
rightState(false),
primaryState(false),
fireMissle(false) {}
void up(bool);
void down(bool);
void left(bool);
void right(bool);
void primary(bool);
void step(double deltaTime);
bool hasSpawn() const;
boost::shared_ptr<Solid> nextSpawn();
private:
const static double ENGINE_THRUST;
const static double ENGINE_REVERSE_THRUST;
const static double TURN_THRUST;
bool upState;
bool downState;
bool leftState;
bool rightState;
bool primaryState;
bool fireMissle; // true while waiting to fire a missle.
}; // end class Ship
} // end namespace PatternSpace
#endif // PATTERN_SPACE_SHIP_INCLUSION_GUARD
| [
"[email protected]"
]
| [
[
[
1,
73
]
]
]
|
0d776183070f83a05fbe6a0fec6cab045ad1db9e | b7c505dcef43c0675fd89d428e45f3c2850b124f | /Util/alcommon/include/albrokerproxy.h | d74e19d0494ed6589c9a4b4062639c3ca35d09f3 | [
"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 | 8,825 | h | /**
* @author Aldebaran Robotics
* Aldebaran Robotics (c) 2007 All Rights Reserved - This file is confidential.\n
*
*
*
* Version : $Id$
*/
#ifndef AL_BROKERPROXY_H
#define AL_BROKERPROXY_H
#include "altypes.h"
#include "alerror.h"
#include <stdlib.h>
#include "alptr.h"
#include "alvalue.h"
#include "almutex.h"
#include "albrokertools.h" // for ALModuleInfo
// deprecated define for debug
//#define AL_BROKER_PROXY_DEBUG(...) printf(__VA_ARGS__)
#define AL_BROKER_PROXY_DEBUG(...)
namespace AL
{
/**
* ALBrokerProxy allow to remotly call broker's method.
*/
class ALBroker;
class ALBrokerProxy
{
public :
/*
* Basic constructor
*/
ALBrokerProxy(ALPtr<ALBroker> parentBroker, const std::string& pBrokerIP, int pBrokerPort);
void setConnection(ALPtr<ALValue> pConnection)
{
fConnection = pConnection;
}
/*
* Basic destructor
*/
virtual ~ALBrokerProxy(void);
/**
* getBrokerName, return name of this broker
* @param reference on broker name
* @return 0 on success
*/
//int getBrokerName( std::string& pBrokerName);
/**
* registerBroker, register a new broker to child to this broker
* @param pBrokerToRegister structure containing broker information
* @return 0 on success
*/
int registerBroker( ALPtr<ALModuleInfo> pBrokerToRegister);
/**
* unregisterBroker, unregister Broker child
* @param pBrokerToUnregister strcuture containing broker information
* @return 0 on success
*/
int unregisterBroker( ALPtr<ALModuleInfo> pBrokerToUnregister);
/**
* getBrokerInfo, return information about this broker
* @param pModuleInfo, out parameter containing information about this broker
* @return 0 on success
*/
int getBrokerInfo( ALPtr<ALModuleInfo> pBrokerInfo );
/**
* getInfo, return structure containing module's information
* @param pModuleName, module's name
* @param pModuleInfo, output parameter containing module's information
* @return 0 on success
*/
int getInfo( const std::string& pModuleName, ALPtr<ALModuleInfo> pModuleInfo);
/**
* pPostMethodCall. generic call to method. usefull in c++ remote procedure call
* @param pMethodeName name of the method to be called
* @param pParams, [input] list of input parameters.
* @return 0 on success
*/
int postMethodCall( const std::string& pModuleName, const std::string& pMethodName, const AL::ALValue& pParams);
/**
* methodCall. generic call to method. usefull in c++ remote procedure call
* @param pMethodeName name of the method to be called
* @param pParams, [input] list of input parameters.
* @param pResult, [output] list of output result.
* @return 0 on success
*/
int methodCall( const std::string& pModuleName, const std::string& pMethodName, const AL::ALValue& pParams, AL::ALValue &pResult);
/**
* exploreToGetModuleByName, used to search a module along the networks
* @param pModuleName, name of the wanted module
* @param pSearchUp, allow this broker to look for module in its parent brokers
* @param pSearchDown, allow this broker to look for module in its childs brokers
* @param pDontLookIntoBrokerName, specify a broker name for which the search must not be call. Usefull to avoid dead lock during search
* @param pModInfo, out parameter containing module information if found.
* @return 0 on success
*/
int exploreToGetModuleByName(const std::string& pModuleName, bool pSearchUp, bool pSearchDown, const std::string& pDontLookIntoBrokerName, ALPtr<ALModuleInfo> pModInfo);
/**
* getModuleByName takes a module name as an input and returns the list of information
* a program will need to contact the module.
* getModuleByName should not be used directly : it should be used through helper functions
* in order to hide the complexity of the returned information.
* @param moduleName name of the module
* @param modInfo returned information about the module\p
* the struct al__moduleInfo is define with these member:\p
* - [string] name\p
* - [int] architecture (see ALTypes.h)\p
* - [string] IP address\p
* - [int] port\p
* - [int] Process ID\p
* - [int] module pointer\p
* @return 0 on success
*/
int getModuleByName(const std::string& pModuleName, ALPtr<ALModuleInfo> pModInfo);
/**
* unregisterModule is typically called when a module quits, as it unregisters the module
* from naoqi.
* @param moduleName name of the module
* @return 0 on success
*/
int unregisterModuleReference(const std::string& pModuleName);
/**
* getModuleList returns the registered module list.
* @params pModuleList list of module information
* @return 0 on success
*/
int getModuleList( ALPtr< TALModuleInfoVector > pBrokerList );
/**
* getBrokerList returns the registered Broker list.
* @params pBrokerList list of Broker information
* @return 0 on success
*/
int getBrokerList( ALPtr<TALModuleInfoVector> pBrokerList );
/**
* getGlobalModuleList returns the registered module list in every broker (global).
* @params pModuleList list of module information
* @return 0 on success
*/
int getGlobalModuleList( ALPtr < TALModuleInfoVector > pModuleList );
/**
* dataChanged, allows to call the dataChanged method on a specified module
* @param pModuleName, module concern by the dataChanged call
* @param pDataName, Name of the ALMemory Data
* @param pValue, value of the ALMemory Data
* @param pMessage, message associate to this callback
* @return 0 on success
*/
int dataChanged(const std::string& pModuleName, const std::string& pDataName, const AL::ALValue& pValue, const std::string& pMessage);
/**
* getMethodList, returns a list of method name of a specified module
* @param pModuleName, name of the module
* @param pMethodListName, output parameter containing the returned method name list.
* @return 0 on success
*/
int getMethodList(const std::string& pModuleName, ALPtr< std::vector<std::string> >pMethodListName);
/**
* getMethodHelp, returns a method's description string
* @param pModuleName, module's name
* @param pMethodName, method's name.
* @param pMethodHelp, output parameter containing a structured method's description
* @return 0 on success
*/
int getMethodHelp( const std::string& pModuleName, const std::string& pMethodeName, AL::ALValue &pMethodHelp );
/**
* init, initialize broker with its own ip and port, and with a possible parent broker.\n
* @param pBrokerName name of this new broker
* @param pIP bind ip of the server
* @param pPort listenning port of the server
* @param pParentBrokerIP ip of the parent broker
* @param pParentPort port of the parent broker
* @return 0 on success
*/
int init(const std::string& pBrokerName, const std::string& pIP, int pPort, const std::string& pParentBrokerIP, int pParentBrokerPort, bool pKeepAlive = false);
/**
* sendBackIP, send back client's ip.
* @param pSoap, soap structure containing client'sip
* @param pIP, out parameter containing IP as string
* @return 0 on success
*/
int sendBackIP( std::string& pIP );
/**
* version, return version of the module
* @param pModuleName, module's name
* @param pVersion, revision of the module as string
* @return 0 on success
*/
int version(std::string& pVersion);
/**
* stop task pId
*/
int stop(int pID);
/**
* stop all tasks pMethodName
*/
int stop(std::string pMethodName);
/**
* return the broker running task list ordered for telepathe
*/
int getDebugTaskList(ALValue& taskList);
/**
* kill broker
*/
int exit( );
public:
inline ALPtr<ALBroker> getParentBroker(void)
{
ALPtr<ALBroker> returnBroker = fParentBroker.lock();
if (returnBroker == NULL)
{
throw ALERROR("ThreadedRemoteExecution", "getParentBroker", "module does not exists");
}
return returnBroker;
}
protected :
// connection structure to other broker
ALPtr<ALValue> fConnection;
/**
* structure containing soap server information
*/
ALPtr<ALMutex> fBrokerSoap_mutex;
/**
* broker pointer
*/
ALWeakPtr<ALBroker> fParentBroker;
};
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
269
]
]
]
|
886879b7421dc119965498079307c4e0142223c6 | 9798f879b08c05b6e0f1e152d75ff72ffcd770da | /pm_main_frame.cc | 0e44973c3222676fbe24d8e29ff4259eb079b98f | []
| no_license | tasdomas/pm-game | 0d22ba3b411fec49d1ceb81524d55ed44ab3cee7 | f93c612858b38428c174fe524e02c0d96734dbef | refs/heads/master | 2021-01-25T03:48:18.869100 | 2008-10-10T13:01:49 | 2008-10-10T13:01:49 | 32,130,531 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,241 | cc | /*
* Protmusio zaidimo valdymo programa.
*
* Domas Monkus, 2008.09
*/
#define wxUSE_UNICODE 1
#include "pm_main_frame.h"
#include "beep_thread.h"
#include "pm_settings_frame.h"
#include "msgs.h"
#include <cstdlib>
#include <ctime>
DEFINE_LOCAL_EVENT_TYPE( EVT_BEEPER )
BEGIN_EVENT_TABLE(PMMainFrame, wxFrame)
EVT_MOUSE_EVENTS(PMMainFrame::OnMouseEvent)
EVT_TIMER(ID_Timer, PMMainFrame::OnTimer)
//settings dialog
EVT_CHAR(PMMainFrame::OnKey)
//paleisti laikmati (gaunama is signalo gijos)
EVT_CUSTOM( EVT_BEEPER, wxID_ANY, PMMainFrame::OnBeeper )
END_EVENT_TABLE()
PMMainFrame::PMMainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style)
: wxFrame((wxFrame *)NULL, -1, title, pos, size, style)
{
CreateControls();
defaultBackground = rows[0].panel->GetBackgroundColour();
//parametrai
dragMode = 0;
resetOnStart = true;
beepRandom = BEEP_RANDOM;
beepStart = BEEP_MIN;
beepEnd = BEEP_MAX;
teamCount = MAX_TEAMS;
srand((unsigned)time(0));
state = STATE_NOT_RUNNING;
for (int i = 0; i < teamCount; i++) {
rows[i].state = TEAM_WAITING;
rows[i].score = 0;
}
//laikmatis
timer = new wxTimer(this, ID_Timer);
watch = new wxStopWatch();
hookActive = 1;
if ((GetKeyState(VK_NUMLOCK) & 1) == 0) {
wxMessageBox(wxT("NumLock turi buti ijungtas!"));
}
}
void PMMainFrame::CreateControls() {
wxPanel * topPanel = new wxPanel(this);
topSizer = new wxBoxSizer(wxVERTICAL);
wxFont font(18, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
//laikmacio isvedimas
timerDisplay = new wxStaticText(topPanel,
wxID_ANY,
wxT("01:00:00"),
wxDefaultPosition,
wxDefaultSize,
wxALIGN_CENTER);
timerDisplay->SetFont(wxFont(font));
timerDisplay->SetEventHandler(this);
topSizer->Add(timerDisplay, 1, wxFIXED_MINSIZE | wxALIGN_CENTER);
for (int i = 0; i < MAX_TEAMS; i++) {
wxPanel * panel = new wxPanel(topPanel);
wxBoxSizer * sizer = new wxBoxSizer(wxHORIZONTAL);
rows[i].panel = panel;
rows[i].nameDisplay = new wxStaticText(panel,
wxID_ANY,
wxString(wxT("Komanda")),
wxDefaultPosition,
wxDefaultSize,
wxALIGN_LEFT);
rows[i].nameDisplay->SetFont(wxFont(font));
rows[i].nameDisplay->SetEventHandler(this);
rows[i].pointsDisplay = new wxStaticText(panel,
wxID_ANY,
wxT("0"),
wxDefaultPosition,
wxDefaultSize,
wxALIGN_RIGHT);
rows[i].pointsDisplay->SetFont(wxFont(font));
rows[i].pointsDisplay->SetEventHandler(this);
sizer->Add(rows[i].nameDisplay, 1, wxEXPAND | wxALIGN_LEFT | wxRIGHT, 10);
sizer->Add(rows[i].pointsDisplay, 0, wxEXPAND | wxALIGN_RIGHT);
panel->SetSizer(sizer);
topSizer->Add(panel, 1, wxEXPAND);
}
topPanel->SetSizer(topSizer);
topSizer->Layout();
topSizer->Fit(this);
this->SetTransparent(200);
}
void PMMainFrame::SetColour(int pos, wxColour colour) {
if ((pos >= 0) && (pos < MAX_TEAMS)) {
rows[pos].nameDisplay->SetBackgroundColour(colour);
rows[pos].pointsDisplay->SetBackgroundColour(colour);
this->Refresh();
}
}
void PMMainFrame::SetTeam(int pos, wxString & name) {
if ((pos >= 0) && (pos < MAX_TEAMS)) {
rows[pos].nameDisplay->SetLabel(name);
}
topSizer->Layout();
topSizer->Fit(this);
}
void PMMainFrame::SetTeams (int count) {
if ((count > 0) && (count <= MAX_TEAMS)) {
if (teamCount > count) { //REMOVE teams
for (int i = teamCount; i > count; i--) {
topSizer->Show(i, false);
}
} else if (teamCount < count) { //add teams
for (int i = teamCount; i <= count; i++) {
topSizer->Show(i, true);
}
}
topSizer->Layout();
topSizer->Fit(this);
teamCount = count;
}
}
void PMMainFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void PMMainFrame::OnTest(wxEvent& WXUNUSED(event))
{
}
WXLRESULT PMMainFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
WXLRESULT rc = 0;
switch (message) {
case MSG_SCORE:
SetScore(wParam);
break;
case MSG_START:
StartGame();
break;
case MSG_PAUSE :
PauseGame();
break;
case MSG_RESET:
ResetGame();
break;
case MSG_GAMEKEY:
if (state != STATE_NOT_RUNNING) {
ProcessGameKey(wParam, lParam);
}
break;
default:
rc = wxFrame::MSWWindowProc(message, wParam, lParam);
}
return rc;
}
void PMMainFrame::ProcessGameKey(long team, long alt) {
if ((alt == 0) && (rows[team].state == TEAM_WAITING)
&& (team >= 0) && (team < 4)) {
if (state == STATE_RUNNING) {
SetTeamState(team, TEAM_ANSWERING);
PauseGame();
BeepThread * beep = new BeepThread(BEEP_CLICK, BEEP_CLICK_LEN);
if (beep->Create() == wxTHREAD_NO_ERROR) {
beep->Run();
}
} else if (state == STATE_BEEPING) {
SetTeamState(team, TEAM_BLOCKED);
}
UpdateTeams();
} else if ((alt != 0) || (team == -1)) { //lygiosios
int draw = 0;
int newState = TEAM_DRAW;
if (state == STATE_BEEPING) {
newState = TEAM_BLOCKED;
}
if (team == -1) {
if (SetTeamState(0, newState)) {
draw++;
}
if (SetTeamState(1, newState)) {
draw++;
}
if (SetTeamState(2, newState)) {
draw++;
}
if (SetTeamState(3, newState)) {
draw++;
}
}
if (alt == KS_LALT) {
switch(team) {
case 0:
if (SetTeamState(2, newState)) {
draw++;
}
if (SetTeamState(1, newState)) {
draw++;
}
if (SetTeamState(0, newState)) {
draw++;
}
break;
case 1:
if (SetTeamState(3, newState)) {
draw++;
}
if (SetTeamState(2, newState)) {
draw++;
}
if (SetTeamState(0, newState)) {
draw++;
}
break;
case 2:
if (SetTeamState(0, newState)) {
draw++;
}
if (SetTeamState(1, newState)) {
draw++;
}
if (SetTeamState(3, newState)) {
draw++;
}
break;
case 3:
if (SetTeamState(1, newState)) {
draw++;
}
if (SetTeamState(2, newState)) {
draw++;
}
if (SetTeamState(3, newState)) {
draw++;
}
break;
}
} else if (alt == KS_LCTRL) {
switch(team) {
case 0:
if (SetTeamState(1, newState)) {
draw++;
}
if (SetTeamState(0, newState)) {
draw++;
}
break;
case 1:
if (SetTeamState(0, newState)) {
draw++;
}
if (SetTeamState(2, newState)) {
draw++;
}
break;
case 2:
if (SetTeamState(0, newState)) {
draw++;
}
if (SetTeamState(3, newState)) {
draw++;
}
break;
case 3:
if (SetTeamState(1, newState)) {
draw++;
}
if (SetTeamState(2, newState)) {
draw++;
}
break;
case 4:
if (SetTeamState(1, newState)) {
draw++;
}
if (SetTeamState(3, newState)) {
draw++;
}
break;
case 5:
if (SetTeamState(2, newState)) {
draw++;
}
if (SetTeamState(3, newState)) {
draw++;
}
break;
}
}
if ((newState == TEAM_DRAW) && (draw > 0)) {
PauseGame();
BeepThread * beep;
if (draw > 1) {
beep = new BeepThread(BEEP_DRAW, 100);
} else {
beep = new BeepThread(BEEP_CLICK, BEEP_CLICK_LEN);
for (int i = 0; i < teamCount; i++) {
if (rows[i].state == TEAM_DRAW) {
rows[i].state = TEAM_ANSWERING;
}
}
}
if (beep->Create() == wxTHREAD_NO_ERROR) {
beep->Run();
}
}
}
UpdateTeams();
}
//mouse event handling
void PMMainFrame::OnMouseEvent(wxMouseEvent& event) {
if (event.LeftDown())
{
dragMode = 1;
dragStart = event.GetPosition();
startPos = this->GetScreenPosition();
}
else if (event.LeftUp() && dragMode != 0)
{
dragMode = 0;
wxPoint current = event.GetPosition();
current = current - dragStart;
wxPoint window = this->GetScreenPosition();
this->Move(window + current);
Refresh(true);
}
else if (event.Dragging() && dragMode != 0)
{
wxPoint current = event.GetPosition();
current = current - dragStart;
if ((abs(current.x) + abs(current.y)) > 0) {
wxPoint window = this->GetScreenPosition();
this->Move(window + current);
Refresh(true);
}
}
}
void PMMainFrame::OnTimer(wxTimerEvent& event) {
long elapse = START_TIME - watch->Time();
int milliseconds = (elapse % 1000) / 10;
int seconds = (elapse / 1000) % 60;
int minutes = elapse / (60*1000);
if ((seconds > 0) && (seconds <= BEEP_START)) {
if (((milliseconds == 0) && (seconds - 1 == beepCount))
|| ((milliseconds != 0) && (seconds == beepCount))) {
beepCount--;
BeepThread * beep = new BeepThread(BEEP_NOTICE, 50);
if (beep->Create() == wxTHREAD_NO_ERROR) {
beep->Run();
}
}
}
if ((minutes <= 0) && (seconds <= 0) && (milliseconds <= 0)) {
TimerStop();
BeepThread * beep = new BeepThread(BEEP_END, 500);
if (beep->Create() == wxTHREAD_NO_ERROR) {
beep->Run();
}
ResetGame();
elapse = 0;
}
ShowTime(elapse);
}
//timer functions
void PMMainFrame::TimerStart(bool reset) {
if (reset) {
beepCount = BEEP_START - 1;
for (int i = 0; i < 5; i++) {
beeps[i] = true;
}
watch->Start();
} else {
watch->Resume();
}
if (!timer->IsRunning()) {
timer->Start(TIMER_INTERVAL);
}
}
void PMMainFrame::TimerStop() {
for (int i = 0; i < 5; i++) {
beeps[i] = true;
}
watch->Pause();
if (timer->IsRunning()) {
timer->Stop();
}
}
void PMMainFrame::TimerPause() {
timer->Stop();
watch->Pause();
}
void PMMainFrame::ShowTime(long timeMs) {
int milliseconds = (timeMs % 1000) / 10;
int seconds = (timeMs / 1000) % 60;
int minutes = timeMs / (60*1000);
wxString time;
time.Printf(wxT("%02d:%02d:%02d"), minutes, seconds, milliseconds);
timerDisplay->SetLabel(time);
}
void PMMainFrame::EditSettings() {
hookActive = 0;
PMSettings dialog(this);
dialog.SetCount(teamCount, true);
for (int i = 0; i < teamCount; i++) {
wxString name = rows[i].nameDisplay->GetLabel();
dialog.SetName(i, name);
}
dialog.SetRandom(beepRandom);
dialog.SetBeepLimits(beepStart, beepEnd);
if (dialog.ShowModal() == wxID_OK) {
SetTeams(dialog.GetCount());
for (int i=0; i < teamCount; i++) {
wxString label = dialog.GetName(i);
SetTeam(i, label);
}
}
beepRandom = dialog.GetRandom();
dialog.GetBeepLimits(beepStart, beepEnd);
hookActive = 1;
}
void PMMainFrame::OnKey(wxKeyEvent & event) {
int code = event.GetKeyCode();
switch(code) {
case ((int)'g'):
EditSettings();
break;
default:
event.Skip(false);
break;
}
}
void PMMainFrame::StartGame() {
if (state == STATE_NOT_RUNNING) {
if (resetOnStart) {
for (int i = 0; i < teamCount; i++) {
SetTeamState(i, TEAM_WAITING);
}
}
for (int i = 0; i < teamCount; i++) {
if (rows[i].state == TEAM_DRAW) {
rows[i].state = TEAM_WAITING;
}
}
UpdateTeams();
int beep = beepStart;
if (beepRandom) {
int diff = beepEnd - beepStart;
double random = (double)rand() / RAND_MAX;
beep = beepStart + (int)(diff * random);
}
BeepThread * beepT = new BeepThread(BEEP_GAMESTART, beep, &state, this);
if (beepT->Create() == wxTHREAD_NO_ERROR) {
beepT->Run();
}
}
}
void PMMainFrame::PauseGame() {
TimerPause();
state = STATE_NOT_RUNNING;
}
void PMMainFrame::ResetGame() {
TimerStop();
ShowTime(START_TIME);
resetOnStart = true;
//komandu bukles i pradzia
for (int i = 0; i < teamCount; i++) {
rows[i].state = TEAM_WAITING;
}
UpdateTeams();
state = STATE_NOT_RUNNING;
}
void PMMainFrame::OnBeeper(wxEvent & event) {
TimerStart(resetOnStart);
resetOnStart = false;
}
void PMMainFrame::UpdateTeams() {
for (int i = 0; i < teamCount; i++) {
switch (rows[i].state) {
case TEAM_WAITING:
rows[i].panel->SetBackgroundColour(defaultBackground);
break;
case TEAM_ANSWERING:
rows[i].panel->SetBackgroundColour(wxColour(0, 0xaa, 0));
break;
case TEAM_BLOCKED:
rows[i].panel->SetBackgroundColour(wxColour(0xaa, 0, 0));
break;
case TEAM_DRAW:
rows[i].panel->SetBackgroundColour(wxColour(0xaa, 0xaa, 0));
break;
}
rows[i].pointsDisplay->SetLabel(wxString::Format(wxT("%d"), rows[i].score));
}
this->Refresh();
}
bool PMMainFrame::SetTeamState(int pos, int newState) {
if ((pos >= 0) && (pos < MAX_TEAMS)) {
if ((rows[pos].state == TEAM_WAITING) || (newState == TEAM_WAITING)) {
rows[pos].state = newState;
return true;
}
}
return false;
}
void PMMainFrame::SetScore(long ch) {
long code = ch - (long)'1';
int diff = 1;
if (code % 2) {
diff = -1;
}
int team = code / 2;
SetScore(team, diff);
UpdateTeams();
topSizer->Fit(this);
}
void PMMainFrame::SetScore(int team, int diff) {
if ((team >= 0) && (team < teamCount)) {
if (rows[team].score + diff >= 0) {
rows[team].score += diff;
}
}
}
| [
"domas.m@c4f24f84-7f43-11dd-ac5a-f353d88c4ef8"
]
| [
[
[
1,
630
]
]
]
|
f8ee5fc6975e5cdac5a7d76e373944395a4ca789 | b22c254d7670522ec2caa61c998f8741b1da9388 | /Tools/PhysExporter/PhysicHandler.h | 57a044ea4575bdede477093db7416486f7e75087 | []
| no_license | ldaehler/lbanet | 341ddc4b62ef2df0a167caff46c2075fdfc85f5c | ecb54fc6fd691f1be3bae03681e355a225f92418 | refs/heads/master | 2021-01-23T13:17:19.963262 | 2011-03-22T21:49:52 | 2011-03-22T21:49:52 | 39,529,945 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 12,223 | h | /*
------------------------[ Lbanet Source ]-------------------------
Copyright (C) 2009
Author: Vivien Delage [Rincevent_123]
Email : [email protected]
-------------------------------[ GNU License ]-------------------------------
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/>.
-----------------------------------------------------------------------------
*/
#ifndef __LBA_NET_PHYSIC_HANDLER_H__
#define __LBA_NET_PHYSIC_HANDLER_H__
#include <string>
#include <vector>
class LocalActorsHandler;
class ExternalActorsHandler;
struct StairInfo
{
int C1X;
int C1Y;
int C1Z;
int C2X;
int C2Y;
int C2Z;
int C3X;
int C3Y;
int C3Z;
int C4X;
int C4Y;
int C4Z;
int type;
int length;
short material;
};
struct CornerStairInfo
{
int C1X;
int C1Y;
int C1Z;
int C2X;
int C2Y;
int C2Z;
int C3X;
int C3Y;
int C3Z;
int type;
short material;
};
struct PlaneInfo
{
int StartX;
int StartY;
int StartZ;
int EndX;
int EndY;
int EndZ;
short material;
};
//struct TexNodeInfo
//{
// int Px;
// int Py;
// int TexCoor1x;
// int TexCoor1y;
//};
struct TexPlaneInfo
{
//std::vector<TexNodeInfo> texinfo;
int textureid;
int StartX;
int StartY;
int EndX;
int EndY;
};
class TextInfo
{
public:
//! constructor
TextInfo(){}
//! denstructor
virtual ~TextInfo(){}
virtual int GetTexture(int X, int Y) = 0;
};
class SingleTextInfo : public TextInfo
{
public:
//! constructor
SingleTextInfo(int TexId)
: _TexId(TexId){}
//! denstructor
virtual ~SingleTextInfo(){}
virtual int GetTexture(int X, int Y)
{ return _TexId;}
private:
int _TexId;
};
class DuoTextInfoX : public TextInfo
{
public:
//! constructor
DuoTextInfoX(int TexId, int TextId2)
: _TexId(TexId), _TextId2(TextId2){}
//! denstructor
virtual ~DuoTextInfoX(){}
virtual int GetTexture(int X, int Y)
{
if ( X & 1)
return _TextId2;
else
return _TexId;
}
private:
int _TexId;
int _TextId2;
};
class DuoTextInfoY : public TextInfo
{
public:
//! constructor
DuoTextInfoY(int TexId, int TextId2)
: _TexId(TexId), _TextId2(TextId2){}
//! denstructor
virtual ~DuoTextInfoY(){}
virtual int GetTexture(int X, int Y)
{
if ( Y & 1)
return _TextId2;
else
return _TexId;
}
private:
int _TexId;
int _TextId2;
};
class QuadraTextInfo : public TextInfo
{
public:
//! constructor
QuadraTextInfo(int TexId, int TextId2, int TexId3, int TextId4)
: _TexId(TexId), _TextId2(TextId2), _TexId3(TexId3), _TextId4(TextId4)
{}
//! denstructor
virtual ~QuadraTextInfo(){}
virtual int GetTexture(int X, int Y)
{
if ( X & 1)
{
if ( Y & 1)
return _TextId4;
else
return _TexId3;
}
else
{
if ( Y & 1)
return _TextId2;
else
return _TexId;
}
}
private:
int _TexId;
int _TextId2;
int _TexId3;
int _TextId4;
};
class LBA_MAP_GL;
//*************************************************************************************************
//* class PhysicHandler
//*************************************************************************************************
class PhysicHandler
{
public:
//! constructor
PhysicHandler(LocalActorsHandler * LAH, ExternalActorsHandler * EAH);
//! destructor
~PhysicHandler();
void SetMapGl(LBA_MAP_GL * mapgl)
{
_mapgl = mapgl;
}
// load a map into memory
void Allocate(int sizeX, int sizeY, int sizeZ);
// save the map physics to a file
void SaveMap(const std::string Filename);
// return pointer to the physic buffer in order to fill it
short * GetBufferPtr()
{ return _physicCube; }
short * GetMaterialBufferPtr()
{ return _materialCube; }
// check if it is possible to move from one position to a certain X and Z offset
// change the offset if the move is not possible
// the actor has a bounding box centered on currX, currZ
// and which goes up from currY
// actorSizeX and actorSizeZ are 1/2 the diameter from the center
void Move(float currX, float currY, float currZ,
float actorSizeX, float actorSizeY, float actorSizeZ,
float & MoveX, float &MoveZ, bool jump);
// used when flying to check if we can go down
void GoUpDown(float currX, float currY, float currZ, float & deltaY, float actorSizeY);
// get the correct Y associate with a position in space
// e.g. if the actor is currently in air - it should fall down
// if the actor is currently on stair - it should move up down
float GetNextY(float pX, float pY, float pZ,
float actorSizeX, float actorSizeY, float actorSizeZ);
// get the correct Y velocity associated with a position in space
// correct pY if necessary
//double GetYVelocity(double pX, double &pY, double pZ, double vX, double vZ,
// double actorSizeX, double actorSizeY, double actorSizeZ);
// return true if the position is on water - the actor should then drow
bool StepOnWater(int X, int Y, int Z);
// return int > 0 if there is a roof on top of the given position
// function used to know when to cut the room in half
int IsUnderRoof(int X, int Y, int Z);
// used for debugging to display where a character is on the map
void Display(int currX, int currY, int currZ);
// used for debugging to display where a character is on the map
std::string DisplayS(int currX, int currY, int currZ);
// return the structure of a specific brick
short GetStructure(int X, int Y, int Z);
// return the Y position of the floor
int GetFloorY(int X, int Y, int Z);
// clean the memory
void ClearMemory();
// return the sound of a specific brick
short GetSound(int X, int Y, int Z);
//! look for floors in the map
void SearchFloors();
//void SearchFloorsNormal(int sizeX, int sizeY, int sizeZ);
void SearchFloorsHidden(int sizeX, int sizeY, int sizeZ);
void SearchFloorsWithMaterial(int sizeX, int sizeY, int sizeZ, short Material);
void SearchWallX();
void SearchWallXNormal(int sizeX, int sizeY, int sizeZ);
void SearchWallXHidden(int sizeX, int sizeY, int sizeZ);
void SearchWallZ();
void SearchWallZNormal(int sizeX, int sizeY, int sizeZ);
void SearchWallZHidden(int sizeX, int sizeY, int sizeZ);
void SearchStairs();
void SearchCornerStairsWithMaterial(short * start, short * tomodify, int sizeX, int sizeY, int sizeZ,
std::vector<CornerStairInfo> & stairs, short Material);
void SearchStairsWithMaterial(short * start, int sizeX, int sizeY, int sizeZ,
std::vector<StairInfo> & stairs, short Material);
StairInfo FindStairUp(short * start, int idX, int idY, int idZ,
int sizeX, int sizeY, int sizeZ, bool overwrite);
std::vector<PlaneInfo> GetPlanes()
{ return _planes; }
std::vector<PlaneInfo> GetPlanesHidden()
{ return _planeshidden; }
std::vector<PlaneInfo> GetWallsX()
{ return _wallsX; }
std::vector<PlaneInfo> GetWallsXHidden()
{ return _wallsXhidden; }
std::vector<PlaneInfo> GetWallsZ()
{ return _wallsZ; }
std::vector<PlaneInfo> GetWallsZHidden()
{ return _wallsZhidden; }
std::vector<StairInfo> GetStairs()
{ return _stairs; }
std::vector<CornerStairInfo> GetCornerStairs()
{ return _cornerstairs; }
std::vector<PlaneInfo> GetRoofs()
{ return _planesRoof; }
//! split rectangle into part with same textures
void SplitToTexture(short * area, int sizeX, int sizeY, std::vector<TexPlaneInfo> & res);
void SavePlanes(const std::string & filename);
//! search roof in the scene
void SearchRoof();
void MakeSurroundingPlanes();
protected:
// allocate a memory buffer of given size
void AllocateMemory(int sizeX, int sizeY, int sizeZ);
// return true if the brick asked contain a solid
// structure - return false otherwise
bool IsSolid(int X, int Y, int Z);
// return true if the brick asked contain an empty
// structure - return false otherwise
bool IsEmpty(int X, int Y, int Z);
// return true if the actor is stepping on empty place
bool EmptyUnderActor(double X, double Y, double Z,
double actorSizeX, double actorSizeY, double actorSizeZ);
//! look for floors in the map
void SearchFloors(short * thisY, int Y, std::vector<PlaneInfo> &planes,
int sizeX, int sizeY, int sizeZ, short material, int minareasize = 0);
//! look for floors in the map
int SearchMaxFloor(short * center, int idxX, int idxZ,
int &startX, int &startZ,
int &endX, int &endZ, int sizeX, int sizeY, int sizeZ);
bool IsSolidHorLine(short * start, int size, int sizeX, int sizeY, int sizeZ);
bool IsSolidVerLine(short * start, int size, int sizeX, int sizeY, int sizeZ);
//! look for floors in the map
int SearchMaxTexture(short * center, int idxX, int idxY,
int &startX, int &startY,
int &endX, int &endY, int sizeX, int sizeY, TextInfo * txi);
bool IsTexHorLine(short * start, int size, int sizeX, int sizeY,
int idxX, int idxY, TextInfo * txi);
bool IsTexVerLine(short * start, int size, int sizeX, int sizeY,
int idxX, int idxY, TextInfo * txi);
void Search6CornerStairs(short * start, short * tomodify, int sizeX, int sizeY, int sizeZ,
int idX, int idY, int idZ,
std::vector<CornerStairInfo> & stairs, short Material);
void Search7CornerStairs(short * start, short * tomodify, int sizeX, int sizeY, int sizeZ,
int idX, int idY, int idZ,
std::vector<CornerStairInfo> & stairs, short Material);
void Search8CornerStairs(short * start, short * tomodify, int sizeX, int sizeY, int sizeZ,
int idX, int idY, int idZ,
std::vector<CornerStairInfo> & stairs, short Material);
void Search9CornerStairs(short * start, short * tomodify, int sizeX, int sizeY, int sizeZ,
int idX, int idY, int idZ,
std::vector<CornerStairInfo> & stairs, short Material);
void Search10CornerStairs(short * start, short * tomodify, int sizeX, int sizeY, int sizeZ,
int idX, int idY, int idZ,
std::vector<CornerStairInfo> & stairs, short Material);
void Search11CornerStairs(short * start, short * tomodify, int sizeX, int sizeY, int sizeZ,
int idX, int idY, int idZ,
std::vector<CornerStairInfo> & stairs, short Material);
void Search12CornerStairs(short * start, short * tomodify, int sizeX, int sizeY, int sizeZ,
int idX, int idY, int idZ,
std::vector<CornerStairInfo> & stairs, short Material);
void Search13CornerStairs(short * start, short * tomodify, int sizeX, int sizeY, int sizeZ,
int idX, int idY, int idZ,
std::vector<CornerStairInfo> & stairs, short Material);
short GetMaterial(int X, int Y, int Z);
private:
// cube representing the map physic
short * _physicCube;
short * _materialCube;
LocalActorsHandler* _localAH;
ExternalActorsHandler * _EAH;
LBA_MAP_GL * _mapgl;
// size of the cube
int _sizeX;
int _sizeY;
int _sizeZ;
std::vector<PlaneInfo> _planes;
std::vector<PlaneInfo> _planeshidden;
std::vector<PlaneInfo> _planesRoof;
std::vector<PlaneInfo> _wallsX;
std::vector<PlaneInfo> _wallsXhidden;
std::vector<PlaneInfo> _wallsZ;
std::vector<PlaneInfo> _wallsZhidden;
std::vector<StairInfo> _stairs;
std::vector<CornerStairInfo> _cornerstairs;
std::vector<CornerStairInfo> _wallsout;
};
#endif
| [
"vdelage@3806491c-8dad-11de-9a8c-6d5b7d1e4d13"
]
| [
[
[
1,
495
]
]
]
|
feef77b673a2f07c7b2f4f3f462cc508fc5926ee | 30898d899aa49d5801dab4f0df19fca18a2d4d02 | /yltk/yltkRealTimeClock.h | e20484827be0fb09d97ba9a13d530ae980a3f7b1 | []
| no_license | jackyko1991/vtkpythonext | c278987c7c61f7e610eec277ca3c9e42df097fa5 | 6d20ce2071581064616064a36243646a96e4c75e | refs/heads/master | 2021-01-10T19:32:45.869634 | 2011-03-20T03:15:55 | 2011-03-20T03:15:55 | 40,592,349 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,435 | h | #ifndef __yltkRealTimeClock_h
#define __yltkRealTimeClock_h
#include "yltkIndent.h"
namespace yltk
{
/** \class RealTimeClock
* \brief The RealTimeClock provides a timestamp from a real-time clock
*
* This class represents a real-time clock object
* and provides a timestamp in platform-independent format.
*
* \author Hee-Su Kim, Compute Science Dept. Kyungpook National University,
Copyright (c) ISC Insight Software Consortium. All rights reserved.
*/
class RealTimeClock
{
public:
/** Define the type for the timestamp */
typedef double TimeStampType;
/** Returns a timestamp in milliseconds e.g. 52.341243 milliseconds */
static TimeStampType GetTimeStamp();
/** Initialize internal variables on the Clock service.
* This method must be called at the begining of every
* YLTK application. */
static void Initialize();
/** Print the object */
static void Print(std::ostream& os, yltk::Indent indent=0);
/** Define the type for the frequency of the clock */
typedef double FrequencyType;
protected:
/** constructor */
RealTimeClock();
/** destructor */
virtual ~RealTimeClock();
static void PrintSelf( std::ostream& os, yltk::Indent indent );
private:
static FrequencyType m_Frequency;
static TimeStampType m_Difference;
static TimeStampType m_Origin;
};
}
#endif | [
"summit.chocice@6ba1a03e-a7e1-11de-9ca8-173d21a9ba08"
]
| [
[
[
1,
61
]
]
]
|
72eac156d1c5be46ce6ccc654434398042f8a536 | 619941b532c6d2987c0f4e92b73549c6c945c7e5 | /Source/Nuclex/GUI/SliderWidget.cpp | 57460d4ce89cdbacd08e7e38527dec5ab6391fa4 | []
| 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,509 | cpp | // //
// # # ### # # -= Nuclex Library =- //
// ## # # # ## ## SliderWidget.cpp - Slider GUI component //
// ### # # ### //
// # ### # ### Slider which can be moved within a limited range //
// # ## # # ## ## //
// # # ### # # R1 (C)2002-2004 Markus Ewald -> License.txt //
// //
#include "Nuclex/GUI/SliderWidget.h"
#include "Nuclex/Video/VertexDrawer.h"
#include "Nuclex/Input/KeyboardInputDevice.h"
//#include "DirectX/DInput.h" //!!Temporary
#include "Nuclex/Kernel.h"
using namespace Nuclex;
using namespace Nuclex::GUI;
SliderWidget::Painter SliderWidget::DefaultPainter;
namespace {
float clamp(float f) {
return min(max(f, 0.0f), 1.0f);
}
}
// ############################################################################################# //
// # Nuclex::GUI::SliderWidget::SliderWidget() Constructor # //
// ############################################################################################# //
/** Initializes a new slider widget
@param Region Region in which to place the slider
@param fPosition Initial position of the slider, from 0.0 to 1.0
@param fSize The slider element's size
@param Steps Number of steps from the left side to the right side.
A number of 0 will disable stepping.
@param sStyle The slider's visual style
@param Painter Delegate used for drawing the slider.
*/
SliderWidget::SliderWidget(const Box2<real> &Region,
float fPosition, float fSize, size_t Steps,
Orientation eOrientation, const string sStyle,
Painter &ThePainter) :
Widget(Region, sStyle),
m_eOrientation(eOrientation),
m_bEnabled(true),
m_Painter(ThePainter),
m_bDragging(false),
m_bHover(false),
m_fPosition(fPosition),
m_fWidth(fSize),
m_Steps(Steps) {
// Make sure the user provided position is valid when using steps
snapToStep();
}
// ############################################################################################# //
// # Nuclex::GUI::SliderWidget::clone() # //
// ############################################################################################# //
/** Creates a clone of the slider
@return The cloned slider
*/
shared_ptr<Widget> SliderWidget::clone() const {
return shared_ptr<SliderWidget>(new SliderWidget(*this));
}
// ############################################################################################# //
// # Nuclex::GUI::SliderWidget::setEnabled() # //
// ############################################################################################# //
/** Enables or disables the slider
@param bEnabled Whether the slider should be enabled or disabled
*/
void SliderWidget::setEnabled(bool bEnabled) {
m_bEnabled = bEnabled;
if(!bEnabled)
m_bDragging = false;
}
// ############################################################################################# //
// # Nuclex::GUI::SliderWidget::processUserInput() # //
// ############################################################################################# //
/** Processes an input event which has been sent to the button
@param InputEvent The input event's data
*/
bool SliderWidget::processInput(const InputReceiver::Event &InputEvent) {
switch(InputEvent.eType) {
// Update the slider when the mouse is moved
case InputReceiver::Event::T_MOUSEMOVE: {
m_bHover = getSliderRegion().intersects(Point2<float>(InputEvent.Location, StaticCastTag()));
// Is the slider element being dragged ?
if(m_bDragging) {
float fOldPosition = m_fPosition;
// Adjust the slider elements position
Point2<float> Location = Point2<float>(InputEvent.Location, StaticCastTag()) - m_DragPoint;
if(m_eOrientation == O_HORIZONTAL)
m_fPosition = clamp((Location.X - m_Region.TL.X) / (m_Region.getWidth() - getSliderWidth()));
else
m_fPosition = clamp((Location.Y - m_Region.TL.Y) / (m_Region.getHeight() - getSliderWidth()));
snapToStep();
// Fire an event if the position has been changed
if(m_fPosition != fOldPosition)
OnSlide(m_fPosition);
}
break;
}
// Mouse button pressed within slider region
case InputReceiver::Event::T_MOUSEBUTTONDOWN: {
// Calculate slider region
Box2<float> SliderRegion(getSliderRegion());
// Left mouse ? Move or drag slider.
if(InputEvent.nButton == 0) {
long nMovement;
if(m_eOrientation == O_HORIZONTAL)
nMovement = (InputEvent.Location.X < SliderRegion.TL.X) ?
-1 : ((InputEvent.Location.X >= SliderRegion.BR.X) ? +1 : 0);
else
nMovement = (InputEvent.Location.Y < SliderRegion.TL.Y) ?
-1 : ((InputEvent.Location.Y >= SliderRegion.BR.Y) ? +1 : 0);
// Move (if clicked beside the slider element) or begin dragging
if(nMovement) {
move(nMovement);
} else {
m_DragPoint = Point2<float>(InputEvent.Location, StaticCastTag());
if(m_eOrientation == O_HORIZONTAL)
m_DragPoint.X -= m_Region.TL.X + (m_Region.getWidth() - getSliderWidth()) * m_fPosition;
else
m_DragPoint.Y -= m_Region.TL.Y + (m_Region.getHeight() - getSliderWidth()) * m_fPosition;
m_bDragging = true;
}
}
m_bHover = getSliderRegion().intersects(Point2<float>(InputEvent.Location, StaticCastTag()));
break;
}
// Mouse button released, stop dragging
case InputReceiver::Event::T_MOUSEBUTTONUP: {
m_bHover = getSliderRegion().intersects(Point2<float>(InputEvent.Location, StaticCastTag()));
if(m_bDragging && (InputEvent.nButton == 0))
m_bDragging = false;
break;
}
// Key pressed while slider widget was focused
case InputReceiver::Event::T_KEYDOWN: {
long nMovement;
if((InputEvent.cKey == Input::KeyboardInputDevice::getScancode("Left")) ||
(InputEvent.cKey == Input::KeyboardInputDevice::getScancode("Up")))
nMovement = -1;
else if((InputEvent.cKey == Input::KeyboardInputDevice::getScancode("Right")) ||
(InputEvent.cKey == Input::KeyboardInputDevice::getScancode("Down")))
nMovement = +1;
else
nMovement = 0;
move(nMovement);
break;
}
}
return true;
}
// ############################################################################################# //
// # Nuclex::GUI::SliderWidget::getSliderRegion() # //
// ############################################################################################# //
Box2<float> SliderWidget::getSliderRegion() const {
float fSliderWidth = getSliderWidth();
float fScrollWidth = (m_eOrientation == O_HORIZONTAL) ?
(m_Region.BR.X - m_Region.TL.X) - fSliderWidth:
(m_Region.BR.Y - m_Region.TL.Y) - fSliderWidth;
if(m_eOrientation == O_HORIZONTAL)
return Box2<float>(
static_cast<float>(round<size_t>(m_Region.TL.X + fScrollWidth * m_fPosition)),
m_Region.TL.Y,
static_cast<float>(round<size_t>(m_Region.TL.X + fScrollWidth * m_fPosition + fSliderWidth)),
m_Region.BR.Y
);
else
return Box2<float>(
m_Region.TL.X,
static_cast<float>(round<size_t>(m_Region.TL.Y + fScrollWidth * m_fPosition)),
m_Region.BR.X,
static_cast<float>(round<size_t>(m_Region.TL.Y + fScrollWidth * m_fPosition + fSliderWidth))
);
}
// ############################################################################################# //
// # Nuclex::GUI::SliderWidget::snapToStep() # //
// ############################################################################################# //
void SliderWidget::snapToStep() {
if(m_Steps > 0) {
float fPosition = 0;
float fMinDistance = 1.0f;
for(size_t Step = 0; Step < m_Steps; ++Step) {
float fDistance = fabs((static_cast<float>(Step) / (m_Steps - 1)) - m_fPosition);
if(fDistance < fMinDistance) {
fPosition = static_cast<float>(Step) / (m_Steps - 1);
fMinDistance = fDistance;
}
}
m_fPosition = fPosition;
}
}
void SliderWidget::move(long nClicks) {
float fOldPosition = m_fPosition;
if(m_Steps > 0)
m_fPosition += static_cast<float>(nClicks) / (m_Steps - 1);
else
m_fPosition += m_fWidth * static_cast<float>(nClicks) / 2;
if(m_fPosition != fOldPosition)
OnSlide(m_fPosition);
} | [
"[email protected]"
]
| [
[
[
1,
241
]
]
]
|
78634daa9431d8b1836c2e841d0742cca05c4479 | b2d46af9c6152323ce240374afc998c1574db71f | /cursovideojuegos/theflostiproject/Code/Flosti Engine/Base/Math/Matrix44.h | 8dceedd4673864d1b02d31794b4fb76643a8cd25 | []
| no_license | bugbit/cipsaoscar | 601b4da0f0a647e71717ed35ee5c2f2d63c8a0f4 | 52aa8b4b67d48f59e46cb43527480f8b3552e96d | refs/heads/master | 2021-01-10T21:31:18.653163 | 2011-09-28T16:39:12 | 2011-09-28T16:39:12 | 33,032,640 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 20,277 | h | //-----------------------------------------------------------------------
// Matrix44 class
// This class defines a matrix 4x4
//-----------------------------------------------------------------------
#ifndef __MATRIX_44_H__
#define __MATRIX_44_H__
#include "Base.h"
#include "MathTypes.h"
#include "MathUtils.h"
#include "Vector3.h"
#include "Vector4.h"
#include "Matrix33.h"
#include "Utils/Types.h"
#include <memory>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Matriz de 4 filas x 4 columnas
/// @Note1
/// \verbatim
/// Cuando la matriz describe una transformación típica, compuesta de
/// rotación + traslación, se almacena con la estructura:
/// \endverbatim
/// \code
/// | | P | | r00 r01 r02 | P_x | | m00 m01 m02 | m03 |
/// | Rotacion 3x3 | o | | r10 r11 r12 | P_y | | m10 m11 m12 | m13 |
/// | | s | ----> | r20 r21 r22 | p_z | ---> | m20 m21 m22 | m23 |
/// |--------------|---| |-------------|-----| |-------------|-----|
/// | 0 0 0 | 1 | | 0 0 0 | 1 | | m30 m31 m32 | m33 |
///
/// | x1 x2 x3 | Px |
/// | y1 y2 y3 | Py |
/// | z1 z2 z3 | Pz |
/// |----------|----|
/// | 0 0 0 | 1 |
/// | | | |
/// | | | `------> Posición del origen del sistema de referencia en coordenadas del padre
/// | | `-----------> eje Z del sistema de referencia en coordenadas del padre
/// | `--------------> eje Y del sistema de referencia en coordenadas del padre
/// `-----------------> eje x del sistema de referencia en coordenadas del padre
/// \endcode
/// \verbatim
/// En memoria los datos están contiguos por columnas:
/// / m00 m10 m20 m30 / m01 m11 m21 m31 / m02 m12 m22 m32 / m03 m13 m23 m33 /
///
/// Esto facilita el acceso a los datos de los ejes y a la posición del sistema de referencia
/// en coordenadas del padre (que suelen ser importantes, ej. vectores de cámara)
///
///
/// Los vectores aislados se consideran 'VECTORES-COLUMNA' y el objeto 'Vector' incluye
/// la funcionalidad de un punto.
///
///
/// | x | | x |
/// | y | como vector | y | como punto
/// | z | | z |
/// | 1 |
///
/// Esto implica que las multiplicaciones matriz-vector se efectúan siempre en el orden
/// MATRIZ x VECTOR (dada una matriz 4x4 y un vector 4x1 --> obtenemos un vector 4x1, el caso
/// contrario, vector 4x1 por matriz 4x4, produce una matriz 4x4)
/// \endverbatim
/// @Note2 Producto Matriz x vector:
/// \verbatim
/// Hay dos tipos de producto de matriz x vector (formalmente productos de matrices), identificados
/// por el operador '*' y el operador '^'
///
/// ( * ) --> Producto Matriz x punto (transformación de ROTACION + TRASLACION)
/// Los vectores incluyen la funcionalidad del punto, por lo tanto,
/// se pueden multiplicar por una matriz de 4x4, considerándolos matrices
/// de 4x1
///
/// | m00 m01 m02 m03 | | x | | x*m00 + y*m01 + z*m02 + m03 |
/// | m10 m11 m12 m13 | * | y | = | x*m10 + y*m11 + z*m12 + m13 |
/// | m20 m21 m22 m23 | | z | | x*m20 + y*m21 + z*m22 + m23 |
/// | m30 m31 m32 m33 | | 1 | | x*m30 + y*m31 + z*m32 + m33 |
///
/// ( ^ ) --> Producto Matriz x vector (transformación de ROTACION)
/// En este caso solo se multiplica el menor 3x3, que incluye la rotación,
/// por el vector-columna 3x1, sin añadir el termino 'w = 1'
///
/// | m00 m01 m02 | | x | | x*m00 + y*m01 + z*m02 |
/// | m10 m11 m12 | ^ | y | = | x*m10 + y*m11 + z*m12 |
/// | m20 m21 m22 | | z | | x*m20 + y*m21 + z*m22 |
/// \endverbatim
/// @Note3 Producto de matrices
/// \verbatim
/// Dos matrices M1 y M2 se multiplican de tal forma que el resultado es una matriz con las
/// filas de la primera y las columnas de la segunda.
///
/// | m00 m01 m02 m03 | | n00 n01 n02 n03 | | m00*n00 + m01*n10 + m02*n20 + m03*n30 ... |
/// | m10 m11 m12 m13 | * | n10 n11 n12 n13 | = | ... |
/// | m20 m21 m22 m23 | | n20 n21 n22 n23 | | ... |
/// | m30 m31 m32 m33 | | n30 n31 n32 n33 | | ... |
///
/// Si consideramos las matrices como transformaciones entre espacios, los productos se
/// concatenan partiendo de la matriz construida a partir del sistema de referencia del
/// mundo hasta llegar a la matriz local de un objeto y a los puntos de los que se compone.
///
/// Si tenemos los sistemas de referencia local -> hijo -> padre -> mundo, para obtener un
/// punto en coordenadas de mundo, a partir de un punto en coordenadas locales, haremos:
///
/// P(en mundo) = M(padre->mundo) * M(hijo->padre) * M(local->hijo) * P(en locales)
///
/// Si concatenamos una rotación y una traslación:
/// M(rotacion) * M(traslación) * P --> el punto se traslada en locales a la posición de traslación y
/// luego rota respecto al origen del sistema local (o sea, pasa
/// a coordenadas de padre habiendo modificado su posición en locales)
/// NOTA: típico efecto de rotar alrededor del mundo, cuando se quiere
/// rotar en local y equivocamos el orden de multiplicación de matrices)
///
/// M(traslación) * M(rotación) * P --> El punto rota en su sistema de referencia y luego es trasladado
/// (en el sistema de referencia del padre). Esta concatenación es la que
/// sirve para construir una matriz de sistema de referencia:
///
/// | ux1 ux2 ux3 Px |
/// | uy1 uy2 uy3 Py |
/// | uz1 uz2 uz3 Pz |
/// | 0 0 0 1 |
///
///
/// Si concatenamos una TRASLACION + ROTACION + ESCALADO:
/// M(traslación) * M(rotación) * M(escalado) P --> El punto (u objeto compuesto de puntos) es escalado, rota en locales,
/// y luego es trasladado en el sistema del padre.
/// Esta concatenación es la que sirve para construir una matriz de
/// sistema de referencia con escalado:
///
/// | ux1*ex x2*ey x3*ez Px |
/// | uy1*ex y2*ey y3*ez Py |
/// | uz1*ex z2*ey z3*ez Pz |
/// | 0 0 0 1 |
/// | | | |
/// | | | `-------> Posición del origen del sistema de referencia en coordenadas del padre
/// | | `-----------> eje Z, ESCALADO, del sistema de referencia en coordenadas del padre
/// | `-----------------> eje Y, ESCALADO, del sistema de referencia en coordenadas del padre
/// `-----------------------> eje X, ESCALADO, del sistema de referencia en coordenadas del padre
///
///
/// Si se multiplica el escalado por la izquierda:
/// M(escalado) * M(traslación) * M(rotación) --> La posición del sistema de referencia se verá afectada, esto es,
/// escalada (en coordenadas del padre) igual que las posiciones de
/// los puntos en local.
/// \endverbatim
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<typename T>
class Matrix44
{
public:
//-----------------
// DATOS PUBLICOS
//-----------------
#ifdef ROW_MAJOR_MATRICES
T m00, m01, m02, m03; // Primera 'fila'
T m10, m11, m12, m13; // Segunda 'fila'
T m20, m21, m22, m23; // Tercera 'fila'
T m30, m31, m32, m33; // Cuarta 'fila'
#else
T m00, m10, m20, m30; // Primera 'columna'
T m01, m11, m21, m31; // Segunda 'columna'
T m02, m12, m22, m32; // Tercera 'columna'
T m03, m13, m23, m33; // Cuarta 'columna'
#endif
public:
//-------------------
// METODOS PUBLICOS
//-------------------
// Construcción
inline Matrix44 ();
inline Matrix44 (const Matrix44<T>& otra);
inline Matrix44 (const Matrix33<T>& otra);
inline Matrix44 (const Matrix34<T>& otra);
inline Matrix44 (const T _m00, const T _m01, const T _m02, const T _m03,
const T _m10, const T _m11, const T _m12, const T _m13,
const T _m20, const T _m21, const T _m22, const T _m23,
const T _m30, const T _m31, const T _m32, const T _m33);
inline Matrix44 (const Vector3<T>& ejeX,
const Vector3<T>& ejeY,
const Vector3<T>& ejeZ,
const Vector3<T>& pos);
inline Matrix44 (const T angleY, const T angleX, const T angleZ);
// Reseteos parciales (traslación/rotación/escalado) y totales (a identidad, a cero)
inline Matrix44<T>& ResetTranslation ();
inline Matrix44<T>& ResetRotation ();
inline Matrix44<T>& ResetScale ();
inline Matrix44<T>& ResetRotationScale ();
inline Matrix44<T>& SetIdentity ();
inline Matrix44<T>& SetZero ();
// Establecimiento de datos de la matriz con reseteo previo a identidad
inline Matrix44<T>& SetFromBasis (const Vector3<T>& vBasisX,
const Vector3<T>& vBasisY,
const Vector3<T>& vBasisZ,
const Vector3<T>& Pos);
inline Matrix44<T>& SetFromBasis (const Vector3<T>& vBasisX,
const Vector3<T>& vBasisY,
const Vector3<T>& vBasisZ);
inline Matrix44<T>& SetFromAngleX (const T angleX);
inline Matrix44<T>& SetFromAngleY (const T angleY);
inline Matrix44<T>& SetFromAngleZ (const T angleZ);
inline Matrix44<T>& SetFromAnglesXZ (const T angleX, const T angleZ);
inline Matrix44<T>& SetFromAnglesYXZ (const T angleY, const T angleX, const T angleZ);
inline Matrix44<T>& SetFromPos (const T posX, const T posY, const T posZ);
inline Matrix44<T>& SetFromPos (const Vector3<T>& pos);
inline Matrix44<T>& SetFromScale (const T escala_x, const T escala_y, const T escala_z);
inline Matrix44<T>& SetFromLookAt (const Vector3<T>& vPos, const Vector3<T>& vTarget, const Vector3<T>& vUp);
inline Matrix44<T>& SetFromLookAt (const Vector3<T>& vPos, const Vector3<T>& vTarget);
//inline Matrix44<T>& SetFromQuatPos (const Quatn<T>& quat, const Vector3<T>& vPos);
// Modificación de una de las partes de la matriz dejando invariable las otras
inline Matrix44<T>& SetRotByAngleX (const T angleX);
inline Matrix44<T>& SetRotByAngleY (const T angleY);
inline Matrix44<T>& SetRotByAngleZ (const T angleZ);
inline Matrix44<T>& SetRotByAnglesXZ (const T angleX, const T angleZ);
inline Matrix44<T>& SetRotByAnglesYXZ (const T angleY, const T angleX, const T angleZ);
//inline Matrix44<T>& SetRotByQuat (const Quatn<T>& quat);
inline Matrix44<T>& SetPos (const Vector3<T>& pos);
inline Matrix44<T>& SetPos (const T posX, const T posY, const T posZ);
inline Matrix44<T>& SetScale (const Matrix33<T>& mat_escala);
inline Matrix44<T>& SetScale (const Matrix44<T>& mat_escala);
inline Matrix44<T>& SetScale (const Vector3<T>& vect_escala);
inline Matrix44<T>& SetScale (const T escala_x, const T escala_y, const T escala_z);
inline Matrix44<T>& SetSubMatrix33 (const Matrix33<T>& mat_sub);
inline Matrix44<T>& SetSubMatrix34 (const Matrix34<T>& mat_sub);
// Acceso
inline Vector4<T> GetRow (int i) const;
inline Vector4<T> GetColum (int i) const;
inline Vector3<T> GetVectorBasis (int i) const;
inline T GetVectorBasisLength (int i) const;
inline Vector3<T> GetPosBasis () const;
inline void GetBasis (Vector3<T>& vBasisX,
Vector3<T>& vBasisY,
Vector3<T>& vBasisZ,
Vector3<T>& Pos) const;
inline Matrix33<T> GetSubMatrix33 () const;
inline void GetSubMatrix33 (Matrix33<T>& subMat) const;
inline Matrix34<T> GetSubMatrix34 () const;
inline void GetSubMatrix34 (Matrix34<T>& subMat) const;
inline Matrix33<T> Get33RotationNormalized () const;
inline Matrix33<T> Get33RotationScaled () const;
inline Matrix33<T> Get33Scale () const;
inline Vector3<T> GetTranslationVector () const;
inline Matrix44<T> Get44RotationNormalized () const;
inline Matrix44<T> Get44RotationScaled () const;
inline Matrix44<T> Get44Scale () const;
inline Matrix44<T> Get44Translation () const;
inline Vector3<T> GetPos () const;
inline Vector3<T> GetScale () const;
inline T GetScaleX () const;
inline T GetScaleY () const;
inline T GetScaleZ () const;
// Angulos de Euler
inline void GetAnglesYXZ (T& angleY, T& angleX, T& angleZ) const;
inline T GetAngleX () const;
inline T GetAngleY () const;
inline T GetAngleZ () const;
// Angulos de Euler con criterio de Pitch-Roll-Yaw
// (Orden XZY, teniendo los ángulos Y,Z el sentido contrario de rotación)
inline T GetRoll () const;
inline T GetPitch () const;
inline T GetYaw () const;
inline Vector3<T> GetPitchRollYaw () const;
Matrix44<T>& SetFromPitchRollYaw (const Vector3<T>& v3PitchRollYaw);
inline Matrix44<T>& SetPitchRollYaw (const Vector3<T>& v3PitchRollYaw);
// Operadores de aritmética de matrices
Matrix44<T> operator + (const Matrix44<T>& otra) const;
Matrix44<T> operator - (const Matrix44<T>& otra) const;
Matrix44<T> operator * (const Matrix44<T>& otra) const;
Matrix44<T> operator * (const T escalar) const;
friend Matrix44<T> operator * (const T escalar, const Matrix44<T>& mat);
Matrix44<T> operator / (const T escalar) const;
Vector3<T> operator * (const Vector3<T>& vector) const;
Vector3<T> operator ^ (const Vector3<T>& vector) const;
Vector4<T> operator * (const Vector4<T>& vector) const;
// Operadores aritméticos de actualización
Matrix44<T>& operator += (const Matrix44<T>& otra);
Matrix44<T>& operator -= (const Matrix44<T>& otra);
Matrix44<T>& operator *= (const Matrix44<T>& otra);
Matrix44<T>& operator *= (const T escalar);
Matrix44<T>& operator /= (const T escalar);
// Operadores de comparación
inline bool operator == (const Matrix44<T>& otra) const;
inline bool operator != (const Matrix44<T>& otra) const;
inline bool IsEqualEpsilon (const Matrix44<T>& otra, const T Epsilo = Epsilon<T>()) const;//TODO CW quito la n para que no sea igual
inline bool IsNotEqualEpsilon (const Matrix44<T>& otra, const T Epsilo = Epsilon<T>()) const;//TODO CW quito la n para que no sea igual
// Funciones de transformación de vectores / puntos
inline void TransformVector (Vector3<T>& vector) const;
inline void TransformPoint (Vector3<T>& vector) const;
inline Vector3<T> GetTransformVector (const Vector3<T>& vector) const;
inline Vector3<T> GetTransformPoint (const Vector3<T>& vector) const;
void TransformArrayVectors (int iElements, Vector3<T>* pVecOUT, Vector3<T>* pVecIN) const;
void TransformArrayPoints (int iElements, Vector3<T>* pVecOUT, Vector3<T>* pVecIN) const;
// Operaciones especiales con matrices
// [const]
Matrix44<T> GetInverted () const;
Matrix44<T> GetInvertedTRS () const;
Matrix44<T> GetInvertedTR () const;
Matrix44<T> GetTransposed () const;
Matrix44<T> GetRotedByAngleX (const T angleX) const;
Matrix44<T> GetRotedByAngleY (const T angleY) const;
Matrix44<T> GetRotedByAngleZ (const T angleZ) const;
Matrix44<T> GetRotedByAnglesXZ (const T angleX, const T angleZ) const;
Matrix44<T> GetRotedByAnglesYXZ (const T angleY, const T angleX, const T angleZ) const;
Matrix44<T> GetTranslated (const Vector3<T>& pos) const;
Matrix44<T> GetScaled (const T escala_x, const T escala_y, const T escala_z) const;
// [no const]
Matrix44<T>& Invert ();
Matrix44<T>& InvertTRS ();
Matrix44<T>& InvertTR ();
Matrix44<T>& Transpose ();
Matrix44<T>& RotByAngleX (const T angleX);
Matrix44<T>& RotByAngleY (const T angleY);
Matrix44<T>& RotByAngleZ (const T angleZ);
Matrix44<T>& RotByAnglesXZ (const T angleX, const T angleZ);
Matrix44<T>& RotByAnglesYXZ (const T angleY, const T angleX, const T angleZ);
Matrix44<T>& Translate (const Vector3<T>& pos);
Matrix44<T>& Scale (const T escala_x, const T escala_y, const T escala_z);
// (*)
Matrix44<T>& AlignYX (const Vector3<T>& vY, const Vector3<T>& vX);
Matrix44<T>& AlignYZ (const Vector3<T>& vY, const Vector3<T>& vZ);
Matrix44<T>& AlignXZ (const Vector3<T>& vX, const Vector3<T>& vZ);
// Acceso/determinación a/de propiedades matriciales
inline T Determinant () const;
bool IsOrthogonalEpsilon () const;
bool IsOrthonormalEpsilon () const;
private:
//inline Vector3<T>& VectorBasis (int i);
//inline Vector3<T>& PosBasis ();
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Fichero con las definiciones de las funciones inline
#include "Matrix44.inl"
////////////////////////////////////////////////////////////////////////////////////////
/// TIPOS DE MATRICES [4x4] CON TIPOS CONCRETOS DE DATOS
////////////////////////////////////////////////////////////////////////////////////////
typedef Matrix44<float> Mat44f;
typedef Matrix44<double> Mat44d;
////////////////////////////////////////////////////////////////////////////////////////
// CONSTANTES FLOAT
////////////////////////////////////////////////////////////////////////////////////////
extern const Mat44f m44fIDENTITY;
extern const Mat44f m44fZERO;
extern const Mat44f m44fONES;
////////////////////////////////////////////////////////////////////////////////////////
// CONSTANTES DOUBLE
////////////////////////////////////////////////////////////////////////////////////////
extern const Mat44d m44dIDENTITY;
extern const Mat44d m44dZERO;
extern const Mat44d m44dONES;
//////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif
| [
"ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a"
]
| [
[
[
1,
389
]
]
]
|
fbe360dc0a6f60ddda8f63629f9f34f6b01718f6 | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/Dependencies/Xerces/include/xercesc/framework/psvi/XSTypeDefinition.cpp | 28ce6be7bce6ede80bff05f5fc1c0f2bb69c943a | []
| 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 | 2,280 | cpp | /*
* Copyright 2003,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XSTypeDefinition.cpp 191054 2005-06-17 02:56:35Z jberry $
*/
#include <xercesc/framework/psvi/XSTypeDefinition.hpp>
#include <xercesc/framework/psvi/XSModel.hpp>
#include <xercesc/util/XMLString.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// XSTypeDefinition: Constructors and Destructor
// ---------------------------------------------------------------------------
XSTypeDefinition::XSTypeDefinition(TYPE_CATEGORY typeCategory,
XSTypeDefinition* const xsBaseType,
XSModel* const xsModel,
MemoryManager* const manager)
: XSObject(XSConstants::TYPE_DEFINITION, xsModel, manager)
, fTypeCategory(typeCategory)
, fFinal(0)
, fBaseType(xsBaseType)
{
}
XSTypeDefinition::~XSTypeDefinition()
{
}
// ---------------------------------------------------------------------------
// XSTypeDefinition: access methods
// ---------------------------------------------------------------------------
bool XSTypeDefinition::isFinal(short toTest)
{
if (fFinal & toTest)
return true;
return false;
}
bool XSTypeDefinition::derivedFrom(const XMLCh *typeNamespace,
const XMLCh *name)
{
if (!name)
return false;
XSTypeDefinition* type = fXSModel->getTypeDefinition(name, typeNamespace);
if (!type)
return false;
return derivedFromType(type);
}
XERCES_CPP_NAMESPACE_END
| [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
]
| [
[
[
1,
73
]
]
]
|
1c73c98a9fe180b7d6876e210bf2870e6a94b629 | 3daaefb69e57941b3dee2a616f62121a3939455a | /mgllib-test/mgl_test/AFチュートリアルB/tutorial_3A.cpp | 8932d8ff8220dda0a06379df61fa39c5f19b551a | []
| 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 | 614 | cpp | #include "stdafx.h"
// メインフレームクラス
class CMglTestFrame : public CMglguiWindow
{
public:
// 初期化時に呼ばれる
void OnInit(){
RegistKbHandler(
MGL_KB_EVT_HANDLER_EVTTYPE_ON_PRESS,
DIK_A,
(MGL_KB_EVT_HANDLER_CALLBACK)OnKbA);
}
bool OnKbA(){
::MessageBox(NULL,"test","test",NULL);
return true;
}
};
CMglTestFrame g_frame;
// WinMain
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
{
g_frame.Start();
return 0;
}
| [
"myun2@6d62ff88-fa28-0410-b5a4-834eb811a934"
]
| [
[
[
1,
29
]
]
]
|
812a319013efca7f35b1aac0eabd44b27b4afdba | 0b66a94448cb545504692eafa3a32f435cdf92fa | /tags/0.3/cbear.berlios.de/range/begin.hpp | d9c968076c37629143dc66fe69969cb3d196a8c1 | [
"MIT"
]
| permissive | BackupTheBerlios/cbear-svn | e6629dfa5175776fbc41510e2f46ff4ff4280f08 | 0109296039b505d71dc215a0b256f73b1a60b3af | refs/heads/master | 2021-03-12T22:51:43.491728 | 2007-09-28T01:13:48 | 2007-09-28T01:13:48 | 40,608,034 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,634 | hpp | /*
The MIT License
Copyright (c) 2005 C Bear (http://cbear.berlios.de)
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 CBEAR_BERLIOS_DE_RANGE_BEGIN_HPP_INCLUDED
#define CBEAR_BERLIOS_DE_RANGE_BEGIN_HPP_INCLUDED
#include <cbear.berlios.de/range/iterator.hpp>
namespace cbear_berlios_de
{
namespace range
{
template<class Container>
typename iterator<Container>::type begin(Container &X)
{
return traits<Container>::begin(X);
}
template<class Container>
typename iterator<const Container>::type begin(const Container &X)
{
return traits<const Container>::begin(X);
}
}
}
#endif
| [
"sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838"
]
| [
[
[
1,
48
]
]
]
|
89c3645e495b8a8e3782edde2cf34dda2a5c6c31 | b5ad65ebe6a1148716115e1faab31b5f0de1b493 | /src/ModelEditor/ModelEditor.cpp | 52e8110d86649bfafed66c2ec9cf31c844e5973e | []
| no_license | gasbank/aran | 4360e3536185dcc0b364d8de84b34ae3a5f0855c | 01908cd36612379ade220cc09783bc7366c80961 | refs/heads/master | 2021-05-01T01:16:19.815088 | 2011-03-01T05:21:38 | 2011-03-01T05:21:38 | 1,051,010 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,187 | cpp | // ModelEditor.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "ModelEditor.h"
#include "MainFrm.h"
#include "ModelEditorDoc.h"
#include "ModelEditorView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CModelEditorApp
BEGIN_MESSAGE_MAP(CModelEditorApp, CWinApp)
ON_COMMAND(ID_APP_ABOUT, &CModelEditorApp::OnAppAbout)
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
// CModelEditorApp construction
CModelEditorApp::CModelEditorApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CModelEditorApp object
CModelEditorApp theApp;
// CModelEditorApp initialization
BOOL CModelEditorApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CModelEditorDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CArnView) /*RUNTIME_CLASS(CModelEditorView)*/
);
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line. Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
// call DragAcceptFiles only if there's a suffix
// In an SDI app, this should occur after ProcessShellCommand
return TRUE;
}
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// App command to run the dialog
void CModelEditorApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
// CModelEditorApp message handlers
//CDocument* CModelEditorApp::OpenDocumentFile(LPCTSTR lpszFileName)
//{
// // TODO: Add your specialized code here and/or call the base class
//
// //AfxMessageBox(_T("File Opened"));
//
// return CWinApp::OpenDocumentFile(lpszFileName);
//}
| [
"[email protected]"
]
| [
[
[
1,
157
]
]
]
|
b211ed9eb54ec209ec6fce1a321049e633b6e8ae | 1d415fdfabd9db522a4c3bca4ba66877ec5b8ef4 | /avstream/ttvideoheaderlist.cpp | 1d60c25c02fe0f1db203e8f8619fbf9b95adac64 | []
| no_license | panjinan333/ttcut | 61b160c0c38c2ea6c8785ba258c2fa4b6d18ae1a | fc13ec3289ae4dbce6a888d83c25fbc9c3d21c1a | refs/heads/master | 2022-03-23T21:55:36.535233 | 2010-12-23T20:58:13 | 2010-12-23T20:58:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,311 | cpp | /*----------------------------------------------------------------------------*/
/* COPYRIGHT: TriTime (c) 2003/2005 / www.tritime.org */
/*----------------------------------------------------------------------------*/
/* PROJEKT : TTCUT 2005 */
/* FILE : ttvideoheaderlist.cpp */
/*----------------------------------------------------------------------------*/
/* AUTHOR : b. altendorf (E-Mail: [email protected]) DATE: 05/12/2005 */
/* MODIFIED: b. altendorf DATE: 08/29/2007 */
/* MODIFIED: DATE: */
/*----------------------------------------------------------------------------*/
// ----------------------------------------------------------------------------
// TTVIDEOHEADERLIST
// ----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Overview
// -----------------------------------------------------------------------------
//
// +- TTAudioHeaderList
// |
// +- TTAudioIndexList
// TTHeaderList -|
// +- TTVideoHeaderList
// |
// +- TTVideoIndexList
//
// -----------------------------------------------------------------------------
/*----------------------------------------------------------------------------*/
/* This program is free software; you can redistribute it and/or modify it */
/* under the terms of the GNU General Public License as published by the Free */
/* Software Foundation; */
/* either version 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but WITHOUT*/
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
/* FITNESS FOR A PARTICULAR PURPOSE. */
/* See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License along */
/* with this program; if not, write to the Free Software Foundation, */
/* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */
/*----------------------------------------------------------------------------*/
#include "ttvideoheaderlist.h"
#include "../common/ttexception.h"
bool videoHeaderListCompareItems( TTAVHeader* head_1, TTAVHeader* head_2 );
const char c_name[] = "TTVideoHeaderList";
/*! ////////////////////////////////////////////////////////////////////////////
* Constructor
*/
TTVideoHeaderList::TTVideoHeaderList(int size)
:TTHeaderList( size )
{
}
TTVideoHeaderList::~TTVideoHeaderList()
{
}
/*! ////////////////////////////////////////////////////////////////////////////
* Returns the header type at header list index position
*/
quint8 TTVideoHeaderList::headerTypeAt(int index)
{
checkIndexRange(index);
return at(index)->headerType();
}
/*! ////////////////////////////////////////////////////////////////////////////
* Returns the TTVideoHeader at header list index position
*/
TTVideoHeader* TTVideoHeaderList::headerAt(int index)
{
checkIndexRange(index);
return (TTVideoHeader*)at( index );
}
/*! //////////////////////////////////////////////////////////////////////////////////////
*
*/
TTVideoHeader* TTVideoHeaderList::getPrevHeader(int startPos, TTMpeg2VideoHeader::mpeg2StartCodes type)
{
int prevIndex = startPos-1;
if (prevIndex < 0 || prevIndex >= count())
return NULL;
if (prevIndex >= 0 && type == TTMpeg2VideoHeader::ndef)
return (TTVideoHeader*)at(prevIndex);
while (prevIndex >= 0)
{
if (at(prevIndex)->headerType() == type)
return (TTVideoHeader*)at(prevIndex);
prevIndex--;
}
return NULL;
}
/*! //////////////////////////////////////////////////////////////////////////////////////
*
*/
TTVideoHeader* TTVideoHeaderList::getNextHeader(int startPos, TTMpeg2VideoHeader::mpeg2StartCodes type)
{
int nextIndex = startPos+1;
if (nextIndex < 0 || nextIndex >= count())
return NULL;
if (nextIndex < count() && type == TTMpeg2VideoHeader::ndef) {
TTAVHeader* next = at(nextIndex);
if (next == at(startPos))
qDebug("ksfjgkdfjgkdjfgkldjf");
return (TTVideoHeader*)at(nextIndex);
}
while (nextIndex < count())
{
if (at(nextIndex)->headerType() == type)
return (TTVideoHeader*)at(nextIndex);
nextIndex++;
}
return NULL;
}
TTVideoHeader* TTVideoHeaderList::getNextHeader(TTVideoHeader* current, TTMpeg2VideoHeader::mpeg2StartCodes type)
{
return (current != NULL)
? getNextHeader(indexOf((TTAVHeader*)current), type)
: NULL;
}
TTVideoHeader* TTVideoHeaderList::getPrevHeader(TTVideoHeader* current, TTMpeg2VideoHeader::mpeg2StartCodes type)
{
return (current != NULL)
? getPrevHeader(indexOf((TTAVHeader*)current), type)
: NULL;
}
int TTVideoHeaderList::findIndexOf(TTVideoHeader* current)
{
for (int i = 0; i < size(); i++) {
TTAVHeader* check = at(i);
if (check == NULL)
qDebug("check is null!");
if (check->headerOffset() == ((TTAVHeader*)current)->headerOffset())
return i;
}
return -2;
}
/*! ////////////////////////////////////////////////////////////////////////////
* Returns the TTSequenceHeader at header list index position
*/
TTSequenceHeader* TTVideoHeaderList::sequenceHeaderAt(int index)
{
checkIndexRange(index);
return (TTSequenceHeader*)at( index );
}
/* /////////////////////////////////////////////////////////////////////////////
* Returns the first TTSequenceHeader in index list
*/
TTSequenceHeader* TTVideoHeaderList::firstSequenceHeader()
{
int index = -1;
quint8 type = 0xFF;
if (size() == 0)
throw new TTInvalidOperationException("Invalid");
do
{
index++;
type = at(index)->headerType();
} while (index < count() && type != TTMpeg2VideoHeader::sequence_start_code);
return (at(index)->headerType() == TTMpeg2VideoHeader::sequence_start_code)
? (TTSequenceHeader*)at( index )
: NULL;
}
/*! ////////////////////////////////////////////////////////////////////////////
* Returns the TTPicturesHeader at header list index position
*/
TTPicturesHeader* TTVideoHeaderList::pictureHeaderAt( int index )
{
checkIndexRange( index );
return (TTPicturesHeader*)at( index );
}
/*! ////////////////////////////////////////////////////////////////////////////
* Returns the TTGOPHeader at header list index position
*/
TTGOPHeader* TTVideoHeaderList::gopHeaderAt( int index )
{
checkIndexRange( index );
return (TTGOPHeader*)at( index );
}
/*! ////////////////////////////////////////////////////////////////////////////
* Returns the index position of the current TTVideoHeader
*/
int TTVideoHeaderList::headerIndex( TTVideoHeader* current )
{
if (size() == 0) {
QString msg = QString("No items in list!");
throw TTInvalidOperationException(msg);
}
return indexOf( (TTAVHeader*)current );
}
// -----------------------------------------------------------------------------
// IDD-Index file operations
// -----------------------------------------------------------------------------
// Aufbau der Indexdatei Video:
// -----------------------------------------------------------------------------
//
// 3 Byte Zeichenkette 'idd' (Indexdatei)
// 1 Byte Versionsnummer
//
// Wiederholen bis Dateiende
// -------------------------------------------------------------
// 1 Byte Headertype ($B3-Sequenzheader,
// $B8-Gruppenheader,
// $00-Bildheader)
// 8 Byte (Int64) Adresse des Headers in der Datei
// (inclusive 4 Byte Startcode $00 00 01 xx)
// >> Wenn Bildheader dann
// 2 Byte (Wort) temporaere Referenz
// 1 Byte Bildtype (1-IFrame, 2-PFrame, 3-BFrame)
// -------------------------------------------------------------
// Wiederholen Ende
//
// 1 Byte HeaderType ($B7-Sequenzendcode)
// 8 Byte Adresse (wird zum kopieren des letzten Bildes gebraucht)
// -----------------------------------------------------------------------------
/*! ///////////////////////////////////////////////////////////////////////////
* Sort the header list by header offset
*/
void TTVideoHeaderList::sort()
{
qSort( begin(), end(), videoHeaderListCompareItems );
}
/*! ////////////////////////////////////////////////////////////////////////////
* compare routine for sort
*/
bool videoHeaderListCompareItems( TTAVHeader* head_1, TTAVHeader* head_2 )
{
return (head_1->headerOffset() < head_2->headerOffset());
}
| [
"[email protected]"
]
| [
[
[
1,
269
]
]
]
|
b46e0f957ce13cfcde9e5d1006ece49ea91d0a0a | 171daeea8e21d62e4e1ea549f94fcf638c542c25 | /JiangChen/UniSens_16405/UniSens/QKF.cpp | c9cdfc0c5e244c444d2598ee91460a4d504f84ab | []
| no_license | sworldy/snarcmotioncapture | b8c848ee64212cfb38f002bdd183bf4b6257a9c7 | d4f57f0b7e2ecda6375c11eaa7f6a6b6d3d0af21 | refs/heads/master | 2021-01-13T02:02:54.097775 | 2011-08-07T16:46:24 | 2011-08-07T16:46:24 | 33,110,437 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,191 | cpp | #include "stdafx.h"
#include "qkf.h"
QKF::QKF(double *gintial, double *minitial){
int i,j;
dimension=23;
for(i=0;i<dimension;i++){
for (j=0;j<dimension;j++)
{
Augmented_P[i][j]=0;
}
}
for(i=0;i<(2*dimension+1);i++){
for (j=0;j<dimension;j++)
{
point[i][j]=0;
weight_m[i][j]=0;
weight_c[i][j]=0;
}
}
for(i=0;i<(2*dimension+1);i++){
for (j=0;j<7;j++)
{
statePredPts[i][j]=0;
statePredPts_innovation[i][j]=0;
}
for (j=0;j<9;j++)
{
meaPredPts[i][j]=0;
meaPredPts_innovation[i][j]=0;
}
}
alpha=1;
beta=0;
kappa=2;
// delta_t=0.02;
delta_t=0.02;
for(i=0;i<7;i++){
for (j=0;j<7;j++)
{
Q[i][j]=0;
P_0[i][j]=0;
P_estimate[i][j]=0;
P_predict[i][j]=0;
}
state_estimate[i]=0;
state_predict[i]=0;
}
for (i=0;i<9;i++)
{
for (j=0;j<9;j++)
{
R[i][j]=0;
}
}
Q[0][0]=0.001;
Q[1][1]=0.001;
Q[2][2]=0.001;
Q[3][3]=0.001;
Q[4][4]=0.51;
Q[5][5]=0.51;
Q[6][6]=0.51;
R[0][0]=2;
R[1][1]=2;
R[2][2]=2;
R[3][3]=0.5;
R[4][4]=0.5;
R[5][5]=0.5;
R[6][6]=2;
R[7][7]=2;
R[8][8]=2;
for (i=0;i<7;i++)
{
P_0[i][i]=0.1;
P_estimate[i][i]=0.1;
}
state_estimate[0]=0;
state_estimate[1]=0;
state_estimate[2]=0;
state_estimate[3]=1;
state_estimate[4]=0.001;
state_estimate[5]=0.001;
state_estimate[6]=0.001;
gravity_initial[0]=gintial[0];
gravity_initial[1]=gintial[1];
gravity_initial[2]=gintial[2];
mag_intitial[0]=minitial[0];
mag_intitial[1]=minitial[1];
mag_intitial[2]=minitial[2];
}
QKF::~QKF(){
/*
free(point);
free(weight_c);
free(weight_m);
free(Augmented_P);
free(statePredPts);
free(meaPredPts);*/
}
void QKF::QKF_Filtering(double *measure){
Augmented_Variance();
cholesky(dimension);
SigmaPoint(dimension);
predict();
Update(measure);
/*
int i,j;
for (i=0;i<41;i++)
{
for (j=0;j<dimension;j++)
{
cout<<point[i][j]<<" ";
}
cout<<endl;
}
cout<<"aaa";*/
}
void QKF::Augmented_Variance(){
int i,j;
for (i=0;i<dimension;i++)
{
for (j=0;j<dimension;j++)
{
Augmented_P[i][j]=0;
}
}
for (i=0;i<7;i++)
{
for (j=0;j<7;j++)
{
Augmented_P[i][j]=P_estimate[i][j];
}
}
for (i=0;i<7;i++)
{
for (j=0;j<7;j++)
{
Augmented_P[7+i][7+j]=Q[i][j];
}
}
for (i=0;i<9;i++)
{
for (j=0;j<9;j++)
{
Augmented_P[7+7+i][7+7+j]=R[i][j];
}
}
}
void QKF::cholesky(int n) {
int i,j,m,k;
double **L;
L=(double **)malloc(n*sizeof(double));
for(i=0;i<n;i++)
L[i]=(double *)malloc(n*sizeof(double));
kappa = alpha*alpha*(n+kappa)-n;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
Augmented_P[i][j]=Augmented_P[i][j]*(n+kappa);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
L[i][j]=0;
for(k=0;k<n;k++)
{
L[k][k]=Augmented_P[k][k];
for(m=0;m<k;m++)
L[k][k]-=L[k][m]*L[k][m];
L[k][k]=sqrt(L[k][k]);
for(i=k+1;i<n;i++)
{
L[i][k]=Augmented_P[i][k];
for(m=0;m<k;m++)
L[i][k]-=L[i][m]*L[k][m];
L[i][k]/=L[k][k];
}
}
for(i=0;i<n;i++)
for(j=0;j<n;j++)
Augmented_P[i][j]=L[j][i];
free(L);
/*
for (i=0;i<n;i++){
for(j=0;j<n;j++)
cout<<L[i][j]<<" ";
cout<<endl;
}*/
}
void QKF::SigmaPoint(int dimension){
int i,j;
double weight1,weight2,weight3;
weight1=kappa/(dimension+kappa);
weight2=weight1+(1-alpha*alpha) + beta;
weight3=1.0/(2*(dimension+kappa));
for (i=0;i<(2*dimension+1);i++)
{
for (j=0;j<7;j++)
{
point[i][j]=state_estimate[j];
}
for (j=7;j<dimension;j++)
{
point[i][j]=0;
}
}
for (i=1;i<(dimension+1);i++)
{
for (j=0;j<dimension;j++)
{
point[i][j]-=Augmented_P[i-1][j];
point[i+dimension][j]+=Augmented_P[i-1][j];
}
}
for (i=0;i<(2*dimension+1);i++)
{
for (j=0;j<dimension;j++)
{
if(i==0){
weight_m[i][j]=weight1;
weight_c[i][j]=weight2;
}
else{
weight_c[i][j]=weight3;
weight_m[i][j]=weight3;
}
}
}
}
void QKF::predict(){
double **tmp_varaianc;
int i,j,k,l;
tmp_varaianc=(double **)malloc(9*sizeof(double));
for(i=0;i<9;i++)
tmp_varaianc[i]=(double *)malloc(9*sizeof(double));
double stat_inno_vec[7],meas_inno_vec[9];
ProcssModel();
MeasureModel();
//State prediction;
for (j=0;j<7;j++)
{
state_predict[j]=0;
for (i=0;i<(2*dimension+1);i++)
{
state_predict[j]+=statePredPts[i][j]*weight_m[i][j];
}
}
//Measurement Prediction
for (j=0;j<9;j++)
{
mesure_predict[j]=0;
for (i=0;i<(2*dimension+1);i++)
{
mesure_predict[j]+=meaPredPts[i][j]*weight_m[i][j];
}
}
//The innovation among state prediction and state prediction sigma points
//The innovation among measurement prediction and measurement prediction sigma points
for (i=0;i<(2*dimension+1);i++)
{
for (j=0;j<7;j++)
{
statePredPts_innovation[i][j]=statePredPts[i][j]-state_predict[j];
}
for (j=0;j<9;j++)
{
meaPredPts_innovation[i][j]=meaPredPts[i][j]-mesure_predict[j];
}
}
for (i=0;i<7;i++)
{
for (j=0;j<7;j++)
{
P_predict[i][j]=0;
}
for (j=0;j<9;j++)
{
XZ_Cov[i][j]=0;
}
}
for (i=0;i<9;i++)
{
for (j=0;j<9;j++)
{
Z_Cov[i][j]=0;
}
}
for (i=0;i<(2*dimension+1);i++)
{
for (j=0;j<7;j++)
{
stat_inno_vec[j]=statePredPts_innovation[i][j];
}
for (j=0;j<9;j++)
{
meas_inno_vec[j]=meaPredPts_innovation[i][j];
}
Vector_Multiple(stat_inno_vec,stat_inno_vec,tmp_varaianc,7,7);
for (k=0;k<7;k++)
{
for (l=0;l<7;l++)
{
P_predict[k][l]+=tmp_varaianc[k][l]*weight_c[i][0];
}
}
Vector_Multiple(meas_inno_vec,meas_inno_vec,tmp_varaianc,9,9);
for (k=0;k<9;k++)
{
for (l=0;l<9;l++)
{
Z_Cov[k][l]+=tmp_varaianc[k][l]*weight_c[i][0];
}
}
Vector_Multiple(stat_inno_vec,meas_inno_vec,tmp_varaianc,7,9);
for (k=0;k<7;k++)
{
for (l=0;l<9;l++)
{
XZ_Cov[k][l]+=tmp_varaianc[k][l]*weight_c[i][0];
}
}
}
free(tmp_varaianc);
}
void QKF::Update(double *measurment){
double measurement_innovation[9];
int i,j;
double tmp;
double **gain, **Z_Cov_inv,**XZ_Cov_point, **cov_error,**gaintrans;
gain=(double **)malloc(7*sizeof(double));
for(i=0;i<7;i++)
gain[i]=(double *)malloc(9*sizeof(double));
XZ_Cov_point=(double **)malloc(7*sizeof(double));
for(i=0;i<7;i++)
XZ_Cov_point[i]=(double *)malloc(9*sizeof(double));
cov_error=(double **)malloc(7*sizeof(double));
for(i=0;i<7;i++)
cov_error[i]=(double *)malloc(7*sizeof(double));
Z_Cov_inv=(double **)malloc(9*sizeof(double));
for(i=0;i<9;i++)
Z_Cov_inv[i]=(double *)malloc(9*sizeof(double));
gaintrans=(double **)malloc(9*sizeof(double));
for(i=0;i<9;i++)
gaintrans[i]=(double *)malloc(7*sizeof(double));
double Z_Cov_back[9][9];
for (i=0;i<9;i++)
{
measurement_innovation[i]=measurment[i]-mesure_predict[i];
}
for (i=0;i<9;i++)
{
for (j=0;j<9;j++)
{
Z_Cov_back[i][j]=Z_Cov[i][j];
}
}
Matrix_inv(&Z_Cov_back[0][0],9);
for (i=0;i<9;i++)
{
for (j=0;j<9;j++)
{
Z_Cov_inv[i][j]=Z_Cov_back[i][j];
}
}
for (i=0;i<7;i++)
{
for (j=0;j<9;j++)
{
XZ_Cov_point[i][j]=XZ_Cov[i][j];
}
}
Matrix_Multiple(XZ_Cov_point,Z_Cov_inv,7,9,9,gain);
//update the state;
for (i=0;i<7;i++)
{
tmp=0;
for (j=0;j<9;j++)
{
tmp+=gain[i][j]*measurement_innovation[j];
}
state_estimate[i]=state_predict[i]+tmp;
}
double qnorm=0;
for (i=0;i<4;i++)
{
qnorm+=state_estimate[i]*state_estimate[i];
}
qnorm=sqrt(qnorm);
for (i=0;i<4;i++)
{
state_estimate[i]=state_estimate[i]/qnorm;
}
//update the covariance.
for (i=0;i<7;i++)
{
for (j=0;j<9;j++)
{
gaintrans[j][i]=gain[i][j];
}
}
Matrix_Multiple(XZ_Cov_point,gaintrans,7,9,7,cov_error);
for (i=0;i<7;i++)
{
for (j=0;j<7;j++)
{
P_estimate[i][j]=P_predict[i][j]-cov_error[i][j];
}
}
free(gain);
free(Z_Cov_inv);
free(XZ_Cov_point);
free(cov_error);
free(gaintrans);
}
void QKF::ProcssModel(){
double quaternion[4],quaternion_angular[4],angular[3];
double angular_norm;
int i,j;
for (i=0;i<(2*dimension+1);i++)
{
angular_norm=0;
for (j=0;j<4;j++)
{
quaternion[j]=point[i][j];
}
for (j=0;j<3;j++)
{
angular[j]=point[i][j+4];
statePredPts[i][j+4]=angular[j]+point[i][j+4+7];
angular_norm=angular_norm+angular[j]*angular[j];
}
angular_norm=sqrt(angular_norm);
for (j=0;j<3;j++)
{
angular[j]=angular[j]/angular_norm*sin(angular_norm*delta_t/2);
quaternion_angular[j]=angular[j];
}
quaternion_angular[3]=cos(angular_norm*delta_t/2);
Quaternion_Multiple(quaternion,quaternion_angular);
for (j=0;j<4;j++)
{
statePredPts[i][j]=quaternion[j]+point[i][j+7];
}
}
}
void QKF::MeasureModel(){
double quaternion[4];
double vectors[3],vectorm[3];
int i,j;
for (i=0;i<(2*dimension+1);i++)
{
for (j=0;j<4;j++)
{
quaternion[j]=statePredPts[i][j];
}
for(j=0;j<3;j++){
vectors[j]=gravity_initial[j];
vectorm[j]=mag_intitial[j];
meaPredPts[i][j+3]=statePredPts[i][j+4]+point[i][j+7+7+3];
}
Quaternion_Rotation(quaternion,vectors);
Quaternion_Rotation(quaternion,vectorm);
for (j=0;j<3;j++)
{
meaPredPts[i][j]=vectors[j]+point[i][j+7+7];
meaPredPts[i][j+6]=vectorm[j]+point[i][j+7+7+6];
}
}
}
void QKF::Quaternion_Multiple(double *a,double *b){
double temp1=a[3]*b[3]-a[0]*b[0]-a[1]*b[1]-a[2]*b[2];
double temp2=a[3]*b[0]+b[3]*a[0]+a[1]*b[2]-b[1]*a[2];
double temp3=a[3]*b[1]+b[3]*a[1]+a[2]*b[0]-b[2]*a[0];
double temp4=a[3]*b[2]+b[3]*a[2]+a[0]*b[1]-b[0]*a[1];
//cout<<temp2<<" "<<temp3<<" "<<temp4<<" "<<temp1<<" ";
a[0]=temp2;
a[1]=temp3;
a[2]=temp4;
a[3]=temp1;
}
void QKF::Quaternion_Rotation(double *a, double *vctors){
double inva[]={-a[0],-a[1],-a[2],a[3]};
double aug_vc[]={vctors[0],vctors[1],vctors[2],0};
Quaternion_Multiple(aug_vc,a);
Quaternion_Multiple(inva,aug_vc);
for (int i=0;i<3;i++)
{
vctors[i]=inva[i];
}
}
void QKF::Vector_Multiple(double *col, double *row, double **retrunback,int col_length,int row_length){
int i,j;
for (j=0;j<row_length;j++)
{
for (i=0;i<col_length;i++)
{
retrunback[i][j]=row[j]*col[i];
}
}
}
//This function was found in the Internet.
int QKF::Matrix_inv(double a[], int n)
{
int *is,*js,i,j,k,l,u,v;
double d,p;
is=(int*)malloc(n*sizeof(int));
js=(int*)malloc(n*sizeof(int));
for (k=0; k<=n-1; k++)
{ d=0.0;
for (i=k; i<=n-1; i++)
for (j=k; j<=n-1; j++)
{ l=i*n+j; p=fabs(a[l]);
if (p>d) { d=p; is[k]=i; js[k]=j;}
}
if (d+1.0==1.0)
{ free(is); free(js); printf("error... no invert exists\n");
return(0);
}
if (is[k]!=k)
for (j=0; j<=n-1; j++)
{ u=k*n+j; v=is[k]*n+j;
p=a[u]; a[u]=a[v]; a[v]=p;
}
if (js[k]!=k)
for (i=0; i<=n-1; i++)
{ u=i*n+k; v=i*n+js[k];
p=a[u]; a[u]=a[v]; a[v]=p;
}
l=k*n+k;
a[l]=1.0/a[l];
for (j=0; j<=n-1; j++)
if (j!=k)
{ u=k*n+j; a[u]=a[u]*a[l];}
for (i=0; i<=n-1; i++)
if (i!=k)
for (j=0; j<=n-1; j++)
if (j!=k)
{ u=i*n+j;
a[u]=a[u]-a[i*n+k]*a[k*n+j];
}
for (i=0; i<=n-1; i++)
if (i!=k)
{ u=i*n+k; a[u]=-a[u]*a[l];}
}
for (k=n-1; k>=0; k--)
{ if (js[k]!=k)
for (j=0; j<=n-1; j++)
{ u=k*n+j; v=js[k]*n+j;
p=a[u]; a[u]=a[v]; a[v]=p;
}
if (is[k]!=k)
for (i=0; i<=n-1; i++)
{ u=i*n+k; v=i*n+is[k];
p=a[u]; a[u]=a[v]; a[v]=p;
}
}
free(is); free(js);
return(1);
}
void QKF::Matrix_Multiple(double **a, double **b, int m, int n,int p, double **c)
{
int i,j,k;
for(i=0;i<m;i++)
for(j=0;j<p;j++){
c[i][j]=0;
for(k=0;k<n;k++)
c[i][j]+=a[i][k]*b[k][j];
}
} | [
"macrotao86@4a66b584-afee-11de-9d1a-45ab25924541"
]
| [
[
[
1,
659
]
]
]
|
f2e390961bb0e87df21a4b038493d99fd00e7d90 | 1cc5720e245ca0d8083b0f12806a5c8b13b5cf98 | /v2/partials/208/program.cpp | 480945b5a2c384c7e26e723dac75a6b24baa7e34 | []
| no_license | Emerson21/uva-problems | 399d82d93b563e3018921eaff12ca545415fd782 | 3079bdd1cd17087cf54b08c60e2d52dbd0118556 | refs/heads/master | 2021-01-18T09:12:23.069387 | 2010-12-15T00:38:34 | 2010-12-15T00:38:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,402 | cpp | #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
// sketch
class Caminho;
class Node;
bool comp(const Node *n1, const Node *n2);
class Grupo {
public:
Grupo(int i) {
this->id = i;
}
int id;
vector<Node *> nodes;
};
Grupo *grupos[25];
// classe para um no
class Node {
public:
Node(int id) {
this->id = id;
}
int id;
vector<Node *> vizinhos;
int grupo;
bool visitado;
void clear() {
vizinhos.clear();
grupo = id;
grupos[id]->nodes.clear();
grupos[id]->nodes.push_back(this);
}
void sorting() {
sort(vizinhos.begin(),vizinhos.end(),comp);
}
};
bool comp(const Node *n1, const Node *n2) {
return n1->id < n2->id;
}
// classe que representa um caminho na arvore
class Caminho {
public:
// construtor limpo
Caminho(Node *de) {
this->nodes.push_back(de);
}
// construtor que copia um caminho
Caminho(Caminho *c) {
for(int i=0;i!=c->nodes.size();i++) {
this->nodes.push_back(c->nodes[i]);
}
}
// nos
vector<Node *> nodes;
void imprime() {
for(int i=0;i < nodes.size() - 1; i++) {
cout << nodes[i]->id << " ";
}
if(nodes.size()!=0) {
cout << nodes[nodes.size()-1]->id;
}
cout << endl;
}
};
// mapa de nos
Node *nodes[25];
int rotas;
void busca(Node *de, Node *nodeAtual, Node *target, Caminho *c) {
// para cada vizinho
for(int i = 0; i != nodeAtual->vizinhos.size(); i++) {
Node *proximo = nodeAtual->vizinhos[i];
// se o proximo vizinho nao foi visitado e nao eh o inicial
if(!proximo->visitado && (proximo->id != de->id)) {
c->nodes.push_back(proximo);
if(proximo->id == target->id) {
c->imprime();
rotas++;
} else {
proximo->visitado = true;
busca(de, proximo, target, c);
proximo->visitado = false;
}
c->nodes.erase(c->nodes.end()-1);
}
}
}
int main() {
// lendo os nos
for(int i = 0; i != 22; i++) {
// gera o grupo
grupos[i] = new Grupo(i);
// gera o no
Node *n = new Node(i);
// adiciona na lista
nodes[i] = n;
}
// le o numero de nos
int targetN, caso = 0;
while((cin >> targetN)) {
cout << "CASE " << ++caso << ":" <<endl;
// lendo os nos
for(int i = 0; i != 22; i++) {
nodes[i]->clear();
}
Node *target = nodes[targetN];
// le o numero de conexoes
while(true) {
int de, para;
cin >> de >> para;
if(de==0 && para==0) {
break;
}
Node *d = nodes[de], *p = nodes[para];
// assume que as conexoes funcionam em ambas os sentidos
//cout << "conectando: " << d->id << " e " << p->id << endl;
if(find(d->vizinhos.begin(),d->vizinhos.end(),p)!=d->vizinhos.end()) {
continue;
}
d->vizinhos.push_back(p);
p->vizinhos.push_back(d);
if(d->grupo != p->grupo) {
Grupo *novo, *velho;
int novoI;
if(d->grupo < p->grupo) {
novo = grupos[d->grupo];
velho = grupos[p->grupo];
novoI = d->grupo;
} else {
novo = grupos[p->grupo];
velho = grupos[d->grupo];
novoI = p->grupo;
}
for(int z = 0; z != velho->nodes.size(); z++) {
velho->nodes[z]->grupo = novoI;
novo->nodes.push_back(velho->nodes[z]);
}
velho->nodes.clear();
}
}
// pega o no inicial
Node *de = nodes[1];
// limpa os caminhos para todos os nos
for(int i2 = 0; i2 != 22; i2++) {
nodes[i2]->visitado = false;
nodes[i2]->sorting();
}
de->visitado = true;
// gera o set de visitados
Caminho *caminho = new Caminho(de);
// executa a recursao
//cout << "Buscando a partir de " << de->name << endl;
rotas = 0;
if(de->grupo == target->grupo) //cout << "!="<<endl;
busca(de, de, target, caminho);
cout << "There are " << rotas << " routes from the firestation to streetcorner " << targetN << "." << endl;
delete caminho;
}
return 0;
}
| [
"[email protected]"
]
| [
[
[
1,
212
]
]
]
|
d962e39a8dc6aa80bc542643defba14324169468 | e99d8eb7e3cc6f75d2bd5621414b79499e9578ed | /src/gfx/tops/DOFCoCComputeTOP.cpp | 83349edf2b70d724825735169904d0d3cd3af41d | []
| no_license | skydave/mpchristmas | 32c84def30dfe045029454b4f27625d3fc9f15b7 | 4f25403b2b5d69a217a70c03383c43247eb91f38 | refs/heads/master | 2016-09-05T22:02:17.417514 | 2010-12-11T18:42:58 | 2010-12-14T12:48:38 | 1,157,617 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,040 | cpp | #include "DOFCoCComputeTOP.h"
#include "../FBO.h"
DOFCoCComputeTOP::DOFCoCComputeTOP() : TOP( 32, 32 )
{
shader = new Shader();
shader->init(vs_nop, vs_nop_size, DOFCoCComputeTOP_ps, DOFCoCComputeTOP_ps_size);
shader->finalize();
}
void DOFCoCComputeTOP::setInputs( Texture *normal_depth, Attribute *focalLength, Attribute *fallOffStart, Attribute *fallOffEnd )
{
// if we dont have an output by now we create one ourselfs
if( !out0 )
//setOutputs( normal_depth->copy() );
setOutputs( Texture::createRGBA8( normal_depth->m_xres/4, normal_depth->m_yres/4 ) );
// adobt the size of the input
TOP::setSize( normal_depth->m_xres/4, normal_depth->m_yres/4 );
// set input with the shader
shader->setUniform( "normal_depth", normal_depth->getUniform() );
shader->setUniform( "focalLength", focalLength );
shader->setUniform( "fallOffStart", fallOffStart );
shader->setUniform( "fallOffEnd", fallOffEnd );
}
void DOFCoCComputeTOP::render( float time )
{
m_fbo->begin();
g_screenQuad->render(shader);
m_fbo->end();
}
| [
"[email protected]"
]
| [
[
[
1,
38
]
]
]
|
1708f3ce7a635d461a0a202212021689d7bd285a | fb71c08b1c1e7ea4d7abc82e65b36272069993e1 | /src/utils.hpp | 5c7010bb241ca98e7c1faf92a649cdae2bb23247 | []
| no_license | cezarygerard/fpteacher | 1bb4ea61bc86cbadcf47a810c8bb441f598d278a | 7bdfcf7c047caa9382e22a9d26a2d381ce2d9166 | refs/heads/master | 2021-01-23T03:47:54.994165 | 2010-03-25T01:12:04 | 2010-03-25T01:12:04 | 39,897,391 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,140 | hpp | /** \mainpage FPTeacher - dokumentacja projektu
*
* \section intro_sec Wstep
*
* FPTEngine jest multiplatformowym silnikiem gry 2D opartym o biblioteki SimpleDirectMedia Library i OpenGL.
* \n
* Przy implementacji stosowane byly biblioteki z rodziny Boost.
* \n
* Do jego funkcjonalnosci nalezy akcelerowane sprzetowo wyswietlanie grafiki 2D w trybie okienkowym lub pelnoekranowym, pobieranie zdarzen z klawiatury i myszy, odtwarzanie dzwieku lokalizowanego w przestrzeni, pobieranie danych z plikow XML, zarzadzanie zasobami (grafiki, animacje, dzwieki), komunikacja sieciowa z drugim terminalem w dwuosobowym trybie gry, synchronizacja i integracja wszystkich wczesniej wymienionych podsystemow.
*
* @file utils.hpp
* @author Sebastian Luczak
* @date 2009.12.08
* @version 0.6
* @class utils::BadFileError utils.hpp
* @class utils::BadBppError utils.hpp
* @struct utils::TexDims utils.hpp
* @brief plik w ktorym przechowywane sa rozne dodatkowe funkcje ulatwiajace i usprawniajace pisanie kodu
**/
#ifndef UTILS_H
#define UTILS_H
#include <iostream>
#include <string>
#include <cassert>
#include <sstream>
#include <stdexcept>
#include <math.h>
// naglowki boost
#include <boost/smart_ptr.hpp>
#include <boost/bind.hpp>
// naglowki SDL
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"
//naglowki OpenGL
#if defined(_WIN32)
#include <windows.h>
#endif
#include <GL/gl.h>
#include <GL/glu.h>
#include "CLog.hpp"
//#include <GL/glext.h>
using namespace std;
/// @namespace utils Przechowuje funkcje i struktury uzywane w kodzie wielu klas
namespace utils
{
/// sciezki do zasobow
const string PATH_LOGS = "../doc/logs/";
const string PATH_FONTS = "../res/graphics/fonts/";
const string PATH_SOUNDS = "../res/sounds/";
const string PATH_SOUNDS_ACTIONS = PATH_SOUNDS+"actions/";
const string PATH_GUI = "../res/graphics/gui/";
const string PATH_GUI_BUTTONS = PATH_GUI+"buttons/";
const string PATH_CURSORS = "../res/graphics/cursors/";
const string PATH_SPRITES = "../res/graphics/sprites/";
const string PATH_SPRITES_AUDITORIUM_STUDENTS = PATH_SPRITES+"auditorium/students/";
const string PATH_SPRITES_AUDITORIUM_TEACHER = PATH_SPRITES+"auditorium/teacher/";
const string PATH_SPRITES_STUDENT_FRONT = PATH_SPRITES+"students/front/";
const string PATH_SPRITES_STUDENT_REAR = PATH_SPRITES+"students/rear/";
const string PATH_SPRITES_TEACHER = PATH_SPRITES+"teacher/";
const string PATH_SPRITES_MINIGAMES = PATH_SPRITES+"minigames/";
const string PATH_SPRITES_MINIGAMES_SLIDER = PATH_SPRITES_MINIGAMES+"slider/";
const string PATH_SPRITES_MINIGAMES_BALANCE = PATH_SPRITES_MINIGAMES+"balance/";
const string PATH_ANIM_SEQUENCES = "../res/animsequences/";
const string PATH_CONSTS = "../res/consts/CConsts.xml";
/// Liczba klatek na sekunde (do ladowania z pliku)
const int FPS = 30;
enum
{
THROW_TEACHER,
THROW_STUDENTS
};
enum
{
OBJECT_CHALK,
OBJECT_PAPERBALL/*,
OBJECT_PLANE,
OBJECT_CLOTH
*/
};
struct Point
{
Point() : x_(0.f), y_(0.f), z_(0.f) {};
Point(float x, float y, float z) : x_(x), y_(y), z_(z) {};
float x_;
float y_;
float z_;
};
struct Vector2f
{
Vector2f() : x_(0.f), y_(0.f){};
Vector2f(float x, float y) : x_(x), y_(y) {};
Vector2f(Point a, Point b)
{
x_ = b.x_ - a.x_;
y_ = b.y_ - a.y_;
};
float x_;
float y_;
};
float distanceBetween(const Point a, const Point b);
Vector2f multiplyVector2f(const Vector2f v, const float multiplier);
Vector2f addVectors2f(const Vector2f v1, const Vector2f v2);
Vector2f getOrthogonalVector2f(const Vector2f v);
Point getEndPoint(const Point a, const Vector2f v);
class BadFileError : public invalid_argument {
public:
///konstruktor domyslny klasy wyjatku blednego pliku
BadFileError(const string& msg = ""): invalid_argument(msg) {}
};
class BadBppError: public invalid_argument {
public:
///konstruktor domyslny klasy wyjatku blednego BytesPerPixel
BadBppError(const string& msg = ""): invalid_argument(msg) {}
};
/// @enum AnimMode Okresla tryb odtwarzania sekwencji zestawow animacji
enum AnimMode
{
ANIM_ONCE,
ANIM_LOOP,
ANIM_NONE,
ANIM_RANDOM
};
/// @enum AnimState Opisuje krok animacji, czyli, czy zestaw animuje sie do przodu, tylu (obecnie nieobslugiwane), czy jest zatrzymany (zapauzowany)
enum AnimState
{
//BACKWARD = -1,
STOP = 0,
FORWARD = 1,
};
/// @typedef Struktura przechowujaca wartosci graniczne tekstury OGL
/// @struct TexDims
typedef struct{
///FESTER
GLfloat texMinX;
///FESTER
GLfloat texMinY;
///FESTER
GLfloat texMaxX;
///FESTER
GLfloat texMaxY;
} TexDims;
/// @return przyblizenie danej wartosci wielokrotnoscia dwojki (dla funkcji OpenGL
int PowerOfTwo(int num);
/// Przerwarza powierzchnie SDL na teksture OpenGL
/// @return Tekstura 2D OpenGL
GLuint SurfaceToTexture(boost::shared_ptr<SDL_Surface> surface, utils::TexDims& texcoord);
/// funkcja bezpiecznie ladujaca pliki obrazow
/// @return sprytny wskaznik do powierzchni grafiki
boost::shared_ptr<SDL_Surface> LoadImage(const std::string& fileName);
/// Dealokator dla sprytnych wskaznikow na powierzchnie SDL
void SafeFreeSurface(SDL_Surface* surface);
/// Operator strumieniowy dla enum'ow
void operator>>(const std::istringstream& data, AnimMode& mode );
// @struct istring_less struktura operator porownania string'ow w indeksie nazw
struct string_less
{
/// przeciazony operator wywolania funkcyjnego do porownywania zawartosci stringow w kontenerze map
/// @param l string jako parametr z lewej strony operatora
/// @param r string jako parametr z prawej strony operatora
/// @return bool czy stringi l i r sa sobie rowne czy rozne
bool operator () ( const std::string& l, const std::string& r ) const
{ return ( l.compare(r) < 0 ); }
};
//void logs(int number);
void randomizeRNG();
}
#endif
//~~utils.hpp
| [
"fester3000@8e29c490-c8d6-11de-b6dc-25c59a28ecba",
"r.malinowski88@8e29c490-c8d6-11de-b6dc-25c59a28ecba",
"czarek.zawadka@8e29c490-c8d6-11de-b6dc-25c59a28ecba"
]
| [
[
[
1,
10
],
[
12,
14
],
[
19,
47
],
[
49,
56
],
[
59,
76
],
[
79,
80
],
[
83,
136
],
[
138,
152
],
[
154,
162
],
[
164,
164
],
[
168,
168
],
[
170,
170
],
[
172,
201
],
[
204,
210
]
],
[
[
11,
11
],
[
15,
18
],
[
48,
48
],
[
57,
58
],
[
77,
78
],
[
137,
137
],
[
153,
153
],
[
163,
163
],
[
165,
167
],
[
169,
169
],
[
171,
171
],
[
202,
203
]
],
[
[
81,
82
]
]
]
|
a431f993e3670b3392286b6b4299bf57095bb7ab | e8d9619e262531453688550db22d0e78f1b51dab | /ping/utils.cpp | 556a8f3186999df74fb12a9cf584c923524158d1 | []
| no_license | sje397/sje-miranda-plugins | e9c562f402daef2cfbe333ce9a8a888cd81c9573 | effb7ea736feeab1c68db34a86da8a2be2b78626 | refs/heads/master | 2016-09-05T16:42:34.162442 | 2011-05-22T14:48:15 | 2011-05-22T14:48:15 | 1,784,020 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 12,353 | cpp | #include "common.h"
#include "utils.h"
#include "icmp.h"
LRESULT CALLBACK NullWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message ) {
case WM_COMMAND: {
PUDeletePopUp( hWnd );
break;
}
case WM_CONTEXTMENU:
PUDeletePopUp( hWnd );
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
void CALLBACK sttMainThreadCallback( ULONG_PTR dwParam )
{
POPUPDATAEX* ppd = ( POPUPDATAEX* )dwParam;
if ( ServiceExists(MS_POPUP_ADDPOPUPEX) )
CallService( MS_POPUP_ADDPOPUPEX, ( WPARAM )ppd, 0 );
else
if ( ServiceExists(MS_POPUP_ADDPOPUP) )
CallService( MS_POPUP_ADDPOPUP, ( WPARAM )ppd, 0 );
free( ppd );
}
void __stdcall ShowPopup( const char* line1, const char* line2, int flags )
{
if(CallService(MS_SYSTEM_TERMINATED, 0, 0)) return;
if ( !ServiceExists( MS_POPUP_ADDPOPUP )) {
MessageBox( NULL, line2, PLUG " Message", MB_OK | MB_ICONINFORMATION );
return;
}
if(ServiceExists(MS_POPUP_ADDPOPUPCLASS)) {
POPUPDATACLASS d = {sizeof(d), "pingpopups"};
d.pwszTitle = (wchar_t *)line1;
d.pwszText = (wchar_t *)line2;
CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&d);
} else {
POPUPDATAEX* ppd = ( POPUPDATAEX* )calloc( sizeof( POPUPDATAEX ), 1 );
ppd->lchContact = NULL;
ppd->lchIcon = (flags ? hIconResponding : hIconNotResponding);
strcpy( ppd->lpzContactName, line1 );
strcpy( ppd->lpzText, line2 );
ppd->colorBack = GetSysColor( COLOR_BTNFACE );
ppd->colorText = GetSysColor( COLOR_WINDOWTEXT );
ppd->iSeconds = 10;
ppd->PluginWindowProc = ( WNDPROC )NullWindowProc;
ppd->PluginData = NULL;
QueueUserAPC( sttMainThreadCallback , mainThread, ( ULONG )ppd );
}
}
// service functions
// wParam is zero
// lParam is address of PINGADDRESS structure where ping result is placed (i.e. modifies 'responding'
// and 'round_trip_time')
INT_PTR PluginPing(WPARAM wParam,LPARAM lParam)
{
PINGADDRESS *pa = (PINGADDRESS *)lParam;
if(pa->port == -1) {
// ICMP echo
if(use_raw_ping) {
pa->round_trip_time = raw_ping(pa->pszName, options.ping_timeout * 1000);
pa->responding = (pa->round_trip_time != -1);
} else {
ICMP_ECHO_REPLY result;
pa->responding = ICMP::get_instance()->ping(pa->pszName, result);
if(pa->responding)
pa->round_trip_time = (short)result.RoundTripTime;
else
pa->round_trip_time = -1;
}
} else if(hNetlibUser) {
// TCP connect
clock_t start_tcp = clock();
//GetLocalTime(&systime);
NETLIBOPENCONNECTION conn = {0};
conn.cbSize = sizeof(NETLIBOPENCONNECTION);
conn.szHost = pa->pszName;
conn.wPort = pa->port;
conn.timeout = options.ping_timeout;
HANDLE s = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hNetlibUser, (LPARAM)&conn);
clock_t end_tcp = clock();
if(s) {
LINGER l;
char buf[1024];
SOCKET socket = (SOCKET)CallService(MS_NETLIB_GETSOCKET, (WPARAM)s, (LPARAM)NLOCF_HTTP);
l.l_onoff = 1;
l.l_linger = 0;
setsockopt(socket, SOL_SOCKET, SO_LINGER, (char *)&l, sizeof(l));
Netlib_Send(s, "OUT\r\n\r\n", 7, 0); //MSG_RAW);
//Sleep(ICMP::get_instance()->get_timeout());
Sleep(options.ping_timeout * 1000);
unsigned long bytes_remaining;
ioctlsocket(socket, FIONBIO, &bytes_remaining);
if(bytes_remaining > 0) {
int retval, rx = 0;
while((retval = Netlib_Recv(s, buf, 1024, 0)) != SOCKET_ERROR && (retval > 0) && rx < 2048) {
rx += retval; // recv at most 2kb before closing connection
}
}
closesocket(socket);
pa->responding = true;
pa->round_trip_time = (int)(((end_tcp - start_tcp) / (double)CLOCKS_PER_SEC) * 1000);
Netlib_CloseHandle(s);
} else {
pa->responding = false;
pa->round_trip_time = -1;
}
}
return 0;
}
void Lock(CRITICAL_SECTION *cs, char *lab) {
// if(logging) {
// std::ostringstream oss1;
// oss1 << "Locking cs: " << cs << ", " << lab;
// CallService(PROTO "/Log", (WPARAM)oss1.str().c_str(), 0);
// }
EnterCriticalSection(cs);
// if(logging) {
// std::ostringstream oss2;
// oss2 << "Locked cs: " << cs;
// CallService(PROTO "/Log", (WPARAM)oss2.str().c_str(), 0);
// }
}
void Unlock(CRITICAL_SECTION *cs) {
// if(logging) {
// std::ostringstream oss1;
// oss1 << "Unlocking cs: " << cs;
// CallService(PROTO "/Log", (WPARAM)oss1.str().c_str(), 0);
// }
LeaveCriticalSection(cs);
}
INT_PTR PingDisableAll(WPARAM wParam, LPARAM lParam) {
PINGLIST pl;
CallService(PLUG "/GetPingList", 0, (LPARAM)&pl);
for(PINGLIST::Iterator i = pl.start(); i.has_val(); i.next()) {
i.val().status = PS_DISABLED;
i.val().miss_count = 0;
}
CallService(PLUG "/SetPingList", (WPARAM)&pl, 0);
return 0;
}
INT_PTR PingEnableAll(WPARAM wParam, LPARAM lParam) {
PINGLIST pl;
CallService(PLUG "/GetPingList", 0, (LPARAM)&pl);
for(PINGLIST::Iterator i = pl.start(); i.has_val(); i.next()) {
if(i.val().status == PS_DISABLED) {
i.val().status = PS_NOTRESPONDING;
}
}
CallService(PLUG "/SetPingList", (WPARAM)&pl, 0);
return 0;
}
INT_PTR ToggleEnabled(WPARAM wParam, LPARAM lParam) {
int retval = 0;
PINGLIST pl;
CallService(PLUG "/GetPingList", 0, (LPARAM)&pl);
for(PINGLIST::Iterator i = pl.start(); i.has_val(); i.next()) {
if(i.val().item_id == (DWORD)wParam) {
if(i.val().status == PS_DISABLED)
i.val().status = PS_NOTRESPONDING;
else {
i.val().status = PS_DISABLED;
i.val().miss_count = 0;
retval = 1;
}
}
}
CallService(PLUG "/SetPingList", (WPARAM)&pl, 0);
return 0;
}
INT_PTR EditContact(WPARAM wParam, LPARAM lParam) {
PINGLIST pl;
HWND hwndList = (HWND)CallService(MS_CLUI_GETHWND, 0, 0);
CallService(PLUG "/GetPingList", 0, (LPARAM)&pl);
for(PINGLIST::Iterator i = pl.start(); i.has_val(); i.next()) {
if(i.val().item_id == (DWORD)wParam) {
add_edit_addr = i.val();
if(DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG3), hwndList, DlgProcDestEdit) == IDOK) {
i.val() = add_edit_addr;
CallService(PLUG "/SetAndSavePingList", (WPARAM)&pl, 0);
return 0;
}
}
}
return 1;
}
INT_PTR DblClick(WPARAM wParam, LPARAM lParam) {
PINGLIST pl;
CallService(PLUG "/GetPingList", 0, (LPARAM)&pl);
for(PINGLIST::Iterator i = pl.start(); i.has_val(); i.next()) {
if(i.val().item_id == (DWORD)wParam) {
if(strlen(i.val().pszCommand)) {
ShellExecute(0, "open", i.val().pszCommand, i.val().pszParams, 0, SW_SHOW);
} else {
return CallService(PLUG "/ToggleEnabled", wParam, 0);
}
}
}
return 0;
}
void import_ping_address(int index, PINGADDRESS &pa) {
DBVARIANT dbv;
char buf[256];
mir_snprintf(buf, 256, "Address%d", index);
if(!DBGetContactSetting(0, "PingPlug", buf, &dbv)) {
strncpy(pa.pszName, dbv.pszVal, MAX_PINGADDRESS_STRING_LENGTH);
DBFreeVariant(&dbv);
} else
strcpy(pa.pszName, Translate("Unknown Address"));
mir_snprintf(buf, 256, "Label%d", index);
if(!DBGetContactSetting(0, "PingPlug", buf, &dbv)) {
strncpy(pa.pszLabel, dbv.pszVal, MAX_PINGADDRESS_STRING_LENGTH);
DBFreeVariant(&dbv);
} else
strcpy(pa.pszLabel, Translate("Unknown"));
mir_snprintf(buf, 256, "Port%d", index);
pa.port = (int)DBGetContactSettingDword(0, "PingPlug", buf, -1);
mir_snprintf(buf, 256, "Proto%d", index);
if(!DBGetContactSetting(0, "PingPlug", buf, &dbv)) {
strncpy(pa.pszProto, dbv.pszVal, MAX_PINGADDRESS_STRING_LENGTH);
DBFreeVariant(&dbv);
mir_snprintf(buf, 256, "Status%d", index);
pa.set_status = DBGetContactSettingWord(0, "PingPlug", buf, ID_STATUS_ONLINE);
mir_snprintf(buf, 256, "Status2%d", index);
pa.get_status = DBGetContactSettingWord(0, "PingPlug", buf, ID_STATUS_OFFLINE);
} else
pa.pszProto[0] = '\0';
pa.responding = false;
pa.round_trip_time = 0;
pa.miss_count = 0;
pa.index = index;
pa.pszCommand[0] = '\0';
pa.pszParams[0] = '\0';
pa.item_id = 0;
mir_snprintf(buf, 256, "Enabled%d", index);
if(DBGetContactSettingByte(0, "PingPlug", buf, 1) == 1)
pa.status = PS_NOTRESPONDING;
else
pa.status = PS_DISABLED;
}
// read in addresses from old pingplug
void import_ping_addresses() {
int count = DBGetContactSettingDword(0, "PingPlug", "NumEntries", 0);
PINGADDRESS pa;
EnterCriticalSection(&list_cs);
list_items.clear();
for(int index = 0; index < count; index++) {
import_ping_address(index, pa);
list_items.add(pa);
}
write_ping_addresses();
LeaveCriticalSection(&list_cs);
}
HANDLE hIcoLibIconsChanged;
HICON hIconResponding, hIconNotResponding, hIconTesting, hIconDisabled;
int ReloadIcons(WPARAM wParam, LPARAM lParam) {
hIconResponding = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"ping_responding");
hIconNotResponding = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"ping_not_responding");
hIconTesting = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"ping_testing");
hIconDisabled = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"ping_disabled");
RefreshWindow(0, 0);
return 0;
}
void InitUtils() {
if(ServiceExists(MS_SKIN2_ADDICON)) {
SKINICONDESC sid = {0};
sid.cbSize = sizeof(SKINICONDESC);
sid.pszSection = "Ping";
sid.pszDescription = Translate("Responding");
sid.pszName = "ping_responding";
sid.pszDefaultFile = "ping.dll";
sid.iDefaultIndex = 0;
sid.hDefaultIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_RESPONDING), IMAGE_ICON, 16, 16, 0);
CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
sid.pszDescription = Translate("Not Responding");
sid.pszName = "ping_not_responding";
sid.pszDefaultFile = "ping.dll";
sid.iDefaultIndex = 1;
sid.hDefaultIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_NOTRESPONDING), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
sid.pszDescription = Translate("Testing");
sid.pszName = "ping_testing";
sid.pszDefaultFile = "ping.dll";
sid.iDefaultIndex = 2;
sid.hDefaultIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_TESTING), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
sid.pszDescription = Translate("Disabled");
sid.pszName = "ping_disabled";
sid.pszDefaultFile = "ping.dll";
sid.iDefaultIndex = 3;
sid.hDefaultIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_DISABLED), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
hIconResponding = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"ping_responding");
hIconNotResponding = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"ping_not_responding");
hIconTesting = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"ping_testing");
hIconDisabled = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"ping_disabled");
hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons);
} else {
hIconResponding = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_RESPONDING), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
hIconNotResponding = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_NOTRESPONDING), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
hIconTesting = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_TESTING), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
hIconDisabled = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_DISABLED), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
}
if(ServiceExists(MS_POPUP_REGISTERCLASS)) {
POPUPCLASS test = {0};
test.cbSize = sizeof(test);
test.flags = PCF_TCHAR;
test.hIcon = hIconResponding;
test.iSeconds = -1;
test.ptszDescription = TranslateT("Ping");
test.pszName = "pingpopups";
test.PluginWindowProc = NullWindowProc;
CallService(MS_POPUP_REGISTERCLASS, 0, (WPARAM)&test);
}
}
void DeinitUtils() {
if(!ServiceExists(MS_SKIN2_ADDICON)) {
if(hIconResponding) DestroyIcon(hIconResponding);
if(hIconResponding) DestroyIcon(hIconNotResponding);
if(hIconResponding) DestroyIcon(hIconTesting);
if(hIconResponding) DestroyIcon(hIconDisabled);
}
} | [
"[email protected]"
]
| [
[
[
1,
391
]
]
]
|
abdc5cee1290daf261264813c7e7db78a7d92b55 | 48ab31a0a6a8605d57b5e140309c910f46eb5b35 | /Root/Support/KeyGeneratorHelper.h | 2ef9093fd17b2382a45a579a82881c2802f56cf4 | []
| no_license | firebreath/indexeddb | 4c3106027a70e233eb0f91c6e0b5d60847d75800 | 50136d2fadced369788a42d249157b8a0d06eb88 | refs/heads/master | 2023-08-31T11:28:42.664028 | 2011-01-03T23:29:46 | 2011-01-03T23:29:46 | 1,218,008 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 975 | h | /**********************************************************\
Copyright Brandon Haynes
http://code.google.com/p/indexeddb
GNU Lesser General Public License
\**********************************************************/
#ifndef BRANDONHAYNES_INDEXEDDB_SUPPORT_KEYGENERATORHELPER_H
#define BRANDONHAYNES_INDEXEDDB_SUPPORT_KEYGENERATORHELPER_H
#include <string>
#include <BrowserObjectAPI.h>
#include "../Implementation/KeyGenerator.h"
namespace BrandonHaynes {
namespace IndexedDB {
namespace API {
namespace Support {
class KeyGeneratorHelper : public Implementation::KeyGenerator
{
public:
KeyGeneratorHelper(FB::BrowserHostPtr host, const std::string& keyPath)
: keyPath(keyPath), host(host)
{ }
virtual Implementation::Key generateKey(const Implementation::Data& context) const;
const FB::variant generateKey(FB::variant value) const;
private:
FB::BrowserHostPtr host;
std::string keyPath;
};
}
}
}
}
#endif | [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
21
],
[
23,
29
],
[
31,
39
]
],
[
[
22,
22
],
[
30,
30
]
]
]
|
2fee0eaff85afdbc4a94a47d029ad50048bcf625 | 1e01b697191a910a872e95ddfce27a91cebc57dd | /GrfSetTextMode.cpp | c8eab66ef41ab112f2812020cf2e081fa2badec8 | []
| no_license | canercandan/codeworker | 7c9871076af481e98be42bf487a9ec1256040d08 | a68851958b1beef3d40114fd1ceb655f587c49ad | refs/heads/master | 2020-05-31T22:53:56.492569 | 2011-01-29T19:12:59 | 2011-01-29T19:12:59 | 1,306,254 | 7 | 5 | null | null | null | null | IBM852 | C++ | false | false | 1,661 | cpp | /* "CodeWorker": a scripting language for parsing and generating text.
Copyright (C) 1996-1997, 1999-2010 CÚdric Lemaire
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
To contact the author: [email protected]
*/
#ifdef WIN32
#pragma warning (disable : 4786)
#endif
#include "ScpStream.h"
#include "CppCompilerEnvironment.h"
#include "CGRuntime.h"
#include "ExprScriptExpression.h"
#include <string>
#include "GrfSetTextMode.h"
namespace CodeWorker {
GrfSetTextMode::~GrfSetTextMode() {
delete _pTextMode;
}
SEQUENCE_INTERRUPTION_LIST GrfSetTextMode::executeInternal(DtaScriptVariable& visibility) {
std::string sTextMode = _pTextMode->getValue(visibility);
return CGRuntime::setTextMode(sTextMode);
}
void GrfSetTextMode::compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_INDENT << "CGRuntime::setTextMode(";
_pTextMode->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ");";
CW_BODY_ENDL;
}
}
| [
"cedric.p.r.lemaire@28b3f5f3-d42e-7560-b87f-5f53cf622bc4"
]
| [
[
[
1,
49
]
]
]
|
106884d212ea30dc402b77a9cd3e29b293119afc | b3283c88e4ddb5f228f16448be6e9dee3d8cb272 | /ngy313/detail/gtkmm_main.hpp | 6f6174aae2f0fddcf6faf2b7debfa0e75569753e | [
"BSD-3-Clause",
"BSL-1.0"
]
| permissive | nagoya313/ngy313 | ae386c84a4d3b5b68d5e172b32de9cd0fe90cf5c | 7c93a3edf69080559049d5e759a4db1be5e1e2fd | refs/heads/master | 2021-01-10T19:09:18.562953 | 2011-07-27T17:12:19 | 2011-07-27T17:12:19 | 1,025,796 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,306 | hpp | #ifndef NGY313_DETAIL_GTKMM_MAIN_HPP_
#define NGY313_DETAIL_GTKMM_MAIN_HPP_
#include <cstdint>
#include <exception>
#include <boost/noncopyable.hpp>
#include <gtkmm.h>
#include <ngy313/detail/gtkmm_initializer.hpp>
namespace ngy313 { namespace detail {
class gtkmm_main : boost::noncopyable {
public:
gtkmm_main() : exception_() {
gtkmm_initializer init;
}
template <typename Pred>
int run(Pred pred) {
Glib::add_exception_handler(
sigc::mem_fun(this, >kmm_main::error_handler));
const main_loop<Pred> update(pred);
Glib::signal_timeout().connect(
sigc::mem_fun(&update, &main_loop<Pred>::update), 16);
Gtk::Main::run();
if (exception_) {
std::rethrow_exception(exception_);
}
return 0;
}
static void quit() {
Gtk::Main::quit();
}
static void sleep(std::uint32_t time) {
Glib::usleep(time);
}
private:
void error_handler() {
exception_ = std::current_exception();
quit();
}
template <typename Pred>
class main_loop {
public:
explicit main_loop(Pred pred) : pred_(pred) {}
bool update() const {
pred_();
return true;
}
private:
Pred pred_;
};
std::exception_ptr exception_;
};
}}
#endif
| [
"[email protected]"
]
| [
[
[
1,
63
]
]
]
|
ac6425bf93d35cf71287b0f6e8681bcc1467d6f5 | 09c43e037d720e24e769ef9faa148f1377524c2c | /nil/console.cpp | 86bafa5090de060a0d441badbfc9c0aacce8870e | []
| no_license | goal/qqbot | bf63cf06e4976f16e2f0b8ec7c6cce88782bdf29 | 3a4b5920d5554cc55b6df962d27ebbc499c63474 | refs/heads/master | 2020-07-30T13:57:11.135976 | 2009-06-10T00:13:46 | 2009-06-10T00:13:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 932 | cpp | #include <nil/console.hpp>
#ifdef NIL_WINDOWS
namespace nil
{
namespace console
{
namespace
{
HANDLE handle = ::GetStdHandle(STD_OUTPUT_HANDLE);
}
std::string colour(colour_type foreground, colour_type background)
{
::SetConsoleTextAttribute(handle, static_cast<WORD>((static_cast<ulong>(background) << 4) | static_cast<ulong>(foreground)));
return "";
}
std::string colour(colour_type foreground)
{
return colour(foreground, black);
}
coordinate get_dimensions()
{
::CONSOLE_SCREEN_BUFFER_INFO console_info;
if(::GetConsoleScreenBufferInfo(handle, &console_info) == 0)
throw nil::exception("Failed to retrieve console dimensions");
coordinate output;
::COORD dimensions = console_info.dwMaximumWindowSize;
output.x = static_cast<long>(dimensions.X);
output.y = static_cast<long>(dimensions.Y);
return output;
}
}
}
#endif
| [
"akirarat@ba06997c-553f-11de-8ef9-cf35a3c3eb08"
]
| [
[
[
1,
39
]
]
]
|
a30d7e9326aa71a3c255bb3c5befe5d32a1261b7 | 3387244856041685a94b72264d41a80ae35c3f80 | /include/Gui/Window.h | df54df9532f5e121045062dceaf8ec91490cfb25 | []
| no_license | kinfung0602/ogre-tower-defense | 768c9ae0c0972379cfbddf91361cf343b8c76dfb | ce950d36b49ea46e294d936f3cd363bcc73c8468 | refs/heads/master | 2021-01-10T08:22:05.424893 | 2011-07-11T01:32:05 | 2011-07-11T01:32:05 | 53,152,007 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 774 | h | #pragma once
#include "gui_predef.h"
namespace GUI
{
class Window : public Widget
{
public:
Window(const Ogre::String& name);
~Window(void);
// INHERITED FROM WIDGET
virtual void* getContainer();
virtual Ogre::String getName();
void setGeometry(Ogre::Real x, Ogre::Real y, Ogre::Real width, Ogre::Real height);
void setSize(Ogre::Real width, Ogre::Real height);
void setPosition(Ogre::Real x, Ogre::Real y);
void setFullscreen();
void addWidget(Widget* widget);
void removeWidget(Widget* widget);
void show();
void hide();
bool isVisible();
private:
Window(void) {}
private:
class p_Window;
p_Window* p;
Widgets mWidgets;
};
} // namespace GUI | [
"[email protected]"
]
| [
[
[
1,
37
]
]
]
|
84070aea190c6a1538374cc4f2538f2e4becfa1a | 5fb9b06a4bf002fc851502717a020362b7d9d042 | /developertools/GumpEditor/codeedit/WordlistDlg.cpp | 15b710851b5a7ce603020b646b58910e6df3efaa | [
"LicenseRef-scancode-warranty-disclaimer"
]
| no_license | bravesoftdz/iris-svn | 8f30b28773cf55ecf8951b982370854536d78870 | c03438fcf59d9c788f6cb66b6cb9cf7235fbcbd4 | refs/heads/master | 2021-12-05T18:32:54.525624 | 2006-08-21T13:10:54 | 2006-08-21T13:10:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,675 | cpp | // WordlistDlg.cpp: Implementierungsdatei
//
#include "stdafx.h"
#include "../GumpEditor.h"
#include "WordlistDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Dialogfeld CWordlistDlg
CWordlistDlg::CWordlistDlg(CWnd* pParent /*=NULL*/)
: CDialog(CWordlistDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CWordlistDlg)
m_strWordlistNumber = _T("");
m_strKeywords = _T("and and_eq asm auto bitand bitor bool break "
"case catch char class compl const const_cast continue default delete do double dynamic_cast "
"else enum explicit export extern false float for friend goto if inline int long"
"mutable namespace new not not_eq operator or or_eq "
"private protected public register reinterpret_cast return "
"short signed sizeof static static_cast struct switch "
"template this throw true try typedef typeid typename "
"union unsigned using virtual void volatile wchar_t while xor xor_eq");
//}}AFX_DATA_INIT
}
void CWordlistDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CWordlistDlg)
DDX_CBString(pDX, IDC_WORDLISTNO, m_strWordlistNumber);
DDX_Text(pDX, IDC_KEYWORDS, m_strKeywords);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CWordlistDlg, CDialog)
//{{AFX_MSG_MAP(CWordlistDlg)
// HINWEIS: Der Klassen-Assistent f?t hier Zuordnungsmakros f? Nachrichten ein
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen f? Nachrichten CWordlistDlg
| [
"sience@a725d9c3-d2eb-0310-b856-fa980ef11a19"
]
| [
[
[
1,
52
]
]
]
|
37001e394f09878cc110c55db2ced2427eae886b | d411188fd286604be7670b61a3c4c373345f1013 | /zomgame/ZGame/ranged_attack_event.cpp | d8f1f48d2be29c3125e55ccb296ea9ee867caae3 | []
| no_license | kjchiu/zomgame | 5af3e45caea6128e6ac41a7e3774584e0ca7a10f | 1f62e569da4c01ecab21a709a4a3f335dff18f74 | refs/heads/master | 2021-01-13T13:16:58.843499 | 2008-09-13T05:11:16 | 2008-09-13T05:11:16 | 1,560,000 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,754 | cpp | #include "ranged_attack_event.h"
#include "game.h"
RangedAttackEvent::RangedAttackEvent(Player *_player, Coord *_targetLoc)
: player(_player), targetLoc(_targetLoc), Event(RANGED_ATTACK) {
}
Message* RangedAttackEvent::resolve() {
Message* msg = new Message();
char buf[128];
Attackable* defender = NULL;
MapBlock* block;
vector<Coord>* ray = Game::getInstance()->getRay(player->getLoc(), targetLoc);
if (!ray) {
sprintf_s(&buf[0], 128, "Stop shooting yourself.");
msg->setMsg(buf);
return 0;
}
// im an idiot and the ray list always includes the player, sigh
unsigned int i = 1;
// find the first thing we hit
do {
block = Game::getInstance()->getMap()->getBlockAt(&(ray->at(i)));
if (block->hasEntities()) {
defender = block->getTopEntity();
break;
} else if (block->hasProps()) {
if (!block->getTopProp()->isPassable()) {
defender = block->getTopProp();
break;
}
}
i++;
} while (i < ray->size());
// if we hit something
if (defender) {
if (player->getEqRngWeapon()) {
// damage the defender
int dmg = player->getEqRngWeapon()->getDamage();
defender->getHealth()->changeCurValueBy(-dmg);
// check if it's dead
if (defender->getHealth()->getCurValue() <= 0) {
// remove entity from map
if (block->hasEntities()) {
block->removeEntity(block->getTopEntity());
defender->getHealth()->changeCurValueBy(defender->getHealth()->getMaxValue());
} else if (block->hasProps()) {
block->removeProp(block->getTopProp());
}
// add debris to map
Game::getInstance()->addEvent(EventFactory::createSpawnItemEvent(defender->destroy(), &ray->at(i), 0));
sprintf_s(&buf[0], 128, "You kill the %s.", static_cast<Entity*>(defender)->getName().c_str());
player->getSkill(skill_list.getSkillID(player->getEqRngWeapon()->getWTypeString()))->raiseExperience(rand() % 2 + 1);
} else {
sprintf_s(&buf[0], 128, "You shot a %s with your %s. It has %d health left.",
static_cast<Entity*>(defender)->getName().c_str(), player->getEqRngWeapon()->getName().c_str(), defender->getHealth()->getCurValue());
player->getSkill(skill_list.getSkillID(player->getEqRngWeapon()->getWTypeString()))->raiseExperience(rand() % 1);
}
} else {
sprintf_s(&buf[0], 128, "You have nothing to shoot with.");
}
} else {
if (player->getEqRngWeapon()) {
sprintf_s(&buf[0], 128, "Your shot hits the ground.");
player->getSkill(skill_list.getSkillID(player->getEqRngWeapon()->getWTypeString()))->raiseExperience(rand() % 1 + 100);
} else {
sprintf_s(&buf[0], 128, "You have no ranged weapon equipped.");
}
}
msg->setMsg(&buf[0]);
return msg;
} | [
"krypes@9b66597e-bb4a-0410-bce4-15c857dd0990",
"nicholasbale@9b66597e-bb4a-0410-bce4-15c857dd0990"
]
| [
[
[
1,
41
],
[
44,
44
],
[
46,
54
],
[
59,
59
],
[
63,
68
],
[
72,
72
],
[
74,
78
]
],
[
[
42,
43
],
[
45,
45
],
[
55,
58
],
[
60,
62
],
[
69,
71
],
[
73,
73
]
]
]
|
a0e08f502926a7f379987ffc08e89d92d660a3d3 | 9a48be80edc7692df4918c0222a1640545384dbb | /Libraries/Boost1.40/libs/asio/test/basic_deadline_timer.cpp | 3b07f0d5f93d4691af18f73e06de2c7afd81f17b | [
"BSL-1.0"
]
| permissive | fcrick/RepSnapper | 05e4fb1157f634acad575fffa2029f7f655b7940 | a5809843f37b7162f19765e852b968648b33b694 | refs/heads/master | 2021-01-17T21:42:29.537504 | 2010-06-07T05:38:05 | 2010-06-07T05:38:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 751 | cpp | //
// basic_deadline_timer.cpp
// ~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
//
// Disable autolinking for unit tests.
#if !defined(BOOST_ALL_NO_LIB)
#define BOOST_ALL_NO_LIB 1
#endif // !defined(BOOST_ALL_NO_LIB)
// Test that header file is self-contained.
#include <boost/asio/basic_deadline_timer.hpp>
#include "unit_test.hpp"
test_suite* init_unit_test_suite(int, char*[])
{
test_suite* test = BOOST_TEST_SUITE("basic_deadline_timer");
test->add(BOOST_TEST_CASE(&null_test));
return test;
}
| [
"metrix@Blended.(none)"
]
| [
[
[
1,
26
]
]
]
|
e5ab06c849cb6a0ca59bf1b9419916d2cb5cad4d | 160e08f968425ae7b8e83f7381c617906b4e9f18 | /TimeServices.Engine.Cuda/Engine.h | da072adfe3bc8cb6f175973abe37358a1773d851 | []
| no_license | m3skine/timeservices | 0f6a938a25a49a0cad884e2ae9fb1fff4a8a08fe | 1efca945a2121cd7f45c05387503ea8ef66541e6 | refs/heads/master | 2020-04-10T20:06:24.326180 | 2010-04-21T01:12:44 | 2010-04-21T01:12:44 | 33,272,683 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,108 | h | #pragma once
#include "Core\CuContext.h"
using namespace System;
namespace TimeServices { namespace Engine {
using namespace Core;
class Engine
{
private:
unsigned long _timesliceIndex;
bool _rebuildWorkingFractions;
CuContext _context;
public:
Engine(CuContext context)
: _context(context), _timesliceIndex(0) { }
void EvaluateFrame(__int64 time)
{
while (true)
{
// exit if frame completed
if (time <= 0)
return;
if (Foo() == 0)
{
// no fractions available, advance a whole time
_rebuildWorkingFractions = true;
time -= (long)TimePrecision::TimeScaler;
} else {
unsigned long lastFractionTime = 0;
// advance time
_rebuildWorkingFractions = true;
time -= (long)(TimePrecision::TimeScaler - lastFractionTime);
}
// next slice
_timesliceIndex++;
if (_timesliceIndex >= EngineSettings::MaxTimeslices)
{
_timesliceIndex = 0;
//DehibernateAnyValues();
}
}
}
int Foo() { return 0; }
};
static Engine s_engine(s_context);
}}
| [
"Moreys@localhost"
]
| [
[
[
1,
49
]
]
]
|
ede07373994dc6ae19ce529ab2ae5b8055bba7b6 | 86c8c65dd5d7c07b46f134f6df76d5127e9428ff | /参考/ghy/Code/mipt034_WD.cpp | 519551f8470cfb115dfab0365a41fc8f4a218adf | []
| no_license | kyokey/MIPT | 2d2fc233475e414b33fe889594929be6af696b92 | f0dcc64731deaf5d0f0949884865216c15c15dbe | refs/heads/master | 2020-04-27T09:10:48.472859 | 2011-01-04T16:35:26 | 2011-01-04T16:35:26 | 1,219,926 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,740 | cpp | /*
login: Majia
password: fAf340u
*/
#include<cstdio>
struct point{
double x,y;
}a[110];
long n;
double h,ans;
void init()
{
scanf("%ld%lf",&n,&h);
for (long i=1;i<=n+1;i++) scanf("%lf%lf",&a[i].x,&a[i].y);
h=h*(a[n+1].x-a[1].x);
a[n+2].x=a[n+1].x;a[n+2].y=1e50;
a[0].x=a[1].x;a[0].y=1e50;
n=n+2;
}
long _highest(long l,long r)
{
long k=l+1;
for (long i=l+1;i<r;i++)
if (a[i].y>a[k].y) k=i;
return k;
}
long _lowest(long l,long r)
{
long k=l+1;
for (long i=l+1;i<r;i++)
if (a[i].y<a[k].y) k=i;
return k;
}
double _min(double x,double y)
{
return x>y?y:x;
}
double _area(long l,long r)
{
double area=0,min=_min(a[l].y,a[r].y);
if (r-l<=1) return 0;
for (long i=l+1;i<r-1;i++)
area=area+(a[i+1].x-a[i].x)*(min-a[i].y+min-a[i+1].y)/2;
if (a[l].y>min+1e-8){
area=area+(a[l+1].x-a[l].x)*(a[l].y-a[l+1].y)/2*(min-a[l+1].y)*(min-a[l+1].y)/(a[l].y-a[l+1].y)/(a[l].y-a[l+1].y);
area=area+(a[r].x-a[r-1].x)*(min-a[r-1].y+min-a[r].y)/2;
}
else if (a[r].y>min){
area=area+(a[r].x-a[r-1].x)*(a[r].y-a[r-1].y)/2*(min-a[r-1].y)*(min-a[r-1].y)/(a[r].y-a[r-1].y)/(a[r].y-a[r-1].y);
area=area+(a[l+1].x-a[l].x)*(min-a[l].y+min-a[l+1].y)/2;
}
return area;
}
double _crossl(double h,point p1,point p2)
{
return p2.x-(h-p2.y)/(p1.y-p2.y)*(p2.x-p1.x);
}
double _crossr(double h,point p1,point p2)
{
return (h-p1.y)/(p2.y-p1.y)*(p2.x-p1.x)+p1.x;
}
void solve(long l,long r,double h)
{
long highest=_highest(l,r);
long lowest=_lowest(l,r);
double height=0,aa=a[highest].y;
double ll=_crossl(aa,a[l],a[l+1]),rr=_crossr(aa,a[r-1],a[r]);
aa=rr-ll;
double max=a[l].y,min=a[highest].y,mid;
while (max-min>1e-7){
mid=(max+min)/2;
ll=_crossl(mid,a[l+1],a[l]),rr=_crossr(mid,a[r-1],a[r]);
if ((rr-ll+aa)*(mid-a[highest].y)/2>h) max=mid;
else min=mid;
}
height=mid;
if (height-a[lowest].y>ans) ans=height-a[lowest].y;
}
void work(long l,long r,double h)
{
if (l>=r-1) return;
if (l>=r-2){
solve(l,r,h);
return;
}
long highest=_highest(l,r);
double area1=_area(l,highest),area2=_area(highest,r);
double h1=h*(a[highest].x-a[l].x)/(a[r].x-a[l].x),h2=h*(a[r].x-a[highest].x)/(a[r].x-a[l].x);
if (h1+h2<area1+area2){
if (h1>area1){
solve(l,highest,0);
work(highest,r,h2+h1-area1);
}
else if (h2>area2){
solve(highest,r,0);
work(l,highest,h1+h2-area2);
}
else{
work(l,highest,h1);
work(highest,r,h2);
}
}
else solve(l,r,h-area1-area2);
}
int main()
{
freopen("P034.in","r",stdin);
freopen("out.txt","w",stdout);
init();
if (h==0) printf("0.0000\n");
else{
work(0,n,h);
printf("%0.4lf\n",ans);
}
return 0;
}
| [
"pq@pq-laptop.(none)"
]
| [
[
[
1,
125
]
]
]
|
b9358aea252168ad7da58dc3c8dc9c4dd1fae426 | f4bb9b5cf99f47f501ded072558bf3a44a45e304 | /HDAPS_Client.cpp | 2ba77c68457ecdf1fbced6a454349d1433845561 | []
| no_license | rvsjoen/hdaps-client | bbc5d70a7749bdc33bf8d40083808ffede0709e9 | f12e8e7e819ca9c1a39e93af29bc8a2761659b87 | refs/heads/master | 2021-01-02T22:49:54.344874 | 2011-07-08T09:31:19 | 2011-07-08T09:31:19 | 2,017,107 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 395 | cpp | #include <QApplication>
#include <QtOpenGL>
#include <QtNetwork>
#include "HDAPS_GLWidget.h"
#include "HDAPS_NetworkListener.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
HDAPS_GLWidget glw;
HDAPS_NetworkListener nwl;
QObject::connect(&nwl, SIGNAL(updateRecieved(int,int)), &glw, SLOT(updatePosition(int, int)));
glw.show();
return app.exec();
}
| [
"[email protected]"
]
| [
[
[
1,
17
]
]
]
|
f06ba4045b4fa882330830331b894ee40f2e8294 | c3531ade6396e9ea9c7c9a85f7da538149df2d09 | /Param/src/ModelMesh/MeshModelKernel.h | 06cb0e4b76208d117a41e3f3306a03f8f097e502 | []
| no_license | feengg/MultiChart-Parameterization | ddbd680f3e1c2100e04c042f8f842256f82c5088 | 764824b7ebab9a3a5e8fa67e767785d2aec6ad0a | refs/heads/master | 2020-03-28T16:43:51.242114 | 2011-04-19T17:18:44 | 2011-04-19T17:18:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,861 | h | /* ================== Library Information ================== */
// [Name]
// MeshLib Library
//
// [Developer]
// Xu Dong
// State Key Lab of CAD&CG, Zhejiang University
//
// [Date]
// 2005-08-05
//
// [Goal]
// A general, flexible, versatile and easy-to-use mesh library for research purpose.
// Supporting arbitrary polygonal meshes as input, but with a
// primary focus on triangle meshes.
/* ================== File Information ================== */
// [Name]
// MeshModelKernel.h
//
// [Developer]
// Xu Dong
// State Key Lab of CAD&CG, Zhejiang University
//
// [Date]
// 2005-08-05
//
// [Goal]
// Defining the kernel components of the mesh model
//
// This class includes four kernel components - vertex, face, edge(optional) and model components.
// This class is responsible for the kernel data storage and component state information
#include "../Common/Utility.h"
#include <vector>
#include <string>
#include <iostream>
#pragma once
/* ================== Kernel Element Flags ================== */
// General Flags
#define FLAG_INVALID 0X00000001
#define FLAG_HIGHLIGHTED 0X00000002
#define FLAG_SELECTED 0X00000004
#define FLAG_VISITED 0X00000008
#define FLAG_USER1 0X00000010
#define FLAG_USER2 0X00000020
#define FLAG_USER3 0X00000040
#define FLAG_USER4 0X00000080
// Vertex Flags
#define VERTEX_FLAG_ISOLATED 0X00000100
#define VERTEX_FLAG_MANIFOLD 0X00000200
#define VERTEX_FLAG_BOUNDARY 0X00000400
// Face Flags
#define FACE_FLAG_BOUNDARY 0X00000100
#define FACE_FLAG_MANIFOLD 0X00000200
// Edge Flags
#define EDGE_FLAG_BOUNDARY 0X00000100
#define EDGE_FLAG_MANIFOLD 0X00000200
// Model Flags
#define MODEL_FLAG_TRIMESH 0X00000100
#define MODEL_FLAG_QUADMESH 0X00000200
#define MODEL_FLAG_GENERALMESH 0X00000400
#define MODEL_FLAG_MANIFOLD 0X00000800
// Model Type
#define MODEL_TYPE_POINT_CLOUD 0X00000001
#define MODEL_TYPE_POLYGON_SOAP 0X00000002
/* ================== Kernel Element - Mesh Vertex Information ================== */
class VertexInfo
{
private:
// The following properties (arrays) are one-for-each-vertex
CoordArray m_Coord; // Vertex coordinate array
NormalArray m_Normal; // Vertex normal array
ColorArray m_Color; // Vertex color array
TexCoordArray m_TexCoord; // Vertex texture coordinate array
FlagArray m_Flag; // Vertex 32-bit flag array
PolyIndexArray m_AdjFaces; // Vertex adjacent face-index array
PolyIndexArray m_AdjVertices; // Vertex adjacent vertex-index array
PolyIndexArray m_AdjEdges; // Vertex adjacent half-edge-index array
CurvatureArray m_Curvatures; // Vertex curvature array
int m_nVertices;
public:
// Constructor
VertexInfo();
// Destructor
~VertexInfo();
// Initializer
void ClearData();
// Get/Set functions
CoordArray& GetCoord() { return m_Coord; }
NormalArray& GetNormal() { return m_Normal; }
ColorArray& GetColor() { return m_Color; }
TexCoordArray& GetTexCoord() { return m_TexCoord; }
FlagArray& GetFlag() { return m_Flag; }
PolyIndexArray& GetAdjFaces() { return m_AdjFaces; }
PolyIndexArray& GetAdjVertices() { return m_AdjVertices; }
PolyIndexArray& GetAdjEdges() { return m_AdjEdges; }
CurvatureArray& GetCurvatures() { return m_Curvatures; }
};
/* ================== Kernel Element - Mesh Face Information ================== */
class FaceInfo
{
private:
// The following properties (arrays) are one-for-each-face
PolyIndexArray m_Index; // Face vertex-index array
NormalArray m_Normal; // Face normal array
ColorArray m_Color; // Face color array
PolyTexCoordArray m_TexCoord; // Face vertex-texture-coordinate array
FlagArray m_Flag; // Face 32-bit flag array
CoordArray m_FaceBaryCenter; // the barycenter of each face.
DoubleArray m_FaceArea;
PolyIndexArray m_TexIndex; // Face vertex-texture-index array
int m_nFaces;
public:
// Constructor
FaceInfo();
// Destructor
~FaceInfo();
// Initializer
void ClearData();
// Get/Set functions
PolyIndexArray& GetIndex() { return m_Index; }
NormalArray& GetNormal() { return m_Normal; }
ColorArray& GetColor() { return m_Color; }
PolyTexCoordArray& GetTexCoord() { return m_TexCoord; }
FlagArray& GetFlag() { return m_Flag; }
CoordArray& GetBaryCenter() { return m_FaceBaryCenter; }
DoubleArray& GetFaceArea() { return m_FaceArea; }
PolyIndexArray& GetTexIndex() { return m_TexIndex; }
};
/* ================== Kernel Element - Mesh Edge Information ================== */
class EdgeInfo
{
private:
PolyIndexArray m_VtxIndex; // Edge vertex-index array
ColorArray m_Color; // Edge color array
FlagArray m_Flag; // Edge 32-bit flag array
DoubleArray m_DihedralAngle; // the dihedral angle of each edge.
PolyIndexArray m_FaceIndex; // Edge face-index array
int m_nHalfEdges;
public:
// Constructor
EdgeInfo();
// Destructor
~EdgeInfo();
// Initializer
void ClearData();
// Get/Set functions
PolyIndexArray& GetVertexIndex() { return m_VtxIndex; }
ColorArray& GetColor() { return m_Color; }
FlagArray& GetFlag() { return m_Flag; }
DoubleArray& GetDihedralAngle() {return m_DihedralAngle;}
PolyIndexArray& GetFaceIndex() {return m_FaceIndex;}
};
/* ================== Kernel Element - Mesh Model Information ================== */
class ModelInfo
{
private:
Flag m_Flag; // Model 32-bit flag
std::string m_FileName; // File name of the mesh model (Path + Tiltle + Ext)
int m_Type; // Model type - Point cloud or Polygon soap
Color m_Color; // Model color
int m_nVertices; // Number of valid vertices
int m_nFaces; // Number of valid faces
int m_nHalfEdges; // Number of valid half edges
int m_nBoundaries; // Number of boundaries
int m_nComponents; // Number of connected components
Coord m_BoxMin, m_BoxMax, m_BoxDim;
Coord m_SphereCenter;
double m_SphereRadius;
double m_AvgEdgeLength;
double m_AvgFaceArea;
PolyIndexArray m_Boundaries; // Boundary vertex loop
Utility util;
public:
// Constructor
ModelInfo();
// Destructor
~ModelInfo();
// Initializer
void ClearData();
// Queries
Flag& GetFlag() { return m_Flag; }
std::string GetFileName() { return m_FileName; }
void SetFileName(std::string filename);
int GetType() { return m_Type; }
void SetType(int type) { m_Type = type; }
Color GetColor() { return m_Color; }
void SetColor(Color color) { m_Color = color; }
int GetVertexNum() { return m_nVertices; }
void SetVertexNum(int num) { m_nVertices = num; }
int GetFaceNum() { return m_nFaces; }
void SetFaceNum(int num) { m_nFaces = num; }
int GetHalfEdgeNum() { return m_nHalfEdges; }
void SetHalfEdgeNum(int num) { m_nHalfEdges = num; }
int GetBoundaryNum() { return m_nBoundaries; }
void SetBoundaryNum(int num) { m_nBoundaries = num; }
int GetComponentNum() { return m_nComponents; }
void SetComponentNum(int num) { m_nComponents = num; }
void GetBoundingBox(Coord& BoxMin, Coord& BoxMax, Coord& BoxDim) { BoxMin = m_BoxMin; BoxMax = m_BoxMax; BoxDim = m_BoxDim; }
void SetBoundingBox(Coord BoxMin, Coord BoxMax, Coord BoxDim) { m_BoxMin = BoxMin; m_BoxMax = BoxMax; m_BoxDim = BoxDim; }
void GetBoundingSphere(Coord& Center, double& radius) { Center = m_SphereCenter; radius = m_SphereRadius; }
void SetBoundingSphere(Coord Center, double Radius) { m_SphereCenter = Center; m_SphereRadius = Radius; }
double GetAvgEdgeLength() { return m_AvgEdgeLength; }
void SetAvgEdgeLength(double length) { m_AvgEdgeLength = length; }
double GetAvgFaceArea() { return m_AvgFaceArea; }
void SetAvgFaceArea(double area) { m_AvgFaceArea = area; }
PolyIndexArray& GetBoundary() { return m_Boundaries; }
// Predictions
bool IsTriMesh(); // Whether the model is a triangle mesh (only containing triangles)
bool IsQuadMesh(); // Whether the model is a quadrangle mesh (only containing quadangles)
bool IsGeneralMesh(); // Whether the model is a general mesh (the rest, not a tri- or quad- one)
bool IsClosed(); // Whether the model is a closed one (no boundaries)
bool IsManifold(); // Whether the model is a 2-manifold one (locally disc-like)
bool IsTriManifold(); // Whether the model is a 2-mainfold triangle mesh
bool IsPatch(); // Whether the model is a patch (single boundary, 2-manifold)
};
/* ================== Mesh Model Kernel ================== */
class MeshModelKernel
{
private:
// Basic Mesh Model Kernel = Vertex Coord Array + Face Index Array
VertexInfo m_VertexInfo;
FaceInfo m_FaceInfo;
EdgeInfo m_EdgeInfo;
ModelInfo m_ModelInfo;
Utility util;
public:
// Constructor & Destructor
MeshModelKernel();
virtual ~MeshModelKernel();
// Initializer
void ClearData();
// Get functions
VertexInfo& GetVertexInfo() { return m_VertexInfo; }
EdgeInfo& GetEdgeInfo() { return m_EdgeInfo; }
FaceInfo& GetFaceInfo() { return m_FaceInfo; }
ModelInfo& GetModelInfo() { return m_ModelInfo; }
};
| [
"[email protected]"
]
| [
[
[
1,
318
]
]
]
|
3287c75e6a6fdfc6501d4bac93e31754fb710b7d | 05869e5d7a32845b306353bdf45d2eab70d5eddc | /soft/application/CoolSimulator/CoolSimulator.cpp | 1ccc041250e5a207e53c64295c54e3098c1f190e | []
| no_license | shenfahsu/sc-fix | beb9dc8034f2a8fd9feb384155fa01d52f3a4b6a | ccc96bfaa3c18f68c38036cf68d3cb34ca5b40cd | refs/heads/master | 2020-07-14T16:13:47.424654 | 2011-07-22T16:46:45 | 2011-07-22T16:46:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,030 | cpp | // CoolSimulator.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "CoolSimulator.h"
#include "CoolSimulatorDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCoolSimulatorApp
BEGIN_MESSAGE_MAP(CCoolSimulatorApp, CWinApp)
//{{AFX_MSG_MAP(CCoolSimulatorApp)
//}}AFX_MSG_MAP
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCoolSimulatorApp construction
CCoolSimulatorApp::CCoolSimulatorApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CCoolSimulatorApp object
CCoolSimulatorApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CCoolSimulatorApp initialization
BOOL CCoolSimulatorApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CCoolSimulatorDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
| [
"windyin@2490691b-6763-96f4-2dba-14a298306784"
]
| [
[
[
1,
74
]
]
]
|
514e1fa46c7242d4979357e8799c866d7a3733a0 | 3ec03fa7bb038ea10801d09a685b9561f827928b | /js_curl/stdafx.cpp | 131021a97e249af0389100c9e4596a0eed28d325 | []
| no_license | jbreams/njord | e2354f2013af0d86390ae7af99a419816ee417cb | ef7ff45fa4882fe8d2c6cabfa7691e2243fe8341 | refs/heads/master | 2021-01-24T17:56:32.048502 | 2009-12-15T18:57:32 | 2009-12-15T18:57:32 | 38,331,688 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 294 | cpp | // stdafx.cpp : source file that includes just the standard includes
// js_curl.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| [
"jreams@1c42f586-7543-11de-ba67-499d525147dd"
]
| [
[
[
1,
8
]
]
]
|
25054828b65dbed12d8f7670e8344483f5b553c7 | b4109adcbaa67920bdbc4821c6101781fdefe013 | /Lib/ProcessUtils.cpp | 5f0a1fa60f71764fad7965de901dda1684a2aa4c | []
| no_license | ohio813/darungrim | 3e62e8b9552cc7d23747e6d3c31f73d392cf90ed | 57eec593887a9d8e2ed143ba07221b9afe0fb4e5 | refs/heads/master | 2020-05-31T15:00:44.211311 | 2010-03-30T22:24:20 | 2010-03-30T22:24:20 | 35,200,134 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,692 | cpp | #include <windows.h>
#include <stdio.h>
HANDLE ServerHandle=NULL;
bool StartProcess(LPTSTR szCmdline)
{
//msg("%s: Entry\n",__FUNCTION__);
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInformation;
//msg("%s: Executing [%s] \n",__FUNCTION__,szCmdline);
if(CreateProcess(
NULL,
szCmdline, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&StartupInfo, // Pointer to STARTUPINFO structure
&ProcessInformation) // Pointer to PROCESS_INFORMATION structure
)
{
ServerHandle=ProcessInformation.hProcess;
//msg("%s: ServerHandle=%x\n",__FUNCTION__,ServerHandle);
return TRUE;
}
if(1) //if server process is already up
{
//OpenProcess
ServerHandle=OpenProcess(
PROCESS_ALL_ACCESS,
FALSE,
10656);
//msg("%s: ServerHandle=%x\n",__FUNCTION__,ServerHandle);
}
return FALSE;
}
void *malloc_wrapper(size_t size)
{
if(ServerHandle)
{
return VirtualAllocEx(
ServerHandle,
NULL,
size,
MEM_COMMIT,
PAGE_READWRITE);
}else{
return malloc(size);
}
}
void *realloc(void *memblock,size_t old_size,size_t size)
{
if(ServerHandle)
{
LPVOID ret_mem=VirtualAllocEx(
ServerHandle,
NULL,
size,
MEM_COMMIT,
PAGE_READWRITE);
if(memblock && old_size>0)
{
memcpy(ret_mem,memblock,old_size);
VirtualFree(memblock,
0,
MEM_RELEASE);
}
return ret_mem;
}else{
return realloc(memblock,size);
}
}
char *WriteToTemporaryFile(const char *format,...)
{
#define BUFSIZE 512
HANDLE hTempFile;
char szTempName[BUFSIZE];
char lpPathBuffer[BUFSIZE];
DWORD dwBufSize=BUFSIZE;
DWORD dwRetVal;
DWORD uRetVal;
// Get the temp path.
dwRetVal=GetTempPath(dwBufSize, // length of the buffer
lpPathBuffer); // buffer for path
if(dwRetVal > dwBufSize ||(dwRetVal==0))
{
printf("GetTempPath failed with error %d.\n",GetLastError());
return NULL;
}
// Create a temporary file.
uRetVal=GetTempFileName(lpPathBuffer,// directory for tmp files
"DarunGrim", // temp file name prefix
0, // create unique name
szTempName); // buffer for name
if(uRetVal==0)
{
printf("GetTempFileName failed with error %d.\n",
GetLastError());
return NULL;
}
// Create the new file to write the upper-case version to.
hTempFile=CreateFile((LPTSTR)szTempName,// file name
GENERIC_READ | GENERIC_WRITE,// open r-w
0, // do not share
NULL, // default security
CREATE_ALWAYS, // overwrite existing
FILE_ATTRIBUTE_NORMAL,// normal file
NULL); // no template
if(hTempFile==INVALID_HANDLE_VALUE)
{
printf("CreateFile failed with error %d.\n",GetLastError());
return NULL;
}
va_list args;
va_start(args,format);
char Contents[1024]={0,};
_vsnprintf(Contents,sizeof(Contents)/sizeof(char),format,args);
va_end(args);
DWORD dwBytesWritten;
BOOL fSuccess=WriteFile(hTempFile,
Contents,
strlen(Contents),
&dwBytesWritten,
NULL);
if(!fSuccess)
{
printf("WriteFile failed with error %d.\n",GetLastError());
return NULL;
}
CloseHandle(hTempFile);
return _strdup(szTempName);
}
void Execute(bool Wait,const char *format,...)
{
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInformation;
ZeroMemory(&StartupInfo,sizeof(StartupInfo));
StartupInfo.cb=sizeof(StartupInfo);
ZeroMemory(&ProcessInformation,sizeof(ProcessInformation));
va_list args;
va_start(args,format);
char szCmdline[1024]={0,};
_vsnprintf(szCmdline,sizeof(szCmdline)/sizeof(char),format,args);
va_end(args);
if(CreateProcess(
NULL,
szCmdline, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&StartupInfo, // Pointer to STARTUPINFO structure
&ProcessInformation) // Pointer to PROCESS_INFORMATION structure
)
{
if(Wait)
{
// Wait until child process exits.
WaitForSingleObject(ProcessInformation.hProcess,INFINITE);
}
// Close process and thread handles.
CloseHandle(ProcessInformation.hProcess);
CloseHandle(ProcessInformation.hThread);
}
}
| [
"[email protected]@6cf4af4c-d3a3-11de-8184-f791cb96e2ed"
]
| [
[
[
1,
185
]
]
]
|
0614f8ed87392dbfa9d358ad848aa3138791371c | 8aa65aef3daa1a52966b287ffa33a3155e48cc84 | /Source/Test/Test.cpp | ac43f61febc7e46c814fc078de2d9e7a85ddf2eb | []
| no_license | jitrc/p3d | da2e63ef4c52ccb70023d64316cbd473f3bd77d9 | b9943c5ee533ddc3a5afa6b92bad15a864e40e1e | refs/heads/master | 2020-04-15T09:09:16.192788 | 2009-06-29T04:45:02 | 2009-06-29T04:45:02 | 37,063,569 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,622 | cpp | // Test.cpp : Defines the entry point for the console application.
//
#include "Includes.h"
#include "Common/Logger.h"
#include "Common/Thread.h"
#include "Common/ThreadLocal.h"
#include "Common/StdCommands.h"
#include "Common/Atomic.h"
#include "Common/ObjectPool.h"
#include "Common/Command.h"
#include "Common/Lazy.h"
using namespace P3D;
using namespace P3D::Graphics;
using namespace P3D::World;
class OpenGLTest :
public RenderWindow
{
TimeCounter fps;
uint frames;
float _fps;
P3D::World::World world;
FlyingCamera* cam;
bool _boost;
bool _firstMove;
Terrain* ter;
SmartPointer<Texture> tex;
public:
OpenGLTest() :
world(Physics::CreatePhysicalWorld())
{ }
virtual void OnInitialize()
{
Graphics::RenderWindow::OnInitialize();
const char* ext = (const char*)glGetString(GL_EXTENSIONS);
SetCursorVisible(false);
SetCursorPosition(400, 300);
_firstMove = true;
{
cam = new FlyingCamera(&world);
QTransform tr;
tr.SetIdentity();
tr.Translation.Set(5, 0, 2500);
cam->SetTransform(tr);
cam->SetFarPlane(10000.0f);
world.AddEntity(cam);
}
{
P3D::World::Box* ground = new P3D::World::Box(&world, 200, 200, 0.5);
QTransform tr;
tr.SetIdentity();
tr.Translation.Set(0, 0, 2400);
ground->SetTransform(tr);
world.AddEntity(ground);
}
P3D::World::CompoundEntity* compound = new P3D::World::CompoundEntity(&world);
QTransform tr;
tr.SetIdentity();
tr.Translation.Set(0, 0, 2500.0f);
tr.Rotation.SetEulerAngles(1.0, 2.0, 1.0);
compound->SetTransform(tr);
for (int i = 0; i < 10; i++)
{
P3D::World::Box* box = new P3D::World::Box(&world, 0.5f, 0.5f, 0.5f);
box->SetMass(1.0);
QTransform tr;
tr.SetIdentity();
tr.Translation.Set(0, 0, 1.0f * i + 2.0f);
tr.Rotation.SetAxisAngle(Vector::GetRandomVector(), 1.0);
box->SetTransform(tr);
compound->AddEntity(box);
}
world.AddEntity(compound);
tex.Attach(GetTextureManager()->LoadTexture(L"SceneTexture.jpg"));
ter = new Terrain(&world);
ter->Load(L"Scene2.raw", 512, 512, 16.0f, 16.0f);
//ter->Load(L"Plain.raw", 256, 256, 4.0f, 4.0f);
world.AddEntity(ter);
glEnable(GL_DEPTH_TEST);
//glEnable(GL_LIGHTING);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_LIGHT0);
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
fps.Reset();
_fps = 0;
Graphics::InitializeText();
}
void CalculateFPS()
{
static float time = 0;
if (fps.GetTotalTime() > 250)
{
time += (float)fps.GetTotalTime();
_fps = (float)frames*4;
frames = 0;
fps.Reset();
}
frames++;
}
virtual void OnDeinitialize()
{
Graphics::RenderWindow::OnDeinitialize();
}
virtual void OnRender()
{
fps.Tick();
double tick = fps.GetLastTick() / 1000.0;
CalculateFPS();
world.Update();
glEnable(GL_TEXTURE_2D);
tex->Bind();
world.Render(cam);
tex->Unbind();
glDisable(GL_TEXTURE_2D);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 800, 600, 0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_LIGHTING);
glColor3f(1.0f, 1.0f, 1.0f);
{
if (_fps > 10000) _fps = 0;
std::ostringstream str;
str << "FPS: " << _fps;
OutputText(10, 20, 0, str.str().c_str());
}
{
std::ostringstream str;
str << "Entities: " << g_EntitiesRendered;
OutputText(10, 40, 0, str.str().c_str());
}
{
std::ostringstream str;
str << "Polygons: " << g_PolygonCounter;
OutputText(10, 60, 0, str.str().c_str());
}
glPopAttrib();
}
virtual void OnKeyDown(SDL_keysym key)
{
if (key.sym == SDLK_ESCAPE)
{
Close();
return;
}
if (key.sym == SDLK_w)
{
cam->Forward(true);
return;
}
if (key.sym == SDLK_s)
{
cam->Backward(true);
return;
}
if (key.sym == SDLK_a)
{
cam->Left(true);
return;
}
if (key.sym == SDLK_d)
{
cam->Right(true);
return;
}
if (key.sym == SDLK_q)
{
cam->Up(true);
return;
}
if (key.sym == SDLK_e)
{
cam->Down(true);
return;
}
if (key.sym == SDLK_LSHIFT)
{
_boost = !_boost;
cam->Boost(_boost);
return;
}
}
virtual void OnKeyUp(SDL_keysym key)
{
if (key.sym == SDLK_w)
{
cam->Forward(false);
return;
}
if (key.sym == SDLK_s)
{
cam->Backward(false);
return;
}
if (key.sym == SDLK_a)
{
cam->Left(false);
return;
}
if (key.sym == SDLK_d)
{
cam->Right(false);
return;
}
if (key.sym == SDLK_q)
{
cam->Up(false);
return;
}
if (key.sym == SDLK_e)
{
cam->Down(false);
return;
}
}
virtual void OnMouseMove(int dx, int dy, int mx, int my)
{
if (_firstMove)
{
_firstMove = false;
return;
}
dx = mx - 400;
dy = my - 300;
if (dx != 0 || dy != 0)
{
Logger logger(L"MouseMove");
SetCursorPosition(400, 300);
cam->Turn(dx / 350.0f, - dy / 350.0f);
}
}
};
int P2DMain()
{
return OpenGLTest().Run();
}
| [
"vadun87@6320d0be-1f75-11de-b650-e715bd6d7cf1"
]
| [
[
[
1,
271
]
]
]
|
033df93e90abde6d9955cbcc8dda2097dfce5bbf | 723202e673511cf9f243177d964dfeba51cb06a3 | /09/oot/epa_labs/l1/src/CDiamond.h | 6957c7569c92db7da904186fbb5ce329a88c1d56 | []
| no_license | aeremenok/a-team-777 | c2ffe04b408a266f62c523fb8d68c87689f2a2e9 | 0945efbe00c3695c9cc3dbcdb9177ff6f1e9f50b | refs/heads/master | 2020-12-24T16:50:12.178873 | 2009-06-16T14:55:41 | 2009-06-16T14:55:41 | 32,388,114 | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 702 | h | #ifndef _CCDIAMOND_H
#define _CCDIAMOND_H
#include "CShape.h"
//фигура
class CDiamond: public CShape{
private:
static int KOLdiamond;
protected:
const int idDiamond;
//длина стороны
double l;
double u; //угол
//re-defined function
virtual ostream& printInfo(ostream&os) const;
public:
//constructors & desctuctors
CDiamond(double x, double y, double l, double u);
//constructors & desctuctors
~CDiamond();
//getters
const double getL() const;
const double getU() const;
//setters
void setL(double newL);
void setU(double newU);
//pure virtual function
double S()const;
double P()const;
};
#endif
| [
"emmanpavel@9273621a-9230-0410-b1c6-9ffd80c20a0c"
]
| [
[
[
1,
45
]
]
]
|
01cbdad8f1b629c905cd34f462043fdedfef0e50 | ce262ae496ab3eeebfcbb337da86d34eb689c07b | /SampleFoundation/PostProcess/SEGaussianBlurHEffect2.h | 9ab2dda6b9a6413f4e0ef6926be1912e4aa1a711 | []
| no_license | pizibing/swingengine | d8d9208c00ec2944817e1aab51287a3c38103bea | e7109d7b3e28c4421c173712eaf872771550669e | refs/heads/master | 2021-01-16T18:29:10.689858 | 2011-06-23T04:27:46 | 2011-06-23T04:27:46 | 33,969,301 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,094 | h | // Swing Engine Version 1 Source Code
// Most of techniques in the engine are mainly based on David Eberly's
// Wild Magic 4 open-source code.The author of Swing Engine learned a lot
// from Eberly's experience of architecture and algorithm.
// Several sub-systems are totally new,and others are re-implimented or
// re-organized based on Wild Magic 4's sub-systems.
// Copyright (c) 2007-2010. All Rights Reserved
//
// Eberly's permission:
// Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2006. All Rights Reserved
//
// 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. The license is available for reading at
// the location:
// http://www.gnu.org/copyleft/lgpl.html
#ifndef Swing_GaussianBlurHEffect2_H
#define Swing_GaussianBlurHEffect2_H
#include "SEShaderEffect.h"
namespace Swing
{
//----------------------------------------------------------------------------
// 说明:专门用于OpenGL ES2 shading language
// 作者:Sun Che
// 时间:20090715
//----------------------------------------------------------------------------
class SEGaussianBlurHEffect2 : public SEShaderEffect
{
SE_DECLARE_RTTI;
SE_DECLARE_NAME_ID;
SE_DECLARE_STREAM;
public:
SEGaussianBlurHEffect2(const std::string& rBaseName);
virtual ~SEGaussianBlurHEffect2(void);
// 根据color buffer尺寸调整texel kernel step.
static void GenerateTexelKernelStep(int iWidth, int iHeight);
protected:
// streaming
SEGaussianBlurHEffect2(void);
virtual void OnLoadPrograms(int iPass, SEProgram* pVProgram,
SEProgram* pPProgram, SEProgram* pGProgram);
// x: 1/width y: 1/height z: direction
static SEVector3f ms_TexelKernelStep;
static bool ms_bUCInitialized;
};
typedef SESmartPointer<SEGaussianBlurHEffect2> SEGaussianBlurHEffect2Ptr;
}
#endif
| [
"[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac"
]
| [
[
[
1,
63
]
]
]
|
7442924716ca311892b646cc580d90966cf331b6 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/LOGINSERVER/LoginProtect.cpp | 125ed09cdd72bfa0594e44b4c95194284e765d57 | []
| no_license | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 37,707 | cpp | // LoginProtect.cpp: implementation of the CLoginProtect class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "LoginProtect.h"
#if __VER >= 15 // __2ND_PASSWORD_SYSTEM
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
namespace NUMPAD
{
u_long uNumPad[1000][10] = {
{ 1, 9, 2, 6, 0, 5, 7, 4, 8, 3 }, { 6, 1, 2, 9, 4, 0, 7, 3, 5, 8 }, { 3, 8, 0, 4, 9, 6, 7, 1, 2, 5 }, { 4, 3, 2, 6, 8, 1, 7, 9, 5, 0 }, { 2, 3, 8, 6, 0, 9, 5, 7, 1, 4 },
{ 7, 3, 1, 2, 8, 6, 5, 0, 9, 4 }, { 8, 0, 1, 4, 5, 6, 7, 2, 9, 3 }, { 9, 7, 8, 2, 5, 0, 3, 6, 4, 1 }, { 3, 1, 8, 9, 6, 7, 4, 2, 5, 0 }, { 2, 9, 1, 4, 7, 5, 0, 6, 8, 3 },
{ 6, 4, 3, 0, 9, 1, 2, 8, 5, 7 }, { 2, 5, 0, 1, 7, 8, 4, 6, 9, 3 }, { 3, 8, 1, 4, 2, 7, 6, 5, 0, 9 }, { 9, 2, 0, 8, 3, 6, 7, 5, 4, 1 }, { 7, 8, 0, 5, 2, 4, 6, 9, 3, 1 },
{ 1, 7, 2, 4, 9, 6, 8, 3, 0, 5 }, { 8, 7, 0, 9, 5, 6, 2, 3, 4, 1 }, { 5, 7, 9, 1, 8, 3, 6, 4, 2, 0 }, { 4, 2, 9, 3, 6, 7, 5, 8, 0, 1 }, { 8, 7, 6, 9, 0, 2, 3, 1, 4, 5 },
{ 2, 9, 1, 0, 6, 8, 5, 7, 3, 4 }, { 8, 6, 0, 9, 3, 7, 4, 1, 5, 2 }, { 9, 2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0, 1, 9, 7, 6, 3, 5 }, { 4, 2, 6, 7, 0, 5, 3, 1, 9, 8 },
{ 2, 8, 0, 6, 5, 9, 1, 3, 4, 7 }, { 5, 0, 4, 1, 7, 3, 2, 6, 8, 9 }, { 3, 5, 7, 4, 6, 2, 9, 1, 0, 8 }, { 3, 9, 0, 4, 5, 1, 7, 8, 2, 6 }, { 7, 1, 0, 6, 4, 5, 8, 9, 3, 2 },
{ 5, 9, 3, 1, 2, 0, 7, 8, 6, 4 }, { 9, 6, 5, 3, 1, 7, 2, 8, 0, 4 }, { 5, 0, 4, 6, 2, 9, 7, 8, 1, 3 }, { 9, 8, 7, 6, 5, 2, 1, 3, 4, 0 }, { 2, 5, 7, 3, 4, 1, 8, 6, 9, 0 },
{ 6, 9, 3, 4, 5, 1, 2, 7, 0, 8 }, { 8, 9, 2, 1, 3, 7, 0, 5, 6, 4 }, { 8, 4, 9, 2, 6, 7, 3, 5, 1, 0 }, { 5, 6, 0, 7, 1, 9, 4, 8, 3, 2 }, { 0, 1, 5, 2, 4, 8, 7, 6, 3, 9 },
{ 9, 4, 5, 3, 7, 6, 0, 1, 8, 2 }, { 7, 3, 5, 6, 4, 2, 0, 9, 8, 1 }, { 7, 4, 2, 3, 0, 5, 1, 8, 6, 9 }, { 9, 6, 1, 4, 0, 7, 5, 8, 2, 3 }, { 6, 2, 5, 7, 3, 1, 0, 9, 4, 8 }
};
}
CLoginProtect::CLoginProtect()
{
}
CLoginProtect::~CLoginProtect()
{
Clear();
}
CLoginProtect* CLoginProtect::GetInstance()
{
static CLoginProtect sLP;
return & sLP;
}
void CLoginProtect::Clear()
{
m_mapCache.clear();
m_mapNumPadId.clear();
}
int CLoginProtect::GetNumPad2PW( u_long idNumPad, u_long uSecretNum )
{
using namespace NUMPAD;
int nPW = INT_MAX;
if( idNumPad <= MAX_NUMPADID && uSecretNum <= MAX_SECRETNUM )
{
u_long uNum1 = uSecretNum / 1000;
u_long uNum2 = ( uSecretNum % 1000 ) / 100;
u_long uNum3 = ( uSecretNum % 100 ) / 10;
u_long uNum4 = uSecretNum % 10;
nPW = ( uNumPad[idNumPad][uNum1] * 1000 ) + ( uNumPad[idNumPad][uNum2] * 100 ) + ( uNumPad[idNumPad][uNum3] * 10 ) + ( uNumPad[idNumPad][uNum4] );
}
return nPW;
}
u_long CLoginProtect::GetNumPadId( DPID dpId )
{
MAP_NUMPAD_ID::iterator it = m_mapNumPadId.find( dpId );
if( it != m_mapNumPadId.end() )
return it->second;
return INT_MAX;
}
u_long CLoginProtect::SetNumPadId( DPID dpId, BOOL bLogin )
{
if( bLogin )
{
m_mapNumPadId.erase( dpId );
return 0;
}
srand( time( NULL ) );
u_long idNumPad = rand() % 1000;
MAP_NUMPAD_ID::iterator it = m_mapNumPadId.find( dpId );
if( it != m_mapNumPadId.end() )
{
while( idNumPad == it->second )
idNumPad = rand() % 1000;
m_mapNumPadId.erase( dpId );
m_mapNumPadId.insert( MAP_NUMPAD_ID::value_type( dpId, idNumPad ) );
}
else
m_mapNumPadId.insert( MAP_NUMPAD_ID::value_type( dpId, idNumPad ) );
return idNumPad;
}
LOGIN_CHECK CLoginProtect::Check( u_long idPlayer )
{
time_t tmCur = time( NULL );
MAP_CACHE::iterator it = m_mapCache.find( idPlayer );
if( it != m_mapCache.end() )
{
if( it->second.nError >= 3 )
{
long nSec = tmCur - it->second.tmError;
if( nSec <= (15 * 60) )
return LOGIN_3TIMES_ERROR;
}
}
return LOGIN_OK;
}
void CLoginProtect::SetError( u_long idPlayer, BOOL bLogin )
{
MAP_CACHE::iterator it = m_mapCache.find( idPlayer );
if( it != m_mapCache.end() )
{
if( bLogin )
m_mapCache.erase( idPlayer );
else
{
++it->second.nError;
it->second.tmError = time( NULL );
}
}
else
{
if( !bLogin )
{
LOGIN_CACHE sCache;
sCache.nError = 1;
sCache.tmError = time( NULL );
m_mapCache.insert( MAP_CACHE::value_type( idPlayer, sCache ) );
}
}
}
#endif // __2ND_PASSWORD_SYSTEM | [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
331
]
]
]
|
30dd60f44d7ce1d5c9e23d03c0ce7b7eab84ae4c | c2426347b183e81f7eba0a61008d5b62b686bada | /TracePage.h | 0ae20c8ac04a5cbdffe0972c111b144a3951c760 | []
| no_license | zephyrer/ftp-mfc | cad97bda7165084460ec265b4430702bf38a055e | 9ed7b2623e24ba523302c03f53515a61d3c7f28b | refs/heads/master | 2021-01-23T06:44:50.496095 | 2010-10-16T02:46:05 | 2010-10-16T02:46:05 | 40,066,779 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 545 | h | #pragma once
//#include "ColorListBox.h"
// CTracePage dialog
class CTracePage : public CDialog
{
DECLARE_DYNAMIC(CTracePage)
public:
CTracePage(CWnd* pParent = NULL); // standard constructor
virtual ~CTracePage();
// void AddTraceLine(int nLevel,LPCTSTR pstrFormat,...);
// Dialog Data
enum { IDD = IDD_PROPPAGE_TRACE };
// CColorListBox m_TraceList;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
afx_msg void OnSize(UINT nType, int cx, int cy);
DECLARE_MESSAGE_MAP()
};
| [
"fjsllzy@16d5555c-4542-f5b6-b58a-99007303009a"
]
| [
[
[
1,
23
]
]
]
|
2394949c3f663f5996c7b50dadc5036f8e3a6a76 | 61bcb936a14064e2a819269d25b5c09b92dad45f | /Reference/EDK_project/code/GUI/HeliosLibrary/stdafx.cpp | d9eddbe0ccdc101234d496a47a47040e681a47cc | []
| no_license | lanxinwoaini/robotic-vision-631 | 47fe73588a5b51296b9ac7fbacd4a553e4fd8e34 | fdb160a8498ec668a32116c655368d068110aba7 | refs/heads/master | 2021-01-10T08:06:58.829618 | 2011-04-20T15:19:06 | 2011-04-20T15:19:06 | 47,861,917 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 213 | cpp | // stdafx.cpp : source file that includes just the standard includes
// HeliosLibrary.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
| [
"[email protected]"
]
| [
[
[
1,
7
]
]
]
|
65812919d5fc929f0267224fd6368afd9392b8e0 | 5234923e1a79e4907336920228e4d4692aa66347 | /CLRBootstrap/CLRBootstrap.cpp | 0048b2b8ea00d77e8e637f41946a5890bc428205 | []
| no_license | FenixTX2/project-helix | 572003c5808f73d0d085b569665c9c214fd75429 | 77ca7b044651ee4f37dcd13d63342af0f78941a9 | refs/heads/master | 2021-01-22T14:44:57.771037 | 2011-09-12T23:45:25 | 2011-09-12T23:45:25 | 2,373,656 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 110 | cpp | // CLRBootstrap.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
| [
"[email protected]"
]
| [
[
[
1,
6
]
]
]
|
991b49de4cc6da2f7e1e5a44f1c3587c658c6e76 | 56c17f756480a02c77aecc69b217c29294f4c180 | /Src/Libs/Rastering/DiamondQbertModel.cpp | c56bd136fa86cbd2bb788cc4fe94aa4890bc8412 | []
| no_license | sangongs/qbert3d | 5fd88b9720b68ca7617a8c5510568911b3dc34c5 | 296b78451b73032e16e64ae1cc4f0200ef7ca734 | refs/heads/master | 2021-01-10T04:02:37.685309 | 2008-09-12T16:13:04 | 2008-09-12T16:13:04 | 46,944,626 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,623 | cpp | #include "StdAfx.h"
#include <string>
#include "MathUtils.h"
#include "Point3D.h"
#include "QbertModel.h"
#include "SimpleControler.h"
#include "QbertBox.h"
#include "QbertGameObject.h"
#include "QbertEnemyObj.h"
#include "DiamondQbertEnemiesFactory.h"
#include "DiamondQbertModel.h"
namespace BGComplete
{
DiamondQbertModel::DiamondQbertModel(int sizeOfDiamond, const std::string& unvisitedBoxName, const std::string& visitedBoxName, const std::string& qbertName,
int * score, int * livesLeft, int * level, int * gainLifeAt, int * addToNextLifeAt, float freeFallAcceleration)
: QbertModel(unvisitedBoxName, visitedBoxName, score, livesLeft, level, gainLifeAt, addToNextLifeAt, freeFallAcceleration), _size(sizeOfDiamond)
{
this;
CreateDiamondStructure(sizeOfDiamond);
SetupQbert(sizeOfDiamond, qbertName);
}
DiamondQbertModel::~DiamondQbertModel(void){}
void DiamondQbertModel::CreateDiamondStructure(int sizeOfDiamond)
{
for (int i = 0, jBorder = sizeOfDiamond - 1; i < sizeOfDiamond; i++, jBorder--)
{
for (int j = -jBorder; j <= jBorder; j++)
{
for (int face = 0; face < 4; face++)
{
bool isPerimetar = false;
if (!i)
{
isPerimetar = true;
if(face == 2) // Draw the 0 level only once; Beware, dosen't draw top and lower levels.
break;
}
if ((j == -jBorder || j == jBorder) && face % 2 == 0) // Boxes between faces has to be drawn once.
continue;
float x = (float)j,
y = ((face & 2) ? -1 : 1) * (float)i,
z = ((face & 1) ? -1 : 1) * (float)(sizeOfDiamond - 1 - i - std::abs(j));
Math::Point3D upDirection(0, (face & 2) ? -1.0f : 1.0f, 0);
InsertBox(Math::Point3D(x, y, z), QbertBox_ptr(new QbertBox(_unvisitedBoxName, face, isPerimetar, x, y, z)));
_boxesUnvisited++;
}
}
}
}
void DiamondQbertModel::SetupQbert(int sizeOfDiamond, const std::string& qbertName)
{
SetQbert(qbertName, _startingBox = _objects->BoxMap.find(Math::Point3D(0.0f , (float)sizeOfDiamond - 1.0f, 0.0f))->second);
_objects->Qbert->SetModel(this);
_objects->Qbert->LastUpDirection = Math::Point3D(0, 1, 0);
_objects->Qbert->LastFaceDirection = Math::Point3D(0, 0, 1);
_objects->Qbert->NextUpDirection = Math::Point3D(0, 1, 0);
_objects->Qbert->NextFaceDirection = Math::Point3D(0, 0, 1);
_objects->Qbert->SetMoveLength(1000, _freeFallAcceleration);
}
void DiamondQbertModel::ReciveInput(const SimpleControler::InputData& inputData)
{
Move(_objects->Qbert, inputData);
CreateEnemies(inputData.DeltaTime);
MoveEnemies(inputData.DeltaTime);
GetAdditionalLife();
}
void DiamondQbertModel::Move(QbertGameObject_ptr object, const SimpleControler::InputData& inputData)
{
if (object->IsDying)
{
object->Scale -= (float)inputData.DeltaTime / (float)object->DyingDuration;
if (object->Scale < 0)
_enemiesToDelete.push_back(boost::static_pointer_cast<QbertEnemyObj>(object));
return;
}
object->Center = object->LastBox->Center + object->LastUpDirection;
object->CurrentFaceDirection = object->LastFaceDirection;
object->CurrentUpDirection = object->LastUpDirection;
if (object->IsMoving)
{
object->Progress += (float)inputData.DeltaTime / (float)object->GetMoveLength();
UpdateCenterOfObject(object);
UpdateFaceAndUpDirections (object);
}
else if (inputData.direction != None) //object in not moving and there is a command to move
{
object->MovingDirection = inputData.direction;
ChangeBox(object);
object->IsMoving = true;
}
if (object->Progress > 1)
EndMovement(object);
}
void DiamondQbertModel::UpdateCenterOfObject(QbertGameObject_ptr object)
{
if (object->IsChangingBox)
{
object->Center += object->GetHorizontalSpeed() * object->Progress * object->NextFaceDirection;
float progress = (object->IsMovingUp) ? 1 - object->Progress : object->Progress;
object->Center += object->LastUpDirection * (
(object->IsMovingUp ? 1 : 0)
+ object->GetVerticalSpeed() * progress
- progress * progress * object->GetFreeAcceleration() * 0.5f);
}
else if (object->MovingDirection == OutOfBox)
object->Center -= (1 - object->Progress) * object->NextUpDirection;
else if (object->MovingDirection == IntoBox)
object->Center -= object->Progress * object->NextUpDirection;
else
object->Center += object->NextUpDirection * (1 + Math::DCos(180 + 270 * object->Progress))
+ object->LastUpDirection * Math::DSin(270 * object->Progress);
}
void DiamondQbertModel::UpdateFaceAndUpDirections(QbertGameObject_ptr object)
{
float factor1 = Math::DCos(90 * object->Progress), factor2 = Math::DSin(90 * object->Progress);
if (object->IsChangingBox)
{
switch(object->MovingDirection)
{
case Left:
case Right:
object->CurrentFaceDirection = object->LastFaceDirection * factor1 +
object->NextFaceDirection * factor2;
break;
case Down:
factor1 = Math::DCos(180 * object->Progress);
factor2 = Math::DSin(180 * object->Progress);
object->CurrentFaceDirection = object->LastFaceDirection * factor1
+ object->GetRightDirection() * factor2;
}
}
else
{
object->CurrentUpDirection = object->LastUpDirection * factor1 +
object->NextUpDirection * factor2;
switch(object->MovingDirection)
{
case Up:
object->CurrentFaceDirection = object->LastFaceDirection * factor1 +
object->NextFaceDirection * factor2;
break;
case Down:
object->CurrentFaceDirection = object->LastFaceDirection * factor1 -
object->NextFaceDirection * factor2;
factor1 = Math::DCos(180 * object->Progress);
factor2 = Math::DSin(180 * object->Progress);
object->CurrentFaceDirection = object->CurrentFaceDirection * factor1 +
object->CurrentFaceDirection.CrossProduct(object->CurrentUpDirection) * factor2;
break;
case Right:
case Left:
object->CurrentFaceDirection = object->CurrentFaceDirection * factor1 +
((object->MovingDirection == Right) ? factor2 : -factor2) * object->CurrentFaceDirection.CrossProduct(object->CurrentUpDirection);
}
}
}
/**
* @pre (object->MovingDirection != NULL &&
* object->MovingDirection != OutOfBox &&
* object->MovingDirection != InsideABox)
**/
void DiamondQbertModel::ChangeBox(QbertGameObject_ptr object)
{
Math::Point3D newBoxCoordinate(object->LastBox->Center), rightDirection = object->GetRightDirection();
object->IsChangingBox = true;
switch (object->MovingDirection)
{
case Up:
newBoxCoordinate += object->LastFaceDirection;
break;
case Down:
newBoxCoordinate -= object->LastFaceDirection;
object->NextFaceDirection = object->LastFaceDirection * (-1);
break;
case Right:
case Left:
newBoxCoordinate += (object->MovingDirection == Right ? 1.0f : -1.0f) * rightDirection;
object->NextFaceDirection = (object->MovingDirection == Right ? 1.0f : -1.0f) * rightDirection;
break;
case IntoBox:
case OutOfBox:
object->IsChangingBox = false;
object->NextBox = object->LastBox;
return;
}
std::map<Math::Point3D, QbertBox_ptr>::iterator box = _objects->BoxMap.find(newBoxCoordinate + object->LastUpDirection);
if (box != _objects->BoxMap.end())
{
object->IsMovingUp = true;
object->IsChangingBox = true;
object->NextBox = box->second;
if((!object->LastUpDirection.Y()) && (!object->NextBox->IsOnPerimeter())) //standing on the perimeter, facing out of the diamond,
object->IsChangingBox = false; //can't move in one move out of the perimeter.
else
return;
}
if (object->IsChangingBox &&
(box = _objects->BoxMap.find(newBoxCoordinate - object->LastUpDirection)) != _objects->BoxMap.end())
{
object->IsMovingUp = false;
object->IsChangingBox = true;
object->NextBox = box->second;
if((!object->LastUpDirection.Y()) && (!object->NextBox->IsOnPerimeter())) //standing on the perimeter, facing out of the diamond,
object->IsChangingBox = false; //can't move in one move out of the perimeter.
else
return;
}
//Not Changing a box!
object->IsChangingBox = false;
object->NextBox = object->LastBox;
object->NextFaceDirection = -object->LastUpDirection;
switch (object->MovingDirection)
{
case Up:
case Down:
object->NextUpDirection = (object->MovingDirection == Up ? 1.0f : -1.0f) * object->LastFaceDirection;
break;
default: //can't be None, OutOfBox, InsideABox: @pre of the function
object->NextUpDirection = (object->MovingDirection == Right ? 1.0f : -1.0f) * rightDirection;
}
}
void DiamondQbertModel::EndMovement(QbertGameObject_ptr object)
{
if (object->MovingDirection == IntoBox)
{
if (object->IsQbert())
throw std::exception("Qbert can't be removed from the model! (in function 'DiamondQbertModel::EndMovement()'");
_enemiesToDelete.push_back(boost::static_pointer_cast<QbertEnemyObj>(object));
*_score += boost::static_pointer_cast<QbertEnemyObj>(object)->GetScore();
return;
}
object->LastBox = object->NextBox;
object->LastUpDirection = object->NextUpDirection;
object->LastFaceDirection = object->NextFaceDirection;
if (object->IsQbert())
VisitBox(object->LastBox);
object->Center = object->LastBox->Center + object->LastUpDirection;
object->CurrentFaceDirection = object->LastFaceDirection;
object->CurrentUpDirection = object->LastUpDirection;
object->Progress = 0;
object->IsMoving = false;
}
void DiamondQbertModel::MoveEnemies(DWORD deltaTime)
{
BOOST_FOREACH(QbertEnemyObj_ptr iter, _objects->Enemies)
{
Move(iter, SimpleControler::InputData(deltaTime, iter->WhereToMove()));
if (iter->IsQbertDies())
{
_enemiesToDelete = _objects->Enemies;
(*_livesLeft)--;
if (*_livesLeft <= 0)
_gameStage = GameOver;
Sleep(1000);
BOOST_FOREACH (EnemiesAppearanceData& data, _enemiesAppearanceData)
{
data.IsAppearedOnce = false;
data.TimeSinceLastAppearance = 0;
}
break;
}
if (!iter->IsDying)
{
BOOST_FOREACH(QbertEnemyObj_ptr iter2, _objects->Enemies)
{
if (iter == iter2)
continue;
if(iter->TestCollision(iter2))
{
*_score += iter->GetScore();
iter->IsDying = true;
iter->DyingProgress = 0;
}
}
}
}
BOOST_FOREACH(QbertEnemyObj_ptr iter, _enemiesToDelete)
RemoveEnemy(iter);
_enemiesToDelete.erase(_enemiesToDelete.begin(), _enemiesToDelete.end());
}
void DiamondQbertModel::RemoveEnemy(const QbertEnemyObj_ptr iter)
{
_objects->Enemies.remove(iter);
BOOST_FOREACH(EnemiesAppearanceData& data, _enemiesAppearanceData)
if (data.Type == iter->GetType())
{
data.TotalAmount--;
return;
}
}
void DiamondQbertModel::AddNewEnemyType(const std::string& type, const std::string& name,
DWORD firstDelay, DWORD appearanceFrequency, DWORD moveLength, int maxAppearances, int score)
{
_enemiesAppearanceData.push_back(EnemiesAppearanceData (type, name, firstDelay, appearanceFrequency, moveLength, maxAppearances, score));
}
void DiamondQbertModel::CreateEnemies (DWORD deltaTime)
{
BOOST_FOREACH (EnemiesAppearanceData& data, _enemiesAppearanceData)
{
data.TimeSinceLastAppearance += deltaTime;
if (data.TimeSinceLastAppearance > ((data.IsAppearedOnce) ? data.AppearanceFrequency : data.FirstDelay))
{
if (data.TotalAmount >= data.MaxAppearances)
continue;
QbertEnemyObj_ptr newEnemy = DiamondQbertEnemiesFactory::GetNewEnemy(data.Type, data.Name, this, data.Score);
SetEnemysMoveLength(newEnemy, data.MoveLength);
VecOfAppearanceBox_ptr vectorOfBoxes = newEnemy->GetAppearanceBoxes();
boost::mt19937 generator((boost::uint32_t)std::time(0));
boost::variate_generator<boost::mt19937, boost::uniform_int<>> uniRand(generator, boost::uniform_int<>(0, (int)vectorOfBoxes->size() - 1));
int index = uniRand();
newEnemy->IsMoving = true;
newEnemy->IsChangingBox = false;
newEnemy->MovingDirection = OutOfBox;
newEnemy->LastBox = (*vectorOfBoxes)[index].get<0>();
newEnemy->LastUpDirection = (*vectorOfBoxes)[index].get<1>();
newEnemy->LastFaceDirection = (*vectorOfBoxes)[index].get<2>();
newEnemy->NextBox = newEnemy->LastBox;
newEnemy->NextUpDirection = newEnemy->LastUpDirection;
newEnemy->NextFaceDirection = newEnemy->LastFaceDirection;
data.TimeSinceLastAppearance = 0;
_objects->Enemies.push_back(newEnemy);
data.TotalAmount++;
data.IsAppearedOnce = true;
}
}
}
} //End of namespace BGComplete
| [
"iliagore@97581c8e-fe54-0410-aa42-dd6ba39e7182",
"haimbender@97581c8e-fe54-0410-aa42-dd6ba39e7182"
]
| [
[
[
1,
4
],
[
6,
18
],
[
20,
28
],
[
30,
30
],
[
32,
66
],
[
70,
70
],
[
76,
79
],
[
81,
100
],
[
102,
105
],
[
107,
116
],
[
118,
126
],
[
128,
160
],
[
162,
166
],
[
168,
168
],
[
170,
222
],
[
225,
236
],
[
238,
282
],
[
284,
284
],
[
286,
287
],
[
289,
294
],
[
296,
307
],
[
309,
309
],
[
312,
388
],
[
390,
397
]
],
[
[
5,
5
],
[
19,
19
],
[
29,
29
],
[
31,
31
],
[
67,
69
],
[
71,
75
],
[
80,
80
],
[
101,
101
],
[
106,
106
],
[
117,
117
],
[
127,
127
],
[
161,
161
],
[
167,
167
],
[
169,
169
],
[
223,
224
],
[
237,
237
],
[
283,
283
],
[
285,
285
],
[
288,
288
],
[
295,
295
],
[
308,
308
],
[
310,
311
],
[
389,
389
]
]
]
|
1c64d6d22f3af74bd83a632bbd5c30e6783b4869 | cd23b98026ca44caf4d7474892ec3be13d35f4bb | /engine/vertex.h | 00f040c817ea665c291a0f83f4d01945fa99edeb | []
| no_license | davidad/kokompe-old | c6941dc3206af26f2c5db988216770945652d92d | c6ffb1ee170f39753b18641cdd3d8ccbc4f98033 | refs/heads/master | 2020-05-30T15:21:18.716355 | 2008-09-23T15:00:24 | 2008-09-23T15:00:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 796 | h | #ifndef VERTEX_H
#define VERTEX_H
#include "vector.h"
#include "trimesh_node.h"
#include "space_interval.h"
#include <list>
using namespace std;
class trimesh_node_t;
class vertex_t : public vector_t {
public:
int number;
space_interval_t si;
int dirty;
int clause;
list<void*> users; // list of trimesh_nodes or path_nodes that use this vertex
vertex_t(float x, float y, float z)
: vector_t(x,y,z),
number(-1), dirty(0),clause(-1) {
}
vertex_t(float ax, float ay, float az, int a_number) {
x=ax;
y=ay;
z=az;
number=a_number;
dirty = 0;
clause = -1;
}
vertex_t() {
}
vertex_t(const vector_t& base)
: vector_t(base) {
}
void set_vector(const vector_t& a) {
x = a.x;
y = a.y;
z = a.z;
}
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
44
]
]
]
|
319bf39f9776d79a732334444ff9811203fb5669 | d57f646dc96686ef496054d073d4d495b6036b9b | /NetPipe/ServiceDB.cpp | 2c437c1eba03ccb3a0875c73445ba174ad451c91 | [
"BSD-2-Clause"
]
| permissive | limura/netpipe | 00d65fd542d3bab833acf24a1a27ac7fd767503a | 1e363a21e299bc2bab4f902c8e70c66786ea8e5b | refs/heads/master | 2021-01-19T13:50:41.041736 | 2007-10-02T10:25:13 | 2007-10-02T10:25:13 | 32,438,427 | 0 | 1 | null | null | null | null | SHIFT_JIS | C++ | false | false | 6,904 | cpp | /*
* Copyright (c) 2007 IIMURA Takuji. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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 REGENTS 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 REGENTS 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.
*
* $Id: ServiceDB.cpp 95 2007-07-06 07:08:18Z $
*/
#include "config.h"
#include "ServiceDB.h"
#include "net.h"
#include "tools.h"
#include <stdlib.h>
#include <string.h>
namespace NetPipe {
ServiceDB::ServiceDB(){
serviceData.clear();
//refreshServiceData();
}
ServiceDB *ServiceDB::getInstance(){
static ServiceDB singleton;
return &singleton;
}
ServiceDB::~ServiceDB(){
clearCache();
}
void ServiceDB::clearCache(){
for(ServiceNameMap::iterator i = serviceData.begin(); i != serviceData.end(); i++){
if(i->second != NULL){
if(i->second->TCPPort != NULL){
free(i->second->TCPPort);
i->second->TCPPort = NULL;
}
if(i->second->IPHost != NULL){
free(i->second->IPHost);
i->second->IPHost = NULL;
}
free(i->second);
i->second = NULL;
}
}
serviceData.clear();
}
void ServiceDB::refreshServiceData(){
int size;
char *p, *p2, *p3, *http_buf = NULL;
char *service_map_url = STATIC_SERVICE_MAP_URL;
if(getenv(SERVICE_MAP_ENV) != NULL)
service_map_url = getenv(SERVICE_MAP_ENV);
int tryNum = 4;
p = NULL;
while(tryNum-- > 0 && (http_buf = p = HTTP_post(service_map_url, NULL, 0, NULL, &size)) == NULL)
;
if(p == NULL || size <= 0)
return;
clearCache();
p = strstr(p, "\r\n\r\n");
if(p == NULL){
free(http_buf);
return;
}
p += 4;
ServiceDB::Service *sv = NULL;
char *saveP;
while((p2 = strchr(p, '\n')) != NULL){
char *serviceString = NULL;
char *host = NULL;
char *port = NULL;
*p2 = '\0'; // 行末を '\0' terminate
p3 = p; // 今のカラム
p = ++p2; // 次の行
if(*p3 != 'p') // 'p' で始まらない行はしらん
continue;
p3++;
while(*p3 == '\t') // とりあえず最初のカラムは 'p' なので読み飛ばす
p3++;
p2 = strtok_r(p3, "\t", &saveP);
if(p2 == NULL)
goto error_retry;
serviceString = p2;
p2 = strtok_r(NULL, "\t", &saveP);
if(p2 == NULL)
goto error_retry;
host = (char *)malloc(strlen(p2) + 1);
if(host == NULL)
goto error_retry;
strcpy(host, p2);
p2 = strtok_r(NULL, "\t", &saveP);
if(p2 == NULL)
goto error_retry;
port = (char *)malloc(strlen(p2) + 1);
if(port == NULL)
goto error_retry;
strcpy(port, p2);
sv = (ServiceDB::Service *)malloc(sizeof(ServiceDB::Service));
if(sv == NULL)
goto error_retry;
sv->TCPPort = port;
sv->IPHost = host;
serviceData[serviceString] = sv;
continue;
error_retry:
if(host != NULL)
free(host);
if(port != NULL)
free(port);
}
free(http_buf);
}
ServiceDB::Service *ServiceDB::updateServiceData(char *serviceName){
char urlBuf[1024];
int size;
if(serviceName == NULL || strlen(serviceName) + strlen(STATIC_SERVICE_MAP_URL) + 2 > sizeof(urlBuf))
return NULL;
sprintf(urlBuf, "%s?%s", STATIC_SERVICE_MAP_URL, serviceName);
char *httpReply = HTTP_post(urlBuf, NULL, 0, NULL, &size);
if(httpReply == NULL)
return NULL;
char *ok200 = strstr(httpReply, " 200 OK\r\n");
char *enter = strchr(httpReply, '\n');
if(ok200 == NULL || enter == NULL || ok200 > enter){
free(httpReply);
return NULL;
}
char *begin = strstr(httpReply, "\r\n\r\n");
begin += 4;
char *p = strchr(begin, ':');
if(p == NULL){
free(httpReply);
return NULL;
}
*p = '\0';
p++;
ServiceDB::Service *sv = new ServiceDB::Service();
if(sv == NULL){
free(httpReply);
return NULL;
}
sv->IPHost = strdup(begin);
if(sv->IPHost == NULL){
delete sv;
free(httpReply);
return NULL;
}
sv->TCPPort = (char *)malloc(size - (p -httpReply) + 1);
if(sv->TCPPort == NULL){
delete sv;
free(sv->IPHost);
free(httpReply);
return NULL;
}
memcpy(sv->TCPPort, p, size - (p - httpReply));
sv->TCPPort[size - (p - httpReply)] = '\0';
serviceData[serviceName] = sv;
free(httpReply);
return sv;
}
char *ServiceDB::QueryIPHostName(char *serviceName){
char *p = strchr(serviceName, ' ');
if(p != NULL)
*p = '\0';
Service *sv = serviceData[serviceName];
if(sv == NULL){
#if 1
sv = updateServiceData(serviceName);
#else
refreshServiceData();
sv = serviceData[serviceName];
#endif
if(p != NULL)
*p = ' ';
if(sv == NULL)
return NULL;
}
if(p != NULL)
*p = ' ';
return sv->IPHost;
}
char *ServiceDB::QueryTCPPortName(char *serviceName){
char *p = strchr(serviceName, ' ');
if(p != NULL)
*p = '\0';
Service *sv = serviceData[serviceName];
if(sv == NULL){
#if 1
sv = updateServiceData(serviceName);
#else
refreshServiceData();
sv = serviceData[serviceName];
#endif
if(p != NULL)
*p = ' ';
if(sv == NULL)
return NULL;
}
if(p != NULL)
*p = ' ';
return sv->TCPPort;
}
bool ServiceDB::Regist(char *ServiceString){
char *service_update_url = STATIC_SERVICE_UPDATE_URL;
if(getenv(SERVICE_UPDATE_ENV) != NULL)
service_update_url = getenv(SERVICE_UPDATE_ENV);
// XXXXX ちゃんと送信できたかどうかを見てない
char *buf = NULL;
int tryNum = 4;
while(tryNum-- > 0 && (buf = HTTP_post(service_update_url, ServiceString, strlen(ServiceString), NULL, NULL)) == NULL)
;
if(buf != NULL)
free(buf);
return buf != NULL;
}
}; /* namespace NetPipe */
| [
"uirou.j@b085bb30-bf34-0410-99c5-0750ab6b8f60"
]
| [
[
[
1,
249
]
]
]
|
f5c62cd6afae3243acf8b58f4f4ff6d85a0cd4b6 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.0/bctestmisccontrol/inc/bctesteikconsolecontrolcase.h | 789f4ece60ccfddc71ca76c423082fe82d13fc31 | []
| no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,173 | h | /*
* Copyright (c) 2006 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: Declares test bc for eik console control testcase.
*
*/
#ifndef C_CBCTESTEIKCONSOLECONTROLCASE_H
#define C_CBCTESTEIKCONSOLECONTROLCASE_H
#include "bctestcase.h"
class CBCTestMiscControlContainer;
class CCoeControl;
/**
* test case for various misc control classes
*/
class CBCTestEikConsoleControlCase: public CBCTestCase
{
public: // constructor and destructor
/**
* Symbian 2nd static constructor
*/
static CBCTestEikConsoleControlCase*
NewL( CBCTestMiscControlContainer* aContainer );
/**
* Destructor
*/
virtual ~CBCTestEikConsoleControlCase();
// from CBCTestCase
/**
* Execute corresponding test functions for UI command
* @param aCmd, UI command
*/
void RunL( TInt aCmd );
protected: // new functions
/**
* Build autotest script
*/
void BuildScriptL();
/**
* TestFunctionsForEikConsoleControlL function
*/
void TestFunctionsForEikConsoleControlL();
/**
* TestProtectedFunctionsForEikConsoleControlL function
*/
void TestProtectedFunctionsForEikConsoleControlL();
/**
* TestFunctionsForEikConsoleScreenL function
*/
void TestFunctionsForEikConsoleScreenL();
private: // constructor
/**
* C++ default constructor
*/
CBCTestEikConsoleControlCase( CBCTestMiscControlContainer* aContainer );
/**
* Symbian 2nd constructor
*/
void ConstructL();
private: // data
/**
* Pointer to container.
* not own
*/
CBCTestMiscControlContainer* iContainer;
};
#endif // C_CBCTESTEIKCONSOLECONTROLCASE_H
| [
"none@none"
]
| [
[
[
1,
98
]
]
]
|
1ba74799a23bec02af95ab457036264a57e2c480 | 74c8da5b29163992a08a376c7819785998afb588 | /NetAnimal/Game/Hunter/NewGameVedioUI/UnitTest/src/main.cpp | 62f5fde4f1f71329c1e9745d1b0bb7dfb793554c | []
| 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 | 139 | cpp | #include "UnitTestStableHeaders.h"
//
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
//
#include "VedioUIComponentUT.h" | [
"[email protected]"
]
| [
[
[
1,
7
]
]
]
|
b2628eba6179cca0c388bfad8f87c53bbf0a2a44 | a7757d5f758e97347565d781c1c8da60784aaeaf | /DirtboxSync.cpp | 997fde003ea68d22293954d3b1628990da2dde76 | []
| no_license | advancingdragon/DirtboxKernel | 6fe96f777f589cdd338f93a3da4488a3eda99bce | 6d5afaf97fab2009b55d0a08e4e4583ba8b2d57e | refs/heads/master | 2016-09-06T19:57:46.411824 | 2011-09-21T04:23:29 | 2011-09-21T04:23:29 | 2,183,799 | 5 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,017 | cpp | // Dirtbox synchronization primitives
#include "DirtboxEmulator.h"
#include <stdio.h>
#define DIRT_NAME_SIZE 32
// NOTE: The current method of simulating kernel synchronization objects
// with named Windows objects is leaky since objects are never destroyed.
// TODO: use Native API
HANDLE Dirtbox::GetDirtObject(PVOID Object)
{
CHAR ObjectName[DIRT_NAME_SIZE];
sprintf_s(ObjectName, DIRT_NAME_SIZE, "Dirtbox_%08x", Object);
PDISPATCHER_HEADER Header = (PDISPATCHER_HEADER)Object;
switch (Header->Type)
{
case EventNotificationObject:
return CreateEventA(NULL, TRUE, Header->SignalState, ObjectName);
case EventSynchronizationObject:
return CreateEventA(NULL, FALSE, Header->SignalState, ObjectName);
case TimerNotificationObject:
return CreateWaitableTimerA(NULL, TRUE, ObjectName);
case TimerSynchronizationObject:
return CreateWaitableTimerA(NULL, FALSE, ObjectName);
default:
return NULL;
}
}
| [
"[email protected]"
]
| [
[
[
1,
31
]
]
]
|
f65a43988a36686941436aaeef14e175abff5fe3 | 74b5cb9980eb7c3467d6a5b08198847d6f14b33b | /dslua/source/DSLPads.cpp | 0f8ff03014e7c9bcb2084b28b66c73a5e5182da2 | []
| no_license | sypherce/dslua | 122d03026a888a8e04483c21b873413d89735afb | 9841f11a84a0f6b01a3b2291cf3fc87fb4133c3a | refs/heads/master | 2021-01-10T03:15:29.531355 | 2007-07-31T03:24:08 | 2007-07-31T03:24:08 | 50,567,809 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,996 | cpp | #include <PA9.h> // Include for PA_Lib
extern "C"
{
#include "lua.h"
#include "lauxlib.h"
//#include "lualib.h"
}
#include "DSLPads.h"
//------------------------------------------------------------
//------------------------------------------------------------
static int l_HeldA(lua_State * lState)
{
lua_pushboolean(lState, Pad.Held.A);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_HeldB(lua_State * lState)
{
lua_pushboolean(lState, Pad.Held.B);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_HeldX(lua_State * lState)
{
lua_pushboolean(lState, Pad.Held.X);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_HeldY(lua_State * lState)
{
lua_pushboolean(lState, Pad.Held.Y);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_HeldR(lua_State * lState)
{
lua_pushboolean(lState, Pad.Held.R);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_HeldL(lua_State * lState)
{
lua_pushboolean(lState, Pad.Held.L);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_HeldUp(lua_State * lState)
{
lua_pushboolean(lState, Pad.Held.Up);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_HeldDown(lua_State * lState)
{
lua_pushboolean(lState, Pad.Held.Down);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_HeldLeft(lua_State * lState)
{
lua_pushboolean(lState, Pad.Held.Left);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_HeldRight(lua_State * lState)
{
lua_pushboolean(lState, Pad.Held.Right);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_HeldSelect(lua_State * lState)
{
lua_pushboolean(lState, Pad.Held.Select);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_HeldStart(lua_State * lState)
{
lua_pushboolean(lState, Pad.Held.Start);
return 1;
}
//------------------------------------------------------------
//------------------------------------------------------------
static int l_HeldAnyKey(lua_State * lState)
{
bool bAnyKey = Pad.Held.A || Pad.Held.B || Pad.Held.X || Pad.Held.Y ||
Pad.Held.R || Pad.Held.L ||
Pad.Held.Up || Pad.Held.Down || Pad.Held.Left || Pad.Held.Right ||
Pad.Held.Select || Pad.Held.Start;
lua_pushboolean(lState, bAnyKey);
return 1;
}
static const struct luaL_reg DSLPadsLib [] =
{
{"A", l_HeldA},
{"B", l_HeldB},
{"X", l_HeldX},
{"Y", l_HeldY},
{"L", l_HeldL},
{"R", l_HeldR},
{"Up", l_HeldUp},
{"Down", l_HeldDown},
{"Left", l_HeldLeft},
{"Right", l_HeldRight},
{"Select", l_HeldSelect},
{"Start", l_HeldStart},
{"AnyKey", l_HeldAnyKey},
{NULL, NULL}
};
//------------------------------------------------------------
//------------------------------------------------------------
int luaopen_DSLPadsLib(lua_State * lState)
{
luaL_openlib(lState, "Pads", DSLPadsLib, 0);
return 1;
}
| [
"sypherce@7bd1a944-e22a-0410-b2d1-0368184b35f6"
]
| [
[
[
1,
145
]
]
]
|
f340ca61b9aeee9a03fbec542241ddea1248f25a | 1960e1ee431d2cfd2f8ed5715a1112f665b258e3 | /src/com/sc/cowallet.cpp | 5a04059cb25266d271cdb554ea771ad39d081443 | []
| no_license | BackupTheBerlios/bvr20983 | c26a1379b0a62e1c09d1428525f3b4940d5bb1a7 | b32e92c866c294637785862e0ff9c491705c62a5 | refs/heads/master | 2021-01-01T16:12:42.021350 | 2009-11-01T22:38:40 | 2009-11-01T22:38:40 | 39,518,214 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,793 | cpp | /*
* $Id$
*
* CoWallet COM Object Class.
*
* Copyright (C) 2008 Dorothea Wachmann
*
* 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 "os.h"
#include "com/sc/cowallet.h"
#include "util/logstream.h"
#include "util/comlogstream.h"
namespace bvr20983
{
namespace COM
{
/**
*
*/
#pragma warning(disable:4355)
COWallet::COWallet(IUnknown* pUnkOuter)
: CODispatch(pUnkOuter,(IWallet*)this,LIBID_BVR20983_0_SC,IID_IWallet,CLSID_Wallet)
{ }
#pragma warning(default:4355)
/*
* COWallet::get_Balance
*
* Purpose:
* get the actual wallet balance.
*
* Parameters:
* short* amount
*
* Return:
* HRESULT
*/
STDMETHODIMP COWallet::get_Balance(short* amount)
{ *amount = 42;
LOGGER_DEBUG<<_T("COWallet::get_Balance. Called. ")<<endl;
return NOERROR;
}
/*
* COWallet::Credit
*
* Purpose:
* get money from wallet.
*
* Parameters:
* short amount
*
* Return:
* HRESULT
*/
STDMETHODIMP COWallet::Credit(short amount)
{ LOGGER_DEBUG<<_T("COWallet::Credit. Called. amount=")<<amount<<endl;
return NOERROR;
}
/*
* COWallet::Debit
*
* Purpose:
* get money from wallet.
*
* Parameters:
* short amount
*
* Return:
* HRESULT
*/
STDMETHODIMP COWallet::Debit(short amount)
{ LOGGER_DEBUG<<_T("COWallet::Debit. Called. amount=")<<amount<<endl;
return NOERROR;
}
/*
* COWallet::Verify
*
* Purpose:
* verify cardholder by asking for a pin.
*
* Parameters:
* BSTR pin PersonalIdentificationNumber
*
* Return:
* HRESULT
*/
STDMETHODIMP COWallet::Verify(BSTR pin)
{ LOGGER_DEBUG<<_T("COWallet::Verify. Called. pin=")<<pin<<endl;
return NOERROR;
}
} // of namespace COM
} // of namespace bvr20983
/*==========================END-OF-FILE===================================*/
| [
"dwachmann@01137330-e44e-0410-aa50-acf51430b3d2",
"[email protected]"
]
| [
[
[
1,
35
],
[
37,
115
]
],
[
[
36,
36
]
]
]
|
541dae20b9cc564125f1e994107edae5507bd895 | f8b49ab7b1fd8252576a07d604338ae615a76cc4 | /QSimSourceCode/QSimStartSimulationGui.cpp | 59841bfdd1990f957359ec3702de44d017b9c25e | []
| no_license | ruisebastiao/qsim | 8eb47c7c40a217f902d886526ceede651e80a14e | 7933f8a44e145f18971062bdd8b3421e75f46657 | refs/heads/master | 2016-09-06T04:32:07.445284 | 2011-10-19T18:55:11 | 2011-10-19T18:55:11 | 35,518,359 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,242 | cpp | //-----------------------------------------------------------------------------
// File: QSimStartSimulationGui.cpp
// Class: QSimStartSimulation
// Parent: QObject
// Purpose: Catches the Qt widget signal that starts the simulation.
// There are TWO .cpp files for this class.
// QSimStartSimulationNoGui.cpp contains standard C++ (non-Qt) methods to run simulation.
// QSimStartSimulationGui.cpp contains Qt methods to display/interact with simulation.
/* ---------------------------------------------------------------------------- *
* QSim was developed with support from Simbios (NIH Center for Physics-Based *
* Simulation of Biological Structures at Stanford) under NIH Roadmap for *
* Medical Research grant U54 GM072970 and NCSRR (National Center for Simulation *
* in Rehabilitation Research) NIH research infrastructure grant R24 HD065690. *
* *
* To the extent possible under law, the author(s) and contributor(s) have *
* dedicated all copyright and related and neighboring rights to this software *
* to the public domain worldwide. This software is distributed without warranty.*
* *
* Authors: Paul Mitiguy (2011) *
* Contributors: Ayman Habib, Michael Sherman *
* *
* Permission is 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.*
* *
* Include this sentence, the above public domain and permission notices, and the*
* following disclaimer 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 NON-INFRINGEMENT. IN NO EVENT SHALL THE *
* AUTHORS OR CONTRIBUTORS 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. *
* ----------------------------------------------------------------------------- */
#include <QtCore>
#include <QtGui>
#include "QSimStartSimulation.h"
#include "QSimGenericFunctions.h"
//------------------------------------------------------------------------------
namespace QSim {
//------------------------------------------------------------------------------
} // End of namespace QSim
| [
"mitiguy@c7bcc468-049e-0410-a823-898a083b103d"
]
| [
[
[
1,
52
]
]
]
|
829e66b5ea37276c08bb376fdb49698ce318558b | 985d66ee52214abaebc0333a859423c319b7e355 | /scratch/scratch.cpp | 5c4f8adeb3142cf45b7497c12c432b84c6400730 | []
| no_license | water-tunnel/Water-Tunnel | c655717a174455306894b7b6462cae2b49582e1b | f9d9b7465757169efdc5d063a80da1de8e3db498 | refs/heads/master | 2021-01-22T18:14:51.156332 | 2010-09-02T16:56:54 | 2010-09-02T16:56:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,890 | cpp | #include <stdio.h>
#include <stdlib.h>
//#include <math.h>
#using <system.dll>
using namespace System;
using namespace System::Timers;
public ref class Timer1
{
private:
static System::Timers::Timer^ aTimer;
public:
static void Demo()
{
// Normally, the timer is declared at the class level,
// so that it stays in scope as long as it is needed.
// If the timer is declared in a long-running method,
// KeepAlive must be used to prevent the JIT compiler
// from allowing aggressive garbage collection to occur
// before the method ends. You can experiment with this
// by commenting out the class-level declaration and
// uncommenting the declaration below; then uncomment
// the GC::KeepAlive(aTimer) at the end of the method.
//System::Timers::Timer^ aTimer;
printf("At 1!\n");
// Create a new Timer with Interval set to 10 seconds.
aTimer = gcnew System::Timers::Timer( 1000000 );
printf("At 2!\n");
// Hook up the Elapsed event for the timer.
aTimer->Elapsed += gcnew ElapsedEventHandler( Timer1::OnTimedEvent );
aTimer->Interval = 2000;
aTimer->Enabled = true; // Set the Interval to 2 seconds (2000 milliseconds).
Console::WriteLine("Press the Enter key to exit the program.");
Console::ReadLine();
printf("At 3!\n");
// If the timer is declared in a long-running method, use
// KeepAlive to prevent garbage collection from occurring
// before the method ends.
//GC::KeepAlive(aTimer);
}
private:
// Specify what you want to happen when the Elapsed event is
// raised.
static void OnTimedEvent( Object^ source, ElapsedEventArgs^ e )
{
printf("Hey!!\n");
}
};
int main()
{
printf("Hey!!!!\n\n");
Timer1::Demo();
return 0;
} | [
"[email protected]"
]
| [
[
[
1,
65
]
]
]
|
9079026a2dde755c5e5008fceeb615255b100eba | bc4919e48aa47e9f8866dcfc368a14e8bbabbfe2 | /Open GL Basic Engine/source/glutFramework/glutFramework/SG400KGA1.cpp | 0c609cf61d37055ccbf116b4afae1c28276b936c | []
| no_license | CorwinJV/rvbgame | 0f2723ed3a4c1a368fc3bac69052091d2d87de77 | a4fc13ed95bd3e5a03e3c6ecff633fe37718314b | refs/heads/master | 2021-01-01T06:49:33.445550 | 2009-11-03T23:14:39 | 2009-11-03T23:14:39 | 32,131,378 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,012 | cpp | #include "SG400KGA1.h"
#include <stdlib.h>
bool SG400KGA1::Update()
{
return true;
}
bool SG400KGA1::Draw()
{
// since all fonts are now well, blackish stuff, lets draw a white background
solidWhite->drawImage();
// image
if(imgSG400)
{
imgSG400->drawImageFaded(alpha);
}
// interface
glColor3ub(255, 0, 0);
GameVars->fontArial18.drawText(25, 700, "Enter Command:");
glColor3ub(0, 255, 0);
GameVars->fontArial18.drawText(220, 700, tempString);
// history
glColor3ub(255, 255, 255);
GameVars->fontArial18.drawText(25, 10, "Command History");
int offsetAmt = 0;
int textOffset = 14;
vector<string*>::iterator sitr;
sitr = commandList.begin();
for(;sitr < commandList.end(); sitr++)
{
GameVars->fontArial12.drawText(25, 29 + offsetAmt*textOffset, (*sitr)->c_str());
offsetAmt++;
}
// draw instruction list on top right
offsetAmt = 0;
textOffset = 15;
int xp = 575;
int yp = 25;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "Available Commands");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "Values inside () & [] are");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "used without the () & []");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "() denotes values");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "[] denotes specific words");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "i.e. move up 50");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "move [up/down/left/right] (pixels)");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "resize (width) (height)");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "set [alpha/width/height/x/y] (value)");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "reset");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "load (filename)");
offsetAmt++;
GameVars->fontArial12.drawText(xp, yp + offsetAmt * textOffset, "quit");
offsetAmt++;
return false;
}
void SG400KGA1::processMouse(int x, int y)
{
}
void SG400KGA1::processMouseClick(int button, int state, int x, int y)
{
}
void SG400KGA1::keyboardInput(unsigned char c, int x, int y)
{
switch(c)
{
case 13: // enter key
if(finished == 2)
{
tempString = "";
finished = 0;
}
else
finished = 1;
break;
case 8: // backspace
if(tempString.length() > 0)
tempString.erase(tempString.length() - 1, 1);
break;
case 27: // escape key
tempString = "";
/*GSM->addGameState<MainMenuState>();
this->setStatus(DeleteMe);*/
break;
default:
if(tempString.length() <= 60)
{
tempString += c;
finished = 0;
}
break;
}
if(finished)
{
tString = new string;
*tString = tempString;
interpret(tString);
commandList.push_back(tString);
tempString = "";
}
}
void SG400KGA1::interpret(string *iString)
{
// parse this out into various things first
vector<string*> parseList;
bool done = false;
bool foundCommand = false;
bool foundvar1 = false;
bool foundvar2 = false;
string command;
string var1 = "";
string var2 = "";
int targetSpot = 0;
(*iString) += " ";
for(int x = 0; x < (int)iString->length(); x++)
{
if(iString->substr(x, 1) == " ")
{
// we found a space, lets do something with it
if(!foundCommand)
{
command = iString->substr(0, x);
foundCommand = true;
targetSpot = x+1;
}
else if(!foundvar1)
{
var1 = (iString->substr(targetSpot, x-targetSpot).c_str());
foundvar1 = true;
targetSpot = x+1;
}
else if(!done)
{
var2 = (iString->substr(targetSpot, x-targetSpot).c_str());
done = true;
foundvar2 = true;
}
}
}
if(foundCommand)
{
if(command == "quit")
{
exit(0);
}
else if(command == "move")
{
if(foundvar1)
{
if(var1 == "up")
{
imgSG400->mY = imgSG400->mY - atoi(var2.c_str());
}
else if(var1 == "down")
{
imgSG400->mY = imgSG400->mY + atoi(var2.c_str());
}
else if(var1 == "left")
{
imgSG400->mX = imgSG400->mX - atoi(var2.c_str());
}
else if(var1 == "right")
{
imgSG400->mX = imgSG400->mX + atoi(var2.c_str());
}
else
{
*iString += " <invalid direction>";
}
}
}
else if(command == "resize")
{
if(foundvar1)
{
imgSG400->dX = atoi(var1.c_str());
}
if(foundvar2)
{
imgSG400->dY = atoi(var2.c_str());
}
}
else if(command == "reset")
{
delete imgSG400;
imgSG400 = new oglTexture2D();
imgSG400->loadImage("buttons\\bacardi.png", 256, 256);
imgSG400->dX = 256;
imgSG400->dY = 256;
imgSG400->mX = 300;
imgSG400->mY = 50;
alpha = 1.0;
}
else if(command == "load")
{
if(foundvar1)
{
delete imgSG400;
imgSG400 = new oglTexture2D();
if(!imgSG400->loadImage(var1.c_str(), 256, 256))
{
*iString += " <invalid file>";
}
imgSG400->dX = 256;
imgSG400->dY = 256;
imgSG400->mX = 300;
imgSG400->mY = 50;
}
}
else if(command == "set" && foundvar1 && foundvar2)
{
if(var1 == "alpha")
{
alpha = atof(var2.c_str());
}
else if(var1 == "width")
{
imgSG400->dX = atoi(var2.c_str());
}
else if(var1 == "height")
{
imgSG400->dY = atoi(var2.c_str());
}
else if(var1 == "x")
{
imgSG400->mX = atoi(var2.c_str());
}
else if(var1 == "y")
{
imgSG400->mY = atoi(var2.c_str());
}
}
else // invalid command
{
*iString += " <Invalid Command>";
}
}
} | [
"corwin.j@5457d560-9b84-11de-b17c-2fd642447241"
]
| [
[
[
1,
270
]
]
]
|
c3b4993bf0b4be5581e874778f4eaaf73cba9d48 | e6ffc738b23d185d18140f644dc9b2c736cd170c | /fuentes/enrutamiento/src/ag/Cromosoma.h | a409866750d8f651967dc8d8a57884058e3aae42 | []
| no_license | ghuttemann/enrutamiento-demandas-unicast | 0444af6e4a5a2e68f62ea0b08286366c8a5d956f | 4a03265ab6e24cc577703f21e1023073730e7bc7 | refs/heads/master | 2021-01-03T13:19:44.629478 | 2008-09-23T13:36:24 | 2008-09-23T13:36:24 | 32,361,107 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 157 | h | #ifndef CROMOSOMA_H_
#define CROMOSOMA_H_
class Cromosoma {
private:
public:
Cromosoma();
virtual ~Cromosoma();
};
#endif /*CROMOSOMA_H_*/
| [
"ghuttemann@bd0bc703-fb3b-0410-a856-e1b9a076a7ce"
]
| [
[
[
1,
12
]
]
]
|
89753a52ee4d50e1dd7f42475d3da01c7ccb0791 | 8c8e31263c3f1ca6984754a4580ec7a6091ac843 | /pololu-dist/src/OrangutanLCD/OrangutanLCD.h | 47388f9e0134991f7e4eee5a49f5572e6be220a6 | []
| no_license | reenberg/wobot | 4a696ad9af37e0aac74ff67f3782ff2910d8f681 | ce7f112096ba1abd43b8d29da7e8944c2a004125 | refs/heads/master | 2020-05-17T14:48:26.506669 | 2010-10-26T15:06:28 | 2010-10-26T15:06:28 | 130,731 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,118 | h | /*
OrangutanLCD.h - Library for using the LCD on the Orangutan LV-168 or 3pi robot.
Originally written by Tom Benedict and Ben Schmidel as part of Orangutan-Lib.
*/
/*
* Modified by Ben Schmidel, May 14, 2008.
* Copyright (c) 2008 Pololu Corporation. For more information, see
*
* http://www.pololu.com
* http://forum.pololu.com
* http://www.pololu.com/docs/0J18/5
*
* You may freely modify and share this code, as long as you keep this
* notice intact (including the two links above). Licensed under the
* Creative Commons BY-SA 3.0 license:
*
* http://creativecommons.org/licenses/by-sa/3.0/
*
* Disclaimer: To the extent permitted by law, Pololu provides this work
* without any warranty. It might be defective, in which case you agree
* to be responsible for all resulting costs and damages.
*/
#ifndef OrangutanLCD_h
#define OrangutanLCD_h
#define LCD_LEFT 0
#define LCD_RIGHT 1
#define CURSOR_SOLID 0
#define CURSOR_BLINKING 1
class OrangutanLCD
{
public:
// constructor
OrangutanLCD();
// Send either data or a command on a 4-bit interface
static void send(unsigned char data, unsigned char rs);
static inline void send_cmd(unsigned char cmd)
{
send(cmd, 0);
}
static inline void send_data(unsigned char data)
{
send(data, 1);
}
// clears the LCD screen and returns the cursor to position (0, 0)
static void clear();
// prints an ASCII character at the current LCD cursor position
static void print(char character);
static inline void print(unsigned char character)
{
print((char)character);
};
// sends a string to the LCD. You can send a string
// longer than 8 characters, but only eight characters show up.
// The string is printed from wherever the cursor is, and will
// not span lines. (This lets you concatenate print statements.)
static void print(const char *str);
// Sends a PROGMEM string to the LCD.
static void printFromProgramSpace(const char *str);
#ifndef LIB_ORANGUTAN
static void printIn(const char *str); // for compatibility with other libs
#endif
// prints signed and unsigned integer values at the current cursor
// position and will not span lines.
static void print(unsigned long value);
static void print(long value);
static inline void print(unsigned int value)
{
print((unsigned long)value);
};
static inline void print(int value)
{
print((long)value);
};
// prints a two-byte value (word) in hex at your current
// cursor location.
static void printHex(unsigned int word);
// prints a one-byte value in hex at your current location
static void printHex(unsigned char byte);
// lcd_binary prints a byte in binary starting at your current cursor location.
static void printBinary(unsigned char byte);
// Go to an (X,Y) location on the LCD. The top line is Y=0, the
// leftmost character is X=0.
static void gotoXY(unsigned char x, unsigned char y);
// Shows the cursor as either a BLINKING or SOLID block
// cursorType should be either CURSOR_BLINKING or CURSOR_SOLID
static void showCursor(unsigned char cursorType);
// Hide the cursor
static void hideCursor();
// shifts the cursor LEFT or RIGHT the given number of positions.
// direction should be either LCD_LEFT or LCD_RIGHT
static void moveCursor(unsigned char direction, unsigned char num);
// shifts the display LEFT or RIGHT the given number of
// positions, delaying for delay_time milliseconds between each shift.
// This is what you'd use for a scrolling display.
// direction should be either LCD_LEFT or LCD_RIGHT
static void scroll(unsigned char direction, unsigned char num,
unsigned int delay_time);
// Loads a custom character into the character memory of the LCD.
// The parameter 'number' is a character value between 0 and 7,
// which represents the character that will be customized. That is
// The pointer 'picture_p' is a pointer to an 8 byte array in
// program space containing the picture data. This kind of array
// may be defined as follows:
//
// #include <avr/pgmspace.h>
// const prog_char pi[] PROGMEM = { 0b11100, .... }
//
// The first byte represets row one, which has, in this example,
// three black pixels on the left, followed by two clear
// pixels. Subsequent values specify the pixels for the remaining
// rows of the 5x8 character.
//
// After loading all desired custom characters, clear() should be
// called to reset the LCD.
static void loadCustomCharacter(const char *picture_p, unsigned char number);
// Initializes the LCD library for printf support. After this,
// printf will start sending characters to the LCD.
static void initPrintf();
private:
static inline void init()
{
static unsigned char initialized = 0;
if (!initialized)
{
initialized = 1; // this MUST be set before init2() is called
init2(); // or else infinite recursion ensues
}
}
// initializes the LCD hardware; this function MUST be called before
// the LCD can be used. It is called if needed by the inline
// member function init(), which is called if needed by send().
static void init2();
// Wait for the busy flag to clear on a 4-bit interface
// This is necessarily more complicated than the 8-bit interface
// because E must be strobed twice to get the full eight bits
// back from the LCD, even though we're only interested in one
// of them.
static void busyWait();
// Send four bits out the 4-bit interface. This assumes the busy flag
// is clear, that our DDRs are all set, etc. Basically all it does is
// line up the bits and shove them out the appropriate I/O lines.
static void sendNibble(unsigned char nibble);
// prints a hex nibble (half of a hex byte) at
// your current cursor location.
static void printHexNibble(unsigned char nibble);
};
#endif
// Local Variables: **
// mode: C++ **
// c-basic-offset: 4 **
// tab-width: 4 **
// indent-tabs-mode: t **
// end: **
| [
"[email protected]"
]
| [
[
[
1,
190
]
]
]
|
c5568957c8bc145cbeea16eed08ae1a30ab33741 | dfd5fe71dac13de11b09e6ceb81528ddbe641628 | /LnkIconShim.cpp | 07c69ad5c2e146d7bf31785dd4240e889818a8f2 | []
| no_license | libor-m/linkiconshim | be669ca09611df1d4c650e8f2e5cc316ad2fa980 | af2baf4655764c9ef9e5b91e7aa2c18d454dc7cd | refs/heads/master | 2021-03-12T19:19:10.212151 | 2010-08-06T15:20:50 | 2010-08-06T15:20:50 | 32,135,468 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,060 | cpp | // LnkIconShim.cpp : Implementation of DLL Exports.
#include "stdafx.h"
#include "resource.h"
#include <initguid.h>
#include "LnkIconShim.h"
#include "LnkIconShim_i.c"
#include "LnkIconShlExt.h"
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_LnkIconShlExt, CLnkIconShlExt)
END_OBJECT_MAP()
/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
_Module.Init(ObjectMap, hInstance, &LIBID_TXTFILEICONSLib);
DisableThreadLibraryCalls(hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH)
_Module.Term();
return TRUE; // ok
}
/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow()
{
return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _Module.GetClassObject(rclsid, riid, ppv);
}
/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer()
{
CRegKey key;
LONG lRet;
// On NT/2K, put our extension in the "approved" list.
if ( 0 == (GetVersion() & 0x80000000) )
{
lRet = key.Open ( HKEY_LOCAL_MACHINE,
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"),
KEY_SET_VALUE );
if ( ERROR_SUCCESS == lRet )
{
lRet = key.SetStringValue ( _T("Link file icon shim"),
_T("{DF4F5AE4-E795-4C12-BC26-7726C27F71AE}") );
key.Close();
}
if ( ERROR_SUCCESS != lRet )
return HRESULT_FROM_WIN32(lRet);
}
// registers object, typelib and all interfaces in typelib
return _Module.RegisterServer(false);
}
/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer()
{
CRegKey key;
LONG lRet;
// On NT/2K, remove our extension from the "approved" list.
if ( 0 == (GetVersion() & 0x80000000) )
{
lRet = key.Open ( HKEY_LOCAL_MACHINE,
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"),
KEY_SET_VALUE );
if ( ERROR_SUCCESS == lRet )
{
key.DeleteValue ( _T("{DF4F5AE4-E795-4C12-BC26-7726C27F71AE}") );
key.Close();
}
}
return _Module.UnregisterServer(false);
}
| [
"liborek@91213e4e-15c0-f57f-9090-303a38b12bd9"
]
| [
[
[
1,
103
]
]
]
|
9d615dab1174e02236f915243dec8cfd2b3bafea | 0b6f8eda32f9c7d545ad676af2c0ae31a0c9f909 | /acs/workshop/awu2008/UOS/Telescope/include/TelescopeImpl.h | 32f72d553cac1288ba39fa9c81130484b9c56d49 | []
| no_license | avillalobos/acsucn-1 | d06d177961821c8410d438dcbefdbb25fb578256 | a886306a291bcbee6dd9d5bffa5cf9426a1ec603 | refs/heads/master | 2021-01-19T09:38:34.787195 | 2011-10-18T23:35:02 | 2011-10-18T23:35:02 | 32,241,150 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,556 | h | #ifndef Telescope_H
#define Telescope_H
#ifndef __cplusplus
#error This is a C++ include file and cannot be used from plain C
#endif
///Contains the defintion of the standard superclass for C++ components
#include <baciCharacteristicComponentImpl.h>
///CORBA generated servant stub
#include <TelescopeS.h>
#include <H3EC.h>
#include <InstrumentC.h>
///Includes for each BACI property used in this example
#include <baciROdouble.h>
#include <baciRWdouble.h>
#include <baciROlong.h>
#include <baciROstring.h>
///Include the smart prointer for the properties
#include <baciSmartPropertyPointer.h>
///Include the acs thread header
#include <acsThread.h>
#include <iostream>
using namespace baci;
class TelescopeImpl : public acscomponent::ACSComponentImpl,
public virtual POA_TELESCOPE_MODULE::Telescope //CORBA servant stub
{
public:
/**
* Constructor
* @param poa poa which will activate this and also all other components
* @param name component name
*/
TelescopeImpl(
const ACE_CString& name,
maci::ContainerServices * containerServices);
/**
* Destructor
*/
virtual ~TelescopeImpl();
//initialize
virtual void initialize()
throw (acsErrTypeLifeCycle::acsErrTypeLifeCycleExImpl);
virtual void execute()
throw (acsErrTypeLifeCycle::acsErrTypeLifeCycleExImpl);
virtual void cleanUp();
/**
* Moves to the given position and takes an exposure
* of length exposureTime (seconds). Raises and exception
* if the requested position is out of limits.
*
* @param coordinates target coordinates
* @param exposureTime exposure time of the current observation
* @return Image
*
*/
TYPES::ImageType* observe(const ::TYPES::Position & coordinates,
::CORBA::Long exposureTime);
//raises(UOSErr::PositionOutOfLimitsEx);
/**
* Commands the telescope to move to the given position. Raises
* an exception if the requested position is out of limits.
*
* @param coordinates Requested telescope position
* @return None
*/
void moveTo(const ::TYPES::Position & coordinates);
//raises(UOSErr::PositionOutOfLimitsEx);
/**
* Get the current telescope position.
*
* @return current telescope position
*/
TYPES::Position getCurrentPosition();
private:
maci::ContainerServices * m_containerServices;
H3E::TelescopeControl_var m_nexstar_p;
INSTRUMENT_MODULE::Instrument_var m_instrument_p;
TYPES::ImageType* m_image_p;
}; // class Telescope
#endif // Telescope_H
| [
"alexis.tejeda@d7a85929-a13b-5166-4859-8762c7bf5a63"
]
| [
[
[
1,
100
]
]
]
|
ba4154551cd4807f9bc7d8888cccfafe1803e92f | 5e72c94a4ea92b1037217e31a66e9bfee67f71dd | /old/src/ThroughputDetail.h | d49789db7f514cb0c6bd9c8683e3ea5582d70b1f | []
| no_license | stein1/bbk | 1070d2c145e43af02a6df14b6d06d9e8ed85fc8a | 2380fc7a2f5bcc9cb2b54f61e38411468e1a1aa8 | refs/heads/master | 2021-01-17T23:57:37.689787 | 2011-05-04T14:50:01 | 2011-05-04T14:50:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 248 | h | #pragma once
#include "includes.h"
#include "TestDetailDialog.h"
class ThroughputDetail : public TestDetailDialog
{
public:
ThroughputDetail(wxWindow *parent, int row = 0);
~ThroughputDetail(void);
void RefreshList(int irow);
};
| [
"[email protected]"
]
| [
[
[
1,
13
]
]
]
|
52e510f1353626a4e9eb9213a068f3471a65609d | 96e96a73920734376fd5c90eb8979509a2da25c0 | /C3DE/PerPixelLighting.cpp | d326c35e35d640ac40e6178567395171fb21167c | []
| no_license | lianlab/c3de | 9be416cfbf44f106e2393f60a32c1bcd22aa852d | a2a6625549552806562901a9fdc083c2cacc19de | refs/heads/master | 2020-04-29T18:07:16.973449 | 2009-11-15T10:49:36 | 2009-11-15T10:49:36 | 32,124,547 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,961 | cpp | #include "PerPixelLighting.h"
#include "DebugMemory.h"
PerPixelLighting::PerPixelLighting(ID3DXEffect *effect):
FX(effect)
{
m_shaderObjectAmbientMaterial = m_effect->GetParameterByName(0, "gAmbientMtrl");
m_shaderObjectDiffuseMaterial = m_effect->GetParameterByName(0, "gDiffuseMtrl");
m_shaderObjectSpecularMaterial = m_effect->GetParameterByName(0, "gSpecMtrl");
m_shaderSpecularLightPower = m_effect->GetParameterByName(0, "gSpecPower");
m_hTex = m_effect->GetParameterByName(0, "gTex");
m_shaderTransformMatrix = m_effect->GetParameterByName(0, "gTransformMatrix");
D3DXMATRIX M;
D3DXMatrixIdentity(&M);
HR(m_effect->SetMatrix(m_shaderTransformMatrix, &M));
m_shaderLightPosition = m_effect->GetParameterByName(0, "gLightPosW");
m_shaderSpecularLightMaterial = m_effect->GetParameterByName(0, "gSpecLight");
m_shaderAlpha = m_effect->GetParameterByName(0, "gAlpha");
}
PerPixelLighting::~PerPixelLighting()
{
}
void PerPixelLighting::ResetHandlers()
{
D3DXMATRIX T;
D3DXMatrixIdentity(&T);
SetTransformMatrix(T);
}
void PerPixelLighting::SetAlpha(float alpha)
{
HR(m_effect->SetFloat(m_shaderAlpha, alpha));
}
void PerPixelLighting::SetObjectMaterials(D3DXCOLOR ambientMaterial, D3DXCOLOR diffuseMaterial,
D3DXCOLOR specularMaterial, float specularPower)
{
D3DXVECTOR3 t = D3DXVECTOR3(0.0f, 2.0f, 0.0f);
HR(m_effect->SetValue(m_shaderLightPosition, &t, sizeof(D3DXVECTOR3)));
HR(m_effect->SetValue(m_shaderObjectAmbientMaterial, &ambientMaterial,sizeof(D3DXCOLOR)));
HR(m_effect->SetValue(m_shaderObjectDiffuseMaterial, &diffuseMaterial, sizeof(D3DXCOLOR)));
HR(m_effect->SetValue(m_shaderObjectSpecularMaterial, &specularMaterial, sizeof(D3DXCOLOR)));
HR(m_effect->SetFloat(m_shaderSpecularLightPower, specularPower));
}
void PerPixelLighting::SetObjectTexture(IDirect3DTexture9 *texture)
{
HR(m_effect->SetTexture(m_hTex, texture));
} | [
"caiocsabino@7e2be596-0d54-0410-9f9d-cf4183935158"
]
| [
[
[
1,
64
]
]
]
|
e6db356d5b839ed55d3489c73b5867cc7ef89ec7 | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/Dependencies/Xerces/include/xercesc/dom/StDOMNode.hpp | fcfea05e160db9b2c48a1e7240dc1f9d51f4c530 | []
| 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 | 3,092 | hpp | #ifndef DOMSPtr_HEADER_GUARD_
#define DOMSPtr_HEADER_GUARD_
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: StDOMNode.hpp 176026 2004-09-08 13:57:07Z peiyongz $
*/
#include <xercesc/dom/DOMNode.hpp>
#include <xercesc/dom/DOMAttr.hpp>
#include <xercesc/dom/DOMElement.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/* This class is a smart pointer implementation over DOMNode interface and
** classes derived from it. It takes care of reference counting automatically.
** Reference counting is optional so use of this class is experimental.
*/
template <class T> class StDOMNode {
T* m_node;
static inline void INCREFCOUNT(T *x) { if (x != (T*)0) x->incRefCount(); }
static inline void DECREFCOUNT(T *x) { if (x != (T*)0) x->decRefCount(); }
public:
inline StDOMNode(T* node = (T*)0) : m_node(node) { INCREFCOUNT(m_node); }
inline StDOMNode(const StDOMNode& stNode) : m_node(stNode.m_node) { INCREFCOUNT(m_node); }
inline ~StDOMNode() { DECREFCOUNT(m_node); }
inline T* operator= (T *node)
{
if (m_node != node) {
DECREFCOUNT(m_node);
m_node = node;
INCREFCOUNT(m_node);
}
return (m_node);
}
inline bool operator!= (T* node) const { return (m_node != node); }
inline bool operator== (T* node) const { return (m_node == node); }
inline T& operator* () { return (*m_node); }
inline const T& operator* () const { return (*m_node); }
inline T* operator-> () const { return (m_node); }
inline operator T*() const { return (m_node); }
inline void ClearNode() { operator=((T*)(0)); }
};
#if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
typedef StDOMNode<DOMNode> DOMNodeSPtr;
#else
typedef DOMNode* DOMNodeSPtr;
#endif
/* StDOMNode is a smart pointer implementation over DOMNode interface and
** classes derived from it. It takes care of reference counting automatically.
** Reference counting is optional so use of this class is experimental.
*/
#if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
typedef StDOMNode<DOMAttr> DOMAttrSPtr;
#else
typedef DOMAttr* DOMAttrSPtr;
#endif
/* StDOMNode is a smart pointer implementation over DOMNode interface and
** classes derived from it. It takes care of reference counting automatically.
** Reference counting is optional so use of this class is experimental.
*/
#if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
typedef StDOMNode<DOMElement> DOMElementSPtr;
#else
typedef DOMElement* DOMElementSPtr;
#endif
XERCES_CPP_NAMESPACE_END
#endif
| [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
]
| [
[
[
1,
94
]
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.