3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: 1 [2] 3 4 ... 10

Author Topic: MouseLook, WASD drive  (Read 13078 times)

« Reply #15 on: February 02, 2013, 07:15:35 PM »
i couldn't notice any proportional speed when using the gamepad.

but it may just be that the carboat is moving quite slow and hard to notice...
« Reply #16 on: February 02, 2013, 08:21:20 PM »
I don't think you should commit a model to my design just yet. It should probably be the other way around, especially if you got a perticular kind of tank in mind.
Since I got this ahk script working nicely now, I'm adding a bunch more wheels.
« Reply #17 on: February 02, 2013, 10:02:17 PM »
You do the tank anyway it works for you.. i'll design the tank parts as needed.

Here are some screen caps ..

I'm redesigning the landscape which is BIG to smooth it out and a retexturing job -

















« Last Edit: February 02, 2013, 10:16:52 PM by TinSoldier »
« Reply #18 on: February 03, 2013, 01:42:33 PM »
wow, looks pretty good!
is this going to be like that tanki online mmo?

( www.tankionline.com  )
« Reply #19 on: February 03, 2013, 04:07:44 PM »
Got a nice zoom system now, and also fixed the firing impact point determination thing. A scan is first done from the gun to where the camera's looking, and obstacles are hit.
It performs nicely now, but I should now untangle the code, and will probably break it in the process, so I'll attach the project as a checkpoint as well as a teaser.
« Reply #20 on: February 03, 2013, 05:04:13 PM »
Sweet  it just keeps getting better & better :)

I like the mouse zoom, nice job.

Just a note..

The over-all size of the tank/boat is getting a little large, i hope making it smaller wont through off the scriping ?
« Reply #21 on: February 03, 2013, 05:21:59 PM »
also

The car/boat is still a little light on it's feet, it's turning around like it's floating almost...

Not sure if that's because you haven't finished the handling / driving / controls just yet or not ?
« Reply #22 on: February 03, 2013, 05:28:07 PM »
I like the mouse zoom, nice job.
Thanks :)

Moving the wheels would throw off the physics a little, but they're off anyway, as you noticed ... what width/length should the wheels be apart, and what radius, to fit your model? Or, you could post your model and then I'd use it instead of the boat.
Is there a particular kind of tank you've got in mind?

You've probably read this thread - I wonder if just one rigged skinmesh for the whole tank and treads could be used, with nodes in the skinmesh that could be linked/positioned to the wheels' positions. I think ragdoll simulation does something similar.
« Last Edit: February 03, 2013, 06:00:01 PM by chronocide »
« Reply #23 on: February 03, 2013, 06:18:34 PM »
I can include the tank
« Reply #24 on: February 03, 2013, 06:45:50 PM »
That's about the size of the sportscar. It's a small tank.
Any chance you know how to make a matching rigidbody?
« Last Edit: February 03, 2013, 06:48:48 PM by chronocide »
« Reply #25 on: February 03, 2013, 07:29:34 PM »
Heres the rigidbody version.

It's the same zip file updated and added the rigidbody parts

so just over-write/replace the skinmesh parts when unzipping
« Reply #26 on: February 04, 2013, 02:35:13 AM »
Done for now. Check it out.

I like it. Is it gonna be a custom concept tank, or something real-world?
« Last Edit: February 04, 2013, 06:48:47 AM by chronocide »
« Reply #27 on: February 04, 2013, 12:25:31 PM »
Custom tank

TY for the time & trouble, i've got something to work with. Lets see where it gets me :)
« Reply #28 on: February 04, 2013, 05:13:02 PM »
No problem.
I updated the turret control script. Fixes the sprite for the turret's look-at point, so it doesn't freeze when looking to the sky. Also makes explosions in the sky too.
Maybe for a final multiplayer product, explosions could be scheduled in a list, delayed by distance.
Code: [Select]
/// objects script interfaces with

int objTarget= OBJ_308;

int objTurret= OBJ_0;
int objGun= OBJ_22;

int objCar= OBJ_44;
int objCam= OBJ_66;

int objSprite= OBJ_352; // i3DLocationToScreen(Vector3,Vector3,Int Object)

