Example #1
0
void Material::SectionINT::constructNode(hecl::BlenderConnection::PyOutStream& out,
                                         const PAKRouter<PAKBridge>& pakRouter,
                                         const PAK::Entry& entry,
                                         const Material::ISection* prevSection,
                                         unsigned idx,
                                         unsigned& texMapIdx,
                                         unsigned& texMtxIdx,
                                         unsigned& kColorIdx) const
{
    switch (Subtype(subtype.toUint32()))
    {
    case Subtype::OPAC:
    {
        GX::Color clr(value);
        out.format("anode = new_nodetree.nodes.new('ShaderNodeValue')\n"
                   "anode.outputs['Value'].default_value = %f\n",
                   float(clr[3]) / float(0xff));
        out << "gridder.place_node(anode, 1)\n";
    }
        break;
    case Subtype::BLOD:
        out.format("new_material.retro_blod = %d\n", value);
        break;
    case Subtype::BLOI:
        out.format("new_material.retro_bloi = %d\n", value);
        break;
    case Subtype::BNIF:
        out.format("new_material.retro_bnif = %d\n", value);
        break;
    case Subtype::XRBR:
        out.format("new_material.retro_xrbr = %d\n", value);
        break;
    default: break;
    }
}
Example #2
0
/**
 * @brief Creates an instance from an input stream.
 *
 * The input stream must respect the syntax of this entity type.
 *
 * @param game the game that will contain the entity created
 * @param is an input stream
 * @param layer the layer
 * @param x x coordinate of the entity
 * @param y y coordinate of the entity
 * @return the instance created
 */
MapEntity* Stairs::parse(Game &game, std::istream &is, Layer layer, int x, int y) {

  std::string name;
  int direction, subtype;

  FileTools::read(is, name);
  FileTools::read(is, direction);
  FileTools::read(is, subtype);

  return new Stairs(name, Layer(layer), x, y, direction, Subtype(subtype));
}
Example #3
0
/**
 * @brief Creates an instance from an input stream.
 *
 * The input stream must respect the syntax of this entity type.
 *
 * @param game the game that will contain the entity created
 * @param is an input stream
 * @param layer the layer
 * @param x x coordinate of the entity
 * @param y y coordinate of the entity
 * @return the instance created
 */
MapEntity* Sensor::parse(Game &game, std::istream &is, Layer layer, int x, int y) {

  std::string name;
  int width, height, subtype;

  FileTools::read(is, width);
  FileTools::read(is, height);
  FileTools::read(is, name);
  FileTools::read(is, subtype);
 
  return new Sensor(name, Layer(layer), x, y, width, height, Subtype(subtype));
}
Example #4
0
/**
 * @brief Converts a subtype name into a value of the Subtype enumeration.
 * @param subtype_name the name of a destructible item subtype
 * @return the corresponding subtype
 */
Destructible::Subtype Destructible::get_subtype_by_name(
    const std::string& subtype_name) {

  for (int i = 0; i < SUBTYPE_NUMBER; i++) {
    if (i != DEPRECATED_1 && features[i].name == subtype_name) {
      return Subtype(i);
    }
  }

  Debug::die(StringConcat() << "Invalid destructible item subtype name: '"
      << subtype_name << "'");
  throw;
}
Example #5
0
void
MimeTypeItem::UpdateText()
{
	if (IsSupertypeOnly())
		return;

	BMimeType type(fType.String());

	char description[B_MIME_TYPE_LENGTH];
	if (type.GetShortDescription(description) == B_OK)
		SetText(description);
	else
		SetText(Subtype());

	fDescription = Text();
}
Example #6
0
/**
 * @brief Creates an instance from an input stream.
 *
 * The input stream must respect the syntax of this entity type.
 *
 * @param game the game that will contain the entity created
 * @param is an input stream
 * @param layer the layer
 * @param x x coordinate of the entity
 * @param y y coordinate of the entity
 * @return the instance created
 */
