added preliminary gui for movie capture

ver1_5_1
Hank Ramsey 2005-06-08 07:28:30 +00:00
parent bcfcfe45cf
commit a5b3ddb3a0
10 changed files with 269 additions and 7 deletions

View File

@ -70,5 +70,8 @@ class CelestiaCore;
-(void)showInfoURL;
-(void)keyDown:(int)c withModifiers:(int)m;
-(void)keyUp:(int)c withModifiers:(int)m;
- (BOOL) captureMovie: (NSString*)filename width: (int)width height: (int)height
frameRate: (float)framerate;
@end

View File

@ -21,6 +21,7 @@
#import "CelestiaController.h"
#include "celestiacore.h"
#include "qtcapture.h"
/*
void initMovieCapture(MovieCapture *)
@ -676,5 +677,21 @@ static NSMutableDictionary* tagDict;
}
}
- (BOOL) captureMovie: (NSString*) filename width: (int) width height: (int) height
frameRate: (float) framerate
{
MovieCapture* movieCapture = new QTCapture();
bool success = movieCapture->start([filename cString], width, height, framerate);
if (success)
appCore->initMovieCapture(movieCapture);
else
delete movieCapture;
return success;
return true;
}
@end

View File

@ -68,6 +68,8 @@
-(IBAction) showPanel: (id) sender;
- (IBAction) captureMovie: (id) sender;
-(void)addSurfaceMenu:(NSMenu*)contextMenu;
-(BOOL)validateMenuItem:(id)item;
-(IBAction)activateMenuItem:(id)item;

View File

@ -697,6 +697,38 @@ NSString* fatalErrorMessage;
[appCore showInfoURL];
}
- (void) moviePanelDidEnd:(NSSavePanel*)savePanel returnCode: (int) rc contextInfo: (void *) ci
{
// if (rc == NSOKButton )
if (rc == 0 ) return;
{
NSString *path;
path = [savePanel filename];
NSLog(@"Saving movie: %@",path);
[appCore captureMovie: path width: 640 height: 480 frameRate: 30 ];
}
}
- (IBAction) captureMovie: (id) sender
{
// Remove following line to enable movie capture...
NSRunAlertPanel(@"No Movie Capture",@"Movie capture is not available in this version of Celestia.",nil,nil,nil); return;
NSSavePanel* panel = [[NSSavePanel alloc] init];
NSString* lastMovie = nil; // temporary; should be saved in defaults
[panel setRequiredFileType: @"mov"];
[panel setTitle: @"Capture Movie"];
[panel setMessage: @"Capture Movie"];
[ panel beginSheetForDirectory: [lastMovie stringByDeletingLastPathComponent]
file: [lastMovie lastPathComponent]
modalForWindow: [glView window]
modalDelegate: self
didEndSelector: @selector(moviePanelDidEnd:returnCode:contextInfo:)
contextInfo: nil
];
}
// GUI Tag Methods ----------------------------------------------------------
- (BOOL) validateMenuItem: (id) item

View File

@ -10,6 +10,7 @@
ACTIONS = {
activateMenuItem = id;
back = id;
captureMovie = id;
forward = id;
openScript = id;
rerunScript = id;

View File

@ -9,7 +9,7 @@
<key>242</key>
<string>441 337 270 342 0 0 1152 746 </string>
<key>29</key>
<string>57 787 721 44 0 0 1280 832 </string>
<string>90 957 721 44 0 0 1600 1002 </string>
<key>296</key>
<string>555 398 170 341 0 0 1280 832 </string>
<key>335</key>
@ -27,12 +27,12 @@
</array>
<key>IBOpenObjects</key>
<array>
<integer>383</integer>
<integer>21</integer>
<integer>29</integer>
<integer>1310</integer>
<integer>383</integer>
<integer>29</integer>
<integer>21</integer>
</array>
<key>IBSystem Version</key>
<string>7W98</string>
<string>7D28</string>
</dict>
</plist>

Binary file not shown.

View File

@ -65,6 +65,59 @@
//082
//083
//084
//0C0
//0C1
//0C2
//0C3
//0C4
0C76BFC0085215B100D31A90 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.h;
name = moviecapture.h;
path = ../src/celestia/moviecapture.h;
refType = 2;
sourceTree = SOURCE_ROOT;
};
0C76BFC1085215B100D31A90 = {
fileRef = 0C76BFC0085215B100D31A90;
isa = PBXBuildFile;
settings = {
};
};
0C76BFCF08537EDB00D31A90 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.cpp.cpp;
path = qtcapture.cpp;
refType = 2;
sourceTree = SOURCE_ROOT;
};
0C76BFD008537EDB00D31A90 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.h;
path = qtcapture.h;
refType = 2;
sourceTree = SOURCE_ROOT;
};
0C76BFD108537EDB00D31A90 = {
fileRef = 0C76BFCF08537EDB00D31A90;
isa = PBXBuildFile;
settings = {
};
};
0C76BFD208537EDB00D31A90 = {
fileRef = 0C76BFD008537EDB00D31A90;
isa = PBXBuildFile;
settings = {
};
};
//0C0
//0C1
//0C2
//0C3
//0C4
//100
//101
//102
@ -567,6 +620,8 @@
E589B6DE078AC511005B8DD9,
E589B6E0078AC511005B8DD9,
E56A5AEC0848F92200A21D7E,
0C76BFC1085215B100D31A90,
0C76BFD208537EDB00D31A90,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@ -1544,6 +1599,7 @@
E589B6DF078AC511005B8DD9,
E56A3DB80848C19800A21D7E,
E56A5AED0848F92200A21D7E,
0C76BFD108537EDB00D31A90,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@ -3229,17 +3285,20 @@
};
F51C6D51029596B4014901DC = {
children = (
E56431450776D52D00E2C4A3,
F51C6D8B02959960014901DC,
E56431450776D52D00E2C4A3,
F51C6D8C02959960014901DC,
F51C6D8D02959960014901DC,
F51C6D8E02959960014901DC,
0C76BFCF08537EDB00D31A90,
F53036BB03D908CE01000002,
F51C6D9A02959960014901DC,
E56431460776D52D00E2C4A3,
F51C6D9B02959960014901DC,
F51C6D9C02959960014901DC,
F51C6D9D02959960014901DC,
F53036BB03D908CE01000002,
0C76BFC0085215B100D31A90,
0C76BFD008537EDB00D31A90,
F53036BC03D908CE01000002,
);
isa = PBXGroup;

View File

@ -0,0 +1,105 @@
// qtcapture.cpp
//
// Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
#include <cmath>
#include "../src/celengine/gl.h"
#include "../src/celengine/glext.h"
#include <celutil/debug.h>
#include "qtcapture.h"
using namespace std;
QTCapture::QTCapture() :
width(-1),
height(-1),
frameRate(30.0f),
frameCounter(0),
capturing(false)
{
}
QTCapture::~QTCapture()
{
cleanup();
}
bool QTCapture::start(const string& filename,
int w, int h,
float fps)
{
if (capturing)
return false;
width = w;
height = h;
frameRate = fps;
capturing = true;
frameCounter = 0;
return true;
}
bool QTCapture::end()
{
capturing = false;
cleanup();
return true;
}
bool QTCapture::captureFrame()
{
if (!capturing)
return false;
// Get the dimensions of the current viewport
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
int x = viewport[0] + (viewport[2] - width) / 2;
int y = viewport[1] + (viewport[3] - height) / 2;
frameCounter++;
return true;
}
void QTCapture::cleanup()
{
}
int QTCapture::getWidth() const
{
return width;
}
int QTCapture::getHeight() const
{
return height;
}
float QTCapture::getFrameRate() const
{
return frameRate;
}
int QTCapture::getFrameCount() const
{
return frameCounter;
}

43
macosx/qtcapture.h 100644
View File

@ -0,0 +1,43 @@
// qtcapture.h
//
// Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
//
// 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.
#ifndef _QTCAPTURE_H_
#define _QTCAPTURE_H_
// #include <vfw.h>
#include "moviecapture.h"
class QTCapture : public MovieCapture
{
public:
QTCapture();
virtual ~QTCapture();
bool start(const std::string& filename, int w, int h, float fps);
bool end();
bool captureFrame();
int getWidth() const;
int getHeight() const;
float getFrameRate() const;
int getFrameCount() const;
private:
void cleanup();
private:
int width;
int height;
float frameRate;
int frameCounter;
bool capturing;
};
#endif // _QTCAPTURE_H_