it took us a long time to get mv working. a lot of things are broke in the mv code and most of them are not easy to fix. rain pretty much had to rewrite the keycatcher code from scratch for example. not a simple task even for those experienced in q3 modding.
Ok, the problem I’ve got is with CG_AddPacketEntities.
This function is called by CG_DrawActiveFrame in order to render the main view. It is also used in Multiview and I need it to work to get my camera mod working properly. It displays entities such as tanks, MG42s etc.
The problem is, when I call this function to build a fresh render list AFTER the main view is constructed, it doesn’t work. It only works if I comment out the initial CG_AddPacketEntities call, but doing this of course results in no entities being displayed in the main view.
Somewhere along the line the cent->currentState.eType is being modified to ET_EVENTS. So the second time the function is called, no entities are found. I’ve spent over a week trying to fix this, and I can’t think of an easy answer. In fact, I can’t think of any answer :banghead:
My code is based on Fretn’s grenade cam code. The CG_AddPacketEntities function is where I believe the problem lies. The CG_DrawCamView function is called by CG_DrawActive. The main view is rendered, followed by the cam view.
As I said previously, the camera window opens up and displays the correct camera view and all the map details. But all the entities, such as tanks, mg42’s, constructibles etc. are not displayed.
I can get the entities displayed in the camera window if I comment out CG_AddPacketEntities for the main view. But this is not a solution. I need the entities displayed in both windows.
I’ve debugged it to a point where I strongly suspect the problem is that the entity states are being changed to ET_EVENTS after the first view is rendered.
Therefore the CG_AddPacketEntities function does not find any entities to render a second time.
But I’ve no idea where or why this is happening, let alone how to fix it. This is why I asked about the multiview code, because Bani & co successfully managed to display a second window, presumably with entities.
there are people who don’t know howto compile with certain compiler flags (yes I received emails about this in the past) , this might have been the case here based on the fact you said cg_multiview.c wasn’t called from somewhere
oh some other unsensible things:
afaik the limbo menu camera is the cg.showgameview case
you can define the size of the rendered window with
but if you want it to be bigger AND visible you’ll have to change the size of the other limbo stuff that’s drawn around it
btw: are you sure the 2nd cam is in your pvs, I guess this will not be the problem, but you’ll never know…
I tried the rtcw code in ET and indeed no entities show up, what I can advise is to take a look at CG_mvDraw in cg_multiview.c this might clear up some things
Sorry Fretn, I thought u were being sarcastic before. Clearly you do have a lot of sensible things to say.
As it happens I don’t know how to compile with certain compiler flags - if you could tell me how it would be appreciated.
As far as I can tell, the limbo camera menu uses the same code as the main view, it just changes the size to letterbox. That isn’t really useful to me.
The 2nd cam is indeed in my pvs, the camera is more or less right in front of my player and the entities are still invisible in the cam view window. I doubt this is the problem.
I’ll check out cg_multiview.c but I had a look at it before and nothing obvious is different. The trouble is I could spend ages getting multiview to work and still not find an answer to this.
Firstly, take a look at how CG_mvDraw sets things up before rendering the scene—it does a few things you don’t.
Firstly, it uses a second refdef to do all of the actual drawing (where you just use a second refdef to back up the original.) This is a bit more complex, but it’s a nicer way to handle things, and it’s likely faster than copying the original refdef twice. To make things actually use that second refdef, change the cg.refdef_current pointer to your refdef, as CG_mvDraw does:
cg.refdef_current = &refdef;
The downside of this is that you have to set up some things on your own (mostly, setting up the vieworg and viewax, the fov, calling CG_SetupFrustum(), etc.), but you may end up wanting to do that for your project down the road anyway.
Aside from that, though, things like mostly okay. There are a few things that won’t be drawn with what you have there, though… You’ll probably want to add CG_AddSmokeSprites(), CG_AddAtmosphericEffects(), CG_AddFlameChunks(), CG_AddTrails(), CG_PB_RenderPolyBuffers(), and CG_DrawMiscGameModels(). The last one is, somewhat obviously, responsible for misc_gamemodels (which would explain some of the missing entities.) The only other thing I see being done is a trap_SetClientLerpOrigin() just before the trap_R_RenderScene(), although I don’t suspect that’s your problem.
This doesn’t really make sense… Assuming you’re talking about currentState.eType becoming ET_EVENTS, this shouldn’t really happen—ever. ET_EVENTS is a special case for temporary entities (created with G_TempEntity()); these entities only exist for about 6 server frames (300ms) and have their eType set to ET_EVENTS + EV_<something>. To actually get ET_EVENTS, the event type would need to be 0 (EV_NONE), which shouldn’t ever be created as a temporary entity.
HTH.
Hopefully I didn’t make any mistakes, since whenever I hit Preview, I get dumped to the front page of splashdamage.com.
:bash: :bash: :bash: :banghead:
I can get entities displayed in the cam window simply by commenting out
CG_AddPacketEntities();
in CG_DrawActiveFrame. No other changes are required to make it work. This means that my cam code is working properly.
Something is screwing up after the first CG_AddPacketEntities function is called. The currentstate.eType IS becoming >=ETEVENTS, because I debugged it and found that the functions that add the entities to the scene, such as CG_Mover, CG_Player etc. are never called.
Now let’s stop wasting time and figure out what’s causing this. Fretn found the same problem when he tried the code in Enemy Territory, yet the same code apparently works in RTCW. So what’s changed?
By the way Rain, I tried what you said, just in case you were right, and used most of the code from cg_multiview.c, and I still get the same problem.
I did, but I ignored it for the sake of argument (to help suggest some other possibilities, and because there’s still a lot of information that nobody besides yourself has.) I eventually forgot about it entirely, though, so one or two of the suggestions don’t apply at all to your situation.
This sounds like you’re saying “The sky is orange because, during experimentation, I never discovered it to be another color.â€? Assuming that the eType isn’t changing (if it is changing outside of the snapshot code, you’ve probably got bigger problems), I hunted around a little more and believe I found your culprit: there’s a special case in CG_AddCEntity_Filter (which is called from CG_AddPacketEntities()) to allow entities to be added more than once when more than 1 client is active in multiview: