Added preload textures command to scripting system

ver1_5_1
Chris Laurel 2002-05-02 07:57:38 +00:00
parent 2e263b2866
commit 1176feae2c
5 changed files with 68 additions and 0 deletions

View File

@ -386,6 +386,12 @@ Command* CommandParser::parseCommand()
paramList->getNumber("brightness", brightness);
cmd = new CommandSetAmbientLight((float) brightness);
}
else if (commandName == "preloadtex")
{
string object;
paramList->getString("object", object);
cmd = new CommandPreloadTextures(object);
}
else
{
error("Unknown command name '" + commandName + "'");

View File

@ -477,6 +477,27 @@ void CommandSet::process(ExecutionEnvironment& env)
}
////////////////
// Preload textures command
CommandPreloadTextures::CommandPreloadTextures(const string& _name) :
name(_name)
{
}
void CommandPreloadTextures::process(ExecutionEnvironment& env)
{
Selection target = env.getSimulation()->findObjectFromPath(name);
if (target.body == NULL)
return;
if (env.getRenderer() != NULL)
env.getRenderer()->loadTextures(target.body);
}
///////////////
// Repeat command

View File

@ -374,6 +374,17 @@ class CommandSet : public InstantaneousCommand
};
class CommandPreloadTextures : public InstantaneousCommand
{
public:
CommandPreloadTextures(const std::string&);
void process(ExecutionEnvironment&);
private:
std::string name;
};
class Execution;
class RepeatCommand : public Command

View File

@ -3622,3 +3622,31 @@ void Renderer::StarVertexBuffer::setBillboardOrientation(const Quatf& q)
v3 = Vec3f(-1, 1, 0) * m;
}
void Renderer::loadTextures(Body* body)
{
Surface& surface = body->getSurface();
if (surface.baseTexture.tex[textureResolution] != InvalidResource)
surface.baseTexture.find(textureResolution);
if ((surface.appearanceFlags & Surface::ApplyBumpMap) != 0 &&
(fragmentShaderEnabled && useRegisterCombiners && useCubeMaps) &&
surface.bumpTexture.tex[textureResolution] != InvalidResource)
surface.bumpTexture.find(textureResolution);
if ((surface.appearanceFlags & Surface::ApplyNightMap) != 0 &&
(renderFlags & ShowNightMaps) != 0)
surface.nightTexture.find(textureResolution);
if ((renderFlags & ShowCloudMaps) != 0 &&
body->getAtmosphere() != NULL &&
body->getAtmosphere()->cloudTexture.tex[textureResolution] != InvalidResource)
{
body->getAtmosphere()->cloudTexture.find(textureResolution);
}
if (body->getRings() != NULL &&
body->getRings()->texture.tex[textureResolution] != InvalidResource)
{
body->getRings()->texture.find(textureResolution);
}
}

View File

@ -95,6 +95,8 @@ class Renderer
void setResolution(unsigned int resolution);
unsigned int getResolution();
void loadTextures(Body*);
typedef struct {
std::string text;
Color color;