News:

One Minute Game Review by The Happy Friar: https://ugetube.com/@OneMinteGameReviews
Also on Rumble: https://rumble.com/c/c-1115371

idTech 4 (aka Doom 3 tech) Discord Server! https://discord.gg/9wtCGHa

Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - argoon

#1
Hello guys, for a very long time now, i've been trying to create a simple quad programatically in the engine, but I just don't know how that is done! I've browsed the source code for answers, but the geometry code I see is just to complicated for my feeble mind. I see stuff about windings and vertices but nothing direct.   

I tried looking at the gameRenderWorld debug code but again it looks way low level for me. Would someone be so kind to explain with code how to create a simple static quad in the 3D world in idtech4?

I know how to import a quad/model but what I really want is to create a quad dynamically by c++/opengl code.

Any help appreciated cheers.

#2
After many hours of trying to prevent a sound from playing over itself, when pressing a key continuously and inside the player think loop, after going trough the engine code i found some ways to solve this.

One:


const idSoundShader *sound = declManager->FindSound( "sound_name" );
// this above is not really necessary you can do the following instead if you want.
//...StartSound( declManager->FindSound( "sound_name" ), SND_CHANNEL_BODY );

// get the sound emitter (speaker) binded to the ingame entity, btw i tried to get a emitter directly from the master entity but it didn't found any and crashed the engine, why i don't know,
// is strange because afaik all entities can be "speakers"...
idSoundEmitter *emit = gameLocal.FindEntity( "some_speaker" )->GetSoundEmitter( );
if (!( emit->CurrentlyPlaying( ) )) // if sound is not playing
{
        // play it
emit->StartSound( sound, SND_CHANNEL_BODY);
}


Two:


const idSoundShader *sound = declManager->FindSound( "sound_name" );
idSoundEmitter *emit = gameLocal.FindEntity( "some_speaker" )->GetSoundEmitter( );
emit->StartSound( sound, SND_CHANNEL_BODY, 0, SSF_PLAY_ONCE ); // SSF_PLAY_ONCE prevents the sound from playing again if it is already playing



Three:  If you don't create a emiter object like above and call the sound directly from a entity it also works. :)


const idSoundShader *sound = declManager->FindSound( "sound_name" );
Entity->StartSoundShader( sound, SND_CHANNEL_BODY, SSF_PLAY_ONCE, false, NULL );
#3
id Tech 4 Engine Coding / Getting var values from GUis?
September 28, 2017, 04:07:16 PM
Hello guys i know that i can set a variable value in a GUI from the engine code using for example somegui->SetStateInt("varName"); and it works fine, but i can't seem to do the inverse, get a value from a gui variable to the game code, i tried using the somegui->GetStateInt("varName"); but it returns zero every time, no matter to what value i set the GUI variable.

what i'm trying to do is create a grid based inventory system, and when i click in a "slot" i tell the c++ code what slot i interacted with.
#4
id Tech 4 Engine Coding / working with idStrg class
August 27, 2017, 04:32:26 PM
Hello guys and gals :)

I need help from some idtech 4 coder that has experience working with the idStrg class, it has many functions ( or members )  to mess around with, but because i don't know what half of them do i'm really going blind here, what i'm trying to do is take a file path, like a icon path, get a particular string from it (like a file name) compared that to some other string and if true or false run some code. Anyone here know anything about this? 
#5
id Tech 4 Discussion / why is this not news here!?
August 11, 2017, 03:57:43 PM
At lest i don't see any thread about it...  :P

Doom 3 BFG got a Vulkan render! written by a id Software coder, so in a sense a official render!

http://www.phoronix.com/scan.php?page=news_item&px=Vulkan-Doom3-Available

#6
id Tech 4 Discussion / Fantastic BFG VR mod!
July 30, 2017, 08:09:32 PM
Can someone explain to me how were they able to modify the BFG flash GUI's so deeply without the source files?

#7
Hello guys and gals,  i'm trying to call functions from the c++ code, like i used to do using DoomScript but obviously is different on the c++ side, studying the engine code i see id calls scripts like so:


