Merge pull request #20 from andreja6/MusicalProgrammer
Musical programmer
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "ButtonListener.h"
|
||||
|
||||
|
||||
ButtonListener::ButtonListener(void)
|
||||
ButtonListener::ButtonListener()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
#include "Demo.h"
|
||||
#include "BaseButtonInstance.h"
|
||||
class BaseButtonInstance;
|
||||
|
||||
class ButtonListener
|
||||
{
|
||||
public:
|
||||
ButtonListener(void);
|
||||
ButtonListener();
|
||||
~ButtonListener(void);
|
||||
virtual void onButton1MouseClick(BaseButtonInstance*);
|
||||
//virtual void onMouseOver(); //TODO
|
||||
|
||||
193
CameraController.cpp
Normal file
193
CameraController.cpp
Normal file
@@ -0,0 +1,193 @@
|
||||
#include "CameraController.h"
|
||||
#include "win32Defines.h"
|
||||
#include <iostream>
|
||||
#include "PhysicalInstance.h"
|
||||
#include "Demo.h"
|
||||
#include "AudioPlayer.h"
|
||||
|
||||
CameraController::CameraController(){
|
||||
yaw=0;
|
||||
pitch=0;
|
||||
moveRate=0.5f;
|
||||
forwards=false;
|
||||
backwards=false;
|
||||
left=false;
|
||||
right=false;
|
||||
rightButtonHolding=false;
|
||||
|
||||
}
|
||||
|
||||
GCamera* CameraController::getCamera()
|
||||
{
|
||||
return &g3dCamera;
|
||||
}
|
||||
|
||||
void CameraController::lookAt(const Vector3& position) {
|
||||
//g3dCamera.lookAt(position,g3dCamera.getCoordinateFrame().upVector());
|
||||
|
||||
const Vector3 look = (position - g3dCamera.getCoordinateFrame().translation);
|
||||
yaw = aTan2(look.x, -look.z);
|
||||
|
||||
pitch = -aTan2(look.y, distance(look.x, look.z));
|
||||
std::cout << distance(look.x, look.z) << "pitch:" << pitch << std::endl;
|
||||
CoordinateFrame frame = g3dCamera.getCoordinateFrame().translation;
|
||||
frame.rotation = Matrix3::fromEulerAnglesZYX(0, -yaw, -pitch);
|
||||
g3dCamera.setCoordinateFrame(frame);
|
||||
}
|
||||
|
||||
void CameraController::setFrame(const CoordinateFrame& cf) {
|
||||
Vector3 look = cf.getLookVector();
|
||||
g3dCamera.setCoordinateFrame(cf);
|
||||
lookAt(cf.translation + look);
|
||||
}
|
||||
|
||||
CoordinateFrame CameraController::getCoordinateFrame() {
|
||||
CoordinateFrame cf;
|
||||
cf.translation=translation;
|
||||
cf.rotation = Matrix3::fromEulerAnglesZYX(0, -yaw, -pitch);
|
||||
return cf;
|
||||
}
|
||||
|
||||
void CameraController::pan(int spdX, int spdY)
|
||||
{
|
||||
|
||||
}
|
||||
bool CameraController::onMouseWheel(int x, int y, short delta)
|
||||
{
|
||||
CoordinateFrame frame = g3dCamera.getCoordinateFrame();
|
||||
if (delta>0) { // Mouse wheel up
|
||||
g3dCamera.setCoordinateFrame(g3dCamera.getCoordinateFrame() + frame.lookVector()*2);
|
||||
}
|
||||
else {
|
||||
g3dCamera.setCoordinateFrame(g3dCamera.getCoordinateFrame() - frame.lookVector()*2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CameraController::panLeft()
|
||||
{
|
||||
CoordinateFrame frame = g3dCamera.getCoordinateFrame();
|
||||
float y = frame.translation.y;
|
||||
CoordinateFrame frame2 = CoordinateFrame(frame.rotation, frame.translation + frame.lookVector()*25);
|
||||
Vector3 focus = Vector3(0,0,0); //frame.translation+frame.lookVector()*25;
|
||||
frame2 = frame2 * Matrix3::fromEulerAnglesXYZ(0,toRadians(-45),0);
|
||||
frame2 = frame2 - frame2.lookVector()*25;
|
||||
Vector3 cameraPos = Vector3(frame2.translation.x, y, frame2.translation.z);
|
||||
CoordinateFrame newFrame = CoordinateFrame(frame2.rotation, Vector3(frame2.translation.x, y, frame2.translation.z));
|
||||
newFrame.lookAt(focus,frame2.upVector());
|
||||
setFrame(CoordinateFrame(focus));
|
||||
}
|
||||
void CameraController::panRight()
|
||||
{
|
||||
CoordinateFrame frame = g3dCamera.getCoordinateFrame();
|
||||
float y = frame.translation.y;
|
||||
CoordinateFrame frame2 = CoordinateFrame(frame.rotation, frame.translation + frame.lookVector()*25);
|
||||
Vector3 focus = frame.translation+frame.lookVector()*25;
|
||||
frame2 = frame2 * Matrix3::fromEulerAnglesXYZ(0,toRadians(45),0);
|
||||
frame2 = frame2 - frame2.lookVector()*25;
|
||||
Vector3 cameraPos = Vector3(frame2.translation.x, y, frame2.translation.z);
|
||||
CoordinateFrame newFrame = CoordinateFrame(frame2.rotation, Vector3(frame2.translation.x, y, frame2.translation.z));
|
||||
newFrame.lookAt(focus);
|
||||
setFrame(newFrame);
|
||||
}
|
||||
|
||||
void CameraController::tiltUp()
|
||||
{
|
||||
CoordinateFrame frame = CoordinateFrame(g3dCamera.getCoordinateFrame().rotation, g3dCamera.getCoordinateFrame().translation);
|
||||
Vector3 camerapoint = frame.translation;
|
||||
|
||||
Vector3 focalPoint = camerapoint + frame.lookVector() * 25;
|
||||
float distance = pow(pow((double)focalPoint.x - (double)camerapoint.x, 2) + pow((double)camerapoint.y - (double)camerapoint.y, 2) + pow((double)focalPoint.z - (double)camerapoint.z, 2), 0.5);
|
||||
float x = distance * cos(22.5 * G3D::pi() / 180) + focalPoint.x;
|
||||
float z = distance * sin(22.5 * G3D::pi() / 180) + focalPoint.z;
|
||||
camerapoint = Vector3(camerapoint.x, camerapoint.y+2, camerapoint.z);
|
||||
|
||||
CoordinateFrame newFrame = CoordinateFrame(camerapoint);
|
||||
newFrame.lookAt(focalPoint);
|
||||
Vector3 cameraPos = camerapoint;
|
||||
frame = newFrame;
|
||||
setFrame(newFrame);
|
||||
}
|
||||
void CameraController::tiltDown()
|
||||
{
|
||||
}
|
||||
|
||||
void CameraController::centerCamera(Instance* selection)
|
||||
{
|
||||
CoordinateFrame frame = CoordinateFrame(g3dCamera.getCoordinateFrame().translation);
|
||||
if(selection == NULL)
|
||||
lookAt(Vector3(0,0,0));
|
||||
else
|
||||
lookAt(((PhysicalInstance*)selection)->getPosition()/2);
|
||||
}
|
||||
|
||||
void CameraController::update(Demo* demo)
|
||||
{
|
||||
float offsetSize = 0.05F;
|
||||
|
||||
Vector3 cameraPos = g3dCamera.getCoordinateFrame().translation;
|
||||
CoordinateFrame frame = g3dCamera.getCoordinateFrame();
|
||||
|
||||
if(GetHoldKeyState('U')) {
|
||||
forwards = true;
|
||||
}
|
||||
if(GetHoldKeyState('J')) {
|
||||
backwards = true;
|
||||
}
|
||||
if(GetHoldKeyState('H')) {
|
||||
left = true;
|
||||
}
|
||||
if(GetHoldKeyState('K')) {
|
||||
right = true;
|
||||
}
|
||||
|
||||
if(forwards) {
|
||||
forwards = false;
|
||||
frame.translation += frame.lookVector()*moveRate;
|
||||
}
|
||||
else if(backwards) {
|
||||
backwards = false;
|
||||
frame.translation -= frame.lookVector()*moveRate;
|
||||
}
|
||||
if(left) {
|
||||
left = false;
|
||||
frame.translation += frame.leftVector()*moveRate;
|
||||
}
|
||||
else if(right) {
|
||||
right = false;
|
||||
frame.translation += frame.rightVector()*moveRate;
|
||||
}
|
||||
|
||||
|
||||
if(rightButtonHolding) {
|
||||
POINT mouse;
|
||||
GetCursorPos(&mouse);
|
||||
|
||||
yaw+=(mouse.x-oldDesktopMouse.x)/100.f;
|
||||
pitch+=(mouse.y-oldDesktopMouse.y)/100.f;
|
||||
|
||||
SetCursorPos(oldDesktopMouse.x,oldDesktopMouse.y);
|
||||
frame.rotation = Matrix3::fromEulerAnglesZYX(0, -yaw, -pitch);
|
||||
}
|
||||
|
||||
if(GetHoldKeyState(VK_RSHIFT) || GetHoldKeyState(VK_LSHIFT)) {
|
||||
moveRate = 1;
|
||||
}
|
||||
else {
|
||||
moveRate = 0.5;
|
||||
}
|
||||
|
||||
if(GetHoldKeyState(VK_RBUTTON))
|
||||
{
|
||||
if (rightButtonHolding==false)
|
||||
{
|
||||
GetCursorPos(&oldDesktopMouse);
|
||||
rightButtonHolding = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rightButtonHolding = false;
|
||||
}
|
||||
g3dCamera.setCoordinateFrame(frame);
|
||||
}
|
||||
39
CameraController.h
Normal file
39
CameraController.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <G3DAll.h>
|
||||
#include "Instance.h"
|
||||
#include <string>
|
||||
|
||||
class Demo;
|
||||
|
||||
class CameraController {
|
||||
public:
|
||||
CameraController();
|
||||
G3D::CoordinateFrame getCoordinateFrame();
|
||||
|
||||
void setFrame(const CoordinateFrame& cf);
|
||||
void lookAt(const Vector3& position);
|
||||
void pan(int spdX,int spdY);
|
||||
void update(Demo* demo);
|
||||
void centerCamera(Instance* selection);
|
||||
void panLeft();
|
||||
void panRight();
|
||||
void tiltUp();
|
||||
void tiltDown();
|
||||
bool onMouseWheel(int x, int y, short delta);
|
||||
GCamera* getCamera();
|
||||
private:
|
||||
Vector3 translation;
|
||||
Vector3 focusPosition;
|
||||
float yaw;
|
||||
float pitch;
|
||||
float moveRate;
|
||||
bool forwards;
|
||||
bool backwards;
|
||||
bool left;
|
||||
bool right;
|
||||
bool rightButtonHolding;
|
||||
POINT oldDesktopMouse;
|
||||
GCamera g3dCamera;
|
||||
std::string cameraSound;
|
||||
};
|
||||
@@ -56,7 +56,20 @@ WorkspaceInstance* DataModelInstance::getWorkspace()
|
||||
{
|
||||
return workspace;
|
||||
}
|
||||
|
||||
Vector2 DataModelInstance::getMousePos()
|
||||
{
|
||||
return Vector2(mousex,mousey);
|
||||
}
|
||||
void DataModelInstance::setMousePos(int x,int y)
|
||||
{
|
||||
mousex=x;
|
||||
mousey=y;
|
||||
}
|
||||
void DataModelInstance::setMousePos(Vector2 pos)
|
||||
{
|
||||
mousex=pos.x;
|
||||
mousey=pos.y;
|
||||
}
|
||||
Instance* DataModelInstance::getGuiRoot()
|
||||
{
|
||||
return guiRoot;
|
||||
|
||||
@@ -16,5 +16,8 @@ public:
|
||||
Instance* getGuiRoot();
|
||||
float mousex;
|
||||
float mousey;
|
||||
Vector2 getMousePos();
|
||||
void setMousePos(int x,int y);
|
||||
void setMousePos(Vector2 pos);
|
||||
bool mouseButton1Down;
|
||||
};
|
||||
|
||||
36
Demo.h
Normal file
36
Demo.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include <G3DAll.h>
|
||||
#include "CameraController.h"
|
||||
|
||||
class Demo : public GApp {
|
||||
public:
|
||||
Demo(const GAppSettings& settings,Win32Window* wind);
|
||||
virtual ~Demo() {}
|
||||
virtual void exitApplication();
|
||||
virtual void onInit();
|
||||
virtual void onLogic();
|
||||
virtual void onNetwork();
|
||||
virtual void onSimulation(RealTime rdt, SimTime sdt, SimTime idt);
|
||||
virtual void onGraphics(RenderDevice* rd);
|
||||
virtual void onUserInput(UserInput* ui);
|
||||
virtual void onCleanup();
|
||||
|
||||
Instance* getSelection();
|
||||
void QuitApp();
|
||||
void onKeyPressed(int key);
|
||||
void onKeyUp(int key);
|
||||
void onMouseLeftPressed(int x, int y);
|
||||
void onMouseLeftUp(int x, int y);
|
||||
void onMouseRightPressed(int x, int y);
|
||||
void onMouseRightUp(int x, int y);
|
||||
void onMouseMoved(int x, int y);
|
||||
void onMouseWheel(int x, int y, short delta);
|
||||
CameraController cameraController;
|
||||
private:
|
||||
void initGUI();
|
||||
HWND hWndMain;
|
||||
SkyRef sky;
|
||||
bool quit;
|
||||
bool rightButtonHolding;
|
||||
void main();
|
||||
};
|
||||
@@ -231,7 +231,7 @@
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\AudioPlayer.cpp"
|
||||
RelativePath=".\BaseButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@@ -243,7 +243,11 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Globals.cpp"
|
||||
RelativePath=".\ImageButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Instance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@@ -266,25 +270,6 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<Filter
|
||||
Name="Instances"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\BaseButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DataModelInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ImageButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Instance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\PhysicalInstance.cpp"
|
||||
>
|
||||
@@ -293,41 +278,17 @@
|
||||
RelativePath=".\TextButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\WorkspaceInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\AudioPlayer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ButtonListener.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Globals.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\resource.h"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="Instances"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\BaseButtonInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DataModelInstance.h"
|
||||
RelativePath=".\ButtonListener.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@@ -343,15 +304,14 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TextButtonInstance.h"
|
||||
RelativePath=".\resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\WorkspaceInstance.h"
|
||||
RelativePath=".\TextButtonInstance.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
|
||||
14
README.md
14
README.md
@@ -1,14 +0,0 @@
|
||||
# G3D-Fun
|
||||
|
||||
Despite its name, this is actually a recreation of ROBLOX as it was in 2005. Early development. Uses roughly time-accurate development tools.
|
||||
|
||||
# COMPILE WITH
|
||||
|
||||
Graphics3D 6.10 (Released July 21, 2006)
|
||||
SDL 1.2.7 (1.2.9 could work as well)
|
||||
Visual Studio 2005 Professional or Visual Studio 2005 Express with Platform SDK
|
||||
|
||||
# NOTE
|
||||
|
||||
Please know that there currently is no documentation and minimal commenting. As such, it may be confusing to follow the code.
|
||||
Code for this project is written quickly at random intervals, where each individual thinks of a solution to a problem and adds it.
|
||||
75
building.md
75
building.md
@@ -1,75 +0,0 @@
|
||||
# Building Setup
|
||||
|
||||
##### G3D is super delicate, meaning that you have to go about building in a special way
|
||||
|
||||
#### Skip to steps 7-13 if you have already built this program
|
||||
|
||||
1. Install Visual Studio 2005. Google where to find it. Make note of which version you downloaded.
|
||||
|
||||
2. Download and install G3D from [this link here](https://sourceforge.net/projects/g3d/files/g3d-cpp/6.10/g3d-6_10_win32.exe/download).
|
||||
|
||||
3. Make sure G3D is included under your build directories by going under Tools -> Options -> Projects and Solutions -> VC++ Directories and check and see if:
|
||||
|
||||
* `g3d-6_10\bin` is under executable files
|
||||
|
||||
* `g3d-6_10\include` is under include files
|
||||
|
||||
* `g3d-6_10\bin` is under executable files
|
||||
|
||||
* `g3d-6_10\win32-vc8-lib` is under library files
|
||||
|
||||
* Ex: `C:\libraries\g3d-6_10\bin`
|
||||
|
||||
4. Download SDL version 1.2.7 from [this link](http://www.libsdl.org/release/SDL-devel-1.2.7-VC6.zip)
|
||||
|
||||
5. Extract the file to a folder on your computer. Keep note of this folder.
|
||||
|
||||
6. Include the extracted files by going to Tools -> Options -> Projects and Solutions -> VC++ Directories and adding the following links:
|
||||
|
||||
* Include files - extractpath\`include`
|
||||
|
||||
* Library files - extractpath\`lib`
|
||||
|
||||
* Ex: `C:\libraries\SDL-1.2.7\bin`
|
||||
|
||||
#### Steps 7-11 are optional if you are using Visual Studio Professional. Check the Error stuff section if it doesn't work, most reference steps from here.
|
||||
|
||||
7. Download and install the [platform SDK](https://www.microsoft.com/en-us/download/details.aspx?id=6510).
|
||||
|
||||
8. Put the platform SDK into your directories (Tools -> Options -> Projects and Solutions -> VC++ Directories) by replacing all mentions of $(VCInstallDir)PlatformSDK with the actual path.
|
||||
Ex: `$(VCInstallDir)PlatformSDK\include` -> `C:\Program Files\Microsoft Platform SDK\Include`
|
||||
|
||||
9. Right click Source files -> Dialogs.rc -> View Code
|
||||
|
||||
10. Edit line 10 to say
|
||||
```cpp
|
||||
#include "WinResrc.h"
|
||||
#define IDC_STATIC -1
|
||||
```
|
||||
|
||||
instead of
|
||||
|
||||
```cpp
|
||||
#include "afxres.h"
|
||||
```
|
||||
|
||||
11. Right click the project -> Properties -> Configuration Properties -> Linker -> Input, and add `AdvAPI32.lib` under Additional Dependencies.
|
||||
|
||||
### Continue back here if you're skipping steps 7-11
|
||||
|
||||
12. Right click the project -> Properties -> Configuration Properties -> Linker -> General, and make sure Additional Library Directories is blank.
|
||||
|
||||
13. Try building using Build -> Build G3DTest.
|
||||
|
||||
|
||||
## Error stuff
|
||||
|
||||
```c:\libraries\g3d-6_10\include\G3D/platform.h(235) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory``` > Download and install platform SDK (lines 7-8)
|
||||
|
||||
```G3D-debug.lib(RegistryUtil.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function "public: static bool __cdecl G3D::RegistryUtil::keyExists(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?keyExists@RegistryUtil@G3D@@SA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)``` > Add AdvAPI32.lib under Additional Dependencies (step 11)
|
||||
|
||||
```.\Dialogs.rc(10) : fatal error RC1015: cannot open include file 'afxres.h'.``` > Perform steps 9-10
|
||||
|
||||
Enjoy!
|
||||
|
||||
please report unfriendliness of this page
|
||||
BIN
content/font/arial-small.fnt
Normal file
BIN
content/font/arial-small.fnt
Normal file
Binary file not shown.
BIN
content/font/arial.fnt
Normal file
BIN
content/font/arial.fnt
Normal file
Binary file not shown.
BIN
content/font/arialblack-small.fnt
Normal file
BIN
content/font/arialblack-small.fnt
Normal file
Binary file not shown.
BIN
content/font/arialblack.fnt
Normal file
BIN
content/font/arialblack.fnt
Normal file
Binary file not shown.
BIN
content/font/arialround.fnt
Normal file
BIN
content/font/arialround.fnt
Normal file
Binary file not shown.
BIN
content/font/ariaround-small.fnt
Normal file
BIN
content/font/ariaround-small.fnt
Normal file
Binary file not shown.
4
win32Defines.h
Normal file
4
win32Defines.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#define GetHoldKeyState(nVirtKey) (GetKeyState(nVirtKey)>>1)
|
||||
Reference in New Issue
Block a user