bool psEffectAnchorSocket::Load(iDocumentNode* node) { // get the attributes name.Clear(); csRef<iDocumentAttributeIterator> attribIter = node->GetAttributes(); while(attribIter->HasNext()) { csRef<iDocumentAttribute> attr = attribIter->Next(); csString attrName = attr->GetName(); attrName.Downcase(); if(attrName == "name") name = attr->GetValue(); if(attrName == "socket") socketName = attr->GetValue(); } if(name.IsEmpty()) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Attempting to create an effect socket anchor with no name.\n"); return false; } if(socketName.IsEmpty()) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Attempting to create an effect socket anchor without specifying a socket.\n"); return false; } if(!psEffectAnchor::Load(node)) return false; return true; }
bool psEffectObjStar::Load(iDocumentNode *node, iLoaderContext* ldr_context) { // get the attributes name.Clear(); materialName.Clear(); segments = 10; csRef<iDocumentAttributeIterator> attribIter = node->GetAttributes(); while (attribIter->HasNext()) { csRef<iDocumentAttribute> attr = attribIter->Next(); csString attrName = attr->GetName(); attrName.Downcase(); if (attrName == "name") name = attr->GetValue(); else if (attrName == "material") materialName = attr->GetValue(); else if (attrName == "segments") segments = attr->GetValueAsInt(); } if (name.IsEmpty()) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Attempting to create an effect obj with no name.\n"); return false; } if (materialName.IsEmpty()) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Attempting to create an effect obj without a material.\n"); return false; } if (!psEffectObj::Load(node, ldr_context)) return false; return PostSetup(); }
bool HeightMapGen::LoadMap () { csRef<iVFS> VFS = csQueryRegistry<iVFS> (object_reg); csStringArray paths; paths.Push ("/lev/"); csString map = cfgmgr->GetStr ("HeightMapGen.WorldInputPath", "/this"); csString world = cfgmgr->GetStr ("HeightMapGen.WorldInput", "world"); if (!VFS->ChDirAuto (map, &paths, 0, world)) { csReport (object_reg, CS_REPORTER_SEVERITY_ERROR, "crystalspace.application.heightmapgen", "Error setting directory %s!", CS::Quote::Single (map.GetData ())); return false; } // Load the level file which is called 'world'. if (!loader->LoadMapFile (world)) { csReport (object_reg, CS_REPORTER_SEVERITY_ERROR, "crystalspace.application.heightmapgen", "Couldn't load level %s on %s!", CS::Quote::Single (world.GetData ()), CS::Quote::Single (map.GetData ())); return false; } engine->Prepare (); return true; }
bool psEffectObjSound::Load(iDocumentNode *node, iLoaderContext* ldr_context) { if (!psEffectObj::Load(node, ldr_context)) return false; // get the attributes name.Clear(); soundName.Clear(); minDistSquared = 25.0f; maxDistSquared = 100000.0f; loop = true; csRef<iDocumentAttributeIterator> attribIter = node->GetAttributes(); while (attribIter->HasNext()) { csRef<iDocumentAttribute> attr = attribIter->Next(); csString attrName = attr->GetName(); attrName.Downcase(); if (attrName == "name") name = attr->GetValue(); else if (attrName == "resource") soundName = attr->GetValue(); else if (attrName == "loop") loop = attr->GetValueAsBool(); } if (!loop && killTime <= 0) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Can't have a looping sound effect without a death.\n"); return false; } csRef<iDocumentNode> dataNode; // min distance dataNode = node->GetNode("mindist"); if (dataNode) { minDistSquared = dataNode->GetContentsValueAsFloat(); minDistSquared *= minDistSquared; } // max distance dataNode = node->GetNode("maxdist"); if (dataNode) { maxDistSquared = dataNode->GetContentsValueAsFloat(); maxDistSquared *= maxDistSquared; } if (name.IsEmpty()) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Attempting to create an effect obj with no name.\n"); return false; } return PostSetup(); }
bool psEffectObjLabel::CreateMeshFact() { //printf("label: creating meshfact\n"); static unsigned int uniqueID = 0; csString facName = "effect_label_fac_"; facName += uniqueID++; meshFact = engine->CreateMeshFactory ("crystalspace.mesh.object.genmesh", facName.GetData()); effectsCollection->Add(meshFact->QueryObject()); iMeshObjectFactory * fact = meshFact->GetMeshObjectFactory(); facState = scfQueryInterface<iGeneralFactoryState> (fact); if (!facState) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "Eulora_effects", "Couldn't create genmesh: %s\n", name.GetData()); return false; } // setup the material csRef<iMaterialWrapper> mat = effectsCollection->FindMaterial(materialName); if (mat) { fact->SetMaterialWrapper(mat); } else { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "Eulora_effects", "No material for label mesh: %s\n", materialName.GetData()); } #if 0 facState->SetVertexCount(4); // we have to set the vertices so that the quad actually gets rendered facState->GetVertices()[0].Set( 0.5f, 0, 0.5f); facState->GetVertices()[1].Set(-0.5f, 0, 0.5f); facState->GetVertices()[2].Set(-0.5f, 0, -0.5f); facState->GetVertices()[3].Set( 0.5f, 0, -0.5f); facState->GetTexels()[0].Set(5.0/8,4.0/16); facState->GetTexels()[1].Set(4.0/8,4.0/16); facState->GetTexels()[2].Set(4.0/8,5.0/16); facState->GetTexels()[3].Set(5.0/8,5.0/16); facState->GetNormals()[0].Set(0,1,0); facState->GetNormals()[1].Set(0,1,0); facState->GetNormals()[2].Set(0,1,0); facState->GetNormals()[3].Set(0,1,0); facState->SetTriangleCount(4); facState->GetTriangles()[0].Set(0, 2, 1); facState->GetTriangles()[1].Set(0, 2, 3); facState->GetTriangles()[2].Set(2, 0, 1); facState->GetTriangles()[3].Set(2, 0, 3); #endif return true; }
bool psEffectManager::LoadFromDirectory(const csString & path, bool includeSubDirs, iView * parentView) { bool success = true; #ifndef DONT_DO_EFFECTS csRef<iVFS> vfs = csQueryRegistry<iVFS> (psCSSetup::object_reg); assert(vfs); if (!vfs->Exists(path)) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "Eulora_effects", "Failed to load effects from directory; %s does not exist", path.GetData()); return false; } if (!vfs->ChDir(path)) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "Eulora_effects", "Failed to load effects from directory; %s read failed", path.GetData()); return false; } csRefArray<iThreadReturn> threadReturns; csRef<iStringArray> files = vfs->FindFiles("*"); for (size_t a=0; a<files->GetSize(); ++a) { const char * file = files->Get(a); if (file[0] == '.') continue; if (strcmp(file, path) == 0) continue; size_t len = strlen(file); char lastChar = file[len-1]; if (lastChar == '/' || lastChar == '\\') { if (includeSubDirs) { if (!LoadFromDirectory(file, true, parentView)) { success = false; } } } else if (len > 4 && ((lastChar == 'f' || lastChar == 'F') && (file[len-2] == 'f' || file[len-2] == 'F') && (file[len-3] == 'e' || file[len-3] == 'E') && file[len-4] == '.')) { threadReturns.Push(LoadEffects(file, parentView)); } } #endif csRef<iThreadManager> threadman = csQueryRegistry<iThreadManager>(object_reg); return threadman->Wait(threadReturns); }
bool psEffectObjSpire::Load(iDocumentNode* node, iLoaderContext* ldr_context) { // get the attributes name.Clear(); materialName.Clear(); shape = SPI_CIRCLE; segments = 5; csRef<iDocumentAttributeIterator> attribIter = node->GetAttributes(); while(attribIter->HasNext()) { csRef<iDocumentAttribute> attr = attribIter->Next(); csString attrName = attr->GetName(); attrName.Downcase(); if(attrName == "name") name = attr->GetValue(); else if(attrName == "material") materialName = attr->GetValue(); else if(attrName == "shape") { csString sshape = attr->GetValue(); sshape.Downcase(); if(sshape == "circle") shape = SPI_CIRCLE; else if(sshape == "cylinder") shape = SPI_CYLINDER; else if(sshape == "asterix") shape = SPI_ASTERIX; else if(sshape == "star") shape = SPI_STAR; else if(sshape == "layered") shape = SPI_LAYERED; } else if(attrName == "segments") segments = attr->GetValueAsInt(); } if(name.IsEmpty()) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Attempting to create an effect obj with no name.\n"); return false; } if(materialName.IsEmpty()) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Attempting to create an effect obj without a material.\n"); return false; } if(!psEffectObj::Load(node, ldr_context)) return false; return PostSetup(); }
bool psEffectAnchorSocket::Create(const csVector3 &offset, iMeshWrapper* posAttach, bool rotateWithMesh) { static unsigned long nextUniqueID = 0; csString anchorID = "effect_anchor_socket_"; anchorID += nextUniqueID++; objBasePos = offset; objOffset = csVector3(0,0,0); this->rotateWithMesh = rotateWithMesh; if(!posAttach) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_WARNING, "planeshift_effects", "Trying to attach an effect socket anchor to nothing.\n"); return false; } cal3d = scfQueryInterface<iSpriteCal3DState> (posAttach->GetMeshObject()); if(!cal3d) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_WARNING, "planeshift_effects", "Trying to attach an effect socket anchor to an invalid mesh type.\n"); return false; } socket = cal3d->FindSocket(socketName); if(!socket) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_WARNING, "planeshift_effects", "Trying to attach an effect socket anchor to a socket that doesn't exist.\n"); return false; } mesh = engine->CreateMeshWrapper("crystalspace.mesh.object.null", anchorID); csRef<iNullMeshState> state = scfQueryInterface<iNullMeshState> (mesh->GetMeshObject()); if(!state) { Error1("No NullMeshState."); return false; } state->SetRadius(1.0); mesh->QuerySceneNode()->SetParent(posAttach->QuerySceneNode()); meshID = socket->AttachSecondary(mesh, csReversibleTransform()); posAttach->GetMovable()->UpdateMove(); isReady = false; initPos = mesh->GetMovable()->GetFullPosition(); return true; }
bool Shagnetron::Initialize () { csRef<iCommandLineParser> cmdline = csQueryRegistry<iCommandLineParser> (object_reg); csRef<iVerbosityManager> verbose = csQueryRegistry<iVerbosityManager> (object_reg); doVerbose = verbose->Enabled ("shagnetron"); // Implicitly enable verboseness for shaders. verbose->Parse ("+renderer.shader.precache"); if (!csInitializer::RequestPlugins (object_reg, CS_REQUEST_VFS, CS_REQUEST_REPORTER, CS_REQUEST_REPORTERLISTENER, CS_REQUEST_PLUGIN("crystalspace.graphics3d.shadermanager", iShaderManager), CS_REQUEST_PLUGIN("crystalspace.documentsystem.multiplexer", iDocumentSystem), CS_REQUEST_END)) { csReport (object_reg, CS_REPORTER_SEVERITY_ERROR, "crystalspace.application.shagnetron", "Can't initialize plugins!"); return false; } // Check for commandline help. if (csCommandLineHelper::CheckHelp (object_reg)) { PrintHelp (); return false; } return true; }
bool csShaderGLCGCommon::WriteToCache (iHierarchicalCache* cache, const ProfileLimits& limits, const ProfileLimitsPair& limitsPair, const char* tag) { csString objectCode; if (program != 0) objectCode = cgGetProgramString (program, CG_COMPILED_PROGRAM); ProgramObject programObj (objectCode, programPositionInvariant ? ProgramObject::flagPositionInvariant : 0, unusedParams); const char* preprocSource (cgGetProgramString (program, CG_PROGRAM_SOURCE)); csString failReason; ProgramObjectID progId; if (!shaderPlug->progCache.WriteObject (preprocSource, limits, programObj, progId, failReason)) { if (shaderPlug->doVerbose) { csReport (objectReg, CS_REPORTER_SEVERITY_WARNING, "crystalspace.graphics3d.shader.glcg", "Error writing %s program for %s to compile cache: %s", GetProgramType(), tag, failReason.GetData()); } return false; } programObj.SetID (progId); return WriteToCache (cache, limits, limitsPair, tag, programObj); }
void csAnimateProctexLoader::Report (int severity, iDocumentNode* node, const char* msg, ...) { va_list arg; va_start (arg, msg); csString text; text.FormatV (msg, arg); csRef<iSyntaxService> synserv; if (node) synserv = csQueryRegistry<iSyntaxService> (object_reg); if (node && synserv) { synserv->Report ("crystalspace.proctex.loader.animimg", severity, node, "%s", (const char*)text); } else { csReport (object_reg, severity, "crystalspace.proctex.loader.animimg", "%s", (const char*)text); } va_end (arg); }
bool psCharAppearance::ChangeMaterial(const char* part, const char* materialName) { if (!part || !materialName) return false; csString materialNameParsed = ParseStrings(part, materialName); bool failed = false; csRef<iMaterialWrapper> material = psengine->GetLoader()->LoadMaterial(materialNameParsed, &failed); if(!failed) { if(!material.IsValid()) { Attachment attach(false); attach.materialName = materialNameParsed; attach.partName = part; if(delayedAttach.IsEmpty()) { psengine->RegisterDelayedLoader(this); } delayedAttach.PushBack(attach); return true; } ProcessAttach(material, materialName, part); return true; } // The material isn't available to load. csReport(psengine->GetObjectRegistry(), CS_REPORTER_SEVERITY_NOTIFY, "planeshift.character.appearance", "Attempted to change to material %s and failed; material not found.", materialNameParsed.GetData()); return false; }
iDocumentNode* csShaderProgram::GetProgramNode (ProgramSource& programSource) { if (programSource.programNode.IsValid ()) return programSource.programNode; if (programSource.programData.IsValid ()) { csRef<iDocumentSystem> docsys = csQueryRegistry<iDocumentSystem> (objectReg); if (!docsys) docsys.AttachNew (new csTinyDocumentSystem ()); csRef<iDocument> doc (docsys->CreateDocument ()); const char* err = doc->Parse (programSource.programData, true); if (err != 0) { csReport (objectReg, CS_REPORTER_SEVERITY_WARNING, "crystalspace.graphics3d.shader.common", "Error parsing %s: %s", programSource.programFileName.GetData(), err); return 0; } programSource.programNode = doc->GetRoot (); programSource.programData.Invalidate(); return programSource.programNode; } return nullptr; }
bool psEffectObjMesh::Load(iDocumentNode *node, iLoaderContext * ldr_context) { globalStringSet = csQueryRegistryTagInterface<iStringSet> (psCSSetup::object_reg, "crystalspace.shared.stringset"); // get the attributes name.Clear(); materialName.Clear(); factName.Clear(); csRef<iDocumentAttributeIterator> attribIter = node->GetAttributes(); while (attribIter->HasNext()) { csRef<iDocumentAttribute> attr = attribIter->Next(); csString attrName = attr->GetName(); attrName.Downcase(); if (attrName == "name") name = attr->GetValue(); else if (attrName == "material") materialName = attr->GetValue(); else if (attrName == "fact") factName = attr->GetValue(); } if (name.IsEmpty()) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "Eulora_effects", "Attempting to create an effect obj with no name.\n"); return false; } if (!psEffectObj::Load(node, ldr_context)) return false; return PostSetup(ldr_context); }
bool psEffectObjStar::PostSetup() { static unsigned int uniqueID = 0; csString facName = "effect_star_fac_"; facName += uniqueID++; meshFact = engine->CreateMeshFactory ("crystalspace.mesh.object.genmesh", facName.GetData()); effectsCollection->Add(meshFact->QueryObject()); // create the actual sprite3d data iMeshObjectFactory* fact = meshFact->GetMeshObjectFactory(); csRef<iGeneralFactoryState> facState = scfQueryInterface<iGeneralFactoryState> (fact); // setup the material csRef<iMaterialWrapper> mat = effectsCollection->FindMaterial(materialName); if (!mat) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Couldn't find effect material: %s\n", materialName.GetData()); return false; } fact->SetMaterialWrapper(mat); GenerateRays(); float topScale = 1.0f; //float height = 1.0f; facState->SetVertexCount(3*segments); for (int b=0; b<segments; ++b) { // vertex data facState->GetVertices()[b*3 ].Set(0, 0, 0); facState->GetVertices()[b*3+1].Set(perp[b] * -topScale + rays[b]); facState->GetVertices()[b*3+2].Set(perp[b] * topScale + rays[b]); // texture coordinates facState->GetTexels()[b*3 ].Set(0.5f, 0.05f); facState->GetTexels()[b*3+1].Set(0, 0.95f); facState->GetTexels()[b*3+2].Set(1, 0.95f); // normals facState->GetNormals()[b*3 ].Set(-rays[b]); facState->GetNormals()[b*3+1].Set( rays[b]); facState->GetNormals()[b*3+2].Set( rays[b]); } animLength = 10; if (keyFrames->GetSize() > 0) animLength += keyFrames->Get(keyFrames->GetSize()-1)->time; facState->SetTriangleCount(2*segments); for (int q=0; q<segments; ++q) { facState->GetTriangles()[q*2 ].Set(q*3, q*3+1, q*3+2); facState->GetTriangles()[q*2+1].Set(q*3, q*3+2, q*3+1); } return true; }
bool csConsoleOutput::Initialize (iObjectRegistry *object_reg) { csConsoleOutput::object_reg = object_reg; G3D = csQueryRegistry<iGraphics3D> (object_reg); if (!G3D) return false; G2D = G3D->GetDriver2D (); csConfigAccess Config (object_reg, "/config/standardcon.cfg"); const char* fontname = Config->GetStr ("StandardConsole.ConFont", "auto"); int fontsize = Config->GetInt ("StandardConsole.ConFontSize", 10); transparent = Config->GetBool ("StandardConsole.TranspBG", false); // Initialize the display rectangle to the entire display size.Set (0, 0, G2D->GetWidth () - 1, G2D->GetHeight () - 1); invalid.Set (size); // Invalidate the entire console int fw, fh; csRef<iFontServer> fserv = G2D->GetFontServer(); if (fserv) { if (!strcasecmp (fontname, "auto")) { // choose a font that allows at least 80 columns of text if (G2D->GetWidth () <= 560) fontname = CSFONT_SMALL; else if (G2D->GetWidth () <= 640) fontname = CSFONT_COURIER; else fontname = CSFONT_LARGE; fontsize = 10; } font = fserv->LoadFont (fontname, fontsize); font->GetMaxSize (fw, fh); } else { fw = fh = 20; csReport (object_reg, CS_REPORTER_SEVERITY_WARNING, "crystalspace.console.output.standard", "csConsoleOutput: Unable to locate iFontServer"); } // Create the backbuffer (4096 lines max) buffer = new csConsoleBuffer (4096, (size.Height() / (fh + 2))); // Initialize flash_time for flashing cursors flash_time = csGetTicks (); // We want to see broadcast events CS_INITIALIZE_SYSTEM_EVENT_SHORTCUTS (object_reg); if (!eventHandler) eventHandler.AttachNew (new EventHandler (this)); csRef<iEventQueue> q (csQueryRegistry<iEventQueue> (object_reg)); if (q.IsValid()) { csEventID events[3] = { SystemOpen, SystemClose, CS_EVENTLIST_END }; q->RegisterListener (eventHandler, events); } return true; }
bool psEffectObjLabel::Load(iDocumentNode *node, iLoaderContext* ldr_context) { // get the attributes name.Clear(); materialName.Clear(); sizeFileName.Clear(); csRef<iDocumentAttributeIterator> attribIter = node->GetAttributes(); while (attribIter->HasNext()) { csRef<iDocumentAttribute> attr = attribIter->Next(); csString attrName = attr->GetName(); attrName.Downcase(); if (attrName == "name") name = attr->GetValue(); else if (attrName == "material") materialName = attr->GetValue(); else if (attrName == "sizefile") sizeFileName = attr->GetValue(); else if (attrName == "labelwidth") labelwidth = attr->GetValueAsFloat(); } if (name.IsEmpty()) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "Eulora_effects", "Attempting to create an effect obj with no name.\n"); return false; } if (materialName.IsEmpty()) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "Eulora_effects", "Attempting to create an effect obj with no material.\n"); return false; } if (!sizeFileName.IsEmpty()) { LoadGlyphs(sizeFileName); } if (!psEffectObj::Load(node, ldr_context)) { return false; } return PostSetup(); }
bool psEffectObjParticles::Render(const csVector3 &up) { static unsigned long nextUniqueID = 0; csString effectID = "effect_particles_"; effectID += nextUniqueID++; mesh = engine->CreateMeshWrapper(meshFact, effectID); // mesh has been loaded before hand if(!mesh) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Couldn't load desired mesh!\n"); return false; } // do the up vector objUp = up; csReversibleTransform rt; rt.LookAt(up, csVector3(1,2,0)); matUp = rt.GetT2O(); matBase = matUp; // common flags mesh->GetFlags().Set(CS_ENTITY_NOHITBEAM); mesh->SetZBufMode(zFunc); mesh->SetRenderPriority(priority); mesh->GetMeshObject()->SetMixMode(mixmode); // disable culling csStringID viscull_id = globalStringSet->Request("viscull"); mesh->GetMeshObject()->GetObjectModel()->SetTriangleData(viscull_id, 0); // obj specific //pstate = scfQueryInterface<iParticlesObjectState> (mesh->GetMeshObject()); //if (!pstate) //{ // csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Effect obj is of type particles, but the mesh is not!\n"); // return false; //} // add the custom material if set if(!materialName.IsEmpty()) { csRef<iMaterialWrapper> mat = effectsCollection->FindMaterial(materialName); if(mat != 0) mesh->GetMeshObject()->SetMaterialWrapper(mat); } //if (mixmode != CS_FX_ALPHA) //pstate->SetMixMode(mixmode); //pstate->Start(); isAnimating = true; return true; }
bool psEffectObjSimpMesh::Load(iDocumentNode *node, iLoaderContext* ldr_context) { // get the attributes name.Clear(); materialName.Clear(); fileName.Clear(); csRef<iDocumentAttributeIterator> attribIter = node->GetAttributes(); while (attribIter->HasNext()) { csRef<iDocumentAttribute> attr = attribIter->Next(); csString attrName = attr->GetName(); attrName.Downcase(); if (attrName == "name") name = attr->GetValue(); else if (attrName == "material") materialName = attr->GetValue(); else if (attrName == "file") fileName = csString("/this/art/effects/") + attr->GetValue(); else if (attrName == "mesh") meshName = attr->GetValue(); } if (name.IsEmpty()) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "Eulora_effects", "Attempting to create an effect obj with no name.\n"); return false; } csRef<iVFS> vfs = csQueryRegistry<iVFS> (psCSSetup::object_reg); assert(vfs); if (!vfs->Exists(fileName)) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "Eulora_effects", "Attempting to create an effect obj without specifying an existing mesh file.\n"); return false; } if (!psEffectObj::Load(node, ldr_context)) return false; return PostSetup(); }
bool psEffectObjLabel::Render(const csVector3 &up) { //printf("label: render\n"); if(!CreateMeshFact()) return false; objUp = up; static unsigned long nextUniqueID = 0; csString effectID = "effect_label_"; effectID += nextUniqueID++; // create a mesh wrapper from the factory we just created mesh = engine->CreateMeshWrapper(meshFact, effectID.GetData()); if (!mesh) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "Eulora_effects", "Couldn't create meshwrapper in label effect\n"); return false; } // do the up vector // csReversibleTransform rt; // rt.LookAt(csVector3(up.x, up.z, up.y), csVector3(0,2,1)); // matUp = rt.GetT2O(); // matBase = matUp; // common flags mesh->GetFlags().Set(CS_ENTITY_NOHITBEAM); mesh->GetFlags().Set(CS_ENTITY_NODECAL); // we can have labels overlay geometry, or we can have them be occluded by it like normal objects //priority = engine->GetAlphaRenderPriority(); // zFunc = CS_ZBUF_NONE; priority = engine->GetObjectRenderPriority(); zFunc = CS_ZBUF_USE; mixmode = CS_FX_COPY; //printf("zbufmode: %d pri: %d mixmode: %d\n", zFunc, priority, mixmode); mesh->SetZBufMode(zFunc); mesh->SetRenderPriority(priority); // disable culling csStringID viscull_id = globalStringSet->Request ("viscull"); mesh->GetMeshObject()->GetObjectModel()->SetTriangleData(viscull_id, 0); genState = scfQueryInterface<iGeneralMeshState> (mesh->GetMeshObject()); // obj specific if (mixmode != CS_FX_ALPHA) mesh->GetMeshObject()->SetMixMode(mixmode); // to check // genState->SetMixMode(mixmode); //was not working with latest CS return true; }
psEffectAnchor * psEffect::CreateAnchor(const csString & type) { if (type == "basic") return new psEffectAnchorBasic(); else if (type == "spline") return new psEffectAnchorSpline(); else if (type == "socket") return new psEffectAnchorSocket(); csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Unknown anchor type: %s\n", type.GetData()); return 0; }
void psCmdBase::Report(int severity, const char* msgtype, const char* description, ... ) { char str[1024]; va_list args; va_start (args, description); vsnprintf(str,1024,description,args); str[1023]=0x00; csReport(objreg,severity,msgtype,"%s",str); va_end (args); }
bool AddLayersFromFile (iObjectRegistry* objectReg, const char* fileName, MultipleRenderLayer& layers) { csRef<iDocumentSystem> docsys = csQueryRegistry<iDocumentSystem> ( objectReg); if (!docsys.IsValid()) docsys.AttachNew (new csTinyDocumentSystem ()); csRef<iVFS> vfs = csQueryRegistry<iVFS> (objectReg); CS_ASSERT(vfs); csRef<iFile> file = vfs->Open (fileName, VFS_FILE_READ); if (!file) { csReport (objectReg, CS_REPORTER_SEVERITY_WARNING, messageID, "Error opening '%s'", fileName); return false; } csRef<iDocument> doc = docsys->CreateDocument(); const char* error = doc->Parse (file); if (error != 0) { csReport (objectReg, CS_REPORTER_SEVERITY_WARNING, messageID, "Error parsing '%s': %s", fileName, error); return false; } csRef<iDocumentNode> docRoot = doc->GetRoot(); if (!docRoot) return false; csRef<iDocumentNode> layerConfigNode = docRoot->GetNode ("layerconfig"); if (!layerConfigNode) { csReport (objectReg, CS_REPORTER_SEVERITY_WARNING, messageID, "No <layerconfig> in '%s'", fileName); return false; } return AddLayersFromDocument (objectReg, layerConfigNode, layers); }
bool csDecalManager::EnsureEngineReference () { if (!engine) { engine = csQueryRegistry<iEngine> (objectReg); if (!engine) { csReport (objectReg, CS_REPORTER_SEVERITY_ERROR, "crystalspace.decal", "Couldn't query engine"); return false; } } return true; }
G2DTestSystemDriver::G2DTestSystemDriver (int argc, char* argv[]) { state_sptr = 0; EnterState (stInit); SwitchBB = false; object_reg = csInitializer::CreateEnvironment (argc, argv); if (!csInitializer::SetupConfigManager (object_reg, "/config/g2dtest.cfg")) { csReport (object_reg, CS_REPORTER_SEVERITY_ERROR, "crystalspace.application.g2dtest", "Unable to init app!"); exit (0); } if (!csInitializer::RequestPlugins (object_reg, CS_REQUEST_VFS, CS_REQUEST_FONTSERVER, CS_REQUEST_LEVELLOADER, CS_REQUEST_END)) { csReport (object_reg, CS_REPORTER_SEVERITY_ERROR, "crystalspace.application.g2dtest", "Unable to init app!"); exit (0); } csRef<iEventQueue> q (csQueryRegistry<iEventQueue> (object_reg)); if (q != 0) { EventOutlet = q->GetEventOutlet(); EventOutlet->IncRef(); } }
bool psEffectObjParticles::PostSetup(iLoaderContext* ldr_context) { static unsigned int uniqueID = 0; csString facName = "effect_particles_fac_"; facName += uniqueID++; meshFact = ldr_context->FindMeshFactory(factName); if(!meshFact) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Could not find factory: %s\n", factName.GetData()); return false; } return true; }
psEffectObjSound::psEffectObjSound(iView *parentView, psEffect2DRenderer * renderer2d) : psEffectObj(parentView, renderer2d) { soundManager = csQueryRegistryOrLoad<iSoundManager>(psCSSetup::object_reg, "iSoundManager"); if(!soundManager) { // if the main sound manager is not found load the dummy plugin soundManager = csQueryRegistryOrLoad<iSoundManager>(psCSSetup::object_reg, "crystalspace.planeshift.sound.dummy"); if(!soundManager) { csReport(psCSSetup::object_reg, CS_REPORTER_SEVERITY_ERROR, "planeshift_effects", "Could not find plugin iSoundManager.\n"); } } soundID = 0; }
bool EventTest::OnInitialize(int /*argc*/, char* /*argv*/ []) { // RequestPlugins() will load all plugins we specify. In addition // it will also check if there are plugins that need to be loaded // from the config system (both the application config and CS or // global configs). In addition it also supports specifying plugins // on the commandline. if (!csInitializer::RequestPlugins(GetObjectRegistry(), CS_REQUEST_VFS, CS_REQUEST_OPENGL3D, CS_REQUEST_FONTSERVER, CS_REQUEST_END)) return ReportError("Failed to initialize plugins!"); // Attempt to load a joystick plugin. csRef<iStringArray> joystickClasses = iSCF::SCF->QueryClassList ("crystalspace.device.joystick."); if (joystickClasses.IsValid()) { csRef<iPluginManager> plugmgr = csQueryRegistry<iPluginManager> (object_reg); for (size_t i = 0; i < joystickClasses->GetSize (); i++) { const char* className = joystickClasses->Get (i); csRef<iBase> b = plugmgr->LoadPlugin (className); csReport (object_reg, CS_REPORTER_SEVERITY_NOTIFY, "crystalspace.application.joytest", "Attempt to load plugin '%s' %s", className, (b != 0) ? "successful" : "failed"); if (b != 0) b->DecRef (); } } // "Warm up" the event handler so it can interact with the world csBaseEventHandler::Initialize(GetObjectRegistry()); // Now we need to register the event handler for our application. // Crystal Space is fully event-driven. Everything (except for this // initialization) happens in an event. if (!RegisterQueue(GetObjectRegistry(), csevAllEvents(GetObjectRegistry()))) return ReportError("Failed to set up event handler!"); return true; }
void csShaderGLCGCommon::WriteAdditionalDumpInfo (const char* description, const char* content) { if (!shaderPlug->debugDump || !debugFN) return; csRef<iVFS> vfs = csQueryRegistry<iVFS> (objectReg); csRef<iDataBuffer> oldDump = vfs->ReadFile (debugFN, true); csString output (oldDump ? (char*)oldDump->GetData() : 0); output << description << ":\n"; output << content; output << "\n"; if (!vfs->WriteFile (debugFN, output.GetData(), output.Length ())) { csReport (objectReg, CS_REPORTER_SEVERITY_WARNING, "crystalspace.graphics3d.shader.glcg", "Could not augment %s", CS::Quote::Single (debugFN.GetData())); } }
bool csShaderGLCGCommon::WriteToCache (iHierarchicalCache* cache, const ProfileLimits& limits, const ProfileLimitsPair& limitsPair, const char* tag, const ProgramObject& program) { csString failReason; if (!WriteToCacheWorker (cache, limits, limitsPair, tag, program, failReason)) { if (shaderPlug->doVerbose) { csReport (objectReg, CS_REPORTER_SEVERITY_WARNING, "crystalspace.graphics3d.shader.glcg", "Error writing %s program for %s to cache: %s", GetProgramType(), tag, failReason.GetData()); } return false; } return true; }