Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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 Offline OP
Member
Elektron  Offline 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:
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.


Carlos Ribeiro aka Elektron
Check my blog: http://indiegamedeveloper71.wordpress.com/
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 Offline
User
Aku_Aku  Offline
User

Joined: Sep 2009
Posts: 987
Budapest
In your code you defined two pointers:
Quote:
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:
Quote:
ptr=myentity;

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:
Code:
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: Aku_Aku] #304041
01/04/10 17:29
01/04/10 17:29
Joined: Oct 2009
Posts: 110
Porto-Portugal
Elektron Offline OP
Member
Elektron  Offline OP
Member

Joined: Oct 2009
Posts: 110
Porto-Portugal
Thank you Aku_Aku, i understand your idea.
But if i want to make a forest of trees (models) using your way it will use much memory and it will be boring to code.
I would like something like array of pointers pointing for the model tree but with diffrent x,y & z values.
Anyone have better system?


Carlos Ribeiro aka Elektron
Check my blog: http://indiegamedeveloper71.wordpress.com/
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 Offline
User
Aku_Aku  Offline
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 manual
and 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:
Code:
#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 Offline
Member
frankjiang  Offline
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!
Re: Problems with pointers, 2nd model not show [Re: frankjiang] #304123
01/05/10 08:20
01/05/10 08:20
Joined: Sep 2009
Posts: 987
Budapest
Aku_Aku Offline
User
Aku_Aku  Offline
User

Joined: Sep 2009
Posts: 987
Budapest
IMHO, yes.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1