R_AddEntitySurfaces

Locked
D-Meat
Posts: 159
Joined: Tue May 17, 2011 8:52 am

R_AddEntitySurfaces

Post by D-Meat »

Hello !

I'm currently trying to do something that might sound strange to people who are common with the modding of Q3A : Rendering entities in a different place than they are "really" ... If this is not clear, please take a look at my other topic that talks about the main project : http://quake3world.com/forum/viewtopic.php?f=16&t=48898

I could do that by duplicating the actual entities, but that would be a waste of space in the entity list since I only need the "visual" information of the entities (position, orientation, ...).

So, I read a lot of code and I think I found the place I wanted to add things in. That's inside the R_AddEntitySurfaces function (tr_main.c, line 1258). In that function, all the game entities are passed in a loop in which their render type (model, sprite, beam, ...) points the out to a specific "addSurface" function (example : "R_addMD3Surfaces( ent )").

Here's what I did : Inside that function, there is a "temp" intity called "ent", that hosts the entity from which the visual infos are used to add the surfaces to render. So, I created another "slot" ( "ent2" ) that also copies the entity, and that modifies the position :

Code: Select all

R_AddMD3Surfaces( ent );

ent2 = ent;
ent2->e.origin[0] += 128;
R_AddMD3Surfaces( ent2 );
The result that would be expected is that a "copy" of every md3 model in the scene would appear 128 units next to the original. Here's the result :
Image

As you can see, the player model seems to be 128 units from it's origin point (which can be seen from the shadow), But there is only one rendered model ! That's the problem n°1.
(Actually, this might be a pointer problem : the original "ent" is actually a pointer and not an independent copy of the concerned entity. And my ent2 was also a pointer, so modifying the position of the same, original entity ... I have to try actually creating an empty instance of an entity, not a pointer. I hope this is possible.).

