it doesnt give me any error, it just doesnt fix the rotation problem :P
Did you set your view matrix to the identity also ?
it doesnt give me any error, it just doesnt fix the rotation problem :P
Did you set your view matrix to the identity also ?
That statement is of no help to me, what errors are you still getting?
The Singleton object instance is globally unique for the class you are making a Singleton.
By nature it had a single instance per application.
You would have to create several duplicate objects to achieve what I think you're after.
You could however have multiple objects stored in a static map within your "Singleton" and access these via some sort of thread ID.
For example:
class SingletonClass
{
public:
static void CreateInstance( unsigned int uiThreadID );
static SingletonClass* Instance( unsigned int uiThreadID );
static void DestroyInstance( unsigned int uiThreadID);
// other stuffs...
private:
static std::map<unsigned int, SingletonClass*> m_smSingletonMap;
// other stuffs...
};
However, you'd need to create and kill the object manually on thread creation and death respectively.
I still think you'd be better served by a single object instance as part of your thread class.
Adam.
Ok, first up, this is probably my mistake, again I'm mainly an OpenGL kind of guy.
The constructor for D3DXMATRIX creates an identity matrix!
D3DXLoadIdentity must have been a function someone has added as a utility function, forget this function call completely, you've already set the identity matrix for current, the D3DXLoadIdentity function call is no longer required.
D3DXMATRIX current = D3DXMATRIX( 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f );
dbSetObjectWorldMatrix ( 1, ¤t );
Adam.
From the Design Patterns book (Gamma, Helm, Johnson, Vlissides):
SINGLETON
-------------------
Intent
Ensure a class has only one instance, and provide a global point of access to it.
As a singleton is globally unique, I assume that what you require would simply be an instance of your object inside the thread class (that isn't based on the Singleton design pattern).
Regards,
Adam
D3DXMATRIX current = D3DXMATRIX( 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f );
Set that matrix as your view matrix before translating your gun in world space.
Adam.
Ok, so I see that D3DXMATRIX has the following constructor:
D3DXMATRIX( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14,
FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24,
FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34,
FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 );
If you call this constructor with the following arguments:
D3DXMATRIX( 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f );
... you will create an identity matrix.
Regards,
Adam
I've not come across dark gdk before so I have done a quick search on google on your behalf.
The function dbMakeVector3 appears to do exactly what it says, it creates a 3D non-homogeneous vector.
To load the identity matrix for current items (and I'm guessing here, as I'm more of an OpenGL guy) you're going to have to set your world matrix to the identity.
For example (after a quick google for dark gdk again):
D3DXMatrix current;
D3DXLoadIdentity( ¤t );
dbSetObjectWorldMatrix( 1, ¤t );
(Based on link)
I'm making an assumption that that clears the camera transform also, if that's controlled by directx's view matrix you may need to load an identity in for that too?
Have a go with the first part and see how it goes from there.
Adam.
Ok, first of all you need to understand what the view frustum is. The view frustum is a volume of 3D space that will contain vertex data that will later be rendered to the screen.
Simply put, the near plane is the closest point that models can be 'seen', the far plane is the furthest point that models can be 'seen' by the camera.
This page should give you a basic idea what this is (check out the image!).
Next, as you're unsure of what a identity matrix actually is, I'm guessing you don't know about matrices.
The best example I can give without going into specifics is that the identity matrix it the transformation that is applied to the vertices that will apply no translation or rotation (i.e. no change).
If you intend to get into 3D graphics programming you're going to need to learn vector and matrix mathematics.
A book I recommend for this is: "3D math primer for graphics and game development" by Fletcher Dunn and Ian Parberry..
I'd also have a look for some 'beginning' books in whatever graphical API you're using.
Also, I'd check out a lot of the free tutorials you'd be able to find through your favourite search engine.
As one last thing, check out the beginnners forums at gamedev.net for games and graphical specific help.
As far as getting the hang of 3D graphics, it can …
First up, have you tried reducing the near plane distance to say 0.1 instead of 1.0, this should reduce clipping?
The alignment problem you're having needn't be one. Here's what you need to do for drawing the weapon:
1. Load the Identity matrix (back to basic transforms here).
2. Translate the weapon slightly into the scene (In opengl you'd translate in the direction of the negative-z axis, in directx the positive)
When you can see the gun in front of you...
3. Translate the weapon down ever so slightly (I'm guessing you're using y-up so -y, but only a small amount)
Finally...
4. Translate the weapon in the x-axis by a small amount depending on which hand you'd like the gun to be in.
Hope this helps.
Adam
I've had a look at re-creating this problem but my compiler (vc++ 9) would only throw a unresolved external for this.
My best guess would be that as the class was not compiled with required functions and the vtable was not created properly for the class(es).
... but I'm a little rusty on this.
Adam.
In probability.cpp try changing the following double f(const double x)
to double Mass1::f(const double x)
.
Adam
I've downloadws today the IronPython. One thing i've noticed that if you type, for example, 5+6 it calculates it..!
So, i tried to do that with my App too, without success...
You should be able to get this going with std::cin.
Here's a quick example:
#include <iostream>
int main()
{
int number1, number2;
char mathsOperator;
std::cout << "Enter a sum. (E.g. '1 + 3')" << "\n";
std::cin >> number1;
std::cin >> mathsOperator;
std::cin >> number2;
std::cout << "\n";
switch( mathsOperator )
{
case '+':
std::cout << "The Answer Is: " << number1 + number2 << "!\n\n";
break;
default:
std::cout << "Invalid Operator!\n\n";
break;
};
}
I'll let you add the other operators. :)
All the best,
Adam
Ancient Dragon: I think he's talking about a 3d game of the first person shooter game type.
tomtetlaw: If you have the gun rendering already, simply align the model with the direction of the camera, slightly offset the position of it and you should be away.
Best of luck!
Adam
You should change the array definition to this:
int a[3];
...and the allocation to this:
a[0] = 1
a[1] = 2
a[2] = 3
If you require dynamically sized arrays you should read into dynamic memory allocation with C++.
Regards,
Adam
Edit: or use a std::vector
Wa-hoo first solve!
I'm a little suspicious of the line in red below too.
I would have to agree. The method for generating your random number is quite odd.
A simple if( rand()%100 < 10 ) would be enough to produce a pseudo 10% chance.
mattwaab: Pleased to hear you managed to solve your problem though!
Cheers,
Adam
As I'm guessing you've not got the headers for the video driver dll's or some kind of SDK for your video device....
If you have the device running with a driver already you should be looking at the following:
1. DirectShow SDK
-- Old but still useful for accessing video devices.
2. Windows Media SDK
-- I've not used this but it's the updated version of the above that microsoft recomend for interfacing with video devices in windows vista.
(Both work.)
If you have no drivers for your device:
3. Go download them from the product's site.
4. Write your own windows drivers for the device. (See Windows Driver Development Kit (DDK), Windows Driver Kit (WDK), Windows Driver Foundation (WDF))
From your phrasing of the question I'd imagine driver development was going to be over your head (no offense intended). If you already have a driver and would only like to write your own application, check out the first two options I've listed above.
Learning to write filter graphs from a beginners point of view can be quite a daunting task and if you fall into this category I'd advise you need a fair amount of time to write this applicaiton.
If I've completely misunderstood the point you've made please forgive me, I'm going to be blaming the pub and beer :)
Cheers,
Adam
Hey,
What it looks like is probably happening is that you are overwriting previously set mines.
For example, You set a mine (to true) on the first iteration of your outer while loop at (2, 2).
However, at the end of this first iteration you have not placed enough mines. Due to this you have a second iteration.
One failed circumstance is that on the second pass the randomly generated condition returns false over a previously true mine location, thus removing it from the grid.
The second failed circumstance is that on the second iteration of the while loop the same cell (2,2) is set to true again and your code decreases the number of mines to place.
Ok, things to change:
1. The mine grid should initially all be set to false, i.e. no mines are present.
2. There is no need for the second if statement.
3. Before line 20 add the following line:
if( mine[r][c] )
continue;
An interesting method of generating a random number I might add. However, the above three points should be enough to get you going.
All the best,
Adam
Edit: Also put the lines 32 and 33 inside your if true condition.
First of all, I'd advise writing the comparison to remove even numbers as something like this:
if( (*it) % 2 == 0 )
(I know both work, but this tends to be clearer.)
Ok, you've correctly identified the problem, in your debugger have you checked the value of count?
You'll probably find that this value is putting your iterator out of the range of your vector, i.e. you have 50 elements in the array, and you've asked your iterator to access element 51 of your vector (which doesn't exist).
That should be enough to get you moving forward,
All the best,
Adam
Hey Adam, I tried this code(with the alteration of it++) in place of the for loop. But i keep getting the same error. Do i have to replace any other part of the code?
Could you post what you've got so far with changes made so I can see where you're at?
Code Error
The code should have read:
it = (buffer.begin()+count); while( it != buffer.end() ) { if ((*it)%2) { it = buffer.erase(it); // this increments for you! } else { // edit: the following line previously read 'iter++' ( my bad :o) ) it++; // if we don't erase just keep going through the list! } }
The problem occurrs first on about line 31. (Then a few more times later)
What's happening here is you are erasing the iterator it. This makes it invalid!
Following this your for loop attempts to call the incremental operator '++', however, now the iterator is invalid, the operation will fail, causing the assertion error you're having problems with.
If you check the documentation for std::vector<T>::iterator::erase(...) you will see that erase as a function returns the next element.
Due to this, a better way of performing this for loop(s) would be to use a while loop like this:
it = (buffer.begin()+count);
while( it != buffer.end() )
{
if ((*it)%2)
{
it = buffer.erase(it); // this increments for you!
}
else
{
iter++; // if we don't erase just keep going through the list!
}
}
Hope this helps.
Regards,
Adam