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.


Messages - gamenewer

Pages: 1 ... 8 9 [10] 11 12
136
News / Re: Away from keyboard for two weeks
« on: June 14, 2014, 04:33:27 pm »
Have a good time  :)

137
Support / Re: About the object "LookAt" , need help
« on: June 14, 2014, 04:48:46 am »
Thanks for your patient reply,  Maybe   I    find the reason for this issue,    because the car  looks invert ,  I  change the direction(Z) vector as following :

                                SimpleVector posAhead = Interp(lookAheadAmount+percent);
            SimpleVector poscurrent = cube.getTransformedCenter();
            posAhead.sub(poscurrent);
            /*
            the car is invert , if I use   posAhead.scalarMul(-1f); the car looks ok,
            I think  if here is the reason for issue

            */
            posAhead.scalarMul(-1f);
            Matrix rotY=posAhead.getRotationMatrix( new SimpleVector(0,-1,0));
            cube.setRotationMatrix(rotY);


So   I    remove this line : 
                               
                                posAhead.scalarMul(-1f);

In this case , the camera is behind the car , of course ,the car looks invert.  but  a new issue appears,  the distance between car and camera becomes  far and far, and the car out of view at last ,   here is camera postion set code:


                      Camera camera = world.getCamera();
            SimpleVector oldCamPos=camera.getPosition();
            SimpleVector oldestCamPos=new SimpleVector(oldCamPos);
            oldCamPos.scalarMul(9f);

            SimpleVector carCenter=cube.getTransformedCenter();
            SimpleVector camPos=new SimpleVector(carCenter);
            SimpleVector zOffset=cube.getZAxis();
            SimpleVector yOffset=new SimpleVector(0, -10, 0); //-100
            zOffset.scalarMul(-20); //-250

            camPos.add(zOffset);
            camPos.add(yOffset);

            camPos.add(oldCamPos);
           
            camPos.scalarMul(0.1f);

            SimpleVector delta=camPos.calcSub(carCenter);
            //distance between camera and car
            float len=delta.length();

            Logger.log("-->distance between camera and  car --->" +  len ); // the len becomes  biger and biger and  the car out of  view at last
           
                      camera.setPosition(camPos);
            camera.lookAt(cube.getTransformedCenter());


I try to change the  ZOffset  , but  no effect  , distance between camera and car should constant  and  a little  change. Could you help me? Thanks a lot.




I captured  some pictures help me to explain clearn.

[attachment deleted by admin]

138
Support / Re: About the object "LookAt" , need help
« on: June 13, 2014, 02:15:46 pm »
I  dont know why this happen ? the camera should  always behind the car  :(

139
Support / Re: About the object "LookAt" , need help
« on: June 13, 2014, 12:53:24 pm »
Maybe, but when camera behind the car , it follow the car indeed

140
Support / Re: About the object "LookAt" , need help
« on: June 13, 2014, 10:56:11 am »
hello EgonOlsen, I captured some picture for explain my issue,  when car start move , speed from 0 to  maxspeed, the  camera first  at front of car and becomes at behind of car .    The road  path is  closed ( loop) , when car run at the startpoint again  , the  camera will  at  front of car again and at behind the car later. I use the code take from car example desktop, and change some values like this:

 SimpleVector oldCamPos=camera.getPosition();
            SimpleVector oldestCamPos=new SimpleVector(oldCamPos);
            oldCamPos.scalarMul(9f);

            SimpleVector carCenter=cube.getTransformedCenter();
            SimpleVector camPos=new SimpleVector(carCenter);
            SimpleVector zOffset=cube.getZAxis();
            SimpleVector yOffset=new SimpleVector(0, -30, 0); //here changed
            zOffset.scalarMul(-300f); //here changed

            camPos.add(zOffset);
            camPos.add(yOffset);

            camPos.add(oldCamPos);
            camPos.scalarMul(0.1f);

            SimpleVector delta=camPos.calcSub(oldestCamPos);
            float len=delta.length();

            if (len!=0) {
               world.checkCameraCollisionEllipsoid(delta.normalize(), new SimpleVector(10, 10, 10), len, 3);
            }

            camera.lookAt(cube.getTransformedCenter());



BTW,  I move the car only by  set  it's position ,  Is there something wrong ?    Thanks very much for your help  :)

[attachment deleted by admin]

141
Support / Re: About the object "LookAt" , need help
« on: June 13, 2014, 01:51:04 am »
Yes ,  it take from the car example of desktop jPCT,  The issue is  , if the car's speed is slow,  the carmera is  closer to the car , but  if   the speed of car is high , the camera is far   to the car ,   in other words , the distance between camera  and car  is becomes very big , close and far , I hope you  can see  my explain ;)

142
Support / Re: About the object "LookAt" , need help
« on: June 12, 2014, 04:58:25 pm »
If  I   don't use the   camera old position,  the camera looks  not smooth follow the car , this is not my expect ~~

/*
      camPos.add(oldCamPos);
      camPos.scalarMul(0.1f);
*/

143
Support / Re: About the object "LookAt" , need help
« on: June 12, 2014, 03:07:52 pm »
hello , I have a new question ,  camera follow the car use the code as show before ,  if the car speed slow, the camera close to the car ,but if the car speed is  high  ,  the camera is become very far to the  car ,   this is not my expect ,  I  want  the distance between camera and car is suitable, not so far ,  I change the   zOffset.scalarMul(Xf)  , but it seems no effect , How should I do ?  Thanks very much

144
thanks very much ,  I know the function getXAxis  getYAxis  getZAxis  usage, they are used to get the  object  up . right , and forward direction vector , use this can easy do something about object ,  thanks again  :)