// objects to test with iObjectScan in bool scanFromObject(int obj)
int objTerrain= OBJ_88;
int objBall= OBJ_132;
int objRandomCar= OBJ_264;
int objRandomCar2= OBJ_286;
int[] testObj= {objTerrain, objBall, objRandomCar, objRandomCar2};

int objPrnDist= OBJ_176;



void boom(Vector3 loc) {objPos(OBJ_220, loc);iObjectStart(OBJ_220);} // position and trigger explosion sound

void valPrnDistance(float v){OUT_176= v;};

void spriteToTarget() {
float s=0.5;

Vector3 vScreenCoords;

i3DLocationToScreen(vScreenCoords, contactPoint, objCam);

iObjectLocationSet(objSprite, vScreenCoords);
float dx= iFloatAbs(vScreenCoords.x);
float dy= iFloatAbs(vScreenCoords.y);
s= iFloatSqrt(dx*dx+dy*dy);
s= (s<1)?(1.0-s)/2.0+0.5:0.5;

s= iFloatSqrt(s);
iObjectScaleSet(objSprite, vecLen(Vector3(1,1,1), 1.7*s));
OUT_352= s;
OUT_353= s;
OUT_354= 1.0-s;
OUT_355= 1.0-s;
}


///

Vector3 vecLen(Vector3 v, float l) {iVectorLengthSet(v,v,l);return v;}
Vector3 vNorm(Vector3 v) {iVectorLengthSet(v,v,1);return v;}
Vector3 vecRot(Quaternion q, Vector3 d) {Vector3 r;iVectorRotate(r,d,q);return r;}
Vector3 objPos(int obj) {Vector3 l; iObjectLocation(obj, l); return l;}
Vector3 objPos(int obj, Vector3 v) {iObjectLocationSet(obj, v); return v;}
Quaternion objRot(int obj) {Quaternion q; iObjectOrientation(obj, q); return q;}
Quaternion qMul(Quaternion q1, Quaternion q2) {Quaternion qt;iQuaternionMultiply(qt,q1,q2);return qt;} // q1+q2
Quaternion qDelta(Quaternion q1, Quaternion q2) {return qMul(q1, qInv(q2));} // q1-q2
Quaternion qInv(Quaternion q) {return Quaternion(q.x,q.y,q.z,-q.w);} // -q
float angleWrap(float a) {while (a<-180) a+=360; while (a> 180) a-=360; return a;}
float sign(float n){return n<0?-1:n>0?1:0;}

Quaternion VectorOrientation(Vector3 v){
Vector3 v1,v2;
iVectorLengthSet(v1,v,1);
iVectorLengthSet(v2,v,2);
return QuatGetLookAt(v2-v1);
}
Quaternion QuatGetLookAt(Vector3 direction){
Vector3 up = Vector3(1,0,0); 
Quaternion orientation;
iQuaternionLookAt(orientation,direction,up);
return orientation;
}
float asin(float value) { // aka, R_asin
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"asin",0);
float f = iDLLArrayGet(0);
return f;
}
float acos(float value) { // aka, R_acos
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"acos",0);
float f = iDLLArrayGet(0);
return f;
}
float atan2(float value1, float value2) { // aka, R_atan2
iDLLArraySet(0,value1); iDLLArraySet(1,value2);
iDLLCall(MathDLLHandle,"atan2",0);
return iDLLArrayGet(0);
}

///
/// GForceImposters


int[] gfiObj= {OBJ_242, OBJ_154, OBJ_198}; // particles & G-Force
int gfiObjs;

Quaternion qGFI;
void GForceImposters_init() {
gfiObjs= gfiObj.length();

for(int j=0;j<gfiObjs;j++) {
iObjectImpostersCreate(gfiObj[j],1);
iObjectImposterHide(gfiObj[j],0);
}

iObjectOrientation(gfiObj[1],qGFI);
}
void GForceImposters_deInit() {for(int j=0;j<gfiObjs;j++) iObjectImpostersDestroy(gfiObj[j]);}
void GForceImposters() {
for(int j=0;j<gfiObjs;j++) { // position & show imposters
iObjectImposterSet(gfiObj[j],0,qGFI,contactPoint);
iObjectImposterShow(gfiObj[j],0);
}

boom(contactPoint);
}

