init
This commit is contained in:
@@ -79,7 +79,6 @@
|
||||
OutputFile="./Blocks3D.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalManifestDependencies=""
|
||||
ProgramDatabaseFile=".\Release/Blocks3D.pdb"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"
|
||||
@@ -146,7 +145,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="".\src\include""
|
||||
AdditionalIncludeDirectories=""C:\libraries\ode-0.5\include\drawstuff";.\src\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
|
||||
MinimalRebuild="false"
|
||||
BasicRuntimeChecks="0"
|
||||
@@ -173,7 +172,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Advapi32.lib UxTheme.lib Comctl32.lib Comdlg32.lib Shell32.lib Urlmon.lib ole32.lib oleaut32.lib uuid.lib"
|
||||
AdditionalDependencies="Advapi32.lib UxTheme.lib Comctl32.lib Comdlg32.lib Shell32.lib Urlmon.lib ole32.lib oleaut32.lib uuid.lib oded.lib OPCODE_D.lib"
|
||||
OutputFile="./Blocks3D-Debug.exe"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="true"
|
||||
@@ -645,6 +644,14 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="XplicitNgine"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\source\XplicitNgine\XplicitNgine.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
@@ -730,10 +737,6 @@
|
||||
RelativePath=".\src\include\WindowFunctions.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\include\winver.h"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="RapidXML"
|
||||
>
|
||||
@@ -882,21 +885,25 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="XplicitNgine"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\include\XplicitNgine\XplicitNgine.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\B3dIcon.ico"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Dialogs.rc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\FatB3dIcon.ico"
|
||||
RelativePath=".\icon1.ico"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "IEBrowser.h"
|
||||
#include "Mouse.h"
|
||||
#include "Tool/Tool.h"
|
||||
#include "XplicitNgine/XplicitNgine.h"
|
||||
//#include "GuiRoot.h"
|
||||
|
||||
class TextButtonInstance;
|
||||
@@ -75,6 +76,7 @@ class Application { // : public GApp {
|
||||
HWND _buttonTest;
|
||||
HWND _hwndRenderer;
|
||||
DataModelInstance* _dataModel;
|
||||
XplicitNgine* _xplicitNgine;
|
||||
G3D::TextureRef shadowMap;
|
||||
std::string _title;
|
||||
bool _dragging;
|
||||
|
||||
@@ -26,6 +26,7 @@ class CameraController {
|
||||
void panRight();
|
||||
void tiltUp();
|
||||
void tiltDown();
|
||||
void zoomExtents();
|
||||
void Zoom(short delta);
|
||||
bool onMouseWheel(int x, int y, short delta);
|
||||
GCamera* getCamera();
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
#include <G3DAll.h>
|
||||
#include "propertyGrid.h"
|
||||
#include "map"
|
||||
|
||||
#ifdef NO_SPRINTF
|
||||
#define sprintf_s sprintf
|
||||
#endif
|
||||
//#include "Properties/BoolProperty.h"
|
||||
|
||||
class Instance
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "instance.h"
|
||||
#include "enum.h"
|
||||
#include <ode/ode.h>
|
||||
|
||||
class PVInstance :
|
||||
public Instance
|
||||
|
||||
@@ -30,6 +30,8 @@ public:
|
||||
Color3 color;
|
||||
bool canCollide;
|
||||
bool anchored;
|
||||
dBodyID physBody;
|
||||
dGeomID physGeom[3];
|
||||
|
||||
//Getters
|
||||
Vector3 getPosition();
|
||||
|
||||
@@ -9,5 +9,6 @@ public:
|
||||
WorkspaceInstance(void);
|
||||
~WorkspaceInstance(void);
|
||||
void clearChildren();
|
||||
void zoomToExtents();
|
||||
std::vector<PartInstance *> partObjects;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "DataModelV2/DataModelInstance.h"
|
||||
|
||||
#include "XplicitNgine/XplicitNgine.h"
|
||||
|
||||
class Application;
|
||||
|
||||
@@ -28,6 +28,7 @@ extern std::vector<Instance*> postRenderStack;
|
||||
extern std::vector<Instance*> g_selectedInstances;
|
||||
extern bool running;
|
||||
extern DataModelInstance* g_dataModel;
|
||||
extern XplicitNgine* g_xplicitNgine;
|
||||
extern Application* g_usableApp;
|
||||
|
||||
extern GFontRef g_fntdominant;
|
||||
|
||||
15
src/include/XplicitNgine/XplicitNgine.h
Normal file
15
src/include/XplicitNgine/XplicitNgine.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include <ode/ode.h>
|
||||
#include "DatamodelV2/PartInstance.h"
|
||||
|
||||
class XplicitNgine
|
||||
{
|
||||
public:
|
||||
XplicitNgine();
|
||||
~XplicitNgine();
|
||||
dWorldID physWorld;
|
||||
dSpaceID physSpace;
|
||||
dJointGroupID contactgroup;
|
||||
|
||||
void createBody(PartInstance* partInstance);
|
||||
};
|
||||
7
src/include/resource.h
Normal file
7
src/include/resource.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#define IDC_PROPERTYGRID 2000
|
||||
#define IDC_STATIC 2
|
||||
|
||||
#define IDE_EDIT 105
|
||||
#define IDI_ICON1 102
|
||||
#define IDB_BITMAP1 103
|
||||
#define IDD_DIALOG1 104
|
||||
@@ -1,5 +0,0 @@
|
||||
#ifndef WINVER
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#define _WIN32_WINDOWS 0x0400
|
||||
#define WINVER 0x0400
|
||||
#endif
|
||||
@@ -1,13 +1,14 @@
|
||||
#include <G3DAll.h>
|
||||
#include <initguid.h>
|
||||
#include <iomanip>
|
||||
#include "../../resource.h"
|
||||
#include "resource.h"
|
||||
#include "DataModelV2/Instance.h"
|
||||
#include "DataModelV2/PartInstance.h"
|
||||
#include "DataModelV2/TextButtonInstance.h"
|
||||
#include "DataModelV2/ImageButtonInstance.h"
|
||||
#include "DataModelV2/DataModelInstance.h"
|
||||
#include "DataModelV2/GuiRootInstance.h"
|
||||
#include "XplicitNgine/XplicitNgine.h"
|
||||
#include "CameraController.h"
|
||||
#include "AudioPlayer.h"
|
||||
#include "Globals.h"
|
||||
@@ -188,9 +189,11 @@ void Application::onInit() {
|
||||
_dataModel->font = g_fntdominant;
|
||||
g_dataModel = _dataModel;
|
||||
|
||||
//initGUI();
|
||||
_xplicitNgine = new XplicitNgine();
|
||||
g_xplicitNgine = _xplicitNgine;
|
||||
|
||||
#ifdef LEGACY_LOAD_G3DFUN_LEVEL
|
||||
// Anchored this baseplate for XplicitNgine tests
|
||||
PartInstance* test = makePart();
|
||||
test->setParent(_dataModel->getWorkspace());
|
||||
test->color = Color3(0.2F,0.3F,1);
|
||||
@@ -198,7 +201,8 @@ void Application::onInit() {
|
||||
test->setPosition(Vector3(0,0,0));
|
||||
test->setCFrame(test->getCFrame() * Matrix3::fromEulerAnglesXYZ(0,toRadians(0),toRadians(0)));
|
||||
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
||||
|
||||
test->anchored = true;
|
||||
|
||||
test = makePart();
|
||||
test->setParent(_dataModel->getWorkspace());
|
||||
test->color = Color3(.5F,1,.5F);
|
||||
@@ -262,9 +266,6 @@ void Application::onInit() {
|
||||
test->setPosition(Vector3(-2,5,0));
|
||||
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
||||
|
||||
|
||||
|
||||
|
||||
test = makePart();
|
||||
test->setParent(_dataModel->getWorkspace());
|
||||
test->color = Color3::gray();
|
||||
@@ -294,86 +295,20 @@ void Application::onInit() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Application::onCleanup() {
|
||||
clearInstances();
|
||||
sky->~Sky();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Class HyperSnapSolver
|
||||
|
||||
function getCollisionDepth(Part colliding, part collider);
|
||||
function getFaceCollision(Part colliding, part collider);
|
||||
|
||||
function eject(Part colliding, Part collider)
|
||||
{
|
||||
if(!colliding.canCollide || !collider.canCollide)
|
||||
return;
|
||||
if(getCollisionDepth(colliding, collider) != 0) {
|
||||
int ejectMultiplier, ejectMultipliery = 1-(collider.Friction+colliding.Friction), ejectMultiplierz = 1-(collider.Friction/2+colliding.Friction/2);
|
||||
if(colliding.Anchored)
|
||||
ejectMultiplier = collider.elasticity;
|
||||
int faceCollided = getFaceCollision(colliding, collider);
|
||||
if(faceCollided % 3 == 1)
|
||||
{
|
||||
ejectMultipliery = ejectMultiplier;
|
||||
ejectMultiplier = 1-(collider.Friction+colliding.Friction/2);
|
||||
}
|
||||
else if(faceCollided % 3 == 2)
|
||||
{
|
||||
ejectMultiplierz = ejectMultiplier;
|
||||
ejectMultiplier = 1-(collider.Friction+colliding.Friction/2);
|
||||
}
|
||||
|
||||
collider.Velocity *= Vector3.new(colliding.Velocity.x*ejectMultiplier,colliding.Velocity.y*ejectMultipliery,colliding.Velocity.z)
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
double grav = 0.32666666666666666666666666666667;
|
||||
void simGrav(PartInstance * collider)
|
||||
{
|
||||
if(!collider->anchored)
|
||||
{
|
||||
collider->setPosition(collider->getPosition()+collider->getVelocity());
|
||||
collider->setVelocity(collider->getVelocity()-Vector3(0,grav,0));
|
||||
}
|
||||
}
|
||||
|
||||
void eject(PartInstance * colliding, PartInstance * collider)
|
||||
{
|
||||
if(colliding == collider || !colliding->canCollide || !collider->canCollide)
|
||||
return;
|
||||
if(G3D::CollisionDetection::fixedSolidBoxIntersectsFixedSolidBox(collider->getBox(), colliding->getBox()))
|
||||
collider->setVelocity(collider->getVelocity().reflectionDirection(colliding->getCFrame().upVector())/1.3F);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Application::onLogic() {
|
||||
//PhysicsStart
|
||||
for_each (_dataModel->getWorkspace()->partObjects.begin(), _dataModel->getWorkspace()->partObjects.end(), simGrav);
|
||||
void Application::onLogic() {
|
||||
// XplicitNgine Start
|
||||
for(size_t i = 0; i < _dataModel->getWorkspace()->partObjects.size(); i++)
|
||||
{
|
||||
for(size_t j = 0; j < _dataModel->getWorkspace()->partObjects.size(); j++)
|
||||
{
|
||||
eject(_dataModel->getWorkspace()->partObjects[i], _dataModel->getWorkspace()->partObjects[j]);
|
||||
}
|
||||
}
|
||||
PartInstance* partInstance = _dataModel->getWorkspace()->partObjects[i];
|
||||
_xplicitNgine->createBody(partInstance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Application::onNetwork() {
|
||||
// Poll net messages here
|
||||
}
|
||||
@@ -407,95 +342,29 @@ void Application::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
||||
|
||||
}
|
||||
|
||||
/*double getOSVersion() {
|
||||
OSVERSIONINFO osvi;
|
||||
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
|
||||
GetVersionEx(&osvi);
|
||||
std::string version = Convert(osvi.dwMajorVersion) + "." + Convert(osvi.dwMinorVersion);
|
||||
return ::atof(version.c_str());
|
||||
}*/
|
||||
/*
|
||||
bool IsHolding(int button)
|
||||
{
|
||||
return (GetKeyState(button) >> 1)>0;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
void Application::onUserInput(UserInput* ui) {
|
||||
if(mouseMoveState)
|
||||
{
|
||||
mouseMoveState = false;
|
||||
tool->onMouseMoved(mouse);
|
||||
}
|
||||
/*
|
||||
if(GetHoldKeyState(VK_LCONTROL))
|
||||
{
|
||||
if(GetHoldKeyState('D'))
|
||||
{
|
||||
_messageTime = System::time();
|
||||
if(debugMode())
|
||||
_message = "Debug Mode Disabled";
|
||||
else
|
||||
_message = "Debug Mode Enabled";
|
||||
setDebugMode(!debugMode());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if(GetHoldKeyState(VK_F8))
|
||||
{
|
||||
_dataModel->getGuiRoot()->setDebugMessage("FOV Set to 10", System::time());
|
||||
}
|
||||
//}
|
||||
|
||||
//_dataModel->mousex = ui->getMouseX();
|
||||
//_dataModel->mousey = ui->getMouseY();
|
||||
mouse.setMouseDown((GetKeyState(VK_LBUTTON) & 0x100) != 0);
|
||||
|
||||
if (GetHoldKeyState(VK_LBUTTON)) {
|
||||
/* if (_dragging) {
|
||||
PartInstance* part = NULL;
|
||||
if(g_selectedInstances.size() > 0)
|
||||
part = (PartInstance*) g_selectedInstances.at(0);
|
||||
Ray dragRay = cameraController.getCamera()->worldRay(mouse.x, mouse.y, renderDevice->getViewport());
|
||||
std::vector<Instance*> instances = _dataModel->getWorkspace()->getAllChildren();
|
||||
for(size_t i = 0; i < instances.size(); i++)
|
||||
{
|
||||
if(PartInstance* moveTo = dynamic_cast<PartInstance*>(instances.at(i)))
|
||||
{
|
||||
float __time = testRay.intersectionTime(moveTo->getBox());
|
||||
float __nearest=std::numeric_limits<float>::infinity();
|
||||
if (__time != inf())
|
||||
{
|
||||
if (__nearest>__time)
|
||||
{
|
||||
// BROKEN
|
||||
//Vector3 closest = (dragRay.closestPoint(moveTo->getPosition()) * 2);
|
||||
//part->setPosition(closest);
|
||||
//part->setPosition(Vector3(floor(closest.x),part->getPosition().y,floor(closest.z)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Sleep(10);
|
||||
}*/
|
||||
}
|
||||
// Camera KB Handling {
|
||||
if (GetKPBool(VK_OEM_COMMA)) //Left
|
||||
g_usableApp->cameraController.panLeft();
|
||||
else if (GetKPBool(VK_OEM_PERIOD)) // Right
|
||||
g_usableApp->cameraController.panRight();
|
||||
else if (GetKPBool(0x49)) // Zoom In (I)
|
||||
g_usableApp->cameraController.Zoom(1);
|
||||
else if (GetKPBool(0x4F)) // Zoom Out (O)
|
||||
g_usableApp->cameraController.Zoom(-1);
|
||||
// }
|
||||
|
||||
//readMouseGUIInput();
|
||||
// Add other key handling here
|
||||
// Camera KB Handling
|
||||
if (GetKPBool(VK_OEM_COMMA)) //Left
|
||||
g_usableApp->cameraController.panLeft();
|
||||
else if (GetKPBool(VK_OEM_PERIOD)) // Right
|
||||
g_usableApp->cameraController.panRight();
|
||||
else if (GetKPBool(0x49)) // Zoom In (I)
|
||||
g_usableApp->cameraController.Zoom(1);
|
||||
else if (GetKPBool(0x4F)) // Zoom Out (O)
|
||||
g_usableApp->cameraController.Zoom(-1);
|
||||
}
|
||||
|
||||
void Application::changeTool(Tool * newTool)
|
||||
@@ -793,11 +662,6 @@ void Application::onKeyPressed(int key)
|
||||
{
|
||||
_dataModel->getOpen();
|
||||
}
|
||||
if ((GetHoldKeyState(VK_LCONTROL) || GetHoldKeyState(VK_RCONTROL)) && key=='A')
|
||||
{
|
||||
std::vector<Instance *> vec = _dataModel->getWorkspace()->getAllChildren();
|
||||
g_selectedInstances.insert(g_selectedInstances.end(), vec.begin(), vec.end());
|
||||
}
|
||||
tool->onKeyDown(key);
|
||||
}
|
||||
void Application::onKeyUp(int key)
|
||||
@@ -948,6 +812,8 @@ void Application::run() {
|
||||
RealTime rdt = timeStep;
|
||||
SimTime sdt = timeStep * rate;
|
||||
SimTime idt = desiredFrameDuration * rate;
|
||||
|
||||
|
||||
|
||||
onSimulation(rdt,sdt,idt);
|
||||
m_simulationWatch.tock();
|
||||
|
||||
@@ -159,6 +159,11 @@ void CameraController::tiltDown()
|
||||
setFrame(frame);
|
||||
}
|
||||
|
||||
void CameraController::zoomExtents()
|
||||
{
|
||||
// do some weird jank math
|
||||
}
|
||||
|
||||
void CameraController::centerCamera(Instance* selection)
|
||||
{
|
||||
CoordinateFrame frame = CoordinateFrame(g3dCamera.getCoordinateFrame().translation);
|
||||
|
||||
@@ -13,7 +13,6 @@ using namespace std;
|
||||
using namespace rapidxml;
|
||||
|
||||
|
||||
|
||||
DataModelInstance::DataModelInstance(void)
|
||||
{
|
||||
Instance::Instance();
|
||||
@@ -519,6 +518,7 @@ bool DataModelInstance::getOpen()
|
||||
of.lpstrFile[0]='\0';
|
||||
of.nMaxFile=500;
|
||||
of.lpstrTitle="Hello";
|
||||
of.Flags = OFN_FILEMUSTEXIST;
|
||||
ShowCursor(TRUE);
|
||||
BOOL file = GetOpenFileName(&of);
|
||||
if (file)
|
||||
@@ -526,7 +526,6 @@ bool DataModelInstance::getOpen()
|
||||
_loadedFileName = of.lpstrFile;
|
||||
load(of.lpstrFile,true);
|
||||
}
|
||||
//else MessageBox(NULL, "Failed to open dialog", "Failure", MB_ICONHAND | MB_OK);
|
||||
return true;
|
||||
}
|
||||
void DataModelInstance::setMessage(std::string msg)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#define WINVER 0x0400
|
||||
#include <G3DAll.h>
|
||||
#include "DataModelV2/Instance.h"
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ PartInstance::PartInstance(void)
|
||||
left = Enum::SurfaceType::Smooth;
|
||||
bottom = Enum::SurfaceType::Smooth;
|
||||
shape = Enum::Shape::Block;
|
||||
physBody = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +280,6 @@ void PartInstance::render(RenderDevice* rd) {
|
||||
changed=false;
|
||||
Vector3 renderSize = size/2;
|
||||
glNewList(glList, GL_COMPILE);
|
||||
//glScalef(0.5f,0.5f,0.5f);
|
||||
renderShape(this->shape, renderSize, color);
|
||||
renderSurface(TOP, this->top, renderSize, this->controller, color);
|
||||
renderSurface(FRONT, this->front, renderSize, this->controller, color);
|
||||
@@ -297,6 +297,16 @@ void PartInstance::render(RenderDevice* rd) {
|
||||
PartInstance::~PartInstance(void)
|
||||
{
|
||||
glDeleteLists(glList, 1);
|
||||
/*
|
||||
// Causes some weird ODE error
|
||||
// Someone, please look into this
|
||||
|
||||
dBodyDestroy(physBody);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (physGeom[i] != NULL)
|
||||
dGeomDestroy(physGeom[i]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
char pto[512];
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "DataModelV2/WorkspaceInstance.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Application.h"
|
||||
|
||||
WorkspaceInstance::WorkspaceInstance(void)
|
||||
{
|
||||
@@ -15,6 +16,11 @@ void WorkspaceInstance::clearChildren()
|
||||
Instance::clearChildren();
|
||||
}
|
||||
|
||||
void WorkspaceInstance::zoomToExtents()
|
||||
{
|
||||
g_usableApp->cameraController.zoomExtents();
|
||||
}
|
||||
|
||||
WorkspaceInstance::~WorkspaceInstance(void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ std::vector<Instance*> postRenderStack = std::vector<Instance*>();
|
||||
|
||||
std::vector<Instance*> g_selectedInstances = std::vector<Instance*>();
|
||||
DataModelInstance* g_dataModel = NULL;
|
||||
XplicitNgine* g_xplicitNgine = NULL;
|
||||
|
||||
bool running = false;
|
||||
G3D::TextureRef Globals::surface;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#define _WINSOCKAPI_
|
||||
#include <windows.h>
|
||||
#include "WindowFunctions.h"
|
||||
#include "../../resource.h"
|
||||
#include "resource.h"
|
||||
#include "PropertyWindow.h"
|
||||
#include "Globals.h"
|
||||
#include "strsafe.h"
|
||||
|
||||
@@ -69,30 +69,6 @@ void ArrowTool::onKeyDown(int key)
|
||||
{
|
||||
lctrlDown = true;
|
||||
}
|
||||
else if(key == 'R')
|
||||
{
|
||||
if(g_selectedInstances.size() > 0)
|
||||
{
|
||||
Instance* selectedInstance = g_selectedInstances.at(0);
|
||||
AudioPlayer::playSound(clickSound);
|
||||
if(PartInstance* part = dynamic_cast<PartInstance*>(selectedInstance))
|
||||
{
|
||||
part->setCFrame(part->getCFrame()*Matrix3::fromEulerAnglesXYZ(0,toRadians(90),0));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(key == 'T')
|
||||
{
|
||||
if(g_selectedInstances.size() > 0)
|
||||
{
|
||||
Instance* selectedInstance = g_selectedInstances.at(0);
|
||||
AudioPlayer::playSound(clickSound);
|
||||
if(PartInstance* part = dynamic_cast<PartInstance*>(selectedInstance))
|
||||
{
|
||||
part->setCFrame(part->getCFrame()*Matrix3::fromEulerAnglesXYZ(0,0,toRadians(90)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ArrowTool::onKeyUp(int key)
|
||||
|
||||
117
src/source/XplicitNgine/XplicitNgine.cpp
Normal file
117
src/source/XplicitNgine/XplicitNgine.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
#include "XplicitNgine/XplicitNgine.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#define SIDE (0.5f)
|
||||
#define MASS (1.0)
|
||||
|
||||
// constraints
|
||||
#define MAX_BODIES 65535
|
||||
#define OBJ_DENSITY (5.0)
|
||||
#define MAX_CONTACT_PER_BODY 4
|
||||
|
||||
XplicitNgine::XplicitNgine()
|
||||
{
|
||||
physWorld = dWorldCreate();
|
||||
physSpace = dHashSpaceCreate(0);
|
||||
contactgroup = dJointGroupCreate(0);
|
||||
|
||||
dWorldSetGravity(physWorld, 0, -0.5, 0);
|
||||
dGeomID ground_geom = dCreatePlane(physSpace, 0, 1, 0, 0);
|
||||
}
|
||||
|
||||
XplicitNgine::~XplicitNgine()
|
||||
{
|
||||
dJointGroupDestroy (contactgroup);
|
||||
dSpaceDestroy (physSpace);
|
||||
dWorldDestroy (physWorld);
|
||||
dCloseODE();
|
||||
}
|
||||
|
||||
void collisionCallback(void *data, dGeomID o1, dGeomID o2)
|
||||
{
|
||||
int i,n;
|
||||
|
||||
dBodyID b1 = dGeomGetBody(o1);
|
||||
dBodyID b2 = dGeomGetBody(o2);
|
||||
if (b1 && b2 && dAreConnected(b1, b2))
|
||||
return;
|
||||
|
||||
const int N = 4;
|
||||
dContact contact[N];
|
||||
n = dCollide (o1,o2,N,&contact[0].geom,sizeof(dContact));
|
||||
if (n > 0) {
|
||||
for (i=0; i<n; i++) {
|
||||
contact[i].surface.mode = dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactSoftCFM | dContactApprox1;
|
||||
if (dGeomGetClass(o1) == dSphereClass || dGeomGetClass(o2) == dSphereClass)
|
||||
contact[i].surface.mu = 20;
|
||||
else
|
||||
contact[i].surface.mu = 0.5;
|
||||
contact[i].surface.slip1 = 0.0;
|
||||
contact[i].surface.slip2 = 0.0;
|
||||
contact[i].surface.soft_erp = 0.8;
|
||||
contact[i].surface.soft_cfm = 0.01;
|
||||
dJointID c = dJointCreateContact (g_xplicitNgine->physWorld,g_xplicitNgine->contactgroup,contact+i);
|
||||
dJointAttach (c,dGeomGetBody(o1),dGeomGetBody(o2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void XplicitNgine::createBody(PartInstance* partInstance)
|
||||
{
|
||||
// calculate collisions
|
||||
dSpaceCollide (physSpace,0,&collisionCallback);
|
||||
|
||||
if(partInstance->physBody == NULL)
|
||||
{
|
||||
// init body
|
||||
partInstance->physBody = dBodyCreate(physWorld);
|
||||
|
||||
// init geom
|
||||
partInstance->physGeom[0] = dCreateBox(physSpace,
|
||||
partInstance->getSize()[0],
|
||||
partInstance->getSize()[1],
|
||||
partInstance->getSize()[2]
|
||||
);
|
||||
|
||||
dVector3 result;
|
||||
dGeomBoxGetLengths(partInstance->physGeom[0], result);
|
||||
printf("[XplicitNgine] Part Geom Size: %.1f, %.1f, %.1f\n",
|
||||
result[0],
|
||||
result[1],
|
||||
result[2]
|
||||
);
|
||||
|
||||
printf("[XplicitNgine] Created Geom for PartInstance\n");
|
||||
|
||||
dBodySetPosition(partInstance->physBody,
|
||||
partInstance->getPosition()[0],
|
||||
partInstance->getPosition()[1],
|
||||
partInstance->getPosition()[2]
|
||||
);
|
||||
|
||||
printf("[XplicitNgine] Created Body for PartInstance\n");
|
||||
|
||||
dGeomSetBody(partInstance->physGeom[0], partInstance->physBody);
|
||||
} else {
|
||||
// There is 100% a better way of doing this, but for now, anchored parts can be like this?
|
||||
if(partInstance->anchored) {
|
||||
dBodySetPosition(partInstance->physBody,
|
||||
partInstance->getPosition()[0],
|
||||
partInstance->getPosition()[1],
|
||||
partInstance->getPosition()[2]
|
||||
);
|
||||
|
||||
dBodySetLinearVel(partInstance->physBody, 0, 0, 0);
|
||||
}
|
||||
|
||||
const dReal* physPosition = dBodyGetPosition(partInstance->physBody);
|
||||
|
||||
// I hate matricies
|
||||
const dReal* physRotation = dGeomGetRotation(partInstance->physGeom[0]);
|
||||
partInstance->setPosition(Vector3(physPosition[0], physPosition[1], physPosition[2]));
|
||||
|
||||
}
|
||||
|
||||
dWorldQuickStep(physWorld,0.05);
|
||||
dJointGroupEmpty(contactgroup);
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
// TODO: Move toolbar buttons with resized window.
|
||||
#include "winver.h"
|
||||
#include "../../resource.h"
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#define _WIN32_WINDOWS 0x0400
|
||||
#define WINVER 0x0400
|
||||
#define _CRTBLD
|
||||
|
||||
#include "resource.h"
|
||||
#include "Application.h"
|
||||
#include "WindowFunctions.h"
|
||||
#include "ax.h"
|
||||
@@ -144,12 +148,7 @@ LRESULT CALLBACK G3DProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
long double a = 1;
|
||||
|
||||
#ifndef IGNORE_CATCH
|
||||
try{
|
||||
#endif
|
||||
hresult = OleInitialize(NULL);
|
||||
|
||||
/* IInternetSecurityManager *pSecurityMgr;
|
||||
@@ -174,7 +173,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
icc.dwSize = sizeof(icc);
|
||||
icc.dwICC = ICC_WIN95_CLASSES/*|ICC_COOL_CLASSES|ICC_DATE_CLASSES|
|
||||
// ICC_PAGESCROLLER_CLASS|ICC_USEREX_CLASSES*/;
|
||||
ICC_PAGESCROLLER_CLASS|ICC_USEREX_CLASSES*/;
|
||||
InitCommonControlsEx(&icc);
|
||||
|
||||
AudioPlayer::init();
|
||||
@@ -215,12 +214,10 @@ int main(int argc, char** argv) {
|
||||
Globals::mainHwnd = hwndMain;
|
||||
Application app = Application(hwndMain);
|
||||
app.run();
|
||||
#ifndef IGNORE_CATCH
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
OnError(-1);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -31,12 +31,13 @@
|
||||
|
||||
//DWM 1.9: Suppress POCC Warning "Argument x to 'sscanf' does not match the format string;
|
||||
// expected 'unsigned char *' but found 'unsigned long'"
|
||||
#include "winver.h"
|
||||
|
||||
#ifdef __POCC__
|
||||
#pragma warn(disable:2234)
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WINNT // Necessary for WM_MOUSEWHEEL support
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#endif
|
||||
|
||||
// MSVC++ Support
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
Reference in New Issue
Block a user