Forum

[FTEQW][WIP] craFTEr - realtime game editor for FTE

The home for dedicated threads to specific projects, be they mods, tools, or independent games.

Moderator: InsideQC Admins

Re: [FTEQW][WIP] Crafter - realtime game editor for FTE

Postby toneddu2000 » Sat Jan 07, 2017 9:03 pm

Spike wrote:regarding pointers the easiest way to deal with them is to just define some global arrays and pass those into the brush builtins as needed. then you can just index the arrays without resorting to allocating/freeing/etc pointers.
Tried,
First created an array of 6 brushface_t structs
Code: Select all
brushface_t brushFace[6];

Then initialized one by one (values are completely invented because I don't know every value what stands for)
Code: Select all
   brushFace[0].shadername = "textures/scifi/barrel1";
   brushFace[0].planenormal = [-32,-32,-32];
   brushFace[0].planedist = 32;
   brushFace[0].sdir = [8,8,8];
   brushFace[0].sbias = 8;
   brushFace[0].tdir = [1,1,1];
   brushFace[0].tbias = 8;

Then created a for loop to create 6 brush faces
Code: Select all
   for(i= 0;i<6;i++){
      //int(float modelidx, brushface_t *in_faces, int numfaces, int contents) brush_create
      brush_create(0,brushFace[0],6,1);
   }

but throws this error
Code: Select all
Cannot cast from brushface_t to brushface_t *
toneddu2000
 
Posts: 1314
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: [FTEQW][WIP] Crafter - realtime game editor for FTE

Postby Spike » Sun Jan 08, 2017 3:57 am

brush_create(world.modelindex, brushFace, brushFace.length, CONTENTBIT_SOLID);
(note that brushFace.length == 6, it just looks a little cleaner to avoid magic numbers. however, chances are that you'll need more faces per brush at some point, this argument should of course be the number of valid faces)

plane normals MUST be normalised. no exceptions.
the normal says the direction the plane is facing, the distance says how far along the plane is along that normal from the origin.
That is, the point at (planedist*planenormal) sits on the plane. Alternatively, planedist=dot(pointonplane,planenormal);

(note that dot(x,y) === x*y in qc, but I'm using function notation because x*y is somewhat weird when you have floats in one place and vectors in another)

so if you want an axial cube centered on the origin, use normals of +x, +y, +z, -x, -y, -z (and by +x I mean '1 0 0'), and some distance that says the 'radius' of the box. to then move it by some vector, planedist += dot(translation,planenormal); should be applied to each of the 6 planes (this logic works regardless of any rotation you have applied. note that using makevectors and negating the results for the other 3 planes should be enough to create a rotated cube centered around the origin).
note that the translation thing can be applied to a single plane, which gives you the translation of a single plane / surface. and by translation, I of course mean 'move' (or the vector/displacement for that movement).

the sdir/sbias and tdir/tbias fields are essentially the same as the plane planenormal/planedist, except that they apply to the texture coords instead. the dir vectors do not need to be normalised, which allows for rescaling the texture. they should normally be tangenital to the normal and each other - that is that the 3 normals each face 90 degrees from each other in order to avoid skewing.
by changing the bias values the same way when translating, you will obtain texture lock.

note that out_x = dot(v_forward,in); out_y = -dot(v_right,in); out_z = dot(v_up,in); can be used to rotate a plane normal (first call makevectors with the rotation difference as an argument - note targ-src angle, which is sucky to calculate with eular angles so try to avoid absolute angle values). adjusting the distance is more tricky, effectively you need to translate the rotation pivot to '0 0 0', rotate it, then move it back.

is it a bird? is it a plane? no, its a friggin maths equation. gah.
with the right helper functions, you should find it managable enough.
Spike
 
Posts: 2883
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: [FTEQW][WIP] Crafter - realtime game editor for FTE

Postby toneddu2000 » Sun Jan 08, 2017 4:40 pm

Thanks Spike, your help is always very precious. Right now I can't understand how to create the origin between two brush faces but I'll make some tests and I'll post them here (or releasing directly crafter release with brush support inside, but more probable that I'll make only some tests). Right now scene is empty but let's see what I can do with a couple of day of 3d math full immersion! :lol:
toneddu2000
 
Posts: 1314
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: [FTEQW][WIP] Crafter - realtime game editor for FTE

Postby Julius » Wed Jan 18, 2017 8:02 am

Some random ideas:
- A vegetation model placement brush on terrain would be cool
- A sort of random dungeon generator, or at least a quick placement option of walls, corners etc. would be nice.

Anyways, really looking forward to the progress you make.
Julius
 
Posts: 92
Joined: Sun Aug 29, 2010 4:32 pm

Re: [FTEQW][WIP] Crafter - realtime game editor for FTE

Postby toneddu2000 » Wed Jan 18, 2017 10:13 pm

- vegetation "brush" system is on the todo list
- random dungeon generation: no, I don't think of any good reason to put it into an editor. Usually it would be more useful as script imo, to be used dynamically in code
toneddu2000
 
Posts: 1314
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: [FTEQW][WIP] Crafter - realtime game editor for FTE

Postby toneddu2000 » Tue Mar 07, 2017 7:03 pm

Ehm, Spike, could you please post a simple code that creates a cube via brush_create? I tried and tried but no clues about orienting faces and set distance between them.
toneddu2000
 
Posts: 1314
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: [FTEQW][WIP] Crafter - realtime game editor for FTE

Postby Spike » Tue Mar 07, 2017 9:08 pm

Code: Select all
//generates default quakeed-style texture mapping for the given surface.
//this sucks for cylinders, but keeps slopes and things easy.
void(brushface_t *fa) reset_texturecoords =
{
   //figure out some default texture coords   
   fa->sdir = '0 0 0';
   fa->sbias = 0;
   fa->tdir = '0 0 0';
   fa->tbias = 0;
   float a=fabs(fa->planenormal[0]),b=fabs(fa->planenormal[1]),c=fabs(fa->planenormal[2]);
   if (a>=b&&a>=c)
      fa->sdir[1] = 1;
   else
      fa->sdir[0] = 1;
   if (c>a&&c>b)
      fa->tdir[1] = -1;
   else
      fa->tdir[2] = -1;
};

void(string texture_to_use, vector midpoint, float radius) SomeCrappyExample =
{
   static brushface_t tmp_faces[6]; //MUST be static or global. the qcvm does not support taking the address of a regular local, not fully anyway.

   //define the 6 planes
   //a plane is defined as an infinitely large flat surface moved X units away from the origin along its normal (hence the negative axis get a negated midpoint. They're all then equally pushed out by the 'radius' value, hence why that is NOT negated.
   //moving eg a floor plane (ie: '0 0 1') along the x+y axis does not change its position along its normal (the z axis), so the dist wouldn't change in that case. to move a plane (or entire brush) by some model-space displacement, dist += displacement*planenormal; (the same goes for the st texturing planes, though they're not normalised and they might be negated... same principal applies)
   tmp_faces[0].planenormal = '1 0 0';
   tmp_faces[1].planenormal = '-1 0 0';
   tmp_faces[2].planenormal = '0 1 0';
   tmp_faces[3].planenormal = '0 -1 0';
   tmp_faces[4].planenormal = '0 0 1';
   tmp_faces[5].planenormal = '0 0 -1';
   int tmp_numfaces = 6i;
   int tmp_contents = CONTENTBIT_SOLID;

   for (int facenum = 0i; facenum < tmp_numfaces; facenum++)
   {
      //position the plane through the given midpoint, and push it out by the radius along its normal.
      tmp_faces[facenum].planedist = (tmp_faces[facenum].planenormal * midpoint) + radius;

      //do something with the textures
      tmp_faces[facenum].shadername = texture_to_use;
      reset_texturecoords(&tmp_faces[facenum]);
   }

   //give the brush to the engine
   brush_create(world.modelindex, &tmp_faces[0], tmp_numfaces, tmp_contents);
};
Spike
 
Posts: 2883
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: [FTEQW][WIP] Crafter - realtime game editor for FTE

Postby toneddu2000 » Tue Mar 07, 2017 9:37 pm

woo! Thanks A LOT man! :biggrin:
It works great!
Code: Select all
brush_create(world.modelindex, &tmp_faces[0], tmp_numfaces, tmp_contents);

So brush_create needs first face (&tmp_faces[0]) to create the brush?
Code: Select all
int tmp_numfaces = 6i;
What's the "i", a cast to int? But, isn't it already an int?
toneddu2000
 
Posts: 1314
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: [FTEQW][WIP] Crafter - realtime game editor for FTE

Postby Spike » Tue Mar 07, 2017 10:20 pm

it takes a pointer, eg either tmp_faces or &tmp_faces[0] (they're meant to be equivelent). I just thought I'd make it more clear that it was a pointer.

qc assumes all numbers are floats. so eg 6 is a float, that needs to be converted to an int if its stored into an int variable. this normally happens automatically of course (and for free if its an immediate), but there's a few ways that the variable is taken verbatim where automatic conversions cannot take place (like __variant function args), plus there's type promotions so eg 3i/2i is 1i, while 3/2i is 1.5, where its especially important is to use ints to avoid precision loss from bitwise operations on floats.
so it can be nice to be explicit about it, even if its not technically needed.
Last edited by Spike on Wed Mar 08, 2017 7:50 am, edited 1 time in total.
Spike
 
Posts: 2883
Joined: Fri Nov 05, 2004 3:12 am
Location: UK


Re: [FTEQW][WIP] Crafter - realtime game editor for FTE

Postby Julius » Sat Apr 01, 2017 3:58 pm

Any news on a possible alpha release of this?
Julius
 
Posts: 92
Joined: Sun Aug 29, 2010 4:32 pm

Re: [FTEQW][WIP] Crafter - realtime game editor for FTE

Postby toneddu2000 » Sat Apr 01, 2017 9:19 pm

Yeah, you're right Julius. I've been completely busy with work/study that I leave Crafter as a draft. I should have at least released a first stub with a handful of models...Let's see next week-end what I can do.

Keep in mind that it's junk. Don't think to thow NetRadiant or whatever to garbage and start using Crafter because it's not still usable and probably it will never be. I don't have the skills to create a level editor and probably quakec is not the best language to do it. But, but, if Spike should consider the idea valid and re-translate the code (with all the modifications he thinks it needs) to full C code, well.. then it could be interesting! :biggrin: I'm just toying with terrain and brush editing. Once drafted a little that could be the time for a first alpha or whatever

One thing is clear right now (and I say it without any kind of presumption): in 2017 there's no space anymore for x-radiant + qxmapwhatever stuff. With Unity and Ue4 being the perfect concept of "live level editor", Crafter *could* be the logical transposition to FTE universe.. with a lot of "if" as prefix.. :biggrin:
toneddu2000
 
Posts: 1314
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: [FTEQW][WIP] Crafter - realtime game editor for FTE

Postby Julius » Sun Apr 02, 2017 6:12 am

No worries, I am not expecting to toss out a full level editor for it (but I am hoping to replace Radiant with Trenchbroom soon).

I see it more as a start for something like Snap Map from the latest Doom release, i.e. something to play around assembling ready made parts. Optimizing realtime lights and bot nodes etc icould also be a cool use for it.

Anyways, looking forward to the alpha release!
Julius
 
Posts: 92
Joined: Sun Aug 29, 2010 4:32 pm

Re: [FTEQW][WIP] Crafter - realtime game editor for FTE

Postby toneddu2000 » Sun Apr 02, 2017 10:58 am

I see it more as a start for something like Snap Map from the latest Doom release, i.e. something to play around assembling ready made parts. Optimizing realtime lights and bot nodes etc icould also be a cool use for it.
Yeah, that could be an idea as projectUnknown (another hanging project...ugh..) mod tool
toneddu2000
 
Posts: 1314
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: [FTEQW][WIP] Crafter - realtime game editor for FTE

Postby Julius » Sun Apr 02, 2017 5:09 pm

Oh yeah, an alpha release from projectUnkown would be great of course too!
Julius
 
Posts: 92
Joined: Sun Aug 29, 2010 4:32 pm

PreviousNext

Return to Project Showcase

Who is online

Users browsing this forum: No registered users and 1 guest