The problem n°2 is that my modification applies to ALL the md3 objects, as you can see on the interface, the ammo and player head are distant. How can I limit my system on only the "scene" entities ?
[url=http://www.dmitri-engman.fr/]My blog[/url] - [url=http://dmeat.free.fr/book/]My portfolio[/url]
---------------------
[url=http://lvlworld.com/#c=m1&i=1908&d=12%20Dec%202012&m=All&p=review]MJDM2[/url] - [url=http://lvlworld.com/#c=m1&i=2108&d=12%20Dec%202012&m=All&p=review]DmeatSP01[/url] - [url=http://lvlworld.com/#c=m1&i=2132&d=12%20Dec%202012&m=All&p=review]DmeatSP02[/url]
UglyFoot
Posts: 139
Joined: Fri Jul 22, 2011 12:35 pm

Re: R_AddEntitySurfaces

Post by UglyFoot »

You can add an entity calling RE_AddRefEntityToScene inside the renderer project.

But you can also add entities in cgame with trap_R_AddRefEntityToScene, which would be useful to only duplicate the entities you want. I think you should do it in CG_DrawActiveFrame.
D-Meat
Posts: 159
Joined: Tue May 17, 2011 8:52 am

Re: R_AddEntitySurfaces

Post by D-Meat »

Thanks ! I'll investigate that ! :D
[url=http://www.dmitri-engman.fr/]My blog[/url] - [url=http://dmeat.free.fr/book/]My portfolio[/url]
---------------------
[url=http://lvlworld.com/#c=m1&i=1908&d=12%20Dec%202012&m=All&p=review]MJDM2[/url] - [url=http://lvlworld.com/#c=m1&i=2108&d=12%20Dec%202012&m=All&p=review]DmeatSP01[/url] - [url=http://lvlworld.com/#c=m1&i=2132&d=12%20Dec%202012&m=All&p=review]DmeatSP02[/url]
D-Meat
Posts: 159
Joined: Tue May 17, 2011 8:52 am

Re: R_AddEntitySurfaces

Post by D-Meat »

Ok, I understand much more now, and I have a vague idea about how I'll do what I want to do :)

But I have a problem : it seems I can't use CG_Printf in the CG folder files ! and that's quite strange, take a look at that small extract from cg_view.c, at the end of CG_DrawActiveFrame :

Code: Select all

	if ( cg_stats.integer ) {
		CG_Printf( "cg.clientFrame:%i\n", cg.clientFrame );
	}
	CG_Printf( "Dmeat testing\n" );
I added the last line. In game, when I activate the cvar cg_stats 1, the text is actually added to the console, but my "Dmeat Testing" is not ! How do you explain that ?

I'm sorry this might sound basic ... But well, it's difficult to code whithout feedback ! ;)
[url=http://www.dmitri-engman.fr/]My blog[/url] - [url=http://dmeat.free.fr/book/]My portfolio[/url]
---------------------
[url=http://lvlworld.com/#c=m1&i=1908&d=12%20Dec%202012&m=All&p=review]MJDM2[/url] - [url=http://lvlworld.com/#c=m1&i=2108&d=12%20Dec%202012&m=All&p=review]DmeatSP01[/url] - [url=http://lvlworld.com/#c=m1&i=2132&d=12%20Dec%202012&m=All&p=review]DmeatSP02[/url]
D-Meat
Posts: 159
Joined: Tue May 17, 2011 8:52 am

Re: R_AddEntitySurfaces

Post by D-Meat »

I think I might have an idea of what's going on. First, one question : are the cgame files always used in the virtual machine ?

Because since my 6dof Project, I have a compilation error, which didn't cause any sort of visible problem in the strict client side and in the renderer project. Here's what thecompiler says :

Code: Select all

CGAME_Q3LCC code/cgame/cg_view.c
Q3ASM build/release-mingw32-x86/baseq3/vm/cgame.qvm
build/release-mingw32-x86/baseq3/qcommon/q_math.asm:7050 error: symbol asin undefined
make[2]: *** [build/release-mingw32-x86/baseq3/vm/cgame.qvm] Error 1
make[2]: Leaving directory `/m/_boulot/prog/ioq3'
make[1]: *** [targets] Error 2
make[1]: Leaving directory `/m/_boulot/prog/ioq3'
make: *** [release] Error 2
the math asin function is used in on the client side for some euler <-> quaternion conversions. It seems it doesn't exist in the Virtual machine ! Do you think it would be easy to add ?
[url=http://www.dmitri-engman.fr/]My blog[/url] - [url=http://dmeat.free.fr/book/]My portfolio[/url]
---------------------
[url=http://lvlworld.com/#c=m1&i=1908&d=12%20Dec%202012&m=All&p=review]MJDM2[/url] - [url=http://lvlworld.com/#c=m1&i=2108&d=12%20Dec%202012&m=All&p=review]DmeatSP01[/url] - [url=http://lvlworld.com/#c=m1&i=2132&d=12%20Dec%202012&m=All&p=review]DmeatSP02[/url]
User avatar
Eraser
Posts: 19174
Joined: Fri Dec 01, 2000 8:00 am

Re: R_AddEntitySurfaces

Post by Eraser »

I always used Com_Printf() in the cgame module.
D-Meat
Posts: 159
Joined: Tue May 17, 2011 8:52 am

Re: R_AddEntitySurfaces

Post by D-Meat »

Ok, I think what I pointed out previously is actually true : the compilation actually stops at the virtual machine stage because of the asin function.

(sorry, this topic is stepping aside from the original theme)

A friend gave ma a solution, using the "acos" function, and since the "acos" function is declared in game/bg_lib.c along with "atan2" and other math things, this should do the trick. Except it doesn't !

Code: Select all

Q3ASM build/release-mingw32-x86/baseq3/vm/qagame.qvm
build/release-mingw32-x86/baseq3/qcommon/q_math.asm:7050 error: symbol acos undefined
The message is the same when I use "Q_acos" !

Now that I found this out, I guess I just need to declare "more" that Acos function I need ...
Now, if someone played with this and happens to read this, I'm always eager to save some time and neurones :)
[url=http://www.dmitri-engman.fr/]My blog[/url] - [url=http://dmeat.free.fr/book/]My portfolio[/url]
---------------------
[url=http://lvlworld.com/#c=m1&i=1908&d=12%20Dec%202012&m=All&p=review]MJDM2[/url] - [url=http://lvlworld.com/#c=m1&i=2108&d=12%20Dec%202012&m=All&p=review]DmeatSP01[/url] - [url=http://lvlworld.com/#c=m1&i=2132&d=12%20Dec%202012&m=All&p=review]DmeatSP02[/url]
D-Meat
Posts: 159
Joined: Tue May 17, 2011 8:52 am

Re: R_AddEntitySurfaces

Post by D-Meat »

OK, now I can chill out a little bit : ioQ3 was reading the .vm files from the old pk3 instead of the newly compiled ones. So, Com_Printf and CG_Printf seem to be working !
Just a question : is it possible to force the game to look for the .vm files always in the baseq3 vm folder ? At the moment, I have to manually update a "pak9.pk3" each time I do a change ...

I can now go back to the real stuff :smirk:
[url=http://www.dmitri-engman.fr/]My blog[/url] - [url=http://dmeat.free.fr/book/]My portfolio[/url]
---------------------
[url=http://lvlworld.com/#c=m1&i=1908&d=12%20Dec%202012&m=All&p=review]MJDM2[/url] - [url=http://lvlworld.com/#c=m1&i=2108&d=12%20Dec%202012&m=All&p=review]DmeatSP01[/url] - [url=http://lvlworld.com/#c=m1&i=2132&d=12%20Dec%202012&m=All&p=review]DmeatSP02[/url]
User avatar
Eraser
Posts: 19174
Joined: Fri Dec 01, 2000 8:00 am

Re: R_AddEntitySurfaces

Post by Eraser »

You should put your pk3 in a separate folder next to baseq3 and run it as mod.
D-Meat
Posts: 159
Joined: Tue May 17, 2011 8:52 am

Re: R_AddEntitySurfaces

Post by D-Meat »

With my current workflow, this still means that I have to move files after I compile. And I have to study what are the prerequisites to make a working mod :)

And my objective is in fine to learn how to have a standalone game using the engine :)

Thanks anyway ! I'm currently making good progress :)
[url=http://www.dmitri-engman.fr/]My blog[/url] - [url=http://dmeat.free.fr/book/]My portfolio[/url]
---------------------
[url=http://lvlworld.com/#c=m1&i=1908&d=12%20Dec%202012&m=All&p=review]MJDM2[/url] - [url=http://lvlworld.com/#c=m1&i=2108&d=12%20Dec%202012&m=All&p=review]DmeatSP01[/url] - [url=http://lvlworld.com/#c=m1&i=2132&d=12%20Dec%202012&m=All&p=review]DmeatSP02[/url]
User avatar
Eraser
Posts: 19174
Joined: Fri Dec 01, 2000 8:00 am

Re: R_AddEntitySurfaces

Post by Eraser »

It's not hard. Just dump the qvm files in a "vm" subfolder in a folder, for example "dmeat". Then start quake3 with
quake3.exe +set fs_game dmeat

You can edit the batchfiles for compiling qvm's to erite to another output folder.
UglyFoot
Posts: 139
Joined: Fri Jul 22, 2011 12:35 pm

Re: R_AddEntitySurfaces

Post by UglyFoot »

I don't have the ioq3 source but in the vq3 source there's a batch file called "installvms" which just moves the .qvm files to the mod folder, you don't need to put them in a .pk3.
tw1sted1
Posts: 9
Joined: Sat Sep 17, 2016 5:27 am

Re: R_AddEntitySurfaces

Post by tw1sted1 »

I found a work-around for the acos problem. I thought I'd toss it out there just in case someone hadn't actually found a solution...
After much experimentation, I decided to try just copying
the create acos table from bg_lib.c and put it in the qcommon
q_math.c right after the Q_crandom...
That did it, the compiler liked it, everything compiled nicely.
D-Meat
Posts: 159
Joined: Tue May 17, 2011 8:52 am

Re: R_AddEntitySurfaces

Post by D-Meat »

Nice !
[url=http://www.dmitri-engman.fr/]My blog[/url] - [url=http://dmeat.free.fr/book/]My portfolio[/url]
---------------------
[url=http://lvlworld.com/#c=m1&i=1908&d=12%20Dec%202012&m=All&p=review]MJDM2[/url] - [url=http://lvlworld.com/#c=m1&i=2108&d=12%20Dec%202012&m=All&p=review]DmeatSP01[/url] - [url=http://lvlworld.com/#c=m1&i=2132&d=12%20Dec%202012&m=All&p=review]DmeatSP02[/url]
Ganemi
Posts: 564
Joined: Thu Apr 21, 2005 12:57 pm

Re: R_AddEntitySurfaces

Post by Ganemi »

You shouldn't have to mess with the underlying engine code, only the mod code.

Bazooka Quake 3 had a "displacement" powerup that would place your player 20 feet away so that you could confuse enemies, and that was before the release of the source.
Locked