Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Beginner help [C#]  (Read 638 times)
Virr3
Community Member
*
Posts: 2


« on: April 20, 2008, 02:58:14 PM »

Hi, i need some help with a few questions.

First of all, how to change the viewrange? You know the distance you can see.

Second, how do i write text? like, if i want some text in the top right corner of the screen all the time. similar to the displayfps, but with a text.

And one more thing, if i want the camera to move in the same direction as it pointing, how do i do that? I mean, if you look yo and push forward, you shuld go up, and if you push back vice versa, if you look right, you shuld walk right.

Thanks in advance, Viktor.
« Last Edit: April 20, 2008, 02:59:52 PM by Virr3 » Logged
JukkaKevät
Customers
Community Member
*****
Posts: 182


« Reply #1 on: April 21, 2008, 01:28:29 AM »

Here's some quick answers:

You can set the min / max viewrange and field of view with the following camera method:
Camera.SetViewFrustum(fov, farplane, nearplane)

Usually set to something like (90,1000,0.1)

You can write text to screen with TVScreen2DText object. Something like:
Code:
-> initialization:
dim screentext as TVScreen2DText
screentext = new TVScreen2DText
-> in renderloop:
screentext.Action_BeginText()
screentext.TextureFont_DrawText("text", posx, posy, Globals.RGBA(1, 1, 1, 1))
screentext.Action_EndText()
sorry this is in Visual Basic syntax

Camera can be moved (any mesh also) how you want with:
Camera.MoveRelative(front/back,up/down,left/right)


Hope these helps.
Logged
Lyrical
Customers
Community Member
*****
Posts: 460


WWW
« Reply #2 on: April 21, 2008, 04:22:53 AM »

Hello Virr3,

Here are some of my inital projects. These arenotfull tutorials but the are set in order to show you how to add various techniques using TV3D.

This is the inital template, it has all the basic structures
http://www.fastrightstudios.co.uk/tv3d/initialtemplate.zip

Adding abasic floor with some stock objects
http://www.fastrightstudios.co.uk/tv3d/FloorwithBasicObjects.zip

Add FPS style camera movement
http://www.fastrightstudios.co.uk/tv3d/CameraMovement.zip

Adding textures
http://www.fastrightstudios.co.uk/tv3d/FloorwithBasicObjects.zip

Adding some lights
http://www.fastrightstudios.co.uk/tv3d/AddLights.zip

These are based on TV3D 6.5 these are full projects and all files are included
i hope these get you going and these projects may also have the Fonts code that
JukkaKevät showed.

I never released these projects as tutorials as i didn't like the structure i used but
here they are for you to get started with and learn TV3D.

PM me ifyou get stuck

Happy coding
Logged
Virr3
Community Member
*
Posts: 2


« Reply #3 on: April 21, 2008, 04:15:24 PM »

Thanks alot for the template and all the other files.

Now when i have looked at your code and seen how you have solved some of the problems i got
i now know how to add like cylinders and so on. Im going to try more how to use the text and
that kind of stuff later on.

Now though, i want to know more about Collision Detection.

I got a simple room, four walls and two floors(one is roof of course), added some textures on to that, and made it look like a proper room.

I got the original code from a tutorial, so i have som problems with understanding all the code.

I have undesrtood that this is the part that i have to use, thats pretty obvious.
Sadly, how to modify it so its works for me isnt that obvious for me.

This is the code i am talking about:
Code:

DxVBLibA.D3DVECTOR linestart;
DxVBLibA.D3DVECTOR lineend;
float distance;

if (Room.Collision(ref linestart,ref lineend,CONST_TV_TESTTYPE.TV_TESTTYPE_BOUNDINGBOX,ref distance)== true)
   {
      //What to write here to make tha camera stop?
   }

What exactly is linestart and lineend? and what does CONST_TV_TESTTYPE.TV_TESTTYPE_BOUNDINGBOX do?

And what is it collideing to? i mean, if i got like a box in the middle of my room, and i want it to stop if it collide with the walls but go steight trough the box. How do i do that?

The second problem i got is what to write inside? i figure that i could take the value that i got from my key-input and just use the opposite value. (if it is negative, then i just add the same value but positive) but that isnt the way it shuld be done is it?
Logged
Lyrical
Customers
Community Member
*****
Posts: 460


WWW
« Reply #4 on: April 22, 2008, 05:58:22 AM »

what you really need to be looking at is the physics side in TV3D 6.5 this will handle the collision detection for you, However there is a learning curve to using it and i don't have a simplified demo to show you unfortunatly.

The code you are looking at is a Raycast, imagine draing a line from yourself to the wall
you are the startpoint and the end point is a set range away from you.

If the wall is in this range you will get a collision and a distance is stored here "ref distance" if this distance is say < 1 then you can stop the moveforward code otherwise you are ok to move forwards.




Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks