Crystal Space
Welcome, Guest. Please login or register.
October 21, 2014, 06:33:08 am

Login with username, password and session length
Search:     Advanced search
9010 Posts in 2044 Topics by 8767 Members
Latest Member: Yolandasutton
* Home Help Search Login Register
  Show Posts
Pages: 1 [2] 3 4 5
16  Crystal Space Project Development / Feature Requests / Re: Upcomming AutoLoader pluggin on: February 24, 2006, 01:40:05 am
It seems that, however hard I try, I can't get past a fundemental chain or errors - I fix one, and another turns out to be "hiding" behind it.  So far, I havent been able to get any of my code de-errored, as the problem code always seems to be in some CS header file.  I am simply trying to get to my errors, which I tend to be fairly good at.  I am not good at fixing compatibility errors with a system that I didn't design.  Here is what I have so far:

In CS\Plugins\autoloader\csAutoloader.cpp:

Code:
/*
    Copyright (C) 2006 by Joshua Warner

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "..\..\include\cssysdef.h"

void csAutoThreadedLoad::Run(csAutoLoader* aloader)
{
csRef<iVFS> vfs;
//TODO:initialize vfs.

csAutoLoaderJob& job;

//aloader->current->SetComplete(0);
//aloader->current->SetTotal(aloader->jobs.GetSize());

csArray<csAutoLoaderJob>::Iterator it;
it = aloader->jobs->GetIterator();

while(it.HasNext())
{
jobs = it.Next();
csRef<iFile> file = vfs->Open(job.fname, VFS_FILE_READ);
job.data = file->GetAllData();
//aloader->current->Step();
job.done = true;
}
//aloader->current->Finished();
aloader->jobs.Empty();

aloading->loading = false;
}

csAutoLoader::csAutoLoader()
{
loading  = false;
}
void csAutoLoader::AddJob(const char* name, const char* fname)
{
csAutoLoaderJob job;
job.fname = new char[strlen(fname)];
job.name = new char[strlen(name)];
strcpy(job.fname,fname);
strcpy(job.name,name);

jobs.Push(job);
}
void csAutoLoader::RemoveJob(const char* name)
{
int i;
for(i = 0;i<jobs.GetSize();i++)
{
if(strcmp(jobs.GetAt(i).name, name)==0)
{
csAutoLoaderJob job = jobs.GetAt(i);
delete [] job.fname;
delete [] job.name;
delete [] job.type;

jobs.DeleteIndex(i);
}
}
}
void csAutoLoader::StartLoad(/*iAutoLoaderProgress& progress = internal*/)
{
//current = progress;
loading = true;
csRef<csThread> thread = csThread::Create(new csAutoThreadedLoad);
thread->Start();
}
bool csAutoLoader::Finish()
{
if(!loading)
{
csRef<iLoader> loader;
//TODO: initialize loader

csArray<csAutoLoaderJob>::Iterator it;
it = jobs->GetIterator();

int i = 0;

while(it.HasNext())
{
job = it.Next();
if(job.done)
{
if(loader->Load(&job.data))
jobs->DeleteIndex(i);
}
i++;
}
return true;
}
else return false;
}

In CS\include\imap\csautoloader.h :
Code:
/*
    Copyright (C) 2006 by Joshua Warner

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __CS_AUTOLOADER_H__
#define __CS_AUTOLOADER_H__

//class csAutoLoaderProgress;
class csAutoLoader;
//class iAutoLoaderProgress;
class iAutoLoader;

/*class csAutoLoaderProgress : public iAutoLoaderProgress
{
public:
csAutoLoaderProgress(void){SetTotal(100);SetComplete(0);abort = false;finished = false;}
~csAutoLoaderProgress(void){return;}

virtual void Abort(){abort = true;}
virtual void Finalize(){finished = true;}
virtual void Finished(){finished = true;complete = 0;}
virtual bool IsFinished(){return finished;}
virtual bool IsAborted(){return abort;}
virtual float GetCurrent(){return ((float)complete/(float)total);}
virtual int GetTotal(){return total;}
virtual int GetComplete(){return complete;}
virtual void SetComplete(int num){complete = num;}
virtual void SetTotal(int num){total = num;}
virtual void Step(int num = 1){if(total>=complete)complete+=num;else Finished();}

private:
    int total;
int complete;
bool finished;
bool abort;
};*/

static struct csAutoLoaderJob
{
const char* name;
const char* fname;
bool done;
csRef<iDataBuffer> data;
};

static class csAutoThreadedLoad : public csRunnable
{
public:
virtual void Run(csAutoLoader* aloader);
};

class csAutoLoader : public iAutoLoader
{
public:
csAutoLoader();
~csAutoLoader();

struct Component : public iComponent
{
SCF_DECLARE_EMBEDDED_IBASE (MyPlugin);
virtual bool Initialize (iObjectRegistry* r)
{ return scfParent->Initialize (r); }
} scfiComponent;

virtual void AddJob(const char* name, const char* fname);
virtual void RemoveJob(const char* name);
virtual void StartLoad(/*iAutoLoaderProgress& progress = internal*/);

virtual void Initialize(iObjectRegistry* r){loader = CS_QUERY_REGISTRY(r, loader);}

virtual bool Finish();

//add custom map loading funtions.

private:
csArray<csAutoLoaderJob> jobs;
//csRef<iAutoLoaderProgress> internal;
//csRef<iAutoLoaderProgress> current;
bool loading;

csRef<iLoader> loader;

friend class csAutoThreadedLoad;
};

#endif // __CS_AUTOLOADER_H__

Please note that while reading this code, you will probably see many errors in it.  I ask only that someone tell me what I am doing wrong with interfacing it with CS.
What I am getting now is errors concerning include statements.  Also, it would be helpful if someone could give me some info on the use of the CS plugin define statements, as the documentation seems a little out of date on this issue.  (all the plugins that I have looked at the code for use a different method than what is described in the documentation.)

Thanks for voting on the pole - those that did.  FYI, the progress handeling code is commented out for debugging purposes.  It will be enabled once I get everything else working.
17  Crystal Space Development / Support / Re: some questions about iScript on: February 23, 2006, 01:13:50 am
This looks like a simple coding error to me.  You are passing a string value to the python function ("%i") and in the script file trying to convert the string into a number.  I suspect this is where the error is comming from.  Maybe you meant to pass an integer to the python function?  Try commenting out that line and run it again.
18  Crystal Space Project Development / Feature Requests / Re: Upcomming AutoLoader pluggin on: February 05, 2006, 10:52:15 pm
Im about a week away from releasing a preliminary version.  For this, I have 2 questions: where do I put the interface header file within the project hierarchy(sp?) and also where should I put the source so that others can view it (and it can be included in a CS release)?
19  Associate Projects / CEL Discussion / Re: CEL Mouselook - 1st Person on: February 03, 2006, 03:03:44 am
Of course its possible.  without more information, however, I can't comment on the dificulty of the coding and or changes.
20  Crystal Space Development / Support / Re: Playing an opening video on: February 03, 2006, 03:00:19 am
How salvagable is the video streaming code from that old video plugin?  I have a similar goal, and I don't want to rewrite all of that.
21  Crystal Space Project Development / Development Discussion / Re: Environtal Systems - as in Rain/Wind/Water and their impact on: February 03, 2006, 02:55:49 am
The most advanced 64 bit cpus on the planet can simulate about 40-50 interacting objects in real time.  Just with trees, you've used most of that up.  Stick to a limited set of pre-made vertex animations until hardware become SIGNIFICANTLY faster.  Otherwise you are adding a lot of overhead for very little added visual realism.
22  Crystal Space Development / General Crystal Space Discussion / Re: Making Crystal Space Easier: Tutorials, documents, wiki, demos on: February 03, 2006, 12:48:53 am
I think it would help dramatically if there were CS "wizards", like the "MFC App Wizard" in MSVC.   I say this because it took me a few weeks to understand CS enough to make my first app, but using ogre (notice: i didn't capitalize that on purpose) it took me only a few days via its MSVC Wizard.
23  Crystal Space Development / General Crystal Space Discussion / Re: Please HELP me!! on: February 01, 2006, 04:02:28 am
In a way, yes...  that demo didn't use any c++ code.  Just xml (another language), in the world (thats the name) file.
24  Crystal Space Development / Support / Re: Making a plugin on: January 30, 2006, 03:04:57 am
In your previous post, you only mentioned how to load it, not how to get it once it has been loaded.  Also, "You must first..." ususaly implies that there is a "then..." following, that explains the next step.  Also, if that particular plugin has been loaded by the main application, is it reloaded to satisfy the second request (the one by csAutoLoader).  If it helps, I know that the csLoader plugin must somehow gain access to the iEngine class so that it can insert the loaded resource into the engine : how does csLoader get the main csRef<iEngine> refererce?
25  Crystal Space Development / Support / Re: Making a plugin on: January 28, 2006, 11:21:12 pm
To get a plugin from the object registry you must first load that plugin (and have it registered there).

The point is: what's the second step in getting the plugin?
26  Crystal Space Project Development / Development Discussion / Re: Environtal Systems - as in Rain/Wind/Water and their impact on: January 28, 2006, 12:54:47 am
the switching of anims is fairly easy to do, as would the water, with an animated texture.  The problem lies with trying to simulate these things in realtime.  One tree with all of its leaves and branches simulated like this could take hours to simulate just a few minutes of waving in gusts.  A premade animation is the way to go.
27  Crystal Space Development / Support / Re: Making a plugin on: January 28, 2006, 12:10:07 am
Suppose I know its already in the object registry?  How do I get at the object registry from a scf plugin class?
28  Crystal Space Project Development / Feature Requests / Re: Upcomming AutoLoader pluggin on: January 27, 2006, 01:02:25 am
Progress update:
The first *working* version of the plugin is within weeks.  For this version, I will scale down the total project so that the thread will only work on loading the file into an iDataBuffer object within iAutoLoader.  The main thread will then call a finalize function in the iAutoLoaded class that will call the various iLoader functions for loading from a buffer.  The amount of time it takes the iLoader plugin to move and modify the data in memory should be almost negligable compared to the time required to load the resource from disk, so I will still be accomplishing my goal. 

Right now, the header is mostly finished and the cpp file is about a third finished.  I still haven't done any testing, and I expect that to take a fair while.
29  Crystal Space Development / Support / Making a plugin on: January 27, 2006, 12:13:36 am
How do you get a plugin from the object registry from a scf plugin?  For example: I need to access iLoader from the plugin I am making: iAutoLoader.  If it helps, I am using the CVS version from the 23rd of january.
30  Crystal Space Project Development / Feature Requests / Re: Upcomming AutoLoader pluggin on: January 22, 2006, 10:51:45 pm
Also, if I decided not to make this iAutoLoader pluggin, I would make something similar for myself located in my executable as opposed to in a plugin.  I decided that I might-as-well make it available for scruiteny, and (if desired) usage by the CS community.  I don't like it when a game simply displays an unchanging image because I never know whether its locked up or actually doing something.  I am going to fix that problem one way or another.

That's why iStreamSource was added. Every loader plugin gets a pointer to such a stream source and can use that to fetch vertex and triangle data from. This is currently not implemented though. The API is there but that's all. I personally think it would be better to pursue this route. If you are interested in this then I can help explain how it all is supposed to work.

As for why I don't want to use the iStreamSource class: it doesn't seem to have any support whatsoever for progress checking, so there is still no way to tell if the game is locked up (it could be that just the loading thread is locked up). 

This class does seem like a good candidate for the buffers in the manager classes, though.
Pages: 1 [2] 3 4 5
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 4.175 seconds with 16 queries.