Creating scriptable object
by Paul Griffiths · in Torque Game Engine · 07/08/2006 (8:18 am) · 8 replies
Hi i wish to create a scriptable object for my webcam project.
pgmedia.awardspace.com/Site/TMessenger/screenshot.php
Ive created a base template:
Header:
source:
in script i have:
All i receive is syntax error in script, any ideas what i'm missing?
I do not wish to render anything, it's not a GUI or renderable object. Thanks.
pgmedia.awardspace.com/Site/TMessenger/screenshot.php
Ive created a base template:
Header:
#ifndef _VIDEOCAPTURE_H_
#define _VIDEOCAPTURE_H_
#ifndef _PLATFORMTHREAD_H_
#include "platform/platformThread.h"
#endif
#ifndef _PLAYER_H_
#include "game/player.h"
#endif
#ifndef _SIMBASE_H_
#include "console/simBase.h"
#endif
class VideoCapture : public SimObject
{
private:
typedef SimObject Parent;
protected:
public:
DECLARE_CONOBJECT(VideoCapture);
VideoCapture();
~VideoCapture();
static void initPersistFields();
void inspectPostApply();
void getDevices();
bool onWake();
void onSleep();
};
#endifsource:
#include "VideoCapture.h"
#include "console/consoleTypes.h"
#include "dgl/dgl.h"
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT(VideoCapture);
VideoCapture::VideoCapture()
{
}
//----------------------------------------------------------------------------
VideoCapture::~VideoCapture()
{
}
void VideoCapture::initPersistFields()
{
Parent::initPersistFields();
}
ConsoleMethod( VideoCapture, getDevices, void, 0, 0, "Get Capture Device List.")
{
object->getDevices();
}
void VideoCapture::getDevices()
{
Con::printf("Looking for capture devices...");
}
//----------------------------------------------------------------------------
bool VideoCapture::onWake()
{
return true;
}
//----------------------------------------------------------------------------
void VideoCapture::onSleep()
{
}
//----------------------------------------------------------------------------
void VideoCapture::inspectPostApply()
{
}in script i have:
Vidcap = new VideoCapture();
All i receive is syntax error in script, any ideas what i'm missing?
I do not wish to render anything, it's not a GUI or renderable object. Thanks.
#2
I have similar code working for my GUI but i don't wish to render anything.
07/08/2006 (8:31 am)
Thanks Ramen but still getting syntax error in script.I have similar code working for my GUI but i don't wish to render anything.
#3
You need the % or $ in front of the receiving variable.
07/08/2006 (8:54 am)
Uh...wouldn't the script need to be something like:%Vidcap = new VideoCapture();
You need the % or $ in front of the receiving variable.
#4
07/08/2006 (8:59 am)
Thanks rubes, how silly of me.
#5
All it is to do is find all video cameras and i will have a tab for it in the options dialog alongside audio, video ect.
Where should it be initialised? It should only be initialised once.
07/08/2006 (9:03 am)
Can anyone suggest where i should create my videoCapture object?All it is to do is find all video cameras and i will have a tab for it in the options dialog alongside audio, video ect.
Where should it be initialised? It should only be initialised once.
#6
07/08/2006 (9:10 am)
I initialised it in main.cs in start function, works ok.
#7
Not compiling, anyone know why?
07/08/2006 (9:50 am)
I have:ConsoleMethod( VideoCapture, getNumDevices, int, 3, 3, "Get total number capture devices.")
{
object->getNumDevices();
}
int VideoCapture::getNumDevices()
{
return numDevices;
}Not compiling, anyone know why?
#8
07/08/2006 (9:57 am)
Got my answer, should be S32's not int's.
Torque Owner Cinder Games
This line concerns me. Even though it's a void, it still need 2 arguments.
I'm not 100% familiar with how it works, but i know it needs 2,2 for the arguments.
ConsoleMethod( ShapeBase, isHidden, bool, 2, 2, "") { return object->isHidden(); }See how that code works?