*** empty log message ***
This commit is contained in:
parent
5a69f4fe30
commit
fcdf344cf6
|
@ -1,5 +1,179 @@
|
|||
#include <vcg/wrap/GUI/trackball.h>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
template <class A, class B> class pippo {
|
||||
public:
|
||||
int a() { return 1; }
|
||||
};
|
||||
|
||||
template <> class pippo<int, int> {
|
||||
public:
|
||||
int a() { return 2; }
|
||||
};
|
||||
|
||||
int main() {
|
||||
pippo<int, int> p;
|
||||
cerr << p.a() << endl;
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
#include<windows.h>
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include <GL/glut.h>
|
||||
#include <wrap/gui/trackball.h>
|
||||
|
||||
using namespace vcg;
|
||||
|
||||
bool fullscreen = false;
|
||||
//int width =1024;
|
||||
//int height = 768;
|
||||
int width = 800;
|
||||
int height = 600;
|
||||
|
||||
|
||||
|
||||
SDL_Surface *screen = NULL;
|
||||
|
||||
bool init() {
|
||||
|
||||
if(SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const SDL_VideoInfo *info = SDL_GetVideoInfo();
|
||||
int bpp = info->vfmt->BitsPerPixel;
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
|
||||
int flags = SDL_OPENGL;
|
||||
if(fullscreen)
|
||||
flags |= SDL_FULLSCREEN;
|
||||
|
||||
screen = SDL_SetVideoMode(width, height, bpp, flags);
|
||||
if(!screen) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_WM_SetIcon(SDL_LoadBMP("inspector.bmp"), NULL);
|
||||
SDL_WM_SetCaption(" Inspector", "Inspector");
|
||||
|
||||
|
||||
glDisable(GL_DITHER);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glHint( GL_FOG_HINT, GL_NICEST );
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc( GL_LEQUAL );
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int wmain(int argc, unsigned short **argv) {
|
||||
if(!init()) return -1;
|
||||
|
||||
Trackball trackball;
|
||||
|
||||
int quit = 0;
|
||||
int x, y;
|
||||
SDL_Event event;
|
||||
while( !quit ) {
|
||||
while( SDL_PollEvent( &event ) ){
|
||||
switch( event.type ) {
|
||||
case SDL_QUIT: quit = 1; break;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
switch(event.key.keysym.sym) {
|
||||
case SDLK_RSHIFT:
|
||||
case SDLK_LSHIFT:
|
||||
trackball.ButtonDown(Trackball::KEY_SHIFT);
|
||||
break;
|
||||
|
||||
case SDLK_RCTRL:
|
||||
case SDLK_LCTRL:
|
||||
trackball.ButtonDown(Trackball::KEY_CTRL);
|
||||
break;
|
||||
|
||||
case SDLK_RALT:
|
||||
case SDLK_LALT:
|
||||
trackball.ButtonDown(Trackball::KEY_ALT);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_KEYUP:
|
||||
switch(event.key.keysym.sym) {
|
||||
case SDLK_q: exit(0); break;
|
||||
|
||||
case SDLK_RSHIFT:
|
||||
case SDLK_LSHIFT:
|
||||
trackball.ButtonUp(Trackball::KEY_SHIFT);
|
||||
break;
|
||||
|
||||
case SDLK_RCTRL:
|
||||
case SDLK_LCTRL:
|
||||
trackball.ButtonUp(Trackball::KEY_CTRL);
|
||||
break;
|
||||
|
||||
case SDLK_RALT:
|
||||
case SDLK_LALT:
|
||||
trackball.ButtonUp(Trackball::KEY_ALT);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
x = event.button.x;
|
||||
y = event.button.y;
|
||||
trackball.MouseDown(x, y, Trackball::BUTTON_LEFT);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
x = event.button.x;
|
||||
y = event.button.y;
|
||||
trackball.MouseUp(x, y, Trackball::BUTTON_LEFT);
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
while(SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_MOUSEMOTIONMASK));
|
||||
x = event.motion.x;
|
||||
y = event.motion.y;
|
||||
trackball.MouseMove(x, y);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(60, 1, 0.1, 100);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
gluLookAt(0,0,4, 0,0,0, 0,1,0);
|
||||
glRotatef(130, 1, 1, 0);
|
||||
glTranslatef(0, 0.7, 1);
|
||||
|
||||
|
||||
trackball.SetPosition(Similarityf(Point3f(1, 0, 0)));
|
||||
trackball.local.sca = 0.5;
|
||||
trackball.GetView();
|
||||
trackball.Apply();
|
||||
trackball.Draw();
|
||||
|
||||
glColor3f(0, 1, 0);
|
||||
glutWireCube(1);
|
||||
|
||||
SDL_GL_SwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
// Clean up
|
||||
SDL_Quit();
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -20,6 +20,7 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="c:\sf\vcg"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG"
|
||||
MinimalRebuild="FALSE"
|
||||
BasicRuntimeChecks="0"
|
||||
|
@ -30,6 +31,7 @@
|
|||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="opengl32.lib glu32.lib glut32.lib SDL.lib"
|
||||
OutputFile="$(OutDir)/trackball.exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"/>
|
||||
|
@ -59,6 +61,7 @@
|
|||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="c:\sf\vcg"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG"
|
||||
MinimalRebuild="FALSE"
|
||||
WarningLevel="3"/>
|
||||
|
@ -66,6 +69,7 @@
|
|||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="opengl32.lib glu32.lib glut32.lib SDL.lib"
|
||||
OutputFile="$(OutDir)/trackball.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="TRUE"/>
|
||||
|
@ -89,10 +93,46 @@
|
|||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
|
||||
<File
|
||||
RelativePath="main.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc">
|
||||
<File
|
||||
RelativePath="..\..\..\vcg\math\base.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\vcg\space\box3.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\wrap\GUI\frustum.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\vcg\math\matrix44.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\vcg\space\point3.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\vcg\math\quaternion.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\vcg\math\similarity.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\wrap\GUI\trackball.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\wrap\GUI\trackmode.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\wrap\GUI\view.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\wrap\gl\wrap.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
|
|
|
@ -38,10 +38,13 @@ namespace vcg {
|
|||
template <class S> class Similarity {
|
||||
public:
|
||||
Similarity() {}
|
||||
Similarity(const Quaternion<S> &q) { SetRotate(q); }
|
||||
Similarity(const Point3<S> &p) { SetTranslate(p); }
|
||||
Similarity(S s) { SetScale(s); }
|
||||
|
||||
Similarity operator*(const Similarity &affine) const;
|
||||
Similarity &operator*=(const Similarity &affine);
|
||||
Point3<S> operator*(const Point3<S> &p) const;
|
||||
//Point3<S> operator*(const Point3<S> &p) const;
|
||||
|
||||
|
||||
Similarity &SetIdentity();
|
||||
|
@ -61,6 +64,7 @@ public:
|
|||
|
||||
template <class S> Similarity<S> &Invert(Similarity<S> &m);
|
||||
template <class S> Similarity<S> Inverse(const Similarity<S> &m);
|
||||
template <class S> Point3<S> operator*(const Point3<S> &p, const Similarity<S> &m);
|
||||
|
||||
|
||||
template <class S> Similarity<S> Similarity<S>::operator*(const Similarity &a) const {
|
||||
|
@ -77,13 +81,6 @@ template <class S> Similarity<S> &Similarity<S>::operator*=(const Similarity &a)
|
|||
tra = (rot.Rotate(a.tra)) * sca + tra;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class S> Point3<S> Similarity<S>::operator*(const Point3<S> &p) const {
|
||||
Point3<S> r = rot.Rotate(p);
|
||||
r *= sca;
|
||||
r += tra;
|
||||
return r;
|
||||
}
|
||||
|
||||
template <class S> Similarity<S> &Similarity<S>::SetIdentity() {
|
||||
rot.FromAxis(0, Point3<S>(1, 0, 0));
|
||||
|
@ -127,7 +124,7 @@ template <class S> Matrix44<S> Similarity<S>::Matrix() const {
|
|||
}
|
||||
|
||||
template <class S> void Similarity<S>::FromMatrix(const Matrix44<S> &m) {
|
||||
sca = pow(m.Determinant(), 1/3);
|
||||
sca = (S)pow(m.Determinant(), 1/3);
|
||||
assert(sca != 0);
|
||||
Matrix44<S> t = m * Matrix44<S>().SetScale(1/sca, 1/sca, 1/sca);
|
||||
rot.FromMatrix(t);
|
||||
|
@ -157,6 +154,13 @@ template <class S> Similarity<S> Interpolate(const Similarity<S> &a, const Simil
|
|||
return r;
|
||||
}
|
||||
|
||||
template <class S> Point3<S> operator*(const Point3<S> &p, const Similarity<S> &m) {
|
||||
Point3<S> r = m.rot.Rotate(p);
|
||||
r *= m.sca;
|
||||
r += m.tra;
|
||||
return r;
|
||||
}
|
||||
|
||||
typedef Similarity<float> Similarityf;
|
||||
typedef Similarity<double>Similarityd;
|
||||
|
||||
|
|
Loading…
Reference in New Issue