News:

One Minute Game Review by The Happy Friar: https://ugetube.com/@OneMinteGameReviews
Also on Rumble: https://rumble.com/c/c-1115371

idTech 4 (aka Doom 3 tech) Discord Server! https://discord.gg/9wtCGHa

Main Menu

blender level creator script

Started by BielBdeLuna, March 24, 2015, 06:38:10 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

BielBdeLuna

#15
there are no texture tools in dark radiant like there are in Blender!

quake/d3 texture all derive form the centre of the map, there is no secret there, it's all planar projections on the surfaces that conform the brushes.
that's the sole reason there is no UV projections (because there aren't any vertex positions to start with) there is only translation rotation and scale all deriving from the centre of the map.

as you see the centre of the map does play a greater role than just being the origin of the world coordinates.

motorsep

#16
Quote from: BielBdeLuna on March 27, 2015, 12:00:57 PM
there are no texture tools in dark radiant like there are in Blender!

quake/d3 texture all derive form the centre of the map, there is no secret there, it's all planar projections on the surfaces that conform the brushes.
that's the sole reason there is no UV projections (because there aren't any vertex positions to start with) there is only translation rotation and scale all deriving from the centre of the map.

as you see the centre of the map does play a greater role than just being the origin of the world coordinates.

What I am saying is in Radiant, you slap material on the face of the brush, and slide/scale it, or select several faces on several brush and press a button to align the materials. It's extremely fast workflow and Blender is incapable of providing such workflow. Not to mention you can't select several meshes in Blender and edit them all at once to match UV maps. UV mapping is the slowest workflow for architectural modeling. Not to mention as soon as you edit mesh that you already UV mapped, it will screw up existing UV map. And I am telling this because of my experience working with CSG and modeling.

Blender would need an add-on that does all the texture mapping under the hood, where the workflow/UI if the same as in Radiant for brushes.

Hey, but who am I to be listened to. Export Doom 3 map as OBJ, remove all the texture coordinates, turn it into a mesh as if it was modeled in Blender initially and try texturing it. You'll quickly see what I am talking about ;)

BielBdeLuna

#17
I bet its far easier than not seeing your closer walls in front of your further walls in order to texture as it is for me at the moment within Darkradiant, go figure  ;)

but let's be constructive for a change, eh... motorsep? I guess we could use a fake object in the middle and reference this object as a texture guide (as for a centre) and then add special properties at the objects in order to change it's UV mapping in relation to that object, this could be done in a one click operation and sort of automatically via python. so it would apply UV mapping to all selected "brushes-meshes" and create their UV mapping taking into account several special properties

there though other problems how do we know what materials there are available? and the entities? could we decode the resource files automatically via python and gather all this info? could we get pk4 support? etc...

but first things first I'm trying to sort out the plane equation and so let some first code to the future repository so all can try: https://github.com/BielBdeLuna/Blender_IDtech4_GPL_map

motorsep

The closest thing you can do is to use generated texture coordinates with planar mapping. Maybe new box mapping could work. The problem is that Blender can't, at its core, work with several selected objects at once. It can only work with one object at a time.

You can make add-on to create dynamic dialog and populate it with properties from .def files. Basically you'd recreate DarkRadiant in Python for Blender. I don't know if you can do that straight from .resources. Perhaps you can write IO for that in Python, but that might not be supported in Blender's API.

BielBdeLuna

ok I will ask you to stop giving me your support at the moment, I really don't need it right at the moment.

trebor

Quote from: BielBdeLuna on March 27, 2015, 04:05:28 PM

there though other problems how do we know what materials there are available? and the entities? could we decode the resource files automatically via python and gather all this info? could we get pk4 support? etc...


My plan was to write an "exportEntityDefinitions" console command that iterates through all entity and model declarations in def/* and exports its into a single xml file for the blender plugin.

BielBdeLuna

#21
ok sounds great  :)

that's my current plan for the exporter no code yet, and just for exporting brushes:

    - make a list of selected objects in the scene
        - if there aren't selected obejcts in the scene gather them all in the list
    - check if all their faces are coplanar?
        - error if non complanar faces?
    - for every object
        - for every coplanar quad face
            - gather normal
            - find the shortest distance between the surface, in which the face is inscribed in, and the global centre
            - figure out how to translate the UVmap to a global UV mapping
            - write brush info in the *.map file
        - get a solution for non coplanar quad faces?
            - separate the two tris as if they where two different surfaces?
                - i think non coplanar quad faces are not allowed in radiant
            - are concave/convex surfaces a problem?

BielBdeLuna

I've coded a mock-up UI in blender in order to have something working, and I've pushed the changes to Github, I'm calling it "Export idTech GPL map" which I don't quite like, it follows the "Export Quake map", and the "Export idTech4 model" script names scheme, so it fits but it's not that much of a differentiation as idtech 2 and 3 are also GPL, and I don't quite like calling it "idTech4.5", how would you guys call a engine derived from the BFG gpl release?

I would like to propose "idTechX" because, X could be a variable meaning any number, and also because X in Roman numerals means 10 which in number is far superior to the already released idTech 2-4, so it's something else besides those engines

BielBdeLuna

I'm stuck! I have the code calculating the normal, which was a super easy function in Blender

After using a much difficult function, and complicating me the existence, I've found now an easier function that calculates the distance between a point and a surface, it only needs the point, the normal of the surface and a point on the surface the normal and the point (which is one of the vertices of the polygon that resides in the surface) are the only thing needed to represent the surface

Blender doesn't accept that function and it returns an error TypeError: distance_point_to_plane which seems like I'm mismatching the variable type to store the return of distance_point_to_surface function, but the variable is initiated by the function (which returns a float, which is what I need) so... I don't know. I guess now it's time to sleep and tomorrow I'll find the damn solution

after that I'll skip the brushDef3 texture as it seems to be something damn difficult and I'll try to export the vertices of a spline.

texture info in brushDef3 seems like a way too complicated scheme, I can image a simpler way to store the same texture info, which could uses a number less. but I guess every complication has it's reasons, so time will tell, let's all learn from those complications. O0

As always the code is in github: https://github.com/BielBdeLuna/Blender_IDtech4_GPL_map so if you want to check it out you're free to do so. :D


BielBdeLuna

at least I got it to export several brushDef3 objects, albeit too small, now I'll try to add the scale back
but normal is done and
distance is done

BielBdeLuna


BielBdeLuna

done, it works now,

so I'm now at 0.0.1 alpha stage, I can export tiny brushDef3 brushes with fake texture coordinates and a strange material

it's tiny because it's lacking the scale conversion yet but it's there. :D

trebor

I uploaded my changes of my new .map file format primitive.

https://github.com/RobertBeckebans/RBDOOM-3-BFG/tree/map-primitive-polygons-for-blender

You can convert existing maps using
convertMap <mapname> and it will write a _converted.map version.

Then you can compile it with dmap. AAS support is still missing.

Common_mapconvert.map also features an OBJ map exporter.
You can use it with the exportMaptoOBJ <map> console command.

This way you don't have to mess with brushes or curves anymore. Simply model everything in your map in blender and put it into a BSP group.
Export the BSP group as worldspawn and everything else as indiviual entities. Then it should work.

The map format still needs to be extended. The new mesh primitives should be flagged as detail geometry or non detail geometry.
Because you don't want to have pipes and other curves considered as structural BSP geometry.

This is how it looks

// entity 0
{
"classname" "worldspawn"
// primitive 0
{
meshDef
{
  ( 24 6 0 0 0 )
  (
   ( 192 -128 256 -2 -2.998046875 0.003921628 0.003921628 -1 )
   ( -192 -128 256 -2 3 0.003921628 0.003921628 -1 )
   ( -192 256 256 4 3 0.003921628 0.003921628 -1 )
   ( 192 256 256 4 -2.998046875 0.003921628 0.003921628 -1 )
   ( -192 256 272 4 -2.998046875 0.003921628 0.003921628 1 )
   ( -192 -128 272 -2 -2.998046875 0.003921628 0.003921628 1 )
   ( 192 -128 272 -2 3 0.003921628 0.003921628 1 )
   ( 192 256 272 4 3 0.003921628 0.003921628 1 )
   ( -192 256 256 -4 -4 -1 0.003921628 0.003921628 )
   ( -192 -128 256 1.9990234375 -4 -1 0.003921628 0.003921628 )
   ( -192 -128 272 1.9990234375 -4.25 -1 0.003921628 0.003921628 )
   ( -192 256 272 -4 -4.25 -1 0.003921628 0.003921628 )
   ( -192 -128 256 -3 -4 0.003921628 -1 0.003921628 )
   ( 192 -128 256 3 -4 0.003921628 -1 0.003921628 )
   ( 192 -128 272 3 -4.25 0.003921628 -1 0.003921628 )
   ( -192 -128 272 -3 -4.25 0.003921628 -1 0.003921628 )
   ( 192 -128 256 -2 -4 1 0.003921628 0.003921628 )
   ( 192 256 256 4 -4 1 0.003921628 0.003921628 )
   ( 192 256 272 4 -4.25 1 0.003921628 0.003921628 )
   ( 192 -128 272 -2 -4.25 1 0.003921628 0.003921628 )
   ( 192 256 256 -3 -4 0.003921628 1 0.003921628 )
   ( -192 256 256 2.998046875 -4 0.003921628 1 0.003921628 )
   ( -192 256 272 2.998046875 -4.25 0.003921628 1 0.003921628 )
   ( 192 256 272 -3 -4.25 0.003921628 1 0.003921628 )
  )
  (
   "textures/base_wall/lfwall27d" 4 = 3 2 1 0
   "textures/base_wall/lfwall27d" 4 = 7 6 5 4
   "textures/base_wall/lfwall27d" 4 = 11 10 9 8
   "textures/base_wall/lfwall27d" 4 = 15 14 13 12
   "textures/base_wall/lfwall27d" 4 = 19 18 17 16
   "textures/base_wall/lfwall27d" 4 = 23 22 21 20
  )
}
}

First you have a list of position x y z then texcoords and then the normal. Later you define the faces or polygons which can have more than 3 or 4 vertices.
So this is Blender N-Gon compatible.

BielBdeLuna

#28
that's great!

let me see:

QuotemeshDef are:

- a group of numbers that are unknown to me at the moment

- followed by the data per vertex

- followed by the data per face

in the following form:

meshDef
{
   ( num num num num num ) //5 numbers, what is this first row of numbers?
   (
       ( num num num num num num num num ) //8 numbers, posX, posY, posZ, posU, posV ,normalX, nomalY, normalZ
       * amount of vertices
   )
   (
       "idMat" 4 = num num num num // what is the "4"? and the next four numbers? are those the vertex index that conform the face? is the "4" indicating the number of vertices that will conform the face? so it could be a number ranging from 3 to infinite, so this number says how much vertices do follow after the "=" so "4 = vert1 vert2 vert3 vert4" is this true?
       * amount of faces
   )
}


is this correct?

trebor

meshDef
{
   ( numVertices numFaces placeholder placeholder placeholder )
   (
       ( posX, posY, posZ, posU, posV ,normalX, nomalY, normalZ )
       * amount of vertices
   )
   (
       "material" numVertexIndices = index0 index1 ...
       * amount of faces
   )
}