|
3 registered members (AndrewAMD, Grant, Neb),
908
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Problems with pointers, 2nd model not show
#304025
01/04/10 15:58
01/04/10 15:58
|
Joined: Oct 2009
Posts: 110 Porto-Portugal
Elektron
OP
Member
|
OP
Member
Joined: Oct 2009
Posts: 110
Porto-Portugal
|
I done code for load a terrain and a model but when i tried to show a copy of the model on other position,using pointer, only first model apears. This is my code:
#include <acknex.h>
#include <default.c>
ENTITY* ptr=NULL;
ENTITY* myentity=NULL;
function main()
{
video_screen = 1;//fullscreen
video_mode = 7;
vec_set(screen_color,vector(1,1,1));
vec_set(sky_color,vector(1,1,1));
camera.x=-100;
level_load("");
ENTITY* myterrain = ent_create("small.hmp",nullvector,NULL);
set(myterrain,VISIBLE);
myentity = ent_create("tree.mdl", vector(0,0,50), NULL);
ptr=myentity;
ptr.x=0;
ptr.y=0;
ptr.z=100;
set(ptr,VISIBLE);
camera.x=0;
camera.z=2000;
camera.y=-2000;
camera.pan=90;
camera.tilt=-45;
while(1)
{
wait(1);
}
}
What i am doing wrong? Thanks in advance.
|
|
|
Re: Problems with pointers, 2nd model not show
[Re: Elektron]
#304027
01/04/10 16:25
01/04/10 16:25
|
Joined: Sep 2009
Posts: 987 Budapest
Aku_Aku
User
|
User
Joined: Sep 2009
Posts: 987
Budapest
|
In your code you defined two pointers: ENTITY* ptr=NULL; ENTITY* myentity=NULL;
Pointers aren't objects of the game just memory address storages. Each object that takes place in the memory has a memory address where they can be found. Pointers contain this adresses. Don't mix each other, the object and its address in the pointer. So when you use this code line: you make a copy of the address of the object. You don't have a brand new object, just a new pointer that points to the same object. If you want to make a new object try this:
ptr = ent_create("tree.mdl", vector(0,0,50), NULL);
based on your code and pointers. I hope this will help you.
|
|
|
Re: Problems with pointers, 2nd model not show
[Re: Elektron]
#304049
01/04/10 17:59
01/04/10 17:59
|
Joined: Sep 2009
Posts: 987 Budapest
Aku_Aku
User
|
User
Joined: Sep 2009
Posts: 987
Budapest
|
First of all, if you want to be a 3D engine programmer, you should train yourself in searching for solution on the net. Try to search: - here at this forum, - AUM Online, from 58. issue to the newest one, - all AUM issues in searchable formats, - the online manualand so on. Here is one hit of results of my search: from AUM 19 and search in the page the word: Forest. Here is my advice if you want to organize your trees into an entity forest: create an array of entity pointers and populate that like this in Lite-C:
#define MAX_TREE_NUMBER 1000
ENTITY* forest[MAX_TREE_NUMBER];
var index;
...
function forest_fill() {
var xx=yy=0;
var increase_x=50;
var increase_y=60;
for(index=0; index<MAX_TREE_NUMBER; index++) {
forest[index] = ent_create("tree.mdl", vector(xx,yy,50), NULL);
xx+=increase_x;
yy+=increase_y;
}
The code isn't tested, i just typed in right now... Your reply is welcome, what did you do.
|
|
|
Re: Problems with pointers, 2nd model not show
[Re: Aku_Aku]
#304118
01/05/10 04:08
01/05/10 04:08
|
Joined: Dec 2009
Posts: 128 China
frankjiang
Member
|
Member
Joined: Dec 2009
Posts: 128
China
|
@Aku_Aku Pointers aren't objects of the game just memory address storages.? means ,is it like pointers of .CPP?
//----------------------------------------------- //test.cpp #include <iostream.h> void main(){ int *p; int value = 20; p = &value; //address storages } //-----------------------------------------------
development 3d game is interesting!
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|