News | Forum | People | FAQ | Links | Search | Register | Log in
Coding Help
This is a counterpart to the "Mapping Help" thread. If you need help with QuakeC coding, or questions about how to do some engine modification, this is the place for you! We've got a few coders here on the forum and hopefully someone knows the answer.
First | Previous | Next | Last
FTEQCC 
There's a more recent version of FTEQCC at http://triptohell.info/moodles/fteqcc/ which has come up twice in the past month. It fixes at least one compilation bug I've encountered, so it's worth having for stability. 
FTE And Arrays 

void debugArrayPrint(float f)
{
bprint(ftos(f));
bprint("\n");
}


with this code:



bprint("debug test:\n");

float i = 0;

float array[5];
array[0] = -1;
array[1] = -2;
array[2] = -3;
array[3] = -4;
array[4] = -5;

float a[1];
a[0] = 1;
float b[2];
b[0] = 2;
b[1] = 3;

array = a;
for (i = 0; i < 1; i++)
debugArrayPrint(array[i]);

array = b;
for (i = 0; i < 2; i++)
debugArrayPrint(array[i]);


gives this output:

debug test:
1
2
-2


I would have expected:

debug test:
1
2
3


It seems like arrays are not handled the way they are in C and only copy the first element. Is it at all possible to pass them like pointers so that functions can freely take array pointers as arguments and return array pointers?

Like for example, if I wanted to create a vector system where we always push elements via a method (let's called it push_back), which would automatically copy the array to a larger one when space ran out. 
 
Arrays are not pointers. Pointers don't exist in QC.
Remember that each and every access is expanded into a function call with a binary search inside in order to read/write the correct global for that index.
Or in other words, no pointers.

array = a; does indeed read+store the first element. it should return a pointer, and refuse to assign to a pointer. but it doesn't. this is a known bug, but as its (normally) an error anyway, it hasn't been a high priority to get it to throw a hissy fit instead. :P
Trying to compile such a statement is also an error in C (lhs is a const pointer, and thus assigning to it is a syntax error).
If you really want to copy one array to another, embedding it within a struct and copying the struct should work (in recentish triptohell builds anyway). The catch is that you can't copy specific blocks.
If you're using opcode extensions (and fteqw), you can just memcpy data from one array to another, but if you're not then you'll need to write some sort of loop to do it instead (use preprocessor?). 
MDL Question 
I'm currently plodding along with my little Quake Web Tools thing, which is currently intended basically to allow you to view Quake file types by just dragging and dropping them onto a web page. Right now I am slowly working towards an MDL viewer, and have encountered an oddity - frame groups.

So, it appears that no models are actually using frame groups for anything, and that frames [i]could[/i] be grouped after extraction by simply processing them by name, since the frames are sorted by animation by name (e.g. walk1 - walk14 for the knight's walk cycle). I also seem to remember animations being defined explicitly in the Quake C somewhere.

So are frame groups used at all? What for? I need a model that has them that I can test with. 
ARGH! 
ok, so I just discovered that the torch model 'flame.mdl' uses frame groups and my code works. 
Btw, Current Progress Here: 
Currently there isn't much to show, but here it is for anyone interested:
http://pecope.co/experiments/quake_web_tools/QuakeWebTools.html

You can drag various Quake file types onto the drop zone at the top and get some kind of file preview, although currently the previews are very limited.
PAK: full file list and allows you to extract the files by clicking on the filename.
WAD: displays all textures in the wad
LMP: displays the image
BSP: displays the texture lump only. Basically the same as wad
MDL: displays skins only
PAL: displays the palette (treats it as a special case LMP)
SPR: does nothing currently, though there is some stub code, so you don't get an error.

My current plan is to make all of the main file types properly preview-able in a modern web browser on any platform said browser runs. This means that it should work fine in Chrome on MacOSX, Windows and Linux. Firefox worked last time I checked, and Opera should too. No idea about Safari and IE, but supporting different browsers is not a priority as long as it works on the good ones: Firefox and Chrome.

Once previewing files works properly (and perhaps before BSP preview works... I dunno) I'd like to start making a sort of browser based TexMex, although this is something that would likely be a lot of work - even if it only supports Quake 1 format WAD. Eventually editing other formats would be nice, but it's so much work to do things like an editor, and who knows, maybe someone will port TrenchBroom to asm.js :)
http://en.wikipedia.org/wiki/Asm.js

I wonder how WebQuake was made... 
 
The MDL format is SO much fun ... that's probably the most bizarre code I've ever written in relation to Quake. At every turn, there's something weird happening. And that's just reading. I never got around to writing it.

There were moments that felt like staring into the abyss... 
Than: 
Willem: 
Spike: 
Thanks for clearing that up. I knew that the arrays were a sort of hack but wasn't sure what the limitations were with them. Still, better than nothing!

Trying to compile such a statement is also an error in C (lhs is a const pointer, and thus assigning to it is a syntax error).
Yeah, the example had the array size declared because fteqcc wouldn't accept entity[]! That should have clued me in! 
 
necros

I don't doubt that it's possible, I just said I never got around to attempting to write it. :)