const function_t *func;

func = Entity->scriptObject.GetFunction("somefuncname");
Thread->CallFunction(frobableEntity, func, true);


but this just crash's the engine for me and i'm totally clueless why.

Any help is welcome.


Edit: before posting this i spend more than a hour trying to make this work, after making this thread and going away to try to solve again i did it: :P  :D

This is the necessary code to successfully call object script functions from withing the c++ code:


const function_t *func;
idThread *Thread;

func = Entity->scriptObject.GetFunction("signalOn");
Thread = new idThread();
Thread->CallFunction(Entity, func, true);
Thread->Start();
#8
id Tech 4 Discussion / modwiki problems
April 07, 2017, 06:16:36 PM
Hello guys i'm getting a "your connection is not private - NET::ERR_CERT_AUTHORITY_INVALID" error when trying to read the idtech4 modwiki, i'm using Vivaldi (is based on chrome), i'm the only one with this error? 
#9
id Tech 4 Engine Coding / Nice PBR opengl tutorial
March 20, 2017, 09:07:16 PM
If some day someone wants to implement PBR in idtech 4 here is a tutorial that could help.

https://learnopengl.com/#!PBR/Theory
#10
id Tech 4 Scripting / LOD system
November 23, 2016, 10:08:21 PM
Hello guys i made a LOD system for my mod using script and it works, more or less, the lod change works the problem i'm getting is that when the model changes it shivers for a moment and is very obvious, do you guys have any idea on how to smooth that transition?

here is the script code


/***********************************************************************

lod_object_base.script

self script contains any LOD's specific code.

revision = 0.1

***********************************************************************/


#define LOD_LEVEL_0 1
#define LOD_LEVEL_1 2
#define LOD_LEVEL_2 3

object lod_object_base {
// bool to control the while loop
    boolean isON;

// lod0 position for the other lod's
vector currObjPos;

float currentLOD;

string lod0_model;
string lod1_model;
string lod2_model;


// player entity
entity lod_player;

// enable or disable the LOD check, no need to do it on objects with no lod's
float lod_enabled;

// show distances
float lod1_dis;
float lod2_dis;
// player distance from lod object
float pldistance;



void init();

void lodUpdate();
void checkLOD();

};


void lod_object_base::checkLOD() {

pldistance = self.distanceTo(lod_player); // check lod obj pos distance to player1 pos

if( pldistance < lod1_dis && currentLOD != LOD_LEVEL_0 ){
currentLOD = LOD_LEVEL_0;
self.setModel(lod0_model);
}
else if ( pldistance >= lod1_dis && pldistance < lod2_dis && currentLOD != LOD_LEVEL_1 ){
currentLOD = LOD_LEVEL_1;
self.setModel(lod1_model);
}
else if ( pldistance >= lod2_dis && currentLOD != LOD_LEVEL_2 ){
currentLOD = LOD_LEVEL_2;
self.setModel(lod2_model);
//self.setKey("noShadows", "1"); doesn't work at runtime :(
}
}

/*
============
lod_object_base::lodUpdate
============
*/
void lod_object_base::lodUpdate() {

lod_enabled = self.getIntKey("lod"); // get the spawn lod value

// if spawnarg lod is 0 disable the while loop
if(lod_enabled == 0){
isON = false;
}

// gets the lod0 world position
currObjPos = self.getWorldOrigin();

// not run this on the loop or it will not work.
currentLOD = LOD_LEVEL_2;

// get the models can be set on the editor if using the def key "editor_model"
lod0_model = self.getKey("model");
lod1_model = self.getKey("model_lod1");
lod2_model = self.getKey("model_lod2");
// then get lod distance values
lod1_dis = self.getIntKey("lod1_distance");
lod2_dis = self.getIntKey("lod2_distance");

// this gets the player entity
    lod_player = sys.getEntity("player1");


// runtime loop to check for the player position and set the lod objs
while ( isON ){ // while isON == true
if( lod_enabled ){ // if lod0 has the spawnarg lod_enabled with value 1 then run if not stop
checkLOD();
}
waitFrame();
}
}

/*
===============
initialisation
================
*/

void lod_object_base::init()
    {
waitFrame();
isON = true;
thread lodUpdate();
    }
#11
Hey guys does idtech 4 script has something like unity enum?

In unity you use - enum NAME { VALUE, VALUE_1, VALUE_2} almost like an array then you access that with - private var name : NAME= NAME.VALUE_2;

This in Unity script looks very similar to the idtech 4 script #define NAME VALUE  directive, i'm i right? If yes how could i implement that using #define?


edit - Was able to do the same using 3 different #defines but would still like to know if something like enum was possible. 
#12
Content for Games/etc. / Node editor
November 22, 2016, 01:59:50 PM
For someone wanting to make a node editor for idtech 4 (i can dream) here is a nice one with open source and all.

http://gratin.gforge.inria.fr/#presentation
#13
id Tech 4 Scripting / idtech 4 Vectors?
November 16, 2016, 12:51:54 PM
Cheers people can anyone explain how to use vectors on idtech 4? As always before asking i tried doing it my self and even reading other people code to learn but i'm just not getting anywhere, math was never my strong point,  i'm trying to make a grass system (using script not c++ code) where every grass model shoots a trace downwards and detects the surface below at init() so it gets on the ground and follows the terrain bumps, without the need for me to manually do that, problem i'm totally failing, because i can't seam to shoot a trace straight down for all models using only code, i tried to learn vector math, it seams easy but when i try to implement it in code i fail, all models just shoot the trace in random directions, can anyone with sufficient knowledge about idtech 4 vectors give me some hints?

here is the code that i have for that, is ugly and just me messing around trying everything so have petty.


void grass_sys::alignToFloor(){
vector traceStart;
vector tracEnd;
vector  downVec;
vector  normVec;
vector  traceNormal;
vector traceStartAng;

traceStart = self.getWorldOrigin();

//traceStart = traceStart - getWorldOrigin();

sys.println("tracStart is: " + traceStart);

/*
traceStartAng = sys.VecToAngles(traceStart);
sys.println("tracStartAng is: " + traceStartAng);

normVec = sys.vecNormalize(traceStart);
sys.println("normVec is: " + normVec);
*/

downVec = sys.angToForward(traceStart);
sys.println("downVec is: " + downVec);

tracEnd = traceStart + downVec * 50;
sys.println("tracEnd is: " + tracEnd);

sys.debugArrow('0 1 0', traceStart, tracEnd, 4, 100 );


Also vectors from where i read http://www.wildbunny.co.uk/blog/vector-maths-a-primer-for-games-programmers/vector/ seam to be
QuoteA Vector is a quantity which has both magnitude (size) and direction, but no position
so how does in idtech 4 they do seam to have a position in space? By using getWorldOrigin() or getOrigin() i get a position this tell me they are points in space but that quote implies otherwise, I'm just not comprehending this well or they are different vectors?

How can you visualize a single vector in idtech 4 script? By using debugLine or debugArrow you need two vectors, a start and a end vector, but isn't a single vector already a "arrow"?

Sorry if this are really dumb questions but i'm just ignorant on this stuff and i'm stuck and would like to learn this. 

Thanks.
#14
id Tech 4 Scripting / help with func_animate
September 24, 2016, 06:34:29 PM
Hello again guys like i referred in the "help with script thread" the func_animate object hides it self after playing the "anim1" "anim2" animations how can i disable that? Is it even possible without messing with the engine or game source code?

here is the entity definition.


model env_smwoodTable {
mesh models/md5/furniture/smwoodTable.md5mesh
anim idle models/md5/furniture/smwoodTable_idle.md5anim
anim open models/md5/furniture/smwoodTable.md5anim {
frame 1 sound storagecabinet_open
}
anim close                      models/md5/furniture/smwoodTable_close.md5anim {
frame 1 sound storagecabinet_close
}
}

entityDef env_smwoodTable {
"editor_color" "1 .5 0"
"editor_mins" "-16 -16 0"
"editor_maxs" "16 16 64"

"inhrit"             "func_animate"
"spawnclass" "idAnimated"
"model" "env_smwoodTable"
"frob"                  "1"
"start_anim"            "idle"
"num_anims"             "2"
"wait"                   "-1" //how long to wait before auto activating.  -1 means only activate when triggered.
"anim1" "open"
"anim2" "close"

"combatModel" "1" // collision based on the md5 mesh (bad for performace use AF's when possible)
//"bleed" "0"
//"mtr_wound_metal" "textures/decals/bullethurt"
//"snd_metal" "bullet_impact_flesh"
"sound_bone" "origin"
#15
id Tech 4 Scripting / help with a script
September 24, 2016, 05:15:28 PM
Hello guys can anyone that knows coding and specially doom 3 scripting see why this script of mine is not working? Is a experience of mine about making a mouse over functionality without the need to mess with the source c++ (that i don't really know at all).

First a disclamer i'm not a coder i'm just a noob at c++ coding and at Doom 3 scripting, what you see below is what i came up with, by trial&error, by reading and copypasting from various sources.

Now the important part, the code that doesn't work as i want it, is the entity.setShaderParm() bit, it highlights the object like i want it too, when i mouse over the "frob" object (inspiration from TDM ;p), but when i stop "mouse overing" the object it stays highlighted still, i tried everything some of my tries made me turn on and off the highlight but only when i mouse overed the object again, what i'm i  missing here?

The funny thing is that the code that turns off the test light (that i put for debugging) and the code to activate the func_animate works just fine. Only problem the func_animate hides it self after playing all the animations.

Sorry for the messy code...


////////////////////
//
//    global vars

#define FROB_NONE  0
#define FROB_OVER  1

entity frobEntity; // detected entity with frob enabled
float isOver_obj = false; // Is the player looking to frob object ?
float   command     = FROB_NONE;
vector traceStart, tracEnd;
float useBtn, btn0; // use button for frob, same as attack
//float highlight_on = false;
float parm11_state;
float isPressed = false;
float isFrobable; // check for the frob spwn arg value
///////////////////

/*
============
trace_objs
============
*/
void trace_objs() {



// bind objs to player head position
$ml_start.bindToJoint( $player1, "headcontrol", 1 );
$ml_end.bind($ml_start);



}

/*
void draw_ent_text_type(){
if(isOver_obj == true){
vector bbox_size = frobEntity.getSize();
vector frob_ent_origin = frobEntity.getWorldOrigin();
vector text_origin = frob_ent_origin;
text_origin_z = text_origin_z + bbox_size_z + 30.0f;
string ent_type = frobEntity.getKey("type");
frobObjText = sys.drawText(ent_type, text_origin,0.5,'0 1 0', 1, 1);
}
}*/

/*
void obj_higlight(){

parm11_state = frobEntity.getShaderParm(SHADERPARM_FROB);
sys.println("\n\nInit parm11 value is: " + parm11_state);

if( parm11_state == 0 ){
//highlight_on = false;
frobEntity.setShaderParm(SHADERPARM_FROB, 1);
sys.println("\n\nOff parm11 value is: " + parm11_state);
}
if( parm11_state == 1 ){
//highlight_on = true;
frobEntity.setShaderParm(SHADERPARM_FROB, 0);
sys.println("\n\nON parm11 value is: " + parm11_state);
}

}*/


void mouseOver()
{
traceStart = $ml_start.getWorldOrigin();
//sys.println("\n\ntraceStart value is: " + traceStart);

tracEnd = $ml_end.getWorldOrigin();
//sys.println("\n\ntraceEnd value is: " + tracEnd);

//sys.drawText("end",tracEnd,1,'0 1 0', 1, 1);

useBtn = $player1.getButtons();
btn0 = 1 & useBtn;

sys.trace( traceStart, tracEnd, '0 0 0','0 0 0', MASK_SOLID|CONTENTS_RENDERMODEL, $player1 );

sys.debugLine('0 1 0', traceStart, tracEnd, 1 );

frobEntity = sys.getTraceEntity();
isFrobable = frobEntity.getIntKey("frob");

parm11_state = frobEntity.getShaderParm(SHADERPARM_FROB);
sys.println("\n\nInit parm11 value is: " + parm11_state);

if( !(!frobEntity) && (frobEntity != $world ) ){
if(isFrobable && isOver_obj == false){
isOver_obj = true;
if(parm11_state == 0){
frobEntity.setShaderParm(SHADERPARM_FROB, 1);
}
$test_light.On();
}
if(!btn0){
isPressed = false;
return;
}
if ( btn0 && isPressed == false ){
sys.println("use was pressed.");
isPressed = true;
frobEntity.activate($player1);
}
} else {
$test_light.Off();
if(parm11_state == 1){
frobEntity.setShaderParm(SHADERPARM_FROB, 0);
}
isOver_obj = false;
}

}


void MO_loop_control(){
while( true ){
command = FROB_NONE;
while( command == FROB_NONE){
mouseOver();
sys.waitFrame();

}
}
}

/*
===============
initialisation
================
*/

void main ()
    {
sys.waitFrame(); // wait for init() routines to finish
$player1.disableWeapon();
/*sys.setCamera($cam1);
sys.wait(20);
sys.firstPerson();*/
trace_objs();
//mouseOver();
thread MO_loop_control();
    }



The "SHADERPARM_FROB" is a custom #define in the doom_defs.script not one that exist in vanilla Doom 3.

here is the material of the "frob" object


textures/boat/boat_woodtable
{

wood

qer_editorimage textures/boat/boat_woodtable.tga

diffusemap textures/boat/boat_woodtable.tga
bumpmap textures/boat/boat_woodtable_bump.tga
Specularmap textures/boat/boat_woodtable_s.tga

// This is the code required for frob highlighting this texture
    {
        if ( parm11 > 0 )
        blend       blend
        map         _white
        color       0.99, 0.95, 0.62, 0.25
    }
}




BTW is there a way to attach a object to the player camera (is it even a entity?) and have it follow all the movements of the player camera? looking up and down, sides to sides, etc.

In my script i attach the trace origin to the $player 1 joint (headcontrol) but it is the head of the invisible character (for shadows and mirrors) so it lags behind the cursor and doesn't follow it precisely, but it more or less works . Help on this would also be appreciated. 
#16
welcome, you are from the TDM community aren't you? Btw before this happens, please don't care about the karma points, we add two new users go away because of the negative karma points they are useless, the comments is what matters.    :)
#17
id Tech 6 General Talk / Are the tables Turning?
March 01, 2016, 09:46:55 AM
Where is the world coming to, AMD beats Nvidia on a early Doom 4 benchmark ON OPENGL!!?

http://www.tweaktown.com/news/50737/amd-beats-nvidia-early-doom-benchmarks-dominating-4k/index.html


Now that John is out of the picture and Tiago Sousa from Crytek is working on idtech 6, we see this, makes me think, perhaps we are seeing that John was tweaking things in favor of Nvidia?

What do you guys think?
#18
Haunting of Deck 12 / Re: OW Engine - idTech 3 based
November 07, 2015, 08:38:52 PM
Hey man fantastic work!! Love that you integrated Bullet, is this production ready? Is there some documentation for the engine, can i use the idtech 4 way of developement in this engine? What GUI system does it uses?
#19
Hello guys

Now that dmap is supported on this engine ( thank's trebor !!! ) I'm trying to convert a glsl fresnel to it (because i also don't know how to convert the one made in ARB code) below is the fresnel code, i'm also trying to convert a ice/snow opengl shaders, but everytime i try to dmap a map with the fresnel_vertex.glsl and fresnel_fragment.glsl i get a "warning bad vertexParm number" error.

fresnel_vertex


const float Eta = 0.67;          // Ratio of indices of refraction (air -> glass)
const float FresnelPower = 10.0; // Controls degree of reflectivity at grazing angles

const float F  = ((1.0 - Eta) * (1.0 - Eta)) / ((1.0 + Eta) * (1.0 + Eta));

varying vec3  Reflect;
varying vec3  Refract;
varying float Ratio;

attribute vec3 normal;

uniform vec3 viewer;

void main( void )
{
    vec4 worldPosition = calcWorldPos( gl_Vertex );
    vec3 ecPosition3  = worldPosition.xyz - viewer;

    vec3 i = normalize(ecPosition3);
    vec3 n = normalize( calcWorldVec(normal) );

    Ratio = F + (1.0 - F) * pow((1.0 - dot(-i, n)), FresnelPower);
    //Ratio = 1.0 - Ratio; // Add this line if your cube map is not based on the right side

    Refract = refract(i, n, Eta);
    Refract = vec3(gl_TextureMatrix[0] * vec4(Refract, 1.0));


    Reflect = reflect(i, n);
    Reflect = vec3(gl_TextureMatrix[0] * vec4(Reflect, 1.0));


    gl_Position   = gl_ModelViewProjectionMatrix * worldPosition;
}



fresnel_fragment

varying vec3  Reflect;
varying vec3  Refract;
varying float Ratio;

uniform samplerCube tex0;

void main(void)
{
    vec3 refractColor = vec3 (textureCube(tex0, Refract));
    vec3 reflectColor = vec3 (textureCube(tex0, Reflect));

    vec3 color   = mix(refractColor, reflectColor, Ratio);

    gl_FragColor = vec4(color, 1.0);
}


material calling the fresnel shader

textures/bod/rock/shiny_mot088
{
   surftype10 //tile

   qer_editorimage   textures/bod/rock/mot088_ed.jpg
   {
      blend      bumpmap         
      map         textures/bod/rock/mot088_local.tga
   }
   diffusemap     textures/bod/rock/mot088.tga
   specularmap     textures/bod/rock/mot088_s.tga
   
   {
      blend   blend
      mirrorRenderMap  128  128

      translate   0.5, 0.5
      scale      0.5, 0.5

      vertexProgram   fresnel_vertex.glsl
      vertexParm   Eta 0.67          // Ratio of indices of refraction (air -> glass)
      vertexParm  FresnelPower 10.0 // Controls degree of reflectivity at grazing angles
 
  fragmentProgram fresnel_fragment.glsl
      fragmentMap   tex0   _scratch

      alpha      0.6
   }


I'm a total noob at this shader thing so please be easy with me. :P 
 
#20
Original text by solarsplace (Arx - End of Sun) on  Doom3World with modifications by me (grammatical corrections mostly)


Here are the exact steps needed in order to:

- ingame, walk up to a GUI, set focus on the GUI, click a button and load another level.

This assumes that you know how to get a simple GUI made and into your map.

- for this you need two maps, replace yourmapname1.map and yourmapname2.map with the real names of your maps.

1 - Create a simple GUI to change the level. You can use the following code as a base if you want. This is a very simple GUI with a button on it. when clicked, the "onAction" code triggers a trigger_once entity placed in the yourmapname1.map called "trigger_once_1"



windowDef Desktop
{
   rect 0,0,640,480
     

    windowDef button1
   {
   rect 270,170,100,100
   visible 1

   backcolor 1,0,0,1
   forecolor 1,1,1,1
   textscale 0.1
   textalign 1
   text  "End Level"
   onAction{
         set "cmd" "activate trigger_once_1" ;
   }
   }
}




Save this as change_level.gui or whatever you like.

2 - Create a trigger_once entity in the map and make sure it is called "trigger_once_1" add a key val pair of "call" "next_map"

3 - In the same folder as yourmapname1.map create a text file called yourmapname1.script  and put the following code in it:



void next_map()
{
   sys.print ("\n Now ending this level\n"); //will NOT show this in the console if the next code is successful.
   sys.trigger ($target_endlevel_1);


4 - Create a target_endlevel entity in yourmapname1.map and call it "target_endlevel1" give it a key val pair of "nextMap" "yourmapname2.map" and thats it.


There may very well be a way to do it without using a script file, but using them makes life easier, it permits to write to the console and debug our code and see where it might be going wrong.