MapEntity* Teletransporter::parse(Game &game, std::istream &is, Layer layer, int x, int y) {
	
  int width, height, subtype, transition_style;
  MapId destination_map_id;
  std::string name, destination_point_name;

  FileTools::read(is, width);
  FileTools::read(is, height);
  FileTools::read(is, name);
  FileTools::read(is, subtype);
  FileTools::read(is, transition_style);
  FileTools::read(is, destination_map_id);
  FileTools::read(is, destination_point_name);

  return new Teletransporter(name, Layer(layer), x, y, width, height,
      Subtype(subtype), Transition::Style(transition_style),
      destination_map_id, destination_point_name);
}
Example #7
0
void Material::SectionCLR::constructNode(hecl::BlenderConnection::PyOutStream& out,
                                         const PAKRouter<PAKBridge>& pakRouter,
                                         const PAK::Entry& entry,
                                         const Material::ISection* prevSection,
                                         unsigned idx,
                                         unsigned& texMapIdx,
                                         unsigned& texMtxIdx,
                                         unsigned& kColorIdx) const
{
    DNAMP1::MaterialSet::Material::AddKcolor(out, color, kColorIdx++);
    switch (Subtype(subtype.toUint32()))
    {
    case Subtype::DIFB:
        out << "kc_node.label += ' DIFB'\n"
               "ka_node.label += ' DIFB'\n";
        break;
    default: break;
    }
}
Example #8
0
		bool IsFeatureCodec() const
		{
			return this->subtype >= Subtype(400);
		}
Example #9
0
		bool IsComplementaryCodec() const
		{
			return this->subtype >= Subtype(300) && this->subtype < (Subtype)400;
		}
Example #10
0
		bool IsMediaCodec() const
		{
			return this->subtype >= Subtype(100) && this->subtype < (Subtype)300;
		}
Example #11
0
void Material::SectionPASS::constructNode(hecl::BlenderConnection::PyOutStream& out,
                                          const PAKRouter<PAKBridge>& pakRouter,
                                          const PAK::Entry& entry,
                                          const Material::ISection* prevSection,
                                          unsigned idx,
                                          unsigned& texMapIdx,
                                          unsigned& texMtxIdx,
                                          unsigned& kColorIdx) const
{
    /* Add Texture nodes */
    if (txtrId)
    {
        std::string texName = pakRouter.getBestEntryName(txtrId);
        const nod::Node* node;
        const PAK::Entry* texEntry = pakRouter.lookupEntry(txtrId, &node);
        hecl::ProjectPath txtrPath = pakRouter.getWorking(texEntry);
        if (txtrPath.getPathType() == hecl::ProjectPath::Type::None)
        {
            PAKEntryReadStream rs = texEntry->beginReadStream(*node);
            TXTR::Extract(rs, txtrPath);
        }
        hecl::SystemString resPath = pakRouter.getResourceRelativePath(entry, txtrId);
        hecl::SystemUTF8View resPathView(resPath);
        out.format("if '%s' in bpy.data.textures:\n"
                   "    image = bpy.data.images['%s']\n"
                   "    texture = bpy.data.textures[image.name]\n"
                   "else:\n"
                   "    image = bpy.data.images.load('''//%s''')\n"
                   "    image.name = '%s'\n"
                   "    texture = bpy.data.textures.new(image.name, 'IMAGE')\n"
                   "    texture.image = image\n"
                   "tex_maps.append(texture)\n"
                   "\n", texName.c_str(), texName.c_str(),
                   resPathView.str().c_str(), texName.c_str());
        if (uvAnim.size())
        {
            const UVAnimation& uva = uvAnim[0];
            DNAMP1::MaterialSet::Material::AddTexture(out, GX::TexGenSrc(uva.unk1 + (uva.unk1 < 2 ? 0 : 2)), texMtxIdx, texMapIdx++);
            DNAMP1::MaterialSet::Material::AddTextureAnim(out, uva.anim.mode, texMtxIdx++, uva.anim.vals);
        }
        else
            DNAMP1::MaterialSet::Material::AddTexture(out, GX::TexGenSrc(uvSrc + 4), -1, texMapIdx++);
    }

    /* Special case for RFLV (environment UV mask) */
    if (Subtype(subtype.toUint32()) == Subtype::RFLV)
    {
        if (txtrId)
            out << "rflv_tex_node = texture_nodes[-1]\n";
        return;
    }

    /* Add PASS node */
    bool linkRAS = false;
    out << "prev_pnode = pnode\n"
           "pnode = new_nodetree.nodes.new('ShaderNodeGroup')\n";
    switch (Subtype(subtype.toUint32()))
    {
    case Subtype::DIFF:
    {
        out << "pnode.node_tree = bpy.data.node_groups['RetroPassDIFF']\n";
        if (txtrId)
        {
            out << "new_material.hecl_lightmap = texture.name\n"
                << "texture.image.use_fake_user = True\n";
        }
        linkRAS = true;
        break;
    }
    case Subtype::RIML:
        out << "pnode.node_tree = bpy.data.node_groups['RetroPassRIML']\n";
        if (idx == 0)
            linkRAS = true;
        break;
    case Subtype::BLOL:
        out << "pnode.node_tree = bpy.data.node_groups['RetroPassBLOL']\n";
        if (idx == 0)
            linkRAS = true;
        break;
    case Subtype::BLOD:
        out << "pnode.node_tree = bpy.data.node_groups['RetroPassBLOD']\n";
        if (idx == 0)
            linkRAS = true;
        break;
    case Subtype::CLR:
        out << "pnode.node_tree = bpy.data.node_groups['RetroPassCLR']\n";
        if (idx == 0)
            linkRAS = true;
        break;
    case Subtype::TRAN:
        if (flags.TRANInvert())
            out << "pnode.node_tree = bpy.data.node_groups['RetroPassTRANInv']\n";
        else
            out << "pnode.node_tree = bpy.data.node_groups['RetroPassTRAN']\n";
        break;
    case Subtype::INCA:
        out << "pnode.node_tree = bpy.data.node_groups['RetroPassINCA']\n";
        break;
    case Subtype::RFLV:
        out << "pnode.node_tree = bpy.data.node_groups['RetroPassRFLV']\n";
        break;
    case Subtype::RFLD:
        out << "pnode.node_tree = bpy.data.node_groups['RetroPassRFLD']\n"
               "if rflv_tex_node:\n"
               "    new_nodetree.links.new(rflv_tex_node.outputs['Color'], pnode.inputs['Mask Color'])\n"
               "    new_nodetree.links.new(rflv_tex_node.outputs['Value'], pnode.inputs['Mask Alpha'])\n";
        break;
    case Subtype::LRLD:
        out << "pnode.node_tree = bpy.data.node_groups['RetroPassLRLD']\n";
        break;
    case Subtype::LURD:
        out << "pnode.node_tree = bpy.data.node_groups['RetroPassLURD']\n";
        break;
    case Subtype::BLOI:
        out << "pnode.node_tree = bpy.data.node_groups['RetroPassBLOI']\n";
        break;
    case Subtype::XRAY:
        out << "pnode.node_tree = bpy.data.node_groups['RetroPassXRAY']\n";
        break;
    case Subtype::TOON:
        out << "pnode.node_tree = bpy.data.node_groups['RetroPassTOON']\n";
        break;
    default: break;
    }
    out << "gridder.place_node(pnode, 2)\n";

    if (txtrId)
    {
        out << "new_nodetree.links.new(texture_nodes[-1].outputs['Color'], pnode.inputs['Tex Color'])\n"
               "new_nodetree.links.new(texture_nodes[-1].outputs['Value'], pnode.inputs['Tex Alpha'])\n";
    }

    if (linkRAS)
        out << "new_nodetree.links.new(material_node.outputs['Color'], pnode.inputs['Prev Color'])\n"
               "new_nodetree.links.new(material_node.outputs['Alpha'], pnode.inputs['Prev Alpha'])\n";
    else if (prevSection)
    {
        if (prevSection->m_type == ISection::Type::PASS &&
            Subtype(static_cast<const SectionPASS*>(prevSection)->subtype.toUint32()) != Subtype::RFLV)
            out << "new_nodetree.links.new(prev_pnode.outputs['Next Color'], pnode.inputs['Prev Color'])\n"
                   "new_nodetree.links.new(prev_pnode.outputs['Next Alpha'], pnode.inputs['Prev Alpha'])\n";
        else if (prevSection->m_type == ISection::Type::CLR)
            out << "new_nodetree.links.new(kcolor_nodes[-1][0].outputs[0], pnode.inputs['Prev Color'])\n"
                   "new_nodetree.links.new(kcolor_nodes[-1][1].outputs[0], pnode.inputs['Prev Alpha'])\n";
    }

    /* Row Break in gridder */
    out << "gridder.row_break(2)\n";
}