I had grand plans at one point to expand ToeTag into an entire Quake editing suite ... it was going to be amazing. And then one day I looked up from the keyboard and saw the mountain of code still ahead of me that needed writing and something broke inside of me.

Still ... it was going to be great. 
Yeah, 
i know what you mean.
I still want to make a model editor that'll let you do modern uv mapping like you can do in 3ds max or maya but both the crap code i wrote so far and the huge amount still left to be written puts me off, just not enough time. :( 
MDL 
Well, I'm not planning on doing any MDL writing for the moment, although I might look into making a tool to update the skin lumps, since that's easy. Aside from the UV format being horrible, the vertices are packed into chars, so making a tool that allows you to alter a model with minimal loss of precision seems like it wouldn't be much fun.

As I mentioned, the only thing I'm thinking about seriously for now is a viewer and WAD file editor. Oh, and probably something that allows you to create and edit PAK files, since my current code merely allows you to extract the files from inside. At least PAK is a sane format... thank god JC never implemented compression :)

A MAP editor would be fucking awesome, but that's by far the most complicated thing, so I doubt I'll ever get that far. A port of Trenchbroom using asm.js might be feasible though, but it would require also porting wxWidgets, which I could barely even get to compile normally, let alone with asm.js.

Btw, for anyone who thinks web apps are shit (yeah, most of them are I guess), the tech does seem to have gotten a LOT better in the last couple of years thanks to HTML5 and an explosion of libraries to iron over browser incompatibilities and lack of support for various standard features. There's an entire modelling package here: http://clara.io/ Compared to that I guess a basic Quake editor would be quite easy. 
Necros 
I'll look into it. Currently there is basically no error checking, and only bsp 29 is supported, so there are bound to be lots of places where shit goes wrong :) 
Necros 
I examined the texture info lump that I had extracted and found that entry at index 176 was garbage. No idea what caused this; The textures before and after are all fine, so it doesn't seem to be some kind of problem with my reader, but I'll have another look. I can probably get past the error if I just ignore entries with an empty name, so I'll try that for now.

Can texmex open the file? How many textures does it contain? I get 263.

My tools don't care about limits, so maybe there is a problem with this going over the 256 texture standard limit causing an error I haven't handled? Then again, the textures are simply read from the offsets defined in the file, and 176 seems to be the only one that has read as garbage.

Any help you can offer on this would be appreciated. 
FYI 
I fixed the bug by ignoring entries with no name. This is the data I extracted from the file regarding the garbage entry:

compression: 0
dsize: 21656952111104
name: ""
offset: 5770699
size: 21656952111104
type: 68

Clearly the size and filename are wrong. The offset seems OK, and the type and compression are both the same as the other entries in the file, so it looks like it's just a corrupted entry. 
To Keep This Monologue Going 
If anyone has any experience loading models in three.js, please let me know. I am having a lot of trouble formatting MDL data in the format required by three.js because the documentation is very poor. Thank god for Chrome's awesome debugger. 
 
God Damn 
I didn't even bother to search because I just assumed nobody would have bothered. Anyway, that should make things easier :) 
Oh... 
they are c programs. Kinda defeats the point :/

Source might have some insights though. Thanks! 
Wow 
Seems he already did all of it. It's also pretty fast. Weird thing is that it only lets me play the sounds even though the messages in the log show that it's also parsing the other files.

Now I feel I've just totally been wasting my time and that I should kill myself. 
Btw... 
Do you know if there is a version online somewhere that can preview the other types (I can only get it to preview sounds if I run it locally - even with a webserver behind it) 
Ah... 
I looked at the code and he's just parsing the BSPS but not showing them in a viewer. Also, it's from two years ago, so I guess he got bored. Still pretty neat though, and I can steal his wav preview code for my own nefarious ends >:D

Thanks for the links, and sorry to spam the thread with another thanalogue. 
Thanalogue Pt.6 
Well, after basically an entire day spent trying to get MDLs to render using three.js, I have finally got... non-textured pink and white MDL reviews. The texture is previewed below the window.

I will get this working one day, but probably not today. I'm so fucking pissed off with three.js's BufferGeometry class and lack of good documentation that I am going to give it a break for a day or two and perhaps work on .spr instead.

I also fixed that bug that Necros found.

http://pecope.co/experiments/quake_web_tools/QuakeWebTools.html 
Than: 
i see 261 textures in texmex O_O 
First | Previous | Next | Last
You must be logged in to post in this thread.
Website copyright © 2002-2024 John Fitzgibbons. All posts are copyright their respective authors.