Quake3World.com Forums
     Programming Discussion
        R_AddEntitySurfaces


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: R_AddEntitySurfaces

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 06-13-2013 01:58 AM           Profile Send private message  E-mail  Edit post Reply with quote


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:
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 ?



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 06-15-2013 09:37 AM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 06-16-2013 12:19 AM           Profile Send private message  E-mail  Edit post Reply with quote


Thanks ! I'll investigate that ! :D



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 06-27-2013 03:39 AM           Profile Send private message  E-mail  Edit post Reply with quote


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:
   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 ! ;)



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 06-28-2013 12:23 AM           Profile Send private message  E-mail  Edit post Reply with quote


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:
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 ?



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 41636
PostPosted: 06-28-2013 12:36 AM           Profile   Send private message  E-mail  Edit post Reply with quote


I always used Com_Printf() in the cgame module.




Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 06-28-2013 01:39 PM           Profile Send private message  E-mail  Edit post Reply with quote


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:
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 :)



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 06-28-2013 11:55 PM           Profile Send private message  E-mail  Edit post Reply with quote


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:



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 41636
PostPosted: 06-29-2013 12:31 PM           Profile   Send private message  E-mail  Edit post Reply with quote


You should put your pk3 in a separate folder next to baseq3 and run it as mod.




Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 06-29-2013 02:21 PM           Profile Send private message  E-mail  Edit post Reply with quote


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 :)



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 41636
PostPosted: 06-29-2013 09:43 PM           Profile   Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Commander
Commander
Joined: 22 Jul 2011
Posts: 139
PostPosted: 06-30-2013 11:55 AM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Recruit
Recruit
Joined: 16 Sep 2016
Posts: 9
PostPosted: 04-01-2017 09:33 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Veteran
Veteran
Joined: 17 May 2011
Posts: 159
PostPosted: 08-08-2017 12:31 PM           Profile Send private message  E-mail  Edit post Reply with quote


Nice !



_________________
My blog - My portfolio
---------------------
MJDM2 - DmeatSP01 - DmeatSP02


Top
                 

The Afflicted
The Afflicted
Joined: 21 Apr 2005
Posts: 502
PostPosted: 09-19-2017 07:55 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 
Quake3World.com | Forum Index | Programming Discussion


Post new topic Reply to topic


cron
Quake3World.com
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group