145
Support / Re: About the object "LookAt" , need help
« on: June 11, 2014, 07:33:37 am »
Thanks EgonOlsen, Now , the car can run along the road by my desinged path , the camera follow behind the car .

But it  seems the car is static , because the  camera position  is set by car position, I pick  code  from other topic is :

      SimpleVector oldCamPos = camera.getPosition();
      oldCamPos.scalarMul(9f);
      SimpleVector carCenter = car.getTransformedCenter();
      SimpleVector zOffset = car.getZAxis();
      zOffset.scalarMul(-250f);
      SimpleVector camPos = new SimpleVector(carCenter);
      camPos.add(camYOffset);
      camPos.add(zOffset);
      camPos.add(oldCamPos);
      camPos.scalarMul(0.1f);
      camera.setPosition(camPos);
      camera.lookAt(carCenter);

      Is there  some way  to let camera  smooth follow the car ?   Camera have little movement up and down or right to left  ,  thanks a lot ~

146
Thanks for help,  When load a model   , it's have an object-space default   or  should to  do some setting ? 

I attached a picture may help me to explain the problem,  I want the car move by  x axis (or other axis)    a   distance  d (object-space ) , How can I do it ?

another new  question is   :   I have got the point A  , and I know  the  distance   from  A to B , How can I caculate the Point B?   ( In object -space ,   the  direction from A to B is   x axis , you can consider  A is an object ,  I want to get  B,the point at  the object   right direction(x axis or other axis)   , distance is d)   I hope you can see my explain  ;)




[attachment deleted by admin]

147
Support / Re: About the object "LookAt" , need help
« on: June 11, 2014, 06:48:13 am »
thanks for your help , I  change the code like this


//get the car current  position
SimpleVector poscur = car.getTransformedCenter();

//get the car lookat waypoint , the  nav point is ahead of car
SimpleVector posLookat = getLookatwaypoint();

posLookat .scalarMul(-1f);
posLookat .add(poscur );
Matrix rotY=posLookat .getRotationMatrix(new SimpleVector(0,-1,0));
car.setRotationMatrix(rotY);

the car  rotation  and lookat seems  ok , Thank again ~

148
Support / Re: About the object "LookAt" , need help
« on: June 11, 2014, 03:43:15 am »
mmm  , thanks for help , first add waypoint object to  road as child, get the waypoint  position after rotate the road ,this can get postion ok  :)

149
Support / Re: About the object "LookAt" , need help
« on: June 10, 2014, 04:12:31 pm »
And  I   have another question ,    I  put some object on my road to use as "waypoint",  I load the model  and  get the waypoint position like this:

Object3D [] obj = Loader.loadOBJ(res.getAssets().open("road.obj"),null,100f);
int k =0;
 for(int i = 0; i < obj.length; i++){
 if(obj.getName().contains("w.0")){
obj.build();
 waypoint[k++] = obj.getTransformedCenter();                        
}
else if(obj.getName().contains("Plane"))
{
saidao = obj;
Logger.log("get the road!!!!!!");
}
}

saidao.rotateX((float) (Math.PI) / 1f);
....

actually, the waypoint get by this method is not correct , because  the road  rotateX  late !  So the waypoint  must do  some actions  to location correct position, but  I don't know how to to do this , please help me ,  Thank you very much !!


[attachment deleted by admin]

150
Sorry , I  don't know  how to translate from object-space  to world- space or  from world-space to object-space  by jpct-ae,   for example, I want to translate my car   by  it's right  direction  a distance  or  by it's  forward  direction a distance   or rotate a  angle ....    and don't care of world - space,  I look at the doc  and not found about this 

Pages: 1 ... 8 9 [10] 11 12