bool key, _key, rKey;
bool triggered() {_key= (IN_110 > 0); rKey= _key and not key; key= _key; return rKey;}


/// scanFromObject
///

float scanRange= 2048;
Vector3 contactPoint, contactNormal;
float contactDist;
bool scanFromObject(int obj) {
bool contacts;
Vector3 scanOrigin= objPos(obj);
Quaternion q= objRot(obj);

Vector3 vScan= vecLen(vecRot(q, Vector3(0,0,1)), scanRange);
contacts= false;
contactDist= -1;
contactPoint= scanOrigin+vScan;

Vector3 rContactPoint, rContactNormal;
float dist;
int arrayLen= testObj.length(), i, nContacts;
for(i=0;i<arrayLen;i++)
if (iObjectScan(testObj[i], scanOrigin, vScan, 0, rContactPoint, rContactNormal)) {
bool isCloser= contactDist>(dist= iVectorLength(scanOrigin-rContactPoint));
if ((!contacts) or isCloser ) {
contactDist= dist;
contacts= true;
contactPoint= rContactPoint;
contactNormal= rContactNormal;

nContacts+= 1;
}
}
   
return contacts;
}

///
/// setTurretRotation
// Actuate hinge motors to rotate the turret and pitch the barrel

void setTurretRotation() {
Vector3 v;
float AngleX, AngleY;

v= vecRot(qDelta(qTarget, objRot(objTurret)), Vector3(0,0,1));
AngleY= 15*angleWrap(57.29578231*atan2(v.x, v.z));

v= vecRot(qDelta(qTarget, objRot(objGun)), Vector3(0,0,1));
AngleX= 15*angleWrap(57.29578231*atan2(v.y, v.z));

if (iFloatAbs(AngleX)>60) AngleX= sign(AngleX)*60;
if (iFloatAbs(AngleY)>60) AngleY= sign(AngleY)*60;

AngleX= iFloatAbs(AngleY)<120?AngleX*((120.0-iFloatAbs(AngleY))/120.0):0;

OUT_310= AngleY;
OUT_332= AngleX;
}


///
/// Turret Control

Quaternion qTarget;
int MathDLLHandle=0;   //   atan2 needs RadMath2.dll
void Main() {            ///   Main   
if(iInitializing()) {
MathDLLHandle = iDLLLoad(".\\3DRad_res\\objects\\Script\\RadMath2.dll");
if (MathDLLHandle==0)
MathDLLHandle = iDLLLoad(".\\3DRad_res\\objects\\Script\\RadMath.dll");

qTarget= objRot(objCar);
GForceImposters_init();
} else if (iDeinitializing()) {
if (MathDLLHandle != 0) iDLLUnload(MathDLLHandle);
GForceImposters_deInit();
} else if (MathDLLHandle != 0) {
// Determine position and distance of what's at screen center
Vector3 targetContactPoint;
float targetDistance;
if (scanFromObject(objCam)) {
valPrnDistance(targetDistance);
iObjectShow(objPrnDist);
} else
iObjectHide(objPrnDist);
targetContactPoint= contactPoint;
targetDistance= contactDist;

// qTarget= (targetDistance>-1) ? VectorOrientation(vNorm(targetContactPoint-objPos(objTurret))) : objRot(objCam);
qTarget= VectorOrientation(vNorm(targetContactPoint-objPos(objTurret)));

setTurretRotation();

// Determine position and distance of what the cannon is aimed at
scanFromObject(objGun); // get impact point
spriteToTarget();

// if firing a shot, not at nothing, create an explosion where the cannon is aimed
if (triggered()) // and targetDistance>-1)
GForceImposters();   // create explosion at target point
}
}
Side note: At a range of 4096, explosions weren't visible in some parts of the sky. The sky is indeed a box. And we're on a turtle. A really big turtle. Ok not that big.
Seems to be a box between 7000 and 8000 units in diameter. File that under trivia.
« Last Edit: February 04, 2013, 05:29:40 PM by chronocide »
« Reply #29 on: February 04, 2013, 06:32:56 PM »
Excellent Job.
Pages: 1 [2] 3 4